pi-mono/vitest.base.ts
Armin Ronacher c3bfd689ef feat(ai): bundle OAuth flows for browsers and share the remote catalog
OAuth flows load node:http only when a callback server starts and use Web Crypto, so they bundle for browsers. Every flow request goes through one replaceable fetch. The new oauth-flows entry registers the flows statically (registerOAuthFlows) and finds a built-in provider's flow (getBuiltinOAuthFlow). Sign in with ChatGPT completes with the pasted address where no server can run.

The pi.dev catalog overlay moves from coding-agent into the new remote-catalog entry, with a configurable request function; coding-agent keeps its retries and User-Agent through a wrapper.
2026-10-30 23:12:37 +01:00

68 lines
4.5 KiB
TypeScript

import { fileURLToPath } from "node:url";
import { defineConfig } from "vitest/config";
export const workspaceSourcePaths = {
chordIndex: fileURLToPath(new URL("./packages/chord/src/index.ts", import.meta.url)),
chordContext: fileURLToPath(new URL("./packages/chord/src/context/index.ts", import.meta.url)),
chordDelta: fileURLToPath(new URL("./packages/chord/src/delta/index.ts", import.meta.url)),
chordNode: fileURLToPath(new URL("./packages/chord/src/node.ts", import.meta.url)),
telemetryIndex: fileURLToPath(new URL("./packages/telemetry/src/index.ts", import.meta.url)),
telemetryTesting: fileURLToPath(new URL("./packages/telemetry/src/testing/index.ts", import.meta.url)),
mcpIndex: fileURLToPath(new URL("./packages/mcp/src/index.ts", import.meta.url)),
mcpOAuth: fileURLToPath(new URL("./packages/mcp/src/oauth/index.ts", import.meta.url)),
mcpTesting: fileURLToPath(new URL("./packages/mcp/src/testing/index.ts", import.meta.url)),
aiIndex: fileURLToPath(new URL("./packages/ai/src/index.ts", import.meta.url)),
aiCompat: fileURLToPath(new URL("./packages/ai/src/compat.ts", import.meta.url)),
aiModels: fileURLToPath(new URL("./packages/ai/src/models.ts", import.meta.url)),
aiOAuth: fileURLToPath(new URL("./packages/ai/src/oauth.ts", import.meta.url)),
aiOAuthFlows: fileURLToPath(new URL("./packages/ai/src/oauth-flows.ts", import.meta.url)),
aiRemoteCatalog: fileURLToPath(new URL("./packages/ai/src/remote-catalog.ts", import.meta.url)),
aiApi: fileURLToPath(new URL("./packages/ai/src/api", import.meta.url)),
aiProviders: fileURLToPath(new URL("./packages/ai/src/providers", import.meta.url)),
aiUtils: fileURLToPath(new URL("./packages/ai/src/utils", import.meta.url)),
agentIndex: fileURLToPath(new URL("./packages/agent/src/index.ts", import.meta.url)),
codemodeIndex: fileURLToPath(new URL("./packages/codemode/src/index.ts", import.meta.url)),
codemodeDeclarations: fileURLToPath(new URL("./packages/codemode/src/declarations.ts", import.meta.url)),
codemodeSource: fileURLToPath(new URL("./packages/codemode/src/source.ts", import.meta.url)),
codingAgentIndex: fileURLToPath(new URL("./packages/coding-agent/src/index.ts", import.meta.url)),
tuiIndex: fileURLToPath(new URL("./packages/tui/src/index.ts", import.meta.url)),
} as const;
export default defineConfig({
resolve: {
alias: [
{ find: /^@earendil-works\/chord$/, replacement: workspaceSourcePaths.chordIndex },
{ find: /^@earendil-works\/chord\/context$/, replacement: workspaceSourcePaths.chordContext },
{ find: /^@earendil-works\/chord\/delta$/, replacement: workspaceSourcePaths.chordDelta },
{ find: /^@earendil-works\/chord\/node$/, replacement: workspaceSourcePaths.chordNode },
{ find: /^@earendil-works\/pi-telemetry$/, replacement: workspaceSourcePaths.telemetryIndex },
{ find: /^@earendil-works\/pi-telemetry\/testing$/, replacement: workspaceSourcePaths.telemetryTesting },
{ find: /^@earendil-works\/pi-mcp$/, replacement: workspaceSourcePaths.mcpIndex },
{ find: /^@earendil-works\/pi-mcp\/oauth$/, replacement: workspaceSourcePaths.mcpOAuth },
{ find: /^@earendil-works\/pi-mcp\/testing$/, replacement: workspaceSourcePaths.mcpTesting },
{ find: /^@earendil-works\/pi-ai$/, replacement: workspaceSourcePaths.aiIndex },
{ find: /^@earendil-works\/pi-ai\/compat$/, replacement: workspaceSourcePaths.aiCompat },
{ find: /^@earendil-works\/pi-ai\/models$/, replacement: workspaceSourcePaths.aiModels },
{ find: /^@earendil-works\/pi-ai\/oauth$/, replacement: workspaceSourcePaths.aiOAuth },
{ find: /^@earendil-works\/pi-ai\/oauth-flows$/, replacement: workspaceSourcePaths.aiOAuthFlows },
{ find: /^@earendil-works\/pi-ai\/remote-catalog$/, replacement: workspaceSourcePaths.aiRemoteCatalog },
{
find: /^@earendil-works\/pi-ai\/utils\/(.+)$/,
replacement: `${workspaceSourcePaths.aiUtils}/$1.ts`,
},
{
find: /^@earendil-works\/pi-ai\/api\/(.+)$/,
replacement: `${workspaceSourcePaths.aiApi}/$1.ts`,
},
{
find: /^@earendil-works\/pi-ai\/providers\/(.+)$/,
replacement: `${workspaceSourcePaths.aiProviders}/$1.ts`,
},
{ find: /^@earendil-works\/pi-agent-core$/, replacement: workspaceSourcePaths.agentIndex },
{ find: /^@earendil-works\/pi-codemode$/, replacement: workspaceSourcePaths.codemodeIndex },
{ find: /^@earendil-works\/pi-codemode\/declarations$/, replacement: workspaceSourcePaths.codemodeDeclarations },
{ find: /^@earendil-works\/pi-codemode\/source$/, replacement: workspaceSourcePaths.codemodeSource },
{ find: /^@earendil-works\/pi-tui$/, replacement: workspaceSourcePaths.tuiIndex },
],
},
});