mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 20:03:05 +00:00
- Add ResourceLoader interface and DefaultResourceLoader implementation - Add PackageManager for npm/git extension sources with install/remove/update - Add session.reload() and session.bindExtensions() APIs - Add /reload command in interactive mode - Add CLI flags: --skill, --theme, --prompt-template, --no-themes, --no-prompt-templates - Add pi install/remove/update commands for extension management - Refactor settings.json to use arrays for skills, prompts, themes - Remove legacy SkillsSettings source flags and filters - Update SDK examples and documentation for ResourceLoader pattern - Add theme registration and loadThemeFromPath for dynamic themes - Add getShellEnv to include bin dir in PATH for bash commands
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
/**
|
|
* API Keys and OAuth
|
|
*
|
|
* Configure API key resolution via AuthStorage and ModelRegistry.
|
|
*/
|
|
|
|
import { AuthStorage, createAgentSession, ModelRegistry, SessionManager } from "@mariozechner/pi-coding-agent";
|
|
|
|
// Default: AuthStorage uses ~/.pi/agent/auth.json
|
|
// ModelRegistry loads built-in + custom models from ~/.pi/agent/models.json
|
|
const authStorage = new AuthStorage();
|
|
const modelRegistry = new ModelRegistry(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");
|