UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.27 kB
import{o as resolveGlobalSingleton}from"./global-singleton-DolL9xGt.mjs";import{o as getAsyncWorkSignal}from"./async-work-scope-DBcxYU4O.mjs";import{i as withGuardedFetchRequestAuthority}from"./fetch-request-authority-BTQz0YES.mjs";import{AsyncLocalStorage}from"node:async_hooks"; //!src/agents/agent-bundle-mcp-request-context.ts const requestSignals=resolveGlobalSingleton(Symbol.for(`openclaw.sessionMcpRequestSignal`),()=>new AsyncLocalStorage);function getSessionMcpRequestSignal(){const e=requestSignals.getStore();const t=getAsyncWorkSignal();return e&&t?AbortSignal.any([e,t]):e??t}function runWithSessionMcpRequestSignal(e,t){return e?requestSignals.run(e,t):t()}const callAuthorities=resolveGlobalSingleton(Symbol.for(`openclaw.sessionMcpToolCallAuthority`),()=>new AsyncLocalStorage);function getSessionMcpToolCallAuthority(){return callAuthorities.getStore()}function runWithSessionMcpToolCallAuthority(e,t){return e?callAuthorities.run(e,t):t()}function withSessionMcpCallerAuthority(e){const t=getSessionMcpToolCallAuthority();return t?(...n)=>{t();return withGuardedFetchRequestAuthority(t,()=>e(...n))}:e}export{withSessionMcpCallerAuthority as i,runWithSessionMcpRequestSignal as n,runWithSessionMcpToolCallAuthority as r,getSessionMcpRequestSignal as t};