UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2.19 kB
import{l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{r as resolveStateDir}from"./state-dir-BwIClCab.mjs";import"./paths-D_FOvGon.mjs";import{n as normalizeAgentId}from"./agent-id-cOfqmfln.mjs";import"./session-key-BPgKfU2m.mjs";import{a as resolveAgentDir,j as tryResolveLegacyDataOwnerAgentId}from"./agent-scope-config-CG9CFpGX.mjs";import{n as getPreparedSharedAuthStoreOwnership}from"./path-resolve-TSS6dv07.mjs";import path from"node:path"; //!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`})}export{resolveLegacyInheritedAuthDir as a,resolveLegacyInheritedAuthAgentId as i,pinLegacyInheritedAuthOwnerForRosterTransition as n,resolveLegacyInheritedAuthAgentDir as r,assertSafeLegacyInheritedAuthDirTransition as t};