mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 06:02:42 +00:00
refactor(coding-agent): move auth storage to backend abstraction
This commit is contained in:
parent
0a6b0b8fb0
commit
2977c14917
21 changed files with 355 additions and 143 deletions
|
|
@ -19,7 +19,7 @@ See [examples/sdk/](../examples/sdk/) for working examples from minimal to full
|
|||
import { AuthStorage, createAgentSession, ModelRegistry, SessionManager } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
// Set up credential storage and model registry
|
||||
const authStorage = new AuthStorage();
|
||||
const authStorage = AuthStorage.create();
|
||||
const modelRegistry = new ModelRegistry(authStorage);
|
||||
|
||||
const { session } = await createAgentSession({
|
||||
|
|
@ -281,7 +281,7 @@ When you pass a custom `ResourceLoader`, `cwd` and `agentDir` no longer control
|
|||
import { getModel } from "@mariozechner/pi-ai";
|
||||
import { AuthStorage, ModelRegistry } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
const authStorage = new AuthStorage();
|
||||
const authStorage = AuthStorage.create();
|
||||
const modelRegistry = new ModelRegistry(authStorage);
|
||||
|
||||
// Find specific built-in model (doesn't check if API key exists)
|
||||
|
|
@ -329,7 +329,7 @@ API key resolution priority (handled by AuthStorage):
|
|||
import { AuthStorage, ModelRegistry } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
// Default: uses ~/.pi/agent/auth.json and ~/.pi/agent/models.json
|
||||
const authStorage = new AuthStorage();
|
||||
const authStorage = AuthStorage.create();
|
||||
const modelRegistry = new ModelRegistry(authStorage);
|
||||
|
||||
const { session } = await createAgentSession({
|
||||
|
|
@ -342,7 +342,7 @@ const { session } = await createAgentSession({
|
|||
authStorage.setRuntimeApiKey("anthropic", "sk-my-temp-key");
|
||||
|
||||
// Custom auth storage location
|
||||
const customAuth = new AuthStorage("/my/app/auth.json");
|
||||
const customAuth = AuthStorage.create("/my/app/auth.json");
|
||||
const customRegistry = new ModelRegistry(customAuth, "/my/app/models.json");
|
||||
|
||||
const { session } = await createAgentSession({
|
||||
|
|
@ -773,7 +773,7 @@ import {
|
|||
} from "@mariozechner/pi-coding-agent";
|
||||
|
||||
// Set up auth storage (custom location)
|
||||
const authStorage = new AuthStorage("/custom/agent/auth.json");
|
||||
const authStorage = AuthStorage.create("/custom/agent/auth.json");
|
||||
|
||||
// Runtime API key override (not persisted)
|
||||
if (process.env.MY_KEY) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue