jonsoc 1.1.48 → 1.1.50

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 (421) hide show
  1. package/bin/jonsoc +17 -9
  2. package/package.json +8 -142
  3. package/postinstall.mjs +15 -0
  4. package/AGENTS.md +0 -27
  5. package/Dockerfile +0 -18
  6. package/PUBLISHING_GUIDE.md +0 -151
  7. package/README.md +0 -58
  8. package/bunfig.toml +0 -7
  9. package/package.json.placeholder +0 -11
  10. package/parsers-config.ts +0 -253
  11. package/script/build.ts +0 -115
  12. package/script/publish-registries.ts +0 -197
  13. package/script/publish.ts +0 -110
  14. package/script/schema.ts +0 -47
  15. package/script/seed-e2e.ts +0 -50
  16. package/src/acp/README.md +0 -164
  17. package/src/acp/agent.ts +0 -1437
  18. package/src/acp/session.ts +0 -105
  19. package/src/acp/types.ts +0 -22
  20. package/src/agent/agent.ts +0 -347
  21. package/src/agent/generate.txt +0 -75
  22. package/src/agent/prompt/compaction.txt +0 -12
  23. package/src/agent/prompt/explore.txt +0 -18
  24. package/src/agent/prompt/summary.txt +0 -11
  25. package/src/agent/prompt/title.txt +0 -44
  26. package/src/auth/index.ts +0 -73
  27. package/src/brand/index.ts +0 -89
  28. package/src/bun/index.ts +0 -139
  29. package/src/bus/bus-event.ts +0 -43
  30. package/src/bus/global.ts +0 -10
  31. package/src/bus/index.ts +0 -105
  32. package/src/cli/bootstrap.ts +0 -17
  33. package/src/cli/cmd/acp.ts +0 -69
  34. package/src/cli/cmd/agent.ts +0 -257
  35. package/src/cli/cmd/auth.ts +0 -405
  36. package/src/cli/cmd/cmd.ts +0 -7
  37. package/src/cli/cmd/debug/agent.ts +0 -166
  38. package/src/cli/cmd/debug/config.ts +0 -16
  39. package/src/cli/cmd/debug/file.ts +0 -97
  40. package/src/cli/cmd/debug/index.ts +0 -48
  41. package/src/cli/cmd/debug/lsp.ts +0 -52
  42. package/src/cli/cmd/debug/ripgrep.ts +0 -87
  43. package/src/cli/cmd/debug/scrap.ts +0 -16
  44. package/src/cli/cmd/debug/skill.ts +0 -16
  45. package/src/cli/cmd/debug/snapshot.ts +0 -52
  46. package/src/cli/cmd/export.ts +0 -88
  47. package/src/cli/cmd/generate.ts +0 -38
  48. package/src/cli/cmd/github.ts +0 -1548
  49. package/src/cli/cmd/import.ts +0 -99
  50. package/src/cli/cmd/mcp.ts +0 -765
  51. package/src/cli/cmd/models.ts +0 -77
  52. package/src/cli/cmd/pr.ts +0 -112
  53. package/src/cli/cmd/run.ts +0 -395
  54. package/src/cli/cmd/serve.ts +0 -20
  55. package/src/cli/cmd/session.ts +0 -135
  56. package/src/cli/cmd/stats.ts +0 -402
  57. package/src/cli/cmd/tui/app.tsx +0 -923
  58. package/src/cli/cmd/tui/attach.ts +0 -39
  59. package/src/cli/cmd/tui/component/border.tsx +0 -21
  60. package/src/cli/cmd/tui/component/dialog-agent.tsx +0 -31
  61. package/src/cli/cmd/tui/component/dialog-command.tsx +0 -162
  62. package/src/cli/cmd/tui/component/dialog-error-log.tsx +0 -155
  63. package/src/cli/cmd/tui/component/dialog-mcp.tsx +0 -86
  64. package/src/cli/cmd/tui/component/dialog-model.tsx +0 -234
  65. package/src/cli/cmd/tui/component/dialog-provider.tsx +0 -256
  66. package/src/cli/cmd/tui/component/dialog-session-list.tsx +0 -114
  67. package/src/cli/cmd/tui/component/dialog-session-rename.tsx +0 -31
  68. package/src/cli/cmd/tui/component/dialog-stash.tsx +0 -87
  69. package/src/cli/cmd/tui/component/dialog-status.tsx +0 -164
  70. package/src/cli/cmd/tui/component/dialog-tag.tsx +0 -44
  71. package/src/cli/cmd/tui/component/dialog-theme-list.tsx +0 -50
  72. package/src/cli/cmd/tui/component/dynamic-layout.tsx +0 -86
  73. package/src/cli/cmd/tui/component/inspector-overlay.tsx +0 -247
  74. package/src/cli/cmd/tui/component/logo.tsx +0 -88
  75. package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +0 -653
  76. package/src/cli/cmd/tui/component/prompt/frecency.tsx +0 -89
  77. package/src/cli/cmd/tui/component/prompt/history.tsx +0 -108
  78. package/src/cli/cmd/tui/component/prompt/index.tsx +0 -1347
  79. package/src/cli/cmd/tui/component/prompt/stash.tsx +0 -101
  80. package/src/cli/cmd/tui/component/textarea-keybindings.ts +0 -73
  81. package/src/cli/cmd/tui/component/tips.tsx +0 -153
  82. package/src/cli/cmd/tui/component/todo-item.tsx +0 -32
  83. package/src/cli/cmd/tui/context/args.tsx +0 -14
  84. package/src/cli/cmd/tui/context/directory.ts +0 -13
  85. package/src/cli/cmd/tui/context/error-log.tsx +0 -56
  86. package/src/cli/cmd/tui/context/exit.tsx +0 -26
  87. package/src/cli/cmd/tui/context/helper.tsx +0 -25
  88. package/src/cli/cmd/tui/context/inspector.tsx +0 -57
  89. package/src/cli/cmd/tui/context/keybind.tsx +0 -108
  90. package/src/cli/cmd/tui/context/kv.tsx +0 -53
  91. package/src/cli/cmd/tui/context/layout.tsx +0 -240
  92. package/src/cli/cmd/tui/context/local.tsx +0 -402
  93. package/src/cli/cmd/tui/context/prompt.tsx +0 -18
  94. package/src/cli/cmd/tui/context/route.tsx +0 -51
  95. package/src/cli/cmd/tui/context/sdk.tsx +0 -94
  96. package/src/cli/cmd/tui/context/sync.tsx +0 -449
  97. package/src/cli/cmd/tui/context/theme/aura.json +0 -69
  98. package/src/cli/cmd/tui/context/theme/ayu.json +0 -80
  99. package/src/cli/cmd/tui/context/theme/carbonfox.json +0 -248
  100. package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +0 -233
  101. package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +0 -233
  102. package/src/cli/cmd/tui/context/theme/catppuccin.json +0 -112
  103. package/src/cli/cmd/tui/context/theme/cobalt2.json +0 -228
  104. package/src/cli/cmd/tui/context/theme/cursor.json +0 -249
  105. package/src/cli/cmd/tui/context/theme/dracula.json +0 -219
  106. package/src/cli/cmd/tui/context/theme/everforest.json +0 -241
  107. package/src/cli/cmd/tui/context/theme/flexoki.json +0 -237
  108. package/src/cli/cmd/tui/context/theme/github.json +0 -233
  109. package/src/cli/cmd/tui/context/theme/gruvbox.json +0 -242
  110. package/src/cli/cmd/tui/context/theme/jonsoc.json +0 -245
  111. package/src/cli/cmd/tui/context/theme/kanagawa.json +0 -77
  112. package/src/cli/cmd/tui/context/theme/lucent-orng.json +0 -237
  113. package/src/cli/cmd/tui/context/theme/material.json +0 -235
  114. package/src/cli/cmd/tui/context/theme/matrix.json +0 -77
  115. package/src/cli/cmd/tui/context/theme/mercury.json +0 -252
  116. package/src/cli/cmd/tui/context/theme/monokai.json +0 -221
  117. package/src/cli/cmd/tui/context/theme/nightowl.json +0 -221
  118. package/src/cli/cmd/tui/context/theme/nord.json +0 -223
  119. package/src/cli/cmd/tui/context/theme/one-dark.json +0 -84
  120. package/src/cli/cmd/tui/context/theme/orng.json +0 -249
  121. package/src/cli/cmd/tui/context/theme/osaka-jade.json +0 -93
  122. package/src/cli/cmd/tui/context/theme/palenight.json +0 -222
  123. package/src/cli/cmd/tui/context/theme/rosepine.json +0 -234
  124. package/src/cli/cmd/tui/context/theme/solarized.json +0 -223
  125. package/src/cli/cmd/tui/context/theme/synthwave84.json +0 -226
  126. package/src/cli/cmd/tui/context/theme/tokyonight.json +0 -243
  127. package/src/cli/cmd/tui/context/theme/vercel.json +0 -245
  128. package/src/cli/cmd/tui/context/theme/vesper.json +0 -218
  129. package/src/cli/cmd/tui/context/theme/zenburn.json +0 -223
  130. package/src/cli/cmd/tui/context/theme.tsx +0 -1153
  131. package/src/cli/cmd/tui/event.ts +0 -48
  132. package/src/cli/cmd/tui/hooks/use-command-registry.tsx +0 -184
  133. package/src/cli/cmd/tui/routes/home.tsx +0 -198
  134. package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +0 -64
  135. package/src/cli/cmd/tui/routes/session/dialog-message.tsx +0 -109
  136. package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +0 -26
  137. package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +0 -47
  138. package/src/cli/cmd/tui/routes/session/footer.tsx +0 -91
  139. package/src/cli/cmd/tui/routes/session/git-commit.tsx +0 -59
  140. package/src/cli/cmd/tui/routes/session/git-history.tsx +0 -122
  141. package/src/cli/cmd/tui/routes/session/header.tsx +0 -185
  142. package/src/cli/cmd/tui/routes/session/index.tsx +0 -2363
  143. package/src/cli/cmd/tui/routes/session/navigator-ui.tsx +0 -214
  144. package/src/cli/cmd/tui/routes/session/navigator.tsx +0 -1124
  145. package/src/cli/cmd/tui/routes/session/panel-explorer.tsx +0 -553
  146. package/src/cli/cmd/tui/routes/session/panel-viewer.tsx +0 -386
  147. package/src/cli/cmd/tui/routes/session/permission.tsx +0 -501
  148. package/src/cli/cmd/tui/routes/session/question.tsx +0 -507
  149. package/src/cli/cmd/tui/routes/session/sidebar.tsx +0 -365
  150. package/src/cli/cmd/tui/routes/session/vcs-diff-viewer.tsx +0 -37
  151. package/src/cli/cmd/tui/routes/ui-settings.tsx +0 -449
  152. package/src/cli/cmd/tui/thread.ts +0 -172
  153. package/src/cli/cmd/tui/ui/dialog-alert.tsx +0 -90
  154. package/src/cli/cmd/tui/ui/dialog-confirm.tsx +0 -83
  155. package/src/cli/cmd/tui/ui/dialog-export-options.tsx +0 -204
  156. package/src/cli/cmd/tui/ui/dialog-help.tsx +0 -38
  157. package/src/cli/cmd/tui/ui/dialog-prompt.tsx +0 -77
  158. package/src/cli/cmd/tui/ui/dialog-select.tsx +0 -384
  159. package/src/cli/cmd/tui/ui/dialog.tsx +0 -170
  160. package/src/cli/cmd/tui/ui/link.tsx +0 -28
  161. package/src/cli/cmd/tui/ui/spinner.ts +0 -375
  162. package/src/cli/cmd/tui/ui/toast.tsx +0 -100
  163. package/src/cli/cmd/tui/util/clipboard.ts +0 -255
  164. package/src/cli/cmd/tui/util/editor.ts +0 -32
  165. package/src/cli/cmd/tui/util/signal.ts +0 -7
  166. package/src/cli/cmd/tui/util/terminal.ts +0 -114
  167. package/src/cli/cmd/tui/util/transcript.ts +0 -98
  168. package/src/cli/cmd/tui/worker.ts +0 -152
  169. package/src/cli/cmd/uninstall.ts +0 -362
  170. package/src/cli/cmd/upgrade.ts +0 -73
  171. package/src/cli/cmd/web.ts +0 -81
  172. package/src/cli/error.ts +0 -57
  173. package/src/cli/network.ts +0 -53
  174. package/src/cli/ui.ts +0 -119
  175. package/src/cli/upgrade.ts +0 -25
  176. package/src/command/index.ts +0 -131
  177. package/src/command/template/initialize.txt +0 -10
  178. package/src/command/template/review.txt +0 -99
  179. package/src/config/config.ts +0 -1404
  180. package/src/config/markdown.ts +0 -93
  181. package/src/env/index.ts +0 -26
  182. package/src/file/ignore.ts +0 -83
  183. package/src/file/index.ts +0 -432
  184. package/src/file/ripgrep.ts +0 -407
  185. package/src/file/time.ts +0 -69
  186. package/src/file/watcher.ts +0 -127
  187. package/src/flag/flag.ts +0 -80
  188. package/src/format/formatter.ts +0 -357
  189. package/src/format/index.ts +0 -137
  190. package/src/global/index.ts +0 -58
  191. package/src/id/id.ts +0 -83
  192. package/src/ide/index.ts +0 -76
  193. package/src/index.ts +0 -208
  194. package/src/installation/index.ts +0 -258
  195. package/src/lsp/client.ts +0 -252
  196. package/src/lsp/index.ts +0 -485
  197. package/src/lsp/language.ts +0 -119
  198. package/src/lsp/server.ts +0 -2046
  199. package/src/mcp/auth.ts +0 -135
  200. package/src/mcp/index.ts +0 -934
  201. package/src/mcp/oauth-callback.ts +0 -200
  202. package/src/mcp/oauth-provider.ts +0 -155
  203. package/src/patch/index.ts +0 -680
  204. package/src/permission/arity.ts +0 -163
  205. package/src/permission/index.ts +0 -210
  206. package/src/permission/next.ts +0 -280
  207. package/src/plugin/codex.ts +0 -500
  208. package/src/plugin/copilot.ts +0 -283
  209. package/src/plugin/index.ts +0 -135
  210. package/src/project/bootstrap.ts +0 -35
  211. package/src/project/instance.ts +0 -91
  212. package/src/project/project.ts +0 -371
  213. package/src/project/state.ts +0 -66
  214. package/src/project/vcs.ts +0 -151
  215. package/src/provider/auth.ts +0 -147
  216. package/src/provider/models-macro.ts +0 -14
  217. package/src/provider/models.ts +0 -114
  218. package/src/provider/provider.ts +0 -1220
  219. package/src/provider/sdk/openai-compatible/src/README.md +0 -5
  220. package/src/provider/sdk/openai-compatible/src/index.ts +0 -2
  221. package/src/provider/sdk/openai-compatible/src/openai-compatible-provider.ts +0 -100
  222. package/src/provider/sdk/openai-compatible/src/responses/convert-to-openai-responses-input.ts +0 -303
  223. package/src/provider/sdk/openai-compatible/src/responses/map-openai-responses-finish-reason.ts +0 -22
  224. package/src/provider/sdk/openai-compatible/src/responses/openai-config.ts +0 -18
  225. package/src/provider/sdk/openai-compatible/src/responses/openai-error.ts +0 -22
  226. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-api-types.ts +0 -207
  227. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-language-model.ts +0 -1732
  228. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-prepare-tools.ts +0 -177
  229. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-settings.ts +0 -1
  230. package/src/provider/sdk/openai-compatible/src/responses/tool/code-interpreter.ts +0 -88
  231. package/src/provider/sdk/openai-compatible/src/responses/tool/file-search.ts +0 -128
  232. package/src/provider/sdk/openai-compatible/src/responses/tool/image-generation.ts +0 -115
  233. package/src/provider/sdk/openai-compatible/src/responses/tool/local-shell.ts +0 -65
  234. package/src/provider/sdk/openai-compatible/src/responses/tool/web-search-preview.ts +0 -104
  235. package/src/provider/sdk/openai-compatible/src/responses/tool/web-search.ts +0 -103
  236. package/src/provider/transform.ts +0 -742
  237. package/src/pty/index.ts +0 -241
  238. package/src/question/index.ts +0 -176
  239. package/src/scheduler/index.ts +0 -61
  240. package/src/server/error.ts +0 -36
  241. package/src/server/event.ts +0 -7
  242. package/src/server/mdns.ts +0 -59
  243. package/src/server/routes/config.ts +0 -92
  244. package/src/server/routes/experimental.ts +0 -208
  245. package/src/server/routes/file.ts +0 -227
  246. package/src/server/routes/global.ts +0 -135
  247. package/src/server/routes/mcp.ts +0 -225
  248. package/src/server/routes/permission.ts +0 -68
  249. package/src/server/routes/project.ts +0 -82
  250. package/src/server/routes/provider.ts +0 -165
  251. package/src/server/routes/pty.ts +0 -169
  252. package/src/server/routes/question.ts +0 -98
  253. package/src/server/routes/session.ts +0 -939
  254. package/src/server/routes/tui.ts +0 -379
  255. package/src/server/server.ts +0 -663
  256. package/src/session/compaction.ts +0 -225
  257. package/src/session/index.ts +0 -498
  258. package/src/session/llm.ts +0 -288
  259. package/src/session/message-v2.ts +0 -740
  260. package/src/session/message.ts +0 -189
  261. package/src/session/processor.ts +0 -406
  262. package/src/session/prompt/anthropic-20250930.txt +0 -168
  263. package/src/session/prompt/anthropic.txt +0 -172
  264. package/src/session/prompt/anthropic_spoof.txt +0 -1
  265. package/src/session/prompt/beast.txt +0 -149
  266. package/src/session/prompt/build-switch.txt +0 -5
  267. package/src/session/prompt/codex_header.txt +0 -81
  268. package/src/session/prompt/copilot-gpt-5.txt +0 -145
  269. package/src/session/prompt/gemini.txt +0 -157
  270. package/src/session/prompt/max-steps.txt +0 -16
  271. package/src/session/prompt/plan-reminder-anthropic.txt +0 -67
  272. package/src/session/prompt/plan.txt +0 -26
  273. package/src/session/prompt/qwen.txt +0 -111
  274. package/src/session/prompt.ts +0 -1815
  275. package/src/session/retry.ts +0 -90
  276. package/src/session/revert.ts +0 -121
  277. package/src/session/status.ts +0 -76
  278. package/src/session/summary.ts +0 -150
  279. package/src/session/system.ts +0 -156
  280. package/src/session/todo.ts +0 -37
  281. package/src/share/share-next.ts +0 -204
  282. package/src/share/share.ts +0 -95
  283. package/src/shell/shell.ts +0 -67
  284. package/src/skill/index.ts +0 -1
  285. package/src/skill/skill.ts +0 -135
  286. package/src/snapshot/index.ts +0 -236
  287. package/src/storage/storage.ts +0 -227
  288. package/src/tool/apply_patch.ts +0 -279
  289. package/src/tool/apply_patch.txt +0 -33
  290. package/src/tool/bash.ts +0 -258
  291. package/src/tool/bash.txt +0 -115
  292. package/src/tool/batch.ts +0 -175
  293. package/src/tool/batch.txt +0 -24
  294. package/src/tool/codesearch.ts +0 -132
  295. package/src/tool/codesearch.txt +0 -12
  296. package/src/tool/edit.ts +0 -645
  297. package/src/tool/edit.txt +0 -10
  298. package/src/tool/external-directory.ts +0 -32
  299. package/src/tool/glob.ts +0 -77
  300. package/src/tool/glob.txt +0 -6
  301. package/src/tool/grep.ts +0 -154
  302. package/src/tool/grep.txt +0 -8
  303. package/src/tool/invalid.ts +0 -17
  304. package/src/tool/ls.ts +0 -121
  305. package/src/tool/ls.txt +0 -1
  306. package/src/tool/lsp.ts +0 -96
  307. package/src/tool/lsp.txt +0 -19
  308. package/src/tool/multiedit.ts +0 -46
  309. package/src/tool/multiedit.txt +0 -41
  310. package/src/tool/plan-enter.txt +0 -14
  311. package/src/tool/plan-exit.txt +0 -13
  312. package/src/tool/plan.ts +0 -130
  313. package/src/tool/question.ts +0 -33
  314. package/src/tool/question.txt +0 -10
  315. package/src/tool/read.ts +0 -202
  316. package/src/tool/read.txt +0 -12
  317. package/src/tool/registry.ts +0 -162
  318. package/src/tool/skill.ts +0 -82
  319. package/src/tool/task.ts +0 -188
  320. package/src/tool/task.txt +0 -60
  321. package/src/tool/todo.ts +0 -53
  322. package/src/tool/todoread.txt +0 -14
  323. package/src/tool/todowrite.txt +0 -167
  324. package/src/tool/tool.ts +0 -88
  325. package/src/tool/truncation.ts +0 -106
  326. package/src/tool/webfetch.ts +0 -182
  327. package/src/tool/webfetch.txt +0 -13
  328. package/src/tool/websearch.ts +0 -150
  329. package/src/tool/websearch.txt +0 -14
  330. package/src/tool/write.ts +0 -80
  331. package/src/tool/write.txt +0 -8
  332. package/src/util/archive.ts +0 -16
  333. package/src/util/color.ts +0 -19
  334. package/src/util/context.ts +0 -25
  335. package/src/util/defer.ts +0 -12
  336. package/src/util/eventloop.ts +0 -20
  337. package/src/util/filesystem.ts +0 -93
  338. package/src/util/fn.ts +0 -11
  339. package/src/util/format.ts +0 -20
  340. package/src/util/iife.ts +0 -3
  341. package/src/util/keybind.ts +0 -103
  342. package/src/util/lazy.ts +0 -18
  343. package/src/util/locale.ts +0 -81
  344. package/src/util/lock.ts +0 -98
  345. package/src/util/log.ts +0 -180
  346. package/src/util/queue.ts +0 -32
  347. package/src/util/rpc.ts +0 -66
  348. package/src/util/scrap.ts +0 -10
  349. package/src/util/signal.ts +0 -12
  350. package/src/util/timeout.ts +0 -14
  351. package/src/util/token.ts +0 -7
  352. package/src/util/wildcard.ts +0 -56
  353. package/src/worktree/index.ts +0 -524
  354. package/sst-env.d.ts +0 -9
  355. package/test/acp/agent-interface.test.ts +0 -51
  356. package/test/acp/event-subscription.test.ts +0 -436
  357. package/test/agent/agent.test.ts +0 -638
  358. package/test/bun.test.ts +0 -53
  359. package/test/cli/cmd/tui/fileref.test.ts +0 -30
  360. package/test/cli/github-action.test.ts +0 -129
  361. package/test/cli/github-remote.test.ts +0 -80
  362. package/test/cli/tui/navigator_logic.test.ts +0 -99
  363. package/test/cli/tui/transcript.test.ts +0 -297
  364. package/test/cli/ui.test.ts +0 -80
  365. package/test/config/agent-color.test.ts +0 -66
  366. package/test/config/config.test.ts +0 -1613
  367. package/test/config/fixtures/empty-frontmatter.md +0 -4
  368. package/test/config/fixtures/frontmatter.md +0 -28
  369. package/test/config/fixtures/no-frontmatter.md +0 -1
  370. package/test/config/markdown.test.ts +0 -192
  371. package/test/file/ignore.test.ts +0 -10
  372. package/test/file/path-traversal.test.ts +0 -198
  373. package/test/fixture/fixture.ts +0 -45
  374. package/test/fixture/lsp/fake-lsp-server.js +0 -77
  375. package/test/ide/ide.test.ts +0 -82
  376. package/test/keybind.test.ts +0 -421
  377. package/test/lsp/client.test.ts +0 -95
  378. package/test/mcp/headers.test.ts +0 -153
  379. package/test/mcp/oauth-browser.test.ts +0 -261
  380. package/test/patch/patch.test.ts +0 -348
  381. package/test/permission/arity.test.ts +0 -33
  382. package/test/permission/next.test.ts +0 -690
  383. package/test/permission-task.test.ts +0 -319
  384. package/test/plugin/codex.test.ts +0 -123
  385. package/test/preload.ts +0 -67
  386. package/test/project/project.test.ts +0 -120
  387. package/test/provider/amazon-bedrock.test.ts +0 -268
  388. package/test/provider/gitlab-duo.test.ts +0 -286
  389. package/test/provider/provider.test.ts +0 -2149
  390. package/test/provider/transform.test.ts +0 -1631
  391. package/test/question/question.test.ts +0 -300
  392. package/test/scheduler.test.ts +0 -73
  393. package/test/server/session-list.test.ts +0 -39
  394. package/test/server/session-select.test.ts +0 -78
  395. package/test/session/compaction.test.ts +0 -293
  396. package/test/session/llm.test.ts +0 -90
  397. package/test/session/message-v2.test.ts +0 -786
  398. package/test/session/retry.test.ts +0 -131
  399. package/test/session/revert-compact.test.ts +0 -285
  400. package/test/session/session.test.ts +0 -71
  401. package/test/skill/skill.test.ts +0 -185
  402. package/test/snapshot/snapshot.test.ts +0 -939
  403. package/test/tool/__snapshots__/tool.test.ts.snap +0 -9
  404. package/test/tool/apply_patch.test.ts +0 -499
  405. package/test/tool/bash.test.ts +0 -320
  406. package/test/tool/external-directory.test.ts +0 -126
  407. package/test/tool/fixtures/large-image.png +0 -0
  408. package/test/tool/fixtures/models-api.json +0 -33453
  409. package/test/tool/grep.test.ts +0 -109
  410. package/test/tool/question.test.ts +0 -105
  411. package/test/tool/read.test.ts +0 -332
  412. package/test/tool/registry.test.ts +0 -76
  413. package/test/tool/truncation.test.ts +0 -159
  414. package/test/util/filesystem.test.ts +0 -39
  415. package/test/util/format.test.ts +0 -59
  416. package/test/util/iife.test.ts +0 -36
  417. package/test/util/lazy.test.ts +0 -50
  418. package/test/util/lock.test.ts +0 -72
  419. package/test/util/timeout.test.ts +0 -21
  420. package/test/util/wildcard.test.ts +0 -75
  421. package/tsconfig.json +0 -16
