WIP: Remove global state from pi-ai OAuth/API key handling

- Remove setApiKey, resolveApiKey, and global apiKeys Map from stream.ts
- Rename getApiKey to getApiKeyFromEnv (only checks env vars)
- Remove OAuth storage layer (storage.ts deleted)
- OAuth login/refresh functions now return credentials instead of saving
- getOAuthApiKey/refreshOAuthToken now take credentials as params
- Add test/oauth.ts helper for ai package tests
- Simplify root npm run check (single biome + tsgo pass)
- Remove redundant check scripts from most packages
- Add web-ui and coding-agent examples to biome/tsgo includes

coding-agent still has compile errors - needs refactoring for new API
This commit is contained in:
Mario Zechner 2025-12-25 01:01:03 +01:00
parent d93cbf8c32
commit 030788140a
51 changed files with 646 additions and 570 deletions

View file

@ -10,31 +10,28 @@
import { Type } from "@sinclair/typebox";
import {
createAgentSession,
discoverCustomTools,
SessionManager,
codingTools, // read, bash, edit, write - uses process.cwd()
readOnlyTools, // read, grep, find, ls - uses process.cwd()
createCodingTools, // Factory: creates tools for specific cwd
createReadOnlyTools, // Factory: creates tools for specific cwd
createReadTool,
createBashTool,
createGrepTool,
readTool,
bashTool,
grepTool,
bashTool, // read, bash, edit, write - uses process.cwd()
type CustomAgentTool,
createAgentSession,
createBashTool,
createCodingTools, // Factory: creates tools for specific cwd
createGrepTool,
createReadTool,
grepTool,
readOnlyTools, // read, grep, find, ls - uses process.cwd()
readTool,
SessionManager,
} from "../../src/index.js";
// Read-only mode (no edit/write) - uses process.cwd()
const { session: readOnly } = await createAgentSession({
await createAgentSession({
tools: readOnlyTools,
sessionManager: SessionManager.inMemory(),
});
console.log("Read-only session created");
// Custom tool selection - uses process.cwd()
const { session: custom } = await createAgentSession({
await createAgentSession({
tools: [readTool, bashTool, grepTool],
sessionManager: SessionManager.inMemory(),
});
@ -42,7 +39,7 @@ console.log("Custom tools session created");
// With custom cwd - MUST use factory functions!
const customCwd = "/path/to/project";
const { session: customCwdSession } = await createAgentSession({
await createAgentSession({
cwd: customCwd,
tools: createCodingTools(customCwd), // Tools resolve paths relative to customCwd
sessionManager: SessionManager.inMemory(),
@ -50,7 +47,7 @@ const { session: customCwdSession } = await createAgentSession({
console.log("Custom cwd session created");
// Or pick specific tools for custom cwd
const { session: specificTools } = await createAgentSession({
await createAgentSession({
cwd: customCwd,
tools: [createReadTool(customCwd), createBashTool(customCwd), createGrepTool(customCwd)],
sessionManager: SessionManager.inMemory(),