openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
48 lines (47 loc) • 2.46 kB
JavaScript
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs";
import { t as normalizeAnyChannelId } from "./registry-normalize-guW5_4yo.mjs";
import { t as getChannelPlugin } from "./registry-ByqVE5S3.mjs";
import "./plugins-BoMiRtiY.mjs";
import { o as listSessionBindingsBySessionsAsync } from "./session-binding-service-Bn-zGfS9.mjs";
import { n as commandReply } from "./command-gates-BZ-IYgiD.mjs";
import { t as formatRunLabel } from "./subagents-utils-DutCBnyZ.mjs";
import { n as resolveCommandSurfaceChannel, t as resolveChannelAccountId } from "./channel-context-C0btiqLS.mjs";
//#region 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("\n"));
}
//#endregion
export { handleSubagentsAgentsAction };