@@ -1,2149 +0,0 @@
1
- import { test, expect, mock } from "bun:test"
2
- import path from "path"
3
-
4
- // Mock BunProc and default plugins to prevent actual installations during tests
5
- mock.module("../../src/bun/index", () => ({
6
- BunProc: {
7
- install: async (pkg: string, _version?: string) => {
8
- // Return package name without version for mocking
9
- const lastAtIndex = pkg.lastIndexOf("@")
10
- return lastAtIndex > 0 ? pkg.substring(0, lastAtIndex) : pkg
11
- },
12
- run: async () => {
13
- throw new Error("BunProc.run should not be called in tests")
14
- },
15
- which: () => process.execPath,
16
- InstallFailedError: class extends Error {},
17
- },
18
- }))
19
-
20
- const mockPlugin = () => ({})
21
- mock.module("jonsoc-copilot-auth", () => ({ default: mockPlugin }))
22
- mock.module("jonsoc-anthropic-auth", () => ({ default: mockPlugin }))
23
- mock.module("@gitlab/jonsoc-gitlab-auth", () => ({ default: mockPlugin }))
24
-
25
- import { tmpdir } from "../fixture/fixture"
26
- import { Instance } from "../../src/project/instance"
27
- import { Provider } from "../../src/provider/provider"
28
- import { Env } from "../../src/env"
29
-
30
- test("provider loaded from env variable", async () => {
31
- await using tmp = await tmpdir({
32
- init: async (dir) => {
33
- await Bun.write(
34
- path.join(dir, "jonsoc.json"),
35
- JSON.stringify({
36
- $schema: "https://jonsoc.com/config.json",
37
- }),
38
- )
39
- },
40
- })
41
- await Instance.provide({
42
- directory: tmp.path,
43
- init: async () => {
44
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
45
- },
46
- fn: async () => {
47
- const providers = await Provider.list()
48
- expect(providers["anthropic"]).toBeDefined()
49
- // Note: source becomes "custom" because CUSTOM_LOADERS run after env loading
50
- // and anthropic has a custom loader that merges additional options
51
- expect(providers["anthropic"].source).toBe("custom")
52
- },
53
- })
54
- })
55
-
56
- test("provider loaded from config with apiKey option", async () => {
57
- await using tmp = await tmpdir({
58
- init: async (dir) => {
59
- await Bun.write(
60
- path.join(dir, "jonsoc.json"),
61
- JSON.stringify({
62
- $schema: "https://jonsoc.com/config.json",
63
- provider: {
64
- anthropic: {
65
- options: {
66
- apiKey: "config-api-key",
67
- },
68
- },
69
- },
70
- }),
71
- )
72
- },
73
- })
74
- await Instance.provide({
75
- directory: tmp.path,
76
- fn: async () => {
77
- const providers = await Provider.list()
78
- expect(providers["anthropic"]).toBeDefined()
79
- },
80
- })
81
- })
82
-
83
- test("disabled_providers excludes provider", async () => {
84
- await using tmp = await tmpdir({
85
- init: async (dir) => {
86
- await Bun.write(
87
- path.join(dir, "jonsoc.json"),
88
- JSON.stringify({
89
- $schema: "https://jonsoc.com/config.json",
90
- disabled_providers: ["anthropic"],
91
- }),
92
- )
93
- },
94
- })
95
- await Instance.provide({
96
- directory: tmp.path,
97
- init: async () => {
98
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
99
- },
100
- fn: async () => {
101
- const providers = await Provider.list()
102
- expect(providers["anthropic"]).toBeUndefined()
103
- },
104
- })
105
- })
106
-
107
- test("enabled_providers restricts to only listed providers", async () => {
108
- await using tmp = await tmpdir({
109
- init: async (dir) => {
110
- await Bun.write(
111
- path.join(dir, "jonsoc.json"),
112
- JSON.stringify({
113
- $schema: "https://jonsoc.com/config.json",
114
- enabled_providers: ["anthropic"],
115
- }),
116
- )
117
- },
118
- })
119
- await Instance.provide({
120
- directory: tmp.path,
121
- init: async () => {
122
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
123
- Env.set("OPENAI_API_KEY", "test-openai-key")
124
- },
125
- fn: async () => {
126
- const providers = await Provider.list()
127
- expect(providers["anthropic"]).toBeDefined()
128
- expect(providers["openai"]).toBeUndefined()
129
- },
130
- })
131
- })
132
-
133
- test("model whitelist filters models for provider", async () => {
134
- await using tmp = await tmpdir({
135
- init: async (dir) => {
136
- await Bun.write(
137
- path.join(dir, "jonsoc.json"),
138
- JSON.stringify({
139
- $schema: "https://jonsoc.com/config.json",
140
- provider: {
141
- anthropic: {
142
- whitelist: ["claude-sonnet-4-20250514"],
143
- },
144
- },
145
- }),
146
- )
147
- },
148
- })
149
- await Instance.provide({
150
- directory: tmp.path,
151
- init: async () => {
152
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
153
- },
154
- fn: async () => {
155
- const providers = await Provider.list()
156
- expect(providers["anthropic"]).toBeDefined()
157
- const models = Object.keys(providers["anthropic"].models)
158
- expect(models).toContain("claude-sonnet-4-20250514")
159
- expect(models.length).toBe(1)
160
- },
161
- })
162
- })
163
-
164
- test("model blacklist excludes specific models", async () => {
165
- await using tmp = await tmpdir({
166
- init: async (dir) => {
167
- await Bun.write(
168
- path.join(dir, "jonsoc.json"),
169
- JSON.stringify({
170
- $schema: "https://jonsoc.com/config.json",
171
- provider: {
172
- anthropic: {
173
- blacklist: ["claude-sonnet-4-20250514"],
174
- },
175
- },
176
- }),
177
- )
178
- },
179
- })
180
- await Instance.provide({
181
- directory: tmp.path,
182
- init: async () => {
183
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
184
- },
185
- fn: async () => {
186
- const providers = await Provider.list()
187
- expect(providers["anthropic"]).toBeDefined()
188
- const models = Object.keys(providers["anthropic"].models)
189
- expect(models).not.toContain("claude-sonnet-4-20250514")
190
- },
191
- })
192
- })
193
-
194
- test("custom model alias via config", async () => {
195
- await using tmp = await tmpdir({
196
- init: async (dir) => {
197
- await Bun.write(
198
- path.join(dir, "jonsoc.json"),
199
- JSON.stringify({
200
- $schema: "https://jonsoc.com/config.json",
201
- provider: {
202
- anthropic: {
203
- models: {
204
- "my-alias": {
205
- id: "claude-sonnet-4-20250514",
206
- name: "My Custom Alias",
207
- },
208
- },
209
- },
210
- },
211
- }),
212
- )
213
- },
214
- })
215
- await Instance.provide({
216
- directory: tmp.path,
217
- init: async () => {
218
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
219
- },
220
- fn: async () => {
221
- const providers = await Provider.list()
222
- expect(providers["anthropic"]).toBeDefined()
223
- expect(providers["anthropic"].models["my-alias"]).toBeDefined()
224
- expect(providers["anthropic"].models["my-alias"].name).toBe("My Custom Alias")
225
- },
226
- })
227
- })
228
-
229
- test("custom provider with npm package", async () => {
230
- await using tmp = await tmpdir({
231
- init: async (dir) => {
232
- await Bun.write(
233
- path.join(dir, "jonsoc.json"),
234
- JSON.stringify({
235
- $schema: "https://jonsoc.com/config.json",
236
- provider: {
237
- "custom-provider": {
238
- name: "Custom Provider",
239
- npm: "@ai-sdk/openai-compatible",
240
- api: "https://api.custom.com/v1",
241
- env: ["CUSTOM_API_KEY"],
242
- models: {
243
- "custom-model": {
244
- name: "Custom Model",
245
- tool_call: true,
246
- limit: {
247
- context: 128000,
248
- output: 4096,
249
- },
250
- },
251
- },
252
- options: {
253
- apiKey: "custom-key",
254
- },
255
- },
256
- },
257
- }),
258
- )
259
- },
260
- })
261
- await Instance.provide({
262
- directory: tmp.path,
263
- fn: async () => {
264
- const providers = await Provider.list()
265
- expect(providers["custom-provider"]).toBeDefined()
266
- expect(providers["custom-provider"].name).toBe("Custom Provider")
267
- expect(providers["custom-provider"].models["custom-model"]).toBeDefined()
268
- },
269
- })
270
- })
271
-
272
- test("env variable takes precedence, config merges options", async () => {
273
- await using tmp = await tmpdir({
274
- init: async (dir) => {
275
- await Bun.write(
276
- path.join(dir, "jonsoc.json"),
277
- JSON.stringify({
278
- $schema: "https://jonsoc.com/config.json",
279
- provider: {
280
- anthropic: {
281
- options: {
282
- timeout: 60000,
283
- },
284
- },
285
- },
286
- }),
287
- )
288
- },
289
- })
290
- await Instance.provide({
291
- directory: tmp.path,
292
- init: async () => {
293
- Env.set("ANTHROPIC_API_KEY", "env-api-key")
294
- },
295
- fn: async () => {
296
- const providers = await Provider.list()
297
- expect(providers["anthropic"]).toBeDefined()
298
- // Config options should be merged
299
- expect(providers["anthropic"].options.timeout).toBe(60000)
300
- },
301
- })
302
- })
303
-
304
- test("getModel returns model for valid provider/model", async () => {
305
- await using tmp = await tmpdir({
306
- init: async (dir) => {
307
- await Bun.write(
308
- path.join(dir, "jonsoc.json"),
309
- JSON.stringify({
310
- $schema: "https://jonsoc.com/config.json",
311
- }),
312
- )
313
- },
314
- })
315
- await Instance.provide({
316
- directory: tmp.path,
317
- init: async () => {
318
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
319
- },
320
- fn: async () => {
321
- const model = await Provider.getModel("anthropic", "claude-sonnet-4-20250514")
322
- expect(model).toBeDefined()
323
- expect(model.providerID).toBe("anthropic")
324
- expect(model.id).toBe("claude-sonnet-4-20250514")
325
- const language = await Provider.getLanguage(model)
326
- expect(language).toBeDefined()
327
- },
328
- })
329
- })
330
-
331
- test("getModel throws ModelNotFoundError for invalid model", async () => {
332
- await using tmp = await tmpdir({
333
- init: async (dir) => {
334
- await Bun.write(
335
- path.join(dir, "jonsoc.json"),
336
- JSON.stringify({
337
- $schema: "https://jonsoc.com/config.json",
338
- }),
339
- )
340
- },
341
- })
342
- await Instance.provide({
343
- directory: tmp.path,
344
- init: async () => {
345
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
346
- },
347
- fn: async () => {
348
- expect(Provider.getModel("anthropic", "nonexistent-model")).rejects.toThrow()
349
- },
350
- })
351
- })
352
-
353
- test("getModel throws ModelNotFoundError for invalid provider", async () => {
354
- await using tmp = await tmpdir({
355
- init: async (dir) => {
356
- await Bun.write(
357
- path.join(dir, "jonsoc.json"),
358
- JSON.stringify({
359
- $schema: "https://jonsoc.com/config.json",
360
- }),
361
- )
362
- },
363
- })
364
- await Instance.provide({
365
- directory: tmp.path,
366
- fn: async () => {
367
- expect(Provider.getModel("nonexistent-provider", "some-model")).rejects.toThrow()
368
- },
369
- })
370
- })
371
-
372
- test("parseModel correctly parses provider/model string", () => {
373
- const result = Provider.parseModel("anthropic/claude-sonnet-4")
374
- expect(result.providerID).toBe("anthropic")
375
- expect(result.modelID).toBe("claude-sonnet-4")
376
- })
377
-
378
- test("parseModel handles model IDs with slashes", () => {
379
- const result = Provider.parseModel("openrouter/anthropic/claude-3-opus")
380
- expect(result.providerID).toBe("openrouter")
381
- expect(result.modelID).toBe("anthropic/claude-3-opus")
382
- })
383
-
384
- test("defaultModel returns first available model when no config set", async () => {
385
- await using tmp = await tmpdir({
386
- init: async (dir) => {
387
- await Bun.write(
388
- path.join(dir, "jonsoc.json"),
389
- JSON.stringify({
390
- $schema: "https://jonsoc.com/config.json",
391
- }),
392
- )
393
- },
394
- })
395
- await Instance.provide({
396
- directory: tmp.path,
397
- init: async () => {
398
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
399
- },
400
- fn: async () => {
401
- const model = await Provider.defaultModel()
402
- expect(model.providerID).toBeDefined()
403
- expect(model.modelID).toBeDefined()
404
- },
405
- })
406
- })
407
-
408
- test("defaultModel respects config model setting", async () => {
409
- await using tmp = await tmpdir({
410
- init: async (dir) => {
411
- await Bun.write(
412
- path.join(dir, "jonsoc.json"),
413
- JSON.stringify({
414
- $schema: "https://jonsoc.com/config.json",
415
- model: "anthropic/claude-sonnet-4-20250514",
416
- }),
417
- )
418
- },
419
- })
420
- await Instance.provide({
421
- directory: tmp.path,
422
- init: async () => {
423
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
424
- },
425
- fn: async () => {
426
- const model = await Provider.defaultModel()
427
- expect(model.providerID).toBe("anthropic")
428
- expect(model.modelID).toBe("claude-sonnet-4-20250514")
429
- },
430
- })
431
- })
432
-
433
- test("provider with baseURL from config", async () => {
434
- await using tmp = await tmpdir({
435
- init: async (dir) => {
436
- await Bun.write(
437
- path.join(dir, "jonsoc.json"),
438
- JSON.stringify({
439
- $schema: "https://jonsoc.com/config.json",
440
- provider: {
441
- "custom-openai": {
442
- name: "Custom OpenAI",
443
- npm: "@ai-sdk/openai-compatible",
444
- env: [],
445
- models: {
446
- "gpt-4": {
447
- name: "GPT-4",
448
- tool_call: true,
449
- limit: { context: 128000, output: 4096 },
450
- },
451
- },
452
- options: {
453
- apiKey: "test-key",
454
- baseURL: "https://custom.openai.com/v1",
455
- },
456
- },
457
- },
458
- }),
459
- )
460
- },
461
- })
462
- await Instance.provide({
463
- directory: tmp.path,
464
- fn: async () => {
465
- const providers = await Provider.list()
466
- expect(providers["custom-openai"]).toBeDefined()
467
- expect(providers["custom-openai"].options.baseURL).toBe("https://custom.openai.com/v1")
468
- },
469
- })
470
- })
471
-
472
- test("model cost defaults to zero when not specified", async () => {
473
- await using tmp = await tmpdir({
474
- init: async (dir) => {
475
- await Bun.write(
476
- path.join(dir, "jonsoc.json"),
477
- JSON.stringify({
478
- $schema: "https://jonsoc.com/config.json",
479
- provider: {
480
- "test-provider": {
481
- name: "Test Provider",
482
- npm: "@ai-sdk/openai-compatible",
483
- env: [],
484
- models: {
485
- "test-model": {
486
- name: "Test Model",
487
- tool_call: true,
488
- limit: { context: 128000, output: 4096 },
489
- },
490
- },
491
- options: {
492
- apiKey: "test-key",
493
- },
494
- },
495
- },
496
- }),
497
- )
498
- },
499
- })
500
- await Instance.provide({
501
- directory: tmp.path,
502
- fn: async () => {
503
- const providers = await Provider.list()
504
- const model = providers["test-provider"].models["test-model"]
505
- expect(model.cost.input).toBe(0)
506
- expect(model.cost.output).toBe(0)
507
- expect(model.cost.cache.read).toBe(0)
508
- expect(model.cost.cache.write).toBe(0)
509
- },
510
- })
511
- })
512
-
513
- test("model options are merged from existing model", async () => {
514
- await using tmp = await tmpdir({
515
- init: async (dir) => {
516
- await Bun.write(
517
- path.join(dir, "jonsoc.json"),
518
- JSON.stringify({
519
- $schema: "https://jonsoc.com/config.json",
520
- provider: {
521
- anthropic: {
522
- models: {
523
- "claude-sonnet-4-20250514": {
524
- options: {
525
- customOption: "custom-value",
526
- },
527
- },
528
- },
529
- },
530
- },
531
- }),
532
- )
533
- },
534
- })
535
- await Instance.provide({
536
- directory: tmp.path,
537
- init: async () => {
538
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
539
- },
540
- fn: async () => {
541
- const providers = await Provider.list()
542
- const model = providers["anthropic"].models["claude-sonnet-4-20250514"]
543
- expect(model.options.customOption).toBe("custom-value")
544
- },
545
- })
546
- })
547
-
548
- test("provider removed when all models filtered out", async () => {
549
- await using tmp = await tmpdir({
550
- init: async (dir) => {
551
- await Bun.write(
552
- path.join(dir, "jonsoc.json"),
553
- JSON.stringify({
554
- $schema: "https://jonsoc.com/config.json",
555
- provider: {
556
- anthropic: {
557
- whitelist: ["nonexistent-model"],
558
- },
559
- },
560
- }),
561
- )
562
- },
563
- })
564
- await Instance.provide({
565
- directory: tmp.path,
566
- init: async () => {
567
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
568
- },
569
- fn: async () => {
570
- const providers = await Provider.list()
571
- expect(providers["anthropic"]).toBeUndefined()
572
- },
573
- })
574
- })
575
-
576
- test("closest finds model by partial match", async () => {
577
- await using tmp = await tmpdir({
578
- init: async (dir) => {
579
- await Bun.write(
580
- path.join(dir, "jonsoc.json"),
581
- JSON.stringify({
582
- $schema: "https://jonsoc.com/config.json",
583
- }),
584
- )
585
- },
586
- })
587
- await Instance.provide({
588
- directory: tmp.path,
589
- init: async () => {
590
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
591
- },
592
- fn: async () => {
593
- const result = await Provider.closest("anthropic", ["sonnet-4"])
594
- expect(result).toBeDefined()
595
- expect(result?.providerID).toBe("anthropic")
596
- expect(result?.modelID).toContain("sonnet-4")
597
- },
598
- })
599
- })
600
-
601
- test("closest returns undefined for nonexistent provider", async () => {
602
- await using tmp = await tmpdir({
603
- init: async (dir) => {
604
- await Bun.write(
605
- path.join(dir, "jonsoc.json"),
606
- JSON.stringify({
607
- $schema: "https://jonsoc.com/config.json",
608
- }),
609
- )
610
- },
611
- })
612
- await Instance.provide({
613
- directory: tmp.path,
614
- fn: async () => {
615
- const result = await Provider.closest("nonexistent", ["model"])
616
- expect(result).toBeUndefined()
617
- },
618
- })
619
- })
620
-
621
- test("getModel uses realIdByKey for aliased models", async () => {
622
- await using tmp = await tmpdir({
623
- init: async (dir) => {
624
- await Bun.write(
625
- path.join(dir, "jonsoc.json"),
626
- JSON.stringify({
627
- $schema: "https://jonsoc.com/config.json",
628
- provider: {
629
- anthropic: {
630
- models: {
631
- "my-sonnet": {
632
- id: "claude-sonnet-4-20250514",
633
- name: "My Sonnet Alias",
634
- },
635
- },
636
- },
637
- },
638
- }),
639
- )
640
- },
641
- })
642
- await Instance.provide({
643
- directory: tmp.path,
644
- init: async () => {
645
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
646
- },
647
- fn: async () => {
648
- const providers = await Provider.list()
649
- expect(providers["anthropic"].models["my-sonnet"]).toBeDefined()
650
-
651
- const model = await Provider.getModel("anthropic", "my-sonnet")
652
- expect(model).toBeDefined()
653
- expect(model.id).toBe("my-sonnet")
654
- expect(model.name).toBe("My Sonnet Alias")
655
- },
656
- })
657
- })
658
-
659
- test("provider api field sets model api.url", async () => {
660
- await using tmp = await tmpdir({
661
- init: async (dir) => {
662
- await Bun.write(
663
- path.join(dir, "jonsoc.json"),
664
- JSON.stringify({
665
- $schema: "https://jonsoc.com/config.json",
666
- provider: {
667
- "custom-api": {
668
- name: "Custom API",
669
- npm: "@ai-sdk/openai-compatible",
670
- api: "https://api.example.com/v1",
671
- env: [],
672
- models: {
673
- "model-1": {
674
- name: "Model 1",
675
- tool_call: true,
676
- limit: { context: 8000, output: 2000 },
677
- },
678
- },
679
- options: {
680
- apiKey: "test-key",
681
- },
682
- },
683
- },
684
- }),
685
- )
686
- },
687
- })
688
- await Instance.provide({
689
- directory: tmp.path,
690
- fn: async () => {
691
- const providers = await Provider.list()
692
- // api field is stored on model.api.url, used by getSDK to set baseURL
693
- expect(providers["custom-api"].models["model-1"].api.url).toBe("https://api.example.com/v1")
694
- },
695
- })
696
- })
697
-
698
- test("explicit baseURL overrides api field", async () => {
699
- await using tmp = await tmpdir({
700
- init: async (dir) => {
701
- await Bun.write(
702
- path.join(dir, "jonsoc.json"),
703
- JSON.stringify({
704
- $schema: "https://jonsoc.com/config.json",
705
- provider: {
706
- "custom-api": {
707
- name: "Custom API",
708
- npm: "@ai-sdk/openai-compatible",
709
- api: "https://api.example.com/v1",
710
- env: [],
711
- models: {
712
- "model-1": {
713
- name: "Model 1",
714
- tool_call: true,
715
- limit: { context: 8000, output: 2000 },
716
- },
717
- },
718
- options: {
719
- apiKey: "test-key",
720
- baseURL: "https://custom.override.com/v1",
721
- },
722
- },
723
- },
724
- }),
725
- )
726
- },
727
- })
728
- await Instance.provide({
729
- directory: tmp.path,
730
- fn: async () => {
731
- const providers = await Provider.list()
732
- expect(providers["custom-api"].options.baseURL).toBe("https://custom.override.com/v1")
733
- },
734
- })
735
- })
736
-
737
- test("model inherits properties from existing database model", async () => {
738
- await using tmp = await tmpdir({
739
- init: async (dir) => {
740
- await Bun.write(
741
- path.join(dir, "jonsoc.json"),
742
- JSON.stringify({
743
- $schema: "https://jonsoc.com/config.json",
744
- provider: {
745
- anthropic: {
746
- models: {
747
- "claude-sonnet-4-20250514": {
748
- name: "Custom Name for Sonnet",
749
- },
750
- },
751
- },
752
- },
753
- }),
754
- )
755
- },
756
- })
757
- await Instance.provide({
758
- directory: tmp.path,
759
- init: async () => {
760
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
761
- },
762
- fn: async () => {
763
- const providers = await Provider.list()
764
- const model = providers["anthropic"].models["claude-sonnet-4-20250514"]
765
- expect(model.name).toBe("Custom Name for Sonnet")
766
- expect(model.capabilities.toolcall).toBe(true)
767
- expect(model.capabilities.attachment).toBe(true)
768
- expect(model.limit.context).toBeGreaterThan(0)
769
- },
770
- })
771
- })
772
-
773
- test("disabled_providers prevents loading even with env var", async () => {
774
- await using tmp = await tmpdir({
775
- init: async (dir) => {
776
- await Bun.write(
777
- path.join(dir, "jonsoc.json"),
778
- JSON.stringify({
779
- $schema: "https://jonsoc.com/config.json",
780
- disabled_providers: ["openai"],
781
- }),
782
- )
783
- },
784
- })
785
- await Instance.provide({
786
- directory: tmp.path,
787
- init: async () => {
788
- Env.set("OPENAI_API_KEY", "test-openai-key")
789
- },
790
- fn: async () => {
791
- const providers = await Provider.list()
792
- expect(providers["openai"]).toBeUndefined()
793
- },
794
- })
795
- })
796
-
797
- test("enabled_providers with empty array allows no providers", async () => {
798
- await using tmp = await tmpdir({
799
- init: async (dir) => {
800
- await Bun.write(
801
- path.join(dir, "jonsoc.json"),
802
- JSON.stringify({
803
- $schema: "https://jonsoc.com/config.json",
804
- enabled_providers: [],
805
- }),
806
- )
807
- },
808
- })
809
- await Instance.provide({
810
- directory: tmp.path,
811
- init: async () => {
812
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
813
- Env.set("OPENAI_API_KEY", "test-openai-key")
814
- },
815
- fn: async () => {
816
- const providers = await Provider.list()
817
- expect(Object.keys(providers).length).toBe(0)
818
- },
819
- })
820
- })
821
-
822
- test("whitelist and blacklist can be combined", async () => {
823
- await using tmp = await tmpdir({
824
- init: async (dir) => {
825
- await Bun.write(
826
- path.join(dir, "jonsoc.json"),
827
- JSON.stringify({
828
- $schema: "https://jonsoc.com/config.json",
829
- provider: {
830
- anthropic: {
831
- whitelist: ["claude-sonnet-4-20250514", "claude-opus-4-20250514"],
832
- blacklist: ["claude-opus-4-20250514"],
833
- },
834
- },
835
- }),
836
- )
837
- },
838
- })
839
- await Instance.provide({
840
- directory: tmp.path,
841
- init: async () => {
842
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
843
- },
844
- fn: async () => {
845
- const providers = await Provider.list()
846
- expect(providers["anthropic"]).toBeDefined()
847
- const models = Object.keys(providers["anthropic"].models)
848
- expect(models).toContain("claude-sonnet-4-20250514")
849
- expect(models).not.toContain("claude-opus-4-20250514")
850
- expect(models.length).toBe(1)
851
- },
852
- })
853
- })
854
-
855
- test("model modalities default correctly", async () => {
856
- await using tmp = await tmpdir({
857
- init: async (dir) => {
858
- await Bun.write(
859
- path.join(dir, "jonsoc.json"),
860
- JSON.stringify({
861
- $schema: "https://jonsoc.com/config.json",
862
- provider: {
863
- "test-provider": {
864
- name: "Test",
865
- npm: "@ai-sdk/openai-compatible",
866
- env: [],
867
- models: {
868
- "test-model": {
869
- name: "Test Model",
870
- tool_call: true,
871
- limit: { context: 8000, output: 2000 },
872
- },
873
- },
874
- options: { apiKey: "test" },
875
- },
876
- },
877
- }),
878
- )
879
- },
880
- })
881
- await Instance.provide({
882
- directory: tmp.path,
883
- fn: async () => {
884
- const providers = await Provider.list()
885
- const model = providers["test-provider"].models["test-model"]
886
- expect(model.capabilities.input.text).toBe(true)
887
- expect(model.capabilities.output.text).toBe(true)
888
- },
889
- })
890
- })
891
-
892
- test("model with custom cost values", async () => {
893
- await using tmp = await tmpdir({
894
- init: async (dir) => {
895
- await Bun.write(
896
- path.join(dir, "jonsoc.json"),
897
- JSON.stringify({
898
- $schema: "https://jonsoc.com/config.json",
899
- provider: {
900
- "test-provider": {
901
- name: "Test",
902
- npm: "@ai-sdk/openai-compatible",
903
- env: [],
904
- models: {
905
- "test-model": {
906
- name: "Test Model",
907
- tool_call: true,
908
- limit: { context: 8000, output: 2000 },
909
- cost: {
910
- input: 5,
911
- output: 15,
912
- cache_read: 2.5,
913
- cache_write: 7.5,
914
- },
915
- },
916
- },
917
- options: { apiKey: "test" },
918
- },
919
- },
920
- }),
921
- )
922
- },
923
- })
924
- await Instance.provide({
925
- directory: tmp.path,
926
- fn: async () => {
927
- const providers = await Provider.list()
928
- const model = providers["test-provider"].models["test-model"]
929
- expect(model.cost.input).toBe(5)
930
- expect(model.cost.output).toBe(15)
931
- expect(model.cost.cache.read).toBe(2.5)
932
- expect(model.cost.cache.write).toBe(7.5)
933
- },
934
- })
935
- })
936
-
937
- test("getSmallModel returns appropriate small model", async () => {
938
- await using tmp = await tmpdir({
939
- init: async (dir) => {
940
- await Bun.write(
941
- path.join(dir, "jonsoc.json"),
942
- JSON.stringify({
943
- $schema: "https://jonsoc.com/config.json",
944
- }),
945
- )
946
- },
947
- })
948
- await Instance.provide({
949
- directory: tmp.path,
950
- init: async () => {
951
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
952
- },
953
- fn: async () => {
954
- const model = await Provider.getSmallModel("anthropic")
955
- expect(model).toBeDefined()
956
- expect(model?.id).toContain("haiku")
957
- },
958
- })
959
- })
960
-
961
- test("getSmallModel respects config small_model override", async () => {
962
- await using tmp = await tmpdir({
963
- init: async (dir) => {
964
- await Bun.write(
965
- path.join(dir, "jonsoc.json"),
966
- JSON.stringify({
967
- $schema: "https://jonsoc.com/config.json",
968
- small_model: "anthropic/claude-sonnet-4-20250514",
969
- }),
970
- )
971
- },
972
- })
973
- await Instance.provide({
974
- directory: tmp.path,
975
- init: async () => {
976
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
977
- },
978
- fn: async () => {
979
- const model = await Provider.getSmallModel("anthropic")
980
- expect(model).toBeDefined()
981
- expect(model?.providerID).toBe("anthropic")
982
- expect(model?.id).toBe("claude-sonnet-4-20250514")
983
- },
984
- })
985
- })
986
-
987
- test("provider.sort prioritizes preferred models", () => {
988
- const models = [
989
- { id: "random-model", name: "Random" },
990
- { id: "claude-sonnet-4-latest", name: "Claude Sonnet 4" },
991
- { id: "gpt-5-turbo", name: "GPT-5 Turbo" },
992
- { id: "other-model", name: "Other" },
993
- ] as any[]
994
-
995
- const sorted = Provider.sort(models)
996
- expect(sorted[0].id).toContain("sonnet-4")
997
- expect(sorted[0].id).toContain("latest")
998
- expect(sorted[sorted.length - 1].id).not.toContain("gpt-5")
999
- expect(sorted[sorted.length - 1].id).not.toContain("sonnet-4")
1000
- })
1001
-
1002
- test("multiple providers can be configured simultaneously", async () => {
1003
- await using tmp = await tmpdir({
1004
- init: async (dir) => {
1005
- await Bun.write(
1006
- path.join(dir, "jonsoc.json"),
1007
- JSON.stringify({
1008
- $schema: "https://jonsoc.com/config.json",
1009
- provider: {
1010
- anthropic: {
1011
- options: { timeout: 30000 },
1012
- },
1013
- openai: {
1014
- options: { timeout: 60000 },
1015
- },
1016
- },
1017
- }),
1018
- )
1019
- },
1020
- })
1021
- await Instance.provide({
1022
- directory: tmp.path,
1023
- init: async () => {
1024
- Env.set("ANTHROPIC_API_KEY", "test-anthropic-key")
1025
- Env.set("OPENAI_API_KEY", "test-openai-key")
1026
- },
1027
- fn: async () => {
1028
- const providers = await Provider.list()
1029
- expect(providers["anthropic"]).toBeDefined()
1030
- expect(providers["openai"]).toBeDefined()
1031
- expect(providers["anthropic"].options.timeout).toBe(30000)
1032
- expect(providers["openai"].options.timeout).toBe(60000)
1033
- },
1034
- })
1035
- })
1036
-
1037
- test("provider with custom npm package", async () => {
1038
- await using tmp = await tmpdir({
1039
- init: async (dir) => {
1040
- await Bun.write(
1041
- path.join(dir, "jonsoc.json"),
1042
- JSON.stringify({
1043
- $schema: "https://jonsoc.com/config.json",
1044
- provider: {
1045
- "local-llm": {
1046
- name: "Local LLM",
1047
- npm: "@ai-sdk/openai-compatible",
1048
- env: [],
1049
- models: {
1050
- "llama-3": {
1051
- name: "Llama 3",
1052
- tool_call: true,
1053
- limit: { context: 8192, output: 2048 },
1054
- },
1055
- },
1056
- options: {
1057
- apiKey: "not-needed",
1058
- baseURL: "http://localhost:11434/v1",
1059
- },
1060
- },
1061
- },
1062
- }),
1063
- )
1064
- },
1065
- })
1066
- await Instance.provide({
1067
- directory: tmp.path,
1068
- fn: async () => {
1069
- const providers = await Provider.list()
1070
- expect(providers["local-llm"]).toBeDefined()
1071
- expect(providers["local-llm"].models["llama-3"].api.npm).toBe("@ai-sdk/openai-compatible")
1072
- expect(providers["local-llm"].options.baseURL).toBe("http://localhost:11434/v1")
1073
- },
1074
- })
1075
- })
1076
-
1077
- // Edge cases for model configuration
1078
-
1079
- test("model alias name defaults to alias key when id differs", async () => {
1080
- await using tmp = await tmpdir({
1081
- init: async (dir) => {
1082
- await Bun.write(
1083
- path.join(dir, "jonsoc.json"),
1084
- JSON.stringify({
1085
- $schema: "https://jonsoc.com/config.json",
1086
- provider: {
1087
- anthropic: {
1088
- models: {
1089
- sonnet: {
1090
- id: "claude-sonnet-4-20250514",
1091
- // no name specified - should default to "sonnet" (the key)
1092
- },
1093
- },
1094
- },
1095
- },
1096
- }),
1097
- )
1098
- },
1099
- })
1100
- await Instance.provide({
1101
- directory: tmp.path,
1102
- init: async () => {
1103
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
1104
- },
1105
- fn: async () => {
1106
- const providers = await Provider.list()
1107
- expect(providers["anthropic"].models["sonnet"].name).toBe("sonnet")
1108
- },
1109
- })
1110
- })
1111
-
1112
- test("provider with multiple env var options only includes apiKey when single env", async () => {
1113
- await using tmp = await tmpdir({
1114
- init: async (dir) => {
1115
- await Bun.write(
1116
- path.join(dir, "jonsoc.json"),
1117
- JSON.stringify({
1118
- $schema: "https://jonsoc.com/config.json",
1119
- provider: {
1120
- "multi-env": {
1121
- name: "Multi Env Provider",
1122
- npm: "@ai-sdk/openai-compatible",
1123
- env: ["MULTI_ENV_KEY_1", "MULTI_ENV_KEY_2"],
1124
- models: {
1125
- "model-1": {
1126
- name: "Model 1",
1127
- tool_call: true,
1128
- limit: { context: 8000, output: 2000 },
1129
- },
1130
- },
1131
- options: {
1132
- baseURL: "https://api.example.com/v1",
1133
- },
1134
- },
1135
- },
1136
- }),
1137
- )
1138
- },
1139
- })
1140
- await Instance.provide({
1141
- directory: tmp.path,
1142
- init: async () => {
1143
- Env.set("MULTI_ENV_KEY_1", "test-key")
1144
- },
1145
- fn: async () => {
1146
- const providers = await Provider.list()
1147
- expect(providers["multi-env"]).toBeDefined()
1148
- // When multiple env options exist, key should NOT be auto-set
1149
- expect(providers["multi-env"].key).toBeUndefined()
1150
- },
1151
- })
1152
- })
1153
-
1154
- test("provider with single env var includes apiKey automatically", async () => {
1155
- await using tmp = await tmpdir({
1156
- init: async (dir) => {
1157
- await Bun.write(
1158
- path.join(dir, "jonsoc.json"),
1159
- JSON.stringify({
1160
- $schema: "https://jonsoc.com/config.json",
1161
- provider: {
1162
- "single-env": {
1163
- name: "Single Env Provider",
1164
- npm: "@ai-sdk/openai-compatible",
1165
- env: ["SINGLE_ENV_KEY"],
1166
- models: {
1167
- "model-1": {
1168
- name: "Model 1",
1169
- tool_call: true,
1170
- limit: { context: 8000, output: 2000 },
1171
- },
1172
- },
1173
- options: {
1174
- baseURL: "https://api.example.com/v1",
1175
- },
1176
- },
1177
- },
1178
- }),
1179
- )
1180
- },
1181
- })
1182
- await Instance.provide({
1183
- directory: tmp.path,
1184
- init: async () => {
1185
- Env.set("SINGLE_ENV_KEY", "my-api-key")
1186
- },
1187
- fn: async () => {
1188
- const providers = await Provider.list()
1189
- expect(providers["single-env"]).toBeDefined()
1190
- // Single env option should auto-set key
1191
- expect(providers["single-env"].key).toBe("my-api-key")
1192
- },
1193
- })
1194
- })
1195
-
1196
- test("model cost overrides existing cost values", async () => {
1197
- await using tmp = await tmpdir({
1198
- init: async (dir) => {
1199
- await Bun.write(
1200
- path.join(dir, "jonsoc.json"),
1201
- JSON.stringify({
1202
- $schema: "https://jonsoc.com/config.json",
1203
- provider: {
1204
- anthropic: {
1205
- models: {
1206
- "claude-sonnet-4-20250514": {
1207
- cost: {
1208
- input: 999,
1209
- output: 888,
1210
- },
1211
- },
1212
- },
1213
- },
1214
- },
1215
- }),
1216
- )
1217
- },
1218
- })
1219
- await Instance.provide({
1220
- directory: tmp.path,
1221
- init: async () => {
1222
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
1223
- },
1224
- fn: async () => {
1225
- const providers = await Provider.list()
1226
- const model = providers["anthropic"].models["claude-sonnet-4-20250514"]
1227
- expect(model.cost.input).toBe(999)
1228
- expect(model.cost.output).toBe(888)
1229
- },
1230
- })
1231
- })
1232
-
1233
- test("completely new provider not in database can be configured", async () => {
1234
- await using tmp = await tmpdir({
1235
- init: async (dir) => {
1236
- await Bun.write(
1237
- path.join(dir, "jonsoc.json"),
1238
- JSON.stringify({
1239
- $schema: "https://jonsoc.com/config.json",
1240
- provider: {
1241
- "brand-new-provider": {
1242
- name: "Brand New",
1243
- npm: "@ai-sdk/openai-compatible",
1244
- env: [],
1245
- api: "https://new-api.com/v1",
1246
- models: {
1247
- "new-model": {
1248
- name: "New Model",
1249
- tool_call: true,
1250
- reasoning: true,
1251
- attachment: true,
1252
- temperature: true,
1253
- limit: { context: 32000, output: 8000 },
1254
- modalities: {
1255
- input: ["text", "image"],
1256
- output: ["text"],
1257
- },
1258
- },
1259
- },
1260
- options: {
1261
- apiKey: "new-key",
1262
- },
1263
- },
1264
- },
1265
- }),
1266
- )
1267
- },
1268
- })
1269
- await Instance.provide({
1270
- directory: tmp.path,
1271
- fn: async () => {
1272
- const providers = await Provider.list()
1273
- expect(providers["brand-new-provider"]).toBeDefined()
1274
- expect(providers["brand-new-provider"].name).toBe("Brand New")
1275
- const model = providers["brand-new-provider"].models["new-model"]
1276
- expect(model.capabilities.reasoning).toBe(true)
1277
- expect(model.capabilities.attachment).toBe(true)
1278
- expect(model.capabilities.input.image).toBe(true)
1279
- },
1280
- })
1281
- })
1282
-
1283
- test("disabled_providers and enabled_providers interaction", async () => {
1284
- await using tmp = await tmpdir({
1285
- init: async (dir) => {
1286
- await Bun.write(
1287
- path.join(dir, "jonsoc.json"),
1288
- JSON.stringify({
1289
- $schema: "https://jonsoc.com/config.json",
1290
- // enabled_providers takes precedence - only these are considered
1291
- enabled_providers: ["anthropic", "openai"],
1292
- // Then disabled_providers filters from the enabled set
1293
- disabled_providers: ["openai"],
1294
- }),
1295
- )
1296
- },
1297
- })
1298
- await Instance.provide({
1299
- directory: tmp.path,
1300
- init: async () => {
1301
- Env.set("ANTHROPIC_API_KEY", "test-anthropic")
1302
- Env.set("OPENAI_API_KEY", "test-openai")
1303
- Env.set("GOOGLE_GENERATIVE_AI_API_KEY", "test-google")
1304
- },
1305
- fn: async () => {
1306
- const providers = await Provider.list()
1307
- // anthropic: in enabled, not in disabled = allowed
1308
- expect(providers["anthropic"]).toBeDefined()
1309
- // openai: in enabled, but also in disabled = NOT allowed
1310
- expect(providers["openai"]).toBeUndefined()
1311
- // google: not in enabled = NOT allowed (even though not disabled)
1312
- expect(providers["google"]).toBeUndefined()
1313
- },
1314
- })
1315
- })
1316
-
1317
- test("model with tool_call false", async () => {
1318
- await using tmp = await tmpdir({
1319
- init: async (dir) => {
1320
- await Bun.write(
1321
- path.join(dir, "jonsoc.json"),
1322
- JSON.stringify({
1323
- $schema: "https://jonsoc.com/config.json",
1324
- provider: {
1325
- "no-tools": {
1326
- name: "No Tools Provider",
1327
- npm: "@ai-sdk/openai-compatible",
1328
- env: [],
1329
- models: {
1330
- "basic-model": {
1331
- name: "Basic Model",
1332
- tool_call: false,
1333
- limit: { context: 4000, output: 1000 },
1334
- },
1335
- },
1336
- options: { apiKey: "test" },
1337
- },
1338
- },
1339
- }),
1340
- )
1341
- },
1342
- })
1343
- await Instance.provide({
1344
- directory: tmp.path,
1345
- fn: async () => {
1346
- const providers = await Provider.list()
1347
- expect(providers["no-tools"].models["basic-model"].capabilities.toolcall).toBe(false)
1348
- },
1349
- })
1350
- })
1351
-
1352
- test("model defaults tool_call to true when not specified", async () => {
1353
- await using tmp = await tmpdir({
1354
- init: async (dir) => {
1355
- await Bun.write(
1356
- path.join(dir, "jonsoc.json"),
1357
- JSON.stringify({
1358
- $schema: "https://jonsoc.com/config.json",
1359
- provider: {
1360
- "default-tools": {
1361
- name: "Default Tools Provider",
1362
- npm: "@ai-sdk/openai-compatible",
1363
- env: [],
1364
- models: {
1365
- model: {
1366
- name: "Model",
1367
- // tool_call not specified
1368
- limit: { context: 4000, output: 1000 },
1369
- },
1370
- },
1371
- options: { apiKey: "test" },
1372
- },
1373
- },
1374
- }),
1375
- )
1376
- },
1377
- })
1378
- await Instance.provide({
1379
- directory: tmp.path,
1380
- fn: async () => {
1381
- const providers = await Provider.list()
1382
- expect(providers["default-tools"].models["model"].capabilities.toolcall).toBe(true)
1383
- },
1384
- })
1385
- })
1386
-
1387
- test("model headers are preserved", async () => {
1388
- await using tmp = await tmpdir({
1389
- init: async (dir) => {
1390
- await Bun.write(
1391
- path.join(dir, "jonsoc.json"),
1392
- JSON.stringify({
1393
- $schema: "https://jonsoc.com/config.json",
1394
- provider: {
1395
- "headers-provider": {
1396
- name: "Headers Provider",
1397
- npm: "@ai-sdk/openai-compatible",
1398
- env: [],
1399
- models: {
1400
- model: {
1401
- name: "Model",
1402
- tool_call: true,
1403
- limit: { context: 4000, output: 1000 },
1404
- headers: {
1405
- "X-Custom-Header": "custom-value",
1406
- Authorization: "Bearer special-token",
1407
- },
1408
- },
1409
- },
1410
- options: { apiKey: "test" },
1411
- },
1412
- },
1413
- }),
1414
- )
1415
- },
1416
- })
1417
- await Instance.provide({
1418
- directory: tmp.path,
1419
- fn: async () => {
1420
- const providers = await Provider.list()
1421
- const model = providers["headers-provider"].models["model"]
1422
- expect(model.headers).toEqual({
1423
- "X-Custom-Header": "custom-value",
1424
- Authorization: "Bearer special-token",
1425
- })
1426
- },
1427
- })
1428
- })
1429
-
1430
- test("provider env fallback - second env var used if first missing", async () => {
1431
- await using tmp = await tmpdir({
1432
- init: async (dir) => {
1433
- await Bun.write(
1434
- path.join(dir, "jonsoc.json"),
1435
- JSON.stringify({
1436
- $schema: "https://jonsoc.com/config.json",
1437
- provider: {
1438
- "fallback-env": {
1439
- name: "Fallback Env Provider",
1440
- npm: "@ai-sdk/openai-compatible",
1441
- env: ["PRIMARY_KEY", "FALLBACK_KEY"],
1442
- models: {
1443
- model: {
1444
- name: "Model",
1445
- tool_call: true,
1446
- limit: { context: 4000, output: 1000 },
1447
- },
1448
- },
1449
- options: { baseURL: "https://api.example.com" },
1450
- },
1451
- },
1452
- }),
1453
- )
1454
- },
1455
- })
1456
- await Instance.provide({
1457
- directory: tmp.path,
1458
- init: async () => {
1459
- // Only set fallback, not primary
1460
- Env.set("FALLBACK_KEY", "fallback-api-key")
1461
- },
1462
- fn: async () => {
1463
- const providers = await Provider.list()
1464
- // Provider should load because fallback env var is set
1465
- expect(providers["fallback-env"]).toBeDefined()
1466
- },
1467
- })
1468
- })
1469
-
1470
- test("getModel returns consistent results", async () => {
1471
- await using tmp = await tmpdir({
1472
- init: async (dir) => {
1473
- await Bun.write(
1474
- path.join(dir, "jonsoc.json"),
1475
- JSON.stringify({
1476
- $schema: "https://jonsoc.com/config.json",
1477
- }),
1478
- )
1479
- },
1480
- })
1481
- await Instance.provide({
1482
- directory: tmp.path,
1483
- init: async () => {
1484
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
1485
- },
1486
- fn: async () => {
1487
- const model1 = await Provider.getModel("anthropic", "claude-sonnet-4-20250514")
1488
- const model2 = await Provider.getModel("anthropic", "claude-sonnet-4-20250514")
1489
- expect(model1.providerID).toEqual(model2.providerID)
1490
- expect(model1.id).toEqual(model2.id)
1491
- expect(model1).toEqual(model2)
1492
- },
1493
- })
1494
- })
1495
-
1496
- test("provider name defaults to id when not in database", async () => {
1497
- await using tmp = await tmpdir({
1498
- init: async (dir) => {
1499
- await Bun.write(
1500
- path.join(dir, "jonsoc.json"),
1501
- JSON.stringify({
1502
- $schema: "https://jonsoc.com/config.json",
1503
- provider: {
1504
- "my-custom-id": {
1505
- // no name specified
1506
- npm: "@ai-sdk/openai-compatible",
1507
- env: [],
1508
- models: {
1509
- model: {
1510
- name: "Model",
1511
- tool_call: true,
1512
- limit: { context: 4000, output: 1000 },
1513
- },
1514
- },
1515
- options: { apiKey: "test" },
1516
- },
1517
- },
1518
- }),
1519
- )
1520
- },
1521
- })
1522
- await Instance.provide({
1523
- directory: tmp.path,
1524
- fn: async () => {
1525
- const providers = await Provider.list()
1526
- expect(providers["my-custom-id"].name).toBe("my-custom-id")
1527
- },
1528
- })
1529
- })
1530
-
1531
- test("ModelNotFoundError includes suggestions for typos", async () => {
1532
- await using tmp = await tmpdir({
1533
- init: async (dir) => {
1534
- await Bun.write(
1535
- path.join(dir, "jonsoc.json"),
1536
- JSON.stringify({
1537
- $schema: "https://jonsoc.com/config.json",
1538
- }),
1539
- )
1540
- },
1541
- })
1542
- await Instance.provide({
1543
- directory: tmp.path,
1544
- init: async () => {
1545
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
1546
- },
1547
- fn: async () => {
1548
- try {
1549
- await Provider.getModel("anthropic", "claude-sonet-4") // typo: sonet instead of sonnet
1550
- expect(true).toBe(false) // Should not reach here
1551
- } catch (e: any) {
1552
- expect(e.data.suggestions).toBeDefined()
1553
- expect(e.data.suggestions.length).toBeGreaterThan(0)
1554
- }
1555
- },
1556
- })
1557
- })
1558
-
1559
- test("ModelNotFoundError for provider includes suggestions", async () => {
1560
- await using tmp = await tmpdir({
1561
- init: async (dir) => {
1562
- await Bun.write(
1563
- path.join(dir, "jonsoc.json"),
1564
- JSON.stringify({
1565
- $schema: "https://jonsoc.com/config.json",
1566
- }),
1567
- )
1568
- },
1569
- })
1570
- await Instance.provide({
1571
- directory: tmp.path,
1572
- init: async () => {
1573
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
1574
- },
1575
- fn: async () => {
1576
- try {
1577
- await Provider.getModel("antropic", "claude-sonnet-4") // typo: antropic
1578
- expect(true).toBe(false) // Should not reach here
1579
- } catch (e: any) {
1580
- expect(e.data.suggestions).toBeDefined()
1581
- expect(e.data.suggestions).toContain("anthropic")
1582
- }
1583
- },
1584
- })
1585
- })
1586
-
1587
- test("getProvider returns undefined for nonexistent provider", async () => {
1588
- await using tmp = await tmpdir({
1589
- init: async (dir) => {
1590
- await Bun.write(
1591
- path.join(dir, "jonsoc.json"),
1592
- JSON.stringify({
1593
- $schema: "https://jonsoc.com/config.json",
1594
- }),
1595
- )
1596
- },
1597
- })
1598
- await Instance.provide({
1599
- directory: tmp.path,
1600
- fn: async () => {
1601
- const provider = await Provider.getProvider("nonexistent")
1602
- expect(provider).toBeUndefined()
1603
- },
1604
- })
1605
- })
1606
-
1607
- test("getProvider returns provider info", async () => {
1608
- await using tmp = await tmpdir({
1609
- init: async (dir) => {
1610
- await Bun.write(
1611
- path.join(dir, "jonsoc.json"),
1612
- JSON.stringify({
1613
- $schema: "https://jonsoc.com/config.json",
1614
- }),
1615
- )
1616
- },
1617
- })
1618
- await Instance.provide({
1619
- directory: tmp.path,
1620
- init: async () => {
1621
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
1622
- },
1623
- fn: async () => {
1624
- const provider = await Provider.getProvider("anthropic")
1625
- expect(provider).toBeDefined()
1626
- expect(provider?.id).toBe("anthropic")
1627
- },
1628
- })
1629
- })
1630
-
1631
- test("closest returns undefined when no partial match found", async () => {
1632
- await using tmp = await tmpdir({
1633
- init: async (dir) => {
1634
- await Bun.write(
1635
- path.join(dir, "jonsoc.json"),
1636
- JSON.stringify({
1637
- $schema: "https://jonsoc.com/config.json",
1638
- }),
1639
- )
1640
- },
1641
- })
1642
- await Instance.provide({
1643
- directory: tmp.path,
1644
- init: async () => {
1645
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
1646
- },
1647
- fn: async () => {
1648
- const result = await Provider.closest("anthropic", ["nonexistent-xyz-model"])
1649
- expect(result).toBeUndefined()
1650
- },
1651
- })
1652
- })
1653
-
1654
- test("closest checks multiple query terms in order", async () => {
1655
- await using tmp = await tmpdir({
1656
- init: async (dir) => {
1657
- await Bun.write(
1658
- path.join(dir, "jonsoc.json"),
1659
- JSON.stringify({
1660
- $schema: "https://jonsoc.com/config.json",
1661
- }),
1662
- )
1663
- },
1664
- })
1665
- await Instance.provide({
1666
- directory: tmp.path,
1667
- init: async () => {
1668
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
1669
- },
1670
- fn: async () => {
1671
- // First term won't match, second will
1672
- const result = await Provider.closest("anthropic", ["nonexistent", "haiku"])
1673
- expect(result).toBeDefined()
1674
- expect(result?.modelID).toContain("haiku")
1675
- },
1676
- })
1677
- })
1678
-
1679
- test("model limit defaults to zero when not specified", async () => {
1680
- await using tmp = await tmpdir({
1681
- init: async (dir) => {
1682
- await Bun.write(
1683
- path.join(dir, "jonsoc.json"),
1684
- JSON.stringify({
1685
- $schema: "https://jonsoc.com/config.json",
1686
- provider: {
1687
- "no-limit": {
1688
- name: "No Limit Provider",
1689
- npm: "@ai-sdk/openai-compatible",
1690
- env: [],
1691
- models: {
1692
- model: {
1693
- name: "Model",
1694
- tool_call: true,
1695
- // no limit specified
1696
- },
1697
- },
1698
- options: { apiKey: "test" },
1699
- },
1700
- },
1701
- }),
1702
- )
1703
- },
1704
- })
1705
- await Instance.provide({
1706
- directory: tmp.path,
1707
- fn: async () => {
1708
- const providers = await Provider.list()
1709
- const model = providers["no-limit"].models["model"]
1710
- expect(model.limit.context).toBe(0)
1711
- expect(model.limit.output).toBe(0)
1712
- },
1713
- })
1714
- })
1715
-
1716
- test("provider options are deeply merged", async () => {
1717
- await using tmp = await tmpdir({
1718
- init: async (dir) => {
1719
- await Bun.write(
1720
- path.join(dir, "jonsoc.json"),
1721
- JSON.stringify({
1722
- $schema: "https://jonsoc.com/config.json",
1723
- provider: {
1724
- anthropic: {
1725
- options: {
1726
- headers: {
1727
- "X-Custom": "custom-value",
1728
- },
1729
- timeout: 30000,
1730
- },
1731
- },
1732
- },
1733
- }),
1734
- )
1735
- },
1736
- })
1737
- await Instance.provide({
1738
- directory: tmp.path,
1739
- init: async () => {
1740
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
1741
- },
1742
- fn: async () => {
1743
- const providers = await Provider.list()
1744
- // Custom options should be merged
1745
- expect(providers["anthropic"].options.timeout).toBe(30000)
1746
- expect(providers["anthropic"].options.headers["X-Custom"]).toBe("custom-value")
1747
- // anthropic custom loader adds its own headers, they should coexist
1748
- expect(providers["anthropic"].options.headers["anthropic-beta"]).toBeDefined()
1749
- },
1750
- })
1751
- })
1752
-
1753
- test("custom model inherits npm package from models.dev provider config", async () => {
1754
- await using tmp = await tmpdir({
1755
- init: async (dir) => {
1756
- await Bun.write(
1757
- path.join(dir, "jonsoc.json"),
1758
- JSON.stringify({
1759
- $schema: "https://jonsoc.com/config.json",
1760
- provider: {
1761
- openai: {
1762
- models: {
1763
- "my-custom-model": {
1764
- name: "My Custom Model",
1765
- tool_call: true,
1766
- limit: { context: 8000, output: 2000 },
1767
- },
1768
- },
1769
- },
1770
- },
1771
- }),
1772
- )
1773
- },
1774
- })
1775
- await Instance.provide({
1776
- directory: tmp.path,
1777
- init: async () => {
1778
- Env.set("OPENAI_API_KEY", "test-api-key")
1779
- },
1780
- fn: async () => {
1781
- const providers = await Provider.list()
1782
- const model = providers["openai"].models["my-custom-model"]
1783
- expect(model).toBeDefined()
1784
- expect(model.api.npm).toBe("@ai-sdk/openai")
1785
- },
1786
- })
1787
- })
1788
-
1789
- test("custom model inherits api.url from models.dev provider", async () => {
1790
- await using tmp = await tmpdir({
1791
- init: async (dir) => {
1792
- await Bun.write(
1793
- path.join(dir, "jonsoc.json"),
1794
- JSON.stringify({
1795
- $schema: "https://jonsoc.com/config.json",
1796
- provider: {
1797
- openrouter: {
1798
- models: {
1799
- "prime-intellect/intellect-3": {},
1800
- "deepseek/deepseek-r1-0528": {
1801
- name: "DeepSeek R1",
1802
- },
1803
- },
1804
- },
1805
- },
1806
- }),
1807
- )
1808
- },
1809
- })
1810
- await Instance.provide({
1811
- directory: tmp.path,
1812
- init: async () => {
1813
- Env.set("OPENROUTER_API_KEY", "test-api-key")
1814
- },
1815
- fn: async () => {
1816
- const providers = await Provider.list()
1817
- expect(providers["openrouter"]).toBeDefined()
1818
-
1819
- // New model not in database should inherit api.url from provider
1820
- const intellect = providers["openrouter"].models["prime-intellect/intellect-3"]
1821
- expect(intellect).toBeDefined()
1822
- expect(intellect.api.url).toBe("https://openrouter.ai/api/v1")
1823
-
1824
- // Another new model should also inherit api.url
1825
- const deepseek = providers["openrouter"].models["deepseek/deepseek-r1-0528"]
1826
- expect(deepseek).toBeDefined()
1827
- expect(deepseek.api.url).toBe("https://openrouter.ai/api/v1")
1828
- expect(deepseek.name).toBe("DeepSeek R1")
1829
- },
1830
- })
1831
- })
1832
-
1833
- test("model variants are generated for reasoning models", async () => {
1834
- await using tmp = await tmpdir({
1835
- init: async (dir) => {
1836
- await Bun.write(
1837
- path.join(dir, "jonsoc.json"),
1838
- JSON.stringify({
1839
- $schema: "https://jonsoc.com/config.json",
1840
- }),
1841
- )
1842
- },
1843
- })
1844
- await Instance.provide({
1845
- directory: tmp.path,
1846
- init: async () => {
1847
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
1848
- },
1849
- fn: async () => {
1850
- const providers = await Provider.list()
1851
- // Claude sonnet 4 has reasoning capability
1852
- const model = providers["anthropic"].models["claude-sonnet-4-20250514"]
1853
- expect(model.capabilities.reasoning).toBe(true)
1854
- expect(model.variants).toBeDefined()
1855
- expect(Object.keys(model.variants!).length).toBeGreaterThan(0)
1856
- },
1857
- })
1858
- })
1859
-
1860
- test("model variants can be disabled via config", async () => {
1861
- await using tmp = await tmpdir({
1862
- init: async (dir) => {
1863
- await Bun.write(
1864
- path.join(dir, "jonsoc.json"),
1865
- JSON.stringify({
1866
- $schema: "https://jonsoc.com/config.json",
1867
- provider: {
1868
- anthropic: {
1869
- models: {
1870
- "claude-sonnet-4-20250514": {
1871
- variants: {
1872
- high: { disabled: true },
1873
- },
1874
- },
1875
- },
1876
- },
1877
- },
1878
- }),
1879
- )
1880
- },
1881
- })
1882
- await Instance.provide({
1883
- directory: tmp.path,
1884
- init: async () => {
1885
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
1886
- },
1887
- fn: async () => {
1888
- const providers = await Provider.list()
1889
- const model = providers["anthropic"].models["claude-sonnet-4-20250514"]
1890
- expect(model.variants).toBeDefined()
1891
- expect(model.variants!["high"]).toBeUndefined()
1892
- // max variant should still exist
1893
- expect(model.variants!["max"]).toBeDefined()
1894
- },
1895
- })
1896
- })
1897
-
1898
- test("model variants can be customized via config", async () => {
1899
- await using tmp = await tmpdir({
1900
- init: async (dir) => {
1901
- await Bun.write(
1902
- path.join(dir, "jonsoc.json"),
1903
- JSON.stringify({
1904
- $schema: "https://jonsoc.com/config.json",
1905
- provider: {
1906
- anthropic: {
1907
- models: {
1908
- "claude-sonnet-4-20250514": {
1909
- variants: {
1910
- high: {
1911
- thinking: {
1912
- type: "enabled",
1913
- budgetTokens: 20000,
1914
- },
1915
- },
1916
- },
1917
- },
1918
- },
1919
- },
1920
- },
1921
- }),
1922
- )
1923
- },
1924
- })
1925
- await Instance.provide({
1926
- directory: tmp.path,
1927
- init: async () => {
1928
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
1929
- },
1930
- fn: async () => {
1931
- const providers = await Provider.list()
1932
- const model = providers["anthropic"].models["claude-sonnet-4-20250514"]
1933
- expect(model.variants!["high"]).toBeDefined()
1934
- expect(model.variants!["high"].thinking.budgetTokens).toBe(20000)
1935
- },
1936
- })
1937
- })
1938
-
1939
- test("disabled key is stripped from variant config", async () => {
1940
- await using tmp = await tmpdir({
1941
- init: async (dir) => {
1942
- await Bun.write(
1943
- path.join(dir, "jonsoc.json"),
1944
- JSON.stringify({
1945
- $schema: "https://jonsoc.com/config.json",
1946
- provider: {
1947
- anthropic: {
1948
- models: {
1949
- "claude-sonnet-4-20250514": {
1950
- variants: {
1951
- max: {
1952
- disabled: false,
1953
- customField: "test",
1954
- },
1955
- },
1956
- },
1957
- },
1958
- },
1959
- },
1960
- }),
1961
- )
1962
- },
1963
- })
1964
- await Instance.provide({
1965
- directory: tmp.path,
1966
- init: async () => {
1967
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
1968
- },
1969
- fn: async () => {
1970
- const providers = await Provider.list()
1971
- const model = providers["anthropic"].models["claude-sonnet-4-20250514"]
1972
- expect(model.variants!["max"]).toBeDefined()
1973
- expect(model.variants!["max"].disabled).toBeUndefined()
1974
- expect(model.variants!["max"].customField).toBe("test")
1975
- },
1976
- })
1977
- })
1978
-
1979
- test("all variants can be disabled via config", async () => {
1980
- await using tmp = await tmpdir({
1981
- init: async (dir) => {
1982
- await Bun.write(
1983
- path.join(dir, "jonsoc.json"),
1984
- JSON.stringify({
1985
- $schema: "https://jonsoc.com/config.json",
1986
- provider: {
1987
- anthropic: {
1988
- models: {
1989
- "claude-sonnet-4-20250514": {
1990
- variants: {
1991
- high: { disabled: true },
1992
- max: { disabled: true },
1993
- },
1994
- },
1995
- },
1996
- },
1997
- },
1998
- }),
1999
- )
2000
- },
2001
- })
2002
- await Instance.provide({
2003
- directory: tmp.path,
2004
- init: async () => {
2005
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
2006
- },
2007
- fn: async () => {
2008
- const providers = await Provider.list()
2009
- const model = providers["anthropic"].models["claude-sonnet-4-20250514"]
2010
- expect(model.variants).toBeDefined()
2011
- expect(Object.keys(model.variants!).length).toBe(0)
2012
- },
2013
- })
2014
- })
2015
-
2016
- test("variant config merges with generated variants", async () => {
2017
- await using tmp = await tmpdir({
2018
- init: async (dir) => {
2019
- await Bun.write(
2020
- path.join(dir, "jonsoc.json"),
2021
- JSON.stringify({
2022
- $schema: "https://jonsoc.com/config.json",
2023
- provider: {
2024
- anthropic: {
2025
- models: {
2026
- "claude-sonnet-4-20250514": {
2027
- variants: {
2028
- high: {
2029
- extraOption: "custom-value",
2030
- },
2031
- },
2032
- },
2033
- },
2034
- },
2035
- },
2036
- }),
2037
- )
2038
- },
2039
- })
2040
- await Instance.provide({
2041
- directory: tmp.path,
2042
- init: async () => {
2043
- Env.set("ANTHROPIC_API_KEY", "test-api-key")
2044
- },
2045
- fn: async () => {
2046
- const providers = await Provider.list()
2047
- const model = providers["anthropic"].models["claude-sonnet-4-20250514"]
2048
- expect(model.variants!["high"]).toBeDefined()
2049
- // Should have both the generated thinking config and the custom option
2050
- expect(model.variants!["high"].thinking).toBeDefined()
2051
- expect(model.variants!["high"].extraOption).toBe("custom-value")
2052
- },
2053
- })
2054
- })
2055
-
2056
- test("variants filtered in second pass for database models", async () => {
2057
- await using tmp = await tmpdir({
2058
- init: async (dir) => {
2059
- await Bun.write(
2060
- path.join(dir, "jonsoc.json"),
2061
- JSON.stringify({
2062
- $schema: "https://jonsoc.com/config.json",
2063
- provider: {
2064
- openai: {
2065
- models: {
2066
- "gpt-5": {
2067
- variants: {
2068
- high: { disabled: true },
2069
- },
2070
- },
2071
- },
2072
- },
2073
- },
2074
- }),
2075
- )
2076
- },
2077
- })
2078
- await Instance.provide({
2079
- directory: tmp.path,
2080
- init: async () => {
2081
- Env.set("OPENAI_API_KEY", "test-api-key")
2082
- },
2083
- fn: async () => {
2084
- const providers = await Provider.list()
2085
- const model = providers["openai"].models["gpt-5"]
2086
- expect(model.variants).toBeDefined()
2087
- expect(model.variants!["high"]).toBeUndefined()
2088
- // Other variants should still exist
2089
- expect(model.variants!["medium"]).toBeDefined()
2090
- },
2091
- })
2092
- })
2093
-
2094
- test("custom model with variants enabled and disabled", async () => {
2095
- await using tmp = await tmpdir({
2096
- init: async (dir) => {
2097
- await Bun.write(
2098
- path.join(dir, "jonsoc.json"),
2099
- JSON.stringify({
2100
- $schema: "https://jonsoc.com/config.json",
2101
- provider: {
2102
- "custom-reasoning": {
2103
- name: "Custom Reasoning Provider",
2104
- npm: "@ai-sdk/openai-compatible",
2105
- env: [],
2106
- models: {
2107
- "reasoning-model": {
2108
- name: "Reasoning Model",
2109
- tool_call: true,
2110
- reasoning: true,
2111
- limit: { context: 128000, output: 16000 },
2112
- variants: {
2113
- low: { reasoningEffort: "low" },
2114
- medium: { reasoningEffort: "medium" },
2115
- high: { reasoningEffort: "high", disabled: true },
2116
- custom: { reasoningEffort: "custom", budgetTokens: 5000 },
2117
- },
2118
- },
2119
- },
2120
- options: { apiKey: "test-key" },
2121
- },
2122
- },
2123
- }),
2124
- )
2125
- },
2126
- })
2127
- await Instance.provide({
2128
- directory: tmp.path,
2129
- fn: async () => {
2130
- const providers = await Provider.list()
2131
- const model = providers["custom-reasoning"].models["reasoning-model"]
2132
- expect(model.variants).toBeDefined()
2133
- // Enabled variants should exist
2134
- expect(model.variants!["low"]).toBeDefined()
2135
- expect(model.variants!["low"].reasoningEffort).toBe("low")
2136
- expect(model.variants!["medium"]).toBeDefined()
2137
- expect(model.variants!["medium"].reasoningEffort).toBe("medium")
2138
- expect(model.variants!["custom"]).toBeDefined()
2139
- expect(model.variants!["custom"].reasoningEffort).toBe("custom")
2140
- expect(model.variants!["custom"].budgetTokens).toBe(5000)
2141
- // Disabled variant should not exist
2142
- expect(model.variants!["high"]).toBeUndefined()
2143
- // disabled key should be stripped from all variants
2144
- expect(model.variants!["low"].disabled).toBeUndefined()
2145
- expect(model.variants!["medium"].disabled).toBeUndefined()
2146
- expect(model.variants!["custom"].disabled).toBeUndefined()
2147
- },
2148
- })
2149
- })