feat(coding-agent): support shell commands and env vars in auth.json API keys

API keys in auth.json now support the same resolution as models.json:
- Shell command: "\!command" executes and uses stdout (cached)
- Environment variable: uses the value of the named variable
- Literal value: used directly

Extracted shared resolveConfigValue() to new resolve-config-value.ts module.
This commit is contained in:
Mario Zechner 2026-02-04 23:01:55 +01:00
parent 7c39a12a28
commit 9cf5758b68
6 changed files with 408 additions and 58 deletions

View file

@ -82,6 +82,24 @@ Store credentials in `~/.pi/agent/auth.json`:
The file is created with `0600` permissions (user read/write only). Auth file credentials take priority over environment variables.
### Key Resolution
The `key` field supports three formats:
- **Shell command:** `"!command"` executes and uses stdout (cached for process lifetime)
```json
{ "type": "api_key", "key": "!security find-generic-password -ws 'anthropic'" }
{ "type": "api_key", "key": "!op read 'op://vault/item/credential'" }
```
- **Environment variable:** Uses the value of the named variable
```json
{ "type": "api_key", "key": "MY_ANTHROPIC_KEY" }
```
- **Literal value:** Used directly
```json
{ "type": "api_key", "key": "sk-ant-..." }
```
OAuth credentials are also stored here after `/login` and managed automatically.
## Cloud Providers