779ca4872b
- Removed Prettier configuration files (.prettierignore and .prettierrc) and migrated formatting to Biome. - Updated Biome configuration from version 2.3.11 to 2.3.12 and changed arrowParentheses rule from 'always' to 'asNeeded'. - Pinned @biomejs/biome dependency to exact version 2.3.12 in package.json and bun.lock. - Applied consistent arrow function formatting across 489 files by removing unnecessary parentheses around single parameters. - Removed blank lines after comment blocks and reorganized imports for consistency across the codebase.
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
/**
|
|
* API Keys and OAuth
|
|
*
|
|
* Configure API key resolution via AuthStorage and ModelRegistry.
|
|
*/
|
|
import {
|
|
AuthStorage,
|
|
createAgentSession,
|
|
discoverAuthStorage,
|
|
discoverModels,
|
|
ModelRegistry,
|
|
SessionManager,
|
|
} from "@oh-my-pi/pi-coding-agent";
|
|
|
|
// Default: discoverAuthStorage() uses ~/.omp/agent/auth.json
|
|
// discoverModels() loads built-in + custom models from ~/.omp/agent/models.json
|
|
const authStorage = await discoverAuthStorage();
|
|
const modelRegistry = await discoverModels(authStorage);
|
|
|
|
await createAgentSession({
|
|
sessionManager: SessionManager.inMemory(),
|
|
authStorage,
|
|
modelRegistry,
|
|
});
|
|
console.log("Session with default auth storage and model registry");
|
|
|
|
// Custom auth storage location
|
|
const customAuthStorage = new AuthStorage("/tmp/my-app/auth.json");
|
|
const customModelRegistry = new ModelRegistry(customAuthStorage, "/tmp/my-app/models.json");
|
|
|
|
await createAgentSession({
|
|
sessionManager: SessionManager.inMemory(),
|
|
authStorage: customAuthStorage,
|
|
modelRegistry: customModelRegistry,
|
|
});
|
|
console.log("Session with custom auth storage location");
|
|
|
|
// Runtime API key override (not persisted to disk)
|
|
authStorage.setRuntimeApiKey("anthropic", "sk-my-temp-key");
|
|
await createAgentSession({
|
|
sessionManager: SessionManager.inMemory(),
|
|
authStorage,
|
|
modelRegistry,
|
|
});
|
|
console.log("Session with runtime API key override");
|
|
|
|
// No models.json - only built-in models
|
|
const simpleRegistry = new ModelRegistry(authStorage); // null = no models.json
|
|
await createAgentSession({
|
|
sessionManager: SessionManager.inMemory(),
|
|
authStorage,
|
|
modelRegistry: simpleRegistry,
|
|
});
|
|
console.log("Session with only built-in models");
|