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
|
@@ -1,9 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create an empty provider switch report.
|
|
3
|
+
*/
|
|
4
|
+
export function createEmptyReport(fromApi, toApi) {
|
|
5
|
+
return {
|
|
6
|
+
fromApi,
|
|
7
|
+
toApi,
|
|
8
|
+
thinkingBlocksDropped: 0,
|
|
9
|
+
thinkingBlocksDowngraded: 0,
|
|
10
|
+
toolCallIdsRemapped: 0,
|
|
11
|
+
syntheticToolResultsInserted: 0,
|
|
12
|
+
thoughtSignaturesDropped: 0,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Check if a provider switch report has any non-zero transformations.
|
|
17
|
+
*/
|
|
18
|
+
export function hasTransformations(report) {
|
|
19
|
+
return (report.thinkingBlocksDropped > 0 ||
|
|
20
|
+
report.thinkingBlocksDowngraded > 0 ||
|
|
21
|
+
report.toolCallIdsRemapped > 0 ||
|
|
22
|
+
report.syntheticToolResultsInserted > 0 ||
|
|
23
|
+
report.thoughtSignaturesDropped > 0);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a report, run transformMessages, and log if non-empty.
|
|
27
|
+
* Convenience wrapper for provider adapters (ADR-005).
|
|
28
|
+
*/
|
|
29
|
+
export function transformMessagesWithReport(messages, model, normalizeToolCallId, sourceApi) {
|
|
30
|
+
const report = createEmptyReport(sourceApi ?? "unknown", model.api);
|
|
31
|
+
const result = transformMessages(messages, model, normalizeToolCallId, report);
|
|
32
|
+
if (hasTransformations(report)) {
|
|
33
|
+
logProviderSwitchReport(report);
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
/** Log a non-empty ProviderSwitchReport as a debug-level warning. */
|
|
38
|
+
function logProviderSwitchReport(report) {
|
|
39
|
+
const parts = [`Provider switch ${report.fromApi} → ${report.toApi}:`];
|
|
40
|
+
if (report.thinkingBlocksDropped > 0)
|
|
41
|
+
parts.push(`${report.thinkingBlocksDropped} thinking blocks dropped`);
|
|
42
|
+
if (report.thinkingBlocksDowngraded > 0)
|
|
43
|
+
parts.push(`${report.thinkingBlocksDowngraded} thinking blocks downgraded`);
|
|
44
|
+
if (report.toolCallIdsRemapped > 0)
|
|
45
|
+
parts.push(`${report.toolCallIdsRemapped} tool call IDs remapped`);
|
|
46
|
+
if (report.syntheticToolResultsInserted > 0)
|
|
47
|
+
parts.push(`${report.syntheticToolResultsInserted} synthetic tool results inserted`);
|
|
48
|
+
if (report.thoughtSignaturesDropped > 0)
|
|
49
|
+
parts.push(`${report.thoughtSignaturesDropped} thought signatures dropped`);
|
|
50
|
+
// Use process.stderr for debug output — this is observable in verbose/debug modes
|
|
51
|
+
// without polluting stdout which may be used for structured output (RPC/MCP).
|
|
52
|
+
if (process.env.GSD_VERBOSE === "1" || process.env.PI_VERBOSE === "1") {
|
|
53
|
+
process.stderr.write(`[provider-switch] ${parts.join(", ")}\n`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
1
56
|
/**
|
|
2
57
|
* Normalize tool call ID for cross-provider compatibility.
|
|
3
58
|
* OpenAI Responses API generates IDs that are 450+ chars with special characters like `|`.
|
|
4
59
|
* Anthropic APIs require IDs matching ^[a-zA-Z0-9_-]+$ (max 64 chars).
|
|
5
60
|
*/
|
|
6
|
-
export function transformMessages(messages, model, normalizeToolCallId) {
|
|
61
|
+
export function transformMessages(messages, model, normalizeToolCallId, report) {
|
|
7
62
|
// Build a map of original tool call IDs to normalized IDs
|
|
8
63
|
const toolCallIdMap = new Map();
|
|
9
64
|
// First pass: transform messages (thinking blocks, tool call ID normalization)
|
|
@@ -31,6 +86,8 @@ export function transformMessages(messages, model, normalizeToolCallId) {
|
|
|
31
86
|
// Redacted thinking is opaque encrypted content, only valid for the same model.
|
|
32
87
|
// Drop it for cross-model to avoid API errors.
|
|
33
88
|
if (block.redacted) {
|
|
89
|
+
if (!isSameModel && report)
|
|
90
|
+
report.thinkingBlocksDropped++;
|
|
34
91
|
return isSameModel ? block : [];
|
|
35
92
|
}
|
|
36
93
|
// For same model: keep thinking blocks with signatures (needed for replay)
|
|
@@ -38,10 +95,16 @@ export function transformMessages(messages, model, normalizeToolCallId) {
|
|
|
38
95
|
if (isSameModel && block.thinkingSignature)
|
|
39
96
|
return block;
|
|
40
97
|
// Skip empty thinking blocks, convert others to plain text
|
|
41
|
-
if (!block.thinking || block.thinking.trim() === "")
|
|
98
|
+
if (!block.thinking || block.thinking.trim() === "") {
|
|
99
|
+
if (!isSameModel && report)
|
|
100
|
+
report.thinkingBlocksDropped++;
|
|
42
101
|
return [];
|
|
102
|
+
}
|
|
43
103
|
if (isSameModel)
|
|
44
104
|
return block;
|
|
105
|
+
// Downgrade: structured thinking → plain text
|
|
106
|
+
if (report)
|
|
107
|
+
report.thinkingBlocksDowngraded++;
|
|
45
108
|
return {
|
|
46
109
|
type: "text",
|
|
47
110
|
text: block.thinking,
|
|
@@ -61,12 +124,16 @@ export function transformMessages(messages, model, normalizeToolCallId) {
|
|
|
61
124
|
if (!isSameModel && toolCall.thoughtSignature) {
|
|
62
125
|
normalizedToolCall = { ...toolCall };
|
|
63
126
|
delete normalizedToolCall.thoughtSignature;
|
|
127
|
+
if (report)
|
|
128
|
+
report.thoughtSignaturesDropped++;
|
|
64
129
|
}
|
|
65
130
|
if (!isSameModel && normalizeToolCallId) {
|
|
66
131
|
const normalizedId = normalizeToolCallId(toolCall.id, model, assistantMsg);
|
|
67
132
|
if (normalizedId !== toolCall.id) {
|
|
68
133
|
toolCallIdMap.set(toolCall.id, normalizedId);
|
|
69
134
|
normalizedToolCall = { ...normalizedToolCall, id: normalizedId };
|
|
135
|
+
if (report)
|
|
136
|
+
report.toolCallIdsRemapped++;
|
|
70
137
|
}
|
|
71
138
|
}
|
|
72
139
|
return normalizedToolCall;
|
|
@@ -100,6 +167,8 @@ export function transformMessages(messages, model, normalizeToolCallId) {
|
|
|
100
167
|
isError: true,
|
|
101
168
|
timestamp: Date.now(),
|
|
102
169
|
});
|
|
170
|
+
if (report)
|
|
171
|
+
report.syntheticToolResultsInserted++;
|
|
103
172
|
}
|
|
104
173
|
}
|
|
105
174
|
pendingToolCalls = [];
|
|
@@ -139,6 +208,8 @@ export function transformMessages(messages, model, normalizeToolCallId) {
|
|
|
139
208
|
isError: true,
|
|
140
209
|
timestamp: Date.now(),
|
|
141
210
|
});
|
|
211
|
+
if (report)
|
|
212
|
+
report.syntheticToolResultsInserted++;
|
|
142
213
|
}
|
|
143
214
|
}
|
|
144
215
|
pendingToolCalls = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-messages.js","sourceRoot":"","sources":["../../src/providers/transform-messages.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAChC,QAAmB,EACnB,KAAkB,EAClB,mBAA0F;IAE1F,0DAA0D;IAC1D,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEhD,+EAA+E;IAC/E,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACxC,u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E,CAAC;YACnC,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;aAAM,CAAC;YACP,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import type { Api, AssistantMessage, Message, Model, ToolCall, ToolResultMessage } from \"../types.js\";\n\n/**\n * Normalize tool call ID for cross-provider compatibility.\n * OpenAI Responses API generates IDs that are 450+ chars with special characters like `|`.\n * Anthropic APIs require IDs matching ^[a-zA-Z0-9_-]+$ (max 64 chars).\n */\nexport function transformMessages<TApi extends Api>(\n\tmessages: Message[],\n\tmodel: Model<TApi>,\n\tnormalizeToolCallId?: (id: string, model: Model<TApi>, source: AssistantMessage) => string,\n): Message[] {\n\t// Build a map of original tool call IDs to normalized IDs\n\tconst toolCallIdMap = new Map<string, string>();\n\n\t// First pass: transform messages (thinking blocks, tool call ID normalization)\n\tconst transformed = messages.map((msg) => {\n\t\t// User messages pass through unchanged\n\t\tif (msg.role === \"user\") {\n\t\t\treturn msg;\n\t\t}\n\n\t\t// Handle toolResult messages - normalize toolCallId if we have a mapping\n\t\tif (msg.role === \"toolResult\") {\n\t\t\tconst normalizedId = toolCallIdMap.get(msg.toolCallId);\n\t\t\tif (normalizedId && normalizedId !== msg.toolCallId) {\n\t\t\t\treturn { ...msg, toolCallId: normalizedId };\n\t\t\t}\n\t\t\treturn msg;\n\t\t}\n\n\t\t// Assistant messages need transformation check\n\t\tif (msg.role === \"assistant\") {\n\t\t\tconst assistantMsg = msg as AssistantMessage;\n\t\t\tconst isSameModel =\n\t\t\t\tassistantMsg.provider === model.provider &&\n\t\t\t\tassistantMsg.api === model.api &&\n\t\t\t\tassistantMsg.model === model.id;\n\n\t\t\tconst transformedContent = assistantMsg.content.flatMap((block) => {\n\t\t\t\tif (block.type === \"thinking\") {\n\t\t\t\t\t// Redacted thinking is opaque encrypted content, only valid for the same model.\n\t\t\t\t\t// Drop it for cross-model to avoid API errors.\n\t\t\t\t\tif (block.redacted) {\n\t\t\t\t\t\treturn isSameModel ? block : [];\n\t\t\t\t\t}\n\t\t\t\t\t// For same model: keep thinking blocks with signatures (needed for replay)\n\t\t\t\t\t// even if the thinking text is empty (OpenAI encrypted reasoning)\n\t\t\t\t\tif (isSameModel && block.thinkingSignature) return block;\n\t\t\t\t\t// Skip empty thinking blocks, convert others to plain text\n\t\t\t\t\tif (!block.thinking || block.thinking.trim() === \"\") return [];\n\t\t\t\t\tif (isSameModel) return block;\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\ttext: block.thinking,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (block.type === \"text\") {\n\t\t\t\t\tif (isSameModel) return block;\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\ttext: block.text,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (block.type === \"toolCall\") {\n\t\t\t\t\tconst toolCall = block as ToolCall;\n\t\t\t\t\tlet normalizedToolCall: ToolCall = toolCall;\n\n\t\t\t\t\tif (!isSameModel && toolCall.thoughtSignature) {\n\t\t\t\t\t\tnormalizedToolCall = { ...toolCall };\n\t\t\t\t\t\tdelete (normalizedToolCall as { thoughtSignature?: string }).thoughtSignature;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!isSameModel && normalizeToolCallId) {\n\t\t\t\t\t\tconst normalizedId = normalizeToolCallId(toolCall.id, model, assistantMsg);\n\t\t\t\t\t\tif (normalizedId !== toolCall.id) {\n\t\t\t\t\t\t\ttoolCallIdMap.set(toolCall.id, normalizedId);\n\t\t\t\t\t\t\tnormalizedToolCall = { ...normalizedToolCall, id: normalizedId };\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn normalizedToolCall;\n\t\t\t\t}\n\n\t\t\t\treturn block;\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\t...assistantMsg,\n\t\t\t\tcontent: transformedContent,\n\t\t\t};\n\t\t}\n\t\treturn msg;\n\t});\n\n\t// Second pass: insert synthetic empty tool results for orphaned tool calls\n\t// This preserves thinking signatures and satisfies API requirements\n\tconst result: Message[] = [];\n\tlet pendingToolCalls: ToolCall[] = [];\n\tlet existingToolResultIds = new Set<string>();\n\n\tfor (let i = 0; i < transformed.length; i++) {\n\t\tconst msg = transformed[i];\n\n\t\tif (msg.role === \"assistant\") {\n\t\t\t// If we have pending orphaned tool calls from a previous assistant, insert synthetic results now\n\t\t\tif (pendingToolCalls.length > 0) {\n\t\t\t\tfor (const tc of pendingToolCalls) {\n\t\t\t\t\tif (!existingToolResultIds.has(tc.id)) {\n\t\t\t\t\t\tresult.push({\n\t\t\t\t\t\t\trole: \"toolResult\",\n\t\t\t\t\t\t\ttoolCallId: tc.id,\n\t\t\t\t\t\t\ttoolName: tc.name,\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No result provided\" }],\n\t\t\t\t\t\t\tisError: true,\n\t\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t\t} as ToolResultMessage);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpendingToolCalls = [];\n\t\t\t\texistingToolResultIds = new Set();\n\t\t\t}\n\n\t\t\t// Skip errored/aborted assistant messages entirely.\n\t\t\t// These are incomplete turns that shouldn't be replayed:\n\t\t\t// - May have partial content (reasoning without message, incomplete tool calls)\n\t\t\t// - Replaying them can cause API errors (e.g., OpenAI \"reasoning without following item\")\n\t\t\t// - The model should retry from the last valid state\n\t\t\tconst assistantMsg = msg as AssistantMessage;\n\t\t\tif (assistantMsg.stopReason === \"error\" || assistantMsg.stopReason === \"aborted\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Track tool calls from this assistant message\n\t\t\tconst toolCalls = assistantMsg.content.filter((b) => b.type === \"toolCall\") as ToolCall[];\n\t\t\tif (toolCalls.length > 0) {\n\t\t\t\tpendingToolCalls = toolCalls;\n\t\t\t\texistingToolResultIds = new Set();\n\t\t\t}\n\n\t\t\tresult.push(msg);\n\t\t} else if (msg.role === \"toolResult\") {\n\t\t\texistingToolResultIds.add(msg.toolCallId);\n\t\t\tresult.push(msg);\n\t\t} else if (msg.role === \"user\") {\n\t\t\t// User message interrupts tool flow - insert synthetic results for orphaned calls\n\t\t\tif (pendingToolCalls.length > 0) {\n\t\t\t\tfor (const tc of pendingToolCalls) {\n\t\t\t\t\tif (!existingToolResultIds.has(tc.id)) {\n\t\t\t\t\t\tresult.push({\n\t\t\t\t\t\t\trole: \"toolResult\",\n\t\t\t\t\t\t\ttoolCallId: tc.id,\n\t\t\t\t\t\t\ttoolName: tc.name,\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No result provided\" }],\n\t\t\t\t\t\t\tisError: true,\n\t\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t\t} as ToolResultMessage);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpendingToolCalls = [];\n\t\t\t\texistingToolResultIds = new Set();\n\t\t\t}\n\t\t\tresult.push(msg);\n\t\t} else {\n\t\t\tresult.push(msg);\n\t\t}\n\t}\n\n\treturn result;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"transform-messages.js","sourceRoot":"","sources":["../../src/providers/transform-messages.ts"],"names":[],"mappings":"AAuBA;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,KAAa;IAC/D,OAAO;QACN,OAAO;QACP,KAAK;QACL,qBAAqB,EAAE,CAAC;QACxB,wBAAwB,EAAE,CAAC;QAC3B,mBAAmB,EAAE,CAAC;QACtB,4BAA4B,EAAE,CAAC;QAC/B,wBAAwB,EAAE,CAAC;KAC3B,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA4B;IAC9D,OAAO,CACN,MAAM,CAAC,qBAAqB,GAAG,CAAC;QAChC,MAAM,CAAC,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AC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import type { Api, AssistantMessage, Message, Model, ToolCall, ToolResultMessage } from \"../types.js\";\n\n/**\n * Report of context transformations during a cross-provider switch (ADR-005 Phase 3).\n * Tracks what was lost or downgraded when replaying conversation history to a different provider.\n */\nexport interface ProviderSwitchReport {\n\t/** API of the messages being transformed from */\n\tfromApi: string;\n\t/** API of the target model */\n\ttoApi: string;\n\t/** Number of thinking blocks completely dropped (redacted/encrypted, cross-model) */\n\tthinkingBlocksDropped: number;\n\t/** Number of thinking blocks downgraded from structured to plain text */\n\tthinkingBlocksDowngraded: number;\n\t/** Number of tool call IDs that were remapped/normalized */\n\ttoolCallIdsRemapped: number;\n\t/** Number of synthetic tool results inserted for orphaned tool calls */\n\tsyntheticToolResultsInserted: number;\n\t/** Number of thought signatures dropped (Google-specific opaque context) */\n\tthoughtSignaturesDropped: number;\n}\n\n/**\n * Create an empty provider switch report.\n */\nexport function createEmptyReport(fromApi: string, toApi: string): ProviderSwitchReport {\n\treturn {\n\t\tfromApi,\n\t\ttoApi,\n\t\tthinkingBlocksDropped: 0,\n\t\tthinkingBlocksDowngraded: 0,\n\t\ttoolCallIdsRemapped: 0,\n\t\tsyntheticToolResultsInserted: 0,\n\t\tthoughtSignaturesDropped: 0,\n\t};\n}\n\n/**\n * Check if a provider switch report has any non-zero transformations.\n */\nexport function hasTransformations(report: ProviderSwitchReport): boolean {\n\treturn (\n\t\treport.thinkingBlocksDropped > 0 ||\n\t\treport.thinkingBlocksDowngraded > 0 ||\n\t\treport.toolCallIdsRemapped > 0 ||\n\t\treport.syntheticToolResultsInserted > 0 ||\n\t\treport.thoughtSignaturesDropped > 0\n\t);\n}\n\n/**\n * Create a report, run transformMessages, and log if non-empty.\n * Convenience wrapper for provider adapters (ADR-005).\n */\nexport function transformMessagesWithReport<TApi extends Api>(\n\tmessages: Message[],\n\tmodel: Model<TApi>,\n\tnormalizeToolCallId?: (id: string, model: Model<TApi>, source: AssistantMessage) => string,\n\tsourceApi?: string,\n): Message[] {\n\tconst report = createEmptyReport(sourceApi ?? \"unknown\", model.api);\n\tconst result = transformMessages(messages, model, normalizeToolCallId, report);\n\tif (hasTransformations(report)) {\n\t\tlogProviderSwitchReport(report);\n\t}\n\treturn result;\n}\n\n/** Log a non-empty ProviderSwitchReport as a debug-level warning. */\nfunction logProviderSwitchReport(report: ProviderSwitchReport): void {\n\tconst parts: string[] = [`Provider switch ${report.fromApi} → ${report.toApi}:`];\n\tif (report.thinkingBlocksDropped > 0) parts.push(`${report.thinkingBlocksDropped} thinking blocks dropped`);\n\tif (report.thinkingBlocksDowngraded > 0) parts.push(`${report.thinkingBlocksDowngraded} thinking blocks downgraded`);\n\tif (report.toolCallIdsRemapped > 0) parts.push(`${report.toolCallIdsRemapped} tool call IDs remapped`);\n\tif (report.syntheticToolResultsInserted > 0) parts.push(`${report.syntheticToolResultsInserted} synthetic tool results inserted`);\n\tif (report.thoughtSignaturesDropped > 0) parts.push(`${report.thoughtSignaturesDropped} thought signatures dropped`);\n\t// Use process.stderr for debug output — this is observable in verbose/debug modes\n\t// without polluting stdout which may be used for structured output (RPC/MCP).\n\tif (process.env.GSD_VERBOSE === \"1\" || process.env.PI_VERBOSE === \"1\") {\n\t\tprocess.stderr.write(`[provider-switch] ${parts.join(\", \")}\\n`);\n\t}\n}\n\n/**\n * Normalize tool call ID for cross-provider compatibility.\n * OpenAI Responses API generates IDs that are 450+ chars with special characters like `|`.\n * Anthropic APIs require IDs matching ^[a-zA-Z0-9_-]+$ (max 64 chars).\n */\nexport function transformMessages<TApi extends Api>(\n\tmessages: Message[],\n\tmodel: Model<TApi>,\n\tnormalizeToolCallId?: (id: string, model: Model<TApi>, source: AssistantMessage) => string,\n\treport?: ProviderSwitchReport,\n): Message[] {\n\t// Build a map of original tool call IDs to normalized IDs\n\tconst toolCallIdMap = new Map<string, string>();\n\n\t// First pass: transform messages (thinking blocks, tool call ID normalization)\n\tconst transformed = messages.map((msg) => {\n\t\t// User messages pass through unchanged\n\t\tif (msg.role === \"user\") {\n\t\t\treturn msg;\n\t\t}\n\n\t\t// Handle toolResult messages - normalize toolCallId if we have a mapping\n\t\tif (msg.role === \"toolResult\") {\n\t\t\tconst normalizedId = toolCallIdMap.get(msg.toolCallId);\n\t\t\tif (normalizedId && normalizedId !== msg.toolCallId) {\n\t\t\t\treturn { ...msg, toolCallId: normalizedId };\n\t\t\t}\n\t\t\treturn msg;\n\t\t}\n\n\t\t// Assistant messages need transformation check\n\t\tif (msg.role === \"assistant\") {\n\t\t\tconst assistantMsg = msg as AssistantMessage;\n\t\t\tconst isSameModel =\n\t\t\t\tassistantMsg.provider === model.provider &&\n\t\t\t\tassistantMsg.api === model.api &&\n\t\t\t\tassistantMsg.model === model.id;\n\n\t\t\tconst transformedContent = assistantMsg.content.flatMap((block) => {\n\t\t\t\tif (block.type === \"thinking\") {\n\t\t\t\t\t// Redacted thinking is opaque encrypted content, only valid for the same model.\n\t\t\t\t\t// Drop it for cross-model to avoid API errors.\n\t\t\t\t\tif (block.redacted) {\n\t\t\t\t\t\tif (!isSameModel && report) report.thinkingBlocksDropped++;\n\t\t\t\t\t\treturn isSameModel ? block : [];\n\t\t\t\t\t}\n\t\t\t\t\t// For same model: keep thinking blocks with signatures (needed for replay)\n\t\t\t\t\t// even if the thinking text is empty (OpenAI encrypted reasoning)\n\t\t\t\t\tif (isSameModel && block.thinkingSignature) return block;\n\t\t\t\t\t// Skip empty thinking blocks, convert others to plain text\n\t\t\t\t\tif (!block.thinking || block.thinking.trim() === \"\") {\n\t\t\t\t\t\tif (!isSameModel && report) report.thinkingBlocksDropped++;\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\t\t\t\t\tif (isSameModel) return block;\n\t\t\t\t\t// Downgrade: structured thinking → plain text\n\t\t\t\t\tif (report) report.thinkingBlocksDowngraded++;\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\ttext: block.thinking,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (block.type === \"text\") {\n\t\t\t\t\tif (isSameModel) return block;\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\ttext: block.text,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (block.type === \"toolCall\") {\n\t\t\t\t\tconst toolCall = block as ToolCall;\n\t\t\t\t\tlet normalizedToolCall: ToolCall = toolCall;\n\n\t\t\t\t\tif (!isSameModel && toolCall.thoughtSignature) {\n\t\t\t\t\t\tnormalizedToolCall = { ...toolCall };\n\t\t\t\t\t\tdelete (normalizedToolCall as { thoughtSignature?: string }).thoughtSignature;\n\t\t\t\t\t\tif (report) report.thoughtSignaturesDropped++;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!isSameModel && normalizeToolCallId) {\n\t\t\t\t\t\tconst normalizedId = normalizeToolCallId(toolCall.id, model, assistantMsg);\n\t\t\t\t\t\tif (normalizedId !== toolCall.id) {\n\t\t\t\t\t\t\ttoolCallIdMap.set(toolCall.id, normalizedId);\n\t\t\t\t\t\t\tnormalizedToolCall = { ...normalizedToolCall, id: normalizedId };\n\t\t\t\t\t\t\tif (report) report.toolCallIdsRemapped++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn normalizedToolCall;\n\t\t\t\t}\n\n\t\t\t\treturn block;\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\t...assistantMsg,\n\t\t\t\tcontent: transformedContent,\n\t\t\t};\n\t\t}\n\t\treturn msg;\n\t});\n\n\t// Second pass: insert synthetic empty tool results for orphaned tool calls\n\t// This preserves thinking signatures and satisfies API requirements\n\tconst result: Message[] = [];\n\tlet pendingToolCalls: ToolCall[] = [];\n\tlet existingToolResultIds = new Set<string>();\n\n\tfor (let i = 0; i < transformed.length; i++) {\n\t\tconst msg = transformed[i];\n\n\t\tif (msg.role === \"assistant\") {\n\t\t\t// If we have pending orphaned tool calls from a previous assistant, insert synthetic results now\n\t\t\tif (pendingToolCalls.length > 0) {\n\t\t\t\tfor (const tc of pendingToolCalls) {\n\t\t\t\t\tif (!existingToolResultIds.has(tc.id)) {\n\t\t\t\t\t\tresult.push({\n\t\t\t\t\t\t\trole: \"toolResult\",\n\t\t\t\t\t\t\ttoolCallId: tc.id,\n\t\t\t\t\t\t\ttoolName: tc.name,\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No result provided\" }],\n\t\t\t\t\t\t\tisError: true,\n\t\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t\t} as ToolResultMessage);\n\t\t\t\t\t\tif (report) report.syntheticToolResultsInserted++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpendingToolCalls = [];\n\t\t\t\texistingToolResultIds = new Set();\n\t\t\t}\n\n\t\t\t// Skip errored/aborted assistant messages entirely.\n\t\t\t// These are incomplete turns that shouldn't be replayed:\n\t\t\t// - May have partial content (reasoning without message, incomplete tool calls)\n\t\t\t// - Replaying them can cause API errors (e.g., OpenAI \"reasoning without following item\")\n\t\t\t// - The model should retry from the last valid state\n\t\t\tconst assistantMsg = msg as AssistantMessage;\n\t\t\tif (assistantMsg.stopReason === \"error\" || assistantMsg.stopReason === \"aborted\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Track tool calls from this assistant message\n\t\t\tconst toolCalls = assistantMsg.content.filter((b) => b.type === \"toolCall\") as ToolCall[];\n\t\t\tif (toolCalls.length > 0) {\n\t\t\t\tpendingToolCalls = toolCalls;\n\t\t\t\texistingToolResultIds = new Set();\n\t\t\t}\n\n\t\t\tresult.push(msg);\n\t\t} else if (msg.role === \"toolResult\") {\n\t\t\texistingToolResultIds.add(msg.toolCallId);\n\t\t\tresult.push(msg);\n\t\t} else if (msg.role === \"user\") {\n\t\t\t// User message interrupts tool flow - insert synthetic results for orphaned calls\n\t\t\tif (pendingToolCalls.length > 0) {\n\t\t\t\tfor (const tc of pendingToolCalls) {\n\t\t\t\t\tif (!existingToolResultIds.has(tc.id)) {\n\t\t\t\t\t\tresult.push({\n\t\t\t\t\t\t\trole: \"toolResult\",\n\t\t\t\t\t\t\ttoolCallId: tc.id,\n\t\t\t\t\t\t\ttoolName: tc.name,\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No result provided\" }],\n\t\t\t\t\t\t\tisError: true,\n\t\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t\t} as ToolResultMessage);\n\t\t\t\t\t\tif (report) report.syntheticToolResultsInserted++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpendingToolCalls = [];\n\t\t\t\texistingToolResultIds = new Set();\n\t\t\t}\n\t\t\tresult.push(msg);\n\t\t} else {\n\t\t\tresult.push(msg);\n\t\t}\n\t}\n\n\treturn result;\n}\n"]}
|
|
@@ -12,7 +12,10 @@ export * from "./providers/google-vertex.js";
|
|
|
12
12
|
export * from "./providers/mistral.js";
|
|
13
13
|
export * from "./providers/openai-completions.js";
|
|
14
14
|
export * from "./providers/openai-responses.js";
|
|
15
|
+
export * from "./providers/provider-capabilities.js";
|
|
15
16
|
export * from "./providers/register-builtins.js";
|
|
17
|
+
export type { ProviderSwitchReport } from "./providers/transform-messages.js";
|
|
18
|
+
export { createEmptyReport, hasTransformations, transformMessagesWithReport } from "./providers/transform-messages.js";
|
|
16
19
|
export * from "./stream.js";
|
|
17
20
|
export * from "./types.js";
|
|
18
21
|
export * from "./utils/event-stream.js";
|
|
@@ -43,7 +43,7 @@ import { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|
|
43
43
|
import { parseStreamingJson } from "../utils/json-parse.js";
|
|
44
44
|
import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
|
|
45
45
|
import { adjustMaxTokensForThinking, buildBaseOptions, clampReasoning } from "./simple-options.js";
|
|
46
|
-
import {
|
|
46
|
+
import { transformMessagesWithReport } from "./transform-messages.js";
|
|
47
47
|
|
|
48
48
|
export interface BedrockOptions extends StreamOptions {
|
|
49
49
|
region?: string;
|
|
@@ -487,7 +487,7 @@ function convertMessages(
|
|
|
487
487
|
cacheRetention: CacheRetention,
|
|
488
488
|
): Message[] {
|
|
489
489
|
const result: Message[] = [];
|
|
490
|
-
const transformedMessages =
|
|
490
|
+
const transformedMessages = transformMessagesWithReport(context.messages, model, normalizeToolCallId, "bedrock-converse-stream");
|
|
491
491
|
|
|
492
492
|
for (let i = 0; i < transformedMessages.length; i++) {
|
|
493
493
|
const m = transformedMessages[i];
|
|
@@ -33,7 +33,7 @@ import type { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|
|
33
33
|
import { parseStreamingJson } from "../utils/json-parse.js";
|
|
34
34
|
import { hasXmlParameterTags, repairToolJson } from "../utils/repair-tool-json.js";
|
|
35
35
|
import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
|
|
36
|
-
import {
|
|
36
|
+
import { transformMessagesWithReport } from "./transform-messages.js";
|
|
37
37
|
|
|
38
38
|
export type AnthropicEffort = "low" | "medium" | "high" | "max";
|
|
39
39
|
|
|
@@ -235,7 +235,7 @@ export function convertMessages(
|
|
|
235
235
|
): MessageParam[] {
|
|
236
236
|
const params: MessageParam[] = [];
|
|
237
237
|
|
|
238
|
-
const transformedMessages =
|
|
238
|
+
const transformedMessages = transformMessagesWithReport(messages, model, normalizeToolCallId, "anthropic-messages");
|
|
239
239
|
|
|
240
240
|
for (let i = 0; i < transformedMessages.length; i++) {
|
|
241
241
|
const msg = transformedMessages[i];
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { type Content, FinishReason, FunctionCallingConfigMode, type Part } from "@google/genai";
|
|
6
6
|
import type { Context, ImageContent, Model, StopReason, TextContent, Tool } from "../types.js";
|
|
7
7
|
import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
|
|
8
|
-
import {
|
|
8
|
+
import { transformMessagesWithReport } from "./transform-messages.js";
|
|
9
9
|
|
|
10
10
|
type GoogleApiType = "google-generative-ai" | "google-gemini-cli" | "google-vertex";
|
|
11
11
|
|
|
@@ -80,7 +80,7 @@ export function convertMessages<T extends GoogleApiType>(model: Model<T>, contex
|
|
|
80
80
|
return id.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64);
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
const transformedMessages =
|
|
83
|
+
const transformedMessages = transformMessagesWithReport(context.messages, model, normalizeToolCallId, "google-generative-ai");
|
|
84
84
|
|
|
85
85
|
for (const msg of transformedMessages) {
|
|
86
86
|
if (msg.role === "user") {
|
|
@@ -39,7 +39,7 @@ import { shortHash } from "../utils/hash.js";
|
|
|
39
39
|
import { parseStreamingJson } from "../utils/json-parse.js";
|
|
40
40
|
import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
|
|
41
41
|
import { buildBaseOptions, clampReasoning } from "./simple-options.js";
|
|
42
|
-
import {
|
|
42
|
+
import { transformMessagesWithReport } from "./transform-messages.js";
|
|
43
43
|
|
|
44
44
|
const MISTRAL_TOOL_CALL_ID_LENGTH = 9;
|
|
45
45
|
const MAX_MISTRAL_ERROR_BODY_CHARS = 4000;
|
|
@@ -79,7 +79,7 @@ export const streamMistral: StreamFunction<"mistral-conversations", MistralOptio
|
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
const normalizeMistralToolCallId = createMistralToolCallIdNormalizer();
|
|
82
|
-
const transformedMessages =
|
|
82
|
+
const transformedMessages = transformMessagesWithReport(context.messages, model, (id) => normalizeMistralToolCallId(id), "mistral-conversations");
|
|
83
83
|
|
|
84
84
|
let payload = buildChatPayload(model, context, transformedMessages, options);
|
|
85
85
|
const nextPayload = await options?.onPayload?.(payload, model);
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
finalizeStream,
|
|
40
40
|
handleStreamError,
|
|
41
41
|
} from "./openai-shared.js";
|
|
42
|
-
import {
|
|
42
|
+
import { transformMessagesWithReport } from "./transform-messages.js";
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Check if conversation messages contain tool calls or tool results.
|
|
@@ -441,7 +441,7 @@ export function convertMessages(
|
|
|
441
441
|
return id;
|
|
442
442
|
};
|
|
443
443
|
|
|
444
|
-
const transformedMessages =
|
|
444
|
+
const transformedMessages = transformMessagesWithReport(context.messages, model, (id) => normalizeToolCallId(id), "openai-completions");
|
|
445
445
|
|
|
446
446
|
if (context.systemPrompt) {
|
|
447
447
|
const useDeveloperRole = model.reasoning && compat.supportsDeveloperRole;
|
|
@@ -30,7 +30,7 @@ import type { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|
|
30
30
|
import { shortHash } from "../utils/hash.js";
|
|
31
31
|
import { parseStreamingJson } from "../utils/json-parse.js";
|
|
32
32
|
import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
|
|
33
|
-
import {
|
|
33
|
+
import { transformMessagesWithReport } from "./transform-messages.js";
|
|
34
34
|
|
|
35
35
|
// =============================================================================
|
|
36
36
|
// Utilities
|
|
@@ -108,7 +108,7 @@ export function convertResponsesMessages<TApi extends Api>(
|
|
|
108
108
|
return `${normalizedCallId}|${normalizedItemId}`;
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
-
const transformedMessages =
|
|
111
|
+
const transformedMessages = transformMessagesWithReport(context.messages, model, normalizeToolCallId, "openai-responses");
|
|
112
112
|
|
|
113
113
|
const includeSystemPrompt = options?.includeSystemPrompt ?? true;
|
|
114
114
|
if (includeSystemPrompt && context.systemPrompt) {
|
|
@@ -0,0 +1,174 @@
|
|
|
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
|
+
|
|
5
|
+
import {
|
|
6
|
+
PROVIDER_CAPABILITIES,
|
|
7
|
+
getProviderCapabilities,
|
|
8
|
+
getUnsupportedFeatures,
|
|
9
|
+
mergeCapabilityOverrides,
|
|
10
|
+
getRegisteredApis,
|
|
11
|
+
} from "./provider-capabilities.js";
|
|
12
|
+
|
|
13
|
+
// ─── Registry Completeness ──────────────────────────────────────────────────
|
|
14
|
+
|
|
15
|
+
describe("PROVIDER_CAPABILITIES registry", () => {
|
|
16
|
+
const EXPECTED_APIS = [
|
|
17
|
+
"anthropic-messages",
|
|
18
|
+
"anthropic-vertex",
|
|
19
|
+
"openai-responses",
|
|
20
|
+
"azure-openai-responses",
|
|
21
|
+
"openai-codex-responses",
|
|
22
|
+
"openai-completions",
|
|
23
|
+
"google-generative-ai",
|
|
24
|
+
"google-gemini-cli",
|
|
25
|
+
"google-vertex",
|
|
26
|
+
"mistral-conversations",
|
|
27
|
+
"bedrock-converse-stream",
|
|
28
|
+
"ollama-chat",
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
test("covers all expected API providers", () => {
|
|
32
|
+
for (const api of EXPECTED_APIS) {
|
|
33
|
+
assert.ok(
|
|
34
|
+
PROVIDER_CAPABILITIES[api],
|
|
35
|
+
`Missing capability entry for API: ${api}`,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("getRegisteredApis returns all entries", () => {
|
|
41
|
+
const registered = getRegisteredApis();
|
|
42
|
+
for (const api of EXPECTED_APIS) {
|
|
43
|
+
assert.ok(registered.includes(api), `getRegisteredApis missing: ${api}`);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("all entries have required fields", () => {
|
|
48
|
+
for (const [api, caps] of Object.entries(PROVIDER_CAPABILITIES)) {
|
|
49
|
+
assert.equal(typeof caps.toolCalling, "boolean", `${api}.toolCalling`);
|
|
50
|
+
assert.equal(typeof caps.maxTools, "number", `${api}.maxTools`);
|
|
51
|
+
assert.equal(typeof caps.imageToolResults, "boolean", `${api}.imageToolResults`);
|
|
52
|
+
assert.equal(typeof caps.structuredOutput, "boolean", `${api}.structuredOutput`);
|
|
53
|
+
assert.ok(caps.toolCallIdFormat, `${api}.toolCallIdFormat`);
|
|
54
|
+
assert.equal(typeof caps.toolCallIdFormat.maxLength, "number", `${api}.toolCallIdFormat.maxLength`);
|
|
55
|
+
assert.ok(caps.toolCallIdFormat.allowedChars instanceof RegExp, `${api}.toolCallIdFormat.allowedChars`);
|
|
56
|
+
assert.ok(
|
|
57
|
+
["full", "text-only", "none"].includes(caps.thinkingPersistence),
|
|
58
|
+
`${api}.thinkingPersistence is "${caps.thinkingPersistence}"`,
|
|
59
|
+
);
|
|
60
|
+
assert.ok(Array.isArray(caps.unsupportedSchemaFeatures), `${api}.unsupportedSchemaFeatures`);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// ─── Provider-specific Values ───────────────────────────────────────────────
|
|
66
|
+
|
|
67
|
+
describe("provider-specific capabilities", () => {
|
|
68
|
+
test("Anthropic supports full thinking persistence", () => {
|
|
69
|
+
assert.equal(PROVIDER_CAPABILITIES["anthropic-messages"].thinkingPersistence, "full");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("Anthropic supports image tool results", () => {
|
|
73
|
+
assert.equal(PROVIDER_CAPABILITIES["anthropic-messages"].imageToolResults, true);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test("Anthropic tool call ID is 64 chars max", () => {
|
|
77
|
+
assert.equal(PROVIDER_CAPABILITIES["anthropic-messages"].toolCallIdFormat.maxLength, 64);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test("Mistral tool call ID is 9 chars max", () => {
|
|
81
|
+
assert.equal(PROVIDER_CAPABILITIES["mistral-conversations"].toolCallIdFormat.maxLength, 9);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test("Mistral has no thinking persistence", () => {
|
|
85
|
+
assert.equal(PROVIDER_CAPABILITIES["mistral-conversations"].thinkingPersistence, "none");
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test("Google does not support patternProperties", () => {
|
|
89
|
+
assert.ok(
|
|
90
|
+
PROVIDER_CAPABILITIES["google-generative-ai"].unsupportedSchemaFeatures.includes("patternProperties"),
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test("Google does not support const", () => {
|
|
95
|
+
assert.ok(
|
|
96
|
+
PROVIDER_CAPABILITIES["google-generative-ai"].unsupportedSchemaFeatures.includes("const"),
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test("OpenAI Responses does not support image tool results", () => {
|
|
101
|
+
assert.equal(PROVIDER_CAPABILITIES["openai-responses"].imageToolResults, false);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test("OpenAI Responses has text-only thinking persistence", () => {
|
|
105
|
+
assert.equal(PROVIDER_CAPABILITIES["openai-responses"].thinkingPersistence, "text-only");
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// ─── getProviderCapabilities ────────────────────────────────────────────────
|
|
110
|
+
|
|
111
|
+
describe("getProviderCapabilities", () => {
|
|
112
|
+
test("returns known provider capabilities", () => {
|
|
113
|
+
const caps = getProviderCapabilities("anthropic-messages");
|
|
114
|
+
assert.equal(caps.toolCalling, true);
|
|
115
|
+
assert.equal(caps.thinkingPersistence, "full");
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test("returns permissive defaults for unknown providers", () => {
|
|
119
|
+
const caps = getProviderCapabilities("unknown-provider-xyz");
|
|
120
|
+
assert.equal(caps.toolCalling, true);
|
|
121
|
+
assert.equal(caps.imageToolResults, true);
|
|
122
|
+
assert.deepEqual(caps.unsupportedSchemaFeatures, []);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// ─── getUnsupportedFeatures ─────────────────────────────────────────────────
|
|
127
|
+
|
|
128
|
+
describe("getUnsupportedFeatures", () => {
|
|
129
|
+
test("returns unsupported features for Google", () => {
|
|
130
|
+
const unsupported = getUnsupportedFeatures("google-generative-ai", ["patternProperties", "const"]);
|
|
131
|
+
assert.deepEqual(unsupported, ["patternProperties", "const"]);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test("returns empty for Anthropic with any features", () => {
|
|
135
|
+
const unsupported = getUnsupportedFeatures("anthropic-messages", ["patternProperties", "const"]);
|
|
136
|
+
assert.deepEqual(unsupported, []);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test("returns empty for unknown provider", () => {
|
|
140
|
+
const unsupported = getUnsupportedFeatures("unknown-xyz", ["patternProperties"]);
|
|
141
|
+
assert.deepEqual(unsupported, []);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// ─── mergeCapabilityOverrides ───────────────────────────────────────────────
|
|
146
|
+
|
|
147
|
+
describe("mergeCapabilityOverrides", () => {
|
|
148
|
+
test("overrides individual fields", () => {
|
|
149
|
+
const merged = mergeCapabilityOverrides("openai-responses", {
|
|
150
|
+
imageToolResults: true,
|
|
151
|
+
});
|
|
152
|
+
assert.equal(merged.imageToolResults, true);
|
|
153
|
+
// Non-overridden fields preserved
|
|
154
|
+
assert.equal(merged.toolCalling, true);
|
|
155
|
+
assert.equal(merged.thinkingPersistence, "text-only");
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test("deep-merges toolCallIdFormat", () => {
|
|
159
|
+
const merged = mergeCapabilityOverrides("anthropic-messages", {
|
|
160
|
+
toolCallIdFormat: { maxLength: 128 },
|
|
161
|
+
});
|
|
162
|
+
assert.equal(merged.toolCallIdFormat.maxLength, 128);
|
|
163
|
+
// allowedChars preserved from base
|
|
164
|
+
assert.ok(merged.toolCallIdFormat.allowedChars instanceof RegExp);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test("uses permissive defaults for unknown provider", () => {
|
|
168
|
+
const merged = mergeCapabilityOverrides("unknown-xyz", {
|
|
169
|
+
imageToolResults: false,
|
|
170
|
+
});
|
|
171
|
+
assert.equal(merged.imageToolResults, false);
|
|
172
|
+
assert.equal(merged.toolCalling, true); // from default
|
|
173
|
+
});
|
|
174
|
+
});
|