{"version":3,"sources":["../src/mcp-credential-deps.ts"],"names":[],"mappings":";;;;;;AAoDA,IAAI,OAA0B,EAAC;AAExB,SAAS,qBAAqB,CAAA,EAA4B;AAC/D,EAAA,IAAA,GAAO,CAAA;AACT;AAEO,SAAS,oBAAA,GAA0C;AACxD,EAAA,OAAO,IAAA;AACT","file":"mcp-credential-deps.mjs","sourcesContent":["/**\n * Dependency-injection surface for MCP credential resolution.\n *\n * `packages/runtime` does depend on `@agentproto/auth` (e.g. `KeychainStore`\n * in `session-spawn.ts`), but credential resolution is still injected here\n * so non-darwin / test stores stay pluggable. The daemon bootstrap (e.g.\n * `packages/cli`) can set a broker-backed resolver here, and `session-spawn.ts` will call it when an `mcpServers`\n * entry carries `credentialRef`. Errors from the hook are treated as\n * non-fatal by the caller.\n */\n\nexport interface McpCredentialDeps {\n  /** Resolve brokered headers for an `mcpServers` entry that names a\n   *  `credentialRef`. The returned headers are merged ON TOP of the\n   *  entry's static `headers` so brokered auth wins on collision. */\n  resolveMcpCredentialHeaders?: (o: {\n    credentialRef: string\n    signal?: AbortSignal\n  }) => Promise<Record<string, string> | undefined>\n  /** Resolve a single named secret (an env-var-shaped slug — e.g. a sandbox\n   *  spec's `env.passthrough` / `env.auth.state.env` entries) to its raw\n   *  value. Distinct from `resolveMcpCredentialHeaders` above (which\n   *  resolves an MCP `credentialRef` PATH into Authorization-style\n   *  headers): this is the `SecretResolver` shape `agent_start`'s sandbox\n   *  branch (`session-spawn.ts`) passes to `@agentproto/sandbox`'s\n   *  `SandboxSecretsConfig.resolver` — so a booted sandbox's env is filled\n   *  from the same host-injected broker as every other secret, never a\n   *  bare `process.env` read at the call site. Returns null when the slug\n   *  can't be resolved (missing/unconfigured). */\n  resolveSandboxSecret?: (slug: string) => Promise<string | null>\n  /** Read an imported-MCP secret by opaque ref\n   *  (`agentproto/mcp-import/<importId>#<header|env>:<KEY>`, split on the last\n   *  `#` into keychain path + account). Undefined when the ref is missing. */\n  resolveMcpSecret?: (ref: string) => Promise<string | undefined>\n  /** Persist an imported-MCP secret under `ref`. */\n  storeMcpSecret?: (ref: string, value: string) => Promise<void>\n}\n\n/**\n * `setMcpCredentialDeps`/`getMcpCredentialDeps` are a plain module-scope\n * singleton, and this package ships with `splitting: false` across many\n * tsup entries: `./mcp-credential-deps` here, `./mcp-oauth` and\n * `./mcp-client-pool` each bundle their OWN copy of this file, with their\n * OWN independent `deps` variable. A `setMcpCredentialDeps` call reached\n * through one subpath import is invisible to a `getMcpCredentialDeps` call\n * reached through another — only consumers that both go through the SAME\n * subpath (or both through `./index`, which inlines everything into one\n * chunk) actually share state. Treat any cross-subpath read of this\n * singleton as unreliable; pass the resolved deps explicitly instead (see\n * `createDaemonOAuthProvider`'s `io` parameter and `mcp-proxy.ts`'s\n * `openClient` for the pattern).\n */\nlet deps: McpCredentialDeps = {}\n\nexport function setMcpCredentialDeps(d: McpCredentialDeps): void {\n  deps = d\n}\n\nexport function getMcpCredentialDeps(): McpCredentialDeps {\n  return deps\n}\n"]}