refactor(coding-agent): move auth storage to backend abstraction

This commit is contained in:
Mario Zechner 2026-02-17 19:57:21 +01:00
parent 0a6b0b8fb0
commit 2977c14917
21 changed files with 355 additions and 143 deletions

View file

@ -43,7 +43,7 @@ import {
} from "@mariozechner/pi-coding-agent";
// Auth and models setup
const authStorage = new AuthStorage();
const authStorage = AuthStorage.create();
const modelRegistry = new ModelRegistry(authStorage);
// Minimal
@ -71,7 +71,7 @@ const { session } = await createAgentSession({
});
// Full control
const customAuth = new AuthStorage("/my/app/auth.json");
const customAuth = AuthStorage.create("/my/app/auth.json");
customAuth.setRuntimeApiKey("anthropic", process.env.MY_KEY!);
const customRegistry = new ModelRegistry(customAuth);
@ -108,7 +108,7 @@ await session.prompt("Hello");
| Option | Default | Description |
|--------|---------|-------------|
| `authStorage` | `new AuthStorage()` | Credential storage |
| `authStorage` | `AuthStorage.create()` | Credential storage |
| `modelRegistry` | `new ModelRegistry(authStorage)` | Model registry |
| `cwd` | `process.cwd()` | Working directory |
| `agentDir` | `~/.pi/agent` | Config directory |