gsd-pi 2.47.0-dev.04be8c9 → 2.47.0-dev.8cfe772

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/resources/extensions/gsd/auto-start.js +8 -1
  2. package/dist/resources/extensions/gsd/guided-flow.js +78 -2
  3. package/dist/resources/extensions/gsd/session-forensics.js +10 -1
  4. package/dist/web/standalone/.next/BUILD_ID +1 -1
  5. package/dist/web/standalone/.next/app-path-routes-manifest.json +14 -14
  6. package/dist/web/standalone/.next/build-manifest.json +2 -2
  7. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  8. package/dist/web/standalone/.next/server/app/_global-error.html +2 -2
  9. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  10. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  12. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  13. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  14. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  15. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  16. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  17. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  18. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  19. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  20. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  21. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  22. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  23. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  24. package/dist/web/standalone/.next/server/app/index.html +1 -1
  25. package/dist/web/standalone/.next/server/app/index.rsc +1 -1
  26. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  27. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  28. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  29. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  30. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  31. package/dist/web/standalone/.next/server/app-paths-manifest.json +14 -14
  32. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  33. package/dist/web/standalone/.next/server/pages/500.html +2 -2
  34. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  35. package/package.json +1 -1
  36. package/packages/pi-agent-core/dist/agent-loop.js +3 -2
  37. package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
  38. package/packages/pi-agent-core/src/agent-loop.ts +3 -2
  39. package/packages/pi-coding-agent/dist/core/model-registry-auth-mode.test.js +43 -0
  40. package/packages/pi-coding-agent/dist/core/model-registry-auth-mode.test.js.map +1 -1
  41. package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
  42. package/packages/pi-coding-agent/dist/core/model-registry.js +26 -3
  43. package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
  44. package/packages/pi-coding-agent/src/core/model-registry-auth-mode.test.ts +70 -0
  45. package/packages/pi-coding-agent/src/core/model-registry.ts +29 -2
  46. package/packages/pi-tui/dist/components/box.d.ts +1 -0
  47. package/packages/pi-tui/dist/components/box.d.ts.map +1 -1
  48. package/packages/pi-tui/dist/components/box.js +10 -0
  49. package/packages/pi-tui/dist/components/box.js.map +1 -1
  50. package/packages/pi-tui/src/components/box.ts +10 -0
  51. package/src/resources/extensions/gsd/auto-start.ts +7 -1
  52. package/src/resources/extensions/gsd/guided-flow.ts +96 -2
  53. package/src/resources/extensions/gsd/session-forensics.ts +11 -1
  54. package/src/resources/extensions/gsd/tests/discuss-queued-milestones.test.ts +241 -0
  55. package/src/resources/extensions/gsd/tests/forensics-error-filter.test.ts +121 -0
  56. package/src/resources/extensions/gsd/tests/preflight-context-draft-filter.test.ts +115 -0
  57. /package/dist/web/standalone/.next/static/{GR9tXQAPXXBL4AUugDPlJ → DyrX2zX_4v7KZDbUNxE2q}/_buildManifest.js +0 -0
  58. /package/dist/web/standalone/.next/static/{GR9tXQAPXXBL4AUugDPlJ → DyrX2zX_4v7KZDbUNxE2q}/_ssgManifest.js +0 -0
