@openchambery/web 1.19.22-beta.1 → 2.0.0-beta.10

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 (328) hide show
  1. package/README.md +13 -7
  2. package/bin/cli-opencode.test.js +208 -0
  3. package/bin/cli.js +62 -9
  4. package/bin/lib/cli-startup.js +105 -2
  5. package/bin/lib/cli-startup.test.js +179 -0
  6. package/dist/assets/{AgentAvatar-CRaBJXKs.js → AgentAvatar-CzTtVMnI.js} +1 -1
  7. package/dist/assets/AssistantView-Cg1qQvVe.js +3 -0
  8. package/dist/assets/{DiagramView-D1LGK_s2.js → DiagramView-hOi72Wdx.js} +1 -1
  9. package/dist/assets/{FadeInOnReveal-B0kJo9Ii.js → FadeInOnReveal-DCqrQkkz.js} +1 -1
  10. package/dist/assets/Icon-B8fSTLdP.js +1 -0
  11. package/dist/assets/MarkdownRenderer-Cw74oVxV.js +2 -0
  12. package/dist/assets/{MarkdownRendererImpl-DfoCJ1Mq.js → MarkdownRendererImpl-YM7iRmzK.js} +3 -3
  13. package/dist/assets/MarkstreamRendererImpl-BDy_oGJQ.js +3 -0
  14. package/dist/assets/MobileDetailNavigation-iX_hb_Xt.js +1 -0
  15. package/dist/assets/{MobileShareBridge-2Yjn6wXg.js → MobileShareBridge-CAMUupwR.js} +2 -2
  16. package/dist/assets/MobileSurface-CHbdPcLH.js +2 -0
  17. package/dist/assets/{MultiRunWindow-tTbMFowS.js → MultiRunWindow-Ci1ODFFX.js} +1 -1
  18. package/dist/assets/{OnboardingScreen-CD2KtlF3.js → OnboardingScreen-O4cGdz5p.js} +1 -1
  19. package/dist/assets/OverlayScrollbar-CRfGtcmG.js +2 -0
  20. package/dist/assets/SettingsView-Dg8BtTV1.js +25 -0
  21. package/dist/assets/{SettingsWindow-zIa76s4t.js → SettingsWindow-B8d8qIQ7.js} +1 -1
  22. package/dist/assets/TerminalView-CMiw3s_c.js +8 -0
  23. package/dist/assets/{ToolOutputDialog-DNqA4uBl.js → ToolOutputDialog-ByaQYRTp.js} +2 -2
  24. package/dist/assets/appThemeRegistry-BGGHio8T.js +1 -0
  25. package/dist/assets/{assistant-attachment-cache-C0aRnFkj.js → assistant-attachment-cache-DphJleHr.js} +1 -1
  26. package/dist/assets/{button-CI7Q-Zw_.js → button-DIIrsMjW.js} +1 -1
  27. package/dist/assets/{collapsible-D5Phaykh.js → collapsible-CnvUeYst.js} +1 -1
  28. package/dist/assets/{context-menu-CubSDW2g.js → context-menu-BGBUpZEQ.js} +1 -1
  29. package/dist/assets/{desktopHosts-B1ixEylr.js → desktopHosts-JGFqhlaM.js} +1 -1
  30. package/dist/assets/{desktopRelayRestore-4JmFUw8r.js → desktopRelayRestore-CHEwrI93.js} +1 -1
  31. package/dist/assets/{diagram-DdLO8HZ9.js → diagram-rvn7_qBM.js} +1 -1
  32. package/dist/assets/{dialog-B6pnIYmp.js → dialog-CQ63sc9E.js} +1 -1
  33. package/dist/assets/es-Dsmc0A_3.js +15 -0
  34. package/dist/assets/fileMentionTouchSelection-BzzcWJCi.js +3 -0
  35. package/dist/assets/{fileQueries-DQc8EJUf.js → fileQueries-DN6gbLhM.js} +1 -1
  36. package/dist/assets/fr-C_ZlZDI2.js +13 -0
  37. package/dist/assets/gitApi-BF8vuoZc.js +10 -0
  38. package/dist/assets/{imageSource-BlAJJUEI.js → imageSource-BMztRu0c.js} +1 -1
  39. package/dist/assets/{input-D-__fwRi.js → input-BVu-iykl.js} +1 -1
  40. package/dist/assets/insertionBoundaries-EcAfGT2D.js +1 -0
  41. package/dist/assets/ja-BqqTaWTi.js +15 -0
  42. package/dist/assets/ko-DP2XPM37.js +15 -0
  43. package/dist/assets/main-B7t9lavz.js +2 -0
  44. package/dist/assets/main-D2BzpnUt.css +1 -0
  45. package/dist/assets/main-DWP-prNB.js +169 -0
  46. package/dist/assets/markdown-worker-bS5OgGO3.js +2 -0
  47. package/dist/assets/{markdownHeightCache-BhxqJOvf.js → markdownHeightCache-D9-B1wdY.js} +1 -1
  48. package/dist/assets/markdownTheme-DM5h1i18.js +1 -0
  49. package/dist/assets/mcpQueries-CfXrAkuU.js +1 -0
  50. package/dist/assets/miniChat-DgOrEQbN.js +2 -0
  51. package/dist/assets/mobile-Co_ZOHkZ.js +2 -0
  52. package/dist/assets/multirun-DelyUO6k.js +4 -0
  53. package/dist/assets/persistence-D0y7226-.js +3 -0
  54. package/dist/assets/pl-BCf5uLlK.js +15 -0
  55. package/dist/assets/platform-CurqO28D.js +6 -0
  56. package/dist/assets/{projectMeta-S1hJ7oBp.js → projectMeta-CPElzJ0n.js} +2 -2
  57. package/dist/assets/pt-BR-W09Q2pvn.js +15 -0
  58. package/dist/assets/{relay-image-stream-DM7atqJs.js → relay-image-stream-DrdVj99c.js} +1 -1
  59. package/dist/assets/renderElectronMiniChatApp-pOE93w86.js +2 -0
  60. package/dist/assets/renderMobileApp-F7ZSLcw8.js +28 -0
  61. package/dist/assets/runtime-fetch-Fs9ZV2V8.js +1 -0
  62. package/dist/assets/{runtimeConfig-CMkwoQ_X.js → runtimeConfig-DSS0KxG3.js} +1 -1
  63. package/dist/assets/runtimeEndpointReset-x2Wgx57R.js +149 -0
  64. package/dist/assets/sessionChangeSummary-BUGSYcHp.js +2 -0
  65. package/dist/assets/{sessionLookup-BrU3rFHJ.js → sessionLookup-Bss8M20i.js} +1 -1
  66. package/dist/assets/{sortable-tabs-strip-Fnfhf3K9.js → sortable-tabs-strip-CE7W7lJ9.js} +1 -1
  67. package/dist/assets/src-lS1keDVV.css +2 -0
  68. package/dist/assets/store-jaP79mqI.js +15 -0
  69. package/dist/assets/{terminalApi-xjqssKke.js → terminalApi-mDR2jXTo.js} +1 -1
  70. package/dist/assets/textarea-XD2oX_Ee.js +1 -0
  71. package/dist/assets/{tooltip-0T5jv0cu.js → tooltip-DYeQ_Hvy.js} +1 -1
  72. package/dist/assets/uk-BgFzz8m2.js +15 -0
  73. package/dist/assets/{url-_z7evzdK.js → url-CGbJbiJq.js} +1 -1
  74. package/dist/assets/{useAppFontEffects-C02YFyAv.js → useAppFontEffects-BAWHZ-t0.js} +64 -45
  75. package/dist/assets/{useAssistantUIStore-CMutVh9B.js → useAssistantUIStore-Bz4tRflF.js} +1 -1
  76. package/dist/assets/useDesktopWindowControlsLayout-hN_nLb7T.js +1 -0
  77. package/dist/assets/useEffectiveDirectory-Do9DQ453.js +1 -0
  78. package/dist/assets/{useFontPreferences-B1JYyzpK.js → useFontPreferences-Bjx8zkGM.js} +1 -1
  79. package/dist/assets/useMobileNavigationStore-BsY_gi_K.js +414 -0
  80. package/dist/assets/useSessionAutoCleanup-C4g5KmDf.js +2 -0
  81. package/dist/assets/useUIStore-syVmbuDA.js +1 -0
  82. package/dist/assets/{useWorkerHighlightedLines-C9z0ML1z.js → useWorkerHighlightedLines-B5QXxBok.js} +2 -2
  83. package/dist/assets/vendor-opencode-client-C12gfjag.js +12 -0
  84. package/dist/assets/{vendor-reactuses-core-BnW6GxJt.js → vendor-reactuses-core-Dq5ocTF8.js} +1 -1
  85. package/dist/assets/{vendor-yaml-DIcAK3EC.js → vendor-yaml-C9KlJAlj.js} +37 -37
  86. package/dist/assets/zh-CN-BhqSLgUY.js +15 -0
  87. package/dist/assets/zh-TW-BsaBgY-p.js +15 -0
  88. package/dist/index.html +12 -12
  89. package/dist/mini-chat.html +12 -12
  90. package/dist/mobile.html +12 -12
  91. package/package.json +3 -2
  92. package/server/index.js +423 -20
  93. package/server/lib/assistants/DOCUMENTATION.md +26 -21
  94. package/server/lib/assistants/assign.js +2 -1
  95. package/server/lib/assistants/contact-store.js +37 -19
  96. package/server/lib/assistants/contracts.js +11 -1
  97. package/server/lib/assistants/projection-history.test.js +454 -0
  98. package/server/lib/assistants/routes.js +11 -5
  99. package/server/lib/assistants/service.js +850 -294
  100. package/server/lib/assistants/service.test.js +588 -274
  101. package/server/lib/browser-provider/DOCUMENTATION.md +141 -0
  102. package/server/lib/browser-provider/contract.js +312 -0
  103. package/server/lib/browser-provider/host.js +421 -0
  104. package/server/lib/browser-provider/host.test.js +304 -0
  105. package/server/lib/browser-provider/routes.js +122 -0
  106. package/server/lib/browser-provider/routes.test.js +120 -0
  107. package/server/lib/browser-provider/selection-store.js +43 -0
  108. package/server/lib/browser-provider/selection-store.test.js +35 -0
  109. package/server/lib/conversations/DOCUMENTATION.md +5 -5
  110. package/server/lib/conversations/service.js +87 -57
  111. package/server/lib/conversations/service.test.js +132 -100
  112. package/server/lib/conversations/validation.js +11 -1
  113. package/server/lib/event-stream/DOCUMENTATION.md +3 -1
  114. package/server/lib/event-stream/directory-ws-bridge.js +13 -2
  115. package/server/lib/event-stream/global-hub.js +51 -5
  116. package/server/lib/event-stream/reasoning-projection.js +16 -1
  117. package/server/lib/event-stream/reasoning-projection.test.js +15 -0
  118. package/server/lib/event-stream/runtime.js +57 -20
  119. package/server/lib/event-stream/runtime.test.js +112 -0
  120. package/server/lib/llm/DOCUMENTATION.md +95 -84
  121. package/server/lib/llm/catalog.js +111 -45
  122. package/server/lib/llm/catalog.test.js +121 -59
  123. package/server/lib/llm/completions.js +41 -12
  124. package/server/lib/llm/completions.test.js +45 -4
  125. package/server/lib/llm/generate.js +516 -453
  126. package/server/lib/llm/generate.test.js +705 -484
  127. package/server/lib/llm/routes.js +8 -4
  128. package/server/lib/message-queue/DOCUMENTATION.md +5 -5
  129. package/server/lib/message-queue/opencode-adapter.js +191 -104
  130. package/server/lib/message-queue/opencode-adapter.test.js +328 -58
  131. package/server/lib/message-queue/runtime.js +15 -2
  132. package/server/lib/message-queue/runtime.test.js +6 -6
  133. package/server/lib/message-queue/worker.js +7 -1
  134. package/server/lib/notifications/DOCUMENTATION.md +3 -1
  135. package/server/lib/notifications/runtime.js +133 -31
  136. package/server/lib/notifications/runtime.test.js +103 -0
  137. package/server/lib/notifications/template-runtime.js +130 -38
  138. package/server/lib/notifications/template-runtime.test.js +96 -0
  139. package/server/lib/opencode/DOCUMENTATION.md +111 -16
  140. package/server/lib/opencode/agent-document.d.ts +28 -0
  141. package/server/lib/opencode/agent-document.js +280 -0
  142. package/server/lib/opencode/agent-document.test.js +137 -0
  143. package/server/lib/opencode/agents.js +96 -0
  144. package/server/lib/opencode/auth-state-runtime.js +5 -0
  145. package/server/lib/opencode/bootstrap-runtime.js +2 -0
  146. package/server/lib/opencode/config-entity-routes.js +117 -103
  147. package/server/lib/opencode/config-entity-routes.test.js +148 -10
  148. package/server/lib/opencode/config-hot-reload.integration.test.js +105 -0
  149. package/server/lib/opencode/ensure-cli.d.ts +8 -0
  150. package/server/lib/opencode/ensure-cli.js +238 -0
  151. package/server/lib/opencode/ensure-cli.test.js +119 -0
  152. package/server/lib/opencode/env-runtime.js +208 -111
  153. package/server/lib/opencode/env-runtime.test.js +211 -14
  154. package/server/lib/opencode/feature-routes-runtime.js +90 -5
  155. package/server/lib/opencode/feature-routes-runtime.test.js +25 -0
  156. package/server/lib/opencode/http-server-connections.js +98 -0
  157. package/server/lib/opencode/http-server-connections.test.js +321 -0
  158. package/server/lib/opencode/lifecycle.js +539 -95
  159. package/server/lib/opencode/lifecycle.test.js +698 -6
  160. package/server/lib/opencode/managed-capabilities-runtime.js +15 -2
  161. package/server/lib/opencode/managed-capabilities-runtime.test.js +1 -0
  162. package/server/lib/opencode/network-runtime.js +28 -16
  163. package/server/lib/opencode/network-runtime.test.js +68 -4
  164. package/server/lib/opencode/openchamber-routes.js +7 -1
  165. package/server/lib/opencode/opencode2-pin.js +139 -0
  166. package/server/lib/opencode/opencode2-pin.test.js +88 -0
  167. package/server/lib/opencode/opencode2-sidecar.e2e.test.js +326 -0
  168. package/server/lib/opencode/owned-runtime-upgrade.js +431 -0
  169. package/server/lib/opencode/owned-runtime-upgrade.test.js +160 -0
  170. package/server/lib/opencode/plugin-compatibility.js +15 -0
  171. package/server/lib/opencode/plugin-compatibility.test.js +21 -0
  172. package/server/lib/opencode/plugin-routes.js +3 -18
  173. package/server/lib/opencode/plugin-routes.test.js +9 -9
  174. package/server/lib/opencode/plugins.js +4 -3
  175. package/server/lib/opencode/plugins.test.js +12 -0
  176. package/server/lib/opencode/provider-catalog.js +58 -12
  177. package/server/lib/opencode/provider-catalog.test.js +48 -0
  178. package/server/lib/opencode/proxy.js +373 -28
  179. package/server/lib/opencode/proxy.test.js +353 -0
  180. package/server/lib/opencode/routes.js +333 -76
  181. package/server/lib/opencode/routes.test.js +315 -50
  182. package/server/lib/opencode/runtime-contract.js +401 -0
  183. package/server/lib/opencode/runtime-contract.test.js +214 -0
  184. package/server/lib/opencode/server-opencode-fetch.js +242 -0
  185. package/server/lib/opencode/server-opencode-fetch.test.js +130 -0
  186. package/server/lib/opencode/server-utils-runtime.js +35 -0
  187. package/server/lib/opencode/shared-service.integration.test.js +66 -0
  188. package/server/lib/opencode/shared-service.js +147 -0
  189. package/server/lib/opencode/shared-service.test.js +93 -0
  190. package/server/lib/opencode/shared.js +3 -3
  191. package/server/lib/opencode/shutdown-runtime.js +15 -6
  192. package/server/lib/opencode/shutdown-runtime.test.js +49 -1
  193. package/server/lib/opencode/skill-routes.js +26 -40
  194. package/server/lib/opencode/skill-routes.test.js +71 -7
  195. package/server/lib/opencode/skills.test.js +15 -0
  196. package/server/lib/opencode/startup-pipeline-runtime.js +4 -0
  197. package/server/lib/opencode/static-routes-runtime.js +3 -1
  198. package/server/lib/opencode/static-routes-runtime.test.js +33 -0
  199. package/server/lib/opencode/upgrade-screen.d.ts +30 -0
  200. package/server/lib/opencode/upgrade-screen.js +299 -0
  201. package/server/lib/opencode/upgrade-screen.test.js +196 -0
  202. package/server/lib/opencode/v1-migration-gate.js +157 -0
  203. package/server/lib/opencode/v1-migration-gate.test.js +111 -0
  204. package/server/lib/opencode/v2-client.js +60 -0
  205. package/server/lib/opencode/v2-plugin-host-shim/index.mjs +155 -0
  206. package/server/lib/opencode/v2-plugin-host-shim/package.json +4 -0
  207. package/server/lib/opencode/watcher.js +2 -1
  208. package/server/lib/opencode/watcher.test.js +1 -1
  209. package/server/lib/permission-auto-accept/DOCUMENTATION.md +5 -5
  210. package/server/lib/permission-auto-accept/runtime.js +14 -7
  211. package/server/lib/permission-auto-accept/runtime.test.js +27 -12
  212. package/server/lib/relay/reasoning-projection.e2e.test.ts +22 -7
  213. package/server/lib/scheduled-tasks/DOCUMENTATION.md +79 -39
  214. package/server/lib/scheduled-tasks/managed-tool-route.js +31 -1
  215. package/server/lib/scheduled-tasks/managed-tool-route.test.js +23 -0
  216. package/server/lib/scheduled-tasks/routes.js +27 -0
  217. package/server/lib/scheduled-tasks/routes.test.js +94 -0
  218. package/server/lib/scheduled-tasks/runtime.js +381 -310
  219. package/server/lib/scheduled-tasks/runtime.test.js +600 -309
  220. package/server/lib/session-goal/DOCUMENTATION.md +173 -22
  221. package/server/lib/session-goal/capability.js +57 -0
  222. package/server/lib/session-goal/capability.test.js +33 -0
  223. package/server/lib/session-goal/routes.js +240 -2
  224. package/server/lib/session-goal/routes.test.js +211 -0
  225. package/server/lib/session-goal/runtime.js +1617 -113
  226. package/server/lib/session-goal/runtime.test.js +1500 -70
  227. package/server/lib/session-index/DOCUMENTATION.md +18 -15
  228. package/server/lib/session-index/event-ingest.js +89 -16
  229. package/server/lib/session-index/event-ingest.test.js +73 -0
  230. package/server/lib/session-index/host-authority-snapshot.js +92 -0
  231. package/server/lib/session-index/routes.host-archive.test.js +201 -0
  232. package/server/lib/session-index/routes.js +63 -10
  233. package/server/lib/session-index/routes.test.js +8 -8
  234. package/server/lib/session-index/service.js +7 -1
  235. package/server/lib/session-index/sync-runtime.js +171 -41
  236. package/server/lib/session-index/sync-runtime.test.js +164 -9
  237. package/server/lib/session-metadata/DOCUMENTATION.md +96 -0
  238. package/server/lib/session-metadata/opencode-session-record.d.ts +57 -0
  239. package/server/lib/session-metadata/opencode-session-record.js +316 -0
  240. package/server/lib/session-metadata/opencode-session-record.test.js +242 -0
  241. package/server/lib/session-metadata/routes.js +197 -0
  242. package/server/lib/session-metadata/routes.test.js +156 -0
  243. package/server/lib/session-metadata/session-archive.d.ts +73 -0
  244. package/server/lib/session-metadata/session-archive.js +654 -0
  245. package/server/lib/session-metadata/session-archive.test.js +359 -0
  246. package/server/lib/session-metadata/session-metadata-store.d.ts +38 -0
  247. package/server/lib/session-metadata/session-metadata-store.js +422 -0
  248. package/server/lib/session-metadata/session-metadata-store.test.js +379 -0
  249. package/server/lib/session-metadata/session-projection.d.ts +41 -0
  250. package/server/lib/session-metadata/session-projection.js +279 -0
  251. package/server/lib/session-metadata/session-projection.test.js +64 -0
  252. package/server/lib/session-metadata/system-session.js +55 -0
  253. package/server/lib/session-metadata/system-session.test.js +55 -0
  254. package/server/lib/session-title/DOCUMENTATION.md +40 -7
  255. package/server/lib/session-title/native-runtime.test.js +167 -0
  256. package/server/lib/session-title/runtime.js +69 -44
  257. package/server/lib/session-title/session-access.js +46 -0
  258. package/server/lib/session-title/session-access.test.js +91 -0
  259. package/server/lib/session-turn-pages/DOCUMENTATION.md +12 -11
  260. package/server/lib/session-turn-pages/reconcile.service.js +1 -1
  261. package/server/lib/session-turn-pages/reconcile.service.test.js +16 -0
  262. package/server/lib/session-turn-pages/routes.js +123 -75
  263. package/server/lib/session-turn-pages/routes.test.js +566 -0
  264. package/server/lib/session-turn-pages/service.js +6 -2
  265. package/server/lib/session-turn-pages/service.test.js +34 -0
  266. package/server/lib/session-turn-pages/session-message-projection.d.ts +13 -0
  267. package/server/lib/session-turn-pages/session-message-projection.js +281 -0
  268. package/server/lib/small-model/DOCUMENTATION.md +101 -146
  269. package/server/lib/small-model/catalog.js +84 -54
  270. package/server/lib/small-model/catalog.test.js +111 -9
  271. package/server/lib/small-model/custom-api.js +68 -0
  272. package/server/lib/small-model/custom-api.test.js +64 -0
  273. package/server/lib/small-model/index.js +125 -241
  274. package/server/lib/small-model/resolve.js +35 -120
  275. package/server/lib/small-model/resolve.test.js +20 -110
  276. package/server/lib/small-model/routes.js +1 -3
  277. package/server/lib/small-model/summary-settings.test.js +157 -253
  278. package/server/opencode-proxy.test.js +63 -12
  279. package/dist/assets/AssistantView-BUveAgc4.js +0 -3
  280. package/dist/assets/Icon-BgdfPhNs.js +0 -1
  281. package/dist/assets/MarkdownRenderer-BbrbDH6-.js +0 -2
  282. package/dist/assets/MarkstreamRendererImpl-D2dsW5Lg.js +0 -3
  283. package/dist/assets/MobileDetailNavigation-B0aqKXd7.js +0 -1
  284. package/dist/assets/MobileSurface-DW7WfPsy.js +0 -2
  285. package/dist/assets/OverlayScrollbar-DrA0Vsg5.js +0 -2
  286. package/dist/assets/SettingsView-PkXIavr7.js +0 -25
  287. package/dist/assets/TerminalView-CDdzF4yi.js +0 -8
  288. package/dist/assets/appThemeRegistry-D5Yxg4YF.js +0 -1
  289. package/dist/assets/es-DA3MqOo0.js +0 -15
  290. package/dist/assets/fileMentionTouchSelection-DNeiqns-.js +0 -4
  291. package/dist/assets/fr-Dbz0CdIA.js +0 -13
  292. package/dist/assets/gitApi-DXyC4MiV.js +0 -7
  293. package/dist/assets/insertionBoundaries-KlOVrHHt.js +0 -1
  294. package/dist/assets/ja-DumanVQA.js +0 -15
  295. package/dist/assets/ko-C0IkiUjQ.js +0 -15
  296. package/dist/assets/main-BPS5ylib.js +0 -2
  297. package/dist/assets/main-Cpd9VWYs.js +0 -169
  298. package/dist/assets/main-qSeeJRW1.css +0 -1
  299. package/dist/assets/markdown-worker-CptoICmq.js +0 -2
  300. package/dist/assets/markdownTheme-DOfGg-A7.js +0 -1
  301. package/dist/assets/miniChat-B8_KLWiY.js +0 -2
  302. package/dist/assets/mobile-CtktKrXn.js +0 -2
  303. package/dist/assets/multirun-CYfP9Cfm.js +0 -4
  304. package/dist/assets/persistence-Ce3AnpEr.js +0 -3
  305. package/dist/assets/pl-B9No6MQp.js +0 -15
  306. package/dist/assets/platform-0w_Q9_ji.js +0 -2
  307. package/dist/assets/pt-BR-DyQ0WTDh.js +0 -15
  308. package/dist/assets/renderElectronMiniChatApp-iK14LWm8.js +0 -2
  309. package/dist/assets/renderMobileApp-DORLPWnb.js +0 -28
  310. package/dist/assets/runtime-fetch-zIalUnbb.js +0 -1
  311. package/dist/assets/runtimeEndpointReset-ChOxt-J7.js +0 -147
  312. package/dist/assets/sessionChangeSummary-NnxcqCTI.js +0 -2
  313. package/dist/assets/src-rS3zCcsC.css +0 -2
  314. package/dist/assets/store-5B_LDnLM.js +0 -15
  315. package/dist/assets/textarea-bHYxZtfH.js +0 -1
  316. package/dist/assets/uk-C_1KkqyP.js +0 -15
  317. package/dist/assets/useDesktopWindowControlsLayout-Dnr-jX0C.js +0 -1
  318. package/dist/assets/useEffectiveDirectory-CZLLyarc.js +0 -1
  319. package/dist/assets/useMobileNavigationStore-CoCiqNgm.js +0 -413
  320. package/dist/assets/useSessionAutoCleanup-xQyETQkG.js +0 -2
  321. package/dist/assets/useUIStore-Bxv3f23A.js +0 -1
  322. package/dist/assets/vendor-opencode-sdk-C07HQypa.js +0 -7
  323. package/dist/assets/zh-CN-uWILgBdt.js +0 -15
  324. package/dist/assets/zh-TW-MYfdvhbD.js +0 -15
  325. package/server/lib/small-model/call.js +0 -427
  326. package/server/lib/small-model/call.test.js +0 -382
  327. package/server/lib/small-model/opencode-session.js +0 -339
  328. package/server/lib/small-model/opencode-session.test.js +0 -177
