saeeol 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (545) hide show
  1. package/AGENTS.md +72 -0
  2. package/BUN_SHELL_MIGRATION_PLAN.md +136 -0
  3. package/Dockerfile +18 -0
  4. package/assets/saeeol.ico +0 -0
  5. package/bin/saeeol.cjs +3 -1
  6. package/bunfig.toml +7 -0
  7. package/database.db +0 -0
  8. package/drizzle.config.ts +10 -0
  9. package/git +0 -0
  10. package/migration/20260127222353_familiar_lady_ursula/migration.sql +90 -0
  11. package/migration/20260127222353_familiar_lady_ursula/snapshot.json +796 -0
  12. package/migration/20260211171708_add_project_commands/migration.sql +1 -0
  13. package/migration/20260211171708_add_project_commands/snapshot.json +806 -0
  14. package/migration/20260213144116_wakeful_the_professor/migration.sql +11 -0
  15. package/migration/20260213144116_wakeful_the_professor/snapshot.json +897 -0
  16. package/migration/20260225215848_workspace/migration.sql +7 -0
  17. package/migration/20260225215848_workspace/snapshot.json +959 -0
  18. package/migration/20260227213759_add_session_workspace_id/migration.sql +2 -0
  19. package/migration/20260227213759_add_session_workspace_id/snapshot.json +983 -0
  20. package/migration/20260228203230_blue_harpoon/migration.sql +17 -0
  21. package/migration/20260228203230_blue_harpoon/snapshot.json +1102 -0
  22. package/migration/20260303231226_add_workspace_fields/migration.sql +5 -0
  23. package/migration/20260303231226_add_workspace_fields/snapshot.json +1013 -0
  24. package/migration/20260309230000_move_org_to_state/migration.sql +3 -0
  25. package/migration/20260309230000_move_org_to_state/snapshot.json +1156 -0
  26. package/migration/20260312043431_session_message_cursor/migration.sql +4 -0
  27. package/migration/20260312043431_session_message_cursor/snapshot.json +1168 -0
  28. package/migration/20260323234822_events/migration.sql +13 -0
  29. package/migration/20260323234822_events/snapshot.json +1271 -0
  30. package/migration/20260410174513_workspace-name/migration.sql +16 -0
  31. package/migration/20260410174513_workspace-name/snapshot.json +1271 -0
  32. package/migration/20260413175956_chief_energizer/migration.sql +13 -0
  33. package/migration/20260413175956_chief_energizer/snapshot.json +1399 -0
  34. package/migration/20260423070820_add_icon_url_override/migration.sql +2 -0
  35. package/migration/20260423070820_add_icon_url_override/snapshot.json +1409 -0
  36. package/migration/20260428004200_add_session_path/migration.sql +1 -0
  37. package/migration/20260428004200_add_session_path/snapshot.json +1419 -0
  38. package/npm/bin/saeeol +42 -0
  39. package/npm/package.json +39 -0
  40. package/npm/postinstall.js +162 -0
  41. package/package.json +201 -207
  42. package/parsers-config.ts +289 -0
  43. package/script/build.ts +393 -0
  44. package/script/check-migrations.ts +16 -0
  45. package/script/fix-node-pty.ts +34 -0
  46. package/script/generate.ts +23 -0
  47. package/script/postinstall.mjs +189 -0
  48. package/script/publish.ts +200 -0
  49. package/script/run-workspace-server +106 -0
  50. package/script/schema.ts +63 -0
  51. package/script/test-runner.ts +420 -0
  52. package/script/time.ts +6 -0
  53. package/script/trace-imports.ts +153 -0
  54. package/script/upgrade-opentui.ts +64 -0
  55. package/scripts/diff-sdk-types.sh +52 -0
  56. package/specs/effect/facades.md +221 -0
  57. package/specs/effect/http-api.md +401 -0
  58. package/specs/effect/instance-context.md +309 -0
  59. package/specs/effect/loose-ends.md +34 -0
  60. package/specs/effect/migration.md +299 -0
  61. package/specs/effect/routes.md +64 -0
  62. package/specs/effect/schema.md +399 -0
  63. package/specs/effect/server-package.md +668 -0
  64. package/specs/effect/tools.md +90 -0
  65. package/specs/tui-plugins.md +433 -0
  66. package/specs/v2/api.ts +67 -0
  67. package/specs/v2/keymappings.md +10 -0
  68. package/specs/v2/message-shape.md +136 -0
  69. package/src/acp/agent-message.ts +1 -1
  70. package/src/acp/agent-utils.ts +1 -1
  71. package/src/boxes/ansi.ts +17 -0
  72. package/src/boxes/atomic-write.ts +35 -0
  73. package/src/boxes/b64.ts +58 -0
  74. package/src/boxes/bash-security.ts +129 -0
  75. package/src/boxes/bom.ts +18 -0
  76. package/src/boxes/cancel.ts +16 -0
  77. package/src/boxes/chop.ts +12 -0
  78. package/src/boxes/clamp.ts +3 -0
  79. package/src/boxes/compact.ts +9 -0
  80. package/src/boxes/cost-tracker.ts +116 -0
  81. package/src/boxes/dataurl.ts +29 -0
  82. package/src/boxes/delay.ts +27 -0
  83. package/src/boxes/diff-apply.ts +53 -0
  84. package/src/boxes/disposable.ts +13 -0
  85. package/src/boxes/err.ts +34 -0
  86. package/src/boxes/human.ts +47 -0
  87. package/src/boxes/iife.ts +9 -0
  88. package/src/boxes/latch.ts +8 -0
  89. package/src/boxes/memory.ts +198 -0
  90. package/src/boxes/net.ts +16 -0
  91. package/src/boxes/plural.ts +4 -0
  92. package/src/boxes/puny.ts +21 -0
  93. package/src/boxes/retry.ts +49 -0
  94. package/src/boxes/rwlock.ts +41 -0
  95. package/src/boxes/schedule.ts +71 -0
  96. package/src/boxes/scope.ts +21 -0
  97. package/src/boxes/tokens.ts +9 -0
  98. package/src/boxes/ttl-cache.ts +63 -0
  99. package/src/boxes/typed-event.ts +51 -0
  100. package/src/boxes/uid.ts +50 -0
  101. package/src/boxes/wave6.test.ts +296 -0
  102. package/src/boxes/wildcard.ts +58 -0
  103. package/src/bus/global.ts +1 -1
  104. package/src/cli/cmd/github-run-api.ts +2 -2
  105. package/src/cli/cmd/run-events.ts +2 -2
  106. package/src/cli/cmd/tui/component/logo.tsx +1 -1
  107. package/src/cli/cmd/tui/component/prompt/use-prompt-memos.ts +2 -2
  108. package/src/cli/cmd/tui/context/app/editor-zed.ts +1 -1
  109. package/src/cli/cmd/tui/context/app/editor.ts +1 -1
  110. package/src/cli/cmd/tui/context/app/theme.tsx +1 -1
  111. package/src/cli/cmd/tui/preflight.ts +138 -0
  112. package/src/cli/cmd/tui/thread.ts +20 -0
  113. package/src/cli/cmd/tui/util/revert-diff.ts +1 -1
  114. package/src/overlay/cli/cmd/roll-call-call.ts +1 -1
  115. package/src/overlay/cost-tracker/format.ts +1 -1
  116. package/src/overlay/cost-tracker/index.ts +4 -4
  117. package/src/overlay/cost-tracker/state.ts +2 -2
  118. package/src/overlay/cost-tracker/types.ts +2 -2
  119. package/src/overlay/memory/age.ts +1 -1
  120. package/src/overlay/memory/index.ts +4 -4
  121. package/src/overlay/memory/paths.ts +2 -2
  122. package/src/overlay/memory/scan.ts +1 -1
  123. package/src/overlay/memory/types.ts +2 -2
  124. package/src/overlay/tool/bash-security.ts +3 -3
  125. package/src/overlay/util/url.ts +1 -1
  126. package/src/plugin/codex-auth.ts +1 -1
  127. package/src/provider/model-cache.ts +2 -2
  128. package/src/provider/provider-resolve.ts +3 -3
  129. package/src/provider/transform-message.ts +1 -1
  130. package/src/server/routes/game.ts +284 -0
  131. package/src/server/server.ts +2 -0
  132. package/src/session/core/compaction/compaction-helpers.ts +1 -1
  133. package/src/session/core/compaction/compaction.ts +1 -1
  134. package/src/session/core/session.ts +2 -0
  135. package/src/sessions/ingest-queue.ts +2 -2
  136. package/src/sessions/remote-ws.ts +1 -1
  137. package/src/tool/workflow/question.ts +1 -1
  138. package/src/util/abort.ts +1 -1
  139. package/src/util/bom.ts +2 -2
  140. package/src/util/color.ts +1 -1
  141. package/src/util/data-url.ts +1 -1
  142. package/src/util/defer.ts +1 -1
  143. package/src/util/error.ts +2 -2
  144. package/src/util/filesystem.ts +2 -2
  145. package/src/util/format.ts +1 -1
  146. package/src/util/iife.ts +1 -1
  147. package/src/util/local-context.ts +1 -1
  148. package/src/util/locale.ts +2 -2
  149. package/src/util/lock.ts +1 -1
  150. package/src/util/network.ts +1 -1
  151. package/src/util/signal.ts +1 -1
  152. package/src/util/token.ts +1 -1
  153. package/src/util/wildcard.ts +1 -1
  154. package/sst-env.d.ts +10 -0
  155. package/test/AGENTS.md +133 -0
  156. package/test/account/repo.test.ts +352 -0
  157. package/test/account/service.test.ts +456 -0
  158. package/test/acp/agent-interface.test.ts +51 -0
  159. package/test/acp/event-subscription.test.ts +725 -0
  160. package/test/agent/agent.test.ts +890 -0
  161. package/test/auth/auth.test.ts +86 -0
  162. package/test/bun/registry.test.ts +75 -0
  163. package/test/bus/bus-effect.test.ts +161 -0
  164. package/test/bus/bus-integration.test.ts +87 -0
  165. package/test/bus/bus.test.ts +219 -0
  166. package/test/cli/account.test.ts +26 -0
  167. package/test/cli/auto-mode.test.ts +75 -0
  168. package/test/cli/bin-saeeol.test.ts +8 -0
  169. package/test/cli/cmd/tui/prompt-part.test.ts +47 -0
  170. package/test/cli/cmd/tui/prompt-traits.test.ts +38 -0
  171. package/test/cli/cmd/tui/sync.test.tsx +159 -0
  172. package/test/cli/error.test.ts +18 -0
  173. package/test/cli/github-action.test.ts +198 -0
  174. package/test/cli/github-remote.test.ts +85 -0
  175. package/test/cli/import.test.ts +97 -0
  176. package/test/cli/install-artifact.test.ts +72 -0
  177. package/test/cli/plugin-auth-picker.test.ts +120 -0
  178. package/test/cli/pr.test.ts +59 -0
  179. package/test/cli/tui/editor-context-zed.test.ts +356 -0
  180. package/test/cli/tui/editor-context.test.tsx +228 -0
  181. package/test/cli/tui/keybind-plugin.test.ts +90 -0
  182. package/test/cli/tui/markdown.test.ts +161 -0
  183. package/test/cli/tui/plugin-add.test.ts +111 -0
  184. package/test/cli/tui/plugin-install.test.ts +87 -0
  185. package/test/cli/tui/plugin-lifecycle.test.ts +224 -0
  186. package/test/cli/tui/plugin-loader-entrypoint.test.ts +484 -0
  187. package/test/cli/tui/plugin-loader-pure.test.ts +71 -0
  188. package/test/cli/tui/plugin-loader.test.ts +816 -0
  189. package/test/cli/tui/plugin-toggle.test.ts +157 -0
  190. package/test/cli/tui/revert-diff.test.ts +35 -0
  191. package/test/cli/tui/slot-replace.test.tsx +47 -0
  192. package/test/cli/tui/theme-store.test.ts +54 -0
  193. package/test/cli/tui/thread.test.ts +28 -0
  194. package/test/cli/tui/transcript.test.ts +426 -0
  195. package/test/cli/tui/usage.test.ts +60 -0
  196. package/test/cli/tui/use-event.test.tsx +175 -0
  197. package/test/config/agent-color.test.ts +67 -0
  198. package/test/config/config.test.ts +2544 -0
  199. package/test/config/fixtures/empty-frontmatter.md +4 -0
  200. package/test/config/fixtures/frontmatter.md +28 -0
  201. package/test/config/fixtures/markdown-header.md +11 -0
  202. package/test/config/fixtures/no-frontmatter.md +1 -0
  203. package/test/config/fixtures/weird-model-id.md +13 -0
  204. package/test/config/lsp.test.ts +87 -0
  205. package/test/config/markdown.test.ts +228 -0
  206. package/test/config/plugin.test.ts +0 -0
  207. package/test/config/tui.test.ts +624 -0
  208. package/test/control-plane/adapters.test.ts +71 -0
  209. package/test/control-plane/workspace.test.ts +1526 -0
  210. package/test/effect/app-runtime-logger.test.ts +98 -0
  211. package/test/effect/config-service.test.ts +65 -0
  212. package/test/effect/instance-state.test.ts +394 -0
  213. package/test/effect/run-service.test.ts +89 -0
  214. package/test/effect/runner.test.ts +523 -0
  215. package/test/fake/provider.ts +82 -0
  216. package/test/file/fsmonitor.test.ts +68 -0
  217. package/test/file/ignore.test.ts +10 -0
  218. package/test/file/index.test.ts +954 -0
  219. package/test/file/path-traversal.test.ts +205 -0
  220. package/test/file/ripgrep.test.ts +226 -0
  221. package/test/file/watcher.test.ts +249 -0
  222. package/test/filesystem/filesystem.test.ts +319 -0
  223. package/test/fixture/db.ts +11 -0
  224. package/test/fixture/fixture.test.ts +26 -0
  225. package/test/fixture/fixture.ts +175 -0
  226. package/test/fixture/flock-worker.ts +72 -0
  227. package/test/fixture/log-init-worker.ts +62 -0
  228. package/test/fixture/lsp/fake-lsp-server.js +249 -0
  229. package/test/fixture/plug-worker.ts +93 -0
  230. package/test/fixture/plugin-meta-worker.ts +19 -0
  231. package/test/fixture/skills/agents-sdk/SKILL.md +152 -0
  232. package/test/fixture/skills/cloudflare/SKILL.md +211 -0
  233. package/test/fixture/skills/index.json +6 -0
  234. package/test/fixture/tui-plugin.ts +323 -0
  235. package/test/fixture/tui-runtime.ts +31 -0
  236. package/test/format/format.test.ts +272 -0
  237. package/test/git/git.test.ts +128 -0
  238. package/test/ide/ide.test.ts +82 -0
  239. package/test/installation/installation.test.ts +168 -0
  240. package/test/keybind.test.ts +421 -0
  241. package/test/lib/effect.ts +53 -0
  242. package/test/lib/filesystem.ts +10 -0
  243. package/test/lib/llm-server.ts +778 -0
  244. package/test/lib/websocket.ts +46 -0
  245. package/test/lsp/client.test.ts +482 -0
  246. package/test/lsp/index.test.ts +160 -0
  247. package/test/lsp/launch.test.ts +22 -0
  248. package/test/lsp/lifecycle.test.ts +184 -0
  249. package/test/ltm/ltm.test.ts +230 -0
  250. package/test/mcp/headers.test.ts +178 -0
  251. package/test/mcp/lifecycle.test.ts +787 -0
  252. package/test/mcp/oauth-auto-connect.test.ts +311 -0
  253. package/test/mcp/oauth-browser.test.ts +276 -0
  254. package/test/mcp/oauth-callback.test.ts +34 -0
  255. package/test/memory/abort-leak-webfetch.ts +49 -0
  256. package/test/memory/abort-leak.test.ts +128 -0
  257. package/test/patch/patch.test.ts +348 -0
  258. package/test/permission/arity.test.ts +33 -0
  259. package/test/permission/next.test.ts +1227 -0
  260. package/test/permission/next.toConfig.test.ts +110 -0
  261. package/test/permission-task.test.ts +326 -0
  262. package/test/plugin/auth-override.test.ts +79 -0
  263. package/test/plugin/cloudflare.test.ts +68 -0
  264. package/test/plugin/codex.test.ts +123 -0
  265. package/test/plugin/github-copilot-models.test.ts +261 -0
  266. package/test/plugin/install-concurrency.test.ts +140 -0
  267. package/test/plugin/install.test.ts +570 -0
  268. package/test/plugin/loader-shared.test.ts +1169 -0
  269. package/test/plugin/meta.test.ts +137 -0
  270. package/test/plugin/plugin-contract.test.ts +291 -0
  271. package/test/plugin/shared.test.ts +88 -0
  272. package/test/plugin/trigger.test.ts +102 -0
  273. package/test/plugin/workspace-adapter.test.ts +109 -0
  274. package/test/preload.ts +77 -0
  275. package/test/project/instance.test.ts +276 -0
  276. package/test/project/migrate-global.test.ts +152 -0
  277. package/test/project/project.test.ts +600 -0
  278. package/test/project/vcs.test.ts +286 -0
  279. package/test/project/worktree-remove.test.ts +126 -0
  280. package/test/project/worktree.test.ts +223 -0
  281. package/test/provider/amazon-bedrock.test.ts +462 -0
  282. package/test/provider/copilot/convert-to-copilot-messages.test.ts +523 -0
  283. package/test/provider/copilot/copilot-chat-model.test.ts +592 -0
  284. package/test/provider/gitlab-duo.test.ts +413 -0
  285. package/test/provider/local.test.ts +208 -0
  286. package/test/provider/models.test.ts +261 -0
  287. package/test/provider/provider-category.test.ts +190 -0
  288. package/test/provider/provider.test.ts +2758 -0
  289. package/test/provider/transform.test.ts +3681 -0
  290. package/test/pty/pty-output-isolation.test.ts +147 -0
  291. package/test/pty/pty-session.test.ts +102 -0
  292. package/test/pty/pty-shell.test.ts +104 -0
  293. package/test/question/question.test.ts +490 -0
  294. package/test/saeeol/agent-global-config-dirs.test.ts +24 -0
  295. package/test/saeeol/agent-manager-tool.test.ts +71 -0
  296. package/test/saeeol/agent-permission-overrides.test.ts +75 -0
  297. package/test/saeeol/agent-skill-permissions.test.ts +37 -0
  298. package/test/saeeol/ask-agent-permissions.test.ts +303 -0
  299. package/test/saeeol/bash-hierarchy.test.ts +64 -0
  300. package/test/saeeol/bash-permission-metadata.test.ts +66 -0
  301. package/test/saeeol/bash-security-extended.test.ts +243 -0
  302. package/test/saeeol/bedrock-claude-empty-content.test.ts +138 -0
  303. package/test/saeeol/boxes-integration.test.ts +415 -0
  304. package/test/saeeol/builtin-skills.test.ts +75 -0
  305. package/test/saeeol/cleanup.ts +28 -0
  306. package/test/saeeol/cli/dev-setup.test.ts +74 -0
  307. package/test/saeeol/cli/roll-call.test.ts +161 -0
  308. package/test/saeeol/cli-run-auto-helper.test.ts +58 -0
  309. package/test/saeeol/codex-auth-refresh.test.ts +124 -0
  310. package/test/saeeol/commit-message/generate.test.ts +188 -0
  311. package/test/saeeol/commit-message/git-context.test.ts +303 -0
  312. package/test/saeeol/commit-message-windows.test.ts +38 -0
  313. package/test/saeeol/compaction-payload-recovery.test.ts +406 -0
  314. package/test/saeeol/compaction-preservation-audit.test.ts +122 -0
  315. package/test/saeeol/compaction-skip-guard.test.ts +224 -0
  316. package/test/saeeol/compaction-smart-select.test.ts +100 -0
  317. package/test/saeeol/config/config.test.ts +166 -0
  318. package/test/saeeol/config/indexing-default-plugin.test.ts +82 -0
  319. package/test/saeeol/config/opentelemetry-default.test.ts +29 -0
  320. package/test/saeeol/config-gitignore.test.ts +70 -0
  321. package/test/saeeol/config-injector.test.ts +305 -0
  322. package/test/saeeol/config-resilience.test.ts +234 -0
  323. package/test/saeeol/config-validation.test.ts +183 -0
  324. package/test/saeeol/cost-propagation.test.ts +94 -0
  325. package/test/saeeol/cost-tracker-extended.test.ts +141 -0
  326. package/test/saeeol/cost-tracker.test.ts +64 -0
  327. package/test/saeeol/custom-provider-delete.test.ts +149 -0
  328. package/test/saeeol/diff-full.test.ts +226 -0
  329. package/test/saeeol/edit-permission-filediff.test.ts +223 -0
  330. package/test/saeeol/encoding.test.ts +364 -0
  331. package/test/saeeol/enhance-prompt.test.ts +61 -0
  332. package/test/saeeol/ensure-plan-dir.test.ts +32 -0
  333. package/test/saeeol/errors.test.ts +144 -0
  334. package/test/saeeol/external-directory-boundary.test.ts +96 -0
  335. package/test/saeeol/gateway-headers.test.ts +88 -0
  336. package/test/saeeol/help.test.ts +191 -0
  337. package/test/saeeol/ignore-migrator.test.ts +308 -0
  338. package/test/saeeol/indexing-auth.test.ts +45 -0
  339. package/test/saeeol/indexing-feature.test.ts +44 -0
  340. package/test/saeeol/indexing-label.test.ts +70 -0
  341. package/test/saeeol/indexing-startup.test.ts +381 -0
  342. package/test/saeeol/indexing-worktree.test.ts +73 -0
  343. package/test/saeeol/instruction.test.ts +136 -0
  344. package/test/saeeol/lancedb-runtime.test.ts +116 -0
  345. package/test/saeeol/loader-auth.test.ts +168 -0
  346. package/test/saeeol/local-model.test.ts +621 -0
  347. package/test/saeeol/logo.test.ts +31 -0
  348. package/test/saeeol/lsp-typescript-lightweight.test.ts +89 -0
  349. package/test/saeeol/mcp-branding.test.ts +33 -0
  350. package/test/saeeol/mcp-docker-rm.test.ts +32 -0
  351. package/test/saeeol/mcp-migrator.test.ts +736 -0
  352. package/test/saeeol/mcp-oauth-callback.test.ts +33 -0
  353. package/test/saeeol/memory-io.test.ts +198 -0
  354. package/test/saeeol/memory-paths.test.ts +87 -0
  355. package/test/saeeol/memory-security.test.ts +166 -0
  356. package/test/saeeol/model-cache-org.test.ts +164 -0
  357. package/test/saeeol/model-info-panel-utils.test.ts +52 -0
  358. package/test/saeeol/model-info-panel.types.test.ts +7 -0
  359. package/test/saeeol/models-401-fallback.test.ts +52 -0
  360. package/test/saeeol/modes-migrator.test.ts +320 -0
  361. package/test/saeeol/nvidia-headers.test.ts +74 -0
  362. package/test/saeeol/patch-jsonc.test.ts +73 -0
  363. package/test/saeeol/patch.test.ts +172 -0
  364. package/test/saeeol/paths.test.ts +265 -0
  365. package/test/saeeol/permission/config-paths.test.ts +174 -0
  366. package/test/saeeol/permission/env-read.test.ts +149 -0
  367. package/test/saeeol/permission/external-directory-allow.test.ts +327 -0
  368. package/test/saeeol/permission/next.always-rules.test.ts +882 -0
  369. package/test/saeeol/permission/next.reply-http.test.ts +205 -0
  370. package/test/saeeol/permission/next.reply-routing.test.ts +184 -0
  371. package/test/saeeol/plan-exit-detection.test.ts +494 -0
  372. package/test/saeeol/plan-followup.test.ts +1376 -0
  373. package/test/saeeol/project-config-update.test.ts +120 -0
  374. package/test/saeeol/project-id.test.ts +455 -0
  375. package/test/saeeol/provider-cost.test.ts +171 -0
  376. package/test/saeeol/provider-list-failed-state.test.ts +100 -0
  377. package/test/saeeol/question-dismiss-all.test.ts +174 -0
  378. package/test/saeeol/read-directory.test.ts +116 -0
  379. package/test/saeeol/rules-migrator.test.ts +257 -0
  380. package/test/saeeol/run-auto.test.ts +176 -0
  381. package/test/saeeol/run-network.test.ts +224 -0
  382. package/test/saeeol/semantic-search.test.ts +186 -0
  383. package/test/saeeol/server/permission-allow-everything.test.ts +125 -0
  384. package/test/saeeol/session/instruction-substitution.test.ts +72 -0
  385. package/test/saeeol/session/platform-attribution.test.ts +118 -0
  386. package/test/saeeol/session/session.test.ts +105 -0
  387. package/test/saeeol/session-compaction-cap.test.ts +399 -0
  388. package/test/saeeol/session-compaction-chunks.test.ts +501 -0
  389. package/test/saeeol/session-compaction-safety.test.ts +481 -0
  390. package/test/saeeol/session-fork-remap.test.ts +251 -0
  391. package/test/saeeol/session-import-service.test.ts +114 -0
  392. package/test/saeeol/session-list.test.ts +47 -0
  393. package/test/saeeol/session-message-metadata.test.ts +128 -0
  394. package/test/saeeol/session-overflow.test.ts +78 -0
  395. package/test/saeeol/session-processor-empty-tool-calls.test.ts +571 -0
  396. package/test/saeeol/session-processor-network-offline.test.ts +204 -0
  397. package/test/saeeol/session-processor-retry-limit.test.ts +238 -0
  398. package/test/saeeol/session-processor-review-telemetry.test.ts +82 -0
  399. package/test/saeeol/session-prompt-compaction-safety.test.ts +517 -0
  400. package/test/saeeol/session-prompt-queue.test.ts +815 -0
  401. package/test/saeeol/sessions/inflight-cache.test.ts +157 -0
  402. package/test/saeeol/sessions/ingest-queue.test.ts +402 -0
  403. package/test/saeeol/sessions/remote-protocol.test.ts +258 -0
  404. package/test/saeeol/sessions/remote-sender.test.ts +1036 -0
  405. package/test/saeeol/sessions/remote-ws.test.ts +367 -0
  406. package/test/saeeol/sessions/sessions-enable-remote.test.disable +181 -0
  407. package/test/saeeol/slot-prop-reactivity.test.ts +142 -0
  408. package/test/saeeol/snapshot-cache.test.ts +84 -0
  409. package/test/saeeol/snapshot-freeze-repro.test.ts +100 -0
  410. package/test/saeeol/snapshot-track-timeout.test.ts +519 -0
  411. package/test/saeeol/stats-subagent-cost.test.ts +123 -0
  412. package/test/saeeol/suggestion/auto-dismiss.test.ts +65 -0
  413. package/test/saeeol/suggestion/suggestion.test.ts +145 -0
  414. package/test/saeeol/suggestion/tool.test.ts +298 -0
  415. package/test/saeeol/summary-file-diff.test.ts +28 -0
  416. package/test/saeeol/system-prompt.test.ts +142 -0
  417. package/test/saeeol/task-nesting.test.ts +193 -0
  418. package/test/saeeol/telemetry/feedback.test.ts +8 -0
  419. package/test/saeeol/todo-view.test.ts +57 -0
  420. package/test/saeeol/tool-encoding.test.ts +455 -0
  421. package/test/saeeol/tool-registry-indexing-import-failure.test.ts +49 -0
  422. package/test/saeeol/tool-registry-indexing.test.ts +236 -0
  423. package/test/saeeol/tool-registry-semantic-import-failure.test.ts +55 -0
  424. package/test/saeeol/tool-task-model.test.ts +352 -0
  425. package/test/saeeol/transform-opus-4.7.test.ts +89 -0
  426. package/test/saeeol/tui-diff.test.ts +91 -0
  427. package/test/saeeol/tui-sync.test.ts +80 -0
  428. package/test/saeeol/util/url.test.ts +141 -0
  429. package/test/saeeol/workflows-migrator.test.ts +261 -0
  430. package/test/saeeol/worktree-diff-summary.test.ts +64 -0
  431. package/test/saeeol/worktree-diff.test.ts +223 -0
  432. package/test/saeeol/worktree-remove-lock.test.ts +82 -0
  433. package/test/server/AGENTS.md +15 -0
  434. package/test/server/contract.test.ts +357 -0
  435. package/test/server/experimental-session-list.test.ts +157 -0
  436. package/test/server/global-session-list.test.ts +155 -0
  437. package/test/server/httpapi-authorization.test.ts +103 -0
  438. package/test/server/httpapi-bridge.test.ts +440 -0
  439. package/test/server/httpapi-config.test.ts +67 -0
  440. package/test/server/httpapi-cors.test.ts +89 -0
  441. package/test/server/httpapi-event.test.ts +57 -0
  442. package/test/server/httpapi-experimental.test.ts +219 -0
  443. package/test/server/httpapi-file.test.ts +79 -0
  444. package/test/server/httpapi-instance-context.test.ts +237 -0
  445. package/test/server/httpapi-instance.legacy.test.ts +140 -0
  446. package/test/server/httpapi-instance.test.ts +83 -0
  447. package/test/server/httpapi-json-parity.test.ts +263 -0
  448. package/test/server/httpapi-mcp-oauth.test.ts +76 -0
  449. package/test/server/httpapi-mcp.test.ts +189 -0
  450. package/test/server/httpapi-provider.test.ts +153 -0
  451. package/test/server/httpapi-pty-websocket.test.ts +16 -0
  452. package/test/server/httpapi-pty.test.ts +175 -0
  453. package/test/server/httpapi-raw-route-auth.test.ts +89 -0
  454. package/test/server/httpapi-sdk.test.ts +681 -0
  455. package/test/server/httpapi-session.test.ts +464 -0
  456. package/test/server/httpapi-sync.test.ts +130 -0
  457. package/test/server/httpapi-tui.test.ts +121 -0
  458. package/test/server/httpapi-workspace-routing.test.ts +471 -0
  459. package/test/server/httpapi-workspace.test.ts +427 -0
  460. package/test/server/lib/conformance.ts +88 -0
  461. package/test/server/lib/stateful.ts +112 -0
  462. package/test/server/project-init-git.test.ts +113 -0
  463. package/test/server/proxy-util.test.ts +113 -0
  464. package/test/server/session-actions.test.ts +49 -0
  465. package/test/server/session-list.test.ts +238 -0
  466. package/test/server/session-messages.test.ts +167 -0
  467. package/test/server/session-select.test.ts +100 -0
  468. package/test/server/trace-attributes.test.ts +76 -0
  469. package/test/server/workspace-proxy.test.ts +165 -0
  470. package/test/server/workspace-routing.test.ts +85 -0
  471. package/test/session/compaction.test.ts +2420 -0
  472. package/test/session/instruction.test.ts +247 -0
  473. package/test/session/llm.test.ts +1273 -0
  474. package/test/session/message-v2.test.ts +1291 -0
  475. package/test/session/messages-pagination.test.ts +1173 -0
  476. package/test/session/network.test.ts +249 -0
  477. package/test/session/processor-effect.test.ts +847 -0
  478. package/test/session/prompt.test.ts +2131 -0
  479. package/test/session/retry.test.ts +340 -0
  480. package/test/session/revert-compact.test.ts +639 -0
  481. package/test/session/schema-decoding.test.ts +311 -0
  482. package/test/session/session-entry-stepper.test.ts +917 -0
  483. package/test/session/session-schema.test.ts +76 -0
  484. package/test/session/snapshot-tool-race.test.ts +257 -0
  485. package/test/session/structured-output-integration.test.ts +265 -0
  486. package/test/session/structured-output.test.ts +381 -0
  487. package/test/session/system.test.ts +73 -0
  488. package/test/share/share-next.test.ts +333 -0
  489. package/test/shell/shell.test.ts +99 -0
  490. package/test/skill/discovery.test.ts +116 -0
  491. package/test/skill/skill.test.ts +393 -0
  492. package/test/smoke/.tui-debug-output.txt +1 -0
  493. package/test/smoke/.tui-debug-plain.txt +1 -0
  494. package/test/smoke/.tui-walkthrough-report.txt +122 -0
  495. package/test/smoke/smoke-tui-pty.test.ts +123 -0
  496. package/test/smoke/smoke-tui.mjs +83 -0
  497. package/test/smoke/tui-walkthrough.test.ts +520 -0
  498. package/test/snapshot/snapshot.test.ts +1531 -0
  499. package/test/storage/db.test.ts +23 -0
  500. package/test/storage/json-migration.test.ts +832 -0
  501. package/test/storage/storage.test.ts +293 -0
  502. package/test/suggestion/suggestion.test.ts +1 -0
  503. package/test/sync/index.test.ts +256 -0
  504. package/test/tool/__snapshots__/parameters.test.ts.snap +500 -0
  505. package/test/tool/__snapshots__/tool.test.ts.snap +9 -0
  506. package/test/tool/apply_patch.test.ts +614 -0
  507. package/test/tool/bash.test.ts +1225 -0
  508. package/test/tool/diagnostics-filter.test.ts +55 -0
  509. package/test/tool/edit.test.ts +754 -0
  510. package/test/tool/external-directory.test.ts +169 -0
  511. package/test/tool/fixtures/large-image.png +0 -0
  512. package/test/tool/fixtures/models-api.json +65179 -0
  513. package/test/tool/glob.test.ts +107 -0
  514. package/test/tool/grep.test.ts +114 -0
  515. package/test/tool/lsp.test.ts +187 -0
  516. package/test/tool/parameters.test.ts +243 -0
  517. package/test/tool/question.test.ts +129 -0
  518. package/test/tool/read.test.ts +500 -0
  519. package/test/tool/recall.test.ts +151 -0
  520. package/test/tool/registry.test.ts +203 -0
  521. package/test/tool/skill.test.ts +135 -0
  522. package/test/tool/suggest.test.ts +1 -0
  523. package/test/tool/task.test.ts +612 -0
  524. package/test/tool/tool-define.test.ts +99 -0
  525. package/test/tool/truncation.test.ts +260 -0
  526. package/test/tool/webfetch.test.ts +103 -0
  527. package/test/tool/write.test.ts +291 -0
  528. package/test/util/data-url.test.ts +14 -0
  529. package/test/util/effect-zod.test.ts +754 -0
  530. package/test/util/error.test.ts +38 -0
  531. package/test/util/filesystem.test.ts +656 -0
  532. package/test/util/format.test.ts +59 -0
  533. package/test/util/glob.test.ts +164 -0
  534. package/test/util/iife.test.ts +36 -0
  535. package/test/util/lazy.test.ts +50 -0
  536. package/test/util/lock.test.ts +72 -0
  537. package/test/util/log.test.ts +86 -0
  538. package/test/util/module.test.ts +59 -0
  539. package/test/util/process.test.ts +128 -0
  540. package/test/util/timeout.test.ts +21 -0
  541. package/test/util/which.test.ts +100 -0
  542. package/test/util/wildcard.test.ts +90 -0
  543. package/test/workspace/workspace-restore.test.ts +296 -0
  544. package/src/provider/models-snapshot.d.ts +0 -2
  545. package/src/provider/models-snapshot.js +0 -3
