nuwaxcode 1.1.25

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