openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
4 lines • 2.18 kB
JavaScript
import{l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{t as normalizeAnyChannelId}from"./registry-normalize-BP0gv89S.mjs";import{t as getChannelPlugin}from"./registry-CpNh6QcT.mjs";import"./plugins-DxOycUNJ.mjs";import{o as listSessionBindingsBySessionsAsync}from"./session-binding-service-TO5btU7E.mjs";import{n as commandReply}from"./command-gates-BMLoLImo.mjs";import{t as formatRunLabel}from"./subagents-utils-DIUUY_Qm.mjs";import{n as resolveCommandSurfaceChannel,t as resolveChannelAccountId}from"./channel-context-LmUxaNH5.mjs";
//!src/auto-reply/reply/commands-subagents/action-agents.ts
function supportsConversationBindings(e){const t=normalizeAnyChannelId(e);if(!t)return false;return getChannelPlugin(t)?.conversationBindings?.supportsCurrentConversationBinding===true}async function handleSubagentsAgentsAction(e){const{params:t,requesterKey:n,readContext:r}=e;const i=resolveCommandSurfaceChannel(t);const a=resolveChannelAccountId(t);const o=supportsConversationBindings(i);const{latest:s,active:c,recent:l}=r.list.view;const u=await listSessionBindingsBySessionsAsync([n,...s.map(e=>e.childSessionKey)]);t.command.assertOwnerCurrent?.();const resolveSessionBindings=e=>(u.get(e)??[]).filter(e=>e.status===`active`&&e.conversation.channel===i&&e.conversation.accountId===a);const d=new Map([...c,...l].map((e,t)=>[e.childSessionKey,t+1]));const f=new Set(c);const p=s.filter(e=>f.has(e)||resolveSessionBindings(e.childSessionKey).length>0);const m=[`agents:`,`-----`];if(p.length===0)m.push(`(none)`);else for(const e of p){const t=resolveSessionBindings(e.childSessionKey)[0];const n=t?`binding:${t.conversation.conversationId}`:o?`unbound`:`bindings unavailable`;const r=d.get(e.childSessionKey);const i=r?`${r}.`:`-`;m.push(`${i} ${formatRunLabel(e)} (${n})`)}const h=resolveSessionBindings(n).filter(e=>e.targetKind===`session`);if(h.length>0){m.push(``,`acp/session bindings:`,`-----`);for(const e of h){const t=normalizeOptionalString(e.metadata?.label)??e.targetSessionKey;m.push(`- ${t} (binding:${e.conversation.conversationId}, session:${e.targetSessionKey})`)}}return commandReply(m.join(`
`))}export{handleSubagentsAgentsAction};