UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

71 lines (70 loc) • 2.34 kB
import { r as isIncognitoSessionKey } from "./session-key-DW1jcHbM.mjs"; import "./session-key-CqAyZeVk.mjs"; import { r as resolveAgentMainSessionKey } from "./main-session-BNL3-mRV.mjs"; import { n as withPreparedSessionResolve, t as resolveSessionKeyFromResolveParams } from "./sessions-resolve-CJ_EcgrH.mjs"; //#region src/gateway/control-ui-session-path-resolve.ts /** Both HTTP readers use the same URL grammar and the existing session resolution owner. */ async function resolveControlUiSessionPath(e) { const { target: t, projection: n } = e; if (e.publicOnly && t.kind !== "main" && isIncognitoSessionKey(t.kind === "short" ? t.literalSessionKey : t.sessionKey)) return null; let isCurrent = () => false; const resolve = (r) => { const i = { projection: n, client: e.client, isCurrent: e.isCurrent, p: { ...r, agentId: t.agentId, allowMissing: true, includeGlobal: true, includeUnknown: true }, publicOnly: e.publicOnly }; return withPreparedSessionResolve(i, (t) => { if (t.ok && "key" in t) { const r = { key: t.key, agentId: t.agentId }; const a = n.capture(r); const o = a?.entry?.sessionId; const s = n.sharingRevision; isCurrent = () => { if (e.isCurrent?.() === false || !a || !n.isCurrent(a) || !isIncognitoSessionKey(r.key) && n.sharingTargetState(r).status !== "ready" || n.capture(r)?.entry?.sessionId !== o || n.sharingRevision === void 0) return false; if (n.sharingRevision === s) return true; try { const e = resolveSessionKeyFromResolveParams(i); return e.ok && "key" in e && e.key === t.key && e.agentId === t.agentId; } catch { return false; } }; } return t; }); }; let r; if (t.kind === "main") r = await resolve({ key: resolveAgentMainSessionKey({ cfg: n.state.cfg, agentId: t.agentId }) }); else if (t.kind === "short") { r = await resolve({ shortId: t.shortId, slugHint: t.slugHint }); if (r.ok && "missing" in r) r = await resolve({ reference: { key: t.literalSessionKey } }); } else r = await resolve({ reference: { key: t.sessionKey, ...t.slugCandidate ? { slug: t.slugCandidate } : {} } }); return r.ok && "key" in r ? { key: r.key, agentId: r.agentId, isCurrent } : null; } //#endregion export { resolveControlUiSessionPath as t };