UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

32 lines (31 loc) 1.47 kB
import { c as withPluginRuntimeGatewayContextResolver, t as bindGatewayContextResolver } from "./gateway-request-scope-BCMYlsDI.js"; //#region src/gateway/scheduled-run-gateway-context.ts /** * Supplies a Gateway request context to scheduler-owned agent runs. * * Timer ticks, hook dispatch queues, and heartbeat wakeups have no Gateway * request of their own, so trusted built-in tools (terminal, dashboard) resolve * no context and fail mid-run. RPC-triggered runs already inherit a scope from * their caller and must keep it. */ function fenceScheduledGatewayContextResolver(resolveGatewayContext) { if (!resolveGatewayContext) return; const resolveScheduledContext = () => { return resolveGatewayContext()?.resolveGatewayContext?.() ?? void 0; }; bindGatewayContextResolver(resolveScheduledContext, resolveGatewayContext); return resolveScheduledContext; } /** * Runs scheduler-owned work with a Gateway context. * * Detached work replaces any request scope inherited when it was queued or * armed. Caller-owned work must stay outside this boundary. */ async function runWithScheduledGatewayContext(params) { const resolveGatewayContext = params.resolveGatewayContext; if (!resolveGatewayContext) return await params.run(); return await withPluginRuntimeGatewayContextResolver(resolveGatewayContext, params.run, { inheritRequestScope: false }); } //#endregion export { runWithScheduledGatewayContext as n, fenceScheduledGatewayContextResolver as t };