UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 2.42 kB
import"./openclaw-state-read-map-size-DJbMcZYM.mjs";import{f as e,l as t}from"./openclaw-state-read-home-dir-BQZX1pD2.mjs";import{n}from"./openclaw-state-read-agent-id-DmscQLD6.mjs";import"./openclaw-state-read-workspace-state-identity-CGvxbhyj.mjs";import{a as r,i}from"./openclaw-state-read-src-DfYHsQWn.mjs";import{c as a}from"./openclaw-state-read-session-key-DaKMXMbu.mjs";import{S as o,T as s,c,p as l,t as u}from"./openclaw-state-read-agent-scope-config-DBTVDK8I.mjs";import"./openclaw-state-read-session-sqlite-target-DOCApy1k.mjs";import"./openclaw-state-read-session-store-read-candidates-Mon1wMui.mjs";import{n as d,t as f}from"./openclaw-state-read-operator-approval-standing-grants.worker-Aazs75VQ.mjs";function tryResolveSessionCompatibilityOwnerAgentId(e,t){let n=l(e,t);return n.kind===`configured`?n.agentId:n.kind===`retired`?void 0:c(e)??s(e)}function canonicalizeSessionKeyForAgent(e,t){let r=a(t);return r===`global`||r===`unknown`||r.startsWith(`agent:`)?r:`agent:${n(e)}:${r}`}function resolveLogicalSessionStoreAgentId(e,t){let n=tryResolveSessionCompatibilityOwnerAgentId(e,t);if(n)return n;let r=l(e,t);throw new u(o(e),{surface:`session key "${t}"`,hint:r.kind===`retired`?`Its recorded owner "${r.agentId}" is no longer configured. Select a configured agent explicitly.`:`Use an agent-prefixed session key or select an agent explicitly.`})}function resolveParsedSessionStoreKey(e,r,a,s){let c=n(a.agentId),l=t(a.rest);if(c!==`main`||l!==`main`&&l!==i(e.session?.mainKey)||o(e).includes(`main`))return{agentId:c,sessionKey:r};let u=s?n(s):resolveLogicalSessionStoreAgentId(e,`main`);return{agentId:u,sessionKey:`agent:${u}:${l}`}}function canonicalizeParsedSessionStoreKey(e,t,r,i,a=!1){let o=resolveParsedSessionStoreKey(e,t,r,i);return a&&o.agentId===n(r.agentId)?o.sessionKey:f({cfg:e,agentId:o.agentId,sessionKey:o.sessionKey})}function resolveSessionStoreKey(t){let o=e(t.sessionKey)??``,s=a(o),c=r(s);if(c)return canonicalizeParsedSessionStoreKey(t.cfg,s,c,t.storeAgentId);let l=o.toLowerCase();if(!o||l===`global`||l===`unknown`)return l;let u=i(t.cfg.session?.mainKey),f=t.storeAgentId?n(t.storeAgentId):void 0;return l===`main`||l===u?t.cfg.session?.scope===`global`?`global`:d({cfg:t.cfg,agentId:f??resolveLogicalSessionStoreAgentId(t.cfg,o)}):canonicalizeSessionKeyForAgent(f??resolveLogicalSessionStoreAgentId(t.cfg,o),o)}export{canonicalizeSessionKeyForAgent,resolveSessionStoreKey};