UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

41 lines (40 loc) • 1.93 kB
import { o as normalizeLowercaseStringOrEmpty } from "./string-coerce-CCIiB4H7.mjs"; import { E as parseStrictNonNegativeInteger } from "./number-coercion-D6u-4YD8.mjs"; import { n as extractTextFromChatContent } from "./chat-content-Dkam4EQe.mjs"; import { n as stripToolMessages, t as extractStoredAssistantText } from "./chat-history-text-DLO39FNc.mjs"; import { t as bindAgentToolGatewayRequest } from "./in-process-gateway-Cy0xoBmg.mjs"; import { n as commandReply } from "./command-gates-BZ-IYgiD.mjs"; import { t as formatRunLabel } from "./subagents-utils-DutCBnyZ.mjs"; import { n as resolveSubagentEntryForToken } from "./shared-DvY0vqro.mjs"; //#region src/auto-reply/reply/commands-subagents/action-log.ts async function handleSubagentsLogAction(e) { const { readContext: t, restTokens: n } = e; const r = n[0]; if (!r) return commandReply("📜 Usage: /subagents log <id|#> [limit]"); const i = n.some((e) => normalizeLowercaseStringOrEmpty(e) === "tools"); const a = n.slice(1).find((e) => parseStrictNonNegativeInteger(e) !== void 0); const o = parseStrictNonNegativeInteger(a); const s = o === void 0 ? 20 : Math.min(200, Math.max(1, o)); const c = resolveSubagentEntryForToken(t.list.view, r); if ("reply" in c) return c.reply; const l = await bindAgentToolGatewayRequest({ hostedOnly: true })({ method: "chat.history", params: { sessionKey: c.entry.childSessionKey, limit: s } }); const u = Array.isArray(l?.messages) ? l.messages : []; const d = i ? u : stripToolMessages(u); const f = []; for (const e of d) { const t = e.role === "assistant"; const n = extractTextFromChatContent(t ? extractStoredAssistantText(e) : e.content); if (!n) continue; f.push(`${t ? "Assistant" : "User"}: ${n}`); } const p = `📜 Subagent log: ${formatRunLabel(c.entry)}`; return commandReply(`${p}\n${f.join("\n") || "(no messages)"}`); } //#endregion export { handleSubagentsLogAction };