gsd-pi 2.68.0 → 2.68.1-dev.58193fa
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.
- package/README.md +66 -70
- package/dist/resources/extensions/gsd/auto-model-selection.js +27 -1
- package/dist/resources/extensions/gsd/auto.js +8 -2
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +7 -0
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +1 -5
- package/dist/resources/extensions/gsd/codebase-generator.js +12 -0
- package/dist/resources/extensions/gsd/guided-flow.js +25 -70
- package/dist/resources/extensions/gsd/model-router.js +85 -2
- package/dist/resources/extensions/gsd/prompts/discuss.md +2 -0
- package/dist/resources/extensions/gsd/templates/context.md +34 -2
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +16 -16
- package/dist/web/standalone/.next/build-manifest.json +3 -3
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/required-server-files.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error/page.js +3 -3
- package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
- package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +3 -3
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/api/boot/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/boot/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/browse-directories/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/dev-mode/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/dev-mode/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/experimental/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/experimental/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/files/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/inspect/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/inspect/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/knowledge/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/knowledge/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/live-state/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/live-state/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/notifications/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/notifications/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/preferences/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/preferences/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/projects/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/remote-questions/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/remote-questions/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/browser/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/browser/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/command/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/command/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/events/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/session/events/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/manage/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/manage/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/shutdown/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/steer/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/steer/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/switch-root/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/switch-root/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/input/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +2 -2
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/upload/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/upload/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +4 -4
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -4
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +3 -3
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/page.js +2 -2
- package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +16 -16
- package/dist/web/standalone/.next/server/chunks/63.js +3 -3
- package/dist/web/standalone/.next/server/chunks/6897.js +1 -1
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware.js +2 -2
- package/dist/web/standalone/.next/server/next-font-manifest.js +1 -1
- package/dist/web/standalone/.next/server/next-font-manifest.json +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/.next/static/chunks/app/_not-found/{page-2f24283c162b6ab3.js → page-f2a7482d42a5614b.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/app/{layout-9ecfd95f343793f0.js → layout-a16c7a7ecdf0c2cf.js} +1 -1
- package/dist/web/standalone/.next/static/chunks/app/page-f1e30ab6bb269149.js +1 -0
- package/dist/web/standalone/.next/static/chunks/main-app-fdab67f7802d7832.js +1 -0
- package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-459824ffb8c323dd.js +1 -0
- package/dist/web/standalone/node_modules/node-pty/build/Makefile +2 -2
- package/dist/web/standalone/node_modules/node-pty/build/Release/pty.node +0 -0
- package/dist/web/standalone/node_modules/node-pty/build/pty.target.mk +14 -14
- package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api.target.mk +14 -14
- package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_except.target.mk +14 -14
- package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_maybe.target.mk +14 -14
- package/dist/web/standalone/server.js +1 -1
- package/package.json +1 -1
- package/packages/pi-ai/dist/index.d.ts +3 -0
- package/packages/pi-ai/dist/index.d.ts.map +1 -1
- package/packages/pi-ai/dist/index.js +2 -0
- package/packages/pi-ai/dist/index.js.map +1 -1
- package/packages/pi-ai/dist/providers/amazon-bedrock.js +2 -2
- package/packages/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic-shared.js +2 -2
- package/packages/pi-ai/dist/providers/anthropic-shared.js.map +1 -1
- package/packages/pi-ai/dist/providers/google-shared.js +2 -2
- package/packages/pi-ai/dist/providers/google-shared.js.map +1 -1
- package/packages/pi-ai/dist/providers/mistral.js +2 -2
- package/packages/pi-ai/dist/providers/mistral.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.js +2 -2
- package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-responses-shared.js +2 -2
- package/packages/pi-ai/dist/providers/openai-responses-shared.js.map +1 -1
- package/packages/pi-ai/dist/providers/provider-capabilities.d.ts +59 -0
- package/packages/pi-ai/dist/providers/provider-capabilities.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/provider-capabilities.js +173 -0
- package/packages/pi-ai/dist/providers/provider-capabilities.js.map +1 -0
- package/packages/pi-ai/dist/providers/provider-capabilities.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/provider-capabilities.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/provider-capabilities.test.js +132 -0
- package/packages/pi-ai/dist/providers/provider-capabilities.test.js.map +1 -0
- package/packages/pi-ai/dist/providers/transform-messages-report.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/transform-messages-report.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/transform-messages-report.test.js +172 -0
- package/packages/pi-ai/dist/providers/transform-messages-report.test.js.map +1 -0
- package/packages/pi-ai/dist/providers/transform-messages.d.ts +34 -1
- package/packages/pi-ai/dist/providers/transform-messages.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/transform-messages.js +73 -2
- package/packages/pi-ai/dist/providers/transform-messages.js.map +1 -1
- package/packages/pi-ai/src/index.ts +3 -0
- package/packages/pi-ai/src/providers/amazon-bedrock.ts +2 -2
- package/packages/pi-ai/src/providers/anthropic-shared.ts +2 -2
- package/packages/pi-ai/src/providers/google-shared.ts +2 -2
- package/packages/pi-ai/src/providers/mistral.ts +2 -2
- package/packages/pi-ai/src/providers/openai-completions.ts +2 -2
- package/packages/pi-ai/src/providers/openai-responses-shared.ts +2 -2
- package/packages/pi-ai/src/providers/provider-capabilities.test.ts +174 -0
- package/packages/pi-ai/src/providers/provider-capabilities.ts +215 -0
- package/packages/pi-ai/src/providers/transform-messages-report.test.ts +189 -0
- package/packages/pi-ai/src/providers/transform-messages.ts +94 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.js +10 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +2 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.js +15 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +41 -0
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts +1 -0
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/index.js +1 -0
- package/packages/pi-coding-agent/dist/core/tools/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/tool-compatibility-registry.d.ts +27 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-compatibility-registry.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-compatibility-registry.js +69 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-compatibility-registry.js.map +1 -0
- package/packages/pi-coding-agent/dist/index.d.ts +2 -2
- package/packages/pi-coding-agent/dist/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/index.js +3 -1
- package/packages/pi-coding-agent/dist/index.js.map +1 -1
- package/packages/pi-coding-agent/package.json +1 -1
- package/packages/pi-coding-agent/src/core/extensions/index.ts +4 -0
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +11 -1
- package/packages/pi-coding-agent/src/core/extensions/runner.ts +18 -0
- package/packages/pi-coding-agent/src/core/extensions/types.ts +45 -0
- package/packages/pi-coding-agent/src/core/tools/index.ts +7 -0
- package/packages/pi-coding-agent/src/core/tools/tool-compatibility-registry.ts +83 -0
- package/packages/pi-coding-agent/src/index.ts +9 -0
- package/pkg/package.json +1 -1
- package/src/resources/extensions/gsd/auto-model-selection.ts +36 -4
- package/src/resources/extensions/gsd/auto.ts +8 -2
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +8 -0
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +1 -5
- package/src/resources/extensions/gsd/codebase-generator.ts +16 -0
- package/src/resources/extensions/gsd/guided-flow.ts +22 -84
- package/src/resources/extensions/gsd/model-router.ts +117 -10
- package/src/resources/extensions/gsd/preferences-types.ts +3 -1
- package/src/resources/extensions/gsd/prompts/discuss.md +2 -0
- package/src/resources/extensions/gsd/templates/context.md +34 -2
- package/src/resources/extensions/gsd/tests/capability-router.test.ts +31 -7
- package/src/resources/extensions/gsd/tests/codebase-generator.test.ts +28 -0
- package/src/resources/extensions/gsd/tests/discord-invite-links.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/model-router.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/resource-loader-import-path.test.ts +37 -0
- package/src/resources/extensions/gsd/tests/tool-compatibility.test.ts +199 -0
- package/src/resources/extensions/gsd/tests/write-gate.test.ts +13 -16
- package/dist/resources/extensions/gsd/prompt-validation.js +0 -67
- package/dist/resources/extensions/gsd/prompts/discuss-prepared.md +0 -424
- package/dist/resources/extensions/gsd/templates/context-enhanced.md +0 -138
- package/dist/web/standalone/.next/static/chunks/app/page-7115e62689b5fd84.js +0 -1
- package/dist/web/standalone/.next/static/chunks/main-app-d3d4c336195465f9.js +0 -1
- package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-ab5a8926e07ec673.js +0 -1
- package/src/resources/extensions/gsd/prompt-validation.ts +0 -88
- package/src/resources/extensions/gsd/prompts/discuss-prepared.md +0 -424
- package/src/resources/extensions/gsd/templates/context-enhanced.md +0 -138
- package/src/resources/extensions/gsd/tests/adversarial-review-fixes.test.ts +0 -223
- package/src/resources/extensions/gsd/tests/integration/test-isolation.ts +0 -53
- package/src/resources/extensions/gsd/tests/integration-prepared-discussion.test.ts +0 -525
- package/src/resources/extensions/gsd/tests/preparation.test.ts +0 -1211
- package/src/resources/extensions/gsd/tests/prompt-builder.test.ts +0 -669
- /package/dist/web/standalone/.next/static/{ka3ShQTakcliYL-EXRRb6 → YFZaRxYFkrifCiWU3AcrJ}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{ka3ShQTakcliYL-EXRRb6 → YFZaRxYFkrifCiWU3AcrJ}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// GSD-2 — Provider Capabilities Registry (ADR-005 Phase 1)
|
|
2
|
+
// Declarative registry of what each API provider supports, consolidating
|
|
3
|
+
// scattered knowledge from *-shared.ts files into a queryable data structure.
|
|
4
|
+
// ─── Registry ───────────────────────────────────────────────────────────────
|
|
5
|
+
/**
|
|
6
|
+
* Built-in provider capability profiles.
|
|
7
|
+
*
|
|
8
|
+
* Sources (consolidated from scattered *-shared.ts files):
|
|
9
|
+
* - anthropic-shared.ts: normalizeToolCallId (64-char, [a-zA-Z0-9_-])
|
|
10
|
+
* - openai-responses-shared.ts: ID normalization (64-char, fc_ prefix), image-in-tool-result workaround
|
|
11
|
+
* - google-shared.ts: sanitizeSchemaForGoogle (patternProperties, const), requiresToolCallId
|
|
12
|
+
* - mistral.ts: MISTRAL_TOOL_CALL_ID_LENGTH = 9
|
|
13
|
+
* - amazon-bedrock.ts: normalizeToolCallId (64-char, [a-zA-Z0-9_-])
|
|
14
|
+
*/
|
|
15
|
+
export const PROVIDER_CAPABILITIES = {
|
|
16
|
+
"anthropic-messages": {
|
|
17
|
+
toolCalling: true,
|
|
18
|
+
maxTools: 0,
|
|
19
|
+
imageToolResults: true,
|
|
20
|
+
structuredOutput: true,
|
|
21
|
+
toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },
|
|
22
|
+
thinkingPersistence: "full",
|
|
23
|
+
unsupportedSchemaFeatures: [],
|
|
24
|
+
},
|
|
25
|
+
"anthropic-vertex": {
|
|
26
|
+
toolCalling: true,
|
|
27
|
+
maxTools: 0,
|
|
28
|
+
imageToolResults: true,
|
|
29
|
+
structuredOutput: true,
|
|
30
|
+
toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },
|
|
31
|
+
thinkingPersistence: "full",
|
|
32
|
+
unsupportedSchemaFeatures: [],
|
|
33
|
+
},
|
|
34
|
+
"openai-responses": {
|
|
35
|
+
toolCalling: true,
|
|
36
|
+
maxTools: 0,
|
|
37
|
+
imageToolResults: false, // images sent as separate user message, not in tool result
|
|
38
|
+
structuredOutput: true,
|
|
39
|
+
toolCallIdFormat: { maxLength: 512, allowedChars: /^.+$/ },
|
|
40
|
+
thinkingPersistence: "text-only",
|
|
41
|
+
unsupportedSchemaFeatures: [],
|
|
42
|
+
},
|
|
43
|
+
"azure-openai-responses": {
|
|
44
|
+
toolCalling: true,
|
|
45
|
+
maxTools: 0,
|
|
46
|
+
imageToolResults: false,
|
|
47
|
+
structuredOutput: true,
|
|
48
|
+
toolCallIdFormat: { maxLength: 512, allowedChars: /^.+$/ },
|
|
49
|
+
thinkingPersistence: "text-only",
|
|
50
|
+
unsupportedSchemaFeatures: [],
|
|
51
|
+
},
|
|
52
|
+
"openai-codex-responses": {
|
|
53
|
+
toolCalling: true,
|
|
54
|
+
maxTools: 0,
|
|
55
|
+
imageToolResults: false,
|
|
56
|
+
structuredOutput: true,
|
|
57
|
+
toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },
|
|
58
|
+
thinkingPersistence: "text-only",
|
|
59
|
+
unsupportedSchemaFeatures: [],
|
|
60
|
+
},
|
|
61
|
+
"openai-completions": {
|
|
62
|
+
toolCalling: true,
|
|
63
|
+
maxTools: 0,
|
|
64
|
+
imageToolResults: false,
|
|
65
|
+
structuredOutput: true,
|
|
66
|
+
toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },
|
|
67
|
+
thinkingPersistence: "text-only",
|
|
68
|
+
unsupportedSchemaFeatures: [],
|
|
69
|
+
},
|
|
70
|
+
"google-generative-ai": {
|
|
71
|
+
toolCalling: true,
|
|
72
|
+
maxTools: 0,
|
|
73
|
+
imageToolResults: true,
|
|
74
|
+
structuredOutput: true,
|
|
75
|
+
toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },
|
|
76
|
+
thinkingPersistence: "text-only",
|
|
77
|
+
unsupportedSchemaFeatures: ["patternProperties", "const"],
|
|
78
|
+
},
|
|
79
|
+
"google-gemini-cli": {
|
|
80
|
+
toolCalling: true,
|
|
81
|
+
maxTools: 0,
|
|
82
|
+
imageToolResults: true,
|
|
83
|
+
structuredOutput: true,
|
|
84
|
+
toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },
|
|
85
|
+
thinkingPersistence: "text-only",
|
|
86
|
+
unsupportedSchemaFeatures: ["patternProperties", "const"],
|
|
87
|
+
},
|
|
88
|
+
"google-vertex": {
|
|
89
|
+
toolCalling: true,
|
|
90
|
+
maxTools: 0,
|
|
91
|
+
imageToolResults: true,
|
|
92
|
+
structuredOutput: true,
|
|
93
|
+
toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },
|
|
94
|
+
thinkingPersistence: "text-only",
|
|
95
|
+
unsupportedSchemaFeatures: ["patternProperties", "const"],
|
|
96
|
+
},
|
|
97
|
+
"mistral-conversations": {
|
|
98
|
+
toolCalling: true,
|
|
99
|
+
maxTools: 0,
|
|
100
|
+
imageToolResults: false,
|
|
101
|
+
structuredOutput: true,
|
|
102
|
+
toolCallIdFormat: { maxLength: 9, allowedChars: /^[a-zA-Z0-9]+$/ },
|
|
103
|
+
thinkingPersistence: "none",
|
|
104
|
+
unsupportedSchemaFeatures: [],
|
|
105
|
+
},
|
|
106
|
+
"bedrock-converse-stream": {
|
|
107
|
+
toolCalling: true,
|
|
108
|
+
maxTools: 0,
|
|
109
|
+
imageToolResults: true, // Bedrock supports image content blocks in tool results
|
|
110
|
+
structuredOutput: true,
|
|
111
|
+
toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },
|
|
112
|
+
thinkingPersistence: "text-only",
|
|
113
|
+
unsupportedSchemaFeatures: [],
|
|
114
|
+
},
|
|
115
|
+
"ollama-chat": {
|
|
116
|
+
toolCalling: true,
|
|
117
|
+
maxTools: 0,
|
|
118
|
+
imageToolResults: false,
|
|
119
|
+
structuredOutput: false,
|
|
120
|
+
toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },
|
|
121
|
+
thinkingPersistence: "none",
|
|
122
|
+
unsupportedSchemaFeatures: [],
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
// ─── Default (permissive) profile for unknown providers ─────────────────────
|
|
126
|
+
const DEFAULT_CAPABILITIES = {
|
|
127
|
+
toolCalling: true,
|
|
128
|
+
maxTools: 0,
|
|
129
|
+
imageToolResults: true,
|
|
130
|
+
structuredOutput: true,
|
|
131
|
+
toolCallIdFormat: { maxLength: 512, allowedChars: /^.+$/ },
|
|
132
|
+
thinkingPersistence: "text-only",
|
|
133
|
+
unsupportedSchemaFeatures: [],
|
|
134
|
+
};
|
|
135
|
+
// ─── Public API ─────────────────────────────────────────────────────────────
|
|
136
|
+
/**
|
|
137
|
+
* Get capabilities for a provider API. Returns a permissive default for
|
|
138
|
+
* unknown providers (preserving existing behavior per ADR-005 principle 5).
|
|
139
|
+
*/
|
|
140
|
+
export function getProviderCapabilities(api) {
|
|
141
|
+
return PROVIDER_CAPABILITIES[api] ?? DEFAULT_CAPABILITIES;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Check if a provider supports all required schema features.
|
|
145
|
+
* Returns the list of unsupported features (empty if all supported).
|
|
146
|
+
*/
|
|
147
|
+
export function getUnsupportedFeatures(api, requiredFeatures) {
|
|
148
|
+
const caps = getProviderCapabilities(api);
|
|
149
|
+
return requiredFeatures.filter(f => caps.unsupportedSchemaFeatures.includes(f));
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Deep-merge user-provided capability overrides with built-in defaults.
|
|
153
|
+
* Partial overrides merge with the built-in profile for the given API.
|
|
154
|
+
*/
|
|
155
|
+
export function mergeCapabilityOverrides(api, overrides) {
|
|
156
|
+
const base = getProviderCapabilities(api);
|
|
157
|
+
return {
|
|
158
|
+
...base,
|
|
159
|
+
...overrides,
|
|
160
|
+
toolCallIdFormat: overrides.toolCallIdFormat
|
|
161
|
+
? { ...base.toolCallIdFormat, ...overrides.toolCallIdFormat }
|
|
162
|
+
: base.toolCallIdFormat,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Get all registered API names in the capability registry.
|
|
167
|
+
* Used by lint rules to verify all providers in register-builtins.ts
|
|
168
|
+
* have corresponding capability entries.
|
|
169
|
+
*/
|
|
170
|
+
export function getRegisteredApis() {
|
|
171
|
+
return Object.keys(PROVIDER_CAPABILITIES);
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=provider-capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-capabilities.js","sourceRoot":"","sources":["../../src/providers/provider-capabilities.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,yEAAyE;AACzE,8EAA8E;AA+B9E,+EAA+E;AAE/E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAyC;IACzE,oBAAoB,EAA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,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC;IAC1C,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAClF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,GAAW,EACX,SAEC;IAED,MAAM,IAAI,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC;IAC1C,OAAO;QACL,GAAG,IAAI;QACP,GAAG,SAAS;QACZ,gBAAgB,EAAE,SAAS,CAAC,gBAAgB;YAC1C,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,gBAAgB,EAAE,GAAG,SAAS,CAAC,gBAAgB,EAAE;YAC7D,CAAC,CAAC,IAAI,CAAC,gBAAgB;KAC1B,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["// GSD-2 — Provider Capabilities Registry (ADR-005 Phase 1)\n// Declarative registry of what each API provider supports, consolidating\n// scattered knowledge from *-shared.ts files into a queryable data structure.\n\nimport type { Api } from \"../types.js\";\n\n// ─── Types ──────────────────────────────────────────────────────────────────\n\n/**\n * Declarative capability profile for an API provider.\n * Used by the model router to filter incompatible models and by the tool\n * system to adjust tool sets per provider.\n */\nexport interface ProviderCapabilities {\n /** Whether models from this provider support tool/function calling */\n toolCalling: boolean;\n /** Maximum number of tools the provider handles well (0 = unlimited) */\n maxTools: number;\n /** Whether tool results can contain images */\n imageToolResults: boolean;\n /** Whether the provider supports structured JSON output */\n structuredOutput: boolean;\n /** Tool call ID format constraints */\n toolCallIdFormat: {\n maxLength: number;\n allowedChars: RegExp;\n };\n /** Whether thinking/reasoning blocks are preserved cross-turn */\n thinkingPersistence: \"full\" | \"text-only\" | \"none\";\n /** Schema features NOT supported (tools using these get filtered) */\n unsupportedSchemaFeatures: string[];\n}\n\n// ─── Registry ───────────────────────────────────────────────────────────────\n\n/**\n * Built-in provider capability profiles.\n *\n * Sources (consolidated from scattered *-shared.ts files):\n * - anthropic-shared.ts: normalizeToolCallId (64-char, [a-zA-Z0-9_-])\n * - openai-responses-shared.ts: ID normalization (64-char, fc_ prefix), image-in-tool-result workaround\n * - google-shared.ts: sanitizeSchemaForGoogle (patternProperties, const), requiresToolCallId\n * - mistral.ts: MISTRAL_TOOL_CALL_ID_LENGTH = 9\n * - amazon-bedrock.ts: normalizeToolCallId (64-char, [a-zA-Z0-9_-])\n */\nexport const PROVIDER_CAPABILITIES: Record<string, ProviderCapabilities> = {\n \"anthropic-messages\": {\n toolCalling: true,\n maxTools: 0,\n imageToolResults: true,\n structuredOutput: true,\n toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },\n thinkingPersistence: \"full\",\n unsupportedSchemaFeatures: [],\n },\n \"anthropic-vertex\": {\n toolCalling: true,\n maxTools: 0,\n imageToolResults: true,\n structuredOutput: true,\n toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },\n thinkingPersistence: \"full\",\n unsupportedSchemaFeatures: [],\n },\n \"openai-responses\": {\n toolCalling: true,\n maxTools: 0,\n imageToolResults: false, // images sent as separate user message, not in tool result\n structuredOutput: true,\n toolCallIdFormat: { maxLength: 512, allowedChars: /^.+$/ },\n thinkingPersistence: \"text-only\",\n unsupportedSchemaFeatures: [],\n },\n \"azure-openai-responses\": {\n toolCalling: true,\n maxTools: 0,\n imageToolResults: false,\n structuredOutput: true,\n toolCallIdFormat: { maxLength: 512, allowedChars: /^.+$/ },\n thinkingPersistence: \"text-only\",\n unsupportedSchemaFeatures: [],\n },\n \"openai-codex-responses\": {\n toolCalling: true,\n maxTools: 0,\n imageToolResults: false,\n structuredOutput: true,\n toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },\n thinkingPersistence: \"text-only\",\n unsupportedSchemaFeatures: [],\n },\n \"openai-completions\": {\n toolCalling: true,\n maxTools: 0,\n imageToolResults: false,\n structuredOutput: true,\n toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },\n thinkingPersistence: \"text-only\",\n unsupportedSchemaFeatures: [],\n },\n \"google-generative-ai\": {\n toolCalling: true,\n maxTools: 0,\n imageToolResults: true,\n structuredOutput: true,\n toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },\n thinkingPersistence: \"text-only\",\n unsupportedSchemaFeatures: [\"patternProperties\", \"const\"],\n },\n \"google-gemini-cli\": {\n toolCalling: true,\n maxTools: 0,\n imageToolResults: true,\n structuredOutput: true,\n toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },\n thinkingPersistence: \"text-only\",\n unsupportedSchemaFeatures: [\"patternProperties\", \"const\"],\n },\n \"google-vertex\": {\n toolCalling: true,\n maxTools: 0,\n imageToolResults: true,\n structuredOutput: true,\n toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },\n thinkingPersistence: \"text-only\",\n unsupportedSchemaFeatures: [\"patternProperties\", \"const\"],\n },\n \"mistral-conversations\": {\n toolCalling: true,\n maxTools: 0,\n imageToolResults: false,\n structuredOutput: true,\n toolCallIdFormat: { maxLength: 9, allowedChars: /^[a-zA-Z0-9]+$/ },\n thinkingPersistence: \"none\",\n unsupportedSchemaFeatures: [],\n },\n \"bedrock-converse-stream\": {\n toolCalling: true,\n maxTools: 0,\n imageToolResults: true, // Bedrock supports image content blocks in tool results\n structuredOutput: true,\n toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },\n thinkingPersistence: \"text-only\",\n unsupportedSchemaFeatures: [],\n },\n \"ollama-chat\": {\n toolCalling: true,\n maxTools: 0,\n imageToolResults: false,\n structuredOutput: false,\n toolCallIdFormat: { maxLength: 64, allowedChars: /^[a-zA-Z0-9_-]+$/ },\n thinkingPersistence: \"none\",\n unsupportedSchemaFeatures: [],\n },\n};\n\n// ─── Default (permissive) profile for unknown providers ─────────────────────\n\nconst DEFAULT_CAPABILITIES: ProviderCapabilities = {\n toolCalling: true,\n maxTools: 0,\n imageToolResults: true,\n structuredOutput: true,\n toolCallIdFormat: { maxLength: 512, allowedChars: /^.+$/ },\n thinkingPersistence: \"text-only\",\n unsupportedSchemaFeatures: [],\n};\n\n// ─── Public API ─────────────────────────────────────────────────────────────\n\n/**\n * Get capabilities for a provider API. Returns a permissive default for\n * unknown providers (preserving existing behavior per ADR-005 principle 5).\n */\nexport function getProviderCapabilities(api: string): ProviderCapabilities {\n return PROVIDER_CAPABILITIES[api] ?? DEFAULT_CAPABILITIES;\n}\n\n/**\n * Check if a provider supports all required schema features.\n * Returns the list of unsupported features (empty if all supported).\n */\nexport function getUnsupportedFeatures(api: string, requiredFeatures: string[]): string[] {\n const caps = getProviderCapabilities(api);\n return requiredFeatures.filter(f => caps.unsupportedSchemaFeatures.includes(f));\n}\n\n/**\n * Deep-merge user-provided capability overrides with built-in defaults.\n * Partial overrides merge with the built-in profile for the given API.\n */\nexport function mergeCapabilityOverrides(\n api: string,\n overrides: Partial<Omit<ProviderCapabilities, \"toolCallIdFormat\">> & {\n toolCallIdFormat?: Partial<ProviderCapabilities[\"toolCallIdFormat\"]>;\n },\n): ProviderCapabilities {\n const base = getProviderCapabilities(api);\n return {\n ...base,\n ...overrides,\n toolCallIdFormat: overrides.toolCallIdFormat\n ? { ...base.toolCallIdFormat, ...overrides.toolCallIdFormat }\n : base.toolCallIdFormat,\n };\n}\n\n/**\n * Get all registered API names in the capability registry.\n * Used by lint rules to verify all providers in register-builtins.ts\n * have corresponding capability entries.\n */\nexport function getRegisteredApis(): string[] {\n return Object.keys(PROVIDER_CAPABILITIES);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-capabilities.test.d.ts","sourceRoot":"","sources":["../../src/providers/provider-capabilities.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// GSD-2 — Provider Capabilities Registry Tests (ADR-005 Phase 1)
|
|
2
|
+
import { describe, test } from "node:test";
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { PROVIDER_CAPABILITIES, getProviderCapabilities, getUnsupportedFeatures, mergeCapabilityOverrides, getRegisteredApis, } from "./provider-capabilities.js";
|
|
5
|
+
// ─── Registry Completeness ──────────────────────────────────────────────────
|
|
6
|
+
describe("PROVIDER_CAPABILITIES registry", () => {
|
|
7
|
+
const EXPECTED_APIS = [
|
|
8
|
+
"anthropic-messages",
|
|
9
|
+
"anthropic-vertex",
|
|
10
|
+
"openai-responses",
|
|
11
|
+
"azure-openai-responses",
|
|
12
|
+
"openai-codex-responses",
|
|
13
|
+
"openai-completions",
|
|
14
|
+
"google-generative-ai",
|
|
15
|
+
"google-gemini-cli",
|
|
16
|
+
"google-vertex",
|
|
17
|
+
"mistral-conversations",
|
|
18
|
+
"bedrock-converse-stream",
|
|
19
|
+
"ollama-chat",
|
|
20
|
+
];
|
|
21
|
+
test("covers all expected API providers", () => {
|
|
22
|
+
for (const api of EXPECTED_APIS) {
|
|
23
|
+
assert.ok(PROVIDER_CAPABILITIES[api], `Missing capability entry for API: ${api}`);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
test("getRegisteredApis returns all entries", () => {
|
|
27
|
+
const registered = getRegisteredApis();
|
|
28
|
+
for (const api of EXPECTED_APIS) {
|
|
29
|
+
assert.ok(registered.includes(api), `getRegisteredApis missing: ${api}`);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
test("all entries have required fields", () => {
|
|
33
|
+
for (const [api, caps] of Object.entries(PROVIDER_CAPABILITIES)) {
|
|
34
|
+
assert.equal(typeof caps.toolCalling, "boolean", `${api}.toolCalling`);
|
|
35
|
+
assert.equal(typeof caps.maxTools, "number", `${api}.maxTools`);
|
|
36
|
+
assert.equal(typeof caps.imageToolResults, "boolean", `${api}.imageToolResults`);
|
|
37
|
+
assert.equal(typeof caps.structuredOutput, "boolean", `${api}.structuredOutput`);
|
|
38
|
+
assert.ok(caps.toolCallIdFormat, `${api}.toolCallIdFormat`);
|
|
39
|
+
assert.equal(typeof caps.toolCallIdFormat.maxLength, "number", `${api}.toolCallIdFormat.maxLength`);
|
|
40
|
+
assert.ok(caps.toolCallIdFormat.allowedChars instanceof RegExp, `${api}.toolCallIdFormat.allowedChars`);
|
|
41
|
+
assert.ok(["full", "text-only", "none"].includes(caps.thinkingPersistence), `${api}.thinkingPersistence is "${caps.thinkingPersistence}"`);
|
|
42
|
+
assert.ok(Array.isArray(caps.unsupportedSchemaFeatures), `${api}.unsupportedSchemaFeatures`);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
// ─── Provider-specific Values ───────────────────────────────────────────────
|
|
47
|
+
describe("provider-specific capabilities", () => {
|
|
48
|
+
test("Anthropic supports full thinking persistence", () => {
|
|
49
|
+
assert.equal(PROVIDER_CAPABILITIES["anthropic-messages"].thinkingPersistence, "full");
|
|
50
|
+
});
|
|
51
|
+
test("Anthropic supports image tool results", () => {
|
|
52
|
+
assert.equal(PROVIDER_CAPABILITIES["anthropic-messages"].imageToolResults, true);
|
|
53
|
+
});
|
|
54
|
+
test("Anthropic tool call ID is 64 chars max", () => {
|
|
55
|
+
assert.equal(PROVIDER_CAPABILITIES["anthropic-messages"].toolCallIdFormat.maxLength, 64);
|
|
56
|
+
});
|
|
57
|
+
test("Mistral tool call ID is 9 chars max", () => {
|
|
58
|
+
assert.equal(PROVIDER_CAPABILITIES["mistral-conversations"].toolCallIdFormat.maxLength, 9);
|
|
59
|
+
});
|
|
60
|
+
test("Mistral has no thinking persistence", () => {
|
|
61
|
+
assert.equal(PROVIDER_CAPABILITIES["mistral-conversations"].thinkingPersistence, "none");
|
|
62
|
+
});
|
|
63
|
+
test("Google does not support patternProperties", () => {
|
|
64
|
+
assert.ok(PROVIDER_CAPABILITIES["google-generative-ai"].unsupportedSchemaFeatures.includes("patternProperties"));
|
|
65
|
+
});
|
|
66
|
+
test("Google does not support const", () => {
|
|
67
|
+
assert.ok(PROVIDER_CAPABILITIES["google-generative-ai"].unsupportedSchemaFeatures.includes("const"));
|
|
68
|
+
});
|
|
69
|
+
test("OpenAI Responses does not support image tool results", () => {
|
|
70
|
+
assert.equal(PROVIDER_CAPABILITIES["openai-responses"].imageToolResults, false);
|
|
71
|
+
});
|
|
72
|
+
test("OpenAI Responses has text-only thinking persistence", () => {
|
|
73
|
+
assert.equal(PROVIDER_CAPABILITIES["openai-responses"].thinkingPersistence, "text-only");
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
// ─── getProviderCapabilities ────────────────────────────────────────────────
|
|
77
|
+
describe("getProviderCapabilities", () => {
|
|
78
|
+
test("returns known provider capabilities", () => {
|
|
79
|
+
const caps = getProviderCapabilities("anthropic-messages");
|
|
80
|
+
assert.equal(caps.toolCalling, true);
|
|
81
|
+
assert.equal(caps.thinkingPersistence, "full");
|
|
82
|
+
});
|
|
83
|
+
test("returns permissive defaults for unknown providers", () => {
|
|
84
|
+
const caps = getProviderCapabilities("unknown-provider-xyz");
|
|
85
|
+
assert.equal(caps.toolCalling, true);
|
|
86
|
+
assert.equal(caps.imageToolResults, true);
|
|
87
|
+
assert.deepEqual(caps.unsupportedSchemaFeatures, []);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
// ─── getUnsupportedFeatures ─────────────────────────────────────────────────
|
|
91
|
+
describe("getUnsupportedFeatures", () => {
|
|
92
|
+
test("returns unsupported features for Google", () => {
|
|
93
|
+
const unsupported = getUnsupportedFeatures("google-generative-ai", ["patternProperties", "const"]);
|
|
94
|
+
assert.deepEqual(unsupported, ["patternProperties", "const"]);
|
|
95
|
+
});
|
|
96
|
+
test("returns empty for Anthropic with any features", () => {
|
|
97
|
+
const unsupported = getUnsupportedFeatures("anthropic-messages", ["patternProperties", "const"]);
|
|
98
|
+
assert.deepEqual(unsupported, []);
|
|
99
|
+
});
|
|
100
|
+
test("returns empty for unknown provider", () => {
|
|
101
|
+
const unsupported = getUnsupportedFeatures("unknown-xyz", ["patternProperties"]);
|
|
102
|
+
assert.deepEqual(unsupported, []);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
// ─── mergeCapabilityOverrides ───────────────────────────────────────────────
|
|
106
|
+
describe("mergeCapabilityOverrides", () => {
|
|
107
|
+
test("overrides individual fields", () => {
|
|
108
|
+
const merged = mergeCapabilityOverrides("openai-responses", {
|
|
109
|
+
imageToolResults: true,
|
|
110
|
+
});
|
|
111
|
+
assert.equal(merged.imageToolResults, true);
|
|
112
|
+
// Non-overridden fields preserved
|
|
113
|
+
assert.equal(merged.toolCalling, true);
|
|
114
|
+
assert.equal(merged.thinkingPersistence, "text-only");
|
|
115
|
+
});
|
|
116
|
+
test("deep-merges toolCallIdFormat", () => {
|
|
117
|
+
const merged = mergeCapabilityOverrides("anthropic-messages", {
|
|
118
|
+
toolCallIdFormat: { maxLength: 128 },
|
|
119
|
+
});
|
|
120
|
+
assert.equal(merged.toolCallIdFormat.maxLength, 128);
|
|
121
|
+
// allowedChars preserved from base
|
|
122
|
+
assert.ok(merged.toolCallIdFormat.allowedChars instanceof RegExp);
|
|
123
|
+
});
|
|
124
|
+
test("uses permissive defaults for unknown provider", () => {
|
|
125
|
+
const merged = mergeCapabilityOverrides("unknown-xyz", {
|
|
126
|
+
imageToolResults: false,
|
|
127
|
+
});
|
|
128
|
+
assert.equal(merged.imageToolResults, false);
|
|
129
|
+
assert.equal(merged.toolCalling, true); // from default
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
//# sourceMappingURL=provider-capabilities.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-capabilities.test.js","sourceRoot":"","sources":["../../src/providers/provider-capabilities.test.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE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YAAY,YAAY,MAAM,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACzD,MAAM,MAAM,GAAG,wBAAwB,CAAC,aAAa,EAAE;YACrD,gBAAgB,EAAE,KAAK;SACxB,CAAC,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QAC7C,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,eAAe;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// GSD-2 — Provider Capabilities Registry Tests (ADR-005 Phase 1)\nimport { describe, test } from \"node:test\";\nimport assert from \"node:assert/strict\";\n\nimport {\n PROVIDER_CAPABILITIES,\n getProviderCapabilities,\n getUnsupportedFeatures,\n mergeCapabilityOverrides,\n getRegisteredApis,\n} from \"./provider-capabilities.js\";\n\n// ─── Registry Completeness ──────────────────────────────────────────────────\n\ndescribe(\"PROVIDER_CAPABILITIES registry\", () => {\n const EXPECTED_APIS = [\n \"anthropic-messages\",\n \"anthropic-vertex\",\n \"openai-responses\",\n \"azure-openai-responses\",\n \"openai-codex-responses\",\n \"openai-completions\",\n \"google-generative-ai\",\n \"google-gemini-cli\",\n \"google-vertex\",\n \"mistral-conversations\",\n \"bedrock-converse-stream\",\n \"ollama-chat\",\n ];\n\n test(\"covers all expected API providers\", () => {\n for (const api of EXPECTED_APIS) {\n assert.ok(\n PROVIDER_CAPABILITIES[api],\n `Missing capability entry for API: ${api}`,\n );\n }\n });\n\n test(\"getRegisteredApis returns all entries\", () => {\n const registered = getRegisteredApis();\n for (const api of EXPECTED_APIS) {\n assert.ok(registered.includes(api), `getRegisteredApis missing: ${api}`);\n }\n });\n\n test(\"all entries have required fields\", () => {\n for (const [api, caps] of Object.entries(PROVIDER_CAPABILITIES)) {\n assert.equal(typeof caps.toolCalling, \"boolean\", `${api}.toolCalling`);\n assert.equal(typeof caps.maxTools, \"number\", `${api}.maxTools`);\n assert.equal(typeof caps.imageToolResults, \"boolean\", `${api}.imageToolResults`);\n assert.equal(typeof caps.structuredOutput, \"boolean\", `${api}.structuredOutput`);\n assert.ok(caps.toolCallIdFormat, `${api}.toolCallIdFormat`);\n assert.equal(typeof caps.toolCallIdFormat.maxLength, \"number\", `${api}.toolCallIdFormat.maxLength`);\n assert.ok(caps.toolCallIdFormat.allowedChars instanceof RegExp, `${api}.toolCallIdFormat.allowedChars`);\n assert.ok(\n [\"full\", \"text-only\", \"none\"].includes(caps.thinkingPersistence),\n `${api}.thinkingPersistence is \"${caps.thinkingPersistence}\"`,\n );\n assert.ok(Array.isArray(caps.unsupportedSchemaFeatures), `${api}.unsupportedSchemaFeatures`);\n }\n });\n});\n\n// ─── Provider-specific Values ───────────────────────────────────────────────\n\ndescribe(\"provider-specific capabilities\", () => {\n test(\"Anthropic supports full thinking persistence\", () => {\n assert.equal(PROVIDER_CAPABILITIES[\"anthropic-messages\"].thinkingPersistence, \"full\");\n });\n\n test(\"Anthropic supports image tool results\", () => {\n assert.equal(PROVIDER_CAPABILITIES[\"anthropic-messages\"].imageToolResults, true);\n });\n\n test(\"Anthropic tool call ID is 64 chars max\", () => {\n assert.equal(PROVIDER_CAPABILITIES[\"anthropic-messages\"].toolCallIdFormat.maxLength, 64);\n });\n\n test(\"Mistral tool call ID is 9 chars max\", () => {\n assert.equal(PROVIDER_CAPABILITIES[\"mistral-conversations\"].toolCallIdFormat.maxLength, 9);\n });\n\n test(\"Mistral has no thinking persistence\", () => {\n assert.equal(PROVIDER_CAPABILITIES[\"mistral-conversations\"].thinkingPersistence, \"none\");\n });\n\n test(\"Google does not support patternProperties\", () => {\n assert.ok(\n PROVIDER_CAPABILITIES[\"google-generative-ai\"].unsupportedSchemaFeatures.includes(\"patternProperties\"),\n );\n });\n\n test(\"Google does not support const\", () => {\n assert.ok(\n PROVIDER_CAPABILITIES[\"google-generative-ai\"].unsupportedSchemaFeatures.includes(\"const\"),\n );\n });\n\n test(\"OpenAI Responses does not support image tool results\", () => {\n assert.equal(PROVIDER_CAPABILITIES[\"openai-responses\"].imageToolResults, false);\n });\n\n test(\"OpenAI Responses has text-only thinking persistence\", () => {\n assert.equal(PROVIDER_CAPABILITIES[\"openai-responses\"].thinkingPersistence, \"text-only\");\n });\n});\n\n// ─── getProviderCapabilities ────────────────────────────────────────────────\n\ndescribe(\"getProviderCapabilities\", () => {\n test(\"returns known provider capabilities\", () => {\n const caps = getProviderCapabilities(\"anthropic-messages\");\n assert.equal(caps.toolCalling, true);\n assert.equal(caps.thinkingPersistence, \"full\");\n });\n\n test(\"returns permissive defaults for unknown providers\", () => {\n const caps = getProviderCapabilities(\"unknown-provider-xyz\");\n assert.equal(caps.toolCalling, true);\n assert.equal(caps.imageToolResults, true);\n assert.deepEqual(caps.unsupportedSchemaFeatures, []);\n });\n});\n\n// ─── getUnsupportedFeatures ─────────────────────────────────────────────────\n\ndescribe(\"getUnsupportedFeatures\", () => {\n test(\"returns unsupported features for Google\", () => {\n const unsupported = getUnsupportedFeatures(\"google-generative-ai\", [\"patternProperties\", \"const\"]);\n assert.deepEqual(unsupported, [\"patternProperties\", \"const\"]);\n });\n\n test(\"returns empty for Anthropic with any features\", () => {\n const unsupported = getUnsupportedFeatures(\"anthropic-messages\", [\"patternProperties\", \"const\"]);\n assert.deepEqual(unsupported, []);\n });\n\n test(\"returns empty for unknown provider\", () => {\n const unsupported = getUnsupportedFeatures(\"unknown-xyz\", [\"patternProperties\"]);\n assert.deepEqual(unsupported, []);\n });\n});\n\n// ─── mergeCapabilityOverrides ───────────────────────────────────────────────\n\ndescribe(\"mergeCapabilityOverrides\", () => {\n test(\"overrides individual fields\", () => {\n const merged = mergeCapabilityOverrides(\"openai-responses\", {\n imageToolResults: true,\n });\n assert.equal(merged.imageToolResults, true);\n // Non-overridden fields preserved\n assert.equal(merged.toolCalling, true);\n assert.equal(merged.thinkingPersistence, \"text-only\");\n });\n\n test(\"deep-merges toolCallIdFormat\", () => {\n const merged = mergeCapabilityOverrides(\"anthropic-messages\", {\n toolCallIdFormat: { maxLength: 128 },\n });\n assert.equal(merged.toolCallIdFormat.maxLength, 128);\n // allowedChars preserved from base\n assert.ok(merged.toolCallIdFormat.allowedChars instanceof RegExp);\n });\n\n test(\"uses permissive defaults for unknown provider\", () => {\n const merged = mergeCapabilityOverrides(\"unknown-xyz\", {\n imageToolResults: false,\n });\n assert.equal(merged.imageToolResults, false);\n assert.equal(merged.toolCalling, true); // from default\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-messages-report.test.d.ts","sourceRoot":"","sources":["../../src/providers/transform-messages-report.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// GSD-2 — ProviderSwitchReport Tests (ADR-005 Phase 3)
|
|
2
|
+
import { describe, test } from "node:test";
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { transformMessages, createEmptyReport, hasTransformations } from "./transform-messages.js";
|
|
5
|
+
// ─── Helpers ────────────────────────────────────────────────────────────────
|
|
6
|
+
function makeModel(overrides = {}) {
|
|
7
|
+
return {
|
|
8
|
+
id: "claude-sonnet-4-6",
|
|
9
|
+
name: "Claude Sonnet 4.6",
|
|
10
|
+
api: "anthropic-messages",
|
|
11
|
+
provider: "anthropic",
|
|
12
|
+
baseUrl: "",
|
|
13
|
+
reasoning: false,
|
|
14
|
+
input: ["text", "image"],
|
|
15
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
16
|
+
contextWindow: 200000,
|
|
17
|
+
maxTokens: 8192,
|
|
18
|
+
...overrides,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function makeAssistantMsg(overrides = {}) {
|
|
22
|
+
return {
|
|
23
|
+
role: "assistant",
|
|
24
|
+
content: [],
|
|
25
|
+
api: "anthropic-messages",
|
|
26
|
+
provider: "anthropic",
|
|
27
|
+
model: "claude-sonnet-4-6",
|
|
28
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } },
|
|
29
|
+
stopReason: "stop",
|
|
30
|
+
timestamp: Date.now(),
|
|
31
|
+
...overrides,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
// ─── createEmptyReport / hasTransformations ─────────────────────────────────
|
|
35
|
+
describe("createEmptyReport", () => {
|
|
36
|
+
test("creates report with zero counters", () => {
|
|
37
|
+
const report = createEmptyReport("anthropic-messages", "openai-responses");
|
|
38
|
+
assert.equal(report.fromApi, "anthropic-messages");
|
|
39
|
+
assert.equal(report.toApi, "openai-responses");
|
|
40
|
+
assert.equal(report.thinkingBlocksDropped, 0);
|
|
41
|
+
assert.equal(report.thinkingBlocksDowngraded, 0);
|
|
42
|
+
assert.equal(report.toolCallIdsRemapped, 0);
|
|
43
|
+
assert.equal(report.syntheticToolResultsInserted, 0);
|
|
44
|
+
assert.equal(report.thoughtSignaturesDropped, 0);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe("hasTransformations", () => {
|
|
48
|
+
test("returns false for empty report", () => {
|
|
49
|
+
const report = createEmptyReport("a", "b");
|
|
50
|
+
assert.equal(hasTransformations(report), false);
|
|
51
|
+
});
|
|
52
|
+
test("returns true when any counter is non-zero", () => {
|
|
53
|
+
const report = createEmptyReport("a", "b");
|
|
54
|
+
report.thinkingBlocksDropped = 1;
|
|
55
|
+
assert.equal(hasTransformations(report), true);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
// ─── Report Tracking in transformMessages ───────────────────────────────────
|
|
59
|
+
describe("transformMessages with report tracking", () => {
|
|
60
|
+
test("tracks thinking blocks dropped for redacted cross-model", () => {
|
|
61
|
+
const model = makeModel({ id: "gpt-5", api: "openai-responses", provider: "openai" });
|
|
62
|
+
const messages = [
|
|
63
|
+
makeAssistantMsg({
|
|
64
|
+
content: [
|
|
65
|
+
{ type: "thinking", thinking: "", redacted: true },
|
|
66
|
+
{ type: "text", text: "Hello" },
|
|
67
|
+
],
|
|
68
|
+
}),
|
|
69
|
+
];
|
|
70
|
+
const report = createEmptyReport("anthropic-messages", "openai-responses");
|
|
71
|
+
transformMessages(messages, model, undefined, report);
|
|
72
|
+
assert.equal(report.thinkingBlocksDropped, 1);
|
|
73
|
+
});
|
|
74
|
+
test("tracks thinking blocks downgraded to plain text", () => {
|
|
75
|
+
const model = makeModel({ id: "gpt-5", api: "openai-responses", provider: "openai" });
|
|
76
|
+
const messages = [
|
|
77
|
+
makeAssistantMsg({
|
|
78
|
+
content: [
|
|
79
|
+
{ type: "thinking", thinking: "Let me think about this..." },
|
|
80
|
+
{ type: "text", text: "Here is my answer" },
|
|
81
|
+
],
|
|
82
|
+
}),
|
|
83
|
+
];
|
|
84
|
+
const report = createEmptyReport("anthropic-messages", "openai-responses");
|
|
85
|
+
transformMessages(messages, model, undefined, report);
|
|
86
|
+
assert.equal(report.thinkingBlocksDowngraded, 1);
|
|
87
|
+
});
|
|
88
|
+
test("tracks tool call IDs remapped", () => {
|
|
89
|
+
const model = makeModel({ id: "claude-sonnet-4-6", api: "anthropic-messages", provider: "anthropic" });
|
|
90
|
+
const toolCall = {
|
|
91
|
+
type: "toolCall",
|
|
92
|
+
id: "original-long-id-that-needs-normalization|with-special-chars",
|
|
93
|
+
name: "bash",
|
|
94
|
+
arguments: { command: "ls" },
|
|
95
|
+
};
|
|
96
|
+
const messages = [
|
|
97
|
+
makeAssistantMsg({
|
|
98
|
+
provider: "openai",
|
|
99
|
+
api: "openai-responses",
|
|
100
|
+
model: "gpt-5",
|
|
101
|
+
content: [toolCall],
|
|
102
|
+
}),
|
|
103
|
+
];
|
|
104
|
+
const normalizer = (id) => id.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64);
|
|
105
|
+
const report = createEmptyReport("openai-responses", "anthropic-messages");
|
|
106
|
+
transformMessages(messages, model, normalizer, report);
|
|
107
|
+
assert.equal(report.toolCallIdsRemapped, 1);
|
|
108
|
+
});
|
|
109
|
+
test("tracks thought signatures dropped", () => {
|
|
110
|
+
const model = makeModel({ id: "claude-sonnet-4-6", api: "anthropic-messages", provider: "anthropic" });
|
|
111
|
+
const toolCall = {
|
|
112
|
+
type: "toolCall",
|
|
113
|
+
id: "tc_001",
|
|
114
|
+
name: "bash",
|
|
115
|
+
arguments: { command: "ls" },
|
|
116
|
+
thoughtSignature: "some-opaque-signature",
|
|
117
|
+
};
|
|
118
|
+
const messages = [
|
|
119
|
+
makeAssistantMsg({
|
|
120
|
+
provider: "google",
|
|
121
|
+
api: "google-generative-ai",
|
|
122
|
+
model: "gemini-2.5-pro",
|
|
123
|
+
content: [toolCall],
|
|
124
|
+
}),
|
|
125
|
+
];
|
|
126
|
+
const report = createEmptyReport("google-generative-ai", "anthropic-messages");
|
|
127
|
+
transformMessages(messages, model, undefined, report);
|
|
128
|
+
assert.equal(report.thoughtSignaturesDropped, 1);
|
|
129
|
+
});
|
|
130
|
+
test("tracks synthetic tool results inserted", () => {
|
|
131
|
+
const model = makeModel();
|
|
132
|
+
const toolCall = {
|
|
133
|
+
type: "toolCall",
|
|
134
|
+
id: "tc_orphan",
|
|
135
|
+
name: "bash",
|
|
136
|
+
arguments: { command: "ls" },
|
|
137
|
+
};
|
|
138
|
+
// Assistant message with tool call followed by another assistant (no tool result)
|
|
139
|
+
const messages = [
|
|
140
|
+
makeAssistantMsg({ content: [toolCall, { type: "text", text: "Using bash" }] }),
|
|
141
|
+
makeAssistantMsg({ content: [{ type: "text", text: "Next message" }] }),
|
|
142
|
+
];
|
|
143
|
+
const report = createEmptyReport("anthropic-messages", "anthropic-messages");
|
|
144
|
+
transformMessages(messages, model, undefined, report);
|
|
145
|
+
assert.equal(report.syntheticToolResultsInserted, 1);
|
|
146
|
+
});
|
|
147
|
+
test("does not count transformations for same-model messages", () => {
|
|
148
|
+
const model = makeModel();
|
|
149
|
+
const messages = [
|
|
150
|
+
makeAssistantMsg({
|
|
151
|
+
content: [
|
|
152
|
+
{ type: "thinking", thinking: "Let me think..." },
|
|
153
|
+
{ type: "text", text: "Answer" },
|
|
154
|
+
],
|
|
155
|
+
}),
|
|
156
|
+
];
|
|
157
|
+
const report = createEmptyReport("anthropic-messages", "anthropic-messages");
|
|
158
|
+
transformMessages(messages, model, undefined, report);
|
|
159
|
+
assert.equal(report.thinkingBlocksDowngraded, 0);
|
|
160
|
+
assert.equal(report.thinkingBlocksDropped, 0);
|
|
161
|
+
});
|
|
162
|
+
test("works without report parameter (backward compatible)", () => {
|
|
163
|
+
const model = makeModel();
|
|
164
|
+
const messages = [
|
|
165
|
+
makeAssistantMsg({ content: [{ type: "text", text: "Hello" }] }),
|
|
166
|
+
];
|
|
167
|
+
// Should not throw
|
|
168
|
+
const result = transformMessages(messages, model);
|
|
169
|
+
assert.ok(Array.isArray(result));
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
//# sourceMappingURL=transform-messages-report.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-messages-report.test.js","sourceRoot":"","sources":["../../src/providers/transform-messages-report.test.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAInG,+EAA+E;AAE/E,SAAS,SAAS,CAAC,YAAiC,EAAE;IACpD,OAAO;QACL,EAAE,EAAE,mBAAmB;QACvB,IAAI,EAAE,mBAAmB;QACzB,GAAG,EAAE,oBAAoB;QACzB,QAAQ,EAAE,WAAW;QACrB,OAAO,EAAE,EAAE;QACX,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;QACxB,IAAI,EAA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QAAQ,EAAE,iBAAiB,EAAE;oBACjD,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE;iBACjC;aACF,CAAC;SACH,CAAC;QACF,MAAM,MAAM,GAAG,iBAAiB,CAAC,oBAAoB,EAAE,oBAAoB,CAAC,CAAC;QAC7E,iBAAiB,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QACtD,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAC;QACjD,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAChE,MAAM,KAAK,GAAG,SAAS,EAAE,CAAC;QAC1B,MAAM,QAAQ,GAAc;YAC1B,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;SACjE,CAAC;QACF,mBAAmB;QACnB,MAAM,MAAM,GAAG,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAClD,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// GSD-2 — ProviderSwitchReport Tests (ADR-005 Phase 3)\nimport { describe, test } from \"node:test\";\nimport assert from \"node:assert/strict\";\n\nimport { transformMessages, createEmptyReport, hasTransformations } from \"./transform-messages.js\";\nimport type { ProviderSwitchReport } from \"./transform-messages.js\";\nimport type { Message, Model, AssistantMessage, ToolCall } from \"../types.js\";\n\n// ─── Helpers ────────────────────────────────────────────────────────────────\n\nfunction makeModel(overrides: Partial<Model<any>> = {}): Model<any> {\n return {\n id: \"claude-sonnet-4-6\",\n name: \"Claude Sonnet 4.6\",\n api: \"anthropic-messages\",\n provider: \"anthropic\",\n baseUrl: \"\",\n reasoning: false,\n input: [\"text\", \"image\"],\n cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n contextWindow: 200000,\n maxTokens: 8192,\n ...overrides,\n } as Model<any>;\n}\n\nfunction makeAssistantMsg(overrides: Partial<AssistantMessage> = {}): AssistantMessage {\n return {\n role: \"assistant\",\n content: [],\n api: \"anthropic-messages\",\n provider: \"anthropic\",\n model: \"claude-sonnet-4-6\",\n usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } },\n stopReason: \"stop\",\n timestamp: Date.now(),\n ...overrides,\n };\n}\n\n// ─── createEmptyReport / hasTransformations ─────────────────────────────────\n\ndescribe(\"createEmptyReport\", () => {\n test(\"creates report with zero counters\", () => {\n const report = createEmptyReport(\"anthropic-messages\", \"openai-responses\");\n assert.equal(report.fromApi, \"anthropic-messages\");\n assert.equal(report.toApi, \"openai-responses\");\n assert.equal(report.thinkingBlocksDropped, 0);\n assert.equal(report.thinkingBlocksDowngraded, 0);\n assert.equal(report.toolCallIdsRemapped, 0);\n assert.equal(report.syntheticToolResultsInserted, 0);\n assert.equal(report.thoughtSignaturesDropped, 0);\n });\n});\n\ndescribe(\"hasTransformations\", () => {\n test(\"returns false for empty report\", () => {\n const report = createEmptyReport(\"a\", \"b\");\n assert.equal(hasTransformations(report), false);\n });\n\n test(\"returns true when any counter is non-zero\", () => {\n const report = createEmptyReport(\"a\", \"b\");\n report.thinkingBlocksDropped = 1;\n assert.equal(hasTransformations(report), true);\n });\n});\n\n// ─── Report Tracking in transformMessages ───────────────────────────────────\n\ndescribe(\"transformMessages with report tracking\", () => {\n test(\"tracks thinking blocks dropped for redacted cross-model\", () => {\n const model = makeModel({ id: \"gpt-5\", api: \"openai-responses\", provider: \"openai\" });\n const messages: Message[] = [\n makeAssistantMsg({\n content: [\n { type: \"thinking\", thinking: \"\", redacted: true },\n { type: \"text\", text: \"Hello\" },\n ],\n }),\n ];\n const report = createEmptyReport(\"anthropic-messages\", \"openai-responses\");\n transformMessages(messages, model, undefined, report);\n assert.equal(report.thinkingBlocksDropped, 1);\n });\n\n test(\"tracks thinking blocks downgraded to plain text\", () => {\n const model = makeModel({ id: \"gpt-5\", api: \"openai-responses\", provider: \"openai\" });\n const messages: Message[] = [\n makeAssistantMsg({\n content: [\n { type: \"thinking\", thinking: \"Let me think about this...\" },\n { type: \"text\", text: \"Here is my answer\" },\n ],\n }),\n ];\n const report = createEmptyReport(\"anthropic-messages\", \"openai-responses\");\n transformMessages(messages, model, undefined, report);\n assert.equal(report.thinkingBlocksDowngraded, 1);\n });\n\n test(\"tracks tool call IDs remapped\", () => {\n const model = makeModel({ id: \"claude-sonnet-4-6\", api: \"anthropic-messages\", provider: \"anthropic\" });\n const toolCall: ToolCall = {\n type: \"toolCall\",\n id: \"original-long-id-that-needs-normalization|with-special-chars\",\n name: \"bash\",\n arguments: { command: \"ls\" },\n };\n const messages: Message[] = [\n makeAssistantMsg({\n provider: \"openai\",\n api: \"openai-responses\",\n model: \"gpt-5\",\n content: [toolCall],\n }),\n ];\n const normalizer = (id: string) => id.replace(/[^a-zA-Z0-9_-]/g, \"_\").slice(0, 64);\n const report = createEmptyReport(\"openai-responses\", \"anthropic-messages\");\n transformMessages(messages, model, normalizer, report);\n assert.equal(report.toolCallIdsRemapped, 1);\n });\n\n test(\"tracks thought signatures dropped\", () => {\n const model = makeModel({ id: \"claude-sonnet-4-6\", api: \"anthropic-messages\", provider: \"anthropic\" });\n const toolCall: ToolCall = {\n type: \"toolCall\",\n id: \"tc_001\",\n name: \"bash\",\n arguments: { command: \"ls\" },\n thoughtSignature: \"some-opaque-signature\",\n };\n const messages: Message[] = [\n makeAssistantMsg({\n provider: \"google\",\n api: \"google-generative-ai\",\n model: \"gemini-2.5-pro\",\n content: [toolCall],\n }),\n ];\n const report = createEmptyReport(\"google-generative-ai\", \"anthropic-messages\");\n transformMessages(messages, model, undefined, report);\n assert.equal(report.thoughtSignaturesDropped, 1);\n });\n\n test(\"tracks synthetic tool results inserted\", () => {\n const model = makeModel();\n const toolCall: ToolCall = {\n type: \"toolCall\",\n id: \"tc_orphan\",\n name: \"bash\",\n arguments: { command: \"ls\" },\n };\n // Assistant message with tool call followed by another assistant (no tool result)\n const messages: Message[] = [\n makeAssistantMsg({ content: [toolCall, { type: \"text\", text: \"Using bash\" }] }),\n makeAssistantMsg({ content: [{ type: \"text\", text: \"Next message\" }] }),\n ];\n const report = createEmptyReport(\"anthropic-messages\", \"anthropic-messages\");\n transformMessages(messages, model, undefined, report);\n assert.equal(report.syntheticToolResultsInserted, 1);\n });\n\n test(\"does not count transformations for same-model messages\", () => {\n const model = makeModel();\n const messages: Message[] = [\n makeAssistantMsg({\n content: [\n { type: \"thinking\", thinking: \"Let me think...\" },\n { type: \"text\", text: \"Answer\" },\n ],\n }),\n ];\n const report = createEmptyReport(\"anthropic-messages\", \"anthropic-messages\");\n transformMessages(messages, model, undefined, report);\n assert.equal(report.thinkingBlocksDowngraded, 0);\n assert.equal(report.thinkingBlocksDropped, 0);\n });\n\n test(\"works without report parameter (backward compatible)\", () => {\n const model = makeModel();\n const messages: Message[] = [\n makeAssistantMsg({ content: [{ type: \"text\", text: \"Hello\" }] }),\n ];\n // Should not throw\n const result = transformMessages(messages, model);\n assert.ok(Array.isArray(result));\n });\n});\n"]}
|
|
@@ -1,8 +1,41 @@
|
|
|
1
1
|
import type { Api, AssistantMessage, Message, Model } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Report of context transformations during a cross-provider switch (ADR-005 Phase 3).
|
|
4
|
+
* Tracks what was lost or downgraded when replaying conversation history to a different provider.
|
|
5
|
+
*/
|
|
6
|
+
export interface ProviderSwitchReport {
|
|
7
|
+
/** API of the messages being transformed from */
|
|
8
|
+
fromApi: string;
|
|
9
|
+
/** API of the target model */
|
|
10
|
+
toApi: string;
|
|
11
|
+
/** Number of thinking blocks completely dropped (redacted/encrypted, cross-model) */
|
|
12
|
+
thinkingBlocksDropped: number;
|
|
13
|
+
/** Number of thinking blocks downgraded from structured to plain text */
|
|
14
|
+
thinkingBlocksDowngraded: number;
|
|
15
|
+
/** Number of tool call IDs that were remapped/normalized */
|
|
16
|
+
toolCallIdsRemapped: number;
|
|
17
|
+
/** Number of synthetic tool results inserted for orphaned tool calls */
|
|
18
|
+
syntheticToolResultsInserted: number;
|
|
19
|
+
/** Number of thought signatures dropped (Google-specific opaque context) */
|
|
20
|
+
thoughtSignaturesDropped: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create an empty provider switch report.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createEmptyReport(fromApi: string, toApi: string): ProviderSwitchReport;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a provider switch report has any non-zero transformations.
|
|
28
|
+
*/
|
|
29
|
+
export declare function hasTransformations(report: ProviderSwitchReport): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Create a report, run transformMessages, and log if non-empty.
|
|
32
|
+
* Convenience wrapper for provider adapters (ADR-005).
|
|
33
|
+
*/
|
|
34
|
+
export declare function transformMessagesWithReport<TApi extends Api>(messages: Message[], model: Model<TApi>, normalizeToolCallId?: (id: string, model: Model<TApi>, source: AssistantMessage) => string, sourceApi?: string): Message[];
|
|
2
35
|
/**
|
|
3
36
|
* Normalize tool call ID for cross-provider compatibility.
|
|
4
37
|
* OpenAI Responses API generates IDs that are 450+ chars with special characters like `|`.
|
|
5
38
|
* Anthropic APIs require IDs matching ^[a-zA-Z0-9_-]+$ (max 64 chars).
|
|
6
39
|
*/
|
|
7
|
-
export declare function transformMessages<TApi extends Api>(messages: Message[], model: Model<TApi>, normalizeToolCallId?: (id: string, model: Model<TApi>, source: AssistantMessage) => string): Message[];
|
|
40
|
+
export declare function transformMessages<TApi extends Api>(messages: Message[], model: Model<TApi>, normalizeToolCallId?: (id: string, model: Model<TApi>, source: AssistantMessage) => string, report?: ProviderSwitchReport): Message[];
|
|
8
41
|
//# sourceMappingURL=transform-messages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-messages.d.ts","sourceRoot":"","sources":["../../src/providers/transform-messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,OAAO,EAAE,KAAK,EAA+B,MAAM,aAAa,CAAC;AAEtG;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,SAAS,GAAG,EACjD,QAAQ,EAAE,OAAO,EAAE,EACnB,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAClB,mBAAmB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,gBAAgB,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"transform-messages.d.ts","sourceRoot":"","sources":["../../src/providers/transform-messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,OAAO,EAAE,KAAK,EAA+B,MAAM,aAAa,CAAC;AAEtG;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACpC,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,qFAAqF;IACrF,qBAAqB,EAAE,MAAM,CAAC;IAC9B,yEAAyE;IACzE,wBAAwB,EAAE,MAAM,CAAC;IACjC,4DAA4D;IAC5D,mBAAmB,EAAE,MAAM,CAAC;IAC5B,wEAAwE;IACxE,4BAA4B,EAAE,MAAM,CAAC;IACrC,4EAA4E;IAC5E,wBAAwB,EAAE,MAAM,CAAC;CACjC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAUtF;AAED;;GAEG;AACH,wBAAgB,k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