@@ -0,0 +1,3681 @@
1
+ import { describe, expect, test } from "bun:test"
2
+ import { ProviderTransform } from "@/provider/transform"
3
+ import { ModelID, ProviderID } from "../../src/provider/schema"
4
+
5
+ describe("ProviderTransform.options - setCacheKey", () => {
6
+ const sessionID = "test-session-123"
7
+
8
+ const mockModel = {
9
+ id: "anthropic/claude-3-5-sonnet",
10
+ providerID: "anthropic",
11
+ api: {
12
+ id: "claude-3-5-sonnet-20241022",
13
+ url: "https://api.anthropic.com",
14
+ npm: "@ai-sdk/anthropic",
15
+ },
16
+ name: "Claude 3.5 Sonnet",
17
+ capabilities: {
18
+ temperature: true,
19
+ reasoning: false,
20
+ attachment: true,
21
+ toolcall: true,
22
+ input: { text: true, audio: false, image: true, video: false, pdf: true },
23
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
24
+ interleaved: false,
25
+ },
26
+ cost: {
27
+ input: 0.003,
28
+ output: 0.015,
29
+ cache: { read: 0.0003, write: 0.00375 },
30
+ },
31
+ limit: {
32
+ context: 200000,
33
+ output: 8192,
34
+ },
35
+ status: "active",
36
+ options: {},
37
+ headers: {},
38
+ } as any
39
+
40
+ test("should set promptCacheKey when providerOptions.setCacheKey is true", () => {
41
+ const result = ProviderTransform.options({
42
+ model: mockModel,
43
+ sessionID,
44
+ providerOptions: { setCacheKey: true },
45
+ })
46
+ expect(result.promptCacheKey).toBe(sessionID)
47
+ })
48
+
49
+ test("should not set promptCacheKey when providerOptions.setCacheKey is false", () => {
50
+ const result = ProviderTransform.options({
51
+ model: mockModel,
52
+ sessionID,
53
+ providerOptions: { setCacheKey: false },
54
+ })
55
+ expect(result.promptCacheKey).toBeUndefined()
56
+ })
57
+
58
+ test("should not set promptCacheKey when providerOptions is undefined", () => {
59
+ const result = ProviderTransform.options({
60
+ model: mockModel,
61
+ sessionID,
62
+ providerOptions: undefined,
63
+ })
64
+ expect(result.promptCacheKey).toBeUndefined()
65
+ })
66
+
67
+ test("should not set promptCacheKey when providerOptions does not have setCacheKey", () => {
68
+ const result = ProviderTransform.options({ model: mockModel, sessionID, providerOptions: {} })
69
+ expect(result.promptCacheKey).toBeUndefined()
70
+ })
71
+
72
+ test("should set promptCacheKey for openai provider regardless of setCacheKey", () => {
73
+ const openaiModel = {
74
+ ...mockModel,
75
+ providerID: "openai",
76
+ api: {
77
+ id: "gpt-4",
78
+ url: "https://api.openai.com",
79
+ npm: "@ai-sdk/openai",
80
+ },
81
+ }
82
+ const result = ProviderTransform.options({ model: openaiModel, sessionID, providerOptions: {} })
83
+ expect(result.promptCacheKey).toBe(sessionID)
84
+ })
85
+
86
+ test("should set store=false for openai provider", () => {
87
+ const openaiModel = {
88
+ ...mockModel,
89
+ providerID: "openai",
90
+ api: {
91
+ id: "gpt-4",
92
+ url: "https://api.openai.com",
93
+ npm: "@ai-sdk/openai",
94
+ },
95
+ }
96
+ const result = ProviderTransform.options({
97
+ model: openaiModel,
98
+ sessionID,
99
+ providerOptions: {},
100
+ })
101
+ expect(result.store).toBe(false)
102
+ })
103
+
104
+ test("should set store=false for azure provider by default", () => {
105
+ const azureModel = {
106
+ ...mockModel,
107
+ providerID: "azure",
108
+ api: {
109
+ id: "gpt-4",
110
+ url: "https://azure.com",
111
+ npm: "@ai-sdk/azure",
112
+ },
113
+ }
114
+ const result = ProviderTransform.options({
115
+ model: azureModel,
116
+ sessionID,
117
+ providerOptions: {},
118
+ })
119
+ expect(result.store).toBe(false)
120
+ })
121
+ })
122
+
123
+ describe("ProviderTransform.options - zai/zhipuai thinking", () => {
124
+ const sessionID = "test-session-123"
125
+
126
+ const createModel = (providerID: string) =>
127
+ ({
128
+ id: `${providerID}/glm-4.6`,
129
+ providerID,
130
+ api: {
131
+ id: "glm-4.6",
132
+ url: "https://open.bigmodel.cn/api/paas/v4",
133
+ npm: "@ai-sdk/openai-compatible",
134
+ },
135
+ name: "GLM 4.6",
136
+ capabilities: {
137
+ temperature: true,
138
+ reasoning: true,
139
+ attachment: true,
140
+ toolcall: true,
141
+ input: { text: true, audio: false, image: true, video: false, pdf: true },
142
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
143
+ interleaved: false,
144
+ },
145
+ cost: {
146
+ input: 0.001,
147
+ output: 0.002,
148
+ cache: { read: 0.0001, write: 0.0002 },
149
+ },
150
+ limit: {
151
+ context: 128000,
152
+ output: 8192,
153
+ },
154
+ status: "active",
155
+ options: {},
156
+ headers: {},
157
+ }) as any
158
+
159
+ for (const providerID of ["zai-coding-plan", "zai", "zhipuai-coding-plan", "zhipuai"]) {
160
+ test(`${providerID} should set thinking cfg`, () => {
161
+ const result = ProviderTransform.options({
162
+ model: createModel(providerID),
163
+ sessionID,
164
+ providerOptions: {},
165
+ })
166
+
167
+ expect(result.thinking).toEqual({
168
+ type: "enabled",
169
+ clear_thinking: false,
170
+ })
171
+ })
172
+ }
173
+ })
174
+
175
+ describe("ProviderTransform.options - google thinkingConfig gating", () => {
176
+ const sessionID = "test-session-123"
177
+
178
+ const createGoogleModel = (reasoning: boolean, npm: "@ai-sdk/google" | "@ai-sdk/google-vertex") =>
179
+ ({
180
+ id: `${npm === "@ai-sdk/google" ? "google" : "google-vertex"}/gemini-2.0-flash`,
181
+ providerID: npm === "@ai-sdk/google" ? "google" : "google-vertex",
182
+ api: {
183
+ id: "gemini-2.0-flash",
184
+ url: npm === "@ai-sdk/google" ? "https://generativelanguage.googleapis.com" : "https://vertexai.googleapis.com",
185
+ npm,
186
+ },
187
+ name: "Gemini 2.0 Flash",
188
+ capabilities: {
189
+ temperature: true,
190
+ reasoning,
191
+ attachment: true,
192
+ toolcall: true,
193
+ input: { text: true, audio: false, image: true, video: false, pdf: true },
194
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
195
+ interleaved: false,
196
+ },
197
+ cost: {
198
+ input: 0.001,
199
+ output: 0.002,
200
+ cache: { read: 0.0001, write: 0.0002 },
201
+ },
202
+ limit: {
203
+ context: 1_000_000,
204
+ output: 8192,
205
+ },
206
+ status: "active",
207
+ options: {},
208
+ headers: {},
209
+ }) as any
210
+
211
+ test("does not set thinkingConfig for google models without reasoning capability", () => {
212
+ const result = ProviderTransform.options({
213
+ model: createGoogleModel(false, "@ai-sdk/google"),
214
+ sessionID,
215
+ providerOptions: {},
216
+ })
217
+ expect(result.thinkingConfig).toBeUndefined()
218
+ })
219
+
220
+ test("sets thinkingConfig for google models with reasoning capability", () => {
221
+ const result = ProviderTransform.options({
222
+ model: createGoogleModel(true, "@ai-sdk/google"),
223
+ sessionID,
224
+ providerOptions: {},
225
+ })
226
+ expect(result.thinkingConfig).toEqual({
227
+ includeThoughts: true,
228
+ })
229
+ })
230
+
231
+ test("does not set thinkingConfig for vertex models without reasoning capability", () => {
232
+ const result = ProviderTransform.options({
233
+ model: createGoogleModel(false, "@ai-sdk/google-vertex"),
234
+ sessionID,
235
+ providerOptions: {},
236
+ })
237
+ expect(result.thinkingConfig).toBeUndefined()
238
+ })
239
+ })
240
+
241
+ describe("ProviderTransform.options - gpt-5 textVerbosity", () => {
242
+ const sessionID = "test-session-123"
243
+
244
+ const createGpt5Model = (apiId: string) =>
245
+ ({
246
+ id: `openai/${apiId}`,
247
+ providerID: "openai",
248
+ api: {
249
+ id: apiId,
250
+ url: "https://api.openai.com",
251
+ npm: "@ai-sdk/openai",
252
+ },
253
+ name: apiId,
254
+ capabilities: {
255
+ temperature: true,
256
+ reasoning: true,
257
+ attachment: true,
258
+ toolcall: true,
259
+ input: { text: true, audio: false, image: true, video: false, pdf: false },
260
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
261
+ interleaved: false,
262
+ },
263
+ cost: { input: 0.03, output: 0.06, cache: { read: 0.001, write: 0.002 } },
264
+ limit: { context: 128000, output: 4096 },
265
+ status: "active",
266
+ options: {},
267
+ headers: {},
268
+ }) as any
269
+
270
+ test("gpt-5.2 should have textVerbosity set to low", () => {
271
+ const model = createGpt5Model("gpt-5.2")
272
+ const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
273
+ expect(result.textVerbosity).toBe("low")
274
+ })
275
+
276
+ test("gpt-5.1 should have textVerbosity set to low", () => {
277
+ const model = createGpt5Model("gpt-5.1")
278
+ const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
279
+ expect(result.textVerbosity).toBe("low")
280
+ })
281
+
282
+ test("gpt-5.2-chat-latest should NOT have textVerbosity set (only supports medium)", () => {
283
+ const model = createGpt5Model("gpt-5.2-chat-latest")
284
+ const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
285
+ expect(result.textVerbosity).toBeUndefined()
286
+ })
287
+
288
+ test("gpt-5.1-chat-latest should NOT have textVerbosity set (only supports medium)", () => {
289
+ const model = createGpt5Model("gpt-5.1-chat-latest")
290
+ const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
291
+ expect(result.textVerbosity).toBeUndefined()
292
+ })
293
+
294
+ test("gpt-5.2-chat should NOT have textVerbosity set", () => {
295
+ const model = createGpt5Model("gpt-5.2-chat")
296
+ const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
297
+ expect(result.textVerbosity).toBeUndefined()
298
+ })
299
+
300
+ test("gpt-5-chat should NOT have textVerbosity set", () => {
301
+ const model = createGpt5Model("gpt-5-chat")
302
+ const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
303
+ expect(result.textVerbosity).toBeUndefined()
304
+ })
305
+
306
+ test("gpt-5.2-codex should NOT have textVerbosity set (codex models excluded)", () => {
307
+ const model = createGpt5Model("gpt-5.2-codex")
308
+ const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
309
+ expect(result.textVerbosity).toBeUndefined()
310
+ })
311
+ })
312
+
313
+ describe("ProviderTransform.options - gateway", () => {
314
+ const sessionID = "test-session-123"
315
+
316
+ const createModel = (id: string) =>
317
+ ({
318
+ id,
319
+ providerID: "vercel",
320
+ api: {
321
+ id,
322
+ url: "https://ai-gateway.vercel.sh/v3/ai",
323
+ npm: "@ai-sdk/gateway",
324
+ },
325
+ name: id,
326
+ capabilities: {
327
+ temperature: true,
328
+ reasoning: true,
329
+ attachment: true,
330
+ toolcall: true,
331
+ input: { text: true, audio: false, image: true, video: false, pdf: true },
332
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
333
+ interleaved: false,
334
+ },
335
+ cost: {
336
+ input: 0.001,
337
+ output: 0.002,
338
+ cache: { read: 0.0001, write: 0.0002 },
339
+ },
340
+ limit: {
341
+ context: 200_000,
342
+ output: 8192,
343
+ },
344
+ status: "active",
345
+ options: {},
346
+ headers: {},
347
+ release_date: "2024-01-01",
348
+ }) as any
349
+
350
+ test("puts gateway defaults under gateway key", () => {
351
+ const model = createModel("anthropic/claude-sonnet-4")
352
+ const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
353
+ expect(result).toEqual({
354
+ gateway: {
355
+ caching: "auto",
356
+ },
357
+ })
358
+ })
359
+ })
360
+
361
+ describe("ProviderTransform.providerOptions", () => {
362
+ const createModel = (overrides: Partial<any> = {}) =>
363
+ ({
364
+ id: "test/test-model",
365
+ providerID: "test",
366
+ api: {
367
+ id: "test-model",
368
+ url: "https://api.test.com",
369
+ npm: "@ai-sdk/openai",
370
+ },
371
+ name: "Test Model",
372
+ capabilities: {
373
+ temperature: true,
374
+ reasoning: true,
375
+ attachment: true,
376
+ toolcall: true,
377
+ input: { text: true, audio: false, image: true, video: false, pdf: false },
378
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
379
+ interleaved: false,
380
+ },
381
+ cost: {
382
+ input: 0.001,
383
+ output: 0.002,
384
+ cache: { read: 0.0001, write: 0.0002 },
385
+ },
386
+ limit: {
387
+ context: 200_000,
388
+ output: 64_000,
389
+ },
390
+ status: "active",
391
+ options: {},
392
+ headers: {},
393
+ release_date: "2024-01-01",
394
+ ...overrides,
395
+ }) as any
396
+
397
+ test("uses sdk key for non-gateway models", () => {
398
+ const model = createModel({
399
+ providerID: "my-bedrock",
400
+ api: {
401
+ id: "anthropic.claude-sonnet-4",
402
+ url: "https://bedrock.aws",
403
+ npm: "@ai-sdk/amazon-bedrock",
404
+ },
405
+ })
406
+
407
+ expect(ProviderTransform.providerOptions(model, { cachePoint: { type: "default" } })).toEqual({
408
+ bedrock: { cachePoint: { type: "default" } },
409
+ })
410
+ })
411
+
412
+ test("uses gateway model provider slug for gateway models", () => {
413
+ const model = createModel({
414
+ providerID: "vercel",
415
+ api: {
416
+ id: "anthropic/claude-sonnet-4",
417
+ url: "https://ai-gateway.vercel.sh/v3/ai",
418
+ npm: "@ai-sdk/gateway",
419
+ },
420
+ })
421
+
422
+ expect(ProviderTransform.providerOptions(model, { thinking: { type: "enabled", budgetTokens: 12_000 } })).toEqual({
423
+ anthropic: { thinking: { type: "enabled", budgetTokens: 12_000 } },
424
+ })
425
+ })
426
+
427
+ test("falls back to gateway key when gateway api id is unscoped", () => {
428
+ const model = createModel({
429
+ id: "anthropic/claude-sonnet-4",
430
+ providerID: "vercel",
431
+ api: {
432
+ id: "claude-sonnet-4",
433
+ url: "https://ai-gateway.vercel.sh/v3/ai",
434
+ npm: "@ai-sdk/gateway",
435
+ },
436
+ })
437
+
438
+ expect(ProviderTransform.providerOptions(model, { thinking: { type: "enabled", budgetTokens: 12_000 } })).toEqual({
439
+ gateway: { thinking: { type: "enabled", budgetTokens: 12_000 } },
440
+ })
441
+ })
442
+
443
+ test("splits gateway routing options from provider-specific options", () => {
444
+ const model = createModel({
445
+ providerID: "vercel",
446
+ api: {
447
+ id: "anthropic/claude-sonnet-4",
448
+ url: "https://ai-gateway.vercel.sh/v3/ai",
449
+ npm: "@ai-sdk/gateway",
450
+ },
451
+ })
452
+
453
+ expect(
454
+ ProviderTransform.providerOptions(model, {
455
+ gateway: { order: ["vertex", "anthropic"] },
456
+ thinking: { type: "enabled", budgetTokens: 12_000 },
457
+ }),
458
+ ).toEqual({
459
+ gateway: { order: ["vertex", "anthropic"] },
460
+ anthropic: { thinking: { type: "enabled", budgetTokens: 12_000 } },
461
+ } as any)
462
+ })
463
+
464
+ test("falls back to gateway key when model id has no provider slug", () => {
465
+ const model = createModel({
466
+ id: "claude-sonnet-4",
467
+ providerID: "vercel",
468
+ api: {
469
+ id: "claude-sonnet-4",
470
+ url: "https://ai-gateway.vercel.sh/v3/ai",
471
+ npm: "@ai-sdk/gateway",
472
+ },
473
+ })
474
+
475
+ expect(ProviderTransform.providerOptions(model, { reasoningEffort: "high" })).toEqual({
476
+ gateway: { reasoningEffort: "high" },
477
+ })
478
+ })
479
+
480
+ test("maps amazon slug to bedrock for provider options", () => {
481
+ const model = createModel({
482
+ providerID: "vercel",
483
+ api: {
484
+ id: "amazon/nova-2-lite",
485
+ url: "https://ai-gateway.vercel.sh/v3/ai",
486
+ npm: "@ai-sdk/gateway",
487
+ },
488
+ })
489
+
490
+ expect(ProviderTransform.providerOptions(model, { reasoningConfig: { type: "enabled" } })).toEqual({
491
+ bedrock: { reasoningConfig: { type: "enabled" } },
492
+ })
493
+ })
494
+
495
+ test("uses groq slug for groq models", () => {
496
+ const model = createModel({
497
+ providerID: "vercel",
498
+ api: {
499
+ id: "groq/llama-3.3-70b-versatile",
500
+ url: "https://ai-gateway.vercel.sh/v3/ai",
501
+ npm: "@ai-sdk/gateway",
502
+ },
503
+ })
504
+
505
+ expect(ProviderTransform.providerOptions(model, { reasoningFormat: "parsed" })).toEqual({
506
+ groq: { reasoningFormat: "parsed" },
507
+ })
508
+ })
509
+ })
510
+
511
+ describe("ProviderTransform.schema - gemini array items", () => {
512
+ test("adds missing items for array properties", () => {
513
+ const geminiModel = {
514
+ providerID: "google",
515
+ api: {
516
+ id: "gemini-3-pro",
517
+ },
518
+ } as any
519
+
520
+ const schema = {
521
+ type: "object",
522
+ properties: {
523
+ nodes: { type: "array" },
524
+ edges: { type: "array", items: { type: "string" } },
525
+ },
526
+ } as any
527
+
528
+ const result = ProviderTransform.schema(geminiModel, schema) as any
529
+
530
+ expect(result.properties.nodes.items).toBeDefined()
531
+ expect(result.properties.edges.items.type).toBe("string")
532
+ })
533
+ })
534
+
535
+ describe("ProviderTransform.schema - gemini nested array items", () => {
536
+ const geminiModel = {
537
+ providerID: "google",
538
+ api: {
539
+ id: "gemini-3-pro",
540
+ },
541
+ } as any
542
+
543
+ test("adds type to 2D array with empty inner items", () => {
544
+ const schema = {
545
+ type: "object",
546
+ properties: {
547
+ values: {
548
+ type: "array",
549
+ items: {
550
+ type: "array",
551
+ items: {}, // Empty items object
552
+ },
553
+ },
554
+ },
555
+ } as any
556
+
557
+ const result = ProviderTransform.schema(geminiModel, schema) as any
558
+
559
+ // Inner items should have a default type
560
+ expect(result.properties.values.items.items.type).toBe("string")
561
+ })
562
+
563
+ test("adds items and type to 2D array with missing inner items", () => {
564
+ const schema = {
565
+ type: "object",
566
+ properties: {
567
+ data: {
568
+ type: "array",
569
+ items: { type: "array" }, // No items at all
570
+ },
571
+ },
572
+ } as any
573
+
574
+ const result = ProviderTransform.schema(geminiModel, schema) as any
575
+
576
+ expect(result.properties.data.items.items).toBeDefined()
577
+ expect(result.properties.data.items.items.type).toBe("string")
578
+ })
579
+
580
+ test("handles deeply nested arrays (3D)", () => {
581
+ const schema = {
582
+ type: "object",
583
+ properties: {
584
+ matrix: {
585
+ type: "array",
586
+ items: {
587
+ type: "array",
588
+ items: {
589
+ type: "array",
590
+ // No items
591
+ },
592
+ },
593
+ },
594
+ },
595
+ } as any
596
+
597
+ const result = ProviderTransform.schema(geminiModel, schema) as any
598
+
599
+ expect(result.properties.matrix.items.items.items).toBeDefined()
600
+ expect(result.properties.matrix.items.items.items.type).toBe("string")
601
+ })
602
+
603
+ test("preserves existing item types in nested arrays", () => {
604
+ const schema = {
605
+ type: "object",
606
+ properties: {
607
+ numbers: {
608
+ type: "array",
609
+ items: {
610
+ type: "array",
611
+ items: { type: "number" }, // Has explicit type
612
+ },
613
+ },
614
+ },
615
+ } as any
616
+
617
+ const result = ProviderTransform.schema(geminiModel, schema) as any
618
+
619
+ // Should preserve the explicit type
620
+ expect(result.properties.numbers.items.items.type).toBe("number")
621
+ })
622
+
623
+ test("handles mixed nested structures with objects and arrays", () => {
624
+ const schema = {
625
+ type: "object",
626
+ properties: {
627
+ spreadsheetData: {
628
+ type: "object",
629
+ properties: {
630
+ rows: {
631
+ type: "array",
632
+ items: {
633
+ type: "array",
634
+ items: {}, // Empty items
635
+ },
636
+ },
637
+ },
638
+ },
639
+ },
640
+ } as any
641
+
642
+ const result = ProviderTransform.schema(geminiModel, schema) as any
643
+
644
+ expect(result.properties.spreadsheetData.properties.rows.items.items.type).toBe("string")
645
+ })
646
+ })
647
+
648
+ describe("ProviderTransform.schema - gemini combiner nodes", () => {
649
+ const geminiModel = {
650
+ providerID: "google",
651
+ api: {
652
+ id: "gemini-3-pro",
653
+ },
654
+ } as any
655
+
656
+ const walk = (node: any, cb: (node: any, path: (string | number)[]) => void, path: (string | number)[] = []) => {
657
+ if (node === null || typeof node !== "object") {
658
+ return
659
+ }
660
+ if (Array.isArray(node)) {
661
+ node.forEach((item, i) => walk(item, cb, [...path, i]))
662
+ return
663
+ }
664
+ cb(node, path)
665
+ Object.entries(node).forEach(([key, value]) => walk(value, cb, [...path, key]))
666
+ }
667
+
668
+ test("keeps edits.items.anyOf without adding type", () => {
669
+ const schema = {
670
+ type: "object",
671
+ properties: {
672
+ edits: {
673
+ type: "array",
674
+ items: {
675
+ anyOf: [
676
+ {
677
+ type: "object",
678
+ properties: {
679
+ old_string: { type: "string" },
680
+ new_string: { type: "string" },
681
+ },
682
+ required: ["old_string", "new_string"],
683
+ },
684
+ {
685
+ type: "object",
686
+ properties: {
687
+ old_string: { type: "string" },
688
+ new_string: { type: "string" },
689
+ replace_all: { type: "boolean" },
690
+ },
691
+ required: ["old_string", "new_string"],
692
+ },
693
+ ],
694
+ },
695
+ },
696
+ },
697
+ required: ["edits"],
698
+ } as any
699
+
700
+ const result = ProviderTransform.schema(geminiModel, schema) as any
701
+
702
+ expect(Array.isArray(result.properties.edits.items.anyOf)).toBe(true)
703
+ expect(result.properties.edits.items.type).toBeUndefined()
704
+ })
705
+
706
+ test("does not add sibling keys to combiner nodes during sanitize", () => {
707
+ const schema = {
708
+ type: "object",
709
+ properties: {
710
+ edits: {
711
+ type: "array",
712
+ items: {
713
+ anyOf: [{ type: "string" }, { type: "number" }],
714
+ },
715
+ },
716
+ value: {
717
+ oneOf: [{ type: "string" }, { type: "boolean" }],
718
+ },
719
+ meta: {
720
+ allOf: [
721
+ {
722
+ type: "object",
723
+ properties: { a: { type: "string" } },
724
+ },
725
+ {
726
+ type: "object",
727
+ properties: { b: { type: "string" } },
728
+ },
729
+ ],
730
+ },
731
+ },
732
+ } as any
733
+ const input = JSON.parse(JSON.stringify(schema))
734
+ const result = ProviderTransform.schema(geminiModel, schema) as any
735
+
736
+ walk(result, (node, path) => {
737
+ const hasCombiner = Array.isArray(node.anyOf) || Array.isArray(node.oneOf) || Array.isArray(node.allOf)
738
+ if (!hasCombiner) {
739
+ return
740
+ }
741
+ const before = path.reduce((acc: any, key) => acc?.[key], input)
742
+ const added = Object.keys(node).filter((key) => !(key in before))
743
+ expect(added).toEqual([])
744
+ })
745
+ })
746
+ })
747
+
748
+ describe("ProviderTransform.schema - gemini non-object properties removal", () => {
749
+ const geminiModel = {
750
+ providerID: "google",
751
+ api: {
752
+ id: "gemini-3-pro",
753
+ },
754
+ } as any
755
+
756
+ test("removes properties from non-object types", () => {
757
+ const schema = {
758
+ type: "object",
759
+ properties: {
760
+ data: {
761
+ type: "string",
762
+ properties: { invalid: { type: "string" } },
763
+ },
764
+ },
765
+ } as any
766
+
767
+ const result = ProviderTransform.schema(geminiModel, schema) as any
768
+
769
+ expect(result.properties.data.type).toBe("string")
770
+ expect(result.properties.data.properties).toBeUndefined()
771
+ })
772
+
773
+ test("removes required from non-object types", () => {
774
+ const schema = {
775
+ type: "object",
776
+ properties: {
777
+ data: {
778
+ type: "array",
779
+ items: { type: "string" },
780
+ required: ["invalid"],
781
+ },
782
+ },
783
+ } as any
784
+
785
+ const result = ProviderTransform.schema(geminiModel, schema) as any
786
+
787
+ expect(result.properties.data.type).toBe("array")
788
+ expect(result.properties.data.required).toBeUndefined()
789
+ })
790
+
791
+ test("removes properties and required from nested non-object types", () => {
792
+ const schema = {
793
+ type: "object",
794
+ properties: {
795
+ outer: {
796
+ type: "object",
797
+ properties: {
798
+ inner: {
799
+ type: "number",
800
+ properties: { bad: { type: "string" } },
801
+ required: ["bad"],
802
+ },
803
+ },
804
+ },
805
+ },
806
+ } as any
807
+
808
+ const result = ProviderTransform.schema(geminiModel, schema) as any
809
+
810
+ expect(result.properties.outer.properties.inner.type).toBe("number")
811
+ expect(result.properties.outer.properties.inner.properties).toBeUndefined()
812
+ expect(result.properties.outer.properties.inner.required).toBeUndefined()
813
+ })
814
+
815
+ test("keeps properties and required on object types", () => {
816
+ const schema = {
817
+ type: "object",
818
+ properties: {
819
+ data: {
820
+ type: "object",
821
+ properties: { name: { type: "string" } },
822
+ required: ["name"],
823
+ },
824
+ },
825
+ } as any
826
+
827
+ const result = ProviderTransform.schema(geminiModel, schema) as any
828
+
829
+ expect(result.properties.data.type).toBe("object")
830
+ expect(result.properties.data.properties).toBeDefined()
831
+ expect(result.properties.data.required).toEqual(["name"])
832
+ })
833
+
834
+ test("does not affect non-gemini providers", () => {
835
+ const openaiModel = {
836
+ providerID: "openai",
837
+ api: {
838
+ id: "gpt-4",
839
+ },
840
+ } as any
841
+
842
+ const schema = {
843
+ type: "object",
844
+ properties: {
845
+ data: {
846
+ type: "string",
847
+ properties: { invalid: { type: "string" } },
848
+ },
849
+ },
850
+ } as any
851
+
852
+ const result = ProviderTransform.schema(openaiModel, schema) as any
853
+
854
+ expect(result.properties.data.properties).toBeDefined()
855
+ })
856
+ })
857
+
858
+ describe("ProviderTransform.schema - moonshot $ref siblings", () => {
859
+ const moonshotModel = {
860
+ providerID: "moonshotai",
861
+ api: {
862
+ id: "kimi-k2",
863
+ },
864
+ } as any
865
+
866
+ test("removes sibling descriptions from referenced tool parameter schemas", () => {
867
+ const schema = {
868
+ type: "object",
869
+ properties: {
870
+ deviceType: {
871
+ description: "Optional. The type of device that captured the screenshot, e.g. mobile or desktop.",
872
+ enum: ["DEVICE_TYPE_UNSPECIFIED", "MOBILE", "DESKTOP", "TABLET", "AGNOSTIC"],
873
+ type: "string",
874
+ },
875
+ modelId: {
876
+ description: "Optional. The model to use for generation.",
877
+ enum: ["MODEL_ID_UNSPECIFIED", "GEMINI_3_PRO", "GEMINI_3_FLASH", "GEMINI_3_1_PRO"],
878
+ type: "string",
879
+ },
880
+ projectId: {
881
+ description: "Required. The project ID of screens to generate variants for.",
882
+ type: "string",
883
+ },
884
+ prompt: {
885
+ description: "Required. The input text used to generate the variants.",
886
+ type: "string",
887
+ },
888
+ selectedScreenIds: {
889
+ description: "Required. The screen ids of screen to generate variants for.",
890
+ items: {
891
+ type: "string",
892
+ },
893
+ type: "array",
894
+ },
895
+ variantOptions: {
896
+ $ref: "#/$defs/VariantOptions",
897
+ description:
898
+ "Required. The variant options for generation, including the number of variants, creative range, and aspects to focus on.",
899
+ },
900
+ },
901
+ required: ["projectId", "selectedScreenIds", "prompt", "variantOptions"],
902
+ $defs: {
903
+ VariantOptions: {
904
+ description:
905
+ "Configuration options for design variant generation. This message captures all parameters used to generate variants, allowing the configuration to be stored, replayed, or analyzed.",
906
+ properties: {
907
+ aspects: {
908
+ description: "Optional. Specific aspects to focus on. If empty, all aspects may be varied.",
909
+ items: {
910
+ enum: ["VARIANT_ASPECT_UNSPECIFIED", "LAYOUT", "COLOR_SCHEME", "IMAGES", "TEXT_FONT", "TEXT_CONTENT"],
911
+ type: "string",
912
+ },
913
+ type: "array",
914
+ },
915
+ creativeRange: {
916
+ description: "Optional. Creative range for variations. Default: EXPLORE",
917
+ enum: ["CREATIVE_RANGE_UNSPECIFIED", "REFINE", "EXPLORE", "REIMAGINE"],
918
+ type: "string",
919
+ },
920
+ variantCount: {
921
+ description: "Optional. Number of variants to generate (1-5). Default: 3",
922
+ format: "int32",
923
+ type: "integer",
924
+ },
925
+ },
926
+ type: "object",
927
+ },
928
+ },
929
+ description: "Request message for GenerateVariants.",
930
+ additionalProperties: false,
931
+ } as any
932
+
933
+ const result = ProviderTransform.schema(moonshotModel, schema) as any
934
+
935
+ expect(result.properties.variantOptions).toEqual({
936
+ $ref: "#/$defs/VariantOptions",
937
+ })
938
+ expect(result.$defs.VariantOptions.description).toBe(schema.$defs.VariantOptions.description)
939
+ })
940
+
941
+ test("also runs for kimi models outside the moonshot provider", () => {
942
+ const result = ProviderTransform.schema(
943
+ {
944
+ providerID: "openrouter",
945
+ name: "Kimi K2",
946
+ api: {
947
+ id: "moonshotai/kimi-k2",
948
+ },
949
+ } as any,
950
+ {
951
+ type: "object",
952
+ properties: {
953
+ value: {
954
+ $ref: "#/$defs/Value",
955
+ description: "Moonshot rejects this sibling after ref expansion.",
956
+ },
957
+ },
958
+ $defs: {
959
+ Value: {
960
+ description: "Referenced schema description stays here.",
961
+ type: "object",
962
+ },
963
+ },
964
+ } as any,
965
+ ) as any
966
+
967
+ expect(result.properties.value).toEqual({
968
+ $ref: "#/$defs/Value",
969
+ })
970
+ })
971
+
972
+ test("converts tuple-style array items to a single item schema", () => {
973
+ const result = ProviderTransform.schema(moonshotModel, {
974
+ type: "object",
975
+ properties: {
976
+ codeSpec: {
977
+ type: "object",
978
+ properties: {
979
+ accessibility: {
980
+ type: "object",
981
+ properties: {
982
+ renderedSize: {
983
+ description: "Rendered size [width, height] in px",
984
+ type: "array",
985
+ items: [{ type: "number" }, { type: "number" }],
986
+ minItems: 2,
987
+ maxItems: 2,
988
+ },
989
+ },
990
+ },
991
+ },
992
+ },
993
+ },
994
+ } as any) as any
995
+
996
+ expect(result.properties.codeSpec.properties.accessibility.properties.renderedSize.items).toEqual({
997
+ type: "number",
998
+ })
999
+ })
1000
+ })
1001
+
1002
+ describe("ProviderTransform.message - DeepSeek reasoning content", () => {
1003
+ test("DeepSeek with tool calls includes reasoning_content in providerOptions", () => {
1004
+ const msgs = [
1005
+ {
1006
+ role: "assistant",
1007
+ content: [
1008
+ { type: "reasoning", text: "Let me think about this..." },
1009
+ {
1010
+ type: "tool-call",
1011
+ toolCallId: "test",
1012
+ toolName: "bash",
1013
+ input: { command: "echo hello" },
1014
+ },
1015
+ ],
1016
+ },
1017
+ ] as any[]
1018
+
1019
+ const result = ProviderTransform.message(
1020
+ msgs,
1021
+ {
1022
+ id: ModelID.make("deepseek/deepseek-chat"),
1023
+ providerID: ProviderID.make("deepseek"),
1024
+ api: {
1025
+ id: "deepseek-chat",
1026
+ url: "https://api.deepseek.com",
1027
+ npm: "@ai-sdk/openai-compatible",
1028
+ },
1029
+ name: "DeepSeek Chat",
1030
+ capabilities: {
1031
+ temperature: true,
1032
+ reasoning: true,
1033
+ attachment: false,
1034
+ toolcall: true,
1035
+ input: { text: true, audio: false, image: false, video: false, pdf: false },
1036
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
1037
+ interleaved: {
1038
+ field: "reasoning_content",
1039
+ },
1040
+ },
1041
+ cost: {
1042
+ input: 0.001,
1043
+ output: 0.002,
1044
+ cache: { read: 0.0001, write: 0.0002 },
1045
+ },
1046
+ limit: {
1047
+ context: 128000,
1048
+ output: 8192,
1049
+ },
1050
+ status: "active",
1051
+ options: {},
1052
+ headers: {},
1053
+ release_date: "2023-04-01",
1054
+ },
1055
+ {},
1056
+ )
1057
+
1058
+ expect(result).toHaveLength(1)
1059
+ expect(result[0].content).toEqual([
1060
+ {
1061
+ type: "tool-call",
1062
+ toolCallId: "test",
1063
+ toolName: "bash",
1064
+ input: { command: "echo hello" },
1065
+ },
1066
+ ])
1067
+ expect(result[0].providerOptions?.openaiCompatible?.reasoning_content).toBe("Let me think about this...")
1068
+ })
1069
+
1070
+ test("Non-DeepSeek providers leave reasoning content unchanged", () => {
1071
+ const msgs = [
1072
+ {
1073
+ role: "assistant",
1074
+ content: [
1075
+ { type: "reasoning", text: "Should not be processed" },
1076
+ { type: "text", text: "Answer" },
1077
+ ],
1078
+ },
1079
+ ] as any[]
1080
+
1081
+ const result = ProviderTransform.message(
1082
+ msgs,
1083
+ {
1084
+ id: ModelID.make("openai/gpt-4"),
1085
+ providerID: ProviderID.make("openai"),
1086
+ api: {
1087
+ id: "gpt-4",
1088
+ url: "https://api.openai.com",
1089
+ npm: "@ai-sdk/openai",
1090
+ },
1091
+ name: "GPT-4",
1092
+ capabilities: {
1093
+ temperature: true,
1094
+ reasoning: false,
1095
+ attachment: true,
1096
+ toolcall: true,
1097
+ input: { text: true, audio: false, image: true, video: false, pdf: false },
1098
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
1099
+ interleaved: false,
1100
+ },
1101
+ cost: {
1102
+ input: 0.03,
1103
+ output: 0.06,
1104
+ cache: { read: 0.001, write: 0.002 },
1105
+ },
1106
+ limit: {
1107
+ context: 128000,
1108
+ output: 4096,
1109
+ },
1110
+ status: "active",
1111
+ options: {},
1112
+ headers: {},
1113
+ release_date: "2023-04-01",
1114
+ },
1115
+ {},
1116
+ )
1117
+
1118
+ expect(result[0].content).toEqual([
1119
+ { type: "reasoning", text: "Should not be processed" },
1120
+ { type: "text", text: "Answer" },
1121
+ ])
1122
+ expect(result[0].providerOptions?.openaiCompatible?.reasoning_content).toBeUndefined()
1123
+ })
1124
+ })
1125
+
1126
+ describe("ProviderTransform.message - empty image handling", () => {
1127
+ const mockModel = {
1128
+ id: "anthropic/claude-3-5-sonnet",
1129
+ providerID: "anthropic",
1130
+ api: {
1131
+ id: "claude-3-5-sonnet-20241022",
1132
+ url: "https://api.anthropic.com",
1133
+ npm: "@ai-sdk/anthropic",
1134
+ },
1135
+ name: "Claude 3.5 Sonnet",
1136
+ capabilities: {
1137
+ temperature: true,
1138
+ reasoning: false,
1139
+ attachment: true,
1140
+ toolcall: true,
1141
+ input: { text: true, audio: false, image: true, video: false, pdf: true },
1142
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
1143
+ interleaved: false,
1144
+ },
1145
+ cost: {
1146
+ input: 0.003,
1147
+ output: 0.015,
1148
+ cache: { read: 0.0003, write: 0.00375 },
1149
+ },
1150
+ limit: {
1151
+ context: 200000,
1152
+ output: 8192,
1153
+ },
1154
+ status: "active",
1155
+ options: {},
1156
+ headers: {},
1157
+ } as any
1158
+
1159
+ test("should replace empty base64 image with error text", () => {
1160
+ const msgs = [
1161
+ {
1162
+ role: "user",
1163
+ content: [
1164
+ { type: "text", text: "What is in this image?" },
1165
+ { type: "image", image: "data:image/png;base64," },
1166
+ ],
1167
+ },
1168
+ ] as any[]
1169
+
1170
+ const result = ProviderTransform.message(msgs, mockModel, {})
1171
+
1172
+ expect(result).toHaveLength(1)
1173
+ expect(result[0].content).toHaveLength(2)
1174
+ expect(result[0].content[0]).toEqual({ type: "text", text: "What is in this image?" })
1175
+ expect(result[0].content[1]).toEqual({
1176
+ type: "text",
1177
+ text: "ERROR: Image file is empty or corrupted. Please provide a valid image.",
1178
+ })
1179
+ })
1180
+
1181
+ test("should keep valid base64 images unchanged", () => {
1182
+ const validBase64 =
1183
+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
1184
+ const msgs = [
1185
+ {
1186
+ role: "user",
1187
+ content: [
1188
+ { type: "text", text: "What is in this image?" },
1189
+ { type: "image", image: `data:image/png;base64,${validBase64}` },
1190
+ ],
1191
+ },
1192
+ ] as any[]
1193
+
1194
+ const result = ProviderTransform.message(msgs, mockModel, {})
1195
+
1196
+ expect(result).toHaveLength(1)
1197
+ expect(result[0].content).toHaveLength(2)
1198
+ expect(result[0].content[0]).toEqual({ type: "text", text: "What is in this image?" })
1199
+ expect(result[0].content[1]).toEqual({ type: "image", image: `data:image/png;base64,${validBase64}` })
1200
+ })
1201
+
1202
+ test("should handle mixed valid and empty images", () => {
1203
+ const validBase64 =
1204
+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
1205
+ const msgs = [
1206
+ {
1207
+ role: "user",
1208
+ content: [
1209
+ { type: "text", text: "Compare these images" },
1210
+ { type: "image", image: `data:image/png;base64,${validBase64}` },
1211
+ { type: "image", image: "data:image/jpeg;base64," },
1212
+ ],
1213
+ },
1214
+ ] as any[]
1215
+
1216
+ const result = ProviderTransform.message(msgs, mockModel, {})
1217
+
1218
+ expect(result).toHaveLength(1)
1219
+ expect(result[0].content).toHaveLength(3)
1220
+ expect(result[0].content[0]).toEqual({ type: "text", text: "Compare these images" })
1221
+ expect(result[0].content[1]).toEqual({ type: "image", image: `data:image/png;base64,${validBase64}` })
1222
+ expect(result[0].content[2]).toEqual({
1223
+ type: "text",
1224
+ text: "ERROR: Image file is empty or corrupted. Please provide a valid image.",
1225
+ })
1226
+ })
1227
+ })
1228
+
1229
+ describe("ProviderTransform.message - anthropic empty content filtering", () => {
1230
+ const anthropicModel = {
1231
+ id: "anthropic/claude-3-5-sonnet",
1232
+ providerID: "anthropic",
1233
+ api: {
1234
+ id: "claude-3-5-sonnet-20241022",
1235
+ url: "https://api.anthropic.com",
1236
+ npm: "@ai-sdk/anthropic",
1237
+ },
1238
+ name: "Claude 3.5 Sonnet",
1239
+ capabilities: {
1240
+ temperature: true,
1241
+ reasoning: false,
1242
+ attachment: true,
1243
+ toolcall: true,
1244
+ input: { text: true, audio: false, image: true, video: false, pdf: true },
1245
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
1246
+ interleaved: false,
1247
+ },
1248
+ cost: {
1249
+ input: 0.003,
1250
+ output: 0.015,
1251
+ cache: { read: 0.0003, write: 0.00375 },
1252
+ },
1253
+ limit: {
1254
+ context: 200000,
1255
+ output: 8192,
1256
+ },
1257
+ status: "active",
1258
+ options: {},
1259
+ headers: {},
1260
+ } as any
1261
+
1262
+ test("filters out messages with empty string content", () => {
1263
+ const msgs = [
1264
+ { role: "user", content: "Hello" },
1265
+ { role: "assistant", content: "" },
1266
+ { role: "user", content: "World" },
1267
+ ] as any[]
1268
+
1269
+ const result = ProviderTransform.message(msgs, anthropicModel, {})
1270
+
1271
+ expect(result).toHaveLength(2)
1272
+ expect(result[0].content).toBe("Hello")
1273
+ expect(result[1].content).toBe("World")
1274
+ })
1275
+
1276
+ test("filters out empty text parts from array content", () => {
1277
+ const msgs = [
1278
+ {
1279
+ role: "assistant",
1280
+ content: [
1281
+ { type: "text", text: "" },
1282
+ { type: "text", text: "Hello" },
1283
+ { type: "text", text: "" },
1284
+ ],
1285
+ },
1286
+ ] as any[]
1287
+
1288
+ const result = ProviderTransform.message(msgs, anthropicModel, {})
1289
+
1290
+ expect(result).toHaveLength(1)
1291
+ expect(result[0].content).toHaveLength(1)
1292
+ expect(result[0].content[0]).toEqual({ type: "text", text: "Hello" })
1293
+ })
1294
+
1295
+ test("filters out empty reasoning parts from array content", () => {
1296
+ const msgs = [
1297
+ {
1298
+ role: "assistant",
1299
+ content: [
1300
+ { type: "reasoning", text: "" },
1301
+ { type: "text", text: "Answer" },
1302
+ { type: "reasoning", text: "" },
1303
+ ],
1304
+ },
1305
+ ] as any[]
1306
+
1307
+ const result = ProviderTransform.message(msgs, anthropicModel, {})
1308
+
1309
+ expect(result).toHaveLength(1)
1310
+ expect(result[0].content).toHaveLength(1)
1311
+ expect(result[0].content[0]).toEqual({ type: "text", text: "Answer" })
1312
+ })
1313
+
1314
+ test("removes entire message when all parts are empty", () => {
1315
+ const msgs = [
1316
+ { role: "user", content: "Hello" },
1317
+ {
1318
+ role: "assistant",
1319
+ content: [
1320
+ { type: "text", text: "" },
1321
+ { type: "reasoning", text: "" },
1322
+ ],
1323
+ },
1324
+ { role: "user", content: "World" },
1325
+ ] as any[]
1326
+
1327
+ const result = ProviderTransform.message(msgs, anthropicModel, {})
1328
+
1329
+ expect(result).toHaveLength(2)
1330
+ expect(result[0].content).toBe("Hello")
1331
+ expect(result[1].content).toBe("World")
1332
+ })
1333
+
1334
+ test("keeps non-text/reasoning parts even if text parts are empty", () => {
1335
+ const msgs = [
1336
+ {
1337
+ role: "assistant",
1338
+ content: [
1339
+ { type: "text", text: "" },
1340
+ { type: "tool-call", toolCallId: "123", toolName: "bash", input: { command: "ls" } },
1341
+ ],
1342
+ },
1343
+ ] as any[]
1344
+
1345
+ const result = ProviderTransform.message(msgs, anthropicModel, {})
1346
+
1347
+ expect(result).toHaveLength(1)
1348
+ expect(result[0].content).toHaveLength(1)
1349
+ expect(result[0].content[0]).toEqual({
1350
+ type: "tool-call",
1351
+ toolCallId: "123",
1352
+ toolName: "bash",
1353
+ input: { command: "ls" },
1354
+ })
1355
+ })
1356
+
1357
+ test("keeps messages with valid text alongside empty parts", () => {
1358
+ const msgs = [
1359
+ {
1360
+ role: "assistant",
1361
+ content: [
1362
+ { type: "reasoning", text: "Thinking..." },
1363
+ { type: "text", text: "" },
1364
+ { type: "text", text: "Result" },
1365
+ ],
1366
+ },
1367
+ ] as any[]
1368
+
1369
+ const result = ProviderTransform.message(msgs, anthropicModel, {})
1370
+
1371
+ expect(result).toHaveLength(1)
1372
+ expect(result[0].content).toHaveLength(2)
1373
+ expect(result[0].content[0]).toEqual({ type: "reasoning", text: "Thinking..." })
1374
+ expect(result[0].content[1]).toEqual({ type: "text", text: "Result" })
1375
+ })
1376
+
1377
+ test("filters empty content for bedrock provider", () => {
1378
+ const bedrockModel = {
1379
+ ...anthropicModel,
1380
+ id: "amazon-bedrock/anthropic.claude-opus-4-6",
1381
+ providerID: "amazon-bedrock",
1382
+ api: {
1383
+ id: "anthropic.claude-opus-4-6",
1384
+ url: "https://bedrock-runtime.us-east-1.amazonaws.com",
1385
+ npm: "@ai-sdk/amazon-bedrock",
1386
+ },
1387
+ }
1388
+
1389
+ const msgs = [
1390
+ { role: "user", content: "Hello" },
1391
+ { role: "assistant", content: "" },
1392
+ {
1393
+ role: "assistant",
1394
+ content: [
1395
+ { type: "text", text: "" },
1396
+ { type: "text", text: "Answer" },
1397
+ ],
1398
+ },
1399
+ ] as any[]
1400
+
1401
+ const result = ProviderTransform.message(msgs, bedrockModel, {})
1402
+
1403
+ expect(result).toHaveLength(2)
1404
+ expect(result[0].content).toBe("Hello")
1405
+ expect(result[1].content).toHaveLength(1)
1406
+ expect(result[1].content[0]).toEqual({ type: "text", text: "Answer" })
1407
+ })
1408
+
1409
+ test("does not filter for non-anthropic providers", () => {
1410
+ const openaiModel = {
1411
+ ...anthropicModel,
1412
+ providerID: "openai",
1413
+ api: {
1414
+ id: "gpt-4",
1415
+ url: "https://api.openai.com",
1416
+ npm: "@ai-sdk/openai",
1417
+ },
1418
+ }
1419
+
1420
+ const msgs = [
1421
+ { role: "assistant", content: "" },
1422
+ {
1423
+ role: "assistant",
1424
+ content: [{ type: "text", text: "" }],
1425
+ },
1426
+ ] as any[]
1427
+
1428
+ const result = ProviderTransform.message(msgs, openaiModel, {})
1429
+
1430
+ expect(result).toHaveLength(2)
1431
+ expect(result[0].content).toBe("")
1432
+ expect(result[1].content).toHaveLength(1)
1433
+ })
1434
+
1435
+ test("splits anthropic assistant messages when text trails tool calls", () => {
1436
+ const msgs = [
1437
+ {
1438
+ role: "user",
1439
+ content: [{ type: "text", text: "Check my home directory for PDFs" }],
1440
+ },
1441
+ {
1442
+ role: "assistant",
1443
+ content: [
1444
+ { type: "tool-call", toolCallId: "toolu_1", toolName: "read", input: { filePath: "/root" } },
1445
+ { type: "tool-call", toolCallId: "toolu_2", toolName: "glob", input: { pattern: "**/*.pdf" } },
1446
+ { type: "text", text: "I checked your home directory and looked for PDF files." },
1447
+ ],
1448
+ },
1449
+ {
1450
+ role: "tool",
1451
+ content: [
1452
+ { type: "tool-result", toolCallId: "toolu_1", toolName: "read", output: { type: "text", value: "ok" } },
1453
+ {
1454
+ type: "tool-result",
1455
+ toolCallId: "toolu_2",
1456
+ toolName: "glob",
1457
+ output: { type: "text", value: "No files found" },
1458
+ },
1459
+ ],
1460
+ },
1461
+ ] as any[]
1462
+
1463
+ const result = ProviderTransform.message(msgs, anthropicModel, {}) as any[]
1464
+
1465
+ expect(result).toHaveLength(4)
1466
+ expect(result[1]).toMatchObject({
1467
+ role: "assistant",
1468
+ content: [{ type: "text", text: "I checked your home directory and looked for PDF files." }],
1469
+ })
1470
+ expect(result[2]).toMatchObject({
1471
+ role: "assistant",
1472
+ content: [
1473
+ { type: "tool-call", toolCallId: "toolu_1", toolName: "read", input: { filePath: "/root" } },
1474
+ { type: "tool-call", toolCallId: "toolu_2", toolName: "glob", input: { pattern: "**/*.pdf" } },
1475
+ ],
1476
+ })
1477
+ })
1478
+
1479
+ test("leaves valid anthropic assistant tool ordering unchanged", () => {
1480
+ const msgs = [
1481
+ {
1482
+ role: "assistant",
1483
+ content: [
1484
+ { type: "text", text: "I checked your home directory and looked for PDF files." },
1485
+ { type: "tool-call", toolCallId: "toolu_1", toolName: "read", input: { filePath: "/root" } },
1486
+ { type: "tool-call", toolCallId: "toolu_2", toolName: "glob", input: { pattern: "**/*.pdf" } },
1487
+ ],
1488
+ },
1489
+ ] as any[]
1490
+
1491
+ const result = ProviderTransform.message(msgs, anthropicModel, {}) as any[]
1492
+
1493
+ expect(result).toHaveLength(1)
1494
+ expect(result[0].content).toMatchObject([
1495
+ { type: "text", text: "I checked your home directory and looked for PDF files." },
1496
+ { type: "tool-call", toolCallId: "toolu_1", toolName: "read", input: { filePath: "/root" } },
1497
+ { type: "tool-call", toolCallId: "toolu_2", toolName: "glob", input: { pattern: "**/*.pdf" } },
1498
+ ])
1499
+ })
1500
+
1501
+ test("splits vertex anthropic assistant messages when text trails tool calls", () => {
1502
+ const model = {
1503
+ ...anthropicModel,
1504
+ providerID: "google-vertex-anthropic",
1505
+ api: {
1506
+ id: "claude-sonnet-4@20250514",
1507
+ url: "https://us-central1-aiplatform.googleapis.com",
1508
+ npm: "@ai-sdk/google-vertex/anthropic",
1509
+ },
1510
+ }
1511
+
1512
+ const msgs = [
1513
+ {
1514
+ role: "assistant",
1515
+ content: [
1516
+ { type: "tool-call", toolCallId: "toolu_1", toolName: "read", input: { filePath: "/root" } },
1517
+ { type: "tool-call", toolCallId: "toolu_2", toolName: "glob", input: { pattern: "**/*.pdf" } },
1518
+ { type: "text", text: "I checked your home directory and looked for PDF files." },
1519
+ ],
1520
+ },
1521
+ ] as any[]
1522
+
1523
+ const result = ProviderTransform.message(msgs, model, {}) as any[]
1524
+
1525
+ expect(result).toHaveLength(2)
1526
+ expect(result[0]).toMatchObject({
1527
+ role: "assistant",
1528
+ content: [{ type: "text", text: "I checked your home directory and looked for PDF files." }],
1529
+ })
1530
+ expect(result[1]).toMatchObject({
1531
+ role: "assistant",
1532
+ content: [
1533
+ { type: "tool-call", toolCallId: "toolu_1", toolName: "read", input: { filePath: "/root" } },
1534
+ { type: "tool-call", toolCallId: "toolu_2", toolName: "glob", input: { pattern: "**/*.pdf" } },
1535
+ ],
1536
+ })
1537
+ })
1538
+ })
1539
+
1540
+ describe("ProviderTransform.message - strip openai metadata when store=false", () => {
1541
+ const openaiModel = {
1542
+ id: "openai/gpt-5",
1543
+ providerID: "openai",
1544
+ api: {
1545
+ id: "gpt-5",
1546
+ url: "https://api.openai.com",
1547
+ npm: "@ai-sdk/openai",
1548
+ },
1549
+ name: "GPT-5",
1550
+ capabilities: {
1551
+ temperature: true,
1552
+ reasoning: true,
1553
+ attachment: true,
1554
+ toolcall: true,
1555
+ input: { text: true, audio: false, image: true, video: false, pdf: false },
1556
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
1557
+ interleaved: false,
1558
+ },
1559
+ cost: { input: 0.03, output: 0.06, cache: { read: 0.001, write: 0.002 } },
1560
+ limit: { context: 128000, output: 4096 },
1561
+ status: "active",
1562
+ options: {},
1563
+ headers: {},
1564
+ } as any
1565
+
1566
+ test("preserves itemId and reasoningEncryptedContent when store=false", () => {
1567
+ const msgs = [
1568
+ {
1569
+ role: "assistant",
1570
+ content: [
1571
+ {
1572
+ type: "reasoning",
1573
+ text: "thinking...",
1574
+ providerOptions: {
1575
+ openai: {
1576
+ itemId: "rs_123",
1577
+ reasoningEncryptedContent: "encrypted",
1578
+ },
1579
+ },
1580
+ },
1581
+ {
1582
+ type: "text",
1583
+ text: "Hello",
1584
+ providerOptions: {
1585
+ openai: {
1586
+ itemId: "msg_456",
1587
+ },
1588
+ },
1589
+ },
1590
+ ],
1591
+ },
1592
+ ] as any[]
1593
+
1594
+ const result = ProviderTransform.message(msgs, openaiModel, { store: false }) as any[]
1595
+
1596
+ expect(result).toHaveLength(1)
1597
+ expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("rs_123")
1598
+ expect(result[0].content[1].providerOptions?.openai?.itemId).toBe("msg_456")
1599
+ })
1600
+
1601
+ test("preserves itemId and reasoningEncryptedContent when store=false even when not openai", () => {
1602
+ const zenModel = {
1603
+ ...openaiModel,
1604
+ providerID: "zen",
1605
+ }
1606
+ const msgs = [
1607
+ {
1608
+ role: "assistant",
1609
+ content: [
1610
+ {
1611
+ type: "reasoning",
1612
+ text: "thinking...",
1613
+ providerOptions: {
1614
+ openai: {
1615
+ itemId: "rs_123",
1616
+ reasoningEncryptedContent: "encrypted",
1617
+ },
1618
+ },
1619
+ },
1620
+ {
1621
+ type: "text",
1622
+ text: "Hello",
1623
+ providerOptions: {
1624
+ openai: {
1625
+ itemId: "msg_456",
1626
+ },
1627
+ },
1628
+ },
1629
+ ],
1630
+ },
1631
+ ] as any[]
1632
+
1633
+ const result = ProviderTransform.message(msgs, zenModel, { store: false }) as any[]
1634
+
1635
+ expect(result).toHaveLength(1)
1636
+ expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("rs_123")
1637
+ expect(result[0].content[1].providerOptions?.openai?.itemId).toBe("msg_456")
1638
+ })
1639
+
1640
+ test("preserves other openai options including itemId", () => {
1641
+ const msgs = [
1642
+ {
1643
+ role: "assistant",
1644
+ content: [
1645
+ {
1646
+ type: "text",
1647
+ text: "Hello",
1648
+ providerOptions: {
1649
+ openai: {
1650
+ itemId: "msg_123",
1651
+ otherOption: "value",
1652
+ },
1653
+ },
1654
+ },
1655
+ ],
1656
+ },
1657
+ ] as any[]
1658
+
1659
+ const result = ProviderTransform.message(msgs, openaiModel, { store: false }) as any[]
1660
+
1661
+ expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
1662
+ expect(result[0].content[0].providerOptions?.openai?.otherOption).toBe("value")
1663
+ })
1664
+
1665
+ test("preserves metadata for openai package when store is true", () => {
1666
+ const msgs = [
1667
+ {
1668
+ role: "assistant",
1669
+ content: [
1670
+ {
1671
+ type: "text",
1672
+ text: "Hello",
1673
+ providerOptions: {
1674
+ openai: {
1675
+ itemId: "msg_123",
1676
+ },
1677
+ },
1678
+ },
1679
+ ],
1680
+ },
1681
+ ] as any[]
1682
+
1683
+ // openai package preserves itemId regardless of store value
1684
+ const result = ProviderTransform.message(msgs, openaiModel, { store: true }) as any[]
1685
+
1686
+ expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
1687
+ })
1688
+
1689
+ test("preserves metadata for non-openai packages when store is false", () => {
1690
+ const anthropicModel = {
1691
+ ...openaiModel,
1692
+ providerID: "anthropic",
1693
+ api: {
1694
+ id: "claude-3",
1695
+ url: "https://api.anthropic.com",
1696
+ npm: "@ai-sdk/anthropic",
1697
+ },
1698
+ }
1699
+ const msgs = [
1700
+ {
1701
+ role: "assistant",
1702
+ content: [
1703
+ {
1704
+ type: "text",
1705
+ text: "Hello",
1706
+ providerOptions: {
1707
+ openai: {
1708
+ itemId: "msg_123",
1709
+ },
1710
+ },
1711
+ },
1712
+ ],
1713
+ },
1714
+ ] as any[]
1715
+
1716
+ // store=false preserves metadata for non-openai packages
1717
+ const result = ProviderTransform.message(msgs, anthropicModel, { store: false }) as any[]
1718
+
1719
+ expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
1720
+ })
1721
+
1722
+ test("preserves metadata using providerID key when store is false", () => {
1723
+ const saeeolModel = {
1724
+ ...openaiModel,
1725
+ providerID: "saeeol",
1726
+ api: {
1727
+ id: "saeeol-test",
1728
+ url: "https://api.saeeol.ai",
1729
+ npm: "@ai-sdk/openai-compatible",
1730
+ },
1731
+ }
1732
+ const msgs = [
1733
+ {
1734
+ role: "assistant",
1735
+ content: [
1736
+ {
1737
+ type: "text",
1738
+ text: "Hello",
1739
+ providerOptions: {
1740
+ saeeol: {
1741
+ itemId: "msg_123",
1742
+ otherOption: "value",
1743
+ },
1744
+ },
1745
+ },
1746
+ ],
1747
+ },
1748
+ ] as any[]
1749
+
1750
+ const result = ProviderTransform.message(msgs, saeeolModel, { store: false }) as any[]
1751
+
1752
+ expect(result[0].content[0].providerOptions?.saeeol?.itemId).toBe("msg_123")
1753
+ expect(result[0].content[0].providerOptions?.saeeol?.otherOption).toBe("value")
1754
+ })
1755
+
1756
+ test("preserves itemId across all providerOptions keys", () => {
1757
+ const saeeolModel = {
1758
+ ...openaiModel,
1759
+ providerID: "saeeol",
1760
+ api: {
1761
+ id: "saeeol-test",
1762
+ url: "https://api.saeeol.ai",
1763
+ npm: "@ai-sdk/openai-compatible",
1764
+ },
1765
+ }
1766
+ const msgs = [
1767
+ {
1768
+ role: "assistant",
1769
+ providerOptions: {
1770
+ openai: { itemId: "msg_root" },
1771
+ saeeol: { itemId: "msg_saeeol" },
1772
+ extra: { itemId: "msg_extra" },
1773
+ },
1774
+ content: [
1775
+ {
1776
+ type: "text",
1777
+ text: "Hello",
1778
+ providerOptions: {
1779
+ openai: { itemId: "msg_openai_part" },
1780
+ saeeol: { itemId: "msg_saeeol_part" },
1781
+ extra: { itemId: "msg_extra_part" },
1782
+ },
1783
+ },
1784
+ ],
1785
+ },
1786
+ ] as any[]
1787
+
1788
+ const result = ProviderTransform.message(msgs, saeeolModel, { store: false }) as any[]
1789
+
1790
+ expect(result[0].providerOptions?.openai?.itemId).toBe("msg_root")
1791
+ expect(result[0].providerOptions?.saeeol?.itemId).toBe("msg_saeeol")
1792
+ expect(result[0].providerOptions?.extra?.itemId).toBe("msg_extra")
1793
+ expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_openai_part")
1794
+ expect(result[0].content[0].providerOptions?.saeeol?.itemId).toBe("msg_saeeol_part")
1795
+ expect(result[0].content[0].providerOptions?.extra?.itemId).toBe("msg_extra_part")
1796
+ })
1797
+
1798
+ test("does not strip metadata for non-openai packages when store is not false", () => {
1799
+ const anthropicModel = {
1800
+ ...openaiModel,
1801
+ providerID: "anthropic",
1802
+ api: {
1803
+ id: "claude-3",
1804
+ url: "https://api.anthropic.com",
1805
+ npm: "@ai-sdk/anthropic",
1806
+ },
1807
+ }
1808
+ const msgs = [
1809
+ {
1810
+ role: "assistant",
1811
+ content: [
1812
+ {
1813
+ type: "text",
1814
+ text: "Hello",
1815
+ providerOptions: {
1816
+ openai: {
1817
+ itemId: "msg_123",
1818
+ },
1819
+ },
1820
+ },
1821
+ ],
1822
+ },
1823
+ ] as any[]
1824
+
1825
+ const result = ProviderTransform.message(msgs, anthropicModel, {}) as any[]
1826
+
1827
+ expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
1828
+ })
1829
+ })
1830
+
1831
+ describe("ProviderTransform.message - providerOptions key remapping", () => {
1832
+ const createModel = (providerID: string, npm: string) =>
1833
+ ({
1834
+ id: `${providerID}/test-model`,
1835
+ providerID,
1836
+ api: {
1837
+ id: "test-model",
1838
+ url: "https://api.test.com",
1839
+ npm,
1840
+ },
1841
+ name: "Test Model",
1842
+ capabilities: {
1843
+ temperature: true,
1844
+ reasoning: false,
1845
+ attachment: true,
1846
+ toolcall: true,
1847
+ input: { text: true, audio: false, image: true, video: false, pdf: true },
1848
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
1849
+ interleaved: false,
1850
+ },
1851
+ cost: { input: 0.001, output: 0.002, cache: { read: 0.0001, write: 0.0002 } },
1852
+ limit: { context: 128000, output: 8192 },
1853
+ status: "active",
1854
+ options: {},
1855
+ headers: {},
1856
+ }) as any
1857
+
1858
+ test("azure keeps 'azure' key and does not remap to 'openai'", () => {
1859
+ const model = createModel("azure", "@ai-sdk/azure")
1860
+ const msgs = [
1861
+ {
1862
+ role: "user",
1863
+ content: "Hello",
1864
+ providerOptions: {
1865
+ azure: { someOption: "value" },
1866
+ },
1867
+ },
1868
+ ] as any[]
1869
+
1870
+ const result = ProviderTransform.message(msgs, model, {})
1871
+
1872
+ expect(result[0].providerOptions?.azure).toEqual({ someOption: "value" })
1873
+ expect(result[0].providerOptions?.openai).toBeUndefined()
1874
+ })
1875
+
1876
+ test("azure cognitive services remaps providerID to 'azure' key", () => {
1877
+ const model = createModel("azure-cognitive-services", "@ai-sdk/azure")
1878
+ const msgs = [
1879
+ {
1880
+ role: "user",
1881
+ content: [
1882
+ {
1883
+ type: "text",
1884
+ text: "Hello",
1885
+ providerOptions: {
1886
+ "azure-cognitive-services": { part: true },
1887
+ },
1888
+ },
1889
+ ],
1890
+ providerOptions: {
1891
+ "azure-cognitive-services": { someOption: "value" },
1892
+ },
1893
+ },
1894
+ ] as any[]
1895
+
1896
+ const result = ProviderTransform.message(msgs, model, {}) as any[]
1897
+ const part = result[0].content[0] as any
1898
+
1899
+ expect(result[0].providerOptions?.azure).toEqual({ someOption: "value" })
1900
+ expect(result[0].providerOptions?.["azure-cognitive-services"]).toBeUndefined()
1901
+ expect(part.providerOptions?.azure).toEqual({ part: true })
1902
+ expect(part.providerOptions?.["azure-cognitive-services"]).toBeUndefined()
1903
+ })
1904
+
1905
+ test("copilot remaps providerID to 'copilot' key", () => {
1906
+ const model = createModel("github-copilot", "@ai-sdk/github-copilot")
1907
+ const msgs = [
1908
+ {
1909
+ role: "user",
1910
+ content: "Hello",
1911
+ providerOptions: {
1912
+ copilot: { someOption: "value" },
1913
+ },
1914
+ },
1915
+ ] as any[]
1916
+
1917
+ const result = ProviderTransform.message(msgs, model, {})
1918
+
1919
+ expect(result[0].providerOptions?.copilot).toEqual({ someOption: "value" })
1920
+ expect(result[0].providerOptions?.["github-copilot"]).toBeUndefined()
1921
+ })
1922
+
1923
+ test("bedrock remaps providerID to 'bedrock' key", () => {
1924
+ const model = createModel("my-bedrock", "@ai-sdk/amazon-bedrock")
1925
+ const msgs = [
1926
+ {
1927
+ role: "user",
1928
+ content: "Hello",
1929
+ providerOptions: {
1930
+ "my-bedrock": { someOption: "value" },
1931
+ },
1932
+ },
1933
+ ] as any[]
1934
+
1935
+ const result = ProviderTransform.message(msgs, model, {})
1936
+
1937
+ expect(result[0].providerOptions?.bedrock).toEqual({ someOption: "value" })
1938
+ expect(result[0].providerOptions?.["my-bedrock"]).toBeUndefined()
1939
+ })
1940
+ })
1941
+
1942
+ describe("ProviderTransform.message - claude w/bedrock custom inference profile", () => {
1943
+ test("adds cachePoint", () => {
1944
+ const model = {
1945
+ id: "amazon-bedrock/custom-claude-sonnet-4.5",
1946
+ providerID: "amazon-bedrock",
1947
+ api: {
1948
+ id: "arn:aws:bedrock:xxx:yyy:application-inference-profile/zzz",
1949
+ url: "https://api.test.com",
1950
+ npm: "@ai-sdk/amazon-bedrock",
1951
+ },
1952
+ name: "Custom inference profile",
1953
+ capabilities: {},
1954
+ options: {},
1955
+ headers: {},
1956
+ } as any
1957
+
1958
+ const msgs = [
1959
+ {
1960
+ role: "user",
1961
+ content: "Hello",
1962
+ },
1963
+ ] as any[]
1964
+
1965
+ const result = ProviderTransform.message(msgs, model, {})
1966
+
1967
+ expect(result[0].providerOptions?.bedrock).toEqual(
1968
+ expect.objectContaining({
1969
+ cachePoint: {
1970
+ type: "default",
1971
+ },
1972
+ }),
1973
+ )
1974
+ })
1975
+ })
1976
+
1977
+ describe("ProviderTransform.message - bedrock caching with non-bedrock providerID", () => {
1978
+ test("applies cache options at message level when npm package is amazon-bedrock", () => {
1979
+ const model = {
1980
+ id: "aws/us.anthropic.claude-opus-4-6-v1",
1981
+ providerID: "aws",
1982
+ api: {
1983
+ id: "us.anthropic.claude-opus-4-6-v1",
1984
+ url: "https://bedrock-runtime.us-east-1.amazonaws.com",
1985
+ npm: "@ai-sdk/amazon-bedrock",
1986
+ },
1987
+ name: "Claude Opus 4.6",
1988
+ capabilities: {},
1989
+ options: {},
1990
+ headers: {},
1991
+ } as any
1992
+
1993
+ const msgs = [
1994
+ {
1995
+ role: "system",
1996
+ content: [{ type: "text", text: "You are a helpful assistant" }],
1997
+ },
1998
+ {
1999
+ role: "user",
2000
+ content: [{ type: "text", text: "Hello" }],
2001
+ },
2002
+ ] as any[]
2003
+
2004
+ const result = ProviderTransform.message(msgs, model, {}) as any[]
2005
+
2006
+ // Cache should be at the message level and not the content-part level
2007
+ expect(result[0].providerOptions?.bedrock).toEqual({
2008
+ cachePoint: { type: "default" },
2009
+ })
2010
+ expect(result[0].content[0].providerOptions?.bedrock).toBeUndefined()
2011
+ })
2012
+ })
2013
+
2014
+ describe("ProviderTransform.message - cache control on gateway", () => {
2015
+ const createModel = (overrides: Partial<any> = {}) =>
2016
+ ({
2017
+ id: "anthropic/claude-sonnet-4",
2018
+ providerID: "vercel",
2019
+ api: {
2020
+ id: "anthropic/claude-sonnet-4",
2021
+ url: "https://ai-gateway.vercel.sh/v3/ai",
2022
+ npm: "@ai-sdk/gateway",
2023
+ },
2024
+ name: "Claude Sonnet 4",
2025
+ capabilities: {
2026
+ temperature: true,
2027
+ reasoning: true,
2028
+ attachment: true,
2029
+ toolcall: true,
2030
+ input: { text: true, audio: false, image: true, video: false, pdf: true },
2031
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
2032
+ interleaved: false,
2033
+ },
2034
+ cost: { input: 0.001, output: 0.002, cache: { read: 0.0001, write: 0.0002 } },
2035
+ limit: { context: 200_000, output: 8192 },
2036
+ status: "active",
2037
+ options: {},
2038
+ headers: {},
2039
+ ...overrides,
2040
+ }) as any
2041
+
2042
+ test("gateway does not set cache control for anthropic models", () => {
2043
+ const model = createModel()
2044
+ const msgs = [
2045
+ {
2046
+ role: "system",
2047
+ content: [{ type: "text", text: "You are a helpful assistant" }],
2048
+ },
2049
+ {
2050
+ role: "user",
2051
+ content: "Hello",
2052
+ },
2053
+ ] as any[]
2054
+
2055
+ const result = ProviderTransform.message(msgs, model, {}) as any[]
2056
+
2057
+ expect(result[0].content[0].providerOptions).toBeUndefined()
2058
+ expect(result[0].providerOptions).toBeUndefined()
2059
+ })
2060
+
2061
+ test("non-gateway anthropic keeps existing cache control behavior", () => {
2062
+ const model = createModel({
2063
+ providerID: "anthropic",
2064
+ api: {
2065
+ id: "claude-sonnet-4",
2066
+ url: "https://api.anthropic.com",
2067
+ npm: "@ai-sdk/anthropic",
2068
+ },
2069
+ })
2070
+ const msgs = [
2071
+ {
2072
+ role: "system",
2073
+ content: "You are a helpful assistant",
2074
+ },
2075
+ {
2076
+ role: "user",
2077
+ content: "Hello",
2078
+ },
2079
+ ] as any[]
2080
+
2081
+ const result = ProviderTransform.message(msgs, model, {}) as any[]
2082
+
2083
+ expect(result[0].providerOptions).toEqual({
2084
+ anthropic: {
2085
+ cacheControl: {
2086
+ type: "ephemeral",
2087
+ },
2088
+ },
2089
+ openrouter: {
2090
+ cacheControl: {
2091
+ type: "ephemeral",
2092
+ },
2093
+ },
2094
+ bedrock: {
2095
+ cachePoint: {
2096
+ type: "default",
2097
+ },
2098
+ },
2099
+ openaiCompatible: {
2100
+ cache_control: {
2101
+ type: "ephemeral",
2102
+ },
2103
+ },
2104
+ copilot: {
2105
+ copilot_cache_control: {
2106
+ type: "ephemeral",
2107
+ },
2108
+ },
2109
+ alibaba: {
2110
+ cacheControl: {
2111
+ type: "ephemeral",
2112
+ },
2113
+ },
2114
+ })
2115
+ })
2116
+
2117
+ test("google-vertex-anthropic applies cache control", () => {
2118
+ const model = createModel({
2119
+ providerID: "google-vertex-anthropic",
2120
+ api: {
2121
+ id: "google-vertex-anthropic",
2122
+ url: "https://us-central1-aiplatform.googleapis.com",
2123
+ npm: "@ai-sdk/google-vertex/anthropic",
2124
+ },
2125
+ id: "claude-sonnet-4@20250514",
2126
+ })
2127
+ const msgs = [
2128
+ {
2129
+ role: "system",
2130
+ content: "You are a helpful assistant",
2131
+ },
2132
+ {
2133
+ role: "user",
2134
+ content: "Hello",
2135
+ },
2136
+ ] as any[]
2137
+
2138
+ const result = ProviderTransform.message(msgs, model, {}) as any[]
2139
+
2140
+ expect(result[0].providerOptions).toEqual({
2141
+ anthropic: {
2142
+ cacheControl: {
2143
+ type: "ephemeral",
2144
+ },
2145
+ },
2146
+ openrouter: {
2147
+ cacheControl: {
2148
+ type: "ephemeral",
2149
+ },
2150
+ },
2151
+ bedrock: {
2152
+ cachePoint: {
2153
+ type: "default",
2154
+ },
2155
+ },
2156
+ openaiCompatible: {
2157
+ cache_control: {
2158
+ type: "ephemeral",
2159
+ },
2160
+ },
2161
+ copilot: {
2162
+ copilot_cache_control: {
2163
+ type: "ephemeral",
2164
+ },
2165
+ },
2166
+ alibaba: {
2167
+ cacheControl: {
2168
+ type: "ephemeral",
2169
+ },
2170
+ },
2171
+ })
2172
+ })
2173
+ })
2174
+
2175
+ describe("ProviderTransform.variants", () => {
2176
+ const createMockModel = (overrides: Partial<any> = {}): any => ({
2177
+ id: "test/test-model",
2178
+ providerID: "test",
2179
+ api: {
2180
+ id: "test-model",
2181
+ url: "https://api.test.com",
2182
+ npm: "@ai-sdk/openai",
2183
+ },
2184
+ name: "Test Model",
2185
+ capabilities: {
2186
+ temperature: true,
2187
+ reasoning: true,
2188
+ attachment: true,
2189
+ toolcall: true,
2190
+ input: { text: true, audio: false, image: true, video: false, pdf: false },
2191
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
2192
+ interleaved: false,
2193
+ },
2194
+ cost: {
2195
+ input: 0.001,
2196
+ output: 0.002,
2197
+ cache: { read: 0.0001, write: 0.0002 },
2198
+ },
2199
+ limit: {
2200
+ context: 200_000,
2201
+ output: 64_000,
2202
+ },
2203
+ status: "active",
2204
+ options: {},
2205
+ headers: {},
2206
+ release_date: "2024-01-01",
2207
+ ...overrides,
2208
+ })
2209
+
2210
+ test("returns empty object when model has no reasoning capabilities", () => {
2211
+ const model = createMockModel({
2212
+ capabilities: { reasoning: false },
2213
+ })
2214
+ const result = ProviderTransform.variants(model)
2215
+ expect(result).toEqual({})
2216
+ })
2217
+
2218
+ test("deepseek returns empty object", () => {
2219
+ const model = createMockModel({
2220
+ id: "deepseek/deepseek-chat",
2221
+ providerID: "deepseek",
2222
+ api: {
2223
+ id: "deepseek-chat",
2224
+ url: "https://api.deepseek.com",
2225
+ npm: "@ai-sdk/openai-compatible",
2226
+ },
2227
+ })
2228
+ const result = ProviderTransform.variants(model)
2229
+ expect(result).toEqual({})
2230
+ })
2231
+
2232
+ test("minimax returns empty object", () => {
2233
+ const model = createMockModel({
2234
+ id: "minimax/minimax-model",
2235
+ providerID: "minimax",
2236
+ api: {
2237
+ id: "minimax-model",
2238
+ url: "https://api.minimax.com",
2239
+ npm: "@ai-sdk/openai-compatible",
2240
+ },
2241
+ })
2242
+ const result = ProviderTransform.variants(model)
2243
+ expect(result).toEqual({})
2244
+ })
2245
+
2246
+ test("glm returns empty object", () => {
2247
+ const model = createMockModel({
2248
+ id: "glm/glm-4",
2249
+ providerID: "glm",
2250
+ api: {
2251
+ id: "glm-4",
2252
+ url: "https://api.glm.com",
2253
+ npm: "@ai-sdk/openai-compatible",
2254
+ },
2255
+ })
2256
+ const result = ProviderTransform.variants(model)
2257
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2258
+ expect(result.low).toEqual({ reasoningEffort: "low" })
2259
+ })
2260
+
2261
+ test("mistral models with reasoning support return variants", () => {
2262
+ const model = createMockModel({
2263
+ id: "mistral/mistral-small-latest",
2264
+ providerID: "mistral",
2265
+ api: {
2266
+ id: "mistral-small-latest",
2267
+ url: "https://api.mistral.com",
2268
+ npm: "@ai-sdk/mistral",
2269
+ },
2270
+ capabilities: { reasoning: true },
2271
+ })
2272
+ const result = ProviderTransform.variants(model)
2273
+ expect(result).toEqual({
2274
+ high: { reasoningEffort: "high" },
2275
+ })
2276
+ })
2277
+
2278
+ test("mistral-medium-3.5 with reasoning returns variants", () => {
2279
+ const model = createMockModel({
2280
+ id: "mistral/mistral-medium-3.5",
2281
+ providerID: "mistral",
2282
+ api: {
2283
+ id: "mistral-medium-3.5",
2284
+ url: "https://api.mistral.com",
2285
+ npm: "@ai-sdk/mistral",
2286
+ },
2287
+ capabilities: { reasoning: true },
2288
+ })
2289
+ const result = ProviderTransform.variants(model)
2290
+ expect(result).toEqual({
2291
+ high: { reasoningEffort: "high" },
2292
+ })
2293
+ })
2294
+
2295
+ test("mistral without reasoning returns empty object", () => {
2296
+ const model = createMockModel({
2297
+ id: "mistral/mistral-large",
2298
+ providerID: "mistral",
2299
+ api: {
2300
+ id: "mistral-large-latest",
2301
+ url: "https://api.mistral.com",
2302
+ npm: "@ai-sdk/mistral",
2303
+ },
2304
+ capabilities: { reasoning: false },
2305
+ })
2306
+ const result = ProviderTransform.variants(model)
2307
+ expect(result).toEqual({})
2308
+ })
2309
+
2310
+ test("mistral large with reasoning returns empty object (only small supports reasoning)", () => {
2311
+ const model = createMockModel({
2312
+ id: "mistral/mistral-large",
2313
+ providerID: "mistral",
2314
+ api: {
2315
+ id: "mistral-large-latest",
2316
+ url: "https://api.mistral.com",
2317
+ npm: "@ai-sdk/mistral",
2318
+ },
2319
+ capabilities: { reasoning: true },
2320
+ })
2321
+ const result = ProviderTransform.variants(model)
2322
+ expect(result).toEqual({})
2323
+ })
2324
+
2325
+ describe("@openrouter/ai-sdk-provider", () => {
2326
+ test("returns empty object for non-qualifying models", () => {
2327
+ const model = createMockModel({
2328
+ id: "openrouter/test-model",
2329
+ providerID: "openrouter",
2330
+ api: {
2331
+ id: "test-model",
2332
+ url: "https://openrouter.ai",
2333
+ npm: "@openrouter/ai-sdk-provider",
2334
+ },
2335
+ })
2336
+ const result = ProviderTransform.variants(model)
2337
+ expect(result).toEqual({})
2338
+ })
2339
+
2340
+ test("gpt models return OPENAI_EFFORTS with reasoning", () => {
2341
+ const model = createMockModel({
2342
+ id: "openrouter/gpt-4",
2343
+ providerID: "openrouter",
2344
+ api: {
2345
+ id: "gpt-4",
2346
+ url: "https://openrouter.ai",
2347
+ npm: "@openrouter/ai-sdk-provider",
2348
+ },
2349
+ })
2350
+ const result = ProviderTransform.variants(model)
2351
+ expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
2352
+ expect(result.low).toEqual({ reasoning: { effort: "low" } })
2353
+ expect(result.high).toEqual({ reasoning: { effort: "high" } })
2354
+ })
2355
+
2356
+ test("gemini-3 returns OPENAI_EFFORTS with reasoning", () => {
2357
+ const model = createMockModel({
2358
+ id: "openrouter/gemini-3-5-pro",
2359
+ providerID: "openrouter",
2360
+ api: {
2361
+ id: "gemini-3-5-pro",
2362
+ url: "https://openrouter.ai",
2363
+ npm: "@openrouter/ai-sdk-provider",
2364
+ },
2365
+ })
2366
+ const result = ProviderTransform.variants(model)
2367
+ expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
2368
+ })
2369
+ test("mercury-2 returns OPENAI_EFFORTS with reasoning", () => {
2370
+ const model = createMockModel({
2371
+ id: "openrouter/inception/mercury-2",
2372
+ providerID: "openrouter",
2373
+ api: {
2374
+ id: "inception/mercury-2",
2375
+ url: "https://openrouter.ai",
2376
+ npm: "@openrouter/ai-sdk-provider",
2377
+ },
2378
+ })
2379
+ const result = ProviderTransform.variants(model)
2380
+ expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
2381
+ expect(result.low).toEqual({ reasoning: { effort: "low" } })
2382
+ expect(result.high).toEqual({ reasoning: { effort: "high" } })
2383
+ })
2384
+
2385
+ test("grok-4 returns empty object", () => {
2386
+ const model = createMockModel({
2387
+ id: "openrouter/grok-4",
2388
+ providerID: "openrouter",
2389
+ api: {
2390
+ id: "grok-4",
2391
+ url: "https://openrouter.ai",
2392
+ npm: "@openrouter/ai-sdk-provider",
2393
+ },
2394
+ })
2395
+ const result = ProviderTransform.variants(model)
2396
+ expect(result).toEqual({})
2397
+ })
2398
+
2399
+ test("grok-3-mini returns low and high with reasoning", () => {
2400
+ const model = createMockModel({
2401
+ id: "openrouter/grok-3-mini",
2402
+ providerID: "openrouter",
2403
+ api: {
2404
+ id: "grok-3-mini",
2405
+ url: "https://openrouter.ai",
2406
+ npm: "@openrouter/ai-sdk-provider",
2407
+ },
2408
+ })
2409
+ const result = ProviderTransform.variants(model)
2410
+ expect(Object.keys(result)).toEqual(["low", "high"])
2411
+ expect(result.low).toEqual({ reasoning: { effort: "low" } })
2412
+ expect(result.high).toEqual({ reasoning: { effort: "high" } })
2413
+ })
2414
+ })
2415
+ describe("@saeeol/gateway", () => {
2416
+ test("claude models return empty variants (reasoning disabled)", () => {
2417
+ const model = createMockModel({
2418
+ id: "saeeol/anthropic/claude-sonnet-4",
2419
+ providerID: "saeeol",
2420
+ capabilities: { reasoning: false },
2421
+ api: {
2422
+ id: "anthropic/claude-sonnet-4",
2423
+ url: "https://gateway.saeeol.ai",
2424
+ npm: "@saeeol/gateway",
2425
+ },
2426
+ })
2427
+ const result = ProviderTransform.variants(model)
2428
+ expect(Object.keys(result)).toEqual([])
2429
+ })
2430
+
2431
+ test("anthropic models in api.id return empty variants (reasoning disabled)", () => {
2432
+ const model = createMockModel({
2433
+ id: "saeeol/anthropic/claude-opus-4",
2434
+ providerID: "saeeol",
2435
+ capabilities: { reasoning: false },
2436
+ api: {
2437
+ id: "anthropic/claude-opus-4",
2438
+ url: "https://gateway.saeeol.ai",
2439
+ npm: "@saeeol/gateway",
2440
+ },
2441
+ })
2442
+ const result = ProviderTransform.variants(model)
2443
+ expect(Object.keys(result)).toEqual([])
2444
+ })
2445
+
2446
+ test("gpt models return OPENAI_EFFORTS with reasoning", () => {
2447
+ const model = createMockModel({
2448
+ id: "saeeol/openai/gpt-5",
2449
+ providerID: "saeeol",
2450
+ api: {
2451
+ id: "openai/gpt-5",
2452
+ url: "https://gateway.saeeol.ai",
2453
+ npm: "@saeeol/gateway",
2454
+ },
2455
+ })
2456
+ const result = ProviderTransform.variants(model)
2457
+ expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
2458
+ expect(result.low).toEqual({ reasoning: { effort: "low" } })
2459
+ })
2460
+
2461
+ test("gemini-3 models return OPENAI_EFFORTS with reasoning and encrypted content", () => {
2462
+ const model = createMockModel({
2463
+ id: "saeeol/google/gemini-3-pro",
2464
+ providerID: "saeeol",
2465
+ api: {
2466
+ id: "google/gemini-3-pro",
2467
+ url: "https://gateway.saeeol.ai",
2468
+ npm: "@saeeol/gateway",
2469
+ },
2470
+ })
2471
+ const result = ProviderTransform.variants(model)
2472
+ expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
2473
+ })
2474
+
2475
+ test("non-qualifying models return empty object", () => {
2476
+ const model = createMockModel({
2477
+ id: "saeeol/meta/llama-4",
2478
+ providerID: "saeeol",
2479
+ api: {
2480
+ id: "meta/llama-4",
2481
+ url: "https://gateway.saeeol.ai",
2482
+ npm: "@saeeol/gateway",
2483
+ },
2484
+ })
2485
+ const result = ProviderTransform.variants(model)
2486
+ expect(result).toEqual({})
2487
+ })
2488
+
2489
+ test("grok-3-mini returns low and high with reasoning", () => {
2490
+ const model = createMockModel({
2491
+ id: "saeeol/x-ai/grok-3-mini",
2492
+ providerID: "saeeol",
2493
+ api: {
2494
+ id: "x-ai/grok-3-mini",
2495
+ url: "https://gateway.saeeol.ai",
2496
+ npm: "@saeeol/gateway",
2497
+ },
2498
+ })
2499
+ const result = ProviderTransform.variants(model)
2500
+ expect(Object.keys(result)).toEqual(["low", "high"])
2501
+ expect(result.low).toEqual({ reasoning: { effort: "low" } })
2502
+ expect(result.high).toEqual({ reasoning: { effort: "high" } })
2503
+ })
2504
+
2505
+ test("codex models return OPENAI_EFFORTS with object-based reasoning format", () => {
2506
+ const model = createMockModel({
2507
+ id: "saeeol/openai/gpt-5.2-codex",
2508
+ providerID: "saeeol",
2509
+ api: {
2510
+ id: "openai/gpt-5.2-codex",
2511
+ url: "https://gateway.saeeol.ai",
2512
+ npm: "@saeeol/gateway",
2513
+ },
2514
+ })
2515
+ const result = ProviderTransform.variants(model)
2516
+ expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
2517
+ expect(result.low).toEqual({ reasoning: { effort: "low" } })
2518
+ expect(result.high).toEqual({ reasoning: { effort: "high" } })
2519
+ expect(result.xhigh).toEqual({ reasoning: { effort: "xhigh" } })
2520
+ })
2521
+ test("mercury-2 uses server-provided variants from saeeol gateway", () => {
2522
+ const serverVariants = {
2523
+ low: { reasoningEffort: "low" },
2524
+ medium: { reasoningEffort: "medium" },
2525
+ high: { reasoningEffort: "high" },
2526
+ }
2527
+ const model = createMockModel({
2528
+ id: "saeeol/inception/mercury-2",
2529
+ providerID: "saeeol",
2530
+ api: {
2531
+ id: "inception/mercury-2",
2532
+ url: "https://gateway.saeeol.ai",
2533
+ npm: "@saeeol/gateway",
2534
+ },
2535
+ variants: serverVariants,
2536
+ })
2537
+ const result = ProviderTransform.variants(model)
2538
+ expect(result).toEqual(serverVariants)
2539
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2540
+ })
2541
+ })
2542
+
2543
+ describe("@ai-sdk/gateway", () => {
2544
+ test("anthropic sonnet 4.6 models return adaptive thinking options", () => {
2545
+ const model = createMockModel({
2546
+ id: "anthropic/claude-sonnet-4-6",
2547
+ providerID: "gateway",
2548
+ api: {
2549
+ id: "anthropic/claude-sonnet-4-6",
2550
+ url: "https://gateway.ai",
2551
+ npm: "@ai-sdk/gateway",
2552
+ },
2553
+ })
2554
+ const result = ProviderTransform.variants(model)
2555
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "max"])
2556
+ expect(result.medium).toEqual({
2557
+ thinking: {
2558
+ type: "adaptive",
2559
+ },
2560
+ effort: "medium",
2561
+ })
2562
+ })
2563
+
2564
+ test("anthropic sonnet 4.6 dot-format models return adaptive thinking options", () => {
2565
+ const model = createMockModel({
2566
+ id: "anthropic/claude-sonnet-4-6",
2567
+ providerID: "gateway",
2568
+ api: {
2569
+ id: "anthropic/claude-sonnet-4.6",
2570
+ url: "https://gateway.ai",
2571
+ npm: "@ai-sdk/gateway",
2572
+ },
2573
+ })
2574
+ const result = ProviderTransform.variants(model)
2575
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "max"])
2576
+ expect(result.medium).toEqual({
2577
+ thinking: {
2578
+ type: "adaptive",
2579
+ },
2580
+ effort: "medium",
2581
+ })
2582
+ })
2583
+
2584
+ test("anthropic opus 4.6 dot-format models return adaptive thinking options", () => {
2585
+ const model = createMockModel({
2586
+ id: "anthropic/claude-opus-4-6",
2587
+ providerID: "gateway",
2588
+ api: {
2589
+ id: "anthropic/claude-opus-4.6",
2590
+ url: "https://gateway.ai",
2591
+ npm: "@ai-sdk/gateway",
2592
+ },
2593
+ })
2594
+ const result = ProviderTransform.variants(model)
2595
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "max"])
2596
+ expect(result.high).toEqual({
2597
+ thinking: {
2598
+ type: "adaptive",
2599
+ },
2600
+ effort: "high",
2601
+ })
2602
+ })
2603
+
2604
+ test("anthropic opus 4.7 models return adaptive thinking options with xhigh", () => {
2605
+ const model = createMockModel({
2606
+ id: "anthropic/claude-opus-4-7",
2607
+ providerID: "gateway",
2608
+ api: {
2609
+ id: "anthropic/claude-opus-4-7",
2610
+ url: "https://gateway.ai",
2611
+ npm: "@ai-sdk/gateway",
2612
+ },
2613
+ })
2614
+ const result = ProviderTransform.variants(model)
2615
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh", "max"])
2616
+ expect(result.xhigh).toEqual({
2617
+ thinking: {
2618
+ type: "adaptive",
2619
+ },
2620
+ effort: "xhigh",
2621
+ })
2622
+ expect(result.max).toEqual({
2623
+ thinking: {
2624
+ type: "adaptive",
2625
+ },
2626
+ effort: "max",
2627
+ })
2628
+ })
2629
+
2630
+ test("anthropic opus 4.7 dot-format models return adaptive thinking options with xhigh", () => {
2631
+ const model = createMockModel({
2632
+ id: "anthropic/claude-opus-4-7",
2633
+ providerID: "gateway",
2634
+ api: {
2635
+ id: "anthropic/claude-opus-4.7",
2636
+ url: "https://gateway.ai",
2637
+ npm: "@ai-sdk/gateway",
2638
+ },
2639
+ })
2640
+ const result = ProviderTransform.variants(model)
2641
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh", "max"])
2642
+ })
2643
+
2644
+ test("anthropic models return anthropic thinking options", () => {
2645
+ const model = createMockModel({
2646
+ id: "anthropic/claude-sonnet-4",
2647
+ providerID: "gateway",
2648
+ api: {
2649
+ id: "anthropic/claude-sonnet-4",
2650
+ url: "https://gateway.ai",
2651
+ npm: "@ai-sdk/gateway",
2652
+ },
2653
+ })
2654
+ const result = ProviderTransform.variants(model)
2655
+ expect(Object.keys(result)).toEqual(["high", "max"])
2656
+ expect(result.high).toEqual({
2657
+ thinking: {
2658
+ type: "enabled",
2659
+ budgetTokens: 16000,
2660
+ },
2661
+ })
2662
+ expect(result.max).toEqual({
2663
+ thinking: {
2664
+ type: "enabled",
2665
+ budgetTokens: 31999,
2666
+ },
2667
+ })
2668
+ })
2669
+
2670
+ test("returns OPENAI_EFFORTS with reasoningEffort", () => {
2671
+ const model = createMockModel({
2672
+ id: "gateway/gateway-model",
2673
+ providerID: "gateway",
2674
+ api: {
2675
+ id: "gateway-model",
2676
+ url: "https://gateway.ai",
2677
+ npm: "@ai-sdk/gateway",
2678
+ },
2679
+ })
2680
+ const result = ProviderTransform.variants(model)
2681
+ expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
2682
+ expect(result.low).toEqual({ reasoningEffort: "low" })
2683
+ expect(result.high).toEqual({ reasoningEffort: "high" })
2684
+ })
2685
+ })
2686
+
2687
+ describe("@ai-sdk/github-copilot", () => {
2688
+ test("standard models return low, medium, high", () => {
2689
+ const model = createMockModel({
2690
+ id: "gpt-4.5",
2691
+ providerID: "github-copilot",
2692
+ api: {
2693
+ id: "gpt-4.5",
2694
+ url: "https://api.githubcopilot.com",
2695
+ npm: "@ai-sdk/github-copilot",
2696
+ },
2697
+ })
2698
+ const result = ProviderTransform.variants(model)
2699
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2700
+ expect(result.low).toEqual({
2701
+ reasoningEffort: "low",
2702
+ reasoningSummary: "auto",
2703
+ include: ["reasoning.encrypted_content"],
2704
+ })
2705
+ })
2706
+
2707
+ test("gpt-5.1-codex-max includes xhigh", () => {
2708
+ const model = createMockModel({
2709
+ id: "gpt-5.1-codex-max",
2710
+ providerID: "github-copilot",
2711
+ api: {
2712
+ id: "gpt-5.1-codex-max",
2713
+ url: "https://api.githubcopilot.com",
2714
+ npm: "@ai-sdk/github-copilot",
2715
+ },
2716
+ })
2717
+ const result = ProviderTransform.variants(model)
2718
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh"])
2719
+ })
2720
+
2721
+ test("gpt-5.1-codex-mini does not include xhigh", () => {
2722
+ const model = createMockModel({
2723
+ id: "gpt-5.1-codex-mini",
2724
+ providerID: "github-copilot",
2725
+ api: {
2726
+ id: "gpt-5.1-codex-mini",
2727
+ url: "https://api.githubcopilot.com",
2728
+ npm: "@ai-sdk/github-copilot",
2729
+ },
2730
+ })
2731
+ const result = ProviderTransform.variants(model)
2732
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2733
+ })
2734
+
2735
+ test("gpt-5.1-codex does not include xhigh", () => {
2736
+ const model = createMockModel({
2737
+ id: "gpt-5.1-codex",
2738
+ providerID: "github-copilot",
2739
+ api: {
2740
+ id: "gpt-5.1-codex",
2741
+ url: "https://api.githubcopilot.com",
2742
+ npm: "@ai-sdk/github-copilot",
2743
+ },
2744
+ })
2745
+ const result = ProviderTransform.variants(model)
2746
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2747
+ })
2748
+
2749
+ test("gpt-5.2 includes xhigh", () => {
2750
+ const model = createMockModel({
2751
+ id: "gpt-5.2",
2752
+ providerID: "github-copilot",
2753
+ api: {
2754
+ id: "gpt-5.2",
2755
+ url: "https://api.githubcopilot.com",
2756
+ npm: "@ai-sdk/github-copilot",
2757
+ },
2758
+ })
2759
+ const result = ProviderTransform.variants(model)
2760
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh"])
2761
+ expect(result.xhigh).toEqual({
2762
+ reasoningEffort: "xhigh",
2763
+ reasoningSummary: "auto",
2764
+ include: ["reasoning.encrypted_content"],
2765
+ })
2766
+ })
2767
+
2768
+ test("gpt-5.2-codex includes xhigh", () => {
2769
+ const model = createMockModel({
2770
+ id: "gpt-5.2-codex",
2771
+ providerID: "github-copilot",
2772
+ api: {
2773
+ id: "gpt-5.2-codex",
2774
+ url: "https://api.githubcopilot.com",
2775
+ npm: "@ai-sdk/github-copilot",
2776
+ },
2777
+ })
2778
+ const result = ProviderTransform.variants(model)
2779
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh"])
2780
+ })
2781
+
2782
+ test("gpt-5.3-codex includes xhigh", () => {
2783
+ const model = createMockModel({
2784
+ id: "gpt-5.3-codex",
2785
+ providerID: "github-copilot",
2786
+ api: {
2787
+ id: "gpt-5.3-codex",
2788
+ url: "https://api.githubcopilot.com",
2789
+ npm: "@ai-sdk/github-copilot",
2790
+ },
2791
+ })
2792
+ const result = ProviderTransform.variants(model)
2793
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh"])
2794
+ })
2795
+
2796
+ test("gpt-5.4 includes xhigh", () => {
2797
+ const model = createMockModel({
2798
+ id: "gpt-5.4",
2799
+ release_date: "2026-03-05",
2800
+ providerID: "github-copilot",
2801
+ api: {
2802
+ id: "gpt-5.4",
2803
+ url: "https://api.githubcopilot.com",
2804
+ npm: "@ai-sdk/github-copilot",
2805
+ },
2806
+ })
2807
+ const result = ProviderTransform.variants(model)
2808
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh"])
2809
+ })
2810
+ })
2811
+ describe("@ai-sdk/azure", () => {
2812
+ test("gpt-5.4 includes xhigh", () => {
2813
+ const model = createMockModel({
2814
+ id: "gpt-5.4",
2815
+ release_date: "2026-03-05",
2816
+ providerID: "azure",
2817
+ api: {
2818
+ id: "gpt-5.4",
2819
+ url: "https://resource.openai.azure.com/openai",
2820
+ npm: "@ai-sdk/azure",
2821
+ },
2822
+ })
2823
+ const result = ProviderTransform.variants(model)
2824
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh"])
2825
+ expect(result.xhigh).toEqual({
2826
+ reasoningEffort: "xhigh",
2827
+ reasoningSummary: "auto",
2828
+ include: ["reasoning.encrypted_content"],
2829
+ })
2830
+ })
2831
+ })
2832
+
2833
+ describe("@ai-sdk/cerebras", () => {
2834
+ test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
2835
+ const model = createMockModel({
2836
+ id: "cerebras/llama-4",
2837
+ providerID: "cerebras",
2838
+ api: {
2839
+ id: "llama-4-sc",
2840
+ url: "https://api.cerebras.ai",
2841
+ npm: "@ai-sdk/cerebras",
2842
+ },
2843
+ })
2844
+ const result = ProviderTransform.variants(model)
2845
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2846
+ expect(result.low).toEqual({ reasoningEffort: "low" })
2847
+ expect(result.high).toEqual({ reasoningEffort: "high" })
2848
+ })
2849
+ })
2850
+
2851
+ describe("@ai-sdk/togetherai", () => {
2852
+ test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
2853
+ const model = createMockModel({
2854
+ id: "togetherai/llama-4",
2855
+ providerID: "togetherai",
2856
+ api: {
2857
+ id: "llama-4-sc",
2858
+ url: "https://api.togetherai.com",
2859
+ npm: "@ai-sdk/togetherai",
2860
+ },
2861
+ })
2862
+ const result = ProviderTransform.variants(model)
2863
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2864
+ expect(result.low).toEqual({ reasoningEffort: "low" })
2865
+ expect(result.high).toEqual({ reasoningEffort: "high" })
2866
+ })
2867
+ })
2868
+
2869
+ describe("@ai-sdk/xai", () => {
2870
+ test("grok-3 returns empty object", () => {
2871
+ const model = createMockModel({
2872
+ id: "xai/grok-3",
2873
+ providerID: "xai",
2874
+ api: {
2875
+ id: "grok-3",
2876
+ url: "https://api.x.ai",
2877
+ npm: "@ai-sdk/xai",
2878
+ },
2879
+ })
2880
+ const result = ProviderTransform.variants(model)
2881
+ expect(result).toEqual({})
2882
+ })
2883
+
2884
+ test("grok-3-mini returns low and high with reasoningEffort", () => {
2885
+ const model = createMockModel({
2886
+ id: "xai/grok-3-mini",
2887
+ providerID: "xai",
2888
+ api: {
2889
+ id: "grok-3-mini",
2890
+ url: "https://api.x.ai",
2891
+ npm: "@ai-sdk/xai",
2892
+ },
2893
+ })
2894
+ const result = ProviderTransform.variants(model)
2895
+ expect(Object.keys(result)).toEqual(["low", "high"])
2896
+ expect(result.low).toEqual({ reasoningEffort: "low" })
2897
+ expect(result.high).toEqual({ reasoningEffort: "high" })
2898
+ })
2899
+ })
2900
+
2901
+ describe("@ai-sdk/deepinfra", () => {
2902
+ test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
2903
+ const model = createMockModel({
2904
+ id: "deepinfra/llama-4",
2905
+ providerID: "deepinfra",
2906
+ api: {
2907
+ id: "llama-4-sc",
2908
+ url: "https://api.deepinfra.com",
2909
+ npm: "@ai-sdk/deepinfra",
2910
+ },
2911
+ })
2912
+ const result = ProviderTransform.variants(model)
2913
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2914
+ expect(result.low).toEqual({ reasoningEffort: "low" })
2915
+ expect(result.high).toEqual({ reasoningEffort: "high" })
2916
+ })
2917
+ })
2918
+
2919
+ describe("@ai-sdk/openai-compatible", () => {
2920
+ test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
2921
+ const model = createMockModel({
2922
+ id: "custom-provider/custom-model",
2923
+ providerID: "custom-provider",
2924
+ api: {
2925
+ id: "custom-model",
2926
+ url: "https://api.custom.com",
2927
+ npm: "@ai-sdk/openai-compatible",
2928
+ },
2929
+ })
2930
+ const result = ProviderTransform.variants(model)
2931
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2932
+ expect(result.low).toEqual({ reasoningEffort: "low" })
2933
+ expect(result.high).toEqual({ reasoningEffort: "high" })
2934
+ })
2935
+ test("mercury-2 returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
2936
+ const model = createMockModel({
2937
+ id: "inception/mercury-2",
2938
+ providerID: "inception",
2939
+ api: {
2940
+ id: "mercury-2",
2941
+ url: "https://api.inceptionlabs.ai",
2942
+ npm: "@ai-sdk/openai-compatible",
2943
+ },
2944
+ })
2945
+ const result = ProviderTransform.variants(model)
2946
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2947
+ expect(result.low).toEqual({ reasoningEffort: "low" })
2948
+ expect(result.high).toEqual({ reasoningEffort: "high" })
2949
+ })
2950
+ })
2951
+
2952
+ describe("@ai-sdk/azure", () => {
2953
+ test("o1-mini returns empty object", () => {
2954
+ const model = createMockModel({
2955
+ id: "o1-mini",
2956
+ providerID: "azure",
2957
+ api: {
2958
+ id: "o1-mini",
2959
+ url: "https://azure.com",
2960
+ npm: "@ai-sdk/azure",
2961
+ },
2962
+ })
2963
+ const result = ProviderTransform.variants(model)
2964
+ expect(result).toEqual({})
2965
+ })
2966
+
2967
+ test("standard azure models return custom efforts with reasoningSummary", () => {
2968
+ const model = createMockModel({
2969
+ id: "o1",
2970
+ providerID: "azure",
2971
+ api: {
2972
+ id: "o1",
2973
+ url: "https://azure.com",
2974
+ npm: "@ai-sdk/azure",
2975
+ },
2976
+ })
2977
+ const result = ProviderTransform.variants(model)
2978
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2979
+ expect(result.low).toEqual({
2980
+ reasoningEffort: "low",
2981
+ reasoningSummary: "auto",
2982
+ include: ["reasoning.encrypted_content"],
2983
+ })
2984
+ })
2985
+
2986
+ test("gpt-5 adds minimal effort", () => {
2987
+ const model = createMockModel({
2988
+ id: "gpt-5",
2989
+ providerID: "azure",
2990
+ api: {
2991
+ id: "gpt-5",
2992
+ url: "https://azure.com",
2993
+ npm: "@ai-sdk/azure",
2994
+ },
2995
+ })
2996
+ const result = ProviderTransform.variants(model)
2997
+ expect(Object.keys(result)).toEqual(["minimal", "low", "medium", "high"])
2998
+ })
2999
+ })
3000
+
3001
+ describe("@ai-sdk/openai", () => {
3002
+ test("gpt-5-pro returns empty object", () => {
3003
+ const model = createMockModel({
3004
+ id: "gpt-5-pro",
3005
+ providerID: "openai",
3006
+ api: {
3007
+ id: "gpt-5-pro",
3008
+ url: "https://api.openai.com",
3009
+ npm: "@ai-sdk/openai",
3010
+ },
3011
+ })
3012
+ const result = ProviderTransform.variants(model)
3013
+ expect(result).toEqual({})
3014
+ })
3015
+
3016
+ test("standard openai models return custom efforts with reasoningSummary", () => {
3017
+ const model = createMockModel({
3018
+ id: "gpt-5",
3019
+ providerID: "openai",
3020
+ api: {
3021
+ id: "gpt-5",
3022
+ url: "https://api.openai.com",
3023
+ npm: "@ai-sdk/openai",
3024
+ },
3025
+ release_date: "2024-06-01",
3026
+ })
3027
+ const result = ProviderTransform.variants(model)
3028
+ expect(Object.keys(result)).toEqual(["minimal", "low", "medium", "high"])
3029
+ expect(result.low).toEqual({
3030
+ reasoningEffort: "low",
3031
+ reasoningSummary: "auto",
3032
+ include: ["reasoning.encrypted_content"],
3033
+ })
3034
+ })
3035
+
3036
+ test("models after 2025-11-13 include 'none' effort", () => {
3037
+ const model = createMockModel({
3038
+ id: "gpt-5-nano",
3039
+ providerID: "openai",
3040
+ api: {
3041
+ id: "gpt-5-nano",
3042
+ url: "https://api.openai.com",
3043
+ npm: "@ai-sdk/openai",
3044
+ },
3045
+ release_date: "2025-11-14",
3046
+ })
3047
+ const result = ProviderTransform.variants(model)
3048
+ expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high"])
3049
+ })
3050
+
3051
+ test("models after 2025-12-04 include 'xhigh' effort", () => {
3052
+ const model = createMockModel({
3053
+ id: "openai/gpt-5-chat",
3054
+ providerID: "openai",
3055
+ api: {
3056
+ id: "gpt-5-chat",
3057
+ url: "https://api.openai.com",
3058
+ npm: "@ai-sdk/openai",
3059
+ },
3060
+ release_date: "2025-12-05",
3061
+ })
3062
+ const result = ProviderTransform.variants(model)
3063
+ expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
3064
+ })
3065
+ })
3066
+
3067
+ describe("@ai-sdk/anthropic", () => {
3068
+ test("sonnet 4.6 returns adaptive thinking options", () => {
3069
+ const model = createMockModel({
3070
+ id: "anthropic/claude-sonnet-4-6",
3071
+ providerID: "anthropic",
3072
+ api: {
3073
+ id: "claude-sonnet-4-6",
3074
+ url: "https://api.anthropic.com",
3075
+ npm: "@ai-sdk/anthropic",
3076
+ },
3077
+ })
3078
+ const result = ProviderTransform.variants(model)
3079
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "max"])
3080
+ expect(result.high).toEqual({
3081
+ thinking: {
3082
+ type: "adaptive",
3083
+ },
3084
+ effort: "high",
3085
+ })
3086
+ })
3087
+
3088
+ test("opus 4.7 returns adaptive thinking options with xhigh", () => {
3089
+ const model = createMockModel({
3090
+ id: "anthropic/claude-opus-4-7",
3091
+ providerID: "anthropic",
3092
+ api: {
3093
+ id: "claude-opus-4-7",
3094
+ url: "https://api.anthropic.com",
3095
+ npm: "@ai-sdk/anthropic",
3096
+ },
3097
+ })
3098
+ const result = ProviderTransform.variants(model)
3099
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh", "max"])
3100
+ expect(result.xhigh).toEqual({
3101
+ thinking: {
3102
+ type: "adaptive",
3103
+ display: "summarized",
3104
+ },
3105
+ effort: "xhigh",
3106
+ })
3107
+ expect(result.max).toEqual({
3108
+ thinking: {
3109
+ type: "adaptive",
3110
+ display: "summarized",
3111
+ },
3112
+ effort: "max",
3113
+ })
3114
+ })
3115
+
3116
+ test("github copilot opus 4.7 returns only medium reasoning effort", () => {
3117
+ const model = createMockModel({
3118
+ id: "claude-opus-4.7",
3119
+ providerID: "github-copilot",
3120
+ api: {
3121
+ id: "claude-opus-4.7",
3122
+ url: "https://api.githubcopilot.com/v1",
3123
+ npm: "@ai-sdk/anthropic",
3124
+ },
3125
+ })
3126
+ const result = ProviderTransform.variants(model)
3127
+ expect(result).toEqual({
3128
+ medium: {
3129
+ thinking: {
3130
+ type: "adaptive",
3131
+ display: "summarized",
3132
+ },
3133
+ effort: "medium",
3134
+ },
3135
+ })
3136
+ })
3137
+
3138
+ test("returns high and max with thinking config", () => {
3139
+ const model = createMockModel({
3140
+ id: "anthropic/claude-4",
3141
+ providerID: "anthropic",
3142
+ api: {
3143
+ id: "claude-4",
3144
+ url: "https://api.anthropic.com",
3145
+ npm: "@ai-sdk/anthropic",
3146
+ },
3147
+ })
3148
+ const result = ProviderTransform.variants(model)
3149
+ expect(Object.keys(result)).toEqual(["high", "max"])
3150
+ expect(result.high).toEqual({
3151
+ thinking: {
3152
+ type: "enabled",
3153
+ budgetTokens: 16000,
3154
+ },
3155
+ })
3156
+ expect(result.max).toEqual({
3157
+ thinking: {
3158
+ type: "enabled",
3159
+ budgetTokens: 31999,
3160
+ },
3161
+ })
3162
+ })
3163
+ })
3164
+
3165
+ describe("@ai-sdk/amazon-bedrock", () => {
3166
+ test("anthropic sonnet 4.6 returns adaptive reasoning options", () => {
3167
+ const model = createMockModel({
3168
+ id: "bedrock/anthropic-claude-sonnet-4-6",
3169
+ providerID: "bedrock",
3170
+ api: {
3171
+ id: "anthropic.claude-sonnet-4-6",
3172
+ url: "https://bedrock.amazonaws.com",
3173
+ npm: "@ai-sdk/amazon-bedrock",
3174
+ },
3175
+ })
3176
+ const result = ProviderTransform.variants(model)
3177
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "max"])
3178
+ expect(result.max).toEqual({
3179
+ reasoningConfig: {
3180
+ type: "adaptive",
3181
+ maxReasoningEffort: "max",
3182
+ },
3183
+ })
3184
+ })
3185
+
3186
+ test("anthropic opus 4.7 returns adaptive reasoning options with xhigh", () => {
3187
+ const model = createMockModel({
3188
+ id: "bedrock/anthropic-claude-opus-4-7",
3189
+ providerID: "bedrock",
3190
+ api: {
3191
+ id: "anthropic.claude-opus-4-7",
3192
+ url: "https://bedrock.amazonaws.com",
3193
+ npm: "@ai-sdk/amazon-bedrock",
3194
+ },
3195
+ })
3196
+ const result = ProviderTransform.variants(model)
3197
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh", "max"])
3198
+ expect(result.xhigh).toEqual({
3199
+ reasoningConfig: {
3200
+ type: "adaptive",
3201
+ maxReasoningEffort: "xhigh",
3202
+ display: "summarized",
3203
+ },
3204
+ })
3205
+ expect(result.max).toEqual({
3206
+ reasoningConfig: {
3207
+ type: "adaptive",
3208
+ maxReasoningEffort: "max",
3209
+ display: "summarized",
3210
+ },
3211
+ })
3212
+ })
3213
+
3214
+ test("returns WIDELY_SUPPORTED_EFFORTS with reasoningConfig", () => {
3215
+ const model = createMockModel({
3216
+ id: "bedrock/llama-4",
3217
+ providerID: "bedrock",
3218
+ api: {
3219
+ id: "llama-4-sc",
3220
+ url: "https://bedrock.amazonaws.com",
3221
+ npm: "@ai-sdk/amazon-bedrock",
3222
+ },
3223
+ })
3224
+ const result = ProviderTransform.variants(model)
3225
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
3226
+ expect(result.low).toEqual({
3227
+ reasoningConfig: {
3228
+ type: "enabled",
3229
+ maxReasoningEffort: "low",
3230
+ },
3231
+ })
3232
+ })
3233
+ })
3234
+
3235
+ describe("@ai-sdk/google", () => {
3236
+ test("gemini-2.5 returns high and max with thinkingConfig and thinkingBudget", () => {
3237
+ const model = createMockModel({
3238
+ id: "google/gemini-2.5-pro",
3239
+ providerID: "google",
3240
+ api: {
3241
+ id: "gemini-2.5-pro",
3242
+ url: "https://generativelanguage.googleapis.com",
3243
+ npm: "@ai-sdk/google",
3244
+ },
3245
+ })
3246
+ const result = ProviderTransform.variants(model)
3247
+ expect(Object.keys(result)).toEqual(["high", "max"])
3248
+ expect(result.high).toEqual({
3249
+ thinkingConfig: {
3250
+ includeThoughts: true,
3251
+ thinkingBudget: 16000,
3252
+ },
3253
+ })
3254
+ expect(result.max).toEqual({
3255
+ thinkingConfig: {
3256
+ includeThoughts: true,
3257
+ thinkingBudget: 24576,
3258
+ },
3259
+ })
3260
+ })
3261
+
3262
+ test("other gemini models return low and high with thinkingLevel", () => {
3263
+ const model = createMockModel({
3264
+ id: "google/gemini-2.0-pro",
3265
+ providerID: "google",
3266
+ api: {
3267
+ id: "gemini-2.0-pro",
3268
+ url: "https://generativelanguage.googleapis.com",
3269
+ npm: "@ai-sdk/google",
3270
+ },
3271
+ })
3272
+ const result = ProviderTransform.variants(model)
3273
+ expect(Object.keys(result)).toEqual(["low", "high"])
3274
+ expect(result.low).toEqual({
3275
+ thinkingConfig: {
3276
+ includeThoughts: true,
3277
+ thinkingLevel: "low",
3278
+ },
3279
+ })
3280
+ expect(result.high).toEqual({
3281
+ thinkingConfig: {
3282
+ includeThoughts: true,
3283
+ thinkingLevel: "high",
3284
+ },
3285
+ })
3286
+ })
3287
+ })
3288
+
3289
+ describe("@ai-sdk/google-vertex", () => {
3290
+ test("gemini-2.5 returns high and max with thinkingConfig and thinkingBudget", () => {
3291
+ const model = createMockModel({
3292
+ id: "google-vertex/gemini-2.5-pro",
3293
+ providerID: "google-vertex",
3294
+ api: {
3295
+ id: "gemini-2.5-pro",
3296
+ url: "https://vertexai.googleapis.com",
3297
+ npm: "@ai-sdk/google-vertex",
3298
+ },
3299
+ })
3300
+ const result = ProviderTransform.variants(model)
3301
+ expect(Object.keys(result)).toEqual(["high", "max"])
3302
+ })
3303
+
3304
+ test("other vertex models return low and high with thinkingLevel", () => {
3305
+ const model = createMockModel({
3306
+ id: "google-vertex/gemini-2.0-pro",
3307
+ providerID: "google-vertex",
3308
+ api: {
3309
+ id: "gemini-2.0-pro",
3310
+ url: "https://vertexai.googleapis.com",
3311
+ npm: "@ai-sdk/google-vertex",
3312
+ },
3313
+ })
3314
+ const result = ProviderTransform.variants(model)
3315
+ expect(Object.keys(result)).toEqual(["low", "high"])
3316
+ })
3317
+ })
3318
+
3319
+ describe("@ai-sdk/cohere", () => {
3320
+ test("returns empty object", () => {
3321
+ const model = createMockModel({
3322
+ id: "cohere/command-r",
3323
+ providerID: "cohere",
3324
+ api: {
3325
+ id: "command-r",
3326
+ url: "https://api.cohere.com",
3327
+ npm: "@ai-sdk/cohere",
3328
+ },
3329
+ })
3330
+ const result = ProviderTransform.variants(model)
3331
+ expect(result).toEqual({})
3332
+ })
3333
+ })
3334
+
3335
+ describe("@ai-sdk/groq", () => {
3336
+ test("returns none and WIDELY_SUPPORTED_EFFORTS with thinkingLevel", () => {
3337
+ const model = createMockModel({
3338
+ id: "groq/llama-4",
3339
+ providerID: "groq",
3340
+ api: {
3341
+ id: "llama-4-sc",
3342
+ url: "https://api.groq.com",
3343
+ npm: "@ai-sdk/groq",
3344
+ },
3345
+ })
3346
+ const result = ProviderTransform.variants(model)
3347
+ expect(Object.keys(result)).toEqual(["none", "low", "medium", "high"])
3348
+ expect(result.none).toEqual({
3349
+ reasoningEffort: "none",
3350
+ })
3351
+ expect(result.low).toEqual({
3352
+ reasoningEffort: "low",
3353
+ })
3354
+ })
3355
+ })
3356
+
3357
+ describe("@ai-sdk/perplexity", () => {
3358
+ test("returns empty object", () => {
3359
+ const model = createMockModel({
3360
+ id: "perplexity/sonar-plus",
3361
+ providerID: "perplexity",
3362
+ api: {
3363
+ id: "sonar-plus",
3364
+ url: "https://api.perplexity.ai",
3365
+ npm: "@ai-sdk/perplexity",
3366
+ },
3367
+ })
3368
+ const result = ProviderTransform.variants(model)
3369
+ expect(result).toEqual({})
3370
+ })
3371
+ })
3372
+
3373
+ describe("@jerome-benoit/sap-ai-provider-v2", () => {
3374
+ test("anthropic models return thinking variants", () => {
3375
+ const model = createMockModel({
3376
+ id: "sap-ai-core/anthropic--claude-sonnet-4",
3377
+ providerID: "sap-ai-core",
3378
+ api: {
3379
+ id: "anthropic--claude-sonnet-4",
3380
+ url: "https://api.ai.sap",
3381
+ npm: "@jerome-benoit/sap-ai-provider-v2",
3382
+ },
3383
+ })
3384
+ const result = ProviderTransform.variants(model)
3385
+ expect(Object.keys(result)).toEqual(["high", "max"])
3386
+ expect(result.high).toEqual({
3387
+ thinking: {
3388
+ type: "enabled",
3389
+ budgetTokens: 16000,
3390
+ },
3391
+ })
3392
+ expect(result.max).toEqual({
3393
+ thinking: {
3394
+ type: "enabled",
3395
+ budgetTokens: 31999,
3396
+ },
3397
+ })
3398
+ })
3399
+
3400
+ test("anthropic 4.6 models return adaptive thinking variants", () => {
3401
+ const model = createMockModel({
3402
+ id: "sap-ai-core/anthropic--claude-sonnet-4-6",
3403
+ providerID: "sap-ai-core",
3404
+ api: {
3405
+ id: "anthropic--claude-sonnet-4-6",
3406
+ url: "https://api.ai.sap",
3407
+ npm: "@jerome-benoit/sap-ai-provider-v2",
3408
+ },
3409
+ })
3410
+ const result = ProviderTransform.variants(model)
3411
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "max"])
3412
+ expect(result.low).toEqual({
3413
+ thinking: {
3414
+ type: "adaptive",
3415
+ },
3416
+ effort: "low",
3417
+ })
3418
+ expect(result.max).toEqual({
3419
+ thinking: {
3420
+ type: "adaptive",
3421
+ },
3422
+ effort: "max",
3423
+ })
3424
+ })
3425
+
3426
+ test("gemini 2.5 models return thinkingConfig variants", () => {
3427
+ const model = createMockModel({
3428
+ id: "sap-ai-core/gcp--gemini-2.5-pro",
3429
+ providerID: "sap-ai-core",
3430
+ api: {
3431
+ id: "gcp--gemini-2.5-pro",
3432
+ url: "https://api.ai.sap",
3433
+ npm: "@jerome-benoit/sap-ai-provider-v2",
3434
+ },
3435
+ })
3436
+ const result = ProviderTransform.variants(model)
3437
+ expect(Object.keys(result)).toEqual(["high", "max"])
3438
+ expect(result.high).toEqual({
3439
+ thinkingConfig: {
3440
+ includeThoughts: true,
3441
+ thinkingBudget: 16000,
3442
+ },
3443
+ })
3444
+ expect(result.max).toEqual({
3445
+ thinkingConfig: {
3446
+ includeThoughts: true,
3447
+ thinkingBudget: 24576,
3448
+ },
3449
+ })
3450
+ })
3451
+
3452
+ test("gpt models return reasoningEffort variants", () => {
3453
+ const model = createMockModel({
3454
+ id: "sap-ai-core/azure-openai--gpt-4o",
3455
+ providerID: "sap-ai-core",
3456
+ api: {
3457
+ id: "azure-openai--gpt-4o",
3458
+ url: "https://api.ai.sap",
3459
+ npm: "@jerome-benoit/sap-ai-provider-v2",
3460
+ },
3461
+ })
3462
+ const result = ProviderTransform.variants(model)
3463
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
3464
+ expect(result.low).toEqual({ reasoningEffort: "low" })
3465
+ expect(result.high).toEqual({ reasoningEffort: "high" })
3466
+ })
3467
+
3468
+ test("o-series models return reasoningEffort variants", () => {
3469
+ const model = createMockModel({
3470
+ id: "sap-ai-core/azure-openai--o3-mini",
3471
+ providerID: "sap-ai-core",
3472
+ api: {
3473
+ id: "azure-openai--o3-mini",
3474
+ url: "https://api.ai.sap",
3475
+ npm: "@jerome-benoit/sap-ai-provider-v2",
3476
+ },
3477
+ })
3478
+ const result = ProviderTransform.variants(model)
3479
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
3480
+ expect(result.low).toEqual({ reasoningEffort: "low" })
3481
+ expect(result.high).toEqual({ reasoningEffort: "high" })
3482
+ })
3483
+
3484
+ test("sonar models return empty object", () => {
3485
+ const model = createMockModel({
3486
+ id: "sap-ai-core/perplexity--sonar-pro",
3487
+ providerID: "sap-ai-core",
3488
+ api: {
3489
+ id: "perplexity--sonar-pro",
3490
+ url: "https://api.ai.sap",
3491
+ npm: "@jerome-benoit/sap-ai-provider-v2",
3492
+ },
3493
+ })
3494
+ const result = ProviderTransform.variants(model)
3495
+ expect(result).toEqual({})
3496
+ })
3497
+
3498
+ test("mistral models return empty object", () => {
3499
+ const model = createMockModel({
3500
+ id: "sap-ai-core/mistral--mistral-large",
3501
+ providerID: "sap-ai-core",
3502
+ api: {
3503
+ id: "mistral--mistral-large",
3504
+ url: "https://api.ai.sap",
3505
+ npm: "@jerome-benoit/sap-ai-provider-v2",
3506
+ },
3507
+ })
3508
+ const result = ProviderTransform.variants(model)
3509
+ expect(result).toEqual({})
3510
+ })
3511
+ })
3512
+ describe("ProviderTransform.smallOptions", () => {
3513
+ describe("@saeeol/gateway", () => {
3514
+ test("claude models return reasoningEffort minimal", () => {
3515
+ const model = createMockModel({
3516
+ id: "saeeol/anthropic/claude-sonnet-4",
3517
+ providerID: "saeeol",
3518
+ api: {
3519
+ id: "anthropic/claude-sonnet-4",
3520
+ url: "https://gateway.saeeol.ai",
3521
+ npm: "@saeeol/gateway",
3522
+ },
3523
+ })
3524
+ const result = ProviderTransform.smallOptions(model)
3525
+ expect(result).toEqual({ reasoningEffort: "minimal" })
3526
+ })
3527
+
3528
+ test("non-claude models use reasoningEffort format", () => {
3529
+ const model = createMockModel({
3530
+ id: "saeeol/openai/gpt-4",
3531
+ providerID: "saeeol",
3532
+ api: {
3533
+ id: "openai/gpt-4",
3534
+ url: "https://gateway.saeeol.ai",
3535
+ npm: "@saeeol/gateway",
3536
+ },
3537
+ })
3538
+ const result = ProviderTransform.smallOptions(model)
3539
+ expect(result).toEqual({ reasoningEffort: "minimal" })
3540
+ })
3541
+
3542
+ test("google models disable reasoning", () => {
3543
+ const model = createMockModel({
3544
+ id: "saeeol/google/gemini-2.0-flash",
3545
+ providerID: "saeeol",
3546
+ api: {
3547
+ id: "google/gemini-2.0-flash",
3548
+ url: "https://gateway.saeeol.ai",
3549
+ npm: "@saeeol/gateway",
3550
+ },
3551
+ })
3552
+ const result = ProviderTransform.smallOptions(model)
3553
+ expect(result).toEqual({ reasoning: { enabled: false } })
3554
+ })
3555
+ })
3556
+ })
3557
+
3558
+ describe("@ai-sdk/groq", () => {
3559
+ test("returns none and WIDELY_SUPPORTED_EFFORTS with thinkingLevel", () => {
3560
+ const model = createMockModel({
3561
+ id: "groq/llama-4",
3562
+ providerID: "groq",
3563
+ api: {
3564
+ id: "llama-4-sc",
3565
+ url: "https://api.groq.com",
3566
+ npm: "@ai-sdk/groq",
3567
+ },
3568
+ })
3569
+ const result = ProviderTransform.variants(model)
3570
+ expect(Object.keys(result)).toEqual(["none", "low", "medium", "high"])
3571
+ expect(result.none).toEqual({
3572
+ reasoningEffort: "none",
3573
+ })
3574
+ expect(result.low).toEqual({
3575
+ reasoningEffort: "low",
3576
+ })
3577
+ })
3578
+ })
3579
+
3580
+ describe("@ai-sdk/perplexity", () => {
3581
+ test("returns empty object", () => {
3582
+ const model = createMockModel({
3583
+ id: "perplexity/sonar-plus",
3584
+ providerID: "perplexity",
3585
+ api: {
3586
+ id: "sonar-plus",
3587
+ url: "https://api.perplexity.ai",
3588
+ npm: "@ai-sdk/perplexity",
3589
+ },
3590
+ })
3591
+ const result = ProviderTransform.variants(model)
3592
+ expect(result).toEqual({})
3593
+ })
3594
+ })
3595
+ })
3596
+ describe("ProviderTransform.options - OpenAI Responses API params guard", () => {
3597
+ const sessionID = "test-session"
3598
+
3599
+ const gpt5Model = (npm: string, providerID: string, apiId = "gpt-5.4"): any => ({
3600
+ id: `${providerID}/${apiId}`,
3601
+ providerID,
3602
+ api: { id: apiId, npm, url: "" },
3603
+ name: apiId,
3604
+ capabilities: {
3605
+ temperature: true,
3606
+ reasoning: true,
3607
+ attachment: true,
3608
+ toolcall: true,
3609
+ input: { text: true, audio: false, image: false, video: false, pdf: false },
3610
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
3611
+ interleaved: false,
3612
+ },
3613
+ cost: { input: 0, output: 0 },
3614
+ limit: { context: 200000, output: 32000 },
3615
+ options: {},
3616
+ headers: {},
3617
+ })
3618
+
3619
+ test("includes reasoningSummary and textVerbosity for @ai-sdk/openai", () => {
3620
+ const result = ProviderTransform.options({
3621
+ model: gpt5Model("@ai-sdk/openai", "openai"),
3622
+ sessionID,
3623
+ })
3624
+ expect(result.reasoningSummary).toBe("auto")
3625
+ expect(result.reasoningEffort).toBe("medium")
3626
+ expect(result.textVerbosity).toBe("low")
3627
+ })
3628
+
3629
+ test("includes reasoningSummary for @ai-sdk/azure", () => {
3630
+ const result = ProviderTransform.options({
3631
+ model: gpt5Model("@ai-sdk/azure", "azure"),
3632
+ sessionID,
3633
+ })
3634
+ expect(result.reasoningSummary).toBe("auto")
3635
+ })
3636
+
3637
+ test("excludes reasoningSummary and textVerbosity for @ai-sdk/openai-compatible", () => {
3638
+ const result = ProviderTransform.options({
3639
+ model: gpt5Model("@ai-sdk/openai-compatible", "my-proxy"),
3640
+ sessionID,
3641
+ })
3642
+ expect(result.reasoningSummary).toBeUndefined()
3643
+ expect(result.textVerbosity).toBeUndefined()
3644
+ expect(result.reasoningEffort).toBe("medium")
3645
+ })
3646
+
3647
+ test("excludes reasoningSummary for unknown SDK packages", () => {
3648
+ const result = ProviderTransform.options({
3649
+ model: gpt5Model("@ai-sdk/xai", "xai"),
3650
+ sessionID,
3651
+ })
3652
+ expect(result.reasoningSummary).toBeUndefined()
3653
+ expect(result.reasoningEffort).toBe("medium")
3654
+ })
3655
+
3656
+ test("includes reasoningSummary for @openrouter/ai-sdk-provider", () => {
3657
+ const result = ProviderTransform.options({
3658
+ model: gpt5Model("@openrouter/ai-sdk-provider", "openrouter"),
3659
+ sessionID,
3660
+ })
3661
+ expect(result.reasoningSummary).toBe("auto")
3662
+ })
3663
+
3664
+ test("includes reasoningSummary for @saeeol/gateway", () => {
3665
+ const result = ProviderTransform.options({
3666
+ model: gpt5Model("@saeeol/gateway", "saeeol"),
3667
+ sessionID,
3668
+ })
3669
+ expect(result.reasoningSummary).toBe("auto")
3670
+ })
3671
+
3672
+ test("reasoningEffort remains universal across all providers", () => {
3673
+ for (const npm of ["@ai-sdk/openai-compatible", "@ai-sdk/xai", "@ai-sdk/deepinfra"]) {
3674
+ const result = ProviderTransform.options({
3675
+ model: gpt5Model(npm, "test"),
3676
+ sessionID,
3677
+ })
3678
+ expect(result.reasoningEffort).toBe("medium")
3679
+ }
3680
+ })
3681
+ })