openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.69 kB
JavaScript
import{c as normalizeOptionalLowercaseString,l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{x as resolveSessionAgentId}from"./agent-scope-config-CG9CFpGX.mjs";import"./agent-scope-Dw5XRSEh.mjs";import{a as stripMentions}from"./mentions-2eKnPtcO.mjs";import{n as isAbortRequestText}from"./abort-primitives-xQnbcbYh.mjs";
//!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}`}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-OpRjQlR8.mjs`);return n(e,t)}export{tryFastAbortFromMessage as n,formatAbortReplyText as t};