refactor(auth-storage): cleanup auth.json mentions

- Migrated authentication storage from JSON-based (auth.json) to database-based (agent.db) format across test files and configuration.
- Simplified auth storage discovery in sdk.ts by removing manual path construction and fallback logic in favor of centralized getAgentDbPath() function.
- Removed dbPath instance property from AuthStorage class as database path is now managed centrally.
- Updated environment variable precedence documentation to reflect agent.db instead of auth.json as the lowest priority source.
- Removed OAuth provider section header comments from multiple test files for cleaner test organization.
- Added support for JSON and JSONC configuration file formats without requiring migration to YAML.
This commit is contained in:
can1357
2026-02-05 14:23:49 +01:00
parent e47657c4d1
commit f8950c22b4
33 changed files with 145 additions and 382 deletions
@@ -12,7 +12,7 @@ import {
SessionManager,
} from "@oh-my-pi/pi-coding-agent";
// Default: discoverAuthStorage() uses ~/.omp/agent/auth.json
// Default: discoverAuthStorage() uses ~/.omp/agent/agent.db
// discoverModels() loads built-in + custom models from ~/.omp/agent/models.json
const authStorage = await discoverAuthStorage();
const modelRegistry = await discoverModels(authStorage);
@@ -25,7 +25,7 @@ await createAgentSession({
console.log("Session with default auth storage and model registry");
// Custom auth storage location
const customAuthStorage = new AuthStorage("/tmp/my-app/auth.json");
const customAuthStorage = await AuthStorage.create("/tmp/my-app/agent.db");
const customModelRegistry = new ModelRegistry(customAuthStorage, "/tmp/my-app/models.json");
await createAgentSession({
+1 -1
View File
@@ -77,7 +77,7 @@ const { session } = await createAgentSession({
});
// Full control
const customAuth = new AuthStorage("/my/app/auth.json");
const customAuth = await AuthStorage.create("/my/app/agent.db");
customAuth.setRuntimeApiKey("anthropic", Bun.env.MY_KEY!);
const customRegistry = new ModelRegistry(customAuth);