UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

32 lines (31 loc) 1.88 kB
import { n as normalizeAgentId } from "./agent-id-CeT3w4ap.js"; import { o as listAgentIds } from "./agent-scope-config-DcbEhP0R.js"; import { c as classifySessionKeyShape } from "./session-key-BnWWjqNc.js"; import { n as isSameFixedSessionStoreConfig, t as isPerAgentSessionStoreConfig } from "./session-store-config-C5gZ4u4F.js"; //#region src/config/sessions/session-store-owner.ts /** Preserves a retired fixed-store owner as an explicit unavailable state. */ function resolvePersistedSessionStoreOwner(config) { if (isPerAgentSessionStoreConfig(config.session?.store)) return { kind: "none" }; const persistedAgentId = config.agents?.defaults?.sessionStore?.agentId?.trim(); if (!persistedAgentId) return { kind: "none" }; const agentId = normalizeAgentId(persistedAgentId); return listAgentIds(config).some((configuredAgentId) => normalizeAgentId(configuredAgentId) === agentId) ? { kind: "configured", agentId } : { kind: "retired", agentId }; } /** Applies fixed-store ownership only to keys without an agent-qualified namespace. */ function resolvePersistedSessionStoreOwnerForKey(config, sessionKey) { return classifySessionKeyShape(sessionKey) === "legacy_or_alias" ? resolvePersistedSessionStoreOwner(config) : { kind: "none" }; } /** Applies fixed-store ownership only when the concrete write target is that configured store. */ function resolvePersistedSessionStoreOwnerForTarget(params) { const owner = resolvePersistedSessionStoreOwnerForKey(params.config, params.sessionKey); if (owner.kind === "none" || !params.storePath) return owner; return isSameFixedSessionStoreConfig(params.config.session?.store, params.storePath, params.env ?? process.env) ? owner : { kind: "none" }; } //#endregion export { resolvePersistedSessionStoreOwnerForKey as n, resolvePersistedSessionStoreOwnerForTarget as r, resolvePersistedSessionStoreOwner as t };