@@ -234,8 +234,9 @@ async function runLoop(
234
234
 
235
235
  const toolResults: ToolResultMessage[] = [];
236
236
  if (hasMoreToolCalls && config.externalToolExecution) {
237
- // External execution mode: tools were handled by the provider (e.g., Claude Code SDK).
238
- // Emit synthetic tool events for TUI rendering but skip local dispatch.
237
+ // External execution mode: tools were handled by the provider
238
+ // (e.g., Claude Code SDK). Emit tool_execution events for each
239
+ // tool call. The TUI adds these as components after the message.
239
240
  for (const tc of toolCalls as AgentToolCall[]) {
240
241
  stream.push({
241
242
  type: "tool_execution_start",
@@ -481,4 +481,47 @@ describe("ModelRegistry authMode — streamSimple apiKey boundary", () => {
481
481
  assert.equal(captured.reasoning, "high", "reasoning must pass through");
482
482
  });
483
483
  });
484
+ // ─── Provider-scoped stream routing (#2533) ───────────────────────────────────
485
+ describe("ModelRegistry authMode — provider-scoped stream routing", () => {
486
+ it("does not clobber built-in stream handler when custom provider uses same api", () => {
487
+ const registry = createRegistry(() => true);
488
+ const customSpy = createStreamSpy();
489
+ // Register a custom provider with the same API type as a built-in (anthropic-messages).
490
+ // This simulates the claude-code-cli extension registering with api: "anthropic-messages".
491
+ registry.registerProvider("custom-cli", {
492
+ authMode: "externalCli",
493
+ baseUrl: "local://custom",
494
+ api: "anthropic-messages",
495
+ streamSimple: customSpy.streamSimple,
496
+ models: [createProviderModel("custom-model", "anthropic-messages")],
497
+ });
498
+ // The built-in anthropic-messages provider should still be accessible
499
+ // when calling streamSimple with a model from the built-in provider.
500
+ const provider = getApiProvider("anthropic-messages");
501
+ assert.ok(provider, "anthropic-messages provider must still be registered");
502
+ // Call with a built-in anthropic model — should NOT hit the custom spy.
503
+ // The built-in handler will throw (no API key), which proves the routing
504
+ // correctly delegates to the built-in instead of the custom handler.
505
+ assert.throws(() => provider.streamSimple(makeModel("anthropic", "claude-sonnet-4-6", "anthropic-messages"), makeContext(), { maxTokens: 4096 }), (err) => err.message.includes("API key"), "built-in Anthropic handler must be invoked (throws because no API key in tests)");
506
+ assert.equal(customSpy.getCapturedOptions(), undefined, "custom provider's streamSimple must NOT be called for anthropic provider models");
507
+ });
508
+ it("routes to custom provider when model.provider matches", () => {
509
+ const registry = createRegistry(() => true);
510
+ const customSpy = createStreamSpy();
511
+ registry.registerProvider("custom-cli", {
512
+ authMode: "externalCli",
513
+ baseUrl: "local://custom",
514
+ api: "anthropic-messages",
515
+ streamSimple: customSpy.streamSimple,
516
+ models: [createProviderModel("custom-model", "anthropic-messages")],
517
+ });
518
+ const provider = getApiProvider("anthropic-messages");
519
+ assert.ok(provider);
520
+ // Call with the custom provider's model — should hit the custom spy
521
+ provider.streamSimple(makeModel("custom-cli", "custom-model", "anthropic-messages"), makeContext(), { maxTokens: 2048 });
522
+ const captured = customSpy.getCapturedOptions();
523
+ assert.ok(captured, "custom provider's streamSimple must be called for its own models");
524
+ assert.equal(captured.maxTokens, 2048);
525
+ });
526
+ });
484
527
  //# sourceMappingURL=model-registry-auth-mode.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"model-registry-auth-mode.test.js","sourceRoot":"","sources":["../../src/core/model-registry-auth-mode.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MA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AC,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,6BAA6B,CAAC,CAAC;QACtE,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;QAClF,MAAM,CAAC,KAAK,CAAE,QAAoC,CAAC,SAAS,EAAE,MAAM,EAAE,6BAA6B,CAAC,CAAC;IACtG,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport { describe, it } from \"node:test\";\nimport type { Api, Model, SimpleStreamOptions, Context, AssistantMessageEventStream } from \"@gsd/pi-ai\";\nimport { getApiProvider } from \"@gsd/pi-ai\";\nimport type { AuthStorage } from \"./auth-storage.js\";\nimport { ModelRegistry } from \"./model-registry.js\";\n\nfunction createRegistry(hasAuthFn?: (provider: string) => boolean): ModelRegistry {\n\tconst authStorage = {\n\t\tsetFallbackResolver: () => {},\n\t\tonCredentialChange: () => {},\n\t\tgetOAuthProviders: () => [],\n\t\tget: () => undefined,\n\t\thasAuth: hasAuthFn ?? (() => false),\n\t\tgetApiKey: async () => undefined,\n\t} as unknown as AuthStorage;\n\n\treturn new ModelRegistry(authStorage, undefined);\n}\n\nfunction createProviderModel(id: string, api?: string): NonNullable<Parameters<ModelRegistry[\"registerProvider\"]>[1][\"models\"]>[number] {\n\treturn {\n\t\tid,\n\t\tname: id,\n\t\tapi: (api ?? \"openai-completions\") as Api,\n\t\treasoning: false,\n\t\tinput: [\"text\"],\n\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n\t\tcontextWindow: 128000,\n\t\tmaxTokens: 16384,\n\t};\n}\n\nfunction findModel(registry: ModelRegistry, provider: string, id: string): Model<Api> | undefined {\n\treturn registry.getAvailable().find((m) => m.provider === provider && m.id === id);\n}\n\nfunction makeModel(provider: string, id: string, api: string): Model<Api> {\n\treturn {\n\t\tid,\n\t\tname: id,\n\t\tapi: api as Api,\n\t\tprovider,\n\t\tbaseUrl: `${provider}:`,\n\t\treasoning: false,\n\t\tinput: [\"text\"],\n\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n\t\tcontextWindow: 128000,\n\t\tmaxTokens: 16384,\n\t};\n}\n\nfunction makeContext(): Context {\n\treturn {\n\t\tsystemPrompt: \"test\",\n\t\tmessages: [{ role: \"user\", content: \"hello\", timestamp: Date.now() }],\n\t};\n}\n\n/** No-op streamSimple for tests that need one to pass validation but don't inspect it. */\nconst noopStreamSimple = (_model: Model<Api>, _context: Context, _options?: SimpleStreamOptions) => {\n\treturn {\n\t\t[Symbol.asyncIterator]() { return { next: async () => ({ value: undefined, done: true as const }) }; },\n\t\tresult: () => Promise.resolve({ role: \"assistant\" as const, content: [], api: \"test\" as Api, provider: \"test\", model: \"test\", usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } }, stopReason: \"stop\" as const, timestamp: Date.now() }),\n\t\tpush: () => {},\n\t\tend: () => {},\n\t} as unknown as AssistantMessageEventStream;\n};\n\n/** Create a spy streamSimple that captures the options it receives and returns a stub stream. */\nfunction createStreamSpy(): {\n\tstreamSimple: (model: Model<Api>, context: Context, options?: SimpleStreamOptions) => AssistantMessageEventStream;\n\tgetCapturedOptions: () => SimpleStreamOptions | undefined;\n} {\n\tlet capturedOptions: SimpleStreamOptions | undefined;\n\tconst streamSimple = (_model: Model<Api>, _context: Context, options?: SimpleStreamOptions) => {\n\t\tcapturedOptions = options;\n\t\t// Return a minimal stub that satisfies AssistantMessageEventStream\n\t\treturn {\n\t\t\t[Symbol.asyncIterator]() { return { next: async () => ({ value: undefined, done: true as const }) }; },\n\t\t\tresult: () => Promise.resolve({ role: \"assistant\" as const, content: [], api: \"test\" as Api, provider: \"test\", model: \"test\", usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } }, stopReason: \"stop\" as const, timestamp: Date.now() }),\n\t\t\tpush: () => {},\n\t\t\tend: () => {},\n\t\t} as unknown as AssistantMessageEventStream;\n\t};\n\treturn { streamSimple, getCapturedOptions: () => capturedOptions };\n}\n\n// ─── Registration ─────────────────────────────────────────────────────────────\n\ndescribe(\"ModelRegistry authMode — registration\", () => {\n\tit(\"registers externalCli provider with streamSimple and without apiKey/oauth\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tassert.doesNotThrow(() => {\n\t\t\tregistry.registerProvider(\"cli-provider\", {\n\t\t\t\tauthMode: \"externalCli\",\n\t\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\t\tapi: \"openai-completions\",\n\t\t\t\tstreamSimple: spy.streamSimple,\n\t\t\t\tmodels: [createProviderModel(\"cli-model\")],\n\t\t\t});\n\t\t});\n\t});\n\n\tit(\"registers none provider with streamSimple and without apiKey/oauth\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tassert.doesNotThrow(() => {\n\t\t\tregistry.registerProvider(\"none-provider\", {\n\t\t\t\tauthMode: \"none\",\n\t\t\t\tbaseUrl: \"http://localhost:11434\",\n\t\t\t\tapi: \"openai-completions\",\n\t\t\t\tstreamSimple: spy.streamSimple,\n\t\t\t\tmodels: [createProviderModel(\"local-model\")],\n\t\t\t});\n\t\t});\n\t});\n\n\tit(\"rejects apiKey provider without apiKey or oauth — message mentions authMode\", () => {\n\t\tconst registry = createRegistry();\n\t\tassert.throws(() => {\n\t\t\tregistry.registerProvider(\"apikey-provider\", {\n\t\t\t\tauthMode: \"apiKey\",\n\t\t\t\tbaseUrl: \"https://api.local\",\n\t\t\t\tapi: \"openai-completions\",\n\t\t\t\tmodels: [createProviderModel(\"model\")],\n\t\t\t});\n\t\t}, (err: Error) => {\n\t\t\tassert.ok(err.message.includes(\"authMode\"), \"error message must mention authMode\");\n\t\t\tassert.ok(err.message.includes(\"externalCli\"), \"error message must suggest externalCli\");\n\t\t\treturn true;\n\t\t});\n\t});\n\n\tit(\"rejects provider with no authMode and no apiKey/oauth (defaults to apiKey)\", () => {\n\t\tconst registry = createRegistry();\n\t\tassert.throws(() => {\n\t\t\tregistry.registerProvider(\"bare-provider\", {\n\t\t\t\tbaseUrl: \"https://api.local\",\n\t\t\t\tapi: \"openai-completions\",\n\t\t\t\tmodels: [createProviderModel(\"model\")],\n\t\t\t});\n\t\t}, (err: Error) => {\n\t\t\tassert.ok(err.message.includes(\"authMode\"), \"error message must mention authMode\");\n\t\t\treturn true;\n\t\t});\n\t});\n\n\tit(\"rejects externalCli provider without streamSimple\", () => {\n\t\tconst registry = createRegistry();\n\t\tassert.throws(() => {\n\t\t\tregistry.registerProvider(\"cli-no-stream\", {\n\t\t\t\tauthMode: \"externalCli\",\n\t\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\t\tapi: \"openai-completions\",\n\t\t\t\tmodels: [createProviderModel(\"model\")],\n\t\t\t});\n\t\t}, (err: Error) => {\n\t\t\tassert.ok(err.message.includes(\"streamSimple\"), \"error message must mention streamSimple\");\n\t\t\tassert.ok(err.message.includes(\"externalCli\"), \"error message must mention authMode\");\n\t\t\treturn true;\n\t\t});\n\t});\n\n\tit(\"rejects none provider without streamSimple\", () => {\n\t\tconst registry = createRegistry();\n\t\tassert.throws(() => {\n\t\t\tregistry.registerProvider(\"none-no-stream\", {\n\t\t\t\tauthMode: \"none\",\n\t\t\t\tbaseUrl: \"http://localhost:11434\",\n\t\t\t\tapi: \"openai-completions\",\n\t\t\t\tmodels: [createProviderModel(\"model\")],\n\t\t\t});\n\t\t}, (err: Error) => {\n\t\t\tassert.ok(err.message.includes(\"streamSimple\"), \"error message must mention streamSimple\");\n\t\t\tassert.ok(err.message.includes(\"none\"), \"error message must mention authMode\");\n\t\t\treturn true;\n\t\t});\n\t});\n\n\tit(\"rejects externalCli provider that also sets apiKey\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tassert.throws(() => {\n\t\t\tregistry.registerProvider(\"cli-with-key\", {\n\t\t\t\tauthMode: \"externalCli\",\n\t\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\t\tapi: \"openai-completions\",\n\t\t\t\tapiKey: \"SHOULD_NOT_EXIST\",\n\t\t\t\tstreamSimple: spy.streamSimple,\n\t\t\t\tmodels: [createProviderModel(\"model\")],\n\t\t\t});\n\t\t}, (err: Error) => {\n\t\t\tassert.ok(err.message.includes(\"apiKey\"), \"error message must mention apiKey\");\n\t\t\tassert.ok(err.message.includes(\"externalCli\"), \"error message must mention authMode\");\n\t\t\treturn true;\n\t\t});\n\t});\n\n\tit(\"rejects none provider that also sets apiKey\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tassert.throws(() => {\n\t\t\tregistry.registerProvider(\"none-with-key\", {\n\t\t\t\tauthMode: \"none\",\n\t\t\t\tbaseUrl: \"http://localhost:11434\",\n\t\t\t\tapi: \"openai-completions\",\n\t\t\t\tapiKey: \"SHOULD_NOT_EXIST\",\n\t\t\t\tstreamSimple: spy.streamSimple,\n\t\t\t\tmodels: [createProviderModel(\"model\")],\n\t\t\t});\n\t\t}, (err: Error) => {\n\t\t\tassert.ok(err.message.includes(\"apiKey\"), \"error message must mention apiKey\");\n\t\t\tassert.ok(err.message.includes(\"none\"), \"error message must mention authMode\");\n\t\t\treturn true;\n\t\t});\n\t});\n});\n\n// ─── getProviderAuthMode ──────────────────────────────────────────────────────\n\ndescribe(\"ModelRegistry authMode — getProviderAuthMode\", () => {\n\tit(\"returns apiKey for unregistered (built-in) providers\", () => {\n\t\tconst registry = createRegistry();\n\t\tassert.equal(registry.getProviderAuthMode(\"anthropic\"), \"apiKey\");\n\t});\n\n\tit(\"returns explicit authMode when set\", () => {\n\t\tconst registry = createRegistry();\n\t\tregistry.registerProvider(\"cli\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tassert.equal(registry.getProviderAuthMode(\"cli\"), \"externalCli\");\n\t});\n\n\tit(\"returns none when authMode is none\", () => {\n\t\tconst registry = createRegistry();\n\t\tregistry.registerProvider(\"local\", {\n\t\t\tauthMode: \"none\",\n\t\t\tbaseUrl: \"http://localhost:11434\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tassert.equal(registry.getProviderAuthMode(\"local\"), \"none\");\n\t});\n});\n\n// ─── isProviderRequestReady ───────────────────────────────────────────────────\n\ndescribe(\"ModelRegistry authMode — isProviderRequestReady\", () => {\n\tit(\"returns true for externalCli without stored auth\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tregistry.registerProvider(\"cli\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tassert.equal(registry.isProviderRequestReady(\"cli\"), true);\n\t});\n\n\tit(\"returns true for none without stored auth\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tregistry.registerProvider(\"local\", {\n\t\t\tauthMode: \"none\",\n\t\t\tbaseUrl: \"http://localhost:11434\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tassert.equal(registry.isProviderRequestReady(\"local\"), true);\n\t});\n\n\tit(\"returns false for apiKey provider without stored auth\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tassert.equal(registry.isProviderRequestReady(\"anthropic\"), false);\n\t});\n\n\tit(\"returns true for apiKey provider with stored auth\", () => {\n\t\tconst registry = createRegistry(() => true);\n\t\tassert.equal(registry.isProviderRequestReady(\"anthropic\"), true);\n\t});\n});\n\n// ─── isReady callback ─────────────────────────────────────────────────────────\n\ndescribe(\"ModelRegistry authMode — isReady callback\", () => {\n\tit(\"calls isReady and returns its result for externalCli provider\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tregistry.registerProvider(\"cli-down\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tisReady: () => false,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tassert.equal(registry.isProviderRequestReady(\"cli-down\"), false);\n\t});\n\n\tit(\"calls isReady for apiKey provider (overrides hasAuth)\", () => {\n\t\tconst registry = createRegistry(() => true);\n\t\tregistry.registerProvider(\"strict-provider\", {\n\t\t\tapiKey: \"MY_KEY\",\n\t\t\tbaseUrl: \"https://api.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tisReady: () => false,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tassert.equal(registry.isProviderRequestReady(\"strict-provider\"), false);\n\t});\n\n\tit(\"isReady returning true makes provider available\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tregistry.registerProvider(\"healthy-cli\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tisReady: () => true,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tassert.equal(registry.isProviderRequestReady(\"healthy-cli\"), true);\n\t});\n\n\tit(\"falls through to default behavior when isReady not provided\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tregistry.registerProvider(\"no-callback\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\t// externalCli without isReady → true (default)\n\t\tassert.equal(registry.isProviderRequestReady(\"no-callback\"), true);\n\t});\n});\n\n// ─── getAvailable ─────────────────────────────────────────────────────────────\n\ndescribe(\"ModelRegistry authMode — getAvailable\", () => {\n\tit(\"includes externalCli models without stored auth\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tregistry.registerProvider(\"cli\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"cli-model\")],\n\t\t});\n\t\tassert.ok(findModel(registry, \"cli\", \"cli-model\"));\n\t});\n\n\tit(\"includes none models without stored auth\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tregistry.registerProvider(\"local\", {\n\t\t\tauthMode: \"none\",\n\t\t\tbaseUrl: \"http://localhost:11434\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"local-model\")],\n\t\t});\n\t\tassert.ok(findModel(registry, \"local\", \"local-model\"));\n\t});\n\n\tit(\"excludes externalCli models when isReady returns false\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tregistry.registerProvider(\"cli-down\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tisReady: () => false,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tassert.equal(findModel(registry, \"cli-down\", \"m\"), undefined);\n\t});\n\n\tit(\"excludes apiKey models without stored auth\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tconst available = registry.getAvailable();\n\t\tassert.equal(available.length, 0);\n\t});\n});\n\n// ─── getApiKey ────────────────────────────────────────────────────────────────\n\ndescribe(\"ModelRegistry authMode — getApiKey\", () => {\n\tit(\"returns undefined for externalCli provider\", async () => {\n\t\tconst registry = createRegistry();\n\t\tregistry.registerProvider(\"cli\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tconst model = registry.getAll().find((m) => m.provider === \"cli\")!;\n\t\tassert.equal(await registry.getApiKey(model), undefined);\n\t});\n\n\tit(\"returns undefined for none provider\", async () => {\n\t\tconst registry = createRegistry();\n\t\tregistry.registerProvider(\"local\", {\n\t\t\tauthMode: \"none\",\n\t\t\tbaseUrl: \"http://localhost:11434\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tconst model = registry.getAll().find((m) => m.provider === \"local\")!;\n\t\tassert.equal(await registry.getApiKey(model), undefined);\n\t});\n\n\tit(\"delegates to authStorage for apiKey provider\", async () => {\n\t\tconst registry = createRegistry();\n\t\tconst key = await registry.getApiKeyForProvider(\"anthropic\");\n\t\tassert.equal(key, undefined);\n\t});\n});\n\n// ─── streamSimple apiKey stripping ────────────────────────────────────────────\n\ndescribe(\"ModelRegistry authMode — streamSimple apiKey boundary\", () => {\n\tit(\"strips apiKey from options for externalCli provider\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tconst apiType = `ext-cli-strip-${Date.now()}`;\n\n\t\tregistry.registerProvider(\"cli-strip\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: apiType as Api,\n\t\t\tstreamSimple: spy.streamSimple,\n\t\t\tmodels: [createProviderModel(\"m\", apiType)],\n\t\t});\n\n\t\tconst provider = getApiProvider(apiType as Api);\n\t\tassert.ok(provider, \"provider must be registered in api registry\");\n\n\t\tprovider.streamSimple(\n\t\t\tmakeModel(\"cli-strip\", \"m\", apiType),\n\t\t\tmakeContext(),\n\t\t\t{ apiKey: \"should-be-stripped\", maxTokens: 1024 } as SimpleStreamOptions,\n\t\t);\n\n\t\tconst captured = spy.getCapturedOptions();\n\t\tassert.ok(captured, \"streamSimple must have been called\");\n\t\tassert.equal(\"apiKey\" in captured, false, \"apiKey must not exist in options for externalCli provider\");\n\t\tassert.equal(captured.maxTokens, 1024, \"other options must pass through\");\n\t});\n\n\tit(\"strips apiKey from options for none provider\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tconst apiType = `none-strip-${Date.now()}`;\n\n\t\tregistry.registerProvider(\"none-strip\", {\n\t\t\tauthMode: \"none\",\n\t\t\tbaseUrl: \"http://localhost:11434\",\n\t\t\tapi: apiType as Api,\n\t\t\tstreamSimple: spy.streamSimple,\n\t\t\tmodels: [createProviderModel(\"m\", apiType)],\n\t\t});\n\n\t\tconst provider = getApiProvider(apiType as Api);\n\t\tassert.ok(provider, \"provider must be registered in api registry\");\n\n\t\tprovider.streamSimple(\n\t\t\tmakeModel(\"none-strip\", \"m\", apiType),\n\t\t\tmakeContext(),\n\t\t\t{ apiKey: \"should-be-stripped\", maxTokens: 2048 } as SimpleStreamOptions,\n\t\t);\n\n\t\tconst captured = spy.getCapturedOptions();\n\t\tassert.ok(captured, \"streamSimple must have been called\");\n\t\tassert.equal(\"apiKey\" in captured, false, \"apiKey must not exist in options for none provider\");\n\t\tassert.equal(captured.maxTokens, 2048, \"other options must pass through\");\n\t});\n\n\tit(\"preserves apiKey in options for apiKey provider\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tconst apiType = `apikey-preserve-${Date.now()}`;\n\n\t\tregistry.registerProvider(\"apikey-preserve\", {\n\t\t\tapiKey: \"MY_KEY\",\n\t\t\tbaseUrl: \"https://api.local\",\n\t\t\tapi: apiType as Api,\n\t\t\tstreamSimple: spy.streamSimple,\n\t\t\tmodels: [createProviderModel(\"m\", apiType)],\n\t\t});\n\n\t\tconst provider = getApiProvider(apiType as Api);\n\t\tassert.ok(provider, \"provider must be registered in api registry\");\n\n\t\tprovider.streamSimple(\n\t\t\tmakeModel(\"apikey-preserve\", \"m\", apiType),\n\t\t\tmakeContext(),\n\t\t\t{ apiKey: \"sk-real-key\", maxTokens: 4096 } as SimpleStreamOptions,\n\t\t);\n\n\t\tconst captured = spy.getCapturedOptions();\n\t\tassert.ok(captured, \"streamSimple must have been called\");\n\t\tassert.equal(captured.apiKey, \"sk-real-key\", \"apiKey must be preserved for apiKey provider\");\n\t\tassert.equal(captured.maxTokens, 4096, \"other options must pass through\");\n\t});\n\n\tit(\"handles undefined options for externalCli provider\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tconst apiType = `ext-cli-undef-${Date.now()}`;\n\n\t\tregistry.registerProvider(\"cli-undef\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: apiType as Api,\n\t\t\tstreamSimple: spy.streamSimple,\n\t\t\tmodels: [createProviderModel(\"m\", apiType)],\n\t\t});\n\n\t\tconst provider = getApiProvider(apiType as Api);\n\t\tassert.ok(provider, \"provider must be registered in api registry\");\n\n\t\tprovider.streamSimple(\n\t\t\tmakeModel(\"cli-undef\", \"m\", apiType),\n\t\t\tmakeContext(),\n\t\t\tundefined,\n\t\t);\n\n\t\tconst captured = spy.getCapturedOptions();\n\t\tassert.ok(captured !== undefined, \"streamSimple must have been called\");\n\t\tassert.equal(\"apiKey\" in captured, false, \"apiKey must not exist even when options is undefined\");\n\t});\n\n\tit(\"strips apiKey but preserves signal and other fields for externalCli\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tconst apiType = `ext-cli-fields-${Date.now()}`;\n\t\tconst abortController = new AbortController();\n\n\t\tregistry.registerProvider(\"cli-fields\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: apiType as Api,\n\t\t\tstreamSimple: spy.streamSimple,\n\t\t\tmodels: [createProviderModel(\"m\", apiType)],\n\t\t});\n\n\t\tconst provider = getApiProvider(apiType as Api);\n\t\tassert.ok(provider, \"provider must be registered in api registry\");\n\n\t\tprovider.streamSimple(\n\t\t\tmakeModel(\"cli-fields\", \"m\", apiType),\n\t\t\tmakeContext(),\n\t\t\t{ apiKey: \"strip-me\", maxTokens: 8192, signal: abortController.signal, reasoning: \"high\" } as SimpleStreamOptions,\n\t\t);\n\n\t\tconst captured = spy.getCapturedOptions();\n\t\tassert.ok(captured, \"streamSimple must have been called\");\n\t\tassert.equal(\"apiKey\" in captured, false, \"apiKey must be stripped\");\n\t\tassert.equal(captured.maxTokens, 8192, \"maxTokens must pass through\");\n\t\tassert.equal(captured.signal, abortController.signal, \"signal must pass through\");\n\t\tassert.equal((captured as Record<string, unknown>).reasoning, \"high\", \"reasoning must pass through\");\n\t});\n});\n"]}
1
+ {"version":3,"file":"model-registry-auth-mode.test.js","sourceRoot":"","sources":["../../src/core/model-registry-auth-mode.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,SAAS,cAAc,CAAC,SAAyC;IAChE,MAAM,WAAW,GAAG;QACnB,mBAAmB,EAAE,GAAG,EAAE,GAAE,CAAC;QAC7B,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;QAC5B,iBAAiB,EAAE,GAAG,EAAE,CAAC,EAAE;QAC3B,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS;QACpB,OAAO,EAAE,SAAS,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC;QACnC,SAAS,EAAE,KAAK,IAAI,EAAE,CA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AAC,gBAAgB,CAAC,YAAY,EAAE;YACvC,QAAQ,EAAE,aAAa;YACvB,OAAO,EAAE,gBAAgB;YACzB,GAAG,EAAE,oBAAoB;YACzB,YAAY,EAAE,SAAS,CAAC,YAAY;YACpC,MAAM,EAAE,CAAC,mBAAmB,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAC;SACnE,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,cAAc,CAAC,oBAA2B,CAAC,CAAC;QAC7D,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;QAEpB,oEAAoE;QACpE,QAAQ,CAAC,YAAY,CACpB,SAAS,CAAC,YAAY,EAAE,cAAc,EAAE,oBAAoB,CAAC,EAC7D,WAAW,EAAE,EACb,EAAE,SAAS,EAAE,IAAI,EAAyB,CAC1C,CAAC;QAEF,MAAM,QAAQ,GAAG,SAAS,CAAC,kBAAkB,EAAE,CAAC;QAChD,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,kEAAkE,CAAC,CAAC;QACxF,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport { describe, it } from \"node:test\";\nimport type { Api, Model, SimpleStreamOptions, Context, AssistantMessageEventStream } from \"@gsd/pi-ai\";\nimport { getApiProvider } from \"@gsd/pi-ai\";\nimport type { AuthStorage } from \"./auth-storage.js\";\nimport { ModelRegistry } from \"./model-registry.js\";\n\nfunction createRegistry(hasAuthFn?: (provider: string) => boolean): ModelRegistry {\n\tconst authStorage = {\n\t\tsetFallbackResolver: () => {},\n\t\tonCredentialChange: () => {},\n\t\tgetOAuthProviders: () => [],\n\t\tget: () => undefined,\n\t\thasAuth: hasAuthFn ?? (() => false),\n\t\tgetApiKey: async () => undefined,\n\t} as unknown as AuthStorage;\n\n\treturn new ModelRegistry(authStorage, undefined);\n}\n\nfunction createProviderModel(id: string, api?: string): NonNullable<Parameters<ModelRegistry[\"registerProvider\"]>[1][\"models\"]>[number] {\n\treturn {\n\t\tid,\n\t\tname: id,\n\t\tapi: (api ?? \"openai-completions\") as Api,\n\t\treasoning: false,\n\t\tinput: [\"text\"],\n\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n\t\tcontextWindow: 128000,\n\t\tmaxTokens: 16384,\n\t};\n}\n\nfunction findModel(registry: ModelRegistry, provider: string, id: string): Model<Api> | undefined {\n\treturn registry.getAvailable().find((m) => m.provider === provider && m.id === id);\n}\n\nfunction makeModel(provider: string, id: string, api: string): Model<Api> {\n\treturn {\n\t\tid,\n\t\tname: id,\n\t\tapi: api as Api,\n\t\tprovider,\n\t\tbaseUrl: `${provider}:`,\n\t\treasoning: false,\n\t\tinput: [\"text\"],\n\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n\t\tcontextWindow: 128000,\n\t\tmaxTokens: 16384,\n\t};\n}\n\nfunction makeContext(): Context {\n\treturn {\n\t\tsystemPrompt: \"test\",\n\t\tmessages: [{ role: \"user\", content: \"hello\", timestamp: Date.now() }],\n\t};\n}\n\n/** No-op streamSimple for tests that need one to pass validation but don't inspect it. */\nconst noopStreamSimple = (_model: Model<Api>, _context: Context, _options?: SimpleStreamOptions) => {\n\treturn {\n\t\t[Symbol.asyncIterator]() { return { next: async () => ({ value: undefined, done: true as const }) }; },\n\t\tresult: () => Promise.resolve({ role: \"assistant\" as const, content: [], api: \"test\" as Api, provider: \"test\", model: \"test\", usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } }, stopReason: \"stop\" as const, timestamp: Date.now() }),\n\t\tpush: () => {},\n\t\tend: () => {},\n\t} as unknown as AssistantMessageEventStream;\n};\n\n/** Create a spy streamSimple that captures the options it receives and returns a stub stream. */\nfunction createStreamSpy(): {\n\tstreamSimple: (model: Model<Api>, context: Context, options?: SimpleStreamOptions) => AssistantMessageEventStream;\n\tgetCapturedOptions: () => SimpleStreamOptions | undefined;\n} {\n\tlet capturedOptions: SimpleStreamOptions | undefined;\n\tconst streamSimple = (_model: Model<Api>, _context: Context, options?: SimpleStreamOptions) => {\n\t\tcapturedOptions = options;\n\t\t// Return a minimal stub that satisfies AssistantMessageEventStream\n\t\treturn {\n\t\t\t[Symbol.asyncIterator]() { return { next: async () => ({ value: undefined, done: true as const }) }; },\n\t\t\tresult: () => Promise.resolve({ role: \"assistant\" as const, content: [], api: \"test\" as Api, provider: \"test\", model: \"test\", usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } }, stopReason: \"stop\" as const, timestamp: Date.now() }),\n\t\t\tpush: () => {},\n\t\t\tend: () => {},\n\t\t} as unknown as AssistantMessageEventStream;\n\t};\n\treturn { streamSimple, getCapturedOptions: () => capturedOptions };\n}\n\n// ─── Registration ─────────────────────────────────────────────────────────────\n\ndescribe(\"ModelRegistry authMode — registration\", () => {\n\tit(\"registers externalCli provider with streamSimple and without apiKey/oauth\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tassert.doesNotThrow(() => {\n\t\t\tregistry.registerProvider(\"cli-provider\", {\n\t\t\t\tauthMode: \"externalCli\",\n\t\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\t\tapi: \"openai-completions\",\n\t\t\t\tstreamSimple: spy.streamSimple,\n\t\t\t\tmodels: [createProviderModel(\"cli-model\")],\n\t\t\t});\n\t\t});\n\t});\n\n\tit(\"registers none provider with streamSimple and without apiKey/oauth\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tassert.doesNotThrow(() => {\n\t\t\tregistry.registerProvider(\"none-provider\", {\n\t\t\t\tauthMode: \"none\",\n\t\t\t\tbaseUrl: \"http://localhost:11434\",\n\t\t\t\tapi: \"openai-completions\",\n\t\t\t\tstreamSimple: spy.streamSimple,\n\t\t\t\tmodels: [createProviderModel(\"local-model\")],\n\t\t\t});\n\t\t});\n\t});\n\n\tit(\"rejects apiKey provider without apiKey or oauth — message mentions authMode\", () => {\n\t\tconst registry = createRegistry();\n\t\tassert.throws(() => {\n\t\t\tregistry.registerProvider(\"apikey-provider\", {\n\t\t\t\tauthMode: \"apiKey\",\n\t\t\t\tbaseUrl: \"https://api.local\",\n\t\t\t\tapi: \"openai-completions\",\n\t\t\t\tmodels: [createProviderModel(\"model\")],\n\t\t\t});\n\t\t}, (err: Error) => {\n\t\t\tassert.ok(err.message.includes(\"authMode\"), \"error message must mention authMode\");\n\t\t\tassert.ok(err.message.includes(\"externalCli\"), \"error message must suggest externalCli\");\n\t\t\treturn true;\n\t\t});\n\t});\n\n\tit(\"rejects provider with no authMode and no apiKey/oauth (defaults to apiKey)\", () => {\n\t\tconst registry = createRegistry();\n\t\tassert.throws(() => {\n\t\t\tregistry.registerProvider(\"bare-provider\", {\n\t\t\t\tbaseUrl: \"https://api.local\",\n\t\t\t\tapi: \"openai-completions\",\n\t\t\t\tmodels: [createProviderModel(\"model\")],\n\t\t\t});\n\t\t}, (err: Error) => {\n\t\t\tassert.ok(err.message.includes(\"authMode\"), \"error message must mention authMode\");\n\t\t\treturn true;\n\t\t});\n\t});\n\n\tit(\"rejects externalCli provider without streamSimple\", () => {\n\t\tconst registry = createRegistry();\n\t\tassert.throws(() => {\n\t\t\tregistry.registerProvider(\"cli-no-stream\", {\n\t\t\t\tauthMode: \"externalCli\",\n\t\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\t\tapi: \"openai-completions\",\n\t\t\t\tmodels: [createProviderModel(\"model\")],\n\t\t\t});\n\t\t}, (err: Error) => {\n\t\t\tassert.ok(err.message.includes(\"streamSimple\"), \"error message must mention streamSimple\");\n\t\t\tassert.ok(err.message.includes(\"externalCli\"), \"error message must mention authMode\");\n\t\t\treturn true;\n\t\t});\n\t});\n\n\tit(\"rejects none provider without streamSimple\", () => {\n\t\tconst registry = createRegistry();\n\t\tassert.throws(() => {\n\t\t\tregistry.registerProvider(\"none-no-stream\", {\n\t\t\t\tauthMode: \"none\",\n\t\t\t\tbaseUrl: \"http://localhost:11434\",\n\t\t\t\tapi: \"openai-completions\",\n\t\t\t\tmodels: [createProviderModel(\"model\")],\n\t\t\t});\n\t\t}, (err: Error) => {\n\t\t\tassert.ok(err.message.includes(\"streamSimple\"), \"error message must mention streamSimple\");\n\t\t\tassert.ok(err.message.includes(\"none\"), \"error message must mention authMode\");\n\t\t\treturn true;\n\t\t});\n\t});\n\n\tit(\"rejects externalCli provider that also sets apiKey\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tassert.throws(() => {\n\t\t\tregistry.registerProvider(\"cli-with-key\", {\n\t\t\t\tauthMode: \"externalCli\",\n\t\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\t\tapi: \"openai-completions\",\n\t\t\t\tapiKey: \"SHOULD_NOT_EXIST\",\n\t\t\t\tstreamSimple: spy.streamSimple,\n\t\t\t\tmodels: [createProviderModel(\"model\")],\n\t\t\t});\n\t\t}, (err: Error) => {\n\t\t\tassert.ok(err.message.includes(\"apiKey\"), \"error message must mention apiKey\");\n\t\t\tassert.ok(err.message.includes(\"externalCli\"), \"error message must mention authMode\");\n\t\t\treturn true;\n\t\t});\n\t});\n\n\tit(\"rejects none provider that also sets apiKey\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tassert.throws(() => {\n\t\t\tregistry.registerProvider(\"none-with-key\", {\n\t\t\t\tauthMode: \"none\",\n\t\t\t\tbaseUrl: \"http://localhost:11434\",\n\t\t\t\tapi: \"openai-completions\",\n\t\t\t\tapiKey: \"SHOULD_NOT_EXIST\",\n\t\t\t\tstreamSimple: spy.streamSimple,\n\t\t\t\tmodels: [createProviderModel(\"model\")],\n\t\t\t});\n\t\t}, (err: Error) => {\n\t\t\tassert.ok(err.message.includes(\"apiKey\"), \"error message must mention apiKey\");\n\t\t\tassert.ok(err.message.includes(\"none\"), \"error message must mention authMode\");\n\t\t\treturn true;\n\t\t});\n\t});\n});\n\n// ─── getProviderAuthMode ──────────────────────────────────────────────────────\n\ndescribe(\"ModelRegistry authMode — getProviderAuthMode\", () => {\n\tit(\"returns apiKey for unregistered (built-in) providers\", () => {\n\t\tconst registry = createRegistry();\n\t\tassert.equal(registry.getProviderAuthMode(\"anthropic\"), \"apiKey\");\n\t});\n\n\tit(\"returns explicit authMode when set\", () => {\n\t\tconst registry = createRegistry();\n\t\tregistry.registerProvider(\"cli\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tassert.equal(registry.getProviderAuthMode(\"cli\"), \"externalCli\");\n\t});\n\n\tit(\"returns none when authMode is none\", () => {\n\t\tconst registry = createRegistry();\n\t\tregistry.registerProvider(\"local\", {\n\t\t\tauthMode: \"none\",\n\t\t\tbaseUrl: \"http://localhost:11434\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tassert.equal(registry.getProviderAuthMode(\"local\"), \"none\");\n\t});\n});\n\n// ─── isProviderRequestReady ───────────────────────────────────────────────────\n\ndescribe(\"ModelRegistry authMode — isProviderRequestReady\", () => {\n\tit(\"returns true for externalCli without stored auth\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tregistry.registerProvider(\"cli\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tassert.equal(registry.isProviderRequestReady(\"cli\"), true);\n\t});\n\n\tit(\"returns true for none without stored auth\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tregistry.registerProvider(\"local\", {\n\t\t\tauthMode: \"none\",\n\t\t\tbaseUrl: \"http://localhost:11434\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tassert.equal(registry.isProviderRequestReady(\"local\"), true);\n\t});\n\n\tit(\"returns false for apiKey provider without stored auth\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tassert.equal(registry.isProviderRequestReady(\"anthropic\"), false);\n\t});\n\n\tit(\"returns true for apiKey provider with stored auth\", () => {\n\t\tconst registry = createRegistry(() => true);\n\t\tassert.equal(registry.isProviderRequestReady(\"anthropic\"), true);\n\t});\n});\n\n// ─── isReady callback ─────────────────────────────────────────────────────────\n\ndescribe(\"ModelRegistry authMode — isReady callback\", () => {\n\tit(\"calls isReady and returns its result for externalCli provider\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tregistry.registerProvider(\"cli-down\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tisReady: () => false,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tassert.equal(registry.isProviderRequestReady(\"cli-down\"), false);\n\t});\n\n\tit(\"calls isReady for apiKey provider (overrides hasAuth)\", () => {\n\t\tconst registry = createRegistry(() => true);\n\t\tregistry.registerProvider(\"strict-provider\", {\n\t\t\tapiKey: \"MY_KEY\",\n\t\t\tbaseUrl: \"https://api.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tisReady: () => false,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tassert.equal(registry.isProviderRequestReady(\"strict-provider\"), false);\n\t});\n\n\tit(\"isReady returning true makes provider available\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tregistry.registerProvider(\"healthy-cli\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tisReady: () => true,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tassert.equal(registry.isProviderRequestReady(\"healthy-cli\"), true);\n\t});\n\n\tit(\"falls through to default behavior when isReady not provided\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tregistry.registerProvider(\"no-callback\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\t// externalCli without isReady → true (default)\n\t\tassert.equal(registry.isProviderRequestReady(\"no-callback\"), true);\n\t});\n});\n\n// ─── getAvailable ─────────────────────────────────────────────────────────────\n\ndescribe(\"ModelRegistry authMode — getAvailable\", () => {\n\tit(\"includes externalCli models without stored auth\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tregistry.registerProvider(\"cli\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"cli-model\")],\n\t\t});\n\t\tassert.ok(findModel(registry, \"cli\", \"cli-model\"));\n\t});\n\n\tit(\"includes none models without stored auth\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tregistry.registerProvider(\"local\", {\n\t\t\tauthMode: \"none\",\n\t\t\tbaseUrl: \"http://localhost:11434\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"local-model\")],\n\t\t});\n\t\tassert.ok(findModel(registry, \"local\", \"local-model\"));\n\t});\n\n\tit(\"excludes externalCli models when isReady returns false\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tregistry.registerProvider(\"cli-down\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tisReady: () => false,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tassert.equal(findModel(registry, \"cli-down\", \"m\"), undefined);\n\t});\n\n\tit(\"excludes apiKey models without stored auth\", () => {\n\t\tconst registry = createRegistry(() => false);\n\t\tconst available = registry.getAvailable();\n\t\tassert.equal(available.length, 0);\n\t});\n});\n\n// ─── getApiKey ────────────────────────────────────────────────────────────────\n\ndescribe(\"ModelRegistry authMode — getApiKey\", () => {\n\tit(\"returns undefined for externalCli provider\", async () => {\n\t\tconst registry = createRegistry();\n\t\tregistry.registerProvider(\"cli\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tconst model = registry.getAll().find((m) => m.provider === \"cli\")!;\n\t\tassert.equal(await registry.getApiKey(model), undefined);\n\t});\n\n\tit(\"returns undefined for none provider\", async () => {\n\t\tconst registry = createRegistry();\n\t\tregistry.registerProvider(\"local\", {\n\t\t\tauthMode: \"none\",\n\t\t\tbaseUrl: \"http://localhost:11434\",\n\t\t\tapi: \"openai-completions\",\n\t\t\tstreamSimple: noopStreamSimple,\n\t\t\tmodels: [createProviderModel(\"m\")],\n\t\t});\n\t\tconst model = registry.getAll().find((m) => m.provider === \"local\")!;\n\t\tassert.equal(await registry.getApiKey(model), undefined);\n\t});\n\n\tit(\"delegates to authStorage for apiKey provider\", async () => {\n\t\tconst registry = createRegistry();\n\t\tconst key = await registry.getApiKeyForProvider(\"anthropic\");\n\t\tassert.equal(key, undefined);\n\t});\n});\n\n// ─── streamSimple apiKey stripping ────────────────────────────────────────────\n\ndescribe(\"ModelRegistry authMode — streamSimple apiKey boundary\", () => {\n\tit(\"strips apiKey from options for externalCli provider\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tconst apiType = `ext-cli-strip-${Date.now()}`;\n\n\t\tregistry.registerProvider(\"cli-strip\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: apiType as Api,\n\t\t\tstreamSimple: spy.streamSimple,\n\t\t\tmodels: [createProviderModel(\"m\", apiType)],\n\t\t});\n\n\t\tconst provider = getApiProvider(apiType as Api);\n\t\tassert.ok(provider, \"provider must be registered in api registry\");\n\n\t\tprovider.streamSimple(\n\t\t\tmakeModel(\"cli-strip\", \"m\", apiType),\n\t\t\tmakeContext(),\n\t\t\t{ apiKey: \"should-be-stripped\", maxTokens: 1024 } as SimpleStreamOptions,\n\t\t);\n\n\t\tconst captured = spy.getCapturedOptions();\n\t\tassert.ok(captured, \"streamSimple must have been called\");\n\t\tassert.equal(\"apiKey\" in captured, false, \"apiKey must not exist in options for externalCli provider\");\n\t\tassert.equal(captured.maxTokens, 1024, \"other options must pass through\");\n\t});\n\n\tit(\"strips apiKey from options for none provider\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tconst apiType = `none-strip-${Date.now()}`;\n\n\t\tregistry.registerProvider(\"none-strip\", {\n\t\t\tauthMode: \"none\",\n\t\t\tbaseUrl: \"http://localhost:11434\",\n\t\t\tapi: apiType as Api,\n\t\t\tstreamSimple: spy.streamSimple,\n\t\t\tmodels: [createProviderModel(\"m\", apiType)],\n\t\t});\n\n\t\tconst provider = getApiProvider(apiType as Api);\n\t\tassert.ok(provider, \"provider must be registered in api registry\");\n\n\t\tprovider.streamSimple(\n\t\t\tmakeModel(\"none-strip\", \"m\", apiType),\n\t\t\tmakeContext(),\n\t\t\t{ apiKey: \"should-be-stripped\", maxTokens: 2048 } as SimpleStreamOptions,\n\t\t);\n\n\t\tconst captured = spy.getCapturedOptions();\n\t\tassert.ok(captured, \"streamSimple must have been called\");\n\t\tassert.equal(\"apiKey\" in captured, false, \"apiKey must not exist in options for none provider\");\n\t\tassert.equal(captured.maxTokens, 2048, \"other options must pass through\");\n\t});\n\n\tit(\"preserves apiKey in options for apiKey provider\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tconst apiType = `apikey-preserve-${Date.now()}`;\n\n\t\tregistry.registerProvider(\"apikey-preserve\", {\n\t\t\tapiKey: \"MY_KEY\",\n\t\t\tbaseUrl: \"https://api.local\",\n\t\t\tapi: apiType as Api,\n\t\t\tstreamSimple: spy.streamSimple,\n\t\t\tmodels: [createProviderModel(\"m\", apiType)],\n\t\t});\n\n\t\tconst provider = getApiProvider(apiType as Api);\n\t\tassert.ok(provider, \"provider must be registered in api registry\");\n\n\t\tprovider.streamSimple(\n\t\t\tmakeModel(\"apikey-preserve\", \"m\", apiType),\n\t\t\tmakeContext(),\n\t\t\t{ apiKey: \"sk-real-key\", maxTokens: 4096 } as SimpleStreamOptions,\n\t\t);\n\n\t\tconst captured = spy.getCapturedOptions();\n\t\tassert.ok(captured, \"streamSimple must have been called\");\n\t\tassert.equal(captured.apiKey, \"sk-real-key\", \"apiKey must be preserved for apiKey provider\");\n\t\tassert.equal(captured.maxTokens, 4096, \"other options must pass through\");\n\t});\n\n\tit(\"handles undefined options for externalCli provider\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tconst apiType = `ext-cli-undef-${Date.now()}`;\n\n\t\tregistry.registerProvider(\"cli-undef\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: apiType as Api,\n\t\t\tstreamSimple: spy.streamSimple,\n\t\t\tmodels: [createProviderModel(\"m\", apiType)],\n\t\t});\n\n\t\tconst provider = getApiProvider(apiType as Api);\n\t\tassert.ok(provider, \"provider must be registered in api registry\");\n\n\t\tprovider.streamSimple(\n\t\t\tmakeModel(\"cli-undef\", \"m\", apiType),\n\t\t\tmakeContext(),\n\t\t\tundefined,\n\t\t);\n\n\t\tconst captured = spy.getCapturedOptions();\n\t\tassert.ok(captured !== undefined, \"streamSimple must have been called\");\n\t\tassert.equal(\"apiKey\" in captured, false, \"apiKey must not exist even when options is undefined\");\n\t});\n\n\tit(\"strips apiKey but preserves signal and other fields for externalCli\", () => {\n\t\tconst registry = createRegistry();\n\t\tconst spy = createStreamSpy();\n\t\tconst apiType = `ext-cli-fields-${Date.now()}`;\n\t\tconst abortController = new AbortController();\n\n\t\tregistry.registerProvider(\"cli-fields\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"https://cli.local\",\n\t\t\tapi: apiType as Api,\n\t\t\tstreamSimple: spy.streamSimple,\n\t\t\tmodels: [createProviderModel(\"m\", apiType)],\n\t\t});\n\n\t\tconst provider = getApiProvider(apiType as Api);\n\t\tassert.ok(provider, \"provider must be registered in api registry\");\n\n\t\tprovider.streamSimple(\n\t\t\tmakeModel(\"cli-fields\", \"m\", apiType),\n\t\t\tmakeContext(),\n\t\t\t{ apiKey: \"strip-me\", maxTokens: 8192, signal: abortController.signal, reasoning: \"high\" } as SimpleStreamOptions,\n\t\t);\n\n\t\tconst captured = spy.getCapturedOptions();\n\t\tassert.ok(captured, \"streamSimple must have been called\");\n\t\tassert.equal(\"apiKey\" in captured, false, \"apiKey must be stripped\");\n\t\tassert.equal(captured.maxTokens, 8192, \"maxTokens must pass through\");\n\t\tassert.equal(captured.signal, abortController.signal, \"signal must pass through\");\n\t\tassert.equal((captured as Record<string, unknown>).reasoning, \"high\", \"reasoning must pass through\");\n\t});\n});\n\n// ─── Provider-scoped stream routing (#2533) ───────────────────────────────────\n\ndescribe(\"ModelRegistry authMode — provider-scoped stream routing\", () => {\n\tit(\"does not clobber built-in stream handler when custom provider uses same api\", () => {\n\t\tconst registry = createRegistry(() => true);\n\t\tconst customSpy = createStreamSpy();\n\n\t\t// Register a custom provider with the same API type as a built-in (anthropic-messages).\n\t\t// This simulates the claude-code-cli extension registering with api: \"anthropic-messages\".\n\t\tregistry.registerProvider(\"custom-cli\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"local://custom\",\n\t\t\tapi: \"anthropic-messages\",\n\t\t\tstreamSimple: customSpy.streamSimple,\n\t\t\tmodels: [createProviderModel(\"custom-model\", \"anthropic-messages\")],\n\t\t});\n\n\t\t// The built-in anthropic-messages provider should still be accessible\n\t\t// when calling streamSimple with a model from the built-in provider.\n\t\tconst provider = getApiProvider(\"anthropic-messages\" as Api);\n\t\tassert.ok(provider, \"anthropic-messages provider must still be registered\");\n\n\t\t// Call with a built-in anthropic model — should NOT hit the custom spy.\n\t\t// The built-in handler will throw (no API key), which proves the routing\n\t\t// correctly delegates to the built-in instead of the custom handler.\n\t\tassert.throws(\n\t\t\t() => provider.streamSimple(\n\t\t\t\tmakeModel(\"anthropic\", \"claude-sonnet-4-6\", \"anthropic-messages\"),\n\t\t\t\tmakeContext(),\n\t\t\t\t{ maxTokens: 4096 } as SimpleStreamOptions,\n\t\t\t),\n\t\t\t(err: Error) => err.message.includes(\"API key\"),\n\t\t\t\"built-in Anthropic handler must be invoked (throws because no API key in tests)\",\n\t\t);\n\n\t\tassert.equal(\n\t\t\tcustomSpy.getCapturedOptions(),\n\t\t\tundefined,\n\t\t\t\"custom provider's streamSimple must NOT be called for anthropic provider models\",\n\t\t);\n\t});\n\n\tit(\"routes to custom provider when model.provider matches\", () => {\n\t\tconst registry = createRegistry(() => true);\n\t\tconst customSpy = createStreamSpy();\n\n\t\tregistry.registerProvider(\"custom-cli\", {\n\t\t\tauthMode: \"externalCli\",\n\t\t\tbaseUrl: \"local://custom\",\n\t\t\tapi: \"anthropic-messages\",\n\t\t\tstreamSimple: customSpy.streamSimple,\n\t\t\tmodels: [createProviderModel(\"custom-model\", \"anthropic-messages\")],\n\t\t});\n\n\t\tconst provider = getApiProvider(\"anthropic-messages\" as Api);\n\t\tassert.ok(provider);\n\n\t\t// Call with the custom provider's model — should hit the custom spy\n\t\tprovider.streamSimple(\n\t\t\tmakeModel(\"custom-cli\", \"custom-model\", \"anthropic-messages\"),\n\t\t\tmakeContext(),\n\t\t\t{ maxTokens: 2048 } as SimpleStreamOptions,\n\t\t);\n\n\t\tconst captured = customSpy.getCapturedOptions();\n\t\tassert.ok(captured, \"custom provider's streamSimple must be called for its own models\");\n\t\tassert.equal(captured.maxTokens, 2048);\n\t});\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"model-registry.d.ts","sourceRoot":"","sources":["../../src/core/model-registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,KAAK,GAAG,EACR,KAAK,2BAA2B,EAChC,KAAK,OAAO,EAIZ,KAAK,KAAK,EACV,KAAK,sBAAsB,EAK3B,KAAK,mBAAmB,EACxB,MAAM,YAAY,CAAC;AAOpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAmB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAwG7E,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,OAAO,GAAG,aAAa,GAAG,MAAM,CAAC;AA2F3E;;GAEG;AACH,qBAAa,aAAa;IASxB,QAAQ,CAAC,WAAW,EAAE,WAAW;IACjC,OAAO,CAAC,cAAc;IATvB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,gBAAgB,CAAoB;IAC5C,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,qBAAqB,CAAkC;IAC/D,OAAO,CAAC,mBAAmB,CAA+C;IAC1E,OAAO,CAAC,SAAS,CAAiC;gBAGxC,WAAW,EAAE,WAAW,EACzB,cAAc,GAAE,MAAM,GAAG,SAA8C;IAoBhF;;OAEG;IACH,OAAO,IAAI,IAAI;IAef;;OAEG;I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5B,IAAI,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAE,CAAC;QAC/E,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,MAAM,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;KAC9B,CAAC,CAAC;CACH"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Model registry - manages built-in and custom models, provides API key resolution.
3
3
  */
4
- import { getModels, getProviders, registerApiProvider, resetApiProviders, } from "@gsd/pi-ai";
4
+ import { getApiProvider, getModels, getProviders, registerApiProvider, resetApiProviders, } from "@gsd/pi-ai";
5
5
  import { registerOAuthProvider, resetOAuthProviders } from "@gsd/pi-ai/oauth";
6
6
  import { Type } from "@sinclair/typebox";
7
7
  import AjvModule from "ajv";
@@ -511,10 +511,33 @@ export class ModelRegistry {
511
511
  return rawStreamSimple(model, context, opts);
512
512
  })
513
513
  : rawStreamSimple;
514
+ // Guard: if there's already a handler registered for this API, wrap
515
+ // the new one so it only fires for models from this provider and
516
+ // delegates to the previous handler for all other providers. Without
517
+ // this, a custom provider using api:"anthropic-messages" would clobber
518
+ // the built-in Anthropic stream handler (#2536).
519
+ const existingProvider = getApiProvider(config.api);
520
+ const scopedStream = existingProvider
521
+ ? (model, context, options) => {
522
+ if (model.provider === providerName) {
523
+ return streamSimple(model, context, options);
524
+ }
525
+ return existingProvider.streamSimple(model, context, options);
526
+ }
527
+ : streamSimple;
528
+ const newFullStream = (model, context, options) => scopedStream(model, context, options);
529
+ const scopedFullStream = existingProvider
530
+ ? (model, context, options) => {
531
+ if (model.provider === providerName) {
532
+ return newFullStream(model, context, options);
533
+ }
534
+ return existingProvider.stream(model, context, options);
535
+ }
536
+ : newFullStream;
514
537
  registerApiProvider({
515
538
  api: config.api,
516
- stream: (model, context, options) => streamSimple(model, context, options),
517
- streamSimple,
539
+ stream: scopedFullStream,
540
+ streamSimple: scopedStream,
518
541
  }, `provider:${providerName}`);
519
542
  }
520
543
  // Store API key for auth resolution