UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.17 kB
import{a as asOptionalRecord}from"./record-coerce-BTbqdJ3-.mjs"; //!src/agents/command/attempt-callbacks.ts function resetAgentAttemptLifecycle(e){e.lifecycleError=void 0;e.lifecycleErrorObservation=void 0;e.lifecycleFinishing=false;e.lifecycleEnded=false}function emitAgentAttemptRuntimeStart(e,t){if(e.phase===`assistant_output_started`||e.phase===`tool_execution_started`)t({stream:`lifecycle`,data:{phase:`start`}})}function createAgentAttemptLifecycleCallbacks(e,t){return{onAttemptStart:()=>resetAgentAttemptLifecycle(e),onAttemptTerminalReplaced:()=>{if(!e.lifecycleEnded)resetAgentAttemptLifecycle(e)},onAgentEvent:n=>{if(n.stream!==`lifecycle`||typeof n.data?.phase!==`string`)return;if(n.data.phase===`start`){resetAgentAttemptLifecycle(e);return t?.()}if(typeof n.data.error===`string`&&n.data.error.trim()){e.lifecycleError=n.data.error;e.lifecycleErrorObservation=asOptionalRecord(n.data.errorObservation)}if(n.data.phase===`finishing`){e.lifecycleFinishing=true;return}if(n.data.phase===`end`||n.data.phase===`error`)e.lifecycleEnded=true}}}export{emitAgentAttemptRuntimeStart as n,resetAgentAttemptLifecycle as r,createAgentAttemptLifecycleCallbacks as t};