@@ -1,382 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
-
3
- // readConfig reads merged opencode config layers from disk; mock it so each
4
- // test controls the provider config without touching the filesystem. call.js
5
- // imports only readConfig from shared.js, so the rest of that module is left
6
- // untouched for this file.
7
- vi.mock('../opencode/shared.js', () => ({
8
- readConfig: vi.fn(),
9
- }));
10
-
11
- const { callSmallModel } = await import('./call.js');
12
- const { readConfig } = await import('../opencode/shared.js');
13
-
14
- // Minimal catalog fragment used by the catalog-based base URL resolution case.
15
- // Base URL comes from model.api.url (OpenCode SDK shape), not provider.api.
16
- const CATALOG = {
17
- mistral: {
18
- id: 'mistral',
19
- name: 'Mistral',
20
- models: {
21
- 'mistral-small-latest': {
22
- id: 'mistral-small-latest',
23
- api: { url: 'https://api.mistral.ai/v1' },
24
- },
25
- },
26
- },
27
- };
28
-
29
- const ok = (content) => ({
30
- ok: true,
31
- status: 200,
32
- json: async () => ({
33
- choices: [{ message: { content }, finish_reason: 'stop' }],
34
- }),
35
- text: async () => JSON.stringify({
36
- choices: [{ message: { content }, finish_reason: 'stop' }],
37
- }),
38
- });
39
-
40
- const lastCall = (mock) => {
41
- const [url, init] = mock.mock.calls.at(-1);
42
- return { url: String(url), init };
43
- };
44
-
45
- // Regression coverage for the small-model dispatch to custom OpenAI-compatible
46
- // providers — credential and endpoint resolution, precedence, and non-leakage.
47
- describe('callSmallModel — custom provider config', () => {
48
- let fetchMock;
49
- let originalFetch;
50
-
51
- beforeEach(() => {
52
- fetchMock = vi.fn();
53
- originalFetch = globalThis.fetch;
54
- globalThis.fetch = fetchMock;
55
- readConfig.mockReset();
56
- });
57
-
58
- afterEach(() => {
59
- globalThis.fetch = originalFetch;
60
- });
61
-
62
- describe('config-supplied credentials (no auth.json entry)', () => {
63
- it('calls a custom summary API without an OpenCode provider login', async () => {
64
- fetchMock.mockResolvedValue(ok('summary'));
65
-
66
- const text = await callSmallModel({
67
- auth: {},
68
- catalog: {},
69
- workingDirectory: '/proj',
70
- providerID: 'custom',
71
- modelID: 'summary-model',
72
- prompt: 'Summarize this diff.',
73
- custom: {
74
- baseURL: 'https://summary.example.test/v1',
75
- apiToken: 'summary-token',
76
- },
77
- });
78
-
79
- expect(text).toBe('summary');
80
- const { url, init } = lastCall(fetchMock);
81
- expect(url).toBe('https://summary.example.test/v1/chat/completions');
82
- expect(init.headers.Authorization).toBe('Bearer summary-token');
83
- expect(JSON.stringify(init.body)).not.toContain('summary-token');
84
- });
85
-
86
- it('uses apiKey and baseURL from provider config when no auth.json entry exists', async () => {
87
- readConfig.mockReturnValue({
88
- provider: {
89
- custom: {
90
- options: { apiKey: 'test-key', baseURL: 'https://proxy.example.test/v1' },
91
- },
92
- },
93
- });
94
- fetchMock.mockResolvedValue(ok('hello'));
95
-
96
- const text = await callSmallModel({
97
- auth: {},
98
- catalog: {},
99
- workingDirectory: '/proj',
100
- providerID: 'custom',
101
- modelID: 'gpt-4o-mini',
102
- prompt: 'hi',
103
- });
104
-
105
- expect(text).toBe('hello');
106
- expect(fetchMock).toHaveBeenCalledTimes(1);
107
-
108
- const { url, init } = lastCall(fetchMock);
109
- // Config baseURL is used, never the hardcoded OpenAI endpoint.
110
- expect(url).toBe('https://proxy.example.test/v1/chat/completions');
111
- expect(url).not.toContain('api.openai.com');
112
- // Config apiKey becomes the bearer credential.
113
- expect(init.headers.Authorization).toBe('Bearer test-key');
114
- });
115
-
116
- it('trims a trailing slash from the configured baseURL', async () => {
117
- readConfig.mockReturnValue({
118
- provider: {
119
- custom: { options: { apiKey: 'k', baseURL: 'https://proxy.example.test/v1/' } },
120
- },
121
- });
122
- fetchMock.mockResolvedValue(ok('ok'));
123
-
124
- await callSmallModel({
125
- auth: {},
126
- catalog: {},
127
- workingDirectory: '/proj',
128
- providerID: 'custom',
129
- modelID: 'gpt-4o-mini',
130
- prompt: 'hi',
131
- });
132
-
133
- expect(lastCall(fetchMock).url).toBe('https://proxy.example.test/v1/chat/completions');
134
- });
135
-
136
- it('throws "No OpenCode login found for provider" when neither auth.json nor config apiKey exists', async () => {
137
- readConfig.mockReturnValue({
138
- provider: { custom: { options: { baseURL: 'https://proxy.example.test/v1' } } },
139
- });
140
-
141
- await expect(callSmallModel({
142
- auth: {},
143
- catalog: {},
144
- workingDirectory: '/proj',
145
- providerID: 'custom',
146
- modelID: 'gpt-4o-mini',
147
- prompt: 'hi',
148
- })).rejects.toThrow('No OpenCode login found for provider "custom"');
149
-
150
- // The credential gate fires before any network call.
151
- expect(fetchMock).not.toHaveBeenCalled();
152
- });
153
-
154
- it('treats a blank/whitespace apiKey in config as absent', async () => {
155
- readConfig.mockReturnValue({
156
- provider: {
157
- custom: { options: { apiKey: ' ', baseURL: 'https://proxy.example.test/v1' } },
158
- },
159
- });
160
-
161
- await expect(callSmallModel({
162
- auth: {},
163
- catalog: {},
164
- workingDirectory: '/proj',
165
- providerID: 'custom',
166
- modelID: 'gpt-4o-mini',
167
- prompt: 'hi',
168
- })).rejects.toThrow('No OpenCode login found for provider "custom"');
169
- });
170
- });
171
-
172
- describe('resolution order when auth.json is also present', () => {
173
- it('uses the auth.json credential with the config baseURL', async () => {
174
- readConfig.mockReturnValue({
175
- provider: { custom: { options: { baseURL: 'https://proxy.example.test/v1' } } },
176
- });
177
- fetchMock.mockResolvedValue(ok('done'));
178
-
179
- const text = await callSmallModel({
180
- auth: { custom: { type: 'api', key: 'authjson-key' } },
181
- catalog: {},
182
- workingDirectory: '/proj',
183
- providerID: 'custom',
184
- modelID: 'gpt-4o-mini',
185
- prompt: 'hi',
186
- });
187
-
188
- expect(text).toBe('done');
189
- const { url, init } = lastCall(fetchMock);
190
- expect(url).toBe('https://proxy.example.test/v1/chat/completions');
191
- expect(init.headers.Authorization).toBe('Bearer authjson-key');
192
- });
193
-
194
- it('prefers the config apiKey over an auth.json credential when both are present (matches OpenCode)', async () => {
195
- readConfig.mockReturnValue({
196
- provider: {
197
- custom: { options: { apiKey: 'config-key', baseURL: 'https://proxy.example.test/v1' } },
198
- },
199
- });
200
- fetchMock.mockResolvedValue(ok('done'));
201
-
202
- await callSmallModel({
203
- auth: { custom: { type: 'api', key: 'authjson-key' } },
204
- catalog: {},
205
- workingDirectory: '/proj',
206
- providerID: 'custom',
207
- modelID: 'gpt-4o-mini',
208
- prompt: 'hi',
209
- });
210
-
211
- // OpenCode's resolveSDK reads options.apiKey first and only falls back to
212
- // auth.json's key when config has none — so the config key wins and the
213
- // auth.json credential must never be sent.
214
- expect(lastCall(fetchMock).init.headers.Authorization).toBe('Bearer config-key');
215
- expect(JSON.stringify(fetchMock.mock.calls[0][1])).not.toContain('authjson-key');
216
- });
217
- });
218
-
219
- describe('openai provider custom baseURL override', () => {
220
- it('respects provider.openai.options.baseURL over the hardcoded OpenAI endpoint', async () => {
221
- readConfig.mockReturnValue({
222
- provider: { openai: { options: { baseURL: 'https://gateway.example.test/v1' } } },
223
- });
224
- fetchMock.mockResolvedValue(ok('ok'));
225
-
226
- await callSmallModel({
227
- auth: { openai: { type: 'api', key: 'sk-openai' } },
228
- catalog: {},
229
- workingDirectory: '/proj',
230
- providerID: 'openai',
231
- modelID: 'gpt-4o-mini',
232
- prompt: 'hi',
233
- });
234
-
235
- const { url, init } = lastCall(fetchMock);
236
- expect(url).toBe('https://gateway.example.test/v1/chat/completions');
237
- expect(url).not.toContain('api.openai.com');
238
- expect(init.headers.Authorization).toBe('Bearer sk-openai');
239
- });
240
-
241
- it('falls back to https://api.openai.com/v1 when no openai baseURL override is configured', async () => {
242
- readConfig.mockReturnValue({});
243
- fetchMock.mockResolvedValue(ok('ok'));
244
-
245
- await callSmallModel({
246
- auth: { openai: { type: 'api', key: 'sk-openai' } },
247
- catalog: {},
248
- workingDirectory: '/proj',
249
- providerID: 'openai',
250
- modelID: 'gpt-4o-mini',
251
- prompt: 'hi',
252
- });
253
-
254
- expect(lastCall(fetchMock).url).toBe('https://api.openai.com/v1/chat/completions');
255
- });
256
-
257
- it('still requires a credential: a baseURL alone does not authenticate openai', async () => {
258
- readConfig.mockReturnValue({
259
- provider: { openai: { options: { baseURL: 'https://gateway.example.test/v1' } } },
260
- });
261
-
262
- await expect(callSmallModel({
263
- auth: {},
264
- catalog: {},
265
- workingDirectory: '/proj',
266
- providerID: 'openai',
267
- modelID: 'gpt-4o-mini',
268
- prompt: 'hi',
269
- })).rejects.toThrow('No OpenCode login found for provider "openai"');
270
- });
271
- });
272
-
273
- describe('catalog-based base URL (no config override)', () => {
274
- it('uses the model api.url from the catalog when no config baseURL is set', async () => {
275
- readConfig.mockReturnValue({});
276
- fetchMock.mockResolvedValue(ok('ok'));
277
-
278
- await callSmallModel({
279
- auth: { mistral: { type: 'api', key: 'mistral-key' } },
280
- catalog: CATALOG,
281
- workingDirectory: '/proj',
282
- providerID: 'mistral',
283
- modelID: 'mistral-small-latest',
284
- prompt: 'hi',
285
- });
286
-
287
- const { url, init } = lastCall(fetchMock);
288
- expect(url).toBe('https://api.mistral.ai/v1/chat/completions');
289
- expect(init.headers.Authorization).toBe('Bearer mistral-key');
290
- });
291
-
292
- it('prefers config baseURL over model api.url', async () => {
293
- readConfig.mockReturnValue({
294
- provider: { mistral: { options: { baseURL: 'https://gateway.example.test/v1' } } },
295
- });
296
- fetchMock.mockResolvedValue(ok('ok'));
297
-
298
- await callSmallModel({
299
- auth: { mistral: { type: 'api', key: 'mistral-key' } },
300
- catalog: CATALOG,
301
- workingDirectory: '/proj',
302
- providerID: 'mistral',
303
- modelID: 'mistral-small-latest',
304
- prompt: 'hi',
305
- });
306
-
307
- expect(lastCall(fetchMock).url).toBe('https://gateway.example.test/v1/chat/completions');
308
- });
309
-
310
- it('throws when a non-openai provider has no model api.url and no config baseURL', async () => {
311
- readConfig.mockReturnValue({});
312
-
313
- await expect(callSmallModel({
314
- auth: { custom: { type: 'api', key: 'k' } },
315
- catalog: {},
316
- workingDirectory: '/proj',
317
- providerID: 'custom',
318
- modelID: 'gpt-4o-mini',
319
- prompt: 'hi',
320
- })).rejects.toThrow('Provider "custom" has no known API base URL');
321
- });
322
- });
323
-
324
- describe('config-supplied key does not leak', () => {
325
- // The config-supplied key must stay in-memory: never copied into catalog
326
- // metadata, the response, or the request body.
327
- it('does not mutate the catalog or echo the key in the request/response', async () => {
328
- const catalog = { custom: { id: 'custom', models: {} } };
329
- const catalogBefore = JSON.parse(JSON.stringify(catalog));
330
- readConfig.mockReturnValue({
331
- provider: {
332
- custom: { options: { apiKey: 'test-key', baseURL: 'https://proxy.example.test/v1' } },
333
- },
334
- });
335
- fetchMock.mockResolvedValue(ok('the answer'));
336
-
337
- const text = await callSmallModel({
338
- auth: {},
339
- catalog,
340
- workingDirectory: '/proj',
341
- providerID: 'custom',
342
- modelID: 'gpt-4o-mini',
343
- prompt: 'hi',
344
- });
345
-
346
- // Response text is exactly the model output — no credential echoed back.
347
- expect(text).toBe('the answer');
348
- // Catalog object left untouched (key stays in-memory only).
349
- expect(catalog).toEqual(catalogBefore);
350
-
351
- const { url, init } = lastCall(fetchMock);
352
- // The key rides only in the Authorization header.
353
- expect(url).not.toContain('test-key');
354
- const body = JSON.parse(init.body);
355
- expect(JSON.stringify(body)).not.toContain('test-key');
356
- });
357
- });
358
-
359
- describe('merged config layers', () => {
360
- it('reads the provider config for the supplied working directory', async () => {
361
- readConfig.mockReturnValue({
362
- provider: {
363
- custom: { options: { apiKey: 'test-key', baseURL: 'https://proxy.example.test/v1' } },
364
- },
365
- });
366
- fetchMock.mockResolvedValue(ok('ok'));
367
-
368
- await callSmallModel({
369
- auth: {},
370
- catalog: {},
371
- workingDirectory: '/path/to/project',
372
- providerID: 'custom',
373
- modelID: 'gpt-4o-mini',
374
- prompt: 'hi',
375
- });
376
-
377
- // readConfig merges global + project-scoped layers for this directory;
378
- // confirm callSmallModel passes the working directory straight through.
379
- expect(readConfig).toHaveBeenCalledWith('/path/to/project');
380
- });
381
- });
382
- });