opencode-v2 1.1.53

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 (439) hide show
  1. package/AGENTS.md +27 -0
  2. package/Dockerfile +18 -0
  3. package/README.md +15 -0
  4. package/bin/opencode +84 -0
  5. package/bunfig.toml +5 -0
  6. package/package.json +126 -0
  7. package/parsers-config.ts +253 -0
  8. package/script/build.ts +193 -0
  9. package/script/postinstall.mjs +125 -0
  10. package/script/publish.ts +181 -0
  11. package/script/schema.ts +47 -0
  12. package/script/seed-e2e.ts +50 -0
  13. package/src/acp/README.md +164 -0
  14. package/src/acp/agent.ts +1676 -0
  15. package/src/acp/session.ts +117 -0
  16. package/src/acp/types.ts +23 -0
  17. package/src/agent/agent.ts +414 -0
  18. package/src/agent/generate.txt +75 -0
  19. package/src/agent/prompt/compaction.txt +12 -0
  20. package/src/agent/prompt/explore.txt +18 -0
  21. package/src/agent/prompt/summary.txt +11 -0
  22. package/src/agent/prompt/title.txt +44 -0
  23. package/src/auth/index.ts +70 -0
  24. package/src/bun/index.ts +137 -0
  25. package/src/bun/registry.ts +48 -0
  26. package/src/bus/bus-event.ts +43 -0
  27. package/src/bus/global.ts +10 -0
  28. package/src/bus/index.ts +105 -0
  29. package/src/cli/bootstrap.ts +17 -0
  30. package/src/cli/cmd/acp.ts +70 -0
  31. package/src/cli/cmd/agent.ts +257 -0
  32. package/src/cli/cmd/auth.ts +400 -0
  33. package/src/cli/cmd/cmd.ts +7 -0
  34. package/src/cli/cmd/debug/agent.ts +167 -0
  35. package/src/cli/cmd/debug/config.ts +16 -0
  36. package/src/cli/cmd/debug/file.ts +97 -0
  37. package/src/cli/cmd/debug/index.ts +48 -0
  38. package/src/cli/cmd/debug/lsp.ts +52 -0
  39. package/src/cli/cmd/debug/ripgrep.ts +87 -0
  40. package/src/cli/cmd/debug/scrap.ts +16 -0
  41. package/src/cli/cmd/debug/skill.ts +16 -0
  42. package/src/cli/cmd/debug/snapshot.ts +52 -0
  43. package/src/cli/cmd/export.ts +88 -0
  44. package/src/cli/cmd/generate.ts +38 -0
  45. package/src/cli/cmd/github.ts +1540 -0
  46. package/src/cli/cmd/import.ts +147 -0
  47. package/src/cli/cmd/mcp.ts +755 -0
  48. package/src/cli/cmd/models.ts +77 -0
  49. package/src/cli/cmd/pr.ts +112 -0
  50. package/src/cli/cmd/run.ts +617 -0
  51. package/src/cli/cmd/serve.ts +20 -0
  52. package/src/cli/cmd/session.ts +135 -0
  53. package/src/cli/cmd/stats.ts +426 -0
  54. package/src/cli/cmd/tui/app.tsx +801 -0
  55. package/src/cli/cmd/tui/attach.ts +52 -0
  56. package/src/cli/cmd/tui/component/border.tsx +21 -0
  57. package/src/cli/cmd/tui/component/dialog-agent.tsx +31 -0
  58. package/src/cli/cmd/tui/component/dialog-command.tsx +148 -0
  59. package/src/cli/cmd/tui/component/dialog-mcp.tsx +86 -0
  60. package/src/cli/cmd/tui/component/dialog-model.tsx +234 -0
  61. package/src/cli/cmd/tui/component/dialog-provider.tsx +266 -0
  62. package/src/cli/cmd/tui/component/dialog-session-list.tsx +108 -0
  63. package/src/cli/cmd/tui/component/dialog-session-rename.tsx +31 -0
  64. package/src/cli/cmd/tui/component/dialog-skill.tsx +36 -0
  65. package/src/cli/cmd/tui/component/dialog-stash.tsx +87 -0
  66. package/src/cli/cmd/tui/component/dialog-status.tsx +177 -0
  67. package/src/cli/cmd/tui/component/dialog-tag.tsx +44 -0
  68. package/src/cli/cmd/tui/component/dialog-theme-list.tsx +50 -0
  69. package/src/cli/cmd/tui/component/logo.tsx +85 -0
  70. package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +666 -0
  71. package/src/cli/cmd/tui/component/prompt/frecency.tsx +89 -0
  72. package/src/cli/cmd/tui/component/prompt/history.tsx +108 -0
  73. package/src/cli/cmd/tui/component/prompt/index.tsx +1132 -0
  74. package/src/cli/cmd/tui/component/prompt/stash.tsx +101 -0
  75. package/src/cli/cmd/tui/component/spinner.tsx +24 -0
  76. package/src/cli/cmd/tui/component/textarea-keybindings.ts +73 -0
  77. package/src/cli/cmd/tui/component/tips.tsx +153 -0
  78. package/src/cli/cmd/tui/component/todo-item.tsx +32 -0
  79. package/src/cli/cmd/tui/context/args.tsx +15 -0
  80. package/src/cli/cmd/tui/context/directory.ts +13 -0
  81. package/src/cli/cmd/tui/context/exit.tsx +52 -0
  82. package/src/cli/cmd/tui/context/helper.tsx +25 -0
  83. package/src/cli/cmd/tui/context/keybind.tsx +100 -0
  84. package/src/cli/cmd/tui/context/kv.tsx +52 -0
  85. package/src/cli/cmd/tui/context/local.tsx +409 -0
  86. package/src/cli/cmd/tui/context/prompt.tsx +18 -0
  87. package/src/cli/cmd/tui/context/route.tsx +46 -0
  88. package/src/cli/cmd/tui/context/sdk.tsx +101 -0
  89. package/src/cli/cmd/tui/context/sync.tsx +470 -0
  90. package/src/cli/cmd/tui/context/theme/aura.json +69 -0
  91. package/src/cli/cmd/tui/context/theme/ayu.json +80 -0
  92. package/src/cli/cmd/tui/context/theme/carbonfox.json +248 -0
  93. package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +233 -0
  94. package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +233 -0
  95. package/src/cli/cmd/tui/context/theme/catppuccin.json +112 -0
  96. package/src/cli/cmd/tui/context/theme/cobalt2.json +228 -0
  97. package/src/cli/cmd/tui/context/theme/cursor.json +249 -0
  98. package/src/cli/cmd/tui/context/theme/dracula.json +219 -0
  99. package/src/cli/cmd/tui/context/theme/everforest.json +241 -0
  100. package/src/cli/cmd/tui/context/theme/flexoki.json +237 -0
  101. package/src/cli/cmd/tui/context/theme/github.json +233 -0
  102. package/src/cli/cmd/tui/context/theme/gruvbox.json +242 -0
  103. package/src/cli/cmd/tui/context/theme/kanagawa.json +77 -0
  104. package/src/cli/cmd/tui/context/theme/lucent-orng.json +237 -0
  105. package/src/cli/cmd/tui/context/theme/material.json +235 -0
  106. package/src/cli/cmd/tui/context/theme/matrix.json +77 -0
  107. package/src/cli/cmd/tui/context/theme/mercury.json +252 -0
  108. package/src/cli/cmd/tui/context/theme/monokai.json +221 -0
  109. package/src/cli/cmd/tui/context/theme/nightowl.json +221 -0
  110. package/src/cli/cmd/tui/context/theme/nord.json +223 -0
  111. package/src/cli/cmd/tui/context/theme/one-dark.json +84 -0
  112. package/src/cli/cmd/tui/context/theme/orng.json +249 -0
  113. package/src/cli/cmd/tui/context/theme/osaka-jade.json +93 -0
  114. package/src/cli/cmd/tui/context/theme/palenight.json +222 -0
  115. package/src/cli/cmd/tui/context/theme/rosepine.json +234 -0
  116. package/src/cli/cmd/tui/context/theme/solarized.json +223 -0
  117. package/src/cli/cmd/tui/context/theme/synthwave84.json +226 -0
  118. package/src/cli/cmd/tui/context/theme/tokyonight.json +243 -0
  119. package/src/cli/cmd/tui/context/theme/vercel.json +245 -0
  120. package/src/cli/cmd/tui/context/theme/vesper.json +218 -0
  121. package/src/cli/cmd/tui/context/theme/zenburn.json +223 -0
  122. package/src/cli/cmd/tui/context/theme.tsx +1152 -0
  123. package/src/cli/cmd/tui/event.ts +48 -0
  124. package/src/cli/cmd/tui/routes/home.tsx +140 -0
  125. package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +64 -0
  126. package/src/cli/cmd/tui/routes/session/dialog-message.tsx +109 -0
  127. package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +26 -0
  128. package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +47 -0
  129. package/src/cli/cmd/tui/routes/session/footer.tsx +91 -0
  130. package/src/cli/cmd/tui/routes/session/header.tsx +142 -0
  131. package/src/cli/cmd/tui/routes/session/index.tsx +2126 -0
  132. package/src/cli/cmd/tui/routes/session/permission.tsx +508 -0
  133. package/src/cli/cmd/tui/routes/session/question.tsx +466 -0
  134. package/src/cli/cmd/tui/routes/session/sidebar.tsx +313 -0
  135. package/src/cli/cmd/tui/thread.ts +175 -0
  136. package/src/cli/cmd/tui/ui/dialog-alert.tsx +68 -0
  137. package/src/cli/cmd/tui/ui/dialog-confirm.tsx +93 -0
  138. package/src/cli/cmd/tui/ui/dialog-export-options.tsx +215 -0
  139. package/src/cli/cmd/tui/ui/dialog-help.tsx +49 -0
  140. package/src/cli/cmd/tui/ui/dialog-prompt.tsx +88 -0
  141. package/src/cli/cmd/tui/ui/dialog-select.tsx +399 -0
  142. package/src/cli/cmd/tui/ui/dialog.tsx +167 -0
  143. package/src/cli/cmd/tui/ui/link.tsx +28 -0
  144. package/src/cli/cmd/tui/ui/spinner.ts +368 -0
  145. package/src/cli/cmd/tui/ui/toast.tsx +100 -0
  146. package/src/cli/cmd/tui/util/clipboard.ts +159 -0
  147. package/src/cli/cmd/tui/util/editor.ts +32 -0
  148. package/src/cli/cmd/tui/util/signal.ts +7 -0
  149. package/src/cli/cmd/tui/util/terminal.ts +114 -0
  150. package/src/cli/cmd/tui/util/transcript.ts +98 -0
  151. package/src/cli/cmd/tui/worker.ts +152 -0
  152. package/src/cli/cmd/uninstall.ts +357 -0
  153. package/src/cli/cmd/upgrade.ts +73 -0
  154. package/src/cli/cmd/web.ts +81 -0
  155. package/src/cli/error.ts +57 -0
  156. package/src/cli/logo.ts +6 -0
  157. package/src/cli/network.ts +60 -0
  158. package/src/cli/ui.ts +113 -0
  159. package/src/cli/upgrade.ts +25 -0
  160. package/src/command/index.ts +150 -0
  161. package/src/command/template/initialize.txt +10 -0
  162. package/src/command/template/review.txt +99 -0
  163. package/src/config/config.ts +1477 -0
  164. package/src/config/markdown.ts +98 -0
  165. package/src/env/index.ts +28 -0
  166. package/src/file/ignore.ts +83 -0
  167. package/src/file/index.ts +583 -0
  168. package/src/file/ripgrep.ts +375 -0
  169. package/src/file/time.ts +69 -0
  170. package/src/file/watcher.ts +127 -0
  171. package/src/flag/flag.ts +97 -0
  172. package/src/format/formatter.ts +366 -0
  173. package/src/format/index.ts +137 -0
  174. package/src/global/index.ts +55 -0
  175. package/src/id/id.ts +83 -0
  176. package/src/ide/index.ts +76 -0
  177. package/src/index.ts +159 -0
  178. package/src/installation/index.ts +246 -0
  179. package/src/lsp/client.ts +252 -0
  180. package/src/lsp/index.ts +485 -0
  181. package/src/lsp/language.ts +119 -0
  182. package/src/lsp/server.ts +2046 -0
  183. package/src/mcp/auth.ts +132 -0
  184. package/src/mcp/index.ts +934 -0
  185. package/src/mcp/oauth-callback.ts +200 -0
  186. package/src/mcp/oauth-provider.ts +154 -0
  187. package/src/patch/index.ts +680 -0
  188. package/src/permission/arity.ts +163 -0
  189. package/src/permission/index.ts +210 -0
  190. package/src/permission/next.ts +280 -0
  191. package/src/plugin/codex.ts +624 -0
  192. package/src/plugin/copilot.ts +327 -0
  193. package/src/plugin/index.ts +138 -0
  194. package/src/project/bootstrap.ts +35 -0
  195. package/src/project/instance.ts +114 -0
  196. package/src/project/project.ts +371 -0
  197. package/src/project/state.ts +70 -0
  198. package/src/project/vcs.ts +76 -0
  199. package/src/provider/auth.ts +147 -0
  200. package/src/provider/models.ts +133 -0
  201. package/src/provider/provider.ts +1262 -0
  202. package/src/provider/sdk/copilot/README.md +5 -0
  203. package/src/provider/sdk/copilot/chat/convert-to-openai-compatible-chat-messages.ts +164 -0
  204. package/src/provider/sdk/copilot/chat/get-response-metadata.ts +15 -0
  205. package/src/provider/sdk/copilot/chat/map-openai-compatible-finish-reason.ts +17 -0
  206. package/src/provider/sdk/copilot/chat/openai-compatible-api-types.ts +64 -0
  207. package/src/provider/sdk/copilot/chat/openai-compatible-chat-language-model.ts +780 -0
  208. package/src/provider/sdk/copilot/chat/openai-compatible-chat-options.ts +28 -0
  209. package/src/provider/sdk/copilot/chat/openai-compatible-metadata-extractor.ts +44 -0
  210. package/src/provider/sdk/copilot/chat/openai-compatible-prepare-tools.ts +87 -0
  211. package/src/provider/sdk/copilot/copilot-provider.ts +100 -0
  212. package/src/provider/sdk/copilot/index.ts +2 -0
  213. package/src/provider/sdk/copilot/openai-compatible-error.ts +27 -0
  214. package/src/provider/sdk/copilot/responses/convert-to-openai-responses-input.ts +303 -0
  215. package/src/provider/sdk/copilot/responses/map-openai-responses-finish-reason.ts +22 -0
  216. package/src/provider/sdk/copilot/responses/openai-config.ts +18 -0
  217. package/src/provider/sdk/copilot/responses/openai-error.ts +22 -0
  218. package/src/provider/sdk/copilot/responses/openai-responses-api-types.ts +207 -0
  219. package/src/provider/sdk/copilot/responses/openai-responses-language-model.ts +1732 -0
  220. package/src/provider/sdk/copilot/responses/openai-responses-prepare-tools.ts +177 -0
  221. package/src/provider/sdk/copilot/responses/openai-responses-settings.ts +1 -0
  222. package/src/provider/sdk/copilot/responses/tool/code-interpreter.ts +88 -0
  223. package/src/provider/sdk/copilot/responses/tool/file-search.ts +128 -0
  224. package/src/provider/sdk/copilot/responses/tool/image-generation.ts +115 -0
  225. package/src/provider/sdk/copilot/responses/tool/local-shell.ts +65 -0
  226. package/src/provider/sdk/copilot/responses/tool/web-search-preview.ts +104 -0
  227. package/src/provider/sdk/copilot/responses/tool/web-search.ts +103 -0
  228. package/src/provider/transform.ts +828 -0
  229. package/src/pty/index.ts +250 -0
  230. package/src/question/index.ts +171 -0
  231. package/src/scheduler/index.ts +61 -0
  232. package/src/server/error.ts +36 -0
  233. package/src/server/event.ts +7 -0
  234. package/src/server/mdns.ts +60 -0
  235. package/src/server/routes/config.ts +92 -0
  236. package/src/server/routes/experimental.ts +208 -0
  237. package/src/server/routes/file.ts +197 -0
  238. package/src/server/routes/global.ts +183 -0
  239. package/src/server/routes/mcp.ts +225 -0
  240. package/src/server/routes/permission.ts +68 -0
  241. package/src/server/routes/project.ts +82 -0
  242. package/src/server/routes/provider.ts +165 -0
  243. package/src/server/routes/pty.ts +169 -0
  244. package/src/server/routes/question.ts +98 -0
  245. package/src/server/routes/session.ts +939 -0
  246. package/src/server/routes/tui.ts +379 -0
  247. package/src/server/server.ts +613 -0
  248. package/src/session/compaction.ts +226 -0
  249. package/src/session/index.ts +524 -0
  250. package/src/session/instruction.ts +197 -0
  251. package/src/session/llm.ts +289 -0
  252. package/src/session/message-v2.ts +802 -0
  253. package/src/session/message.ts +189 -0
  254. package/src/session/processor.ts +407 -0
  255. package/src/session/prompt/agent.txt +43 -0
  256. package/src/session/prompt/anthropic-20250930.txt +166 -0
  257. package/src/session/prompt/anthropic.txt +105 -0
  258. package/src/session/prompt/beast.txt +147 -0
  259. package/src/session/prompt/build-switch.txt +5 -0
  260. package/src/session/prompt/codex_header.txt +79 -0
  261. package/src/session/prompt/copilot-gpt-5.txt +143 -0
  262. package/src/session/prompt/gemini.txt +155 -0
  263. package/src/session/prompt/max-steps.txt +16 -0
  264. package/src/session/prompt/plan-reminder-anthropic.txt +67 -0
  265. package/src/session/prompt/plan.txt +26 -0
  266. package/src/session/prompt/qwen.txt +109 -0
  267. package/src/session/prompt/research.txt +81 -0
  268. package/src/session/prompt/trinity.txt +97 -0
  269. package/src/session/prompt.ts +1952 -0
  270. package/src/session/retry.ts +97 -0
  271. package/src/session/revert.ts +121 -0
  272. package/src/session/status.ts +76 -0
  273. package/src/session/summary.ts +217 -0
  274. package/src/session/system.ts +54 -0
  275. package/src/session/todo.ts +37 -0
  276. package/src/share/share-next.ts +200 -0
  277. package/src/share/share.ts +92 -0
  278. package/src/shell/shell.ts +67 -0
  279. package/src/skill/discovery.ts +97 -0
  280. package/src/skill/index.ts +1 -0
  281. package/src/skill/skill.ts +188 -0
  282. package/src/snapshot/index.ts +255 -0
  283. package/src/storage/storage.ts +227 -0
  284. package/src/tool/agent-enter.txt +1 -0
  285. package/src/tool/agent-exit.txt +1 -0
  286. package/src/tool/agent.ts +237 -0
  287. package/src/tool/apply_patch.ts +281 -0
  288. package/src/tool/apply_patch.txt +33 -0
  289. package/src/tool/bash.ts +269 -0
  290. package/src/tool/bash.txt +115 -0
  291. package/src/tool/batch.ts +175 -0
  292. package/src/tool/batch.txt +24 -0
  293. package/src/tool/chat-enter.txt +15 -0
  294. package/src/tool/chat-exit.txt +7 -0
  295. package/src/tool/chat.ts +217 -0
  296. package/src/tool/codesearch.ts +132 -0
  297. package/src/tool/codesearch.txt +12 -0
  298. package/src/tool/edit.ts +655 -0
  299. package/src/tool/edit.txt +10 -0
  300. package/src/tool/external-directory.ts +32 -0
  301. package/src/tool/glob.ts +78 -0
  302. package/src/tool/glob.txt +6 -0
  303. package/src/tool/grep.ts +147 -0
  304. package/src/tool/grep.txt +8 -0
  305. package/src/tool/invalid.ts +17 -0
  306. package/src/tool/ls.ts +121 -0
  307. package/src/tool/ls.txt +1 -0
  308. package/src/tool/lsp.ts +96 -0
  309. package/src/tool/lsp.txt +19 -0
  310. package/src/tool/multiedit.ts +46 -0
  311. package/src/tool/multiedit.txt +41 -0
  312. package/src/tool/plan-enter.txt +14 -0
  313. package/src/tool/plan-exit.txt +13 -0
  314. package/src/tool/plan.ts +130 -0
  315. package/src/tool/question.ts +33 -0
  316. package/src/tool/question.txt +10 -0
  317. package/src/tool/read.ts +211 -0
  318. package/src/tool/read.txt +12 -0
  319. package/src/tool/registry.ts +167 -0
  320. package/src/tool/research-enter.txt +1 -0
  321. package/src/tool/research-exit.txt +1 -0
  322. package/src/tool/research.ts +134 -0
  323. package/src/tool/skill.ts +123 -0
  324. package/src/tool/task.ts +165 -0
  325. package/src/tool/task.txt +60 -0
  326. package/src/tool/todo.ts +53 -0
  327. package/src/tool/todoread.txt +14 -0
  328. package/src/tool/todowrite.txt +167 -0
  329. package/src/tool/tool.ts +89 -0
  330. package/src/tool/truncation.ts +106 -0
  331. package/src/tool/webfetch.ts +186 -0
  332. package/src/tool/webfetch.txt +13 -0
  333. package/src/tool/websearch.ts +150 -0
  334. package/src/tool/websearch.txt +14 -0
  335. package/src/tool/write.ts +85 -0
  336. package/src/tool/write.txt +8 -0
  337. package/src/util/abort.ts +35 -0
  338. package/src/util/archive.ts +16 -0
  339. package/src/util/color.ts +19 -0
  340. package/src/util/context.ts +25 -0
  341. package/src/util/defer.ts +12 -0
  342. package/src/util/eventloop.ts +20 -0
  343. package/src/util/filesystem.ts +93 -0
  344. package/src/util/fn.ts +11 -0
  345. package/src/util/format.ts +20 -0
  346. package/src/util/iife.ts +3 -0
  347. package/src/util/keybind.ts +103 -0
  348. package/src/util/lazy.ts +18 -0
  349. package/src/util/locale.ts +81 -0
  350. package/src/util/lock.ts +98 -0
  351. package/src/util/log.ts +180 -0
  352. package/src/util/proxied.ts +3 -0
  353. package/src/util/queue.ts +32 -0
  354. package/src/util/rpc.ts +66 -0
  355. package/src/util/scrap.ts +10 -0
  356. package/src/util/signal.ts +12 -0
  357. package/src/util/timeout.ts +14 -0
  358. package/src/util/token.ts +7 -0
  359. package/src/util/wildcard.ts +56 -0
  360. package/src/worktree/index.ts +574 -0
  361. package/sst-env.d.ts +9 -0
  362. package/test/acp/agent-interface.test.ts +51 -0
  363. package/test/acp/event-subscription.test.ts +436 -0
  364. package/test/agent/agent.test.ts +675 -0
  365. package/test/bun.test.ts +53 -0
  366. package/test/cli/github-action.test.ts +161 -0
  367. package/test/cli/github-remote.test.ts +80 -0
  368. package/test/cli/import.test.ts +38 -0
  369. package/test/cli/tui/transcript.test.ts +322 -0
  370. package/test/config/agent-color.test.ts +71 -0
  371. package/test/config/config.test.ts +1802 -0
  372. package/test/config/fixtures/empty-frontmatter.md +4 -0
  373. package/test/config/fixtures/frontmatter.md +28 -0
  374. package/test/config/fixtures/markdown-header.md +11 -0
  375. package/test/config/fixtures/no-frontmatter.md +1 -0
  376. package/test/config/fixtures/weird-model-id.md +13 -0
  377. package/test/config/markdown.test.ts +228 -0
  378. package/test/file/ignore.test.ts +10 -0
  379. package/test/file/path-traversal.test.ts +198 -0
  380. package/test/file/ripgrep.test.ts +39 -0
  381. package/test/fixture/fixture.ts +45 -0
  382. package/test/fixture/lsp/fake-lsp-server.js +77 -0
  383. package/test/ide/ide.test.ts +82 -0
  384. package/test/keybind.test.ts +421 -0
  385. package/test/lsp/client.test.ts +95 -0
  386. package/test/mcp/headers.test.ts +153 -0
  387. package/test/mcp/oauth-browser.test.ts +249 -0
  388. package/test/memory/abort-leak.test.ts +136 -0
  389. package/test/patch/patch.test.ts +348 -0
  390. package/test/permission/arity.test.ts +33 -0
  391. package/test/permission/next.test.ts +690 -0
  392. package/test/permission-task.test.ts +319 -0
  393. package/test/plugin/auth-override.test.ts +44 -0
  394. package/test/plugin/codex.test.ts +123 -0
  395. package/test/preload.ts +63 -0
  396. package/test/project/project.test.ts +120 -0
  397. package/test/provider/amazon-bedrock.test.ts +445 -0
  398. package/test/provider/copilot/convert-to-copilot-messages.test.ts +523 -0
  399. package/test/provider/copilot/copilot-chat-model.test.ts +592 -0
  400. package/test/provider/gitlab-duo.test.ts +262 -0
  401. package/test/provider/provider.test.ts +2129 -0
  402. package/test/provider/transform.test.ts +2022 -0
  403. package/test/question/question.test.ts +300 -0
  404. package/test/scheduler.test.ts +73 -0
  405. package/test/server/session-list.test.ts +39 -0
  406. package/test/server/session-select.test.ts +78 -0
  407. package/test/session/compaction.test.ts +293 -0
  408. package/test/session/instruction.test.ts +170 -0
  409. package/test/session/llm.test.ts +691 -0
  410. package/test/session/message-v2.test.ts +786 -0
  411. package/test/session/prompt-missing-file.test.ts +53 -0
  412. package/test/session/prompt-special-chars.test.ts +56 -0
  413. package/test/session/prompt-variant.test.ts +60 -0
  414. package/test/session/retry.test.ts +179 -0
  415. package/test/session/revert-compact.test.ts +285 -0
  416. package/test/session/session.test.ts +71 -0
  417. package/test/skill/discovery.test.ts +60 -0
  418. package/test/skill/skill.test.ts +388 -0
  419. package/test/snapshot/snapshot.test.ts +1040 -0
  420. package/test/tool/__snapshots__/tool.test.ts.snap +9 -0
  421. package/test/tool/apply_patch.test.ts +559 -0
  422. package/test/tool/bash.test.ts +399 -0
  423. package/test/tool/external-directory.test.ts +127 -0
  424. package/test/tool/fixtures/large-image.png +0 -0
  425. package/test/tool/fixtures/models-api.json +38413 -0
  426. package/test/tool/grep.test.ts +110 -0
  427. package/test/tool/question.test.ts +107 -0
  428. package/test/tool/read.test.ts +358 -0
  429. package/test/tool/registry.test.ts +122 -0
  430. package/test/tool/skill.test.ts +112 -0
  431. package/test/tool/truncation.test.ts +159 -0
  432. package/test/util/filesystem.test.ts +39 -0
  433. package/test/util/format.test.ts +59 -0
  434. package/test/util/iife.test.ts +36 -0
  435. package/test/util/lazy.test.ts +50 -0
  436. package/test/util/lock.test.ts +72 -0
  437. package/test/util/timeout.test.ts +21 -0
  438. package/test/util/wildcard.test.ts +75 -0
  439. package/tsconfig.json +16 -0
