UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

45 lines (44 loc) • 2.02 kB
import { c as normalizeOptionalLowercaseString, l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs"; import { x as resolveSessionAgentId } from "./agent-scope-config-DmXgFGKP.mjs"; import "./agent-scope-BwB8YH6y.mjs"; import { a as stripMentions } from "./mentions-CACvAvae.mjs"; import { n as isAbortRequestText } from "./abort-primitives-Bk9blQey.mjs"; //#region src/auto-reply/reply/abort.ts function formatAbortReplyText(e, t, n, r) { const i = n !== void 0 && n > 0 ? ` Cancellation was incomplete for ${n} sub-agent${n === 1 ? "" : "s"}. Retry /stop.` : ""; const a = r && !t ? " Cancellation requested; the local model may still be finishing." : ""; const o = t === "finalizing" ? "Agent reply is already finalizing and can no longer be aborted." : "⚙️ Agent was aborted."; if (e === void 0 || e <= 0) return `${o}${i}${a}`; return `${o} Stopped ${e} ${e === 1 ? "sub-agent" : "sub-agents"}.${i}${a}`; } /** Normalize ingress once; current authorization belongs to the loaded operation. */ function resolveFastAbortRequest(e) { const { ctx: t, cfg: n } = e; const r = normalizeOptionalString(t.SessionKey) ?? normalizeOptionalString(t.ParentSessionKey); const i = normalizeOptionalString(t.CommandTargetSessionKey) ?? r; const resolveTargetAgentId = () => resolveSessionAgentId({ sessionKey: i ?? t.SessionKey ?? "", config: n, fallbackAgentId: t.AgentId }); const a = t.commandText; const o = normalizeOptionalLowercaseString(t.ChatType) === "group" ? stripMentions(a, t, n, resolveTargetAgentId()) : a; if (!isAbortRequestText(o)) return; return { commandSessionKey: r, targetKey: i, resolveTargetAgentId }; } async function tryFastAbortFromMessage(e) { const t = resolveFastAbortRequest(e); if (!t) return { handled: false, aborted: false }; e.onAbortRequest?.(); const { executeFastAbortRequest: n } = await import("./abort-operation-Eq7FmUFe.mjs"); return n(e, t); } //#endregion export { tryFastAbortFromMessage as n, formatAbortReplyText as t };