UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

29 lines • 1.7 kB
import { legacyMcpCredentialIdentity } from "./auth/catalog-identity.js"; import { getValidCachedServer, writeMcpCachedServer, } from "./catalog-cache.js"; import { legacyHashConfig } from "./config-identity.js"; /** The identities an earlier, unkeyed build persisted for this server, when its credential resolves now. */ export function legacyMcpCacheIdentity(config, serverName, scope) { const credentialIdentity = legacyMcpCredentialIdentity(config, serverName, scope.agentDir, scope.env); return credentialIdentity === undefined ? undefined : { configHash: legacyHashConfig(config), credentialIdentity }; } /** * The cached catalog for the current keyed identity. An entry written under the unkeyed identities is adopted only * when both its config and its credential match, so a changed account never inherits another account's catalog, * and it is rewritten under the keyed identities. */ export async function adoptMcpCachedServer(adoption) { const { cache, serverName, current } = adoption; const cached = getValidCachedServer(cache, serverName, current.configHash, current.credentialIdentity); if (cached !== undefined) return cached; const legacy = adoption.legacy(); if (legacy === undefined) return undefined; const previous = getValidCachedServer(cache, serverName, legacy.configHash, legacy.credentialIdentity); if (previous === undefined) return undefined; const migrated = { ...previous, configHash: current.configHash, credentialIdentity: current.credentialIdentity }; await writeMcpCachedServer(adoption.agentDir, serverName, migrated); return migrated; } //# sourceMappingURL=catalog-cache-adoption.js.map