UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 919 B
import{o as resolveGlobalSingleton}from"./global-singleton-DolL9xGt.mjs";import{AsyncLocalStorage}from"node:async_hooks"; //!src/cli/failure-context.ts const failureContext=resolveGlobalSingleton(Symbol.for(`openclaw.cliFailureContext`),()=>new AsyncLocalStorage);const getCliFailureContext=()=>failureContext.getStore()?.active;function installProcessFailureListener(e,t){const n=resolveGlobalSingleton(Symbol.for(`openclaw.processFailureListener.${e}`),()=>{const n={handle:t,listener:(...[t])=>{(getCliFailureContext()?.[e]??n.handle)(t)}};return n});n.handle=t;const r=getCliFailureContext();if(r)r[e]=t;if(!process.listeners(e).includes(n.listener))process.on(e,n.listener);return n.listener}async function withCliFailureContext(e){const t={active:{}};try{return await failureContext.run(t,e)}finally{t.active=void 0}}export{installProcessFailureListener as n,withCliFailureContext as r,getCliFailureContext as t};