openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.22 kB
JavaScript
import{o as resolveGlobalSingleton}from"./global-singleton-DolL9xGt.mjs";import{a as asOptionalRecord}from"./record-coerce-BTbqdJ3-.mjs";
//!src/gateway/in-process-session-run.ts
const runs=resolveGlobalSingleton(Symbol.for(`openclaw.inProcessSessionRuns`),()=>/* @__PURE__ */ new WeakMap);function bindInProcessSessionRun(e,t){if(e.sessionKey!==t.sessionKey||e.idempotencyKey!==t.runId)throw new Error(`Session run does not match its prepared target`);const n={...e,expectedExistingSessionId:t.sessionId,expectedExistingSessionLifecycleRevision:t.lifecycleRevision};runs.set(n,{...t});return n}function takeInProcessFreshChildSession(e){const t=getInProcessSessionRun(`agent`,e);if(!t)return;const{freshChild:n,...r}=t;runs.set(e,r);return n}function isInProcessSessionRun(e,t){return getInProcessSessionRun(e,t)!==void 0}function getInProcessSessionRun(e,t){const n=asOptionalRecord(t);const r=e===`agent`&&n?runs.get(n):void 0;return r&&n?.sessionKey===r.sessionKey&&n.idempotencyKey===r.runId&&n.expectedExistingSessionId===r.sessionId&&n.expectedExistingSessionLifecycleRevision===r.lifecycleRevision?r:void 0}export{isInProcessSessionRun as n,takeInProcessFreshChildSession as r,bindInProcessSessionRun as t};