UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

27 lines (26 loc) • 1.34 kB
import { n as normalizeAgentId } from "./agent-id-CQjtp2ft.mjs"; import "./session-key-CqAyZeVk.mjs"; import { n as sha256Hex } from "./node-crypto-B6yuTjmm.mjs"; //#region src/config/sessions/internal-session-key.ts const INTERNAL_SESSION_EFFECTS_SEGMENT = "internal-session-effects"; const INTERNAL_SESSION_EFFECTS_REST_PREFIX = `${INTERNAL_SESSION_EFFECTS_SEGMENT}:`; function normalizeInternalRunId(e) { return `${e.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 48) || "run"}-${sha256Hex(e).slice(0, 16)}`; } /** Resolves the hidden SQLite session identity owned by one internal-effects run. */ function resolveInternalSessionEffectsIdentity(e) { const t = normalizeInternalRunId(e.runId); const n = e.incognito ? `incognito-${t}` : t.startsWith("incognito-") ? `legacy-${t}` : t; return { sessionId: `${INTERNAL_SESSION_EFFECTS_SEGMENT}-${t}`, sessionKey: `agent:${normalizeAgentId(e.agentId)}:${INTERNAL_SESSION_EFFECTS_SEGMENT}:${n}` }; } /** Returns true for SQLite entries that exist only to contain suppressed run effects. */ function isInternalSessionEffectsKey(e) { if (!e.startsWith("agent:")) return false; const t = e.indexOf(":", 6); return t >= 0 && e.startsWith(INTERNAL_SESSION_EFFECTS_REST_PREFIX, t + 1); } //#endregion export { resolveInternalSessionEffectsIdentity as n, isInternalSessionEffectsKey as t };