@@ -0,0 +1,2022 @@
1
+ import { describe, expect, test } from "bun:test"
2
+ import { ProviderTransform } from "../../src/provider/transform"
3
+
4
+ const OUTPUT_TOKEN_MAX = 32000
5
+
6
+ describe("ProviderTransform.options - setCacheKey", () => {
7
+ const sessionID = "test-session-123"
8
+
9
+ const mockModel = {
10
+ id: "anthropic/claude-3-5-sonnet",
11
+ providerID: "anthropic",
12
+ api: {
13
+ id: "claude-3-5-sonnet-20241022",
14
+ url: "https://api.anthropic.com",
15
+ npm: "@ai-sdk/anthropic",
16
+ },
17
+ name: "Claude 3.5 Sonnet",
18
+ capabilities: {
19
+ temperature: true,
20
+ reasoning: false,
21
+ attachment: true,
22
+ toolcall: true,
23
+ input: { text: true, audio: false, image: true, video: false, pdf: true },
24
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
25
+ interleaved: false,
26
+ },
27
+ cost: {
28
+ input: 0.003,
29
+ output: 0.015,
30
+ cache: { read: 0.0003, write: 0.00375 },
31
+ },
32
+ limit: {
33
+ context: 200000,
34
+ output: 8192,
35
+ },
36
+ status: "active",
37
+ options: {},
38
+ headers: {},
39
+ } as any
40
+
41
+ test("should set promptCacheKey when providerOptions.setCacheKey is true", () => {
42
+ const result = ProviderTransform.options({
43
+ model: mockModel,
44
+ sessionID,
45
+ providerOptions: { setCacheKey: true },
46
+ })
47
+ expect(result.promptCacheKey).toBe(sessionID)
48
+ })
49
+
50
+ test("should not set promptCacheKey when providerOptions.setCacheKey is false", () => {
51
+ const result = ProviderTransform.options({
52
+ model: mockModel,
53
+ sessionID,
54
+ providerOptions: { setCacheKey: false },
55
+ })
56
+ expect(result.promptCacheKey).toBeUndefined()
57
+ })
58
+
59
+ test("should not set promptCacheKey when providerOptions is undefined", () => {
60
+ const result = ProviderTransform.options({
61
+ model: mockModel,
62
+ sessionID,
63
+ providerOptions: undefined,
64
+ })
65
+ expect(result.promptCacheKey).toBeUndefined()
66
+ })
67
+
68
+ test("should not set promptCacheKey when providerOptions does not have setCacheKey", () => {
69
+ const result = ProviderTransform.options({ model: mockModel, sessionID, providerOptions: {} })
70
+ expect(result.promptCacheKey).toBeUndefined()
71
+ })
72
+
73
+ test("should set promptCacheKey for openai provider regardless of setCacheKey", () => {
74
+ const openaiModel = {
75
+ ...mockModel,
76
+ providerID: "openai",
77
+ api: {
78
+ id: "gpt-4",
79
+ url: "https://api.openai.com",
80
+ npm: "@ai-sdk/openai",
81
+ },
82
+ }
83
+ const result = ProviderTransform.options({ model: openaiModel, sessionID, providerOptions: {} })
84
+ expect(result.promptCacheKey).toBe(sessionID)
85
+ })
86
+
87
+ test("should set store=false for openai provider", () => {
88
+ const openaiModel = {
89
+ ...mockModel,
90
+ providerID: "openai",
91
+ api: {
92
+ id: "gpt-4",
93
+ url: "https://api.openai.com",
94
+ npm: "@ai-sdk/openai",
95
+ },
96
+ }
97
+ const result = ProviderTransform.options({
98
+ model: openaiModel,
99
+ sessionID,
100
+ providerOptions: {},
101
+ })
102
+ expect(result.store).toBe(false)
103
+ })
104
+ })
105
+
106
+ describe("ProviderTransform.options - gpt-5 textVerbosity", () => {
107
+ const sessionID = "test-session-123"
108
+
109
+ const createGpt5Model = (apiId: string) =>
110
+ ({
111
+ id: `openai/${apiId}`,
112
+ providerID: "openai",
113
+ api: {
114
+ id: apiId,
115
+ url: "https://api.openai.com",
116
+ npm: "@ai-sdk/openai",
117
+ },
118
+ name: apiId,
119
+ capabilities: {
120
+ temperature: true,
121
+ reasoning: true,
122
+ attachment: true,
123
+ toolcall: true,
124
+ input: { text: true, audio: false, image: true, video: false, pdf: false },
125
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
126
+ interleaved: false,
127
+ },
128
+ cost: { input: 0.03, output: 0.06, cache: { read: 0.001, write: 0.002 } },
129
+ limit: { context: 128000, output: 4096 },
130
+ status: "active",
131
+ options: {},
132
+ headers: {},
133
+ }) as any
134
+
135
+ test("gpt-5.2 should have textVerbosity set to low", () => {
136
+ const model = createGpt5Model("gpt-5.2")
137
+ const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
138
+ expect(result.textVerbosity).toBe("low")
139
+ })
140
+
141
+ test("gpt-5.1 should have textVerbosity set to low", () => {
142
+ const model = createGpt5Model("gpt-5.1")
143
+ const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
144
+ expect(result.textVerbosity).toBe("low")
145
+ })
146
+
147
+ test("gpt-5.2-chat-latest should NOT have textVerbosity set (only supports medium)", () => {
148
+ const model = createGpt5Model("gpt-5.2-chat-latest")
149
+ const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
150
+ expect(result.textVerbosity).toBeUndefined()
151
+ })
152
+
153
+ test("gpt-5.1-chat-latest should NOT have textVerbosity set (only supports medium)", () => {
154
+ const model = createGpt5Model("gpt-5.1-chat-latest")
155
+ const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
156
+ expect(result.textVerbosity).toBeUndefined()
157
+ })
158
+
159
+ test("gpt-5.2-chat should NOT have textVerbosity set", () => {
160
+ const model = createGpt5Model("gpt-5.2-chat")
161
+ const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
162
+ expect(result.textVerbosity).toBeUndefined()
163
+ })
164
+
165
+ test("gpt-5-chat should NOT have textVerbosity set", () => {
166
+ const model = createGpt5Model("gpt-5-chat")
167
+ const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
168
+ expect(result.textVerbosity).toBeUndefined()
169
+ })
170
+
171
+ test("gpt-5.2-codex should NOT have textVerbosity set (codex models excluded)", () => {
172
+ const model = createGpt5Model("gpt-5.2-codex")
173
+ const result = ProviderTransform.options({ model, sessionID, providerOptions: {} })
174
+ expect(result.textVerbosity).toBeUndefined()
175
+ })
176
+ })
177
+
178
+ describe("ProviderTransform.maxOutputTokens", () => {
179
+ test("returns 32k when modelLimit > 32k", () => {
180
+ const modelLimit = 100000
181
+ const result = ProviderTransform.maxOutputTokens("@ai-sdk/openai", {}, modelLimit, OUTPUT_TOKEN_MAX)
182
+ expect(result).toBe(OUTPUT_TOKEN_MAX)
183
+ })
184
+
185
+ test("returns modelLimit when modelLimit < 32k", () => {
186
+ const modelLimit = 16000
187
+ const result = ProviderTransform.maxOutputTokens("@ai-sdk/openai", {}, modelLimit, OUTPUT_TOKEN_MAX)
188
+ expect(result).toBe(16000)
189
+ })
190
+
191
+ describe("azure", () => {
192
+ test("returns 32k when modelLimit > 32k", () => {
193
+ const modelLimit = 100000
194
+ const result = ProviderTransform.maxOutputTokens("@ai-sdk/azure", {}, modelLimit, OUTPUT_TOKEN_MAX)
195
+ expect(result).toBe(OUTPUT_TOKEN_MAX)
196
+ })
197
+
198
+ test("returns modelLimit when modelLimit < 32k", () => {
199
+ const modelLimit = 16000
200
+ const result = ProviderTransform.maxOutputTokens("@ai-sdk/azure", {}, modelLimit, OUTPUT_TOKEN_MAX)
201
+ expect(result).toBe(16000)
202
+ })
203
+ })
204
+
205
+ describe("bedrock", () => {
206
+ test("returns 32k when modelLimit > 32k", () => {
207
+ const modelLimit = 100000
208
+ const result = ProviderTransform.maxOutputTokens("@ai-sdk/amazon-bedrock", {}, modelLimit, OUTPUT_TOKEN_MAX)
209
+ expect(result).toBe(OUTPUT_TOKEN_MAX)
210
+ })
211
+
212
+ test("returns modelLimit when modelLimit < 32k", () => {
213
+ const modelLimit = 16000
214
+ const result = ProviderTransform.maxOutputTokens("@ai-sdk/amazon-bedrock", {}, modelLimit, OUTPUT_TOKEN_MAX)
215
+ expect(result).toBe(16000)
216
+ })
217
+ })
218
+
219
+ describe("anthropic without thinking options", () => {
220
+ test("returns 32k when modelLimit > 32k", () => {
221
+ const modelLimit = 100000
222
+ const result = ProviderTransform.maxOutputTokens("@ai-sdk/anthropic", {}, modelLimit, OUTPUT_TOKEN_MAX)
223
+ expect(result).toBe(OUTPUT_TOKEN_MAX)
224
+ })
225
+
226
+ test("returns modelLimit when modelLimit < 32k", () => {
227
+ const modelLimit = 16000
228
+ const result = ProviderTransform.maxOutputTokens("@ai-sdk/anthropic", {}, modelLimit, OUTPUT_TOKEN_MAX)
229
+ expect(result).toBe(16000)
230
+ })
231
+ })
232
+
233
+ describe("anthropic with thinking options", () => {
234
+ test("returns 32k when budgetTokens + 32k <= modelLimit", () => {
235
+ const modelLimit = 100000
236
+ const options = {
237
+ thinking: {
238
+ type: "enabled",
239
+ budgetTokens: 10000,
240
+ },
241
+ }
242
+ const result = ProviderTransform.maxOutputTokens("@ai-sdk/anthropic", options, modelLimit, OUTPUT_TOKEN_MAX)
243
+ expect(result).toBe(OUTPUT_TOKEN_MAX)
244
+ })
245
+
246
+ test("returns modelLimit - budgetTokens when budgetTokens + 32k > modelLimit", () => {
247
+ const modelLimit = 50000
248
+ const options = {
249
+ thinking: {
250
+ type: "enabled",
251
+ budgetTokens: 30000,
252
+ },
253
+ }
254
+ const result = ProviderTransform.maxOutputTokens("@ai-sdk/anthropic", options, modelLimit, OUTPUT_TOKEN_MAX)
255
+ expect(result).toBe(20000)
256
+ })
257
+
258
+ test("returns 32k when thinking type is not enabled", () => {
259
+ const modelLimit = 100000
260
+ const options = {
261
+ thinking: {
262
+ type: "disabled",
263
+ budgetTokens: 10000,
264
+ },
265
+ }
266
+ const result = ProviderTransform.maxOutputTokens("@ai-sdk/anthropic", options, modelLimit, OUTPUT_TOKEN_MAX)
267
+ expect(result).toBe(OUTPUT_TOKEN_MAX)
268
+ })
269
+ })
270
+ })
271
+
272
+ describe("ProviderTransform.schema - gemini array items", () => {
273
+ test("adds missing items for array properties", () => {
274
+ const geminiModel = {
275
+ providerID: "google",
276
+ api: {
277
+ id: "gemini-3-pro",
278
+ },
279
+ } as any
280
+
281
+ const schema = {
282
+ type: "object",
283
+ properties: {
284
+ nodes: { type: "array" },
285
+ edges: { type: "array", items: { type: "string" } },
286
+ },
287
+ } as any
288
+
289
+ const result = ProviderTransform.schema(geminiModel, schema) as any
290
+
291
+ expect(result.properties.nodes.items).toBeDefined()
292
+ expect(result.properties.edges.items.type).toBe("string")
293
+ })
294
+ })
295
+
296
+ describe("ProviderTransform.schema - gemini nested array items", () => {
297
+ const geminiModel = {
298
+ providerID: "google",
299
+ api: {
300
+ id: "gemini-3-pro",
301
+ },
302
+ } as any
303
+
304
+ test("adds type to 2D array with empty inner items", () => {
305
+ const schema = {
306
+ type: "object",
307
+ properties: {
308
+ values: {
309
+ type: "array",
310
+ items: {
311
+ type: "array",
312
+ items: {}, // Empty items object
313
+ },
314
+ },
315
+ },
316
+ } as any
317
+
318
+ const result = ProviderTransform.schema(geminiModel, schema) as any
319
+
320
+ // Inner items should have a default type
321
+ expect(result.properties.values.items.items.type).toBe("string")
322
+ })
323
+
324
+ test("adds items and type to 2D array with missing inner items", () => {
325
+ const schema = {
326
+ type: "object",
327
+ properties: {
328
+ data: {
329
+ type: "array",
330
+ items: { type: "array" }, // No items at all
331
+ },
332
+ },
333
+ } as any
334
+
335
+ const result = ProviderTransform.schema(geminiModel, schema) as any
336
+
337
+ expect(result.properties.data.items.items).toBeDefined()
338
+ expect(result.properties.data.items.items.type).toBe("string")
339
+ })
340
+
341
+ test("handles deeply nested arrays (3D)", () => {
342
+ const schema = {
343
+ type: "object",
344
+ properties: {
345
+ matrix: {
346
+ type: "array",
347
+ items: {
348
+ type: "array",
349
+ items: {
350
+ type: "array",
351
+ // No items
352
+ },
353
+ },
354
+ },
355
+ },
356
+ } as any
357
+
358
+ const result = ProviderTransform.schema(geminiModel, schema) as any
359
+
360
+ expect(result.properties.matrix.items.items.items).toBeDefined()
361
+ expect(result.properties.matrix.items.items.items.type).toBe("string")
362
+ })
363
+
364
+ test("preserves existing item types in nested arrays", () => {
365
+ const schema = {
366
+ type: "object",
367
+ properties: {
368
+ numbers: {
369
+ type: "array",
370
+ items: {
371
+ type: "array",
372
+ items: { type: "number" }, // Has explicit type
373
+ },
374
+ },
375
+ },
376
+ } as any
377
+
378
+ const result = ProviderTransform.schema(geminiModel, schema) as any
379
+
380
+ // Should preserve the explicit type
381
+ expect(result.properties.numbers.items.items.type).toBe("number")
382
+ })
383
+
384
+ test("handles mixed nested structures with objects and arrays", () => {
385
+ const schema = {
386
+ type: "object",
387
+ properties: {
388
+ spreadsheetData: {
389
+ type: "object",
390
+ properties: {
391
+ rows: {
392
+ type: "array",
393
+ items: {
394
+ type: "array",
395
+ items: {}, // Empty items
396
+ },
397
+ },
398
+ },
399
+ },
400
+ },
401
+ } as any
402
+
403
+ const result = ProviderTransform.schema(geminiModel, schema) as any
404
+
405
+ expect(result.properties.spreadsheetData.properties.rows.items.items.type).toBe("string")
406
+ })
407
+ })
408
+
409
+ describe("ProviderTransform.schema - gemini non-object properties removal", () => {
410
+ const geminiModel = {
411
+ providerID: "google",
412
+ api: {
413
+ id: "gemini-3-pro",
414
+ },
415
+ } as any
416
+
417
+ test("removes properties from non-object types", () => {
418
+ const schema = {
419
+ type: "object",
420
+ properties: {
421
+ data: {
422
+ type: "string",
423
+ properties: { invalid: { type: "string" } },
424
+ },
425
+ },
426
+ } as any
427
+
428
+ const result = ProviderTransform.schema(geminiModel, schema) as any
429
+
430
+ expect(result.properties.data.type).toBe("string")
431
+ expect(result.properties.data.properties).toBeUndefined()
432
+ })
433
+
434
+ test("removes required from non-object types", () => {
435
+ const schema = {
436
+ type: "object",
437
+ properties: {
438
+ data: {
439
+ type: "array",
440
+ items: { type: "string" },
441
+ required: ["invalid"],
442
+ },
443
+ },
444
+ } as any
445
+
446
+ const result = ProviderTransform.schema(geminiModel, schema) as any
447
+
448
+ expect(result.properties.data.type).toBe("array")
449
+ expect(result.properties.data.required).toBeUndefined()
450
+ })
451
+
452
+ test("removes properties and required from nested non-object types", () => {
453
+ const schema = {
454
+ type: "object",
455
+ properties: {
456
+ outer: {
457
+ type: "object",
458
+ properties: {
459
+ inner: {
460
+ type: "number",
461
+ properties: { bad: { type: "string" } },
462
+ required: ["bad"],
463
+ },
464
+ },
465
+ },
466
+ },
467
+ } as any
468
+
469
+ const result = ProviderTransform.schema(geminiModel, schema) as any
470
+
471
+ expect(result.properties.outer.properties.inner.type).toBe("number")
472
+ expect(result.properties.outer.properties.inner.properties).toBeUndefined()
473
+ expect(result.properties.outer.properties.inner.required).toBeUndefined()
474
+ })
475
+
476
+ test("keeps properties and required on object types", () => {
477
+ const schema = {
478
+ type: "object",
479
+ properties: {
480
+ data: {
481
+ type: "object",
482
+ properties: { name: { type: "string" } },
483
+ required: ["name"],
484
+ },
485
+ },
486
+ } as any
487
+
488
+ const result = ProviderTransform.schema(geminiModel, schema) as any
489
+
490
+ expect(result.properties.data.type).toBe("object")
491
+ expect(result.properties.data.properties).toBeDefined()
492
+ expect(result.properties.data.required).toEqual(["name"])
493
+ })
494
+
495
+ test("does not affect non-gemini providers", () => {
496
+ const openaiModel = {
497
+ providerID: "openai",
498
+ api: {
499
+ id: "gpt-4",
500
+ },
501
+ } as any
502
+
503
+ const schema = {
504
+ type: "object",
505
+ properties: {
506
+ data: {
507
+ type: "string",
508
+ properties: { invalid: { type: "string" } },
509
+ },
510
+ },
511
+ } as any
512
+
513
+ const result = ProviderTransform.schema(openaiModel, schema) as any
514
+
515
+ expect(result.properties.data.properties).toBeDefined()
516
+ })
517
+ })
518
+
519
+ describe("ProviderTransform.message - DeepSeek reasoning content", () => {
520
+ test("DeepSeek with tool calls includes reasoning_content in providerOptions", () => {
521
+ const msgs = [
522
+ {
523
+ role: "assistant",
524
+ content: [
525
+ { type: "reasoning", text: "Let me think about this..." },
526
+ {
527
+ type: "tool-call",
528
+ toolCallId: "test",
529
+ toolName: "bash",
530
+ input: { command: "echo hello" },
531
+ },
532
+ ],
533
+ },
534
+ ] as any[]
535
+
536
+ const result = ProviderTransform.message(
537
+ msgs,
538
+ {
539
+ id: "deepseek/deepseek-chat",
540
+ providerID: "deepseek",
541
+ api: {
542
+ id: "deepseek-chat",
543
+ url: "https://api.deepseek.com",
544
+ npm: "@ai-sdk/openai-compatible",
545
+ },
546
+ name: "DeepSeek Chat",
547
+ capabilities: {
548
+ temperature: true,
549
+ reasoning: true,
550
+ attachment: false,
551
+ toolcall: true,
552
+ input: { text: true, audio: false, image: false, video: false, pdf: false },
553
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
554
+ interleaved: {
555
+ field: "reasoning_content",
556
+ },
557
+ },
558
+ cost: {
559
+ input: 0.001,
560
+ output: 0.002,
561
+ cache: { read: 0.0001, write: 0.0002 },
562
+ },
563
+ limit: {
564
+ context: 128000,
565
+ output: 8192,
566
+ },
567
+ status: "active",
568
+ options: {},
569
+ headers: {},
570
+ release_date: "2023-04-01",
571
+ },
572
+ {},
573
+ )
574
+
575
+ expect(result).toHaveLength(1)
576
+ expect(result[0].content).toEqual([
577
+ {
578
+ type: "tool-call",
579
+ toolCallId: "test",
580
+ toolName: "bash",
581
+ input: { command: "echo hello" },
582
+ },
583
+ ])
584
+ expect(result[0].providerOptions?.openaiCompatible?.reasoning_content).toBe("Let me think about this...")
585
+ })
586
+
587
+ test("Non-DeepSeek providers leave reasoning content unchanged", () => {
588
+ const msgs = [
589
+ {
590
+ role: "assistant",
591
+ content: [
592
+ { type: "reasoning", text: "Should not be processed" },
593
+ { type: "text", text: "Answer" },
594
+ ],
595
+ },
596
+ ] as any[]
597
+
598
+ const result = ProviderTransform.message(
599
+ msgs,
600
+ {
601
+ id: "openai/gpt-4",
602
+ providerID: "openai",
603
+ api: {
604
+ id: "gpt-4",
605
+ url: "https://api.openai.com",
606
+ npm: "@ai-sdk/openai",
607
+ },
608
+ name: "GPT-4",
609
+ capabilities: {
610
+ temperature: true,
611
+ reasoning: false,
612
+ attachment: true,
613
+ toolcall: true,
614
+ input: { text: true, audio: false, image: true, video: false, pdf: false },
615
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
616
+ interleaved: false,
617
+ },
618
+ cost: {
619
+ input: 0.03,
620
+ output: 0.06,
621
+ cache: { read: 0.001, write: 0.002 },
622
+ },
623
+ limit: {
624
+ context: 128000,
625
+ output: 4096,
626
+ },
627
+ status: "active",
628
+ options: {},
629
+ headers: {},
630
+ release_date: "2023-04-01",
631
+ },
632
+ {},
633
+ )
634
+
635
+ expect(result[0].content).toEqual([
636
+ { type: "reasoning", text: "Should not be processed" },
637
+ { type: "text", text: "Answer" },
638
+ ])
639
+ expect(result[0].providerOptions?.openaiCompatible?.reasoning_content).toBeUndefined()
640
+ })
641
+ })
642
+
643
+ describe("ProviderTransform.message - empty image handling", () => {
644
+ const mockModel = {
645
+ id: "anthropic/claude-3-5-sonnet",
646
+ providerID: "anthropic",
647
+ api: {
648
+ id: "claude-3-5-sonnet-20241022",
649
+ url: "https://api.anthropic.com",
650
+ npm: "@ai-sdk/anthropic",
651
+ },
652
+ name: "Claude 3.5 Sonnet",
653
+ capabilities: {
654
+ temperature: true,
655
+ reasoning: false,
656
+ attachment: true,
657
+ toolcall: true,
658
+ input: { text: true, audio: false, image: true, video: false, pdf: true },
659
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
660
+ interleaved: false,
661
+ },
662
+ cost: {
663
+ input: 0.003,
664
+ output: 0.015,
665
+ cache: { read: 0.0003, write: 0.00375 },
666
+ },
667
+ limit: {
668
+ context: 200000,
669
+ output: 8192,
670
+ },
671
+ status: "active",
672
+ options: {},
673
+ headers: {},
674
+ } as any
675
+
676
+ test("should replace empty base64 image with error text", () => {
677
+ const msgs = [
678
+ {
679
+ role: "user",
680
+ content: [
681
+ { type: "text", text: "What is in this image?" },
682
+ { type: "image", image: "data:image/png;base64," },
683
+ ],
684
+ },
685
+ ] as any[]
686
+
687
+ const result = ProviderTransform.message(msgs, mockModel, {})
688
+
689
+ expect(result).toHaveLength(1)
690
+ expect(result[0].content).toHaveLength(2)
691
+ expect(result[0].content[0]).toEqual({ type: "text", text: "What is in this image?" })
692
+ expect(result[0].content[1]).toEqual({
693
+ type: "text",
694
+ text: "ERROR: Image file is empty or corrupted. Please provide a valid image.",
695
+ })
696
+ })
697
+
698
+ test("should keep valid base64 images unchanged", () => {
699
+ const validBase64 =
700
+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
701
+ const msgs = [
702
+ {
703
+ role: "user",
704
+ content: [
705
+ { type: "text", text: "What is in this image?" },
706
+ { type: "image", image: `data:image/png;base64,${validBase64}` },
707
+ ],
708
+ },
709
+ ] as any[]
710
+
711
+ const result = ProviderTransform.message(msgs, mockModel, {})
712
+
713
+ expect(result).toHaveLength(1)
714
+ expect(result[0].content).toHaveLength(2)
715
+ expect(result[0].content[0]).toEqual({ type: "text", text: "What is in this image?" })
716
+ expect(result[0].content[1]).toEqual({ type: "image", image: `data:image/png;base64,${validBase64}` })
717
+ })
718
+
719
+ test("should handle mixed valid and empty images", () => {
720
+ const validBase64 =
721
+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
722
+ const msgs = [
723
+ {
724
+ role: "user",
725
+ content: [
726
+ { type: "text", text: "Compare these images" },
727
+ { type: "image", image: `data:image/png;base64,${validBase64}` },
728
+ { type: "image", image: "data:image/jpeg;base64," },
729
+ ],
730
+ },
731
+ ] as any[]
732
+
733
+ const result = ProviderTransform.message(msgs, mockModel, {})
734
+
735
+ expect(result).toHaveLength(1)
736
+ expect(result[0].content).toHaveLength(3)
737
+ expect(result[0].content[0]).toEqual({ type: "text", text: "Compare these images" })
738
+ expect(result[0].content[1]).toEqual({ type: "image", image: `data:image/png;base64,${validBase64}` })
739
+ expect(result[0].content[2]).toEqual({
740
+ type: "text",
741
+ text: "ERROR: Image file is empty or corrupted. Please provide a valid image.",
742
+ })
743
+ })
744
+ })
745
+
746
+ describe("ProviderTransform.message - anthropic empty content filtering", () => {
747
+ const anthropicModel = {
748
+ id: "anthropic/claude-3-5-sonnet",
749
+ providerID: "anthropic",
750
+ api: {
751
+ id: "claude-3-5-sonnet-20241022",
752
+ url: "https://api.anthropic.com",
753
+ npm: "@ai-sdk/anthropic",
754
+ },
755
+ name: "Claude 3.5 Sonnet",
756
+ capabilities: {
757
+ temperature: true,
758
+ reasoning: false,
759
+ attachment: true,
760
+ toolcall: true,
761
+ input: { text: true, audio: false, image: true, video: false, pdf: true },
762
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
763
+ interleaved: false,
764
+ },
765
+ cost: {
766
+ input: 0.003,
767
+ output: 0.015,
768
+ cache: { read: 0.0003, write: 0.00375 },
769
+ },
770
+ limit: {
771
+ context: 200000,
772
+ output: 8192,
773
+ },
774
+ status: "active",
775
+ options: {},
776
+ headers: {},
777
+ } as any
778
+
779
+ test("filters out messages with empty string content", () => {
780
+ const msgs = [
781
+ { role: "user", content: "Hello" },
782
+ { role: "assistant", content: "" },
783
+ { role: "user", content: "World" },
784
+ ] as any[]
785
+
786
+ const result = ProviderTransform.message(msgs, anthropicModel, {})
787
+
788
+ expect(result).toHaveLength(2)
789
+ expect(result[0].content).toBe("Hello")
790
+ expect(result[1].content).toBe("World")
791
+ })
792
+
793
+ test("filters out empty text parts from array content", () => {
794
+ const msgs = [
795
+ {
796
+ role: "assistant",
797
+ content: [
798
+ { type: "text", text: "" },
799
+ { type: "text", text: "Hello" },
800
+ { type: "text", text: "" },
801
+ ],
802
+ },
803
+ ] as any[]
804
+
805
+ const result = ProviderTransform.message(msgs, anthropicModel, {})
806
+
807
+ expect(result).toHaveLength(1)
808
+ expect(result[0].content).toHaveLength(1)
809
+ expect(result[0].content[0]).toEqual({ type: "text", text: "Hello" })
810
+ })
811
+
812
+ test("filters out empty reasoning parts from array content", () => {
813
+ const msgs = [
814
+ {
815
+ role: "assistant",
816
+ content: [
817
+ { type: "reasoning", text: "" },
818
+ { type: "text", text: "Answer" },
819
+ { type: "reasoning", text: "" },
820
+ ],
821
+ },
822
+ ] as any[]
823
+
824
+ const result = ProviderTransform.message(msgs, anthropicModel, {})
825
+
826
+ expect(result).toHaveLength(1)
827
+ expect(result[0].content).toHaveLength(1)
828
+ expect(result[0].content[0]).toEqual({ type: "text", text: "Answer" })
829
+ })
830
+
831
+ test("removes entire message when all parts are empty", () => {
832
+ const msgs = [
833
+ { role: "user", content: "Hello" },
834
+ {
835
+ role: "assistant",
836
+ content: [
837
+ { type: "text", text: "" },
838
+ { type: "reasoning", text: "" },
839
+ ],
840
+ },
841
+ { role: "user", content: "World" },
842
+ ] as any[]
843
+
844
+ const result = ProviderTransform.message(msgs, anthropicModel, {})
845
+
846
+ expect(result).toHaveLength(2)
847
+ expect(result[0].content).toBe("Hello")
848
+ expect(result[1].content).toBe("World")
849
+ })
850
+
851
+ test("keeps non-text/reasoning parts even if text parts are empty", () => {
852
+ const msgs = [
853
+ {
854
+ role: "assistant",
855
+ content: [
856
+ { type: "text", text: "" },
857
+ { type: "tool-call", toolCallId: "123", toolName: "bash", input: { command: "ls" } },
858
+ ],
859
+ },
860
+ ] as any[]
861
+
862
+ const result = ProviderTransform.message(msgs, anthropicModel, {})
863
+
864
+ expect(result).toHaveLength(1)
865
+ expect(result[0].content).toHaveLength(1)
866
+ expect(result[0].content[0]).toEqual({
867
+ type: "tool-call",
868
+ toolCallId: "123",
869
+ toolName: "bash",
870
+ input: { command: "ls" },
871
+ })
872
+ })
873
+
874
+ test("keeps messages with valid text alongside empty parts", () => {
875
+ const msgs = [
876
+ {
877
+ role: "assistant",
878
+ content: [
879
+ { type: "reasoning", text: "Thinking..." },
880
+ { type: "text", text: "" },
881
+ { type: "text", text: "Result" },
882
+ ],
883
+ },
884
+ ] as any[]
885
+
886
+ const result = ProviderTransform.message(msgs, anthropicModel, {})
887
+
888
+ expect(result).toHaveLength(1)
889
+ expect(result[0].content).toHaveLength(2)
890
+ expect(result[0].content[0]).toEqual({ type: "reasoning", text: "Thinking..." })
891
+ expect(result[0].content[1]).toEqual({ type: "text", text: "Result" })
892
+ })
893
+
894
+ test("does not filter for non-anthropic providers", () => {
895
+ const openaiModel = {
896
+ ...anthropicModel,
897
+ providerID: "openai",
898
+ api: {
899
+ id: "gpt-4",
900
+ url: "https://api.openai.com",
901
+ npm: "@ai-sdk/openai",
902
+ },
903
+ }
904
+
905
+ const msgs = [
906
+ { role: "assistant", content: "" },
907
+ {
908
+ role: "assistant",
909
+ content: [{ type: "text", text: "" }],
910
+ },
911
+ ] as any[]
912
+
913
+ const result = ProviderTransform.message(msgs, openaiModel, {})
914
+
915
+ expect(result).toHaveLength(2)
916
+ expect(result[0].content).toBe("")
917
+ expect(result[1].content).toHaveLength(1)
918
+ })
919
+ })
920
+
921
+ describe("ProviderTransform.message - strip openai metadata when store=false", () => {
922
+ const openaiModel = {
923
+ id: "openai/gpt-5",
924
+ providerID: "openai",
925
+ api: {
926
+ id: "gpt-5",
927
+ url: "https://api.openai.com",
928
+ npm: "@ai-sdk/openai",
929
+ },
930
+ name: "GPT-5",
931
+ capabilities: {
932
+ temperature: true,
933
+ reasoning: true,
934
+ attachment: true,
935
+ toolcall: true,
936
+ input: { text: true, audio: false, image: true, video: false, pdf: false },
937
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
938
+ interleaved: false,
939
+ },
940
+ cost: { input: 0.03, output: 0.06, cache: { read: 0.001, write: 0.002 } },
941
+ limit: { context: 128000, output: 4096 },
942
+ status: "active",
943
+ options: {},
944
+ headers: {},
945
+ } as any
946
+
947
+ test("preserves itemId and reasoningEncryptedContent when store=false", () => {
948
+ const msgs = [
949
+ {
950
+ role: "assistant",
951
+ content: [
952
+ {
953
+ type: "reasoning",
954
+ text: "thinking...",
955
+ providerOptions: {
956
+ openai: {
957
+ itemId: "rs_123",
958
+ reasoningEncryptedContent: "encrypted",
959
+ },
960
+ },
961
+ },
962
+ {
963
+ type: "text",
964
+ text: "Hello",
965
+ providerOptions: {
966
+ openai: {
967
+ itemId: "msg_456",
968
+ },
969
+ },
970
+ },
971
+ ],
972
+ },
973
+ ] as any[]
974
+
975
+ const result = ProviderTransform.message(msgs, openaiModel, { store: false }) as any[]
976
+
977
+ expect(result).toHaveLength(1)
978
+ expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("rs_123")
979
+ expect(result[0].content[1].providerOptions?.openai?.itemId).toBe("msg_456")
980
+ })
981
+
982
+ test("preserves itemId and reasoningEncryptedContent when store=false even when not openai", () => {
983
+ const zenModel = {
984
+ ...openaiModel,
985
+ providerID: "zen",
986
+ }
987
+ const msgs = [
988
+ {
989
+ role: "assistant",
990
+ content: [
991
+ {
992
+ type: "reasoning",
993
+ text: "thinking...",
994
+ providerOptions: {
995
+ openai: {
996
+ itemId: "rs_123",
997
+ reasoningEncryptedContent: "encrypted",
998
+ },
999
+ },
1000
+ },
1001
+ {
1002
+ type: "text",
1003
+ text: "Hello",
1004
+ providerOptions: {
1005
+ openai: {
1006
+ itemId: "msg_456",
1007
+ },
1008
+ },
1009
+ },
1010
+ ],
1011
+ },
1012
+ ] as any[]
1013
+
1014
+ const result = ProviderTransform.message(msgs, zenModel, { store: false }) as any[]
1015
+
1016
+ expect(result).toHaveLength(1)
1017
+ expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("rs_123")
1018
+ expect(result[0].content[1].providerOptions?.openai?.itemId).toBe("msg_456")
1019
+ })
1020
+
1021
+ test("preserves other openai options including itemId", () => {
1022
+ const msgs = [
1023
+ {
1024
+ role: "assistant",
1025
+ content: [
1026
+ {
1027
+ type: "text",
1028
+ text: "Hello",
1029
+ providerOptions: {
1030
+ openai: {
1031
+ itemId: "msg_123",
1032
+ otherOption: "value",
1033
+ },
1034
+ },
1035
+ },
1036
+ ],
1037
+ },
1038
+ ] as any[]
1039
+
1040
+ const result = ProviderTransform.message(msgs, openaiModel, { store: false }) as any[]
1041
+
1042
+ expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
1043
+ expect(result[0].content[0].providerOptions?.openai?.otherOption).toBe("value")
1044
+ })
1045
+
1046
+ test("preserves metadata for openai package when store is true", () => {
1047
+ const msgs = [
1048
+ {
1049
+ role: "assistant",
1050
+ content: [
1051
+ {
1052
+ type: "text",
1053
+ text: "Hello",
1054
+ providerOptions: {
1055
+ openai: {
1056
+ itemId: "msg_123",
1057
+ },
1058
+ },
1059
+ },
1060
+ ],
1061
+ },
1062
+ ] as any[]
1063
+
1064
+ // openai package preserves itemId regardless of store value
1065
+ const result = ProviderTransform.message(msgs, openaiModel, { store: true }) as any[]
1066
+
1067
+ expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
1068
+ })
1069
+
1070
+ test("preserves metadata for non-openai packages when store is false", () => {
1071
+ const anthropicModel = {
1072
+ ...openaiModel,
1073
+ providerID: "anthropic",
1074
+ api: {
1075
+ id: "claude-3",
1076
+ url: "https://api.anthropic.com",
1077
+ npm: "@ai-sdk/anthropic",
1078
+ },
1079
+ }
1080
+ const msgs = [
1081
+ {
1082
+ role: "assistant",
1083
+ content: [
1084
+ {
1085
+ type: "text",
1086
+ text: "Hello",
1087
+ providerOptions: {
1088
+ openai: {
1089
+ itemId: "msg_123",
1090
+ },
1091
+ },
1092
+ },
1093
+ ],
1094
+ },
1095
+ ] as any[]
1096
+
1097
+ // store=false preserves metadata for non-openai packages
1098
+ const result = ProviderTransform.message(msgs, anthropicModel, { store: false }) as any[]
1099
+
1100
+ expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
1101
+ })
1102
+
1103
+ test("preserves metadata using providerID key when store is false", () => {
1104
+ const opencodeModel = {
1105
+ ...openaiModel,
1106
+ providerID: "opencode",
1107
+ api: {
1108
+ id: "opencode-test",
1109
+ url: "https://api.opencode.ai",
1110
+ npm: "@ai-sdk/openai-compatible",
1111
+ },
1112
+ }
1113
+ const msgs = [
1114
+ {
1115
+ role: "assistant",
1116
+ content: [
1117
+ {
1118
+ type: "text",
1119
+ text: "Hello",
1120
+ providerOptions: {
1121
+ opencode: {
1122
+ itemId: "msg_123",
1123
+ otherOption: "value",
1124
+ },
1125
+ },
1126
+ },
1127
+ ],
1128
+ },
1129
+ ] as any[]
1130
+
1131
+ const result = ProviderTransform.message(msgs, opencodeModel, { store: false }) as any[]
1132
+
1133
+ expect(result[0].content[0].providerOptions?.opencode?.itemId).toBe("msg_123")
1134
+ expect(result[0].content[0].providerOptions?.opencode?.otherOption).toBe("value")
1135
+ })
1136
+
1137
+ test("preserves itemId across all providerOptions keys", () => {
1138
+ const opencodeModel = {
1139
+ ...openaiModel,
1140
+ providerID: "opencode",
1141
+ api: {
1142
+ id: "opencode-test",
1143
+ url: "https://api.opencode.ai",
1144
+ npm: "@ai-sdk/openai-compatible",
1145
+ },
1146
+ }
1147
+ const msgs = [
1148
+ {
1149
+ role: "assistant",
1150
+ providerOptions: {
1151
+ openai: { itemId: "msg_root" },
1152
+ opencode: { itemId: "msg_opencode" },
1153
+ extra: { itemId: "msg_extra" },
1154
+ },
1155
+ content: [
1156
+ {
1157
+ type: "text",
1158
+ text: "Hello",
1159
+ providerOptions: {
1160
+ openai: { itemId: "msg_openai_part" },
1161
+ opencode: { itemId: "msg_opencode_part" },
1162
+ extra: { itemId: "msg_extra_part" },
1163
+ },
1164
+ },
1165
+ ],
1166
+ },
1167
+ ] as any[]
1168
+
1169
+ const result = ProviderTransform.message(msgs, opencodeModel, { store: false }) as any[]
1170
+
1171
+ expect(result[0].providerOptions?.openai?.itemId).toBe("msg_root")
1172
+ expect(result[0].providerOptions?.opencode?.itemId).toBe("msg_opencode")
1173
+ expect(result[0].providerOptions?.extra?.itemId).toBe("msg_extra")
1174
+ expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_openai_part")
1175
+ expect(result[0].content[0].providerOptions?.opencode?.itemId).toBe("msg_opencode_part")
1176
+ expect(result[0].content[0].providerOptions?.extra?.itemId).toBe("msg_extra_part")
1177
+ })
1178
+
1179
+ test("does not strip metadata for non-openai packages when store is not false", () => {
1180
+ const anthropicModel = {
1181
+ ...openaiModel,
1182
+ providerID: "anthropic",
1183
+ api: {
1184
+ id: "claude-3",
1185
+ url: "https://api.anthropic.com",
1186
+ npm: "@ai-sdk/anthropic",
1187
+ },
1188
+ }
1189
+ const msgs = [
1190
+ {
1191
+ role: "assistant",
1192
+ content: [
1193
+ {
1194
+ type: "text",
1195
+ text: "Hello",
1196
+ providerOptions: {
1197
+ openai: {
1198
+ itemId: "msg_123",
1199
+ },
1200
+ },
1201
+ },
1202
+ ],
1203
+ },
1204
+ ] as any[]
1205
+
1206
+ const result = ProviderTransform.message(msgs, anthropicModel, {}) as any[]
1207
+
1208
+ expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
1209
+ })
1210
+ })
1211
+
1212
+ describe("ProviderTransform.message - providerOptions key remapping", () => {
1213
+ const createModel = (providerID: string, npm: string) =>
1214
+ ({
1215
+ id: `${providerID}/test-model`,
1216
+ providerID,
1217
+ api: {
1218
+ id: "test-model",
1219
+ url: "https://api.test.com",
1220
+ npm,
1221
+ },
1222
+ name: "Test Model",
1223
+ capabilities: {
1224
+ temperature: true,
1225
+ reasoning: false,
1226
+ attachment: true,
1227
+ toolcall: true,
1228
+ input: { text: true, audio: false, image: true, video: false, pdf: true },
1229
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
1230
+ interleaved: false,
1231
+ },
1232
+ cost: { input: 0.001, output: 0.002, cache: { read: 0.0001, write: 0.0002 } },
1233
+ limit: { context: 128000, output: 8192 },
1234
+ status: "active",
1235
+ options: {},
1236
+ headers: {},
1237
+ }) as any
1238
+
1239
+ test("azure keeps 'azure' key and does not remap to 'openai'", () => {
1240
+ const model = createModel("azure", "@ai-sdk/azure")
1241
+ const msgs = [
1242
+ {
1243
+ role: "user",
1244
+ content: "Hello",
1245
+ providerOptions: {
1246
+ azure: { someOption: "value" },
1247
+ },
1248
+ },
1249
+ ] as any[]
1250
+
1251
+ const result = ProviderTransform.message(msgs, model, {})
1252
+
1253
+ expect(result[0].providerOptions?.azure).toEqual({ someOption: "value" })
1254
+ expect(result[0].providerOptions?.openai).toBeUndefined()
1255
+ })
1256
+
1257
+ test("copilot remaps providerID to 'copilot' key", () => {
1258
+ const model = createModel("github-copilot", "@ai-sdk/github-copilot")
1259
+ const msgs = [
1260
+ {
1261
+ role: "user",
1262
+ content: "Hello",
1263
+ providerOptions: {
1264
+ copilot: { someOption: "value" },
1265
+ },
1266
+ },
1267
+ ] as any[]
1268
+
1269
+ const result = ProviderTransform.message(msgs, model, {})
1270
+
1271
+ expect(result[0].providerOptions?.copilot).toEqual({ someOption: "value" })
1272
+ expect(result[0].providerOptions?.["github-copilot"]).toBeUndefined()
1273
+ })
1274
+
1275
+ test("bedrock remaps providerID to 'bedrock' key", () => {
1276
+ const model = createModel("my-bedrock", "@ai-sdk/amazon-bedrock")
1277
+ const msgs = [
1278
+ {
1279
+ role: "user",
1280
+ content: "Hello",
1281
+ providerOptions: {
1282
+ "my-bedrock": { someOption: "value" },
1283
+ },
1284
+ },
1285
+ ] as any[]
1286
+
1287
+ const result = ProviderTransform.message(msgs, model, {})
1288
+
1289
+ expect(result[0].providerOptions?.bedrock).toEqual({ someOption: "value" })
1290
+ expect(result[0].providerOptions?.["my-bedrock"]).toBeUndefined()
1291
+ })
1292
+ })
1293
+
1294
+ describe("ProviderTransform.message - claude w/bedrock custom inference profile", () => {
1295
+ test("adds cachePoint", () => {
1296
+ const model = {
1297
+ id: "amazon-bedrock/custom-claude-sonnet-4.5",
1298
+ providerID: "amazon-bedrock",
1299
+ api: {
1300
+ id: "arn:aws:bedrock:xxx:yyy:application-inference-profile/zzz",
1301
+ url: "https://api.test.com",
1302
+ npm: "@ai-sdk/amazon-bedrock",
1303
+ },
1304
+ name: "Custom inference profile",
1305
+ capabilities: {},
1306
+ options: {},
1307
+ headers: {},
1308
+ } as any
1309
+
1310
+ const msgs = [
1311
+ {
1312
+ role: "user",
1313
+ content: "Hello",
1314
+ },
1315
+ ] as any[]
1316
+
1317
+ const result = ProviderTransform.message(msgs, model, {})
1318
+
1319
+ expect(result[0].providerOptions?.bedrock).toEqual(
1320
+ expect.objectContaining({
1321
+ cachePoint: {
1322
+ type: "default",
1323
+ },
1324
+ }),
1325
+ )
1326
+ })
1327
+ })
1328
+
1329
+ describe("ProviderTransform.variants", () => {
1330
+ const createMockModel = (overrides: Partial<any> = {}): any => ({
1331
+ id: "test/test-model",
1332
+ providerID: "test",
1333
+ api: {
1334
+ id: "test-model",
1335
+ url: "https://api.test.com",
1336
+ npm: "@ai-sdk/openai",
1337
+ },
1338
+ name: "Test Model",
1339
+ capabilities: {
1340
+ temperature: true,
1341
+ reasoning: true,
1342
+ attachment: true,
1343
+ toolcall: true,
1344
+ input: { text: true, audio: false, image: true, video: false, pdf: false },
1345
+ output: { text: true, audio: false, image: false, video: false, pdf: false },
1346
+ interleaved: false,
1347
+ },
1348
+ cost: {
1349
+ input: 0.001,
1350
+ output: 0.002,
1351
+ cache: { read: 0.0001, write: 0.0002 },
1352
+ },
1353
+ limit: {
1354
+ context: 200_000,
1355
+ output: 64_000,
1356
+ },
1357
+ status: "active",
1358
+ options: {},
1359
+ headers: {},
1360
+ release_date: "2024-01-01",
1361
+ ...overrides,
1362
+ })
1363
+
1364
+ test("returns empty object when model has no reasoning capabilities", () => {
1365
+ const model = createMockModel({
1366
+ capabilities: { reasoning: false },
1367
+ })
1368
+ const result = ProviderTransform.variants(model)
1369
+ expect(result).toEqual({})
1370
+ })
1371
+
1372
+ test("deepseek returns empty object", () => {
1373
+ const model = createMockModel({
1374
+ id: "deepseek/deepseek-chat",
1375
+ providerID: "deepseek",
1376
+ api: {
1377
+ id: "deepseek-chat",
1378
+ url: "https://api.deepseek.com",
1379
+ npm: "@ai-sdk/openai-compatible",
1380
+ },
1381
+ })
1382
+ const result = ProviderTransform.variants(model)
1383
+ expect(result).toEqual({})
1384
+ })
1385
+
1386
+ test("minimax returns empty object", () => {
1387
+ const model = createMockModel({
1388
+ id: "minimax/minimax-model",
1389
+ providerID: "minimax",
1390
+ api: {
1391
+ id: "minimax-model",
1392
+ url: "https://api.minimax.com",
1393
+ npm: "@ai-sdk/openai-compatible",
1394
+ },
1395
+ })
1396
+ const result = ProviderTransform.variants(model)
1397
+ expect(result).toEqual({})
1398
+ })
1399
+
1400
+ test("glm returns empty object", () => {
1401
+ const model = createMockModel({
1402
+ id: "glm/glm-4",
1403
+ providerID: "glm",
1404
+ api: {
1405
+ id: "glm-4",
1406
+ url: "https://api.glm.com",
1407
+ npm: "@ai-sdk/openai-compatible",
1408
+ },
1409
+ })
1410
+ const result = ProviderTransform.variants(model)
1411
+ expect(result).toEqual({})
1412
+ })
1413
+
1414
+ test("mistral returns empty object", () => {
1415
+ const model = createMockModel({
1416
+ id: "mistral/mistral-large",
1417
+ providerID: "mistral",
1418
+ api: {
1419
+ id: "mistral-large-latest",
1420
+ url: "https://api.mistral.com",
1421
+ npm: "@ai-sdk/mistral",
1422
+ },
1423
+ })
1424
+ const result = ProviderTransform.variants(model)
1425
+ expect(result).toEqual({})
1426
+ })
1427
+
1428
+ describe("@openrouter/ai-sdk-provider", () => {
1429
+ test("returns empty object for non-qualifying models", () => {
1430
+ const model = createMockModel({
1431
+ id: "openrouter/test-model",
1432
+ providerID: "openrouter",
1433
+ api: {
1434
+ id: "test-model",
1435
+ url: "https://openrouter.ai",
1436
+ npm: "@openrouter/ai-sdk-provider",
1437
+ },
1438
+ })
1439
+ const result = ProviderTransform.variants(model)
1440
+ expect(result).toEqual({})
1441
+ })
1442
+
1443
+ test("gpt models return OPENAI_EFFORTS with reasoning", () => {
1444
+ const model = createMockModel({
1445
+ id: "openrouter/gpt-4",
1446
+ providerID: "openrouter",
1447
+ api: {
1448
+ id: "gpt-4",
1449
+ url: "https://openrouter.ai",
1450
+ npm: "@openrouter/ai-sdk-provider",
1451
+ },
1452
+ })
1453
+ const result = ProviderTransform.variants(model)
1454
+ expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
1455
+ expect(result.low).toEqual({ reasoning: { effort: "low" } })
1456
+ expect(result.high).toEqual({ reasoning: { effort: "high" } })
1457
+ })
1458
+
1459
+ test("gemini-3 returns OPENAI_EFFORTS with reasoning", () => {
1460
+ const model = createMockModel({
1461
+ id: "openrouter/gemini-3-5-pro",
1462
+ providerID: "openrouter",
1463
+ api: {
1464
+ id: "gemini-3-5-pro",
1465
+ url: "https://openrouter.ai",
1466
+ npm: "@openrouter/ai-sdk-provider",
1467
+ },
1468
+ })
1469
+ const result = ProviderTransform.variants(model)
1470
+ expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
1471
+ })
1472
+
1473
+ test("grok-4 returns empty object", () => {
1474
+ const model = createMockModel({
1475
+ id: "openrouter/grok-4",
1476
+ providerID: "openrouter",
1477
+ api: {
1478
+ id: "grok-4",
1479
+ url: "https://openrouter.ai",
1480
+ npm: "@openrouter/ai-sdk-provider",
1481
+ },
1482
+ })
1483
+ const result = ProviderTransform.variants(model)
1484
+ expect(result).toEqual({})
1485
+ })
1486
+
1487
+ test("grok-3-mini returns low and high with reasoning", () => {
1488
+ const model = createMockModel({
1489
+ id: "openrouter/grok-3-mini",
1490
+ providerID: "openrouter",
1491
+ api: {
1492
+ id: "grok-3-mini",
1493
+ url: "https://openrouter.ai",
1494
+ npm: "@openrouter/ai-sdk-provider",
1495
+ },
1496
+ })
1497
+ const result = ProviderTransform.variants(model)
1498
+ expect(Object.keys(result)).toEqual(["low", "high"])
1499
+ expect(result.low).toEqual({ reasoning: { effort: "low" } })
1500
+ expect(result.high).toEqual({ reasoning: { effort: "high" } })
1501
+ })
1502
+ })
1503
+
1504
+ describe("@ai-sdk/gateway", () => {
1505
+ test("returns OPENAI_EFFORTS with reasoningEffort", () => {
1506
+ const model = createMockModel({
1507
+ id: "gateway/gateway-model",
1508
+ providerID: "gateway",
1509
+ api: {
1510
+ id: "gateway-model",
1511
+ url: "https://gateway.ai",
1512
+ npm: "@ai-sdk/gateway",
1513
+ },
1514
+ })
1515
+ const result = ProviderTransform.variants(model)
1516
+ expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
1517
+ expect(result.low).toEqual({ reasoningEffort: "low" })
1518
+ expect(result.high).toEqual({ reasoningEffort: "high" })
1519
+ })
1520
+ })
1521
+
1522
+ describe("@ai-sdk/github-copilot", () => {
1523
+ test("standard models return low, medium, high", () => {
1524
+ const model = createMockModel({
1525
+ id: "gpt-4.5",
1526
+ providerID: "github-copilot",
1527
+ api: {
1528
+ id: "gpt-4.5",
1529
+ url: "https://api.githubcopilot.com",
1530
+ npm: "@ai-sdk/github-copilot",
1531
+ },
1532
+ })
1533
+ const result = ProviderTransform.variants(model)
1534
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
1535
+ expect(result.low).toEqual({
1536
+ reasoningEffort: "low",
1537
+ reasoningSummary: "auto",
1538
+ include: ["reasoning.encrypted_content"],
1539
+ })
1540
+ })
1541
+
1542
+ test("gpt-5.1-codex-max includes xhigh", () => {
1543
+ const model = createMockModel({
1544
+ id: "gpt-5.1-codex-max",
1545
+ providerID: "github-copilot",
1546
+ api: {
1547
+ id: "gpt-5.1-codex-max",
1548
+ url: "https://api.githubcopilot.com",
1549
+ npm: "@ai-sdk/github-copilot",
1550
+ },
1551
+ })
1552
+ const result = ProviderTransform.variants(model)
1553
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh"])
1554
+ })
1555
+
1556
+ test("gpt-5.1-codex-mini does not include xhigh", () => {
1557
+ const model = createMockModel({
1558
+ id: "gpt-5.1-codex-mini",
1559
+ providerID: "github-copilot",
1560
+ api: {
1561
+ id: "gpt-5.1-codex-mini",
1562
+ url: "https://api.githubcopilot.com",
1563
+ npm: "@ai-sdk/github-copilot",
1564
+ },
1565
+ })
1566
+ const result = ProviderTransform.variants(model)
1567
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
1568
+ })
1569
+
1570
+ test("gpt-5.1-codex does not include xhigh", () => {
1571
+ const model = createMockModel({
1572
+ id: "gpt-5.1-codex",
1573
+ providerID: "github-copilot",
1574
+ api: {
1575
+ id: "gpt-5.1-codex",
1576
+ url: "https://api.githubcopilot.com",
1577
+ npm: "@ai-sdk/github-copilot",
1578
+ },
1579
+ })
1580
+ const result = ProviderTransform.variants(model)
1581
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
1582
+ })
1583
+
1584
+ test("gpt-5.2 includes xhigh", () => {
1585
+ const model = createMockModel({
1586
+ id: "gpt-5.2",
1587
+ providerID: "github-copilot",
1588
+ api: {
1589
+ id: "gpt-5.2",
1590
+ url: "https://api.githubcopilot.com",
1591
+ npm: "@ai-sdk/github-copilot",
1592
+ },
1593
+ })
1594
+ const result = ProviderTransform.variants(model)
1595
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh"])
1596
+ expect(result.xhigh).toEqual({
1597
+ reasoningEffort: "xhigh",
1598
+ reasoningSummary: "auto",
1599
+ include: ["reasoning.encrypted_content"],
1600
+ })
1601
+ })
1602
+
1603
+ test("gpt-5.2-codex includes xhigh", () => {
1604
+ const model = createMockModel({
1605
+ id: "gpt-5.2-codex",
1606
+ providerID: "github-copilot",
1607
+ api: {
1608
+ id: "gpt-5.2-codex",
1609
+ url: "https://api.githubcopilot.com",
1610
+ npm: "@ai-sdk/github-copilot",
1611
+ },
1612
+ })
1613
+ const result = ProviderTransform.variants(model)
1614
+ expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh"])
1615
+ })
1616
+ })
1617
+
1618
+ describe("@ai-sdk/cerebras", () => {
1619
+ test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
1620
+ const model = createMockModel({
1621
+ id: "cerebras/llama-4",
1622
+ providerID: "cerebras",
1623
+ api: {
1624
+ id: "llama-4-sc",
1625
+ url: "https://api.cerebras.ai",
1626
+ npm: "@ai-sdk/cerebras",
1627
+ },
1628
+ })
1629
+ const result = ProviderTransform.variants(model)
1630
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
1631
+ expect(result.low).toEqual({ reasoningEffort: "low" })
1632
+ expect(result.high).toEqual({ reasoningEffort: "high" })
1633
+ })
1634
+ })
1635
+
1636
+ describe("@ai-sdk/togetherai", () => {
1637
+ test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
1638
+ const model = createMockModel({
1639
+ id: "togetherai/llama-4",
1640
+ providerID: "togetherai",
1641
+ api: {
1642
+ id: "llama-4-sc",
1643
+ url: "https://api.togetherai.com",
1644
+ npm: "@ai-sdk/togetherai",
1645
+ },
1646
+ })
1647
+ const result = ProviderTransform.variants(model)
1648
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
1649
+ expect(result.low).toEqual({ reasoningEffort: "low" })
1650
+ expect(result.high).toEqual({ reasoningEffort: "high" })
1651
+ })
1652
+ })
1653
+
1654
+ describe("@ai-sdk/xai", () => {
1655
+ test("grok-3 returns empty object", () => {
1656
+ const model = createMockModel({
1657
+ id: "xai/grok-3",
1658
+ providerID: "xai",
1659
+ api: {
1660
+ id: "grok-3",
1661
+ url: "https://api.x.ai",
1662
+ npm: "@ai-sdk/xai",
1663
+ },
1664
+ })
1665
+ const result = ProviderTransform.variants(model)
1666
+ expect(result).toEqual({})
1667
+ })
1668
+
1669
+ test("grok-3-mini returns low and high with reasoningEffort", () => {
1670
+ const model = createMockModel({
1671
+ id: "xai/grok-3-mini",
1672
+ providerID: "xai",
1673
+ api: {
1674
+ id: "grok-3-mini",
1675
+ url: "https://api.x.ai",
1676
+ npm: "@ai-sdk/xai",
1677
+ },
1678
+ })
1679
+ const result = ProviderTransform.variants(model)
1680
+ expect(Object.keys(result)).toEqual(["low", "high"])
1681
+ expect(result.low).toEqual({ reasoningEffort: "low" })
1682
+ expect(result.high).toEqual({ reasoningEffort: "high" })
1683
+ })
1684
+ })
1685
+
1686
+ describe("@ai-sdk/deepinfra", () => {
1687
+ test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
1688
+ const model = createMockModel({
1689
+ id: "deepinfra/llama-4",
1690
+ providerID: "deepinfra",
1691
+ api: {
1692
+ id: "llama-4-sc",
1693
+ url: "https://api.deepinfra.com",
1694
+ npm: "@ai-sdk/deepinfra",
1695
+ },
1696
+ })
1697
+ const result = ProviderTransform.variants(model)
1698
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
1699
+ expect(result.low).toEqual({ reasoningEffort: "low" })
1700
+ expect(result.high).toEqual({ reasoningEffort: "high" })
1701
+ })
1702
+ })
1703
+
1704
+ describe("@ai-sdk/openai-compatible", () => {
1705
+ test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
1706
+ const model = createMockModel({
1707
+ id: "custom-provider/custom-model",
1708
+ providerID: "custom-provider",
1709
+ api: {
1710
+ id: "custom-model",
1711
+ url: "https://api.custom.com",
1712
+ npm: "@ai-sdk/openai-compatible",
1713
+ },
1714
+ })
1715
+ const result = ProviderTransform.variants(model)
1716
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
1717
+ expect(result.low).toEqual({ reasoningEffort: "low" })
1718
+ expect(result.high).toEqual({ reasoningEffort: "high" })
1719
+ })
1720
+ })
1721
+
1722
+ describe("@ai-sdk/azure", () => {
1723
+ test("o1-mini returns empty object", () => {
1724
+ const model = createMockModel({
1725
+ id: "o1-mini",
1726
+ providerID: "azure",
1727
+ api: {
1728
+ id: "o1-mini",
1729
+ url: "https://azure.com",
1730
+ npm: "@ai-sdk/azure",
1731
+ },
1732
+ })
1733
+ const result = ProviderTransform.variants(model)
1734
+ expect(result).toEqual({})
1735
+ })
1736
+
1737
+ test("standard azure models return custom efforts with reasoningSummary", () => {
1738
+ const model = createMockModel({
1739
+ id: "o1",
1740
+ providerID: "azure",
1741
+ api: {
1742
+ id: "o1",
1743
+ url: "https://azure.com",
1744
+ npm: "@ai-sdk/azure",
1745
+ },
1746
+ })
1747
+ const result = ProviderTransform.variants(model)
1748
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
1749
+ expect(result.low).toEqual({
1750
+ reasoningEffort: "low",
1751
+ reasoningSummary: "auto",
1752
+ include: ["reasoning.encrypted_content"],
1753
+ })
1754
+ })
1755
+
1756
+ test("gpt-5 adds minimal effort", () => {
1757
+ const model = createMockModel({
1758
+ id: "gpt-5",
1759
+ providerID: "azure",
1760
+ api: {
1761
+ id: "gpt-5",
1762
+ url: "https://azure.com",
1763
+ npm: "@ai-sdk/azure",
1764
+ },
1765
+ })
1766
+ const result = ProviderTransform.variants(model)
1767
+ expect(Object.keys(result)).toEqual(["minimal", "low", "medium", "high"])
1768
+ })
1769
+ })
1770
+
1771
+ describe("@ai-sdk/openai", () => {
1772
+ test("gpt-5-pro returns empty object", () => {
1773
+ const model = createMockModel({
1774
+ id: "gpt-5-pro",
1775
+ providerID: "openai",
1776
+ api: {
1777
+ id: "gpt-5-pro",
1778
+ url: "https://api.openai.com",
1779
+ npm: "@ai-sdk/openai",
1780
+ },
1781
+ })
1782
+ const result = ProviderTransform.variants(model)
1783
+ expect(result).toEqual({})
1784
+ })
1785
+
1786
+ test("standard openai models return custom efforts with reasoningSummary", () => {
1787
+ const model = createMockModel({
1788
+ id: "gpt-5",
1789
+ providerID: "openai",
1790
+ api: {
1791
+ id: "gpt-5",
1792
+ url: "https://api.openai.com",
1793
+ npm: "@ai-sdk/openai",
1794
+ },
1795
+ release_date: "2024-06-01",
1796
+ })
1797
+ const result = ProviderTransform.variants(model)
1798
+ expect(Object.keys(result)).toEqual(["minimal", "low", "medium", "high"])
1799
+ expect(result.low).toEqual({
1800
+ reasoningEffort: "low",
1801
+ reasoningSummary: "auto",
1802
+ include: ["reasoning.encrypted_content"],
1803
+ })
1804
+ })
1805
+
1806
+ test("models after 2025-11-13 include 'none' effort", () => {
1807
+ const model = createMockModel({
1808
+ id: "gpt-5-nano",
1809
+ providerID: "openai",
1810
+ api: {
1811
+ id: "gpt-5-nano",
1812
+ url: "https://api.openai.com",
1813
+ npm: "@ai-sdk/openai",
1814
+ },
1815
+ release_date: "2025-11-14",
1816
+ })
1817
+ const result = ProviderTransform.variants(model)
1818
+ expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high"])
1819
+ })
1820
+
1821
+ test("models after 2025-12-04 include 'xhigh' effort", () => {
1822
+ const model = createMockModel({
1823
+ id: "openai/gpt-5-chat",
1824
+ providerID: "openai",
1825
+ api: {
1826
+ id: "gpt-5-chat",
1827
+ url: "https://api.openai.com",
1828
+ npm: "@ai-sdk/openai",
1829
+ },
1830
+ release_date: "2025-12-05",
1831
+ })
1832
+ const result = ProviderTransform.variants(model)
1833
+ expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
1834
+ })
1835
+ })
1836
+
1837
+ describe("@ai-sdk/anthropic", () => {
1838
+ test("returns high and max with thinking config", () => {
1839
+ const model = createMockModel({
1840
+ id: "anthropic/claude-4",
1841
+ providerID: "anthropic",
1842
+ api: {
1843
+ id: "claude-4",
1844
+ url: "https://api.anthropic.com",
1845
+ npm: "@ai-sdk/anthropic",
1846
+ },
1847
+ })
1848
+ const result = ProviderTransform.variants(model)
1849
+ expect(Object.keys(result)).toEqual(["high", "max"])
1850
+ expect(result.high).toEqual({
1851
+ thinking: {
1852
+ type: "enabled",
1853
+ budgetTokens: 16000,
1854
+ },
1855
+ })
1856
+ expect(result.max).toEqual({
1857
+ thinking: {
1858
+ type: "enabled",
1859
+ budgetTokens: 31999,
1860
+ },
1861
+ })
1862
+ })
1863
+ })
1864
+
1865
+ describe("@ai-sdk/amazon-bedrock", () => {
1866
+ test("returns WIDELY_SUPPORTED_EFFORTS with reasoningConfig", () => {
1867
+ const model = createMockModel({
1868
+ id: "bedrock/llama-4",
1869
+ providerID: "bedrock",
1870
+ api: {
1871
+ id: "llama-4-sc",
1872
+ url: "https://bedrock.amazonaws.com",
1873
+ npm: "@ai-sdk/amazon-bedrock",
1874
+ },
1875
+ })
1876
+ const result = ProviderTransform.variants(model)
1877
+ expect(Object.keys(result)).toEqual(["low", "medium", "high"])
1878
+ expect(result.low).toEqual({
1879
+ reasoningConfig: {
1880
+ type: "enabled",
1881
+ maxReasoningEffort: "low",
1882
+ },
1883
+ })
1884
+ })
1885
+ })
1886
+
1887
+ describe("@ai-sdk/google", () => {
1888
+ test("gemini-2.5 returns high and max with thinkingConfig and thinkingBudget", () => {
1889
+ const model = createMockModel({
1890
+ id: "google/gemini-2.5-pro",
1891
+ providerID: "google",
1892
+ api: {
1893
+ id: "gemini-2.5-pro",
1894
+ url: "https://generativelanguage.googleapis.com",
1895
+ npm: "@ai-sdk/google",
1896
+ },
1897
+ })
1898
+ const result = ProviderTransform.variants(model)
1899
+ expect(Object.keys(result)).toEqual(["high", "max"])
1900
+ expect(result.high).toEqual({
1901
+ thinkingConfig: {
1902
+ includeThoughts: true,
1903
+ thinkingBudget: 16000,
1904
+ },
1905
+ })
1906
+ expect(result.max).toEqual({
1907
+ thinkingConfig: {
1908
+ includeThoughts: true,
1909
+ thinkingBudget: 24576,
1910
+ },
1911
+ })
1912
+ })
1913
+
1914
+ test("other gemini models return low and high with thinkingLevel", () => {
1915
+ const model = createMockModel({
1916
+ id: "google/gemini-2.0-pro",
1917
+ providerID: "google",
1918
+ api: {
1919
+ id: "gemini-2.0-pro",
1920
+ url: "https://generativelanguage.googleapis.com",
1921
+ npm: "@ai-sdk/google",
1922
+ },
1923
+ })
1924
+ const result = ProviderTransform.variants(model)
1925
+ expect(Object.keys(result)).toEqual(["low", "high"])
1926
+ expect(result.low).toEqual({
1927
+ includeThoughts: true,
1928
+ thinkingLevel: "low",
1929
+ })
1930
+ expect(result.high).toEqual({
1931
+ includeThoughts: true,
1932
+ thinkingLevel: "high",
1933
+ })
1934
+ })
1935
+ })
1936
+
1937
+ describe("@ai-sdk/google-vertex", () => {
1938
+ test("gemini-2.5 returns high and max with thinkingConfig and thinkingBudget", () => {
1939
+ const model = createMockModel({
1940
+ id: "google-vertex/gemini-2.5-pro",
1941
+ providerID: "google-vertex",
1942
+ api: {
1943
+ id: "gemini-2.5-pro",
1944
+ url: "https://vertexai.googleapis.com",
1945
+ npm: "@ai-sdk/google-vertex",
1946
+ },
1947
+ })
1948
+ const result = ProviderTransform.variants(model)
1949
+ expect(Object.keys(result)).toEqual(["high", "max"])
1950
+ })
1951
+
1952
+ test("other vertex models return low and high with thinkingLevel", () => {
1953
+ const model = createMockModel({
1954
+ id: "google-vertex/gemini-2.0-pro",
1955
+ providerID: "google-vertex",
1956
+ api: {
1957
+ id: "gemini-2.0-pro",
1958
+ url: "https://vertexai.googleapis.com",
1959
+ npm: "@ai-sdk/google-vertex",
1960
+ },
1961
+ })
1962
+ const result = ProviderTransform.variants(model)
1963
+ expect(Object.keys(result)).toEqual(["low", "high"])
1964
+ })
1965
+ })
1966
+
1967
+ describe("@ai-sdk/cohere", () => {
1968
+ test("returns empty object", () => {
1969
+ const model = createMockModel({
1970
+ id: "cohere/command-r",
1971
+ providerID: "cohere",
1972
+ api: {
1973
+ id: "command-r",
1974
+ url: "https://api.cohere.com",
1975
+ npm: "@ai-sdk/cohere",
1976
+ },
1977
+ })
1978
+ const result = ProviderTransform.variants(model)
1979
+ expect(result).toEqual({})
1980
+ })
1981
+ })
1982
+
1983
+ describe("@ai-sdk/groq", () => {
1984
+ test("returns none and WIDELY_SUPPORTED_EFFORTS with thinkingLevel", () => {
1985
+ const model = createMockModel({
1986
+ id: "groq/llama-4",
1987
+ providerID: "groq",
1988
+ api: {
1989
+ id: "llama-4-sc",
1990
+ url: "https://api.groq.com",
1991
+ npm: "@ai-sdk/groq",
1992
+ },
1993
+ })
1994
+ const result = ProviderTransform.variants(model)
1995
+ expect(Object.keys(result)).toEqual(["none", "low", "medium", "high"])
1996
+ expect(result.none).toEqual({
1997
+ includeThoughts: true,
1998
+ thinkingLevel: "none",
1999
+ })
2000
+ expect(result.low).toEqual({
2001
+ includeThoughts: true,
2002
+ thinkingLevel: "low",
2003
+ })
2004
+ })
2005
+ })
2006
+
2007
+ describe("@ai-sdk/perplexity", () => {
2008
+ test("returns empty object", () => {
2009
+ const model = createMockModel({
2010
+ id: "perplexity/sonar-plus",
2011
+ providerID: "perplexity",
2012
+ api: {
2013
+ id: "sonar-plus",
2014
+ url: "https://api.perplexity.ai",
2015
+ npm: "@ai-sdk/perplexity",
2016
+ },
2017
+ })
2018
+ const result = ProviderTransform.variants(model)
2019
+ expect(result).toEqual({})
2020
+ })
2021
+ })
2022
+ })