UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

46 lines (45 loc) • 2.42 kB
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs"; import { r as resolveStateDir } from "./state-dir-DiG0gXzD.mjs"; import "./paths-DAcAg5aV.mjs"; import { n as normalizeAgentId } from "./agent-id-CQjtp2ft.mjs"; import "./session-key-CqAyZeVk.mjs"; import { a as resolveAgentDir, j as tryResolveLegacyDataOwnerAgentId } from "./agent-scope-config-DmXgFGKP.mjs"; import { n as getPreparedSharedAuthStoreOwnership } from "./path-resolve-CpNl_n1M.mjs"; import path from "node:path"; //#region src/agents/legacy-inherited-auth-dir.ts function resolveLegacyInheritedAuthAgentId(e) { return normalizeOptionalString(e.agents?.defaults?.authInheritance?.agentId) ?? tryResolveLegacyDataOwnerAgentId(e) ?? "main"; } function resolveLegacyInheritedAuthAgentDir(e, t = process.env) { return resolveAgentDir(e, resolveLegacyInheritedAuthAgentId(e), t); } function resolveLegacyInheritedAuthDir(e, t = process.env, n) { return getPreparedSharedAuthStoreOwnership(t)?.location === "legacy-main" ? n?.() ?? resolveLegacyInheritedAuthAgentDir(e, t) : void 0; } function pinLegacyInheritedAuthOwnerForRosterTransition(e, t) { const n = resolveLegacyInheritedAuthAgentId(e); if (n === resolveLegacyInheritedAuthAgentId(t)) return t; return { ...t, agents: { ...t.agents, defaults: { ...t.agents?.defaults, authInheritance: { ...t.agents?.defaults?.authInheritance, agentId: n } } } }; } function assertSafeLegacyInheritedAuthDirTransition(e, t, n = process.env) { const r = resolveLegacyInheritedAuthAgentId(e); const i = resolveAgentDir(e, r, n); const a = path.join(resolveStateDir(n), "agents", normalizeAgentId(r), "agent"); const o = resolveAgentDir(t, r, n); if (path.resolve(i) === path.resolve(a) || o === i) return; throw Object.assign(/* @__PURE__ */ new Error(`Config write refused: inherited auth for agent "${r}" is stored in custom agentDir ${JSON.stringify(i)}, but this roster change removes or changes that directory. Relocate the credentials to ${JSON.stringify(a)} or set agents.defaults.authInheritance explicitly for the destination owner, then retry.`), { code: "CONFIG_WRITE_REJECTED" }); } //#endregion export { resolveLegacyInheritedAuthDir as a, resolveLegacyInheritedAuthAgentId as i, pinLegacyInheritedAuthOwnerForRosterTransition as n, resolveLegacyInheritedAuthAgentDir as r, assertSafeLegacyInheritedAuthDirTransition as t };