saeeol 1.1.0 → 1.1.1

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