Commit 0264481
committed
config: add secret_source=metadata mode and ${secret:NAME} interpolation
Phase C Cloud tenants need to fetch the provider API key from the host
metadata gateway instead of reading process.env. The loader now supports
two modes: the existing default secret_source: env continues to read
process.env unchanged, and the new secret_source: metadata fetches the
named secret from http://169.254.169.254/v1/secrets/<name>, populates
process.env.ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN, and walks the
parsed config replacing ${secret:NAME} references with their resolved
plaintext. Self-host installs that omit secret_source see no behaviour
change. Whole-string interpolation only, so partial-string references
in URLs and other composed values are intentionally left untouched to
avoid leaking plaintext through any code path that logs the original
string. Adds MetadataSecretFetcher (60s TTL cache, ETag/If-None-Match
against X-Phantom-Rotation-Id) and updates two callers (src/index.ts,
src/cli/doctor.ts) to await the now-async loadConfig. The original
sync code path is preserved as loadConfigSync for any context that
genuinely cannot await.1 parent 34c252a commit 0264481
13 files changed
Lines changed: 557 additions & 55 deletions
File tree
- src
- agent/__tests__
- cli
- config
- __tests__
- mcp/__tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
0 commit comments