@toolkit-cli/toolkode 1.3.7 → 1.3.9

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 (674) hide show
  1. package/package.json +18 -151
  2. package/{script/postinstall.mjs → postinstall.mjs} +5 -5
  3. package/AGENTS.md +0 -69
  4. package/BUN_SHELL_MIGRATION_PLAN.md +0 -136
  5. package/Dockerfile +0 -18
  6. package/README.md +0 -15
  7. package/bin/opencode +0 -179
  8. package/bunfig.toml +0 -7
  9. package/drizzle.config.ts +0 -10
  10. package/git +0 -0
  11. package/migration/20260127222353_familiar_lady_ursula/migration.sql +0 -90
  12. package/migration/20260127222353_familiar_lady_ursula/snapshot.json +0 -796
  13. package/migration/20260211171708_add_project_commands/migration.sql +0 -1
  14. package/migration/20260211171708_add_project_commands/snapshot.json +0 -806
  15. package/migration/20260213144116_wakeful_the_professor/migration.sql +0 -11
  16. package/migration/20260213144116_wakeful_the_professor/snapshot.json +0 -897
  17. package/migration/20260225215848_workspace/migration.sql +0 -7
  18. package/migration/20260225215848_workspace/snapshot.json +0 -959
  19. package/migration/20260227213759_add_session_workspace_id/migration.sql +0 -2
  20. package/migration/20260227213759_add_session_workspace_id/snapshot.json +0 -983
  21. package/migration/20260228203230_blue_harpoon/migration.sql +0 -17
  22. package/migration/20260228203230_blue_harpoon/snapshot.json +0 -1102
  23. package/migration/20260303231226_add_workspace_fields/migration.sql +0 -5
  24. package/migration/20260303231226_add_workspace_fields/snapshot.json +0 -1013
  25. package/migration/20260309230000_move_org_to_state/migration.sql +0 -3
  26. package/migration/20260309230000_move_org_to_state/snapshot.json +0 -1156
  27. package/migration/20260312043431_session_message_cursor/migration.sql +0 -4
  28. package/migration/20260312043431_session_message_cursor/snapshot.json +0 -1168
  29. package/migration/20260323234822_events/migration.sql +0 -13
  30. package/migration/20260323234822_events/snapshot.json +0 -1271
  31. package/parsers-config.ts +0 -290
  32. package/script/build-node.ts +0 -54
  33. package/script/build.ts +0 -276
  34. package/script/check-migrations.ts +0 -16
  35. package/script/publish.ts +0 -181
  36. package/script/schema.ts +0 -63
  37. package/script/seed-e2e.ts +0 -60
  38. package/script/upgrade-opentui.ts +0 -64
  39. package/specs/effect-migration.md +0 -293
  40. package/specs/tui-plugins.md +0 -389
  41. package/src/account/account.sql.ts +0 -39
  42. package/src/account/index.ts +0 -397
  43. package/src/account/repo.ts +0 -163
  44. package/src/account/schema.ts +0 -91
  45. package/src/acp/README.md +0 -174
  46. package/src/acp/agent.ts +0 -1743
  47. package/src/acp/session.ts +0 -116
  48. package/src/acp/types.ts +0 -24
  49. package/src/agent/agent.ts +0 -418
  50. package/src/agent/generate.txt +0 -75
  51. package/src/agent/prompt/compaction.txt +0 -14
  52. package/src/agent/prompt/explore.txt +0 -18
  53. package/src/agent/prompt/summary.txt +0 -11
  54. package/src/agent/prompt/title.txt +0 -44
  55. package/src/auth/index.ts +0 -115
  56. package/src/bun/index.ts +0 -128
  57. package/src/bun/registry.ts +0 -50
  58. package/src/bus/bus-event.ts +0 -40
  59. package/src/bus/global.ts +0 -10
  60. package/src/bus/index.ts +0 -184
  61. package/src/channel/index.ts +0 -231
  62. package/src/cli/bootstrap.ts +0 -17
  63. package/src/cli/cmd/account.ts +0 -257
  64. package/src/cli/cmd/acp.ts +0 -70
  65. package/src/cli/cmd/agent.ts +0 -245
  66. package/src/cli/cmd/cmd.ts +0 -7
  67. package/src/cli/cmd/db.ts +0 -119
  68. package/src/cli/cmd/debug/agent.ts +0 -167
  69. package/src/cli/cmd/debug/config.ts +0 -16
  70. package/src/cli/cmd/debug/file.ts +0 -97
  71. package/src/cli/cmd/debug/index.ts +0 -48
  72. package/src/cli/cmd/debug/lsp.ts +0 -53
  73. package/src/cli/cmd/debug/ripgrep.ts +0 -87
  74. package/src/cli/cmd/debug/scrap.ts +0 -16
  75. package/src/cli/cmd/debug/skill.ts +0 -16
  76. package/src/cli/cmd/debug/snapshot.ts +0 -52
  77. package/src/cli/cmd/export.ts +0 -89
  78. package/src/cli/cmd/generate.ts +0 -38
  79. package/src/cli/cmd/github.ts +0 -1646
  80. package/src/cli/cmd/import.ts +0 -207
  81. package/src/cli/cmd/mcp.ts +0 -754
  82. package/src/cli/cmd/models.ts +0 -78
  83. package/src/cli/cmd/plug.ts +0 -231
  84. package/src/cli/cmd/pr.ts +0 -127
  85. package/src/cli/cmd/providers.ts +0 -482
  86. package/src/cli/cmd/run.ts +0 -738
  87. package/src/cli/cmd/serve.ts +0 -42
  88. package/src/cli/cmd/session.ts +0 -159
  89. package/src/cli/cmd/stats.ts +0 -410
  90. package/src/cli/cmd/tui/app.tsx +0 -1255
  91. package/src/cli/cmd/tui/attach.ts +0 -88
  92. package/src/cli/cmd/tui/component/border.tsx +0 -21
  93. package/src/cli/cmd/tui/component/dialog-agent.tsx +0 -31
  94. package/src/cli/cmd/tui/component/dialog-command.tsx +0 -171
  95. package/src/cli/cmd/tui/component/dialog-mcp.tsx +0 -86
  96. package/src/cli/cmd/tui/component/dialog-model.tsx +0 -264
  97. package/src/cli/cmd/tui/component/dialog-provider.tsx +0 -334
  98. package/src/cli/cmd/tui/component/dialog-session-list.tsx +0 -108
  99. package/src/cli/cmd/tui/component/dialog-session-rename.tsx +0 -31
  100. package/src/cli/cmd/tui/component/dialog-skill.tsx +0 -36
  101. package/src/cli/cmd/tui/component/dialog-stash.tsx +0 -87
  102. package/src/cli/cmd/tui/component/dialog-status.tsx +0 -168
  103. package/src/cli/cmd/tui/component/dialog-tag.tsx +0 -44
  104. package/src/cli/cmd/tui/component/dialog-theme-list.tsx +0 -50
  105. package/src/cli/cmd/tui/component/dialog-variant.tsx +0 -29
  106. package/src/cli/cmd/tui/component/dialog-workspace-list.tsx +0 -320
  107. package/src/cli/cmd/tui/component/error-component.tsx +0 -91
  108. package/src/cli/cmd/tui/component/logo.tsx +0 -86
  109. package/src/cli/cmd/tui/component/plugin-route-missing.tsx +0 -14
  110. package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +0 -667
  111. package/src/cli/cmd/tui/component/prompt/frecency.tsx +0 -90
  112. package/src/cli/cmd/tui/component/prompt/history.tsx +0 -108
  113. package/src/cli/cmd/tui/component/prompt/index.tsx +0 -1353
  114. package/src/cli/cmd/tui/component/prompt/part.ts +0 -16
  115. package/src/cli/cmd/tui/component/prompt/stash.tsx +0 -101
  116. package/src/cli/cmd/tui/component/spinner.tsx +0 -24
  117. package/src/cli/cmd/tui/component/startup-loading.tsx +0 -63
  118. package/src/cli/cmd/tui/component/textarea-keybindings.ts +0 -73
  119. package/src/cli/cmd/tui/component/todo-item.tsx +0 -32
  120. package/src/cli/cmd/tui/component/workspace/dialog-session-list.tsx +0 -151
  121. package/src/cli/cmd/tui/context/args.tsx +0 -15
  122. package/src/cli/cmd/tui/context/directory.ts +0 -13
  123. package/src/cli/cmd/tui/context/exit.tsx +0 -60
  124. package/src/cli/cmd/tui/context/helper.tsx +0 -25
  125. package/src/cli/cmd/tui/context/keybind.tsx +0 -105
  126. package/src/cli/cmd/tui/context/kv.tsx +0 -52
  127. package/src/cli/cmd/tui/context/local.tsx +0 -406
  128. package/src/cli/cmd/tui/context/plugin-keybinds.ts +0 -41
  129. package/src/cli/cmd/tui/context/prompt.tsx +0 -18
  130. package/src/cli/cmd/tui/context/route.tsx +0 -52
  131. package/src/cli/cmd/tui/context/sdk.tsx +0 -128
  132. package/src/cli/cmd/tui/context/sync.tsx +0 -504
  133. package/src/cli/cmd/tui/context/theme/amber.json +0 -245
  134. package/src/cli/cmd/tui/context/theme/amiga.json +0 -245
  135. package/src/cli/cmd/tui/context/theme/atari.json +0 -245
  136. package/src/cli/cmd/tui/context/theme/aura.json +0 -69
  137. package/src/cli/cmd/tui/context/theme/ayu.json +0 -80
  138. package/src/cli/cmd/tui/context/theme/borland.json +0 -245
  139. package/src/cli/cmd/tui/context/theme/carbonfox.json +0 -248
  140. package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +0 -233
  141. package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +0 -233
  142. package/src/cli/cmd/tui/context/theme/catppuccin.json +0 -112
  143. package/src/cli/cmd/tui/context/theme/cobalt2.json +0 -228
  144. package/src/cli/cmd/tui/context/theme/commodore.json +0 -245
  145. package/src/cli/cmd/tui/context/theme/cursor.json +0 -249
  146. package/src/cli/cmd/tui/context/theme/dos-edit.json +0 -245
  147. package/src/cli/cmd/tui/context/theme/dracula.json +0 -219
  148. package/src/cli/cmd/tui/context/theme/everforest.json +0 -241
  149. package/src/cli/cmd/tui/context/theme/flexoki.json +0 -237
  150. package/src/cli/cmd/tui/context/theme/github.json +0 -233
  151. package/src/cli/cmd/tui/context/theme/gnu.json +0 -245
  152. package/src/cli/cmd/tui/context/theme/gruvbox.json +0 -242
  153. package/src/cli/cmd/tui/context/theme/hacker.json +0 -245
  154. package/src/cli/cmd/tui/context/theme/irix.json +0 -245
  155. package/src/cli/cmd/tui/context/theme/kanagawa.json +0 -77
  156. package/src/cli/cmd/tui/context/theme/lucent-orng.json +0 -237
  157. package/src/cli/cmd/tui/context/theme/mac84.json +0 -245
  158. package/src/cli/cmd/tui/context/theme/material.json +0 -235
  159. package/src/cli/cmd/tui/context/theme/matrix.json +0 -77
  160. package/src/cli/cmd/tui/context/theme/mercury.json +0 -252
  161. package/src/cli/cmd/tui/context/theme/monokai.json +0 -221
  162. package/src/cli/cmd/tui/context/theme/nightowl.json +0 -221
  163. package/src/cli/cmd/tui/context/theme/nord.json +0 -223
  164. package/src/cli/cmd/tui/context/theme/norton.json +0 -245
  165. package/src/cli/cmd/tui/context/theme/one-dark.json +0 -84
  166. package/src/cli/cmd/tui/context/theme/opencode.json +0 -245
  167. package/src/cli/cmd/tui/context/theme/orng.json +0 -249
  168. package/src/cli/cmd/tui/context/theme/osaka-jade.json +0 -93
  169. package/src/cli/cmd/tui/context/theme/palenight.json +0 -222
  170. package/src/cli/cmd/tui/context/theme/pine.json +0 -245
  171. package/src/cli/cmd/tui/context/theme/retrowave.json +0 -245
  172. package/src/cli/cmd/tui/context/theme/rosepine.json +0 -234
  173. package/src/cli/cmd/tui/context/theme/solarized.json +0 -223
  174. package/src/cli/cmd/tui/context/theme/synthwave84.json +0 -226
  175. package/src/cli/cmd/tui/context/theme/tokyonight.json +0 -243
  176. package/src/cli/cmd/tui/context/theme/toolkode.json +0 -245
  177. package/src/cli/cmd/tui/context/theme/tron.json +0 -245
  178. package/src/cli/cmd/tui/context/theme/ubuntu.json +0 -245
  179. package/src/cli/cmd/tui/context/theme/vercel.json +0 -245
  180. package/src/cli/cmd/tui/context/theme/vesper.json +0 -218
  181. package/src/cli/cmd/tui/context/theme/vt100.json +0 -245
  182. package/src/cli/cmd/tui/context/theme/xcode.json +0 -245
  183. package/src/cli/cmd/tui/context/theme/zenburn.json +0 -223
  184. package/src/cli/cmd/tui/context/theme.tsx +0 -1288
  185. package/src/cli/cmd/tui/context/tui-config.tsx +0 -9
  186. package/src/cli/cmd/tui/event.ts +0 -49
  187. package/src/cli/cmd/tui/feature-plugins/home/tips-view.tsx +0 -152
  188. package/src/cli/cmd/tui/feature-plugins/home/tips.tsx +0 -50
  189. package/src/cli/cmd/tui/feature-plugins/sidebar/agents-panel.tsx +0 -95
  190. package/src/cli/cmd/tui/feature-plugins/sidebar/btw-panel.tsx +0 -105
  191. package/src/cli/cmd/tui/feature-plugins/sidebar/commands-panel.tsx +0 -40
  192. package/src/cli/cmd/tui/feature-plugins/sidebar/context.tsx +0 -63
  193. package/src/cli/cmd/tui/feature-plugins/sidebar/files.tsx +0 -62
  194. package/src/cli/cmd/tui/feature-plugins/sidebar/footer.tsx +0 -93
  195. package/src/cli/cmd/tui/feature-plugins/sidebar/git-panel.tsx +0 -36
  196. package/src/cli/cmd/tui/feature-plugins/sidebar/loop-panel.tsx +0 -124
  197. package/src/cli/cmd/tui/feature-plugins/sidebar/lsp.tsx +0 -66
  198. package/src/cli/cmd/tui/feature-plugins/sidebar/mcp.tsx +0 -96
  199. package/src/cli/cmd/tui/feature-plugins/sidebar/session-panel.tsx +0 -48
  200. package/src/cli/cmd/tui/feature-plugins/sidebar/todo.tsx +0 -48
  201. package/src/cli/cmd/tui/feature-plugins/system/plugins.tsx +0 -270
  202. package/src/cli/cmd/tui/plugin/api.tsx +0 -420
  203. package/src/cli/cmd/tui/plugin/index.ts +0 -3
  204. package/src/cli/cmd/tui/plugin/internal.ts +0 -37
  205. package/src/cli/cmd/tui/plugin/runtime.ts +0 -967
  206. package/src/cli/cmd/tui/plugin/slots.tsx +0 -61
  207. package/src/cli/cmd/tui/routes/home.tsx +0 -173
  208. package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +0 -65
  209. package/src/cli/cmd/tui/routes/session/dialog-message.tsx +0 -110
  210. package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +0 -26
  211. package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +0 -47
  212. package/src/cli/cmd/tui/routes/session/footer.tsx +0 -91
  213. package/src/cli/cmd/tui/routes/session/index.tsx +0 -2229
  214. package/src/cli/cmd/tui/routes/session/permission.tsx +0 -685
  215. package/src/cli/cmd/tui/routes/session/question.tsx +0 -467
  216. package/src/cli/cmd/tui/routes/session/sidebar.tsx +0 -72
  217. package/src/cli/cmd/tui/routes/session/subagent-footer.tsx +0 -131
  218. package/src/cli/cmd/tui/thread.ts +0 -232
  219. package/src/cli/cmd/tui/ui/dialog-alert.tsx +0 -59
  220. package/src/cli/cmd/tui/ui/dialog-confirm.tsx +0 -89
  221. package/src/cli/cmd/tui/ui/dialog-export-options.tsx +0 -208
  222. package/src/cli/cmd/tui/ui/dialog-help.tsx +0 -40
  223. package/src/cli/cmd/tui/ui/dialog-prompt.tsx +0 -106
  224. package/src/cli/cmd/tui/ui/dialog-select.tsx +0 -402
  225. package/src/cli/cmd/tui/ui/dialog.tsx +0 -192
  226. package/src/cli/cmd/tui/ui/link.tsx +0 -28
  227. package/src/cli/cmd/tui/ui/spinner.ts +0 -368
  228. package/src/cli/cmd/tui/ui/toast.tsx +0 -100
  229. package/src/cli/cmd/tui/util/clipboard.ts +0 -192
  230. package/src/cli/cmd/tui/util/editor.ts +0 -37
  231. package/src/cli/cmd/tui/util/selection.ts +0 -25
  232. package/src/cli/cmd/tui/util/signal.ts +0 -7
  233. package/src/cli/cmd/tui/util/terminal.ts +0 -114
  234. package/src/cli/cmd/tui/util/transcript.ts +0 -98
  235. package/src/cli/cmd/tui/win32.ts +0 -129
  236. package/src/cli/cmd/tui/worker.ts +0 -204
  237. package/src/cli/cmd/uninstall.ts +0 -353
  238. package/src/cli/cmd/upgrade.ts +0 -73
  239. package/src/cli/cmd/web.ts +0 -81
  240. package/src/cli/effect/prompt.ts +0 -25
  241. package/src/cli/error.ts +0 -46
  242. package/src/cli/logo.ts +0 -7
  243. package/src/cli/network.ts +0 -60
  244. package/src/cli/ui.ts +0 -116
  245. package/src/cli/upgrade.ts +0 -31
  246. package/src/command/index.ts +0 -195
  247. package/src/command/template/initialize.txt +0 -10
  248. package/src/command/template/review.txt +0 -101
  249. package/src/config/config.ts +0 -1693
  250. package/src/config/markdown.ts +0 -99
  251. package/src/config/migrate-tui-config.ts +0 -155
  252. package/src/config/paths.ts +0 -174
  253. package/src/config/tui-schema.ts +0 -36
  254. package/src/config/tui.ts +0 -212
  255. package/src/control-plane/adaptors/index.ts +0 -20
  256. package/src/control-plane/adaptors/worktree.ts +0 -38
  257. package/src/control-plane/schema.ts +0 -17
  258. package/src/control-plane/sse.ts +0 -66
  259. package/src/control-plane/types.ts +0 -21
  260. package/src/control-plane/workspace.sql.ts +0 -17
  261. package/src/control-plane/workspace.ts +0 -154
  262. package/src/cron/index.ts +0 -241
  263. package/src/cron/parse.ts +0 -189
  264. package/src/effect/cross-spawn-spawner.ts +0 -479
  265. package/src/effect/instance-registry.ts +0 -12
  266. package/src/effect/instance-state.ts +0 -47
  267. package/src/effect/run-service.ts +0 -19
  268. package/src/env/index.ts +0 -28
  269. package/src/file/ignore.ts +0 -82
  270. package/src/file/index.ts +0 -693
  271. package/src/file/protected.ts +0 -59
  272. package/src/file/ripgrep.ts +0 -376
  273. package/src/file/time.ts +0 -128
  274. package/src/file/watcher.ts +0 -171
  275. package/src/filesystem/index.ts +0 -226
  276. package/src/flag/flag.ts +0 -157
  277. package/src/format/formatter.ts +0 -396
  278. package/src/format/index.ts +0 -199
  279. package/src/global/index.ts +0 -54
  280. package/src/hooks/index.ts +0 -302
  281. package/src/id/id.ts +0 -85
  282. package/src/ide/index.ts +0 -74
  283. package/src/index.ts +0 -243
  284. package/src/installation/index.ts +0 -363
  285. package/src/lsp/client.ts +0 -252
  286. package/src/lsp/index.ts +0 -558
  287. package/src/lsp/language.ts +0 -120
  288. package/src/lsp/launch.ts +0 -21
  289. package/src/lsp/server.ts +0 -2093
  290. package/src/mcp/auth.ts +0 -181
  291. package/src/mcp/index.ts +0 -926
  292. package/src/mcp/oauth-callback.ts +0 -215
  293. package/src/mcp/oauth-provider.ts +0 -185
  294. package/src/node.ts +0 -1
  295. package/src/patch/index.ts +0 -680
  296. package/src/permission/arity.ts +0 -163
  297. package/src/permission/evaluate.ts +0 -15
  298. package/src/permission/index.ts +0 -322
  299. package/src/permission/schema.ts +0 -17
  300. package/src/plugin/codex.ts +0 -628
  301. package/src/plugin/copilot.ts +0 -343
  302. package/src/plugin/index.ts +0 -331
  303. package/src/plugin/install.ts +0 -384
  304. package/src/plugin/meta.ts +0 -165
  305. package/src/plugin/shared.ts +0 -172
  306. package/src/project/bootstrap.ts +0 -31
  307. package/src/project/instance.ts +0 -167
  308. package/src/project/project.sql.ts +0 -16
  309. package/src/project/project.ts +0 -519
  310. package/src/project/schema.ts +0 -16
  311. package/src/project/state.ts +0 -70
  312. package/src/project/vcs.ts +0 -124
  313. package/src/provider/auth.ts +0 -252
  314. package/src/provider/error.ts +0 -197
  315. package/src/provider/models.ts +0 -138
  316. package/src/provider/provider.ts +0 -1593
  317. package/src/provider/schema.ts +0 -39
  318. package/src/provider/sdk/copilot/README.md +0 -5
  319. package/src/provider/sdk/copilot/chat/convert-to-openai-compatible-chat-messages.ts +0 -170
  320. package/src/provider/sdk/copilot/chat/get-response-metadata.ts +0 -15
  321. package/src/provider/sdk/copilot/chat/map-openai-compatible-finish-reason.ts +0 -19
  322. package/src/provider/sdk/copilot/chat/openai-compatible-api-types.ts +0 -64
  323. package/src/provider/sdk/copilot/chat/openai-compatible-chat-language-model.ts +0 -815
  324. package/src/provider/sdk/copilot/chat/openai-compatible-chat-options.ts +0 -28
  325. package/src/provider/sdk/copilot/chat/openai-compatible-metadata-extractor.ts +0 -44
  326. package/src/provider/sdk/copilot/chat/openai-compatible-prepare-tools.ts +0 -83
  327. package/src/provider/sdk/copilot/copilot-provider.ts +0 -100
  328. package/src/provider/sdk/copilot/index.ts +0 -2
  329. package/src/provider/sdk/copilot/openai-compatible-error.ts +0 -27
  330. package/src/provider/sdk/copilot/responses/convert-to-openai-responses-input.ts +0 -335
  331. package/src/provider/sdk/copilot/responses/map-openai-responses-finish-reason.ts +0 -22
  332. package/src/provider/sdk/copilot/responses/openai-config.ts +0 -18
  333. package/src/provider/sdk/copilot/responses/openai-error.ts +0 -22
  334. package/src/provider/sdk/copilot/responses/openai-responses-api-types.ts +0 -214
  335. package/src/provider/sdk/copilot/responses/openai-responses-language-model.ts +0 -1769
  336. package/src/provider/sdk/copilot/responses/openai-responses-prepare-tools.ts +0 -173
  337. package/src/provider/sdk/copilot/responses/openai-responses-settings.ts +0 -1
  338. package/src/provider/sdk/copilot/responses/tool/code-interpreter.ts +0 -87
  339. package/src/provider/sdk/copilot/responses/tool/file-search.ts +0 -127
  340. package/src/provider/sdk/copilot/responses/tool/image-generation.ts +0 -114
  341. package/src/provider/sdk/copilot/responses/tool/local-shell.ts +0 -64
  342. package/src/provider/sdk/copilot/responses/tool/web-search-preview.ts +0 -103
  343. package/src/provider/sdk/copilot/responses/tool/web-search.ts +0 -102
  344. package/src/provider/toolkit-manifest.ts +0 -110
  345. package/src/provider/transform.ts +0 -1045
  346. package/src/pty/index.ts +0 -397
  347. package/src/pty/schema.ts +0 -17
  348. package/src/question/index.ts +0 -221
  349. package/src/question/schema.ts +0 -17
  350. package/src/server/error.ts +0 -36
  351. package/src/server/event.ts +0 -7
  352. package/src/server/instance.ts +0 -285
  353. package/src/server/mdns.ts +0 -60
  354. package/src/server/middleware.ts +0 -29
  355. package/src/server/projectors.ts +0 -28
  356. package/src/server/router.ts +0 -99
  357. package/src/server/routes/config.ts +0 -92
  358. package/src/server/routes/event.ts +0 -83
  359. package/src/server/routes/experimental.ts +0 -271
  360. package/src/server/routes/file.ts +0 -197
  361. package/src/server/routes/global.ts +0 -339
  362. package/src/server/routes/mcp.ts +0 -225
  363. package/src/server/routes/permission.ts +0 -69
  364. package/src/server/routes/project.ts +0 -118
  365. package/src/server/routes/provider.ts +0 -171
  366. package/src/server/routes/pty.ts +0 -211
  367. package/src/server/routes/question.ts +0 -99
  368. package/src/server/routes/session.ts +0 -1031
  369. package/src/server/routes/tui.ts +0 -379
  370. package/src/server/routes/workspace.ts +0 -94
  371. package/src/server/server.ts +0 -312
  372. package/src/session/compaction.ts +0 -424
  373. package/src/session/index.ts +0 -882
  374. package/src/session/instruction.ts +0 -321
  375. package/src/session/llm.ts +0 -341
  376. package/src/session/message-v2.ts +0 -1030
  377. package/src/session/message.ts +0 -191
  378. package/src/session/overflow.ts +0 -22
  379. package/src/session/processor.ts +0 -554
  380. package/src/session/projectors.ts +0 -135
  381. package/src/session/prompt/anthropic.txt +0 -105
  382. package/src/session/prompt/beast.txt +0 -147
  383. package/src/session/prompt/build-switch.txt +0 -5
  384. package/src/session/prompt/codex.txt +0 -79
  385. package/src/session/prompt/copilot-gpt-5.txt +0 -143
  386. package/src/session/prompt/default.txt +0 -108
  387. package/src/session/prompt/gemini.txt +0 -155
  388. package/src/session/prompt/gpt.txt +0 -107
  389. package/src/session/prompt/max-steps.txt +0 -16
  390. package/src/session/prompt/plan-reminder-anthropic.txt +0 -67
  391. package/src/session/prompt/plan.txt +0 -26
  392. package/src/session/prompt/trinity.txt +0 -97
  393. package/src/session/prompt.ts +0 -2058
  394. package/src/session/retry.ts +0 -106
  395. package/src/session/revert.ts +0 -138
  396. package/src/session/schema.ts +0 -38
  397. package/src/session/session.sql.ts +0 -103
  398. package/src/session/status.ts +0 -102
  399. package/src/session/summary.ts +0 -170
  400. package/src/session/system.ts +0 -74
  401. package/src/session/todo.ts +0 -57
  402. package/src/share/share-next.ts +0 -288
  403. package/src/share/share.sql.ts +0 -13
  404. package/src/shell/shell.ts +0 -73
  405. package/src/skill/discovery.ts +0 -116
  406. package/src/skill/index.ts +0 -284
  407. package/src/skills-marketplace/index.ts +0 -305
  408. package/src/snapshot/index.ts +0 -489
  409. package/src/sql.d.ts +0 -4
  410. package/src/storage/db.bun.ts +0 -8
  411. package/src/storage/db.node.ts +0 -8
  412. package/src/storage/db.ts +0 -177
  413. package/src/storage/json-migration.ts +0 -425
  414. package/src/storage/schema.sql.ts +0 -10
  415. package/src/storage/schema.ts +0 -5
  416. package/src/storage/storage.ts +0 -217
  417. package/src/sync/README.md +0 -179
  418. package/src/sync/event.sql.ts +0 -16
  419. package/src/sync/index.ts +0 -263
  420. package/src/sync/schema.ts +0 -14
  421. package/src/team/index.ts +0 -428
  422. package/src/tool/apply_patch.ts +0 -281
  423. package/src/tool/apply_patch.txt +0 -33
  424. package/src/tool/bash.ts +0 -271
  425. package/src/tool/bash.txt +0 -115
  426. package/src/tool/batch.ts +0 -183
  427. package/src/tool/batch.txt +0 -24
  428. package/src/tool/codesearch.ts +0 -132
  429. package/src/tool/codesearch.txt +0 -12
  430. package/src/tool/cron-create.ts +0 -54
  431. package/src/tool/cron-create.txt +0 -16
  432. package/src/tool/cron-delete.ts +0 -29
  433. package/src/tool/cron-delete.txt +0 -1
  434. package/src/tool/cron-list.ts +0 -41
  435. package/src/tool/cron-list.txt +0 -1
  436. package/src/tool/edit.ts +0 -667
  437. package/src/tool/edit.txt +0 -10
  438. package/src/tool/external-directory.ts +0 -32
  439. package/src/tool/glob.ts +0 -78
  440. package/src/tool/glob.txt +0 -6
  441. package/src/tool/grep.ts +0 -156
  442. package/src/tool/grep.txt +0 -8
  443. package/src/tool/invalid.ts +0 -17
  444. package/src/tool/ls.ts +0 -121
  445. package/src/tool/ls.txt +0 -1
  446. package/src/tool/lsp.ts +0 -97
  447. package/src/tool/lsp.txt +0 -19
  448. package/src/tool/multiedit.ts +0 -46
  449. package/src/tool/multiedit.txt +0 -41
  450. package/src/tool/plan-enter.txt +0 -14
  451. package/src/tool/plan-exit.txt +0 -13
  452. package/src/tool/plan.ts +0 -131
  453. package/src/tool/question.ts +0 -33
  454. package/src/tool/question.txt +0 -10
  455. package/src/tool/read.ts +0 -293
  456. package/src/tool/read.txt +0 -14
  457. package/src/tool/registry.ts +0 -232
  458. package/src/tool/schema.ts +0 -17
  459. package/src/tool/send-message.ts +0 -59
  460. package/src/tool/send-message.txt +0 -7
  461. package/src/tool/skill.ts +0 -105
  462. package/src/tool/task.ts +0 -230
  463. package/src/tool/task.txt +0 -62
  464. package/src/tool/team.ts +0 -235
  465. package/src/tool/team.txt +0 -22
  466. package/src/tool/todo.ts +0 -31
  467. package/src/tool/todowrite.txt +0 -167
  468. package/src/tool/tool.ts +0 -90
  469. package/src/tool/truncate.ts +0 -144
  470. package/src/tool/truncation-dir.ts +0 -4
  471. package/src/tool/webfetch.ts +0 -206
  472. package/src/tool/webfetch.txt +0 -13
  473. package/src/tool/websearch.ts +0 -150
  474. package/src/tool/websearch.txt +0 -14
  475. package/src/tool/write.ts +0 -84
  476. package/src/tool/write.txt +0 -8
  477. package/src/util/abort.ts +0 -35
  478. package/src/util/archive.ts +0 -17
  479. package/src/util/color.ts +0 -19
  480. package/src/util/context.ts +0 -25
  481. package/src/util/data-url.ts +0 -9
  482. package/src/util/defer.ts +0 -12
  483. package/src/util/effect-http-client.ts +0 -11
  484. package/src/util/effect-zod.ts +0 -98
  485. package/src/util/error.ts +0 -77
  486. package/src/util/filesystem.ts +0 -203
  487. package/src/util/flock.ts +0 -333
  488. package/src/util/fn.ts +0 -21
  489. package/src/util/format.ts +0 -20
  490. package/src/util/git.ts +0 -35
  491. package/src/util/glob.ts +0 -34
  492. package/src/util/hash.ts +0 -7
  493. package/src/util/iife.ts +0 -3
  494. package/src/util/keybind.ts +0 -103
  495. package/src/util/lazy.ts +0 -23
  496. package/src/util/locale.ts +0 -81
  497. package/src/util/lock.ts +0 -98
  498. package/src/util/log.ts +0 -182
  499. package/src/util/network.ts +0 -9
  500. package/src/util/process.ts +0 -172
  501. package/src/util/queue.ts +0 -32
  502. package/src/util/record.ts +0 -3
  503. package/src/util/rpc.ts +0 -66
  504. package/src/util/schema.ts +0 -53
  505. package/src/util/scrap.ts +0 -10
  506. package/src/util/signal.ts +0 -12
  507. package/src/util/timeout.ts +0 -14
  508. package/src/util/token.ts +0 -7
  509. package/src/util/update-schema.ts +0 -13
  510. package/src/util/which.ts +0 -14
  511. package/src/util/wildcard.ts +0 -59
  512. package/src/worktree/index.ts +0 -638
  513. package/sst-env.d.ts +0 -10
  514. package/test/AGENTS.md +0 -81
  515. package/test/account/repo.test.ts +0 -326
  516. package/test/account/service.test.ts +0 -282
  517. package/test/acp/agent-interface.test.ts +0 -51
  518. package/test/acp/event-subscription.test.ts +0 -685
  519. package/test/agent/agent.test.ts +0 -717
  520. package/test/auth/auth.test.ts +0 -58
  521. package/test/bun.test.ts +0 -53
  522. package/test/bus/bus-effect.test.ts +0 -164
  523. package/test/bus/bus-integration.test.ts +0 -87
  524. package/test/bus/bus.test.ts +0 -219
  525. package/test/cli/account.test.ts +0 -26
  526. package/test/cli/cmd/tui/prompt-part.test.ts +0 -47
  527. package/test/cli/github-action.test.ts +0 -198
  528. package/test/cli/github-remote.test.ts +0 -80
  529. package/test/cli/import.test.ts +0 -54
  530. package/test/cli/plugin-auth-picker.test.ts +0 -120
  531. package/test/cli/tui/keybind-plugin.test.ts +0 -90
  532. package/test/cli/tui/plugin-add.test.ts +0 -61
  533. package/test/cli/tui/plugin-install.test.ts +0 -95
  534. package/test/cli/tui/plugin-lifecycle.test.ts +0 -225
  535. package/test/cli/tui/plugin-loader-entrypoint.test.ts +0 -189
  536. package/test/cli/tui/plugin-loader-pure.test.ts +0 -71
  537. package/test/cli/tui/plugin-loader.test.ts +0 -563
  538. package/test/cli/tui/plugin-toggle.test.ts +0 -157
  539. package/test/cli/tui/theme-store.test.ts +0 -51
  540. package/test/cli/tui/thread.test.ts +0 -128
  541. package/test/cli/tui/transcript.test.ts +0 -322
  542. package/test/config/agent-color.test.ts +0 -71
  543. package/test/config/config.test.ts +0 -2187
  544. package/test/config/fixtures/empty-frontmatter.md +0 -4
  545. package/test/config/fixtures/frontmatter.md +0 -28
  546. package/test/config/fixtures/markdown-header.md +0 -11
  547. package/test/config/fixtures/no-frontmatter.md +0 -1
  548. package/test/config/fixtures/weird-model-id.md +0 -13
  549. package/test/config/markdown.test.ts +0 -228
  550. package/test/config/tui.test.ts +0 -667
  551. package/test/control-plane/sse.test.ts +0 -56
  552. package/test/effect/cross-spawn-spawner.test.ts +0 -402
  553. package/test/effect/instance-state.test.ts +0 -384
  554. package/test/effect/run-service.test.ts +0 -46
  555. package/test/file/fsmonitor.test.ts +0 -62
  556. package/test/file/ignore.test.ts +0 -10
  557. package/test/file/index.test.ts +0 -946
  558. package/test/file/path-traversal.test.ts +0 -198
  559. package/test/file/ripgrep.test.ts +0 -54
  560. package/test/file/time.test.ts +0 -354
  561. package/test/file/watcher.test.ts +0 -247
  562. package/test/filesystem/filesystem.test.ts +0 -319
  563. package/test/fixture/db.ts +0 -11
  564. package/test/fixture/fixture.test.ts +0 -26
  565. package/test/fixture/fixture.ts +0 -141
  566. package/test/fixture/flock-worker.ts +0 -72
  567. package/test/fixture/lsp/fake-lsp-server.js +0 -77
  568. package/test/fixture/plug-worker.ts +0 -93
  569. package/test/fixture/plugin-meta-worker.ts +0 -26
  570. package/test/fixture/skills/agents-sdk/SKILL.md +0 -152
  571. package/test/fixture/skills/agents-sdk/references/callable.md +0 -92
  572. package/test/fixture/skills/cloudflare/SKILL.md +0 -211
  573. package/test/fixture/skills/index.json +0 -6
  574. package/test/fixture/tui-plugin.ts +0 -335
  575. package/test/fixture/tui-runtime.ts +0 -34
  576. package/test/format/format.test.ts +0 -179
  577. package/test/ide/ide.test.ts +0 -82
  578. package/test/installation/installation.test.ts +0 -151
  579. package/test/keybind.test.ts +0 -421
  580. package/test/lib/effect.ts +0 -37
  581. package/test/lib/filesystem.ts +0 -10
  582. package/test/lsp/client.test.ts +0 -95
  583. package/test/lsp/index.test.ts +0 -55
  584. package/test/lsp/launch.test.ts +0 -22
  585. package/test/lsp/lifecycle.test.ts +0 -147
  586. package/test/mcp/headers.test.ts +0 -153
  587. package/test/mcp/lifecycle.test.ts +0 -750
  588. package/test/mcp/oauth-auto-connect.test.ts +0 -199
  589. package/test/mcp/oauth-browser.test.ts +0 -249
  590. package/test/memory/abort-leak.test.ts +0 -137
  591. package/test/patch/patch.test.ts +0 -348
  592. package/test/permission/arity.test.ts +0 -33
  593. package/test/permission/next.test.ts +0 -1148
  594. package/test/permission-task.test.ts +0 -323
  595. package/test/plugin/auth-override.test.ts +0 -74
  596. package/test/plugin/codex.test.ts +0 -123
  597. package/test/plugin/install-concurrency.test.ts +0 -134
  598. package/test/plugin/install.test.ts +0 -504
  599. package/test/plugin/loader-shared.test.ts +0 -625
  600. package/test/plugin/meta.test.ts +0 -137
  601. package/test/plugin/trigger.test.ts +0 -111
  602. package/test/preload.ts +0 -90
  603. package/test/project/migrate-global.test.ts +0 -140
  604. package/test/project/project.test.ts +0 -459
  605. package/test/project/state.test.ts +0 -115
  606. package/test/project/vcs.test.ts +0 -116
  607. package/test/project/worktree-remove.test.ts +0 -96
  608. package/test/project/worktree.test.ts +0 -173
  609. package/test/provider/amazon-bedrock.test.ts +0 -447
  610. package/test/provider/copilot/convert-to-copilot-messages.test.ts +0 -523
  611. package/test/provider/copilot/copilot-chat-model.test.ts +0 -592
  612. package/test/provider/gitlab-duo.test.ts +0 -412
  613. package/test/provider/provider.test.ts +0 -2284
  614. package/test/provider/transform.test.ts +0 -2758
  615. package/test/pty/pty-output-isolation.test.ts +0 -141
  616. package/test/pty/pty-session.test.ts +0 -92
  617. package/test/question/question.test.ts +0 -453
  618. package/test/server/global-session-list.test.ts +0 -89
  619. package/test/server/project-init-git.test.ts +0 -121
  620. package/test/server/session-list.test.ts +0 -90
  621. package/test/server/session-messages.test.ts +0 -132
  622. package/test/server/session-select.test.ts +0 -78
  623. package/test/session/compaction.test.ts +0 -1094
  624. package/test/session/instruction.test.ts +0 -170
  625. package/test/session/llm.test.ts +0 -882
  626. package/test/session/message-v2.test.ts +0 -957
  627. package/test/session/messages-pagination.test.ts +0 -115
  628. package/test/session/processor-effect.test.ts +0 -838
  629. package/test/session/prompt.test.ts +0 -518
  630. package/test/session/retry.test.ts +0 -232
  631. package/test/session/revert-compact.test.ts +0 -286
  632. package/test/session/session.test.ts +0 -142
  633. package/test/session/structured-output-integration.test.ts +0 -233
  634. package/test/session/structured-output.test.ts +0 -391
  635. package/test/session/system.test.ts +0 -59
  636. package/test/share/share-next.test.ts +0 -76
  637. package/test/skill/discovery.test.ts +0 -116
  638. package/test/skill/skill.test.ts +0 -392
  639. package/test/snapshot/snapshot.test.ts +0 -1235
  640. package/test/storage/db.test.ts +0 -14
  641. package/test/storage/json-migration.test.ts +0 -849
  642. package/test/sync/index.test.ts +0 -191
  643. package/test/tool/__snapshots__/tool.test.ts.snap +0 -9
  644. package/test/tool/apply_patch.test.ts +0 -567
  645. package/test/tool/bash.test.ts +0 -403
  646. package/test/tool/edit.test.ts +0 -681
  647. package/test/tool/external-directory.test.ts +0 -128
  648. package/test/tool/fixtures/large-image.png +0 -0
  649. package/test/tool/fixtures/models-api.json +0 -38413
  650. package/test/tool/grep.test.ts +0 -111
  651. package/test/tool/question.test.ts +0 -108
  652. package/test/tool/read.test.ts +0 -509
  653. package/test/tool/registry.test.ts +0 -126
  654. package/test/tool/skill.test.ts +0 -167
  655. package/test/tool/task.test.ts +0 -49
  656. package/test/tool/truncation.test.ts +0 -161
  657. package/test/tool/webfetch.test.ts +0 -101
  658. package/test/tool/write.test.ts +0 -353
  659. package/test/util/data-url.test.ts +0 -14
  660. package/test/util/effect-zod.test.ts +0 -61
  661. package/test/util/error.test.ts +0 -38
  662. package/test/util/filesystem.test.ts +0 -558
  663. package/test/util/flock.test.ts +0 -383
  664. package/test/util/format.test.ts +0 -59
  665. package/test/util/glob.test.ts +0 -164
  666. package/test/util/iife.test.ts +0 -36
  667. package/test/util/lazy.test.ts +0 -50
  668. package/test/util/lock.test.ts +0 -72
  669. package/test/util/module.test.ts +0 -59
  670. package/test/util/process.test.ts +0 -128
  671. package/test/util/timeout.test.ts +0 -21
  672. package/test/util/which.test.ts +0 -100
  673. package/test/util/wildcard.test.ts +0 -90
  674. package/tsconfig.json +0 -23
@@ -1,2758 +0,0 @@
1
- import { describe, expect, test } from "bun:test"
2
- import { ProviderTransform } from "../../src/provider/transform"
3
- import { ModelID, ProviderID } from "../../src/provider/schema"
4
-
5
- const OUTPUT_TOKEN_MAX = 32000
6
-
7
- describe("ProviderTransform.options - setCacheKey", () => {
8
- const sessionID = "test-session-123"
9
-
10
- const mockModel = {
11
- id: "anthropic/claude-3-5-sonnet",
12
- providerID: "anthropic",
13
- api: {
14
- id: "claude-3-5-sonnet-20241022",
15
- url: "https://api.anthropic.com",
16
- npm: "@ai-sdk/anthropic",
17
- },
18
- name: "Claude 3.5 Sonnet",
19
- capabilities: {
20
- temperature: true,
21
- reasoning: false,
22
- attachment: true,
23
- toolcall: true,
24
- input: { text: true, audio: false, image: true, video: false, pdf: true },
25
- output: { text: true, audio: false, image: false, video: false, pdf: false },
26
- interleaved: false,
27
- },
28
- cost: {
29
- input: 0.003,
30
- output: 0.015,
31
- cache: { read: 0.0003, write: 0.00375 },
32
- },
33
- limit: {
34
- context: 200000,
35
- output: 8192,
36
- },
37
- status: "active",
38
- options: {},
39
- headers: {},
40
- } as any
41
-
42
- test("should set promptCacheKey when providerOptions.setCacheKey is true", () => {
43
- const result = ProviderTransform.options({
44
- model: mockModel,
45
- sessionID,
46
- providerOptions: { setCacheKey: true },
47
- })
48
- expect(result.promptCacheKey).toBe(sessionID)
49
- })
50
-
51
- test("should not set promptCacheKey when providerOptions.setCacheKey is false", () => {
52
- const result = ProviderTransform.options({
53
- model: mockModel,
54
- sessionID,
55
- providerOptions: { setCacheKey: false },
56
- })
57
- expect(result.promptCacheKey).toBeUndefined()
58
- })
59
-
60
- test("should not set promptCacheKey when providerOptions is undefined", () => {
61
- const result = ProviderTransform.options({
62
- model: mockModel,
63
- sessionID,
64
- providerOptions: undefined,
65
- })
66
- expect(result.promptCacheKey).toBeUndefined()
67
- })
68
-
69
- test("should not set promptCacheKey when providerOptions does not have setCacheKey", () => {
70
- const result = ProviderTransform.options({ model: mockModel, sessionID, providerOptions: {} })
71
- expect(result.promptCacheKey).toBeUndefined()
72
- })
73
-
74
- test("should set promptCacheKey for openai provider regardless of setCacheKey", () => {
75
- const openaiModel = {
76
- ...mockModel,
77
- providerID: "openai",
78
- api: {
79
- id: "gpt-4",
80
- url: "https://api.openai.com",
81
- npm: "@ai-sdk/openai",
82
- },
83
- }
84
- const result = ProviderTransform.options({ model: openaiModel, sessionID, providerOptions: {} })
85
- expect(result.promptCacheKey).toBe(sessionID)
86
- })
87
-
88
- test("should set store=false for openai provider", () => {
89
- const openaiModel = {
90
- ...mockModel,
91
- providerID: "openai",
92
- api: {
93
- id: "gpt-4",
94
- url: "https://api.openai.com",
95
- npm: "@ai-sdk/openai",
96
- },
97
- }
98
- const result = ProviderTransform.options({
99
- model: openaiModel,
100
- sessionID,
101
- providerOptions: {},
102
- })
103
- expect(result.store).toBe(false)
104
- })
105
- })
106
-
107
- describe("ProviderTransform.options - google thinkingConfig gating", () => {
108
- const sessionID = "test-session-123"
109
-
110
- const createGoogleModel = (reasoning: boolean, npm: "@ai-sdk/google" | "@ai-sdk/google-vertex") =>
111
- ({
112
- id: `${npm === "@ai-sdk/google" ? "google" : "google-vertex"}/gemini-2.0-flash`,
113
- providerID: npm === "@ai-sdk/google" ? "google" : "google-vertex",
114
- api: {
115
- id: "gemini-2.0-flash",
116
- url: npm === "@ai-sdk/google" ? "https://generativelanguage.googleapis.com" : "https://vertexai.googleapis.com",
117
- npm,
118
- },
119
- name: "Gemini 2.0 Flash",
120
- capabilities: {
121
- temperature: true,
122
- reasoning,
123
- attachment: true,
124
- toolcall: true,
125
- input: { text: true, audio: false, image: true, video: false, pdf: true },
126
- output: { text: true, audio: false, image: false, video: false, pdf: false },
127
- interleaved: false,
128
- },
129
- cost: {
130
- input: 0.001,
131
- output: 0.002,
132
- cache: { read: 0.0001, write: 0.0002 },
133
- },
134
- limit: {
135
- context: 1_000_000,
136
- output: 8192,
137
- },
138
- status: "active",
139
- options: {},
140
- headers: {},
141
- }) as any
142
-
143
- test("does not set thinkingConfig for google models without reasoning capability", () => {
144
- const result = ProviderTransform.options({
145
- model: createGoogleModel(false, "@ai-sdk/google"),
146
- sessionID,
147
- providerOptions: {},
148
- })
149
- expect(result.thinkingConfig).toBeUndefined()
150
- })
151
-
152
- test("sets thinkingConfig for google models with reasoning capability", () => {
153
- const result = ProviderTransform.options({
154
- model: createGoogleModel(true, "@ai-sdk/google"),
155
- sessionID,
156
- providerOptions: {},
157
- })
158
- expect(result.thinkingConfig).toEqual({
159
- includeThoughts: true,
160
- })
161
- })
162
-
163
- test("does not set thinkingConfig for vertex models without reasoning capability", () => {
164
- const result = ProviderTransform.options({
165
- model: createGoogleModel(false, "@ai-sdk/google-vertex"),
166
- sessionID,
167
- providerOptions: {},
168
- })
169
- expect(result.thinkingConfig).toBeUndefined()
170
- })
171
- })
172
-
173
- describe("ProviderTransform.options - gpt-5 textVerbosity", () => {
174
- const sessionID = "test-session-123"
175
-
176
- const createGpt5Model = (apiId: string) =>
177
- ({
178
- id: `openai/${apiId}`,
179
- providerID: "openai",
180
- api: {
181
- id: apiId,
182
- url: "https://api.openai.com",
183
- npm: "@ai-sdk/openai",
184
- },
185
- name: apiId,
186
- capabilities: {
187
- temperature: true,
188
- reasoning: true,
189
- attachment: true,
190
- toolcall: true,
191
- input: { text: true, audio: false, image: true, video: false, pdf: false },
192
- output: { text: true, audio: false, image: false, video: false, pdf: false },
193
- interleaved: false,
194
- },
195
- cost: { input: 0.03, output: 0.06, cache: { read: 0.001, write: 0.002 } },
196
- limit: { context: 128000, output: 4096 },
197
- status: "active",
198
- options: {},
199
- headers: {},
200
- }) as any
201
-
202
- test("gpt-5.2 should have textVerbosity set to low", () => {
203
- const model = createGpt5Model("gpt-5.2")
204
- const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
205
- expect(result.textVerbosity).toBe("low")
206
- })
207
-
208
- test("gpt-5.1 should have textVerbosity set to low", () => {
209
- const model = createGpt5Model("gpt-5.1")
210
- const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
211
- expect(result.textVerbosity).toBe("low")
212
- })
213
-
214
- test("gpt-5.2-chat-latest should NOT have textVerbosity set (only supports medium)", () => {
215
- const model = createGpt5Model("gpt-5.2-chat-latest")
216
- const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
217
- expect(result.textVerbosity).toBeUndefined()
218
- })
219
-
220
- test("gpt-5.1-chat-latest should NOT have textVerbosity set (only supports medium)", () => {
221
- const model = createGpt5Model("gpt-5.1-chat-latest")
222
- const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
223
- expect(result.textVerbosity).toBeUndefined()
224
- })
225
-
226
- test("gpt-5.2-chat should NOT have textVerbosity set", () => {
227
- const model = createGpt5Model("gpt-5.2-chat")
228
- const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
229
- expect(result.textVerbosity).toBeUndefined()
230
- })
231
-
232
- test("gpt-5-chat should NOT have textVerbosity set", () => {
233
- const model = createGpt5Model("gpt-5-chat")
234
- const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
235
- expect(result.textVerbosity).toBeUndefined()
236
- })
237
-
238
- test("gpt-5.2-codex should NOT have textVerbosity set (codex models excluded)", () => {
239
- const model = createGpt5Model("gpt-5.2-codex")
240
- const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
241
- expect(result.textVerbosity).toBeUndefined()
242
- })
243
- })
244
-
245
- describe("ProviderTransform.options - gateway", () => {
246
- const sessionID = "test-session-123"
247
-
248
- const createModel = (id: string) =>
249
- ({
250
- id,
251
- providerID: "vercel",
252
- api: {
253
- id,
254
- url: "https://ai-gateway.vercel.sh/v3/ai",
255
- npm: "@ai-sdk/gateway",
256
- },
257
- name: id,
258
- capabilities: {
259
- temperature: true,
260
- reasoning: true,
261
- attachment: true,
262
- toolcall: true,
263
- input: { text: true, audio: false, image: true, video: false, pdf: true },
264
- output: { text: true, audio: false, image: false, video: false, pdf: false },
265
- interleaved: false,
266
- },
267
- cost: {
268
- input: 0.001,
269
- output: 0.002,
270
- cache: { read: 0.0001, write: 0.0002 },
271
- },
272
- limit: {
273
- context: 200_000,
274
- output: 8192,
275
- },
276
- status: "active",
277
- options: {},
278
- headers: {},
279
- release_date: "2024-01-01",
280
- }) as any
281
-
282
- test("puts gateway defaults under gateway key", () => {
283
- const model = createModel("anthropic/claude-sonnet-4")
284
- const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
285
- expect(result).toEqual({
286
- gateway: {
287
- caching: "auto",
288
- },
289
- })
290
- })
291
- })
292
-
293
- describe("ProviderTransform.providerOptions", () => {
294
- const createModel = (overrides: Partial<any> = {}) =>
295
- ({
296
- id: "test/test-model",
297
- providerID: "test",
298
- api: {
299
- id: "test-model",
300
- url: "https://api.test.com",
301
- npm: "@ai-sdk/openai",
302
- },
303
- name: "Test Model",
304
- capabilities: {
305
- temperature: true,
306
- reasoning: true,
307
- attachment: true,
308
- toolcall: true,
309
- input: { text: true, audio: false, image: true, video: false, pdf: false },
310
- output: { text: true, audio: false, image: false, video: false, pdf: false },
311
- interleaved: false,
312
- },
313
- cost: {
314
- input: 0.001,
315
- output: 0.002,
316
- cache: { read: 0.0001, write: 0.0002 },
317
- },
318
- limit: {
319
- context: 200_000,
320
- output: 64_000,
321
- },
322
- status: "active",
323
- options: {},
324
- headers: {},
325
- release_date: "2024-01-01",
326
- ...overrides,
327
- }) as any
328
-
329
- test("uses sdk key for non-gateway models", () => {
330
- const model = createModel({
331
- providerID: "my-bedrock",
332
- api: {
333
- id: "anthropic.claude-sonnet-4",
334
- url: "https://bedrock.aws",
335
- npm: "@ai-sdk/amazon-bedrock",
336
- },
337
- })
338
-
339
- expect(ProviderTransform.providerOptions(model, { cachePoint: { type: "default" } })).toEqual({
340
- bedrock: { cachePoint: { type: "default" } },
341
- })
342
- })
343
-
344
- test("uses gateway model provider slug for gateway models", () => {
345
- const model = createModel({
346
- providerID: "vercel",
347
- api: {
348
- id: "anthropic/claude-sonnet-4",
349
- url: "https://ai-gateway.vercel.sh/v3/ai",
350
- npm: "@ai-sdk/gateway",
351
- },
352
- })
353
-
354
- expect(ProviderTransform.providerOptions(model, { thinking: { type: "enabled", budgetTokens: 12_000 } })).toEqual({
355
- anthropic: { thinking: { type: "enabled", budgetTokens: 12_000 } },
356
- })
357
- })
358
-
359
- test("falls back to gateway key when gateway api id is unscoped", () => {
360
- const model = createModel({
361
- id: "anthropic/claude-sonnet-4",
362
- providerID: "vercel",
363
- api: {
364
- id: "claude-sonnet-4",
365
- url: "https://ai-gateway.vercel.sh/v3/ai",
366
- npm: "@ai-sdk/gateway",
367
- },
368
- })
369
-
370
- expect(ProviderTransform.providerOptions(model, { thinking: { type: "enabled", budgetTokens: 12_000 } })).toEqual({
371
- gateway: { thinking: { type: "enabled", budgetTokens: 12_000 } },
372
- })
373
- })
374
-
375
- test("splits gateway routing options from provider-specific options", () => {
376
- const model = createModel({
377
- providerID: "vercel",
378
- api: {
379
- id: "anthropic/claude-sonnet-4",
380
- url: "https://ai-gateway.vercel.sh/v3/ai",
381
- npm: "@ai-sdk/gateway",
382
- },
383
- })
384
-
385
- expect(
386
- ProviderTransform.providerOptions(model, {
387
- gateway: { order: ["vertex", "anthropic"] },
388
- thinking: { type: "enabled", budgetTokens: 12_000 },
389
- }),
390
- ).toEqual({
391
- gateway: { order: ["vertex", "anthropic"] },
392
- anthropic: { thinking: { type: "enabled", budgetTokens: 12_000 } },
393
- } as any)
394
- })
395
-
396
- test("falls back to gateway key when model id has no provider slug", () => {
397
- const model = createModel({
398
- id: "claude-sonnet-4",
399
- providerID: "vercel",
400
- api: {
401
- id: "claude-sonnet-4",
402
- url: "https://ai-gateway.vercel.sh/v3/ai",
403
- npm: "@ai-sdk/gateway",
404
- },
405
- })
406
-
407
- expect(ProviderTransform.providerOptions(model, { reasoningEffort: "high" })).toEqual({
408
- gateway: { reasoningEffort: "high" },
409
- })
410
- })
411
-
412
- test("maps amazon slug to bedrock for provider options", () => {
413
- const model = createModel({
414
- providerID: "vercel",
415
- api: {
416
- id: "amazon/nova-2-lite",
417
- url: "https://ai-gateway.vercel.sh/v3/ai",
418
- npm: "@ai-sdk/gateway",
419
- },
420
- })
421
-
422
- expect(ProviderTransform.providerOptions(model, { reasoningConfig: { type: "enabled" } })).toEqual({
423
- bedrock: { reasoningConfig: { type: "enabled" } },
424
- })
425
- })
426
-
427
- test("uses groq slug for groq models", () => {
428
- const model = createModel({
429
- providerID: "vercel",
430
- api: {
431
- id: "groq/llama-3.3-70b-versatile",
432
- url: "https://ai-gateway.vercel.sh/v3/ai",
433
- npm: "@ai-sdk/gateway",
434
- },
435
- })
436
-
437
- expect(ProviderTransform.providerOptions(model, { reasoningFormat: "parsed" })).toEqual({
438
- groq: { reasoningFormat: "parsed" },
439
- })
440
- })
441
- })
442
-
443
- describe("ProviderTransform.schema - gemini array items", () => {
444
- test("adds missing items for array properties", () => {
445
- const geminiModel = {
446
- providerID: "google",
447
- api: {
448
- id: "gemini-3-pro",
449
- },
450
- } as any
451
-
452
- const schema = {
453
- type: "object",
454
- properties: {
455
- nodes: { type: "array" },
456
- edges: { type: "array", items: { type: "string" } },
457
- },
458
- } as any
459
-
460
- const result = ProviderTransform.schema(geminiModel, schema) as any
461
-
462
- expect(result.properties.nodes.items).toBeDefined()
463
- expect(result.properties.edges.items.type).toBe("string")
464
- })
465
- })
466
-
467
- describe("ProviderTransform.schema - gemini nested array items", () => {
468
- const geminiModel = {
469
- providerID: "google",
470
- api: {
471
- id: "gemini-3-pro",
472
- },
473
- } as any
474
-
475
- test("adds type to 2D array with empty inner items", () => {
476
- const schema = {
477
- type: "object",
478
- properties: {
479
- values: {
480
- type: "array",
481
- items: {
482
- type: "array",
483
- items: {}, // Empty items object
484
- },
485
- },
486
- },
487
- } as any
488
-
489
- const result = ProviderTransform.schema(geminiModel, schema) as any
490
-
491
- // Inner items should have a default type
492
- expect(result.properties.values.items.items.type).toBe("string")
493
- })
494
-
495
- test("adds items and type to 2D array with missing inner items", () => {
496
- const schema = {
497
- type: "object",
498
- properties: {
499
- data: {
500
- type: "array",
501
- items: { type: "array" }, // No items at all
502
- },
503
- },
504
- } as any
505
-
506
- const result = ProviderTransform.schema(geminiModel, schema) as any
507
-
508
- expect(result.properties.data.items.items).toBeDefined()
509
- expect(result.properties.data.items.items.type).toBe("string")
510
- })
511
-
512
- test("handles deeply nested arrays (3D)", () => {
513
- const schema = {
514
- type: "object",
515
- properties: {
516
- matrix: {
517
- type: "array",
518
- items: {
519
- type: "array",
520
- items: {
521
- type: "array",
522
- // No items
523
- },
524
- },
525
- },
526
- },
527
- } as any
528
-
529
- const result = ProviderTransform.schema(geminiModel, schema) as any
530
-
531
- expect(result.properties.matrix.items.items.items).toBeDefined()
532
- expect(result.properties.matrix.items.items.items.type).toBe("string")
533
- })
534
-
535
- test("preserves existing item types in nested arrays", () => {
536
- const schema = {
537
- type: "object",
538
- properties: {
539
- numbers: {
540
- type: "array",
541
- items: {
542
- type: "array",
543
- items: { type: "number" }, // Has explicit type
544
- },
545
- },
546
- },
547
- } as any
548
-
549
- const result = ProviderTransform.schema(geminiModel, schema) as any
550
-
551
- // Should preserve the explicit type
552
- expect(result.properties.numbers.items.items.type).toBe("number")
553
- })
554
-
555
- test("handles mixed nested structures with objects and arrays", () => {
556
- const schema = {
557
- type: "object",
558
- properties: {
559
- spreadsheetData: {
560
- type: "object",
561
- properties: {
562
- rows: {
563
- type: "array",
564
- items: {
565
- type: "array",
566
- items: {}, // Empty items
567
- },
568
- },
569
- },
570
- },
571
- },
572
- } as any
573
-
574
- const result = ProviderTransform.schema(geminiModel, schema) as any
575
-
576
- expect(result.properties.spreadsheetData.properties.rows.items.items.type).toBe("string")
577
- })
578
- })
579
-
580
- describe("ProviderTransform.schema - gemini combiner nodes", () => {
581
- const geminiModel = {
582
- providerID: "google",
583
- api: {
584
- id: "gemini-3-pro",
585
- },
586
- } as any
587
-
588
- const walk = (node: any, cb: (node: any, path: (string | number)[]) => void, path: (string | number)[] = []) => {
589
- if (node === null || typeof node !== "object") {
590
- return
591
- }
592
- if (Array.isArray(node)) {
593
- node.forEach((item, i) => walk(item, cb, [...path, i]))
594
- return
595
- }
596
- cb(node, path)
597
- Object.entries(node).forEach(([key, value]) => walk(value, cb, [...path, key]))
598
- }
599
-
600
- test("keeps edits.items.anyOf without adding type", () => {
601
- const schema = {
602
- type: "object",
603
- properties: {
604
- edits: {
605
- type: "array",
606
- items: {
607
- anyOf: [
608
- {
609
- type: "object",
610
- properties: {
611
- old_string: { type: "string" },
612
- new_string: { type: "string" },
613
- },
614
- required: ["old_string", "new_string"],
615
- },
616
- {
617
- type: "object",
618
- properties: {
619
- old_string: { type: "string" },
620
- new_string: { type: "string" },
621
- replace_all: { type: "boolean" },
622
- },
623
- required: ["old_string", "new_string"],
624
- },
625
- ],
626
- },
627
- },
628
- },
629
- required: ["edits"],
630
- } as any
631
-
632
- const result = ProviderTransform.schema(geminiModel, schema) as any
633
-
634
- expect(Array.isArray(result.properties.edits.items.anyOf)).toBe(true)
635
- expect(result.properties.edits.items.type).toBeUndefined()
636
- })
637
-
638
- test("does not add sibling keys to combiner nodes during sanitize", () => {
639
- const schema = {
640
- type: "object",
641
- properties: {
642
- edits: {
643
- type: "array",
644
- items: {
645
- anyOf: [{ type: "string" }, { type: "number" }],
646
- },
647
- },
648
- value: {
649
- oneOf: [{ type: "string" }, { type: "boolean" }],
650
- },
651
- meta: {
652
- allOf: [
653
- {
654
- type: "object",
655
- properties: { a: { type: "string" } },
656
- },
657
- {
658
- type: "object",
659
- properties: { b: { type: "string" } },
660
- },
661
- ],
662
- },
663
- },
664
- } as any
665
- const input = JSON.parse(JSON.stringify(schema))
666
- const result = ProviderTransform.schema(geminiModel, schema) as any
667
-
668
- walk(result, (node, path) => {
669
- const hasCombiner = Array.isArray(node.anyOf) || Array.isArray(node.oneOf) || Array.isArray(node.allOf)
670
- if (!hasCombiner) {
671
- return
672
- }
673
- const before = path.reduce((acc: any, key) => acc?.[key], input)
674
- const added = Object.keys(node).filter((key) => !(key in before))
675
- expect(added).toEqual([])
676
- })
677
- })
678
- })
679
-
680
- describe("ProviderTransform.schema - gemini non-object properties removal", () => {
681
- const geminiModel = {
682
- providerID: "google",
683
- api: {
684
- id: "gemini-3-pro",
685
- },
686
- } as any
687
-
688
- test("removes properties from non-object types", () => {
689
- const schema = {
690
- type: "object",
691
- properties: {
692
- data: {
693
- type: "string",
694
- properties: { invalid: { type: "string" } },
695
- },
696
- },
697
- } as any
698
-
699
- const result = ProviderTransform.schema(geminiModel, schema) as any
700
-
701
- expect(result.properties.data.type).toBe("string")
702
- expect(result.properties.data.properties).toBeUndefined()
703
- })
704
-
705
- test("removes required from non-object types", () => {
706
- const schema = {
707
- type: "object",
708
- properties: {
709
- data: {
710
- type: "array",
711
- items: { type: "string" },
712
- required: ["invalid"],
713
- },
714
- },
715
- } as any
716
-
717
- const result = ProviderTransform.schema(geminiModel, schema) as any
718
-
719
- expect(result.properties.data.type).toBe("array")
720
- expect(result.properties.data.required).toBeUndefined()
721
- })
722
-
723
- test("removes properties and required from nested non-object types", () => {
724
- const schema = {
725
- type: "object",
726
- properties: {
727
- outer: {
728
- type: "object",
729
- properties: {
730
- inner: {
731
- type: "number",
732
- properties: { bad: { type: "string" } },
733
- required: ["bad"],
734
- },
735
- },
736
- },
737
- },
738
- } as any
739
-
740
- const result = ProviderTransform.schema(geminiModel, schema) as any
741
-
742
- expect(result.properties.outer.properties.inner.type).toBe("number")
743
- expect(result.properties.outer.properties.inner.properties).toBeUndefined()
744
- expect(result.properties.outer.properties.inner.required).toBeUndefined()
745
- })
746
-
747
- test("keeps properties and required on object types", () => {
748
- const schema = {
749
- type: "object",
750
- properties: {
751
- data: {
752
- type: "object",
753
- properties: { name: { type: "string" } },
754
- required: ["name"],
755
- },
756
- },
757
- } as any
758
-
759
- const result = ProviderTransform.schema(geminiModel, schema) as any
760
-
761
- expect(result.properties.data.type).toBe("object")
762
- expect(result.properties.data.properties).toBeDefined()
763
- expect(result.properties.data.required).toEqual(["name"])
764
- })
765
-
766
- test("does not affect non-gemini providers", () => {
767
- const openaiModel = {
768
- providerID: "openai",
769
- api: {
770
- id: "gpt-4",
771
- },
772
- } as any
773
-
774
- const schema = {
775
- type: "object",
776
- properties: {
777
- data: {
778
- type: "string",
779
- properties: { invalid: { type: "string" } },
780
- },
781
- },
782
- } as any
783
-
784
- const result = ProviderTransform.schema(openaiModel, schema) as any
785
-
786
- expect(result.properties.data.properties).toBeDefined()
787
- })
788
- })
789
-
790
- describe("ProviderTransform.message - DeepSeek reasoning content", () => {
791
- test("DeepSeek with tool calls includes reasoning_content in providerOptions", () => {
792
- const msgs = [
793
- {
794
- role: "assistant",
795
- content: [
796
- { type: "reasoning", text: "Let me think about this..." },
797
- {
798
- type: "tool-call",
799
- toolCallId: "test",
800
- toolName: "bash",
801
- input: { command: "echo hello" },
802
- },
803
- ],
804
- },
805
- ] as any[]
806
-
807
- const result = ProviderTransform.message(
808
- msgs,
809
- {
810
- id: ModelID.make("deepseek/deepseek-chat"),
811
- providerID: ProviderID.make("deepseek"),
812
- api: {
813
- id: "deepseek-chat",
814
- url: "https://api.deepseek.com",
815
- npm: "@ai-sdk/openai-compatible",
816
- },
817
- name: "DeepSeek Chat",
818
- capabilities: {
819
- temperature: true,
820
- reasoning: true,
821
- attachment: false,
822
- toolcall: true,
823
- input: { text: true, audio: false, image: false, video: false, pdf: false },
824
- output: { text: true, audio: false, image: false, video: false, pdf: false },
825
- interleaved: {
826
- field: "reasoning_content",
827
- },
828
- },
829
- cost: {
830
- input: 0.001,
831
- output: 0.002,
832
- cache: { read: 0.0001, write: 0.0002 },
833
- },
834
- limit: {
835
- context: 128000,
836
- output: 8192,
837
- },
838
- status: "active",
839
- options: {},
840
- headers: {},
841
- release_date: "2023-04-01",
842
- },
843
- {},
844
- )
845
-
846
- expect(result).toHaveLength(1)
847
- expect(result[0].content).toEqual([
848
- {
849
- type: "tool-call",
850
- toolCallId: "test",
851
- toolName: "bash",
852
- input: { command: "echo hello" },
853
- },
854
- ])
855
- expect(result[0].providerOptions?.openaiCompatible?.reasoning_content).toBe("Let me think about this...")
856
- })
857
-
858
- test("Non-DeepSeek providers leave reasoning content unchanged", () => {
859
- const msgs = [
860
- {
861
- role: "assistant",
862
- content: [
863
- { type: "reasoning", text: "Should not be processed" },
864
- { type: "text", text: "Answer" },
865
- ],
866
- },
867
- ] as any[]
868
-
869
- const result = ProviderTransform.message(
870
- msgs,
871
- {
872
- id: ModelID.make("openai/gpt-4"),
873
- providerID: ProviderID.make("openai"),
874
- api: {
875
- id: "gpt-4",
876
- url: "https://api.openai.com",
877
- npm: "@ai-sdk/openai",
878
- },
879
- name: "GPT-4",
880
- capabilities: {
881
- temperature: true,
882
- reasoning: false,
883
- attachment: true,
884
- toolcall: true,
885
- input: { text: true, audio: false, image: true, video: false, pdf: false },
886
- output: { text: true, audio: false, image: false, video: false, pdf: false },
887
- interleaved: false,
888
- },
889
- cost: {
890
- input: 0.03,
891
- output: 0.06,
892
- cache: { read: 0.001, write: 0.002 },
893
- },
894
- limit: {
895
- context: 128000,
896
- output: 4096,
897
- },
898
- status: "active",
899
- options: {},
900
- headers: {},
901
- release_date: "2023-04-01",
902
- },
903
- {},
904
- )
905
-
906
- expect(result[0].content).toEqual([
907
- { type: "reasoning", text: "Should not be processed" },
908
- { type: "text", text: "Answer" },
909
- ])
910
- expect(result[0].providerOptions?.openaiCompatible?.reasoning_content).toBeUndefined()
911
- })
912
- })
913
-
914
- describe("ProviderTransform.message - empty image handling", () => {
915
- const mockModel = {
916
- id: "anthropic/claude-3-5-sonnet",
917
- providerID: "anthropic",
918
- api: {
919
- id: "claude-3-5-sonnet-20241022",
920
- url: "https://api.anthropic.com",
921
- npm: "@ai-sdk/anthropic",
922
- },
923
- name: "Claude 3.5 Sonnet",
924
- capabilities: {
925
- temperature: true,
926
- reasoning: false,
927
- attachment: true,
928
- toolcall: true,
929
- input: { text: true, audio: false, image: true, video: false, pdf: true },
930
- output: { text: true, audio: false, image: false, video: false, pdf: false },
931
- interleaved: false,
932
- },
933
- cost: {
934
- input: 0.003,
935
- output: 0.015,
936
- cache: { read: 0.0003, write: 0.00375 },
937
- },
938
- limit: {
939
- context: 200000,
940
- output: 8192,
941
- },
942
- status: "active",
943
- options: {},
944
- headers: {},
945
- } as any
946
-
947
- test("should replace empty base64 image with error text", () => {
948
- const msgs = [
949
- {
950
- role: "user",
951
- content: [
952
- { type: "text", text: "What is in this image?" },
953
- { type: "image", image: "data:image/png;base64," },
954
- ],
955
- },
956
- ] as any[]
957
-
958
- const result = ProviderTransform.message(msgs, mockModel, {})
959
-
960
- expect(result).toHaveLength(1)
961
- expect(result[0].content).toHaveLength(2)
962
- expect(result[0].content[0]).toEqual({ type: "text", text: "What is in this image?" })
963
- expect(result[0].content[1]).toEqual({
964
- type: "text",
965
- text: "ERROR: Image file is empty or corrupted. Please provide a valid image.",
966
- })
967
- })
968
-
969
- test("should keep valid base64 images unchanged", () => {
970
- const validBase64 =
971
- "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
972
- const msgs = [
973
- {
974
- role: "user",
975
- content: [
976
- { type: "text", text: "What is in this image?" },
977
- { type: "image", image: `data:image/png;base64,${validBase64}` },
978
- ],
979
- },
980
- ] as any[]
981
-
982
- const result = ProviderTransform.message(msgs, mockModel, {})
983
-
984
- expect(result).toHaveLength(1)
985
- expect(result[0].content).toHaveLength(2)
986
- expect(result[0].content[0]).toEqual({ type: "text", text: "What is in this image?" })
987
- expect(result[0].content[1]).toEqual({ type: "image", image: `data:image/png;base64,${validBase64}` })
988
- })
989
-
990
- test("should handle mixed valid and empty images", () => {
991
- const validBase64 =
992
- "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
993
- const msgs = [
994
- {
995
- role: "user",
996
- content: [
997
- { type: "text", text: "Compare these images" },
998
- { type: "image", image: `data:image/png;base64,${validBase64}` },
999
- { type: "image", image: "data:image/jpeg;base64," },
1000
- ],
1001
- },
1002
- ] as any[]
1003
-
1004
- const result = ProviderTransform.message(msgs, mockModel, {})
1005
-
1006
- expect(result).toHaveLength(1)
1007
- expect(result[0].content).toHaveLength(3)
1008
- expect(result[0].content[0]).toEqual({ type: "text", text: "Compare these images" })
1009
- expect(result[0].content[1]).toEqual({ type: "image", image: `data:image/png;base64,${validBase64}` })
1010
- expect(result[0].content[2]).toEqual({
1011
- type: "text",
1012
- text: "ERROR: Image file is empty or corrupted. Please provide a valid image.",
1013
- })
1014
- })
1015
- })
1016
-
1017
- describe("ProviderTransform.message - anthropic empty content filtering", () => {
1018
- const anthropicModel = {
1019
- id: "anthropic/claude-3-5-sonnet",
1020
- providerID: "anthropic",
1021
- api: {
1022
- id: "claude-3-5-sonnet-20241022",
1023
- url: "https://api.anthropic.com",
1024
- npm: "@ai-sdk/anthropic",
1025
- },
1026
- name: "Claude 3.5 Sonnet",
1027
- capabilities: {
1028
- temperature: true,
1029
- reasoning: false,
1030
- attachment: true,
1031
- toolcall: true,
1032
- input: { text: true, audio: false, image: true, video: false, pdf: true },
1033
- output: { text: true, audio: false, image: false, video: false, pdf: false },
1034
- interleaved: false,
1035
- },
1036
- cost: {
1037
- input: 0.003,
1038
- output: 0.015,
1039
- cache: { read: 0.0003, write: 0.00375 },
1040
- },
1041
- limit: {
1042
- context: 200000,
1043
- output: 8192,
1044
- },
1045
- status: "active",
1046
- options: {},
1047
- headers: {},
1048
- } as any
1049
-
1050
- test("filters out messages with empty string content", () => {
1051
- const msgs = [
1052
- { role: "user", content: "Hello" },
1053
- { role: "assistant", content: "" },
1054
- { role: "user", content: "World" },
1055
- ] as any[]
1056
-
1057
- const result = ProviderTransform.message(msgs, anthropicModel, {})
1058
-
1059
- expect(result).toHaveLength(2)
1060
- expect(result[0].content).toBe("Hello")
1061
- expect(result[1].content).toBe("World")
1062
- })
1063
-
1064
- test("filters out empty text parts from array content", () => {
1065
- const msgs = [
1066
- {
1067
- role: "assistant",
1068
- content: [
1069
- { type: "text", text: "" },
1070
- { type: "text", text: "Hello" },
1071
- { type: "text", text: "" },
1072
- ],
1073
- },
1074
- ] as any[]
1075
-
1076
- const result = ProviderTransform.message(msgs, anthropicModel, {})
1077
-
1078
- expect(result).toHaveLength(1)
1079
- expect(result[0].content).toHaveLength(1)
1080
- expect(result[0].content[0]).toEqual({ type: "text", text: "Hello" })
1081
- })
1082
-
1083
- test("filters out empty reasoning parts from array content", () => {
1084
- const msgs = [
1085
- {
1086
- role: "assistant",
1087
- content: [
1088
- { type: "reasoning", text: "" },
1089
- { type: "text", text: "Answer" },
1090
- { type: "reasoning", text: "" },
1091
- ],
1092
- },
1093
- ] as any[]
1094
-
1095
- const result = ProviderTransform.message(msgs, anthropicModel, {})
1096
-
1097
- expect(result).toHaveLength(1)
1098
- expect(result[0].content).toHaveLength(1)
1099
- expect(result[0].content[0]).toEqual({ type: "text", text: "Answer" })
1100
- })
1101
-
1102
- test("removes entire message when all parts are empty", () => {
1103
- const msgs = [
1104
- { role: "user", content: "Hello" },
1105
- {
1106
- role: "assistant",
1107
- content: [
1108
- { type: "text", text: "" },
1109
- { type: "reasoning", text: "" },
1110
- ],
1111
- },
1112
- { role: "user", content: "World" },
1113
- ] as any[]
1114
-
1115
- const result = ProviderTransform.message(msgs, anthropicModel, {})
1116
-
1117
- expect(result).toHaveLength(2)
1118
- expect(result[0].content).toBe("Hello")
1119
- expect(result[1].content).toBe("World")
1120
- })
1121
-
1122
- test("keeps non-text/reasoning parts even if text parts are empty", () => {
1123
- const msgs = [
1124
- {
1125
- role: "assistant",
1126
- content: [
1127
- { type: "text", text: "" },
1128
- { type: "tool-call", toolCallId: "123", toolName: "bash", input: { command: "ls" } },
1129
- ],
1130
- },
1131
- ] as any[]
1132
-
1133
- const result = ProviderTransform.message(msgs, anthropicModel, {})
1134
-
1135
- expect(result).toHaveLength(1)
1136
- expect(result[0].content).toHaveLength(1)
1137
- expect(result[0].content[0]).toEqual({
1138
- type: "tool-call",
1139
- toolCallId: "123",
1140
- toolName: "bash",
1141
- input: { command: "ls" },
1142
- })
1143
- })
1144
-
1145
- test("keeps messages with valid text alongside empty parts", () => {
1146
- const msgs = [
1147
- {
1148
- role: "assistant",
1149
- content: [
1150
- { type: "reasoning", text: "Thinking..." },
1151
- { type: "text", text: "" },
1152
- { type: "text", text: "Result" },
1153
- ],
1154
- },
1155
- ] as any[]
1156
-
1157
- const result = ProviderTransform.message(msgs, anthropicModel, {})
1158
-
1159
- expect(result).toHaveLength(1)
1160
- expect(result[0].content).toHaveLength(2)
1161
- expect(result[0].content[0]).toEqual({ type: "reasoning", text: "Thinking..." })
1162
- expect(result[0].content[1]).toEqual({ type: "text", text: "Result" })
1163
- })
1164
-
1165
- test("filters empty content for bedrock provider", () => {
1166
- const bedrockModel = {
1167
- ...anthropicModel,
1168
- id: "amazon-bedrock/anthropic.claude-opus-4-6",
1169
- providerID: "amazon-bedrock",
1170
- api: {
1171
- id: "anthropic.claude-opus-4-6",
1172
- url: "https://bedrock-runtime.us-east-1.amazonaws.com",
1173
- npm: "@ai-sdk/amazon-bedrock",
1174
- },
1175
- }
1176
-
1177
- const msgs = [
1178
- { role: "user", content: "Hello" },
1179
- { role: "assistant", content: "" },
1180
- {
1181
- role: "assistant",
1182
- content: [
1183
- { type: "text", text: "" },
1184
- { type: "text", text: "Answer" },
1185
- ],
1186
- },
1187
- ] as any[]
1188
-
1189
- const result = ProviderTransform.message(msgs, bedrockModel, {})
1190
-
1191
- expect(result).toHaveLength(2)
1192
- expect(result[0].content).toBe("Hello")
1193
- expect(result[1].content).toHaveLength(1)
1194
- expect(result[1].content[0]).toEqual({ type: "text", text: "Answer" })
1195
- })
1196
-
1197
- test("does not filter for non-anthropic providers", () => {
1198
- const openaiModel = {
1199
- ...anthropicModel,
1200
- providerID: "openai",
1201
- api: {
1202
- id: "gpt-4",
1203
- url: "https://api.openai.com",
1204
- npm: "@ai-sdk/openai",
1205
- },
1206
- }
1207
-
1208
- const msgs = [
1209
- { role: "assistant", content: "" },
1210
- {
1211
- role: "assistant",
1212
- content: [{ type: "text", text: "" }],
1213
- },
1214
- ] as any[]
1215
-
1216
- const result = ProviderTransform.message(msgs, openaiModel, {})
1217
-
1218
- expect(result).toHaveLength(2)
1219
- expect(result[0].content).toBe("")
1220
- expect(result[1].content).toHaveLength(1)
1221
- })
1222
- })
1223
-
1224
- describe("ProviderTransform.message - strip openai metadata when store=false", () => {
1225
- const openaiModel = {
1226
- id: "openai/gpt-5",
1227
- providerID: "openai",
1228
- api: {
1229
- id: "gpt-5",
1230
- url: "https://api.openai.com",
1231
- npm: "@ai-sdk/openai",
1232
- },
1233
- name: "GPT-5",
1234
- capabilities: {
1235
- temperature: true,
1236
- reasoning: true,
1237
- attachment: true,
1238
- toolcall: true,
1239
- input: { text: true, audio: false, image: true, video: false, pdf: false },
1240
- output: { text: true, audio: false, image: false, video: false, pdf: false },
1241
- interleaved: false,
1242
- },
1243
- cost: { input: 0.03, output: 0.06, cache: { read: 0.001, write: 0.002 } },
1244
- limit: { context: 128000, output: 4096 },
1245
- status: "active",
1246
- options: {},
1247
- headers: {},
1248
- } as any
1249
-
1250
- test("preserves itemId and reasoningEncryptedContent when store=false", () => {
1251
- const msgs = [
1252
- {
1253
- role: "assistant",
1254
- content: [
1255
- {
1256
- type: "reasoning",
1257
- text: "thinking...",
1258
- providerOptions: {
1259
- openai: {
1260
- itemId: "rs_123",
1261
- reasoningEncryptedContent: "encrypted",
1262
- },
1263
- },
1264
- },
1265
- {
1266
- type: "text",
1267
- text: "Hello",
1268
- providerOptions: {
1269
- openai: {
1270
- itemId: "msg_456",
1271
- },
1272
- },
1273
- },
1274
- ],
1275
- },
1276
- ] as any[]
1277
-
1278
- const result = ProviderTransform.message(msgs, openaiModel, { store: false }) as any[]
1279
-
1280
- expect(result).toHaveLength(1)
1281
- expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("rs_123")
1282
- expect(result[0].content[1].providerOptions?.openai?.itemId).toBe("msg_456")
1283
- })
1284
-
1285
- test("preserves itemId and reasoningEncryptedContent when store=false even when not openai", () => {
1286
- const zenModel = {
1287
- ...openaiModel,
1288
- providerID: "zen",
1289
- }
1290
- const msgs = [
1291
- {
1292
- role: "assistant",
1293
- content: [
1294
- {
1295
- type: "reasoning",
1296
- text: "thinking...",
1297
- providerOptions: {
1298
- openai: {
1299
- itemId: "rs_123",
1300
- reasoningEncryptedContent: "encrypted",
1301
- },
1302
- },
1303
- },
1304
- {
1305
- type: "text",
1306
- text: "Hello",
1307
- providerOptions: {
1308
- openai: {
1309
- itemId: "msg_456",
1310
- },
1311
- },
1312
- },
1313
- ],
1314
- },
1315
- ] as any[]
1316
-
1317
- const result = ProviderTransform.message(msgs, zenModel, { store: false }) as any[]
1318
-
1319
- expect(result).toHaveLength(1)
1320
- expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("rs_123")
1321
- expect(result[0].content[1].providerOptions?.openai?.itemId).toBe("msg_456")
1322
- })
1323
-
1324
- test("preserves other openai options including itemId", () => {
1325
- const msgs = [
1326
- {
1327
- role: "assistant",
1328
- content: [
1329
- {
1330
- type: "text",
1331
- text: "Hello",
1332
- providerOptions: {
1333
- openai: {
1334
- itemId: "msg_123",
1335
- otherOption: "value",
1336
- },
1337
- },
1338
- },
1339
- ],
1340
- },
1341
- ] as any[]
1342
-
1343
- const result = ProviderTransform.message(msgs, openaiModel, { store: false }) as any[]
1344
-
1345
- expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
1346
- expect(result[0].content[0].providerOptions?.openai?.otherOption).toBe("value")
1347
- })
1348
-
1349
- test("preserves metadata for openai package when store is true", () => {
1350
- const msgs = [
1351
- {
1352
- role: "assistant",
1353
- content: [
1354
- {
1355
- type: "text",
1356
- text: "Hello",
1357
- providerOptions: {
1358
- openai: {
1359
- itemId: "msg_123",
1360
- },
1361
- },
1362
- },
1363
- ],
1364
- },
1365
- ] as any[]
1366
-
1367
- // openai package preserves itemId regardless of store value
1368
- const result = ProviderTransform.message(msgs, openaiModel, { store: true }) as any[]
1369
-
1370
- expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
1371
- })
1372
-
1373
- test("preserves metadata for non-openai packages when store is false", () => {
1374
- const anthropicModel = {
1375
- ...openaiModel,
1376
- providerID: "anthropic",
1377
- api: {
1378
- id: "claude-3",
1379
- url: "https://api.anthropic.com",
1380
- npm: "@ai-sdk/anthropic",
1381
- },
1382
- }
1383
- const msgs = [
1384
- {
1385
- role: "assistant",
1386
- content: [
1387
- {
1388
- type: "text",
1389
- text: "Hello",
1390
- providerOptions: {
1391
- openai: {
1392
- itemId: "msg_123",
1393
- },
1394
- },
1395
- },
1396
- ],
1397
- },
1398
- ] as any[]
1399
-
1400
- // store=false preserves metadata for non-openai packages
1401
- const result = ProviderTransform.message(msgs, anthropicModel, { store: false }) as any[]
1402
-
1403
- expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
1404
- })
1405
-
1406
- test("preserves metadata using providerID key when store is false", () => {
1407
- const opencodeModel = {
1408
- ...openaiModel,
1409
- providerID: "opencode",
1410
- api: {
1411
- id: "opencode-test",
1412
- url: "https://api.opencode.ai",
1413
- npm: "@ai-sdk/openai-compatible",
1414
- },
1415
- }
1416
- const msgs = [
1417
- {
1418
- role: "assistant",
1419
- content: [
1420
- {
1421
- type: "text",
1422
- text: "Hello",
1423
- providerOptions: {
1424
- opencode: {
1425
- itemId: "msg_123",
1426
- otherOption: "value",
1427
- },
1428
- },
1429
- },
1430
- ],
1431
- },
1432
- ] as any[]
1433
-
1434
- const result = ProviderTransform.message(msgs, opencodeModel, { store: false }) as any[]
1435
-
1436
- expect(result[0].content[0].providerOptions?.opencode?.itemId).toBe("msg_123")
1437
- expect(result[0].content[0].providerOptions?.opencode?.otherOption).toBe("value")
1438
- })
1439
-
1440
- test("preserves itemId across all providerOptions keys", () => {
1441
- const opencodeModel = {
1442
- ...openaiModel,
1443
- providerID: "opencode",
1444
- api: {
1445
- id: "opencode-test",
1446
- url: "https://api.opencode.ai",
1447
- npm: "@ai-sdk/openai-compatible",
1448
- },
1449
- }
1450
- const msgs = [
1451
- {
1452
- role: "assistant",
1453
- providerOptions: {
1454
- openai: { itemId: "msg_root" },
1455
- opencode: { itemId: "msg_opencode" },
1456
- extra: { itemId: "msg_extra" },
1457
- },
1458
- content: [
1459
- {
1460
- type: "text",
1461
- text: "Hello",
1462
- providerOptions: {
1463
- openai: { itemId: "msg_openai_part" },
1464
- opencode: { itemId: "msg_opencode_part" },
1465
- extra: { itemId: "msg_extra_part" },
1466
- },
1467
- },
1468
- ],
1469
- },
1470
- ] as any[]
1471
-
1472
- const result = ProviderTransform.message(msgs, opencodeModel, { store: false }) as any[]
1473
-
1474
- expect(result[0].providerOptions?.openai?.itemId).toBe("msg_root")
1475
- expect(result[0].providerOptions?.opencode?.itemId).toBe("msg_opencode")
1476
- expect(result[0].providerOptions?.extra?.itemId).toBe("msg_extra")
1477
- expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_openai_part")
1478
- expect(result[0].content[0].providerOptions?.opencode?.itemId).toBe("msg_opencode_part")
1479
- expect(result[0].content[0].providerOptions?.extra?.itemId).toBe("msg_extra_part")
1480
- })
1481
-
1482
- test("does not strip metadata for non-openai packages when store is not false", () => {
1483
- const anthropicModel = {
1484
- ...openaiModel,
1485
- providerID: "anthropic",
1486
- api: {
1487
- id: "claude-3",
1488
- url: "https://api.anthropic.com",
1489
- npm: "@ai-sdk/anthropic",
1490
- },
1491
- }
1492
- const msgs = [
1493
- {
1494
- role: "assistant",
1495
- content: [
1496
- {
1497
- type: "text",
1498
- text: "Hello",
1499
- providerOptions: {
1500
- openai: {
1501
- itemId: "msg_123",
1502
- },
1503
- },
1504
- },
1505
- ],
1506
- },
1507
- ] as any[]
1508
-
1509
- const result = ProviderTransform.message(msgs, anthropicModel, {}) as any[]
1510
-
1511
- expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
1512
- })
1513
- })
1514
-
1515
- describe("ProviderTransform.message - providerOptions key remapping", () => {
1516
- const createModel = (providerID: string, npm: string) =>
1517
- ({
1518
- id: `${providerID}/test-model`,
1519
- providerID,
1520
- api: {
1521
- id: "test-model",
1522
- url: "https://api.test.com",
1523
- npm,
1524
- },
1525
- name: "Test Model",
1526
- capabilities: {
1527
- temperature: true,
1528
- reasoning: false,
1529
- attachment: true,
1530
- toolcall: true,
1531
- input: { text: true, audio: false, image: true, video: false, pdf: true },
1532
- output: { text: true, audio: false, image: false, video: false, pdf: false },
1533
- interleaved: false,
1534
- },
1535
- cost: { input: 0.001, output: 0.002, cache: { read: 0.0001, write: 0.0002 } },
1536
- limit: { context: 128000, output: 8192 },
1537
- status: "active",
1538
- options: {},
1539
- headers: {},
1540
- }) as any
1541
-
1542
- test("azure keeps 'azure' key and does not remap to 'openai'", () => {
1543
- const model = createModel("azure", "@ai-sdk/azure")
1544
- const msgs = [
1545
- {
1546
- role: "user",
1547
- content: "Hello",
1548
- providerOptions: {
1549
- azure: { someOption: "value" },
1550
- },
1551
- },
1552
- ] as any[]
1553
-
1554
- const result = ProviderTransform.message(msgs, model, {})
1555
-
1556
- expect(result[0].providerOptions?.azure).toEqual({ someOption: "value" })
1557
- expect(result[0].providerOptions?.openai).toBeUndefined()
1558
- })
1559
-
1560
- test("copilot remaps providerID to 'copilot' key", () => {
1561
- const model = createModel("github-copilot", "@ai-sdk/github-copilot")
1562
- const msgs = [
1563
- {
1564
- role: "user",
1565
- content: "Hello",
1566
- providerOptions: {
1567
- copilot: { someOption: "value" },
1568
- },
1569
- },
1570
- ] as any[]
1571
-
1572
- const result = ProviderTransform.message(msgs, model, {})
1573
-
1574
- expect(result[0].providerOptions?.copilot).toEqual({ someOption: "value" })
1575
- expect(result[0].providerOptions?.["github-copilot"]).toBeUndefined()
1576
- })
1577
-
1578
- test("bedrock remaps providerID to 'bedrock' key", () => {
1579
- const model = createModel("my-bedrock", "@ai-sdk/amazon-bedrock")
1580
- const msgs = [
1581
- {
1582
- role: "user",
1583
- content: "Hello",
1584
- providerOptions: {
1585
- "my-bedrock": { someOption: "value" },
1586
- },
1587
- },
1588
- ] as any[]
1589
-
1590
- const result = ProviderTransform.message(msgs, model, {})
1591
-
1592
- expect(result[0].providerOptions?.bedrock).toEqual({ someOption: "value" })
1593
- expect(result[0].providerOptions?.["my-bedrock"]).toBeUndefined()
1594
- })
1595
- })
1596
-
1597
- describe("ProviderTransform.message - claude w/bedrock custom inference profile", () => {
1598
- test("adds cachePoint", () => {
1599
- const model = {
1600
- id: "amazon-bedrock/custom-claude-sonnet-4.5",
1601
- providerID: "amazon-bedrock",
1602
- api: {
1603
- id: "arn:aws:bedrock:xxx:yyy:application-inference-profile/zzz",
1604
- url: "https://api.test.com",
1605
- npm: "@ai-sdk/amazon-bedrock",
1606
- },
1607
- name: "Custom inference profile",
1608
- capabilities: {},
1609
- options: {},
1610
- headers: {},
1611
- } as any
1612
-
1613
- const msgs = [
1614
- {
1615
- role: "user",
1616
- content: "Hello",
1617
- },
1618
- ] as any[]
1619
-
1620
- const result = ProviderTransform.message(msgs, model, {})
1621
-
1622
- expect(result[0].providerOptions?.bedrock).toEqual(
1623
- expect.objectContaining({
1624
- cachePoint: {
1625
- type: "default",
1626
- },
1627
- }),
1628
- )
1629
- })
1630
- })
1631
-
1632
- describe("ProviderTransform.message - bedrock caching with non-bedrock providerID", () => {
1633
- test("applies cache options at message level when npm package is amazon-bedrock", () => {
1634
- const model = {
1635
- id: "aws/us.anthropic.claude-opus-4-6-v1",
1636
- providerID: "aws",
1637
- api: {
1638
- id: "us.anthropic.claude-opus-4-6-v1",
1639
- url: "https://bedrock-runtime.us-east-1.amazonaws.com",
1640
- npm: "@ai-sdk/amazon-bedrock",
1641
- },
1642
- name: "Claude Opus 4.6",
1643
- capabilities: {},
1644
- options: {},
1645
- headers: {},
1646
- } as any
1647
-
1648
- const msgs = [
1649
- {
1650
- role: "system",
1651
- content: [{ type: "text", text: "You are a helpful assistant" }],
1652
- },
1653
- {
1654
- role: "user",
1655
- content: [{ type: "text", text: "Hello" }],
1656
- },
1657
- ] as any[]
1658
-
1659
- const result = ProviderTransform.message(msgs, model, {}) as any[]
1660
-
1661
- // Cache should be at the message level and not the content-part level
1662
- expect(result[0].providerOptions?.bedrock).toEqual({
1663
- cachePoint: { type: "default" },
1664
- })
1665
- expect(result[0].content[0].providerOptions?.bedrock).toBeUndefined()
1666
- })
1667
- })
1668
-
1669
- describe("ProviderTransform.message - cache control on gateway", () => {
1670
- const createModel = (overrides: Partial<any> = {}) =>
1671
- ({
1672
- id: "anthropic/claude-sonnet-4",
1673
- providerID: "vercel",
1674
- api: {
1675
- id: "anthropic/claude-sonnet-4",
1676
- url: "https://ai-gateway.vercel.sh/v3/ai",
1677
- npm: "@ai-sdk/gateway",
1678
- },
1679
- name: "Claude Sonnet 4",
1680
- capabilities: {
1681
- temperature: true,
1682
- reasoning: true,
1683
- attachment: true,
1684
- toolcall: true,
1685
- input: { text: true, audio: false, image: true, video: false, pdf: true },
1686
- output: { text: true, audio: false, image: false, video: false, pdf: false },
1687
- interleaved: false,
1688
- },
1689
- cost: { input: 0.001, output: 0.002, cache: { read: 0.0001, write: 0.0002 } },
1690
- limit: { context: 200_000, output: 8192 },
1691
- status: "active",
1692
- options: {},
1693
- headers: {},
1694
- ...overrides,
1695
- }) as any
1696
-
1697
- test("gateway does not set cache control for anthropic models", () => {
1698
- const model = createModel()
1699
- const msgs = [
1700
- {
1701
- role: "system",
1702
- content: [{ type: "text", text: "You are a helpful assistant" }],
1703
- },
1704
- {
1705
- role: "user",
1706
- content: "Hello",
1707
- },
1708
- ] as any[]
1709
-
1710
- const result = ProviderTransform.message(msgs, model, {}) as any[]
1711
-
1712
- expect(result[0].content[0].providerOptions).toBeUndefined()
1713
- expect(result[0].providerOptions).toBeUndefined()
1714
- })
1715
-
1716
- test("non-gateway anthropic keeps existing cache control behavior", () => {
1717
- const model = createModel({
1718
- providerID: "anthropic",
1719
- api: {
1720
- id: "claude-sonnet-4",
1721
- url: "https://api.anthropic.com",
1722
- npm: "@ai-sdk/anthropic",
1723
- },
1724
- })
1725
- const msgs = [
1726
- {
1727
- role: "system",
1728
- content: "You are a helpful assistant",
1729
- },
1730
- {
1731
- role: "user",
1732
- content: "Hello",
1733
- },
1734
- ] as any[]
1735
-
1736
- const result = ProviderTransform.message(msgs, model, {}) as any[]
1737
-
1738
- expect(result[0].providerOptions).toEqual({
1739
- anthropic: {
1740
- cacheControl: {
1741
- type: "ephemeral",
1742
- },
1743
- },
1744
- openrouter: {
1745
- cacheControl: {
1746
- type: "ephemeral",
1747
- },
1748
- },
1749
- bedrock: {
1750
- cachePoint: {
1751
- type: "default",
1752
- },
1753
- },
1754
- openaiCompatible: {
1755
- cache_control: {
1756
- type: "ephemeral",
1757
- },
1758
- },
1759
- copilot: {
1760
- copilot_cache_control: {
1761
- type: "ephemeral",
1762
- },
1763
- },
1764
- })
1765
- })
1766
- })
1767
-
1768
- describe("ProviderTransform.variants", () => {
1769
- const createMockModel = (overrides: Partial<any> = {}): any => ({
1770
- id: "test/test-model",
1771
- providerID: "test",
1772
- api: {
1773
- id: "test-model",
1774
- url: "https://api.test.com",
1775
- npm: "@ai-sdk/openai",
1776
- },
1777
- name: "Test Model",
1778
- capabilities: {
1779
- temperature: true,
1780
- reasoning: true,
1781
- attachment: true,
1782
- toolcall: true,
1783
- input: { text: true, audio: false, image: true, video: false, pdf: false },
1784
- output: { text: true, audio: false, image: false, video: false, pdf: false },
1785
- interleaved: false,
1786
- },
1787
- cost: {
1788
- input: 0.001,
1789
- output: 0.002,
1790
- cache: { read: 0.0001, write: 0.0002 },
1791
- },
1792
- limit: {
1793
- context: 200_000,
1794
- output: 64_000,
1795
- },
1796
- status: "active",
1797
- options: {},
1798
- headers: {},
1799
- release_date: "2024-01-01",
1800
- ...overrides,
1801
- })
1802
-
1803
- test("returns empty object when model has no reasoning capabilities", () => {
1804
- const model = createMockModel({
1805
- capabilities: { reasoning: false },
1806
- })
1807
- const result = ProviderTransform.variants(model)
1808
- expect(result).toEqual({})
1809
- })
1810
-
1811
- test("deepseek returns empty object", () => {
1812
- const model = createMockModel({
1813
- id: "deepseek/deepseek-chat",
1814
- providerID: "deepseek",
1815
- api: {
1816
- id: "deepseek-chat",
1817
- url: "https://api.deepseek.com",
1818
- npm: "@ai-sdk/openai-compatible",
1819
- },
1820
- })
1821
- const result = ProviderTransform.variants(model)
1822
- expect(result).toEqual({})
1823
- })
1824
-
1825
- test("minimax returns empty object", () => {
1826
- const model = createMockModel({
1827
- id: "minimax/minimax-model",
1828
- providerID: "minimax",
1829
- api: {
1830
- id: "minimax-model",
1831
- url: "https://api.minimax.com",
1832
- npm: "@ai-sdk/openai-compatible",
1833
- },
1834
- })
1835
- const result = ProviderTransform.variants(model)
1836
- expect(result).toEqual({})
1837
- })
1838
-
1839
- test("glm returns empty object", () => {
1840
- const model = createMockModel({
1841
- id: "glm/glm-4",
1842
- providerID: "glm",
1843
- api: {
1844
- id: "glm-4",
1845
- url: "https://api.glm.com",
1846
- npm: "@ai-sdk/openai-compatible",
1847
- },
1848
- })
1849
- const result = ProviderTransform.variants(model)
1850
- expect(result).toEqual({})
1851
- })
1852
-
1853
- test("mistral returns empty object", () => {
1854
- const model = createMockModel({
1855
- id: "mistral/mistral-large",
1856
- providerID: "mistral",
1857
- api: {
1858
- id: "mistral-large-latest",
1859
- url: "https://api.mistral.com",
1860
- npm: "@ai-sdk/mistral",
1861
- },
1862
- })
1863
- const result = ProviderTransform.variants(model)
1864
- expect(result).toEqual({})
1865
- })
1866
-
1867
- describe("@openrouter/ai-sdk-provider", () => {
1868
- test("returns empty object for non-qualifying models", () => {
1869
- const model = createMockModel({
1870
- id: "openrouter/test-model",
1871
- providerID: "openrouter",
1872
- api: {
1873
- id: "test-model",
1874
- url: "https://openrouter.ai",
1875
- npm: "@openrouter/ai-sdk-provider",
1876
- },
1877
- })
1878
- const result = ProviderTransform.variants(model)
1879
- expect(result).toEqual({})
1880
- })
1881
-
1882
- test("gpt models return OPENAI_EFFORTS with reasoning", () => {
1883
- const model = createMockModel({
1884
- id: "openrouter/gpt-4",
1885
- providerID: "openrouter",
1886
- api: {
1887
- id: "gpt-4",
1888
- url: "https://openrouter.ai",
1889
- npm: "@openrouter/ai-sdk-provider",
1890
- },
1891
- })
1892
- const result = ProviderTransform.variants(model)
1893
- expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
1894
- expect(result.low).toEqual({ reasoning: { effort: "low" } })
1895
- expect(result.high).toEqual({ reasoning: { effort: "high" } })
1896
- })
1897
-
1898
- test("gemini-3 returns OPENAI_EFFORTS with reasoning", () => {
1899
- const model = createMockModel({
1900
- id: "openrouter/gemini-3-5-pro",
1901
- providerID: "openrouter",
1902
- api: {
1903
- id: "gemini-3-5-pro",
1904
- url: "https://openrouter.ai",
1905
- npm: "@openrouter/ai-sdk-provider",
1906
- },
1907
- })
1908
- const result = ProviderTransform.variants(model)
1909
- expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
1910
- })
1911
-
1912
- test("grok-4 returns empty object", () => {
1913
- const model = createMockModel({
1914
- id: "openrouter/grok-4",
1915
- providerID: "openrouter",
1916
- api: {
1917
- id: "grok-4",
1918
- url: "https://openrouter.ai",
1919
- npm: "@openrouter/ai-sdk-provider",
1920
- },
1921
- })
1922
- const result = ProviderTransform.variants(model)
1923
- expect(result).toEqual({})
1924
- })
1925
-
1926
- test("grok-3-mini returns low and high with reasoning", () => {
1927
- const model = createMockModel({
1928
- id: "openrouter/grok-3-mini",
1929
- providerID: "openrouter",
1930
- api: {
1931
- id: "grok-3-mini",
1932
- url: "https://openrouter.ai",
1933
- npm: "@openrouter/ai-sdk-provider",
1934
- },
1935
- })
1936
- const result = ProviderTransform.variants(model)
1937
- expect(Object.keys(result)).toEqual(["low", "high"])
1938
- expect(result.low).toEqual({ reasoning: { effort: "low" } })
1939
- expect(result.high).toEqual({ reasoning: { effort: "high" } })
1940
- })
1941
- })
1942
-
1943
- describe("@ai-sdk/gateway", () => {
1944
- test("anthropic sonnet 4.6 models return adaptive thinking options", () => {
1945
- const model = createMockModel({
1946
- id: "anthropic/claude-sonnet-4-6",
1947
- providerID: "gateway",
1948
- api: {
1949
- id: "anthropic/claude-sonnet-4-6",
1950
- url: "https://gateway.ai",
1951
- npm: "@ai-sdk/gateway",
1952
- },
1953
- })
1954
- const result = ProviderTransform.variants(model)
1955
- expect(Object.keys(result)).toEqual(["low", "medium", "high", "max"])
1956
- expect(result.medium).toEqual({
1957
- thinking: {
1958
- type: "adaptive",
1959
- },
1960
- effort: "medium",
1961
- })
1962
- })
1963
-
1964
- test("anthropic sonnet 4.6 dot-format models return adaptive thinking options", () => {
1965
- const model = createMockModel({
1966
- id: "anthropic/claude-sonnet-4-6",
1967
- providerID: "gateway",
1968
- api: {
1969
- id: "anthropic/claude-sonnet-4.6",
1970
- url: "https://gateway.ai",
1971
- npm: "@ai-sdk/gateway",
1972
- },
1973
- })
1974
- const result = ProviderTransform.variants(model)
1975
- expect(Object.keys(result)).toEqual(["low", "medium", "high", "max"])
1976
- expect(result.medium).toEqual({
1977
- thinking: {
1978
- type: "adaptive",
1979
- },
1980
- effort: "medium",
1981
- })
1982
- })
1983
-
1984
- test("anthropic opus 4.6 dot-format models return adaptive thinking options", () => {
1985
- const model = createMockModel({
1986
- id: "anthropic/claude-opus-4-6",
1987
- providerID: "gateway",
1988
- api: {
1989
- id: "anthropic/claude-opus-4.6",
1990
- url: "https://gateway.ai",
1991
- npm: "@ai-sdk/gateway",
1992
- },
1993
- })
1994
- const result = ProviderTransform.variants(model)
1995
- expect(Object.keys(result)).toEqual(["low", "medium", "high", "max"])
1996
- expect(result.high).toEqual({
1997
- thinking: {
1998
- type: "adaptive",
1999
- },
2000
- effort: "high",
2001
- })
2002
- })
2003
-
2004
- test("anthropic models return anthropic thinking options", () => {
2005
- const model = createMockModel({
2006
- id: "anthropic/claude-sonnet-4",
2007
- providerID: "gateway",
2008
- api: {
2009
- id: "anthropic/claude-sonnet-4",
2010
- url: "https://gateway.ai",
2011
- npm: "@ai-sdk/gateway",
2012
- },
2013
- })
2014
- const result = ProviderTransform.variants(model)
2015
- expect(Object.keys(result)).toEqual(["high", "max"])
2016
- expect(result.high).toEqual({
2017
- thinking: {
2018
- type: "enabled",
2019
- budgetTokens: 16000,
2020
- },
2021
- })
2022
- expect(result.max).toEqual({
2023
- thinking: {
2024
- type: "enabled",
2025
- budgetTokens: 31999,
2026
- },
2027
- })
2028
- })
2029
-
2030
- test("returns OPENAI_EFFORTS with reasoningEffort", () => {
2031
- const model = createMockModel({
2032
- id: "gateway/gateway-model",
2033
- providerID: "gateway",
2034
- api: {
2035
- id: "gateway-model",
2036
- url: "https://gateway.ai",
2037
- npm: "@ai-sdk/gateway",
2038
- },
2039
- })
2040
- const result = ProviderTransform.variants(model)
2041
- expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
2042
- expect(result.low).toEqual({ reasoningEffort: "low" })
2043
- expect(result.high).toEqual({ reasoningEffort: "high" })
2044
- })
2045
- })
2046
-
2047
- describe("@ai-sdk/github-copilot", () => {
2048
- test("standard models return low, medium, high", () => {
2049
- const model = createMockModel({
2050
- id: "gpt-4.5",
2051
- providerID: "github-copilot",
2052
- api: {
2053
- id: "gpt-4.5",
2054
- url: "https://api.githubcopilot.com",
2055
- npm: "@ai-sdk/github-copilot",
2056
- },
2057
- })
2058
- const result = ProviderTransform.variants(model)
2059
- expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2060
- expect(result.low).toEqual({
2061
- reasoningEffort: "low",
2062
- reasoningSummary: "auto",
2063
- include: ["reasoning.encrypted_content"],
2064
- })
2065
- })
2066
-
2067
- test("gpt-5.1-codex-max includes xhigh", () => {
2068
- const model = createMockModel({
2069
- id: "gpt-5.1-codex-max",
2070
- providerID: "github-copilot",
2071
- api: {
2072
- id: "gpt-5.1-codex-max",
2073
- url: "https://api.githubcopilot.com",
2074
- npm: "@ai-sdk/github-copilot",
2075
- },
2076
- })
2077
- const result = ProviderTransform.variants(model)
2078
- expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh"])
2079
- })
2080
-
2081
- test("gpt-5.1-codex-mini does not include xhigh", () => {
2082
- const model = createMockModel({
2083
- id: "gpt-5.1-codex-mini",
2084
- providerID: "github-copilot",
2085
- api: {
2086
- id: "gpt-5.1-codex-mini",
2087
- url: "https://api.githubcopilot.com",
2088
- npm: "@ai-sdk/github-copilot",
2089
- },
2090
- })
2091
- const result = ProviderTransform.variants(model)
2092
- expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2093
- })
2094
-
2095
- test("gpt-5.1-codex does not include xhigh", () => {
2096
- const model = createMockModel({
2097
- id: "gpt-5.1-codex",
2098
- providerID: "github-copilot",
2099
- api: {
2100
- id: "gpt-5.1-codex",
2101
- url: "https://api.githubcopilot.com",
2102
- npm: "@ai-sdk/github-copilot",
2103
- },
2104
- })
2105
- const result = ProviderTransform.variants(model)
2106
- expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2107
- })
2108
-
2109
- test("gpt-5.2 includes xhigh", () => {
2110
- const model = createMockModel({
2111
- id: "gpt-5.2",
2112
- providerID: "github-copilot",
2113
- api: {
2114
- id: "gpt-5.2",
2115
- url: "https://api.githubcopilot.com",
2116
- npm: "@ai-sdk/github-copilot",
2117
- },
2118
- })
2119
- const result = ProviderTransform.variants(model)
2120
- expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh"])
2121
- expect(result.xhigh).toEqual({
2122
- reasoningEffort: "xhigh",
2123
- reasoningSummary: "auto",
2124
- include: ["reasoning.encrypted_content"],
2125
- })
2126
- })
2127
-
2128
- test("gpt-5.2-codex includes xhigh", () => {
2129
- const model = createMockModel({
2130
- id: "gpt-5.2-codex",
2131
- providerID: "github-copilot",
2132
- api: {
2133
- id: "gpt-5.2-codex",
2134
- url: "https://api.githubcopilot.com",
2135
- npm: "@ai-sdk/github-copilot",
2136
- },
2137
- })
2138
- const result = ProviderTransform.variants(model)
2139
- expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh"])
2140
- })
2141
-
2142
- test("gpt-5.3-codex includes xhigh", () => {
2143
- const model = createMockModel({
2144
- id: "gpt-5.3-codex",
2145
- providerID: "github-copilot",
2146
- api: {
2147
- id: "gpt-5.3-codex",
2148
- url: "https://api.githubcopilot.com",
2149
- npm: "@ai-sdk/github-copilot",
2150
- },
2151
- })
2152
- const result = ProviderTransform.variants(model)
2153
- expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh"])
2154
- })
2155
-
2156
- test("gpt-5.4 includes xhigh", () => {
2157
- const model = createMockModel({
2158
- id: "gpt-5.4",
2159
- release_date: "2026-03-05",
2160
- providerID: "github-copilot",
2161
- api: {
2162
- id: "gpt-5.4",
2163
- url: "https://api.githubcopilot.com",
2164
- npm: "@ai-sdk/github-copilot",
2165
- },
2166
- })
2167
- const result = ProviderTransform.variants(model)
2168
- expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh"])
2169
- })
2170
- })
2171
-
2172
- describe("@ai-sdk/cerebras", () => {
2173
- test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
2174
- const model = createMockModel({
2175
- id: "cerebras/llama-4",
2176
- providerID: "cerebras",
2177
- api: {
2178
- id: "llama-4-sc",
2179
- url: "https://api.cerebras.ai",
2180
- npm: "@ai-sdk/cerebras",
2181
- },
2182
- })
2183
- const result = ProviderTransform.variants(model)
2184
- expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2185
- expect(result.low).toEqual({ reasoningEffort: "low" })
2186
- expect(result.high).toEqual({ reasoningEffort: "high" })
2187
- })
2188
- })
2189
-
2190
- describe("@ai-sdk/togetherai", () => {
2191
- test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
2192
- const model = createMockModel({
2193
- id: "togetherai/llama-4",
2194
- providerID: "togetherai",
2195
- api: {
2196
- id: "llama-4-sc",
2197
- url: "https://api.togetherai.com",
2198
- npm: "@ai-sdk/togetherai",
2199
- },
2200
- })
2201
- const result = ProviderTransform.variants(model)
2202
- expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2203
- expect(result.low).toEqual({ reasoningEffort: "low" })
2204
- expect(result.high).toEqual({ reasoningEffort: "high" })
2205
- })
2206
- })
2207
-
2208
- describe("@ai-sdk/xai", () => {
2209
- test("grok-3 returns empty object", () => {
2210
- const model = createMockModel({
2211
- id: "xai/grok-3",
2212
- providerID: "xai",
2213
- api: {
2214
- id: "grok-3",
2215
- url: "https://api.x.ai",
2216
- npm: "@ai-sdk/xai",
2217
- },
2218
- })
2219
- const result = ProviderTransform.variants(model)
2220
- expect(result).toEqual({})
2221
- })
2222
-
2223
- test("grok-3-mini returns low and high with reasoningEffort", () => {
2224
- const model = createMockModel({
2225
- id: "xai/grok-3-mini",
2226
- providerID: "xai",
2227
- api: {
2228
- id: "grok-3-mini",
2229
- url: "https://api.x.ai",
2230
- npm: "@ai-sdk/xai",
2231
- },
2232
- })
2233
- const result = ProviderTransform.variants(model)
2234
- expect(Object.keys(result)).toEqual(["low", "high"])
2235
- expect(result.low).toEqual({ reasoningEffort: "low" })
2236
- expect(result.high).toEqual({ reasoningEffort: "high" })
2237
- })
2238
- })
2239
-
2240
- describe("@ai-sdk/deepinfra", () => {
2241
- test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
2242
- const model = createMockModel({
2243
- id: "deepinfra/llama-4",
2244
- providerID: "deepinfra",
2245
- api: {
2246
- id: "llama-4-sc",
2247
- url: "https://api.deepinfra.com",
2248
- npm: "@ai-sdk/deepinfra",
2249
- },
2250
- })
2251
- const result = ProviderTransform.variants(model)
2252
- expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2253
- expect(result.low).toEqual({ reasoningEffort: "low" })
2254
- expect(result.high).toEqual({ reasoningEffort: "high" })
2255
- })
2256
- })
2257
-
2258
- describe("@ai-sdk/openai-compatible", () => {
2259
- test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
2260
- const model = createMockModel({
2261
- id: "custom-provider/custom-model",
2262
- providerID: "custom-provider",
2263
- api: {
2264
- id: "custom-model",
2265
- url: "https://api.custom.com",
2266
- npm: "@ai-sdk/openai-compatible",
2267
- },
2268
- })
2269
- const result = ProviderTransform.variants(model)
2270
- expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2271
- expect(result.low).toEqual({ reasoningEffort: "low" })
2272
- expect(result.high).toEqual({ reasoningEffort: "high" })
2273
- })
2274
- })
2275
-
2276
- describe("@ai-sdk/azure", () => {
2277
- test("o1-mini returns empty object", () => {
2278
- const model = createMockModel({
2279
- id: "o1-mini",
2280
- providerID: "azure",
2281
- api: {
2282
- id: "o1-mini",
2283
- url: "https://azure.com",
2284
- npm: "@ai-sdk/azure",
2285
- },
2286
- })
2287
- const result = ProviderTransform.variants(model)
2288
- expect(result).toEqual({})
2289
- })
2290
-
2291
- test("standard azure models return custom efforts with reasoningSummary", () => {
2292
- const model = createMockModel({
2293
- id: "o1",
2294
- providerID: "azure",
2295
- api: {
2296
- id: "o1",
2297
- url: "https://azure.com",
2298
- npm: "@ai-sdk/azure",
2299
- },
2300
- })
2301
- const result = ProviderTransform.variants(model)
2302
- expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2303
- expect(result.low).toEqual({
2304
- reasoningEffort: "low",
2305
- reasoningSummary: "auto",
2306
- include: ["reasoning.encrypted_content"],
2307
- })
2308
- })
2309
-
2310
- test("gpt-5 adds minimal effort", () => {
2311
- const model = createMockModel({
2312
- id: "gpt-5",
2313
- providerID: "azure",
2314
- api: {
2315
- id: "gpt-5",
2316
- url: "https://azure.com",
2317
- npm: "@ai-sdk/azure",
2318
- },
2319
- })
2320
- const result = ProviderTransform.variants(model)
2321
- expect(Object.keys(result)).toEqual(["minimal", "low", "medium", "high"])
2322
- })
2323
- })
2324
-
2325
- describe("@ai-sdk/openai", () => {
2326
- test("gpt-5-pro returns empty object", () => {
2327
- const model = createMockModel({
2328
- id: "gpt-5-pro",
2329
- providerID: "openai",
2330
- api: {
2331
- id: "gpt-5-pro",
2332
- url: "https://api.openai.com",
2333
- npm: "@ai-sdk/openai",
2334
- },
2335
- })
2336
- const result = ProviderTransform.variants(model)
2337
- expect(result).toEqual({})
2338
- })
2339
-
2340
- test("standard openai models return custom efforts with reasoningSummary", () => {
2341
- const model = createMockModel({
2342
- id: "gpt-5",
2343
- providerID: "openai",
2344
- api: {
2345
- id: "gpt-5",
2346
- url: "https://api.openai.com",
2347
- npm: "@ai-sdk/openai",
2348
- },
2349
- release_date: "2024-06-01",
2350
- })
2351
- const result = ProviderTransform.variants(model)
2352
- expect(Object.keys(result)).toEqual(["minimal", "low", "medium", "high"])
2353
- expect(result.low).toEqual({
2354
- reasoningEffort: "low",
2355
- reasoningSummary: "auto",
2356
- include: ["reasoning.encrypted_content"],
2357
- })
2358
- })
2359
-
2360
- test("models after 2025-11-13 include 'none' effort", () => {
2361
- const model = createMockModel({
2362
- id: "gpt-5-nano",
2363
- providerID: "openai",
2364
- api: {
2365
- id: "gpt-5-nano",
2366
- url: "https://api.openai.com",
2367
- npm: "@ai-sdk/openai",
2368
- },
2369
- release_date: "2025-11-14",
2370
- })
2371
- const result = ProviderTransform.variants(model)
2372
- expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high"])
2373
- })
2374
-
2375
- test("models after 2025-12-04 include 'xhigh' effort", () => {
2376
- const model = createMockModel({
2377
- id: "openai/gpt-5-chat",
2378
- providerID: "openai",
2379
- api: {
2380
- id: "gpt-5-chat",
2381
- url: "https://api.openai.com",
2382
- npm: "@ai-sdk/openai",
2383
- },
2384
- release_date: "2025-12-05",
2385
- })
2386
- const result = ProviderTransform.variants(model)
2387
- expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
2388
- })
2389
- })
2390
-
2391
- describe("@ai-sdk/anthropic", () => {
2392
- test("sonnet 4.6 returns adaptive thinking options", () => {
2393
- const model = createMockModel({
2394
- id: "anthropic/claude-sonnet-4-6",
2395
- providerID: "anthropic",
2396
- api: {
2397
- id: "claude-sonnet-4-6",
2398
- url: "https://api.anthropic.com",
2399
- npm: "@ai-sdk/anthropic",
2400
- },
2401
- })
2402
- const result = ProviderTransform.variants(model)
2403
- expect(Object.keys(result)).toEqual(["low", "medium", "high", "max"])
2404
- expect(result.high).toEqual({
2405
- thinking: {
2406
- type: "adaptive",
2407
- },
2408
- effort: "high",
2409
- })
2410
- })
2411
-
2412
- test("returns high and max with thinking config", () => {
2413
- const model = createMockModel({
2414
- id: "anthropic/claude-4",
2415
- providerID: "anthropic",
2416
- api: {
2417
- id: "claude-4",
2418
- url: "https://api.anthropic.com",
2419
- npm: "@ai-sdk/anthropic",
2420
- },
2421
- })
2422
- const result = ProviderTransform.variants(model)
2423
- expect(Object.keys(result)).toEqual(["high", "max"])
2424
- expect(result.high).toEqual({
2425
- thinking: {
2426
- type: "enabled",
2427
- budgetTokens: 16000,
2428
- },
2429
- })
2430
- expect(result.max).toEqual({
2431
- thinking: {
2432
- type: "enabled",
2433
- budgetTokens: 31999,
2434
- },
2435
- })
2436
- })
2437
- })
2438
-
2439
- describe("@ai-sdk/amazon-bedrock", () => {
2440
- test("anthropic sonnet 4.6 returns adaptive reasoning options", () => {
2441
- const model = createMockModel({
2442
- id: "bedrock/anthropic-claude-sonnet-4-6",
2443
- providerID: "bedrock",
2444
- api: {
2445
- id: "anthropic.claude-sonnet-4-6",
2446
- url: "https://bedrock.amazonaws.com",
2447
- npm: "@ai-sdk/amazon-bedrock",
2448
- },
2449
- })
2450
- const result = ProviderTransform.variants(model)
2451
- expect(Object.keys(result)).toEqual(["low", "medium", "high", "max"])
2452
- expect(result.max).toEqual({
2453
- reasoningConfig: {
2454
- type: "adaptive",
2455
- maxReasoningEffort: "max",
2456
- },
2457
- })
2458
- })
2459
-
2460
- test("returns WIDELY_SUPPORTED_EFFORTS with reasoningConfig", () => {
2461
- const model = createMockModel({
2462
- id: "bedrock/llama-4",
2463
- providerID: "bedrock",
2464
- api: {
2465
- id: "llama-4-sc",
2466
- url: "https://bedrock.amazonaws.com",
2467
- npm: "@ai-sdk/amazon-bedrock",
2468
- },
2469
- })
2470
- const result = ProviderTransform.variants(model)
2471
- expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2472
- expect(result.low).toEqual({
2473
- reasoningConfig: {
2474
- type: "enabled",
2475
- maxReasoningEffort: "low",
2476
- },
2477
- })
2478
- })
2479
- })
2480
-
2481
- describe("@ai-sdk/google", () => {
2482
- test("gemini-2.5 returns high and max with thinkingConfig and thinkingBudget", () => {
2483
- const model = createMockModel({
2484
- id: "google/gemini-2.5-pro",
2485
- providerID: "google",
2486
- api: {
2487
- id: "gemini-2.5-pro",
2488
- url: "https://generativelanguage.googleapis.com",
2489
- npm: "@ai-sdk/google",
2490
- },
2491
- })
2492
- const result = ProviderTransform.variants(model)
2493
- expect(Object.keys(result)).toEqual(["high", "max"])
2494
- expect(result.high).toEqual({
2495
- thinkingConfig: {
2496
- includeThoughts: true,
2497
- thinkingBudget: 16000,
2498
- },
2499
- })
2500
- expect(result.max).toEqual({
2501
- thinkingConfig: {
2502
- includeThoughts: true,
2503
- thinkingBudget: 24576,
2504
- },
2505
- })
2506
- })
2507
-
2508
- test("other gemini models return low and high with thinkingLevel", () => {
2509
- const model = createMockModel({
2510
- id: "google/gemini-2.0-pro",
2511
- providerID: "google",
2512
- api: {
2513
- id: "gemini-2.0-pro",
2514
- url: "https://generativelanguage.googleapis.com",
2515
- npm: "@ai-sdk/google",
2516
- },
2517
- })
2518
- const result = ProviderTransform.variants(model)
2519
- expect(Object.keys(result)).toEqual(["low", "high"])
2520
- expect(result.low).toEqual({
2521
- thinkingConfig: {
2522
- includeThoughts: true,
2523
- thinkingLevel: "low",
2524
- },
2525
- })
2526
- expect(result.high).toEqual({
2527
- thinkingConfig: {
2528
- includeThoughts: true,
2529
- thinkingLevel: "high",
2530
- },
2531
- })
2532
- })
2533
- })
2534
-
2535
- describe("@ai-sdk/google-vertex", () => {
2536
- test("gemini-2.5 returns high and max with thinkingConfig and thinkingBudget", () => {
2537
- const model = createMockModel({
2538
- id: "google-vertex/gemini-2.5-pro",
2539
- providerID: "google-vertex",
2540
- api: {
2541
- id: "gemini-2.5-pro",
2542
- url: "https://vertexai.googleapis.com",
2543
- npm: "@ai-sdk/google-vertex",
2544
- },
2545
- })
2546
- const result = ProviderTransform.variants(model)
2547
- expect(Object.keys(result)).toEqual(["high", "max"])
2548
- })
2549
-
2550
- test("other vertex models return low and high with thinkingLevel", () => {
2551
- const model = createMockModel({
2552
- id: "google-vertex/gemini-2.0-pro",
2553
- providerID: "google-vertex",
2554
- api: {
2555
- id: "gemini-2.0-pro",
2556
- url: "https://vertexai.googleapis.com",
2557
- npm: "@ai-sdk/google-vertex",
2558
- },
2559
- })
2560
- const result = ProviderTransform.variants(model)
2561
- expect(Object.keys(result)).toEqual(["low", "high"])
2562
- })
2563
- })
2564
-
2565
- describe("@ai-sdk/cohere", () => {
2566
- test("returns empty object", () => {
2567
- const model = createMockModel({
2568
- id: "cohere/command-r",
2569
- providerID: "cohere",
2570
- api: {
2571
- id: "command-r",
2572
- url: "https://api.cohere.com",
2573
- npm: "@ai-sdk/cohere",
2574
- },
2575
- })
2576
- const result = ProviderTransform.variants(model)
2577
- expect(result).toEqual({})
2578
- })
2579
- })
2580
-
2581
- describe("@ai-sdk/groq", () => {
2582
- test("returns none and WIDELY_SUPPORTED_EFFORTS with thinkingLevel", () => {
2583
- const model = createMockModel({
2584
- id: "groq/llama-4",
2585
- providerID: "groq",
2586
- api: {
2587
- id: "llama-4-sc",
2588
- url: "https://api.groq.com",
2589
- npm: "@ai-sdk/groq",
2590
- },
2591
- })
2592
- const result = ProviderTransform.variants(model)
2593
- expect(Object.keys(result)).toEqual(["none", "low", "medium", "high"])
2594
- expect(result.none).toEqual({
2595
- reasoningEffort: "none",
2596
- })
2597
- expect(result.low).toEqual({
2598
- reasoningEffort: "low",
2599
- })
2600
- })
2601
- })
2602
-
2603
- describe("@ai-sdk/perplexity", () => {
2604
- test("returns empty object", () => {
2605
- const model = createMockModel({
2606
- id: "perplexity/sonar-plus",
2607
- providerID: "perplexity",
2608
- api: {
2609
- id: "sonar-plus",
2610
- url: "https://api.perplexity.ai",
2611
- npm: "@ai-sdk/perplexity",
2612
- },
2613
- })
2614
- const result = ProviderTransform.variants(model)
2615
- expect(result).toEqual({})
2616
- })
2617
- })
2618
-
2619
- describe("@jerome-benoit/sap-ai-provider-v2", () => {
2620
- test("anthropic models return thinking variants", () => {
2621
- const model = createMockModel({
2622
- id: "sap-ai-core/anthropic--claude-sonnet-4",
2623
- providerID: "sap-ai-core",
2624
- api: {
2625
- id: "anthropic--claude-sonnet-4",
2626
- url: "https://api.ai.sap",
2627
- npm: "@jerome-benoit/sap-ai-provider-v2",
2628
- },
2629
- })
2630
- const result = ProviderTransform.variants(model)
2631
- expect(Object.keys(result)).toEqual(["high", "max"])
2632
- expect(result.high).toEqual({
2633
- thinking: {
2634
- type: "enabled",
2635
- budgetTokens: 16000,
2636
- },
2637
- })
2638
- expect(result.max).toEqual({
2639
- thinking: {
2640
- type: "enabled",
2641
- budgetTokens: 31999,
2642
- },
2643
- })
2644
- })
2645
-
2646
- test("anthropic 4.6 models return adaptive thinking variants", () => {
2647
- const model = createMockModel({
2648
- id: "sap-ai-core/anthropic--claude-sonnet-4-6",
2649
- providerID: "sap-ai-core",
2650
- api: {
2651
- id: "anthropic--claude-sonnet-4-6",
2652
- url: "https://api.ai.sap",
2653
- npm: "@jerome-benoit/sap-ai-provider-v2",
2654
- },
2655
- })
2656
- const result = ProviderTransform.variants(model)
2657
- expect(Object.keys(result)).toEqual(["low", "medium", "high", "max"])
2658
- expect(result.low).toEqual({
2659
- thinking: {
2660
- type: "adaptive",
2661
- },
2662
- effort: "low",
2663
- })
2664
- expect(result.max).toEqual({
2665
- thinking: {
2666
- type: "adaptive",
2667
- },
2668
- effort: "max",
2669
- })
2670
- })
2671
-
2672
- test("gemini 2.5 models return thinkingConfig variants", () => {
2673
- const model = createMockModel({
2674
- id: "sap-ai-core/gcp--gemini-2.5-pro",
2675
- providerID: "sap-ai-core",
2676
- api: {
2677
- id: "gcp--gemini-2.5-pro",
2678
- url: "https://api.ai.sap",
2679
- npm: "@jerome-benoit/sap-ai-provider-v2",
2680
- },
2681
- })
2682
- const result = ProviderTransform.variants(model)
2683
- expect(Object.keys(result)).toEqual(["high", "max"])
2684
- expect(result.high).toEqual({
2685
- thinkingConfig: {
2686
- includeThoughts: true,
2687
- thinkingBudget: 16000,
2688
- },
2689
- })
2690
- expect(result.max).toEqual({
2691
- thinkingConfig: {
2692
- includeThoughts: true,
2693
- thinkingBudget: 24576,
2694
- },
2695
- })
2696
- })
2697
-
2698
- test("gpt models return reasoningEffort variants", () => {
2699
- const model = createMockModel({
2700
- id: "sap-ai-core/azure-openai--gpt-4o",
2701
- providerID: "sap-ai-core",
2702
- api: {
2703
- id: "azure-openai--gpt-4o",
2704
- url: "https://api.ai.sap",
2705
- npm: "@jerome-benoit/sap-ai-provider-v2",
2706
- },
2707
- })
2708
- const result = ProviderTransform.variants(model)
2709
- expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2710
- expect(result.low).toEqual({ reasoningEffort: "low" })
2711
- expect(result.high).toEqual({ reasoningEffort: "high" })
2712
- })
2713
-
2714
- test("o-series models return reasoningEffort variants", () => {
2715
- const model = createMockModel({
2716
- id: "sap-ai-core/azure-openai--o3-mini",
2717
- providerID: "sap-ai-core",
2718
- api: {
2719
- id: "azure-openai--o3-mini",
2720
- url: "https://api.ai.sap",
2721
- npm: "@jerome-benoit/sap-ai-provider-v2",
2722
- },
2723
- })
2724
- const result = ProviderTransform.variants(model)
2725
- expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2726
- expect(result.low).toEqual({ reasoningEffort: "low" })
2727
- expect(result.high).toEqual({ reasoningEffort: "high" })
2728
- })
2729
-
2730
- test("sonar models return empty object", () => {
2731
- const model = createMockModel({
2732
- id: "sap-ai-core/perplexity--sonar-pro",
2733
- providerID: "sap-ai-core",
2734
- api: {
2735
- id: "perplexity--sonar-pro",
2736
- url: "https://api.ai.sap",
2737
- npm: "@jerome-benoit/sap-ai-provider-v2",
2738
- },
2739
- })
2740
- const result = ProviderTransform.variants(model)
2741
- expect(result).toEqual({})
2742
- })
2743
-
2744
- test("mistral models return empty object", () => {
2745
- const model = createMockModel({
2746
- id: "sap-ai-core/mistral--mistral-large",
2747
- providerID: "sap-ai-core",
2748
- api: {
2749
- id: "mistral--mistral-large",
2750
- url: "https://api.ai.sap",
2751
- npm: "@jerome-benoit/sap-ai-provider-v2",
2752
- },
2753
- })
2754
- const result = ProviderTransform.variants(model)
2755
- expect(result).toEqual({})
2756
- })
2757
- })
2758
- })