@openchamber/web 1.24.2 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (387) hide show
  1. package/bin/lib/commands-connect-url.js +3 -8
  2. package/bin/lib/commands-tunnel.js +3 -0
  3. package/dist/assets/{CodeMirrorCommentWidgets-B_vBPQYm.js → CodeMirrorCommentWidgets-zm3C1FvM.js} +1 -1
  4. package/dist/assets/DiffView-DNExNi1z.js +4 -0
  5. package/dist/assets/FilesView-DUCLmHBi.js +17 -0
  6. package/dist/assets/{GitView-k0hUF8KB.js → GitView-Bz9z6gZA.js} +4 -4
  7. package/dist/assets/{GuestAttachDialog-DIf2U85Z.js → GuestAttachDialog-UGp4KDlK.js} +1 -1
  8. package/dist/assets/GuestSurfacePane-B3pdB_2u.js +1 -0
  9. package/dist/assets/{JsonTreeView-4AnJ04Pw.js → JsonTreeView-7lVecnZl.js} +1 -1
  10. package/dist/assets/LinearIssuesView-CTGRS9Vq.js +1 -0
  11. package/dist/assets/MarkdownImageGallery-DQk5adUs.js +1 -0
  12. package/dist/assets/MarkdownRendererImpl-DPF8fZpX.js +12 -0
  13. package/dist/assets/OnboardingScreen-CBx6cXPP.js +1 -0
  14. package/dist/assets/{PatchDiff-DpGmHRnV.js → PatchDiff-D7VVpR_l.js} +1 -1
  15. package/dist/assets/{PierreDiffViewer-CgLl_tp7.js → PierreDiffViewer-Gbfks1pk.js} +3 -3
  16. package/dist/assets/PlanView-CPSK0x97.js +5 -0
  17. package/dist/assets/PluginPane-BIGsUx69.js +3 -0
  18. package/dist/assets/SettingsView-Dql7z6Ww.js +30 -0
  19. package/dist/assets/SettingsWindow-D6oi-UmV.js +1 -0
  20. package/dist/assets/SubmoduleDiffSummary-BXA0FAWj.js +1 -0
  21. package/dist/assets/ToolOutputDialog-BQJsSbDm.js +15 -0
  22. package/dist/assets/ToolPartDiffPreview-FY9w0TVT.js +8 -0
  23. package/dist/assets/{VirtualizedFileDiff-BK4aU5qJ.js → VirtualizedFileDiff-B9YhAya5.js} +4 -4
  24. package/dist/assets/{WalkthroughView-Bk6TPNFw.js → WalkthroughView-CmFgOUFN.js} +2 -2
  25. package/dist/assets/appThemeRegistry-BebxalUt.js +1 -0
  26. package/dist/assets/changesTree-CePHbFcj.js +1 -0
  27. package/dist/assets/commitAndPush-Wfxng_IK.js +1 -0
  28. package/dist/assets/{computeVirtualFileMetrics-BVTujWSX.js → computeVirtualFileMetrics-BCOqgixN.js} +2 -2
  29. package/dist/assets/de-CMA45TC-.js +10 -0
  30. package/dist/assets/es-DPL4fBtl.js +16 -0
  31. package/dist/assets/fr-OHBKBseP.js +14 -0
  32. package/dist/assets/index-3TiDNtfN.js +1 -0
  33. package/dist/assets/index-BLUZa5u0.js +41 -0
  34. package/dist/assets/index-Cm2rrq69.css +1 -0
  35. package/dist/assets/{isDiffPlainText-D3yX_vx4.js → isDiffPlainText-DnDYQmWK.js} +1 -1
  36. package/dist/assets/{isFilePlainText-CZR9TcHV.js → isFilePlainText-BA_AHX7d.js} +1 -1
  37. package/dist/assets/ja-DvX4WSRf.js +16 -0
  38. package/dist/assets/ko-BUcLd8YZ.js +16 -0
  39. package/dist/assets/main-B_jri4i-.js +896 -0
  40. package/dist/assets/main-DtUmJp9B.js +2 -0
  41. package/dist/assets/{markdown-shiki.worker-CahLvHIq.js → markdown-shiki.worker-Bg8SoAJJ.js} +8 -5
  42. package/dist/assets/markdownCore-BSnlUXBf.js +7 -0
  43. package/dist/assets/miniChat-BYfLUnDK.js +2 -0
  44. package/dist/assets/mobile-DH3hI6gd.js +2 -0
  45. package/dist/assets/patchFileDiff--L7lt_GZ.js +13 -0
  46. package/dist/assets/pl-BkI_xHqz.js +16 -0
  47. package/dist/assets/pt-BR-7wFtQlV9.js +16 -0
  48. package/dist/assets/renderElectronMiniChatApp-C7kpNW_-.js +2 -0
  49. package/dist/assets/renderMobileApp-i0nq7Dwy.js +25 -0
  50. package/dist/assets/runtimeEndpointReset-CfEYbcCc.js +27 -0
  51. package/dist/assets/scheduledTasksApi-Cy7uZCaI.js +1 -0
  52. package/dist/assets/{shikiHighlight-BfjuB3CD.js → shikiHighlight-D4vxipfr.js} +1 -1
  53. package/dist/assets/{textMateThemeFromAppTheme-BP60t9SX.js → textMateThemeFromAppTheme-BYAHtJwQ.js} +1 -1
  54. package/dist/assets/tr-TsD-AqEH.js +7 -0
  55. package/dist/assets/uk-B-qspCmD.js +16 -0
  56. package/dist/assets/useAppFontEffects-DHZ9-L30.js +7338 -0
  57. package/dist/assets/useInlineCommentController-CvpOMK-R.js +2 -0
  58. package/dist/assets/useRootScrollLock-DzNFi-fn.js +2 -0
  59. package/dist/assets/{vendor-codemirror-language-data-BFm1Ju2w.js → vendor-codemirror-language-data-j3fhlwUM.js} +2 -2
  60. package/dist/assets/vendor-cron-parser-CjvYVigk.js +2 -0
  61. package/dist/assets/vendor-opencode-client-DYdsLbCM.js +12 -0
  62. package/dist/assets/{vendor-remixicon-react-BDmGmFCA.js → vendor-remixicon-react-D6dZ0UwF.js} +1 -1
  63. package/dist/assets/vendor-zod-BSoePkpP.js +39 -0
  64. package/dist/assets/{web-components-2vo9YsZc.js → web-components-BvHNFSEG.js} +2 -2
  65. package/dist/assets/zh-CN-DYuPJV5i.js +16 -0
  66. package/dist/assets/zh-TW-BX_2D_lV.js +16 -0
  67. package/dist/index.html +13 -7
  68. package/dist/mini-chat.html +5 -5
  69. package/dist/mobile.html +5 -5
  70. package/package.json +6 -5
  71. package/server/index.d.ts +1 -0
  72. package/server/index.js +264 -91
  73. package/server/lib/agent-tool/DOCUMENTATION.md +38 -16
  74. package/server/lib/agent-tool/runtime.js +167 -58
  75. package/server/lib/agent-tool/runtime.test.js +170 -87
  76. package/server/lib/browser-control/DOCUMENTATION.md +51 -4
  77. package/server/lib/browser-control/provider.js +217 -0
  78. package/server/lib/browser-control/provider.test.js +251 -0
  79. package/server/lib/context-obligatory/runtime.js +61 -50
  80. package/server/lib/context-obligatory/runtime.test.js +62 -162
  81. package/server/lib/event-stream/DOCUMENTATION.md +12 -1
  82. package/server/lib/event-stream/delta-coalescer.js +0 -0
  83. package/server/lib/event-stream/delta-coalescer.test.js +68 -57
  84. package/server/lib/event-stream/directory-ws-bridge.js +1 -1
  85. package/server/lib/event-stream/global-hub.js +10 -1
  86. package/server/lib/event-stream/global-hub.test.js +27 -26
  87. package/server/lib/event-stream/index.js +6 -0
  88. package/server/lib/event-stream/protocol.js +26 -19
  89. package/server/lib/event-stream/protocol.test.js +18 -7
  90. package/server/lib/event-stream/rebind.test.js +5 -5
  91. package/server/lib/event-stream/runtime.test.js +17 -15
  92. package/server/lib/event-stream/translate-v2.js +313 -0
  93. package/server/lib/event-stream/translate-v2.test.js +209 -0
  94. package/server/lib/event-stream/upstream-reader.test.js +16 -16
  95. package/server/lib/fs/DOCUMENTATION.md +4 -2
  96. package/server/lib/fs/byte-range.js +35 -0
  97. package/server/lib/fs/byte-range.test.js +31 -0
  98. package/server/lib/fs/routes.js +47 -42
  99. package/server/lib/fs/routes.test.js +123 -18
  100. package/server/lib/git/DOCUMENTATION.md +1 -1
  101. package/server/lib/git/service.js +34 -0
  102. package/server/lib/git/service.test.js +8 -0
  103. package/server/lib/github/DOCUMENTATION.md +1 -1
  104. package/server/lib/github/pr-status.js +22 -2
  105. package/server/lib/github/pr-status.test.js +27 -14
  106. package/server/lib/guests/DOCUMENTATION.md +16 -2
  107. package/server/lib/guests/catalog.js +31 -1
  108. package/server/lib/guests/catalog.test.js +55 -0
  109. package/server/lib/guests/html-styles.js +5 -3
  110. package/server/lib/guests/html-styles.test.js +3 -1
  111. package/server/lib/guests/routes.js +21 -4
  112. package/server/lib/guests/service.js +197 -14
  113. package/server/lib/guests/service.test.js +201 -1
  114. package/server/lib/guests/surface.js +676 -0
  115. package/server/lib/guests/surface.test.js +536 -0
  116. package/server/lib/markdown-image-grants/routes.js +18 -5
  117. package/server/lib/markdown-image-grants/routes.test.js +9 -6
  118. package/server/lib/message-queue/DOCUMENTATION.md +33 -22
  119. package/server/lib/message-queue/runtime.js +155 -100
  120. package/server/lib/message-queue/runtime.test.js +168 -82
  121. package/server/lib/notifications/DOCUMENTATION.md +38 -0
  122. package/server/lib/notifications/control-stream.http.test.js +68 -0
  123. package/server/lib/notifications/emit-route.js +118 -0
  124. package/server/lib/notifications/emit-route.test.js +112 -0
  125. package/server/lib/notifications/emitter-runtime.js +15 -0
  126. package/server/lib/notifications/emitter-runtime.test.js +32 -0
  127. package/server/lib/notifications/push-runtime.js +5 -1
  128. package/server/lib/notifications/push-runtime.test.js +2 -2
  129. package/server/lib/notifications/routes.js +1 -1
  130. package/server/lib/notifications/runtime.js +115 -26
  131. package/server/lib/notifications/template-runtime.js +13 -15
  132. package/server/lib/notifications/template-runtime.test.js +16 -9
  133. package/server/lib/notifications/trigger-runtime.test.js +187 -0
  134. package/server/lib/openchamber-control/DOCUMENTATION.md +10 -0
  135. package/server/lib/openchamber-control/actions.js +19 -4
  136. package/server/lib/openchamber-control/error.js +1 -1
  137. package/server/lib/openchamber-control/file-open.js +59 -0
  138. package/server/lib/openchamber-control/file-open.test.js +57 -0
  139. package/server/lib/openchamber-control/routes.test.js +12 -0
  140. package/server/lib/openchamber-control/service.js +125 -49
  141. package/server/lib/openchamber-control/service.test.js +115 -44
  142. package/server/lib/openchamber-sessions/archive-store.js +224 -0
  143. package/server/lib/openchamber-sessions/archive-store.test.js +187 -0
  144. package/server/lib/openchamber-sessions/fork-inheritance.js +103 -0
  145. package/server/lib/openchamber-sessions/fork-inheritance.test.js +69 -0
  146. package/server/lib/openchamber-sessions/opencode-client.js +22 -0
  147. package/server/lib/openchamber-sessions/routes.js +409 -328
  148. package/server/lib/openchamber-sessions/routes.test.js +795 -740
  149. package/server/lib/openchamber-sessions/session-metadata-store.js +285 -0
  150. package/server/lib/openchamber-sessions/session-metadata-store.test.js +259 -0
  151. package/server/lib/opencode/DOCUMENTATION.md +458 -29
  152. package/server/lib/opencode/agents.js +233 -327
  153. package/server/lib/opencode/auth.js +41 -44
  154. package/server/lib/opencode/auth.test.js +92 -0
  155. package/server/lib/opencode/bootstrap-runtime.js +12 -0
  156. package/server/lib/opencode/cli-upgrade.d.ts +4 -0
  157. package/server/lib/opencode/cli-upgrade.js +18 -0
  158. package/server/lib/opencode/cli-upgrade.test.js +36 -0
  159. package/server/lib/opencode/commands.js +164 -145
  160. package/server/lib/opencode/compatibility.d.ts +16 -0
  161. package/server/lib/opencode/compatibility.js +91 -0
  162. package/server/lib/opencode/compatibility.test.js +70 -0
  163. package/server/lib/opencode/config-entity-routes.js +58 -29
  164. package/server/lib/opencode/config-entity-v2.test.js +290 -0
  165. package/server/lib/opencode/config-mutation-response.js +17 -7
  166. package/server/lib/opencode/config-mutation-response.test.js +4 -7
  167. package/server/lib/opencode/config-paths.test.js +2 -2
  168. package/server/lib/opencode/config-v2.d.ts +185 -0
  169. package/server/lib/opencode/config-v2.js +843 -0
  170. package/server/lib/opencode/config-v2.test.js +483 -0
  171. package/server/lib/opencode/core-routes.js +3 -0
  172. package/server/lib/opencode/core-routes.test.js +15 -0
  173. package/server/lib/opencode/credential-db.js +144 -0
  174. package/server/lib/opencode/credential-db.test.js +104 -0
  175. package/server/lib/opencode/env-runtime.js +47 -15
  176. package/server/lib/opencode/env-runtime.test.js +45 -0
  177. package/server/lib/opencode/feature-routes-runtime.js +16 -5
  178. package/server/lib/opencode/lifecycle-process.test.js +7 -4
  179. package/server/lib/opencode/lifecycle.js +113 -30
  180. package/server/lib/opencode/lifecycle.test.js +107 -8
  181. package/server/lib/opencode/login-shell-env.js +27 -0
  182. package/server/lib/opencode/managed-config-file.js +131 -0
  183. package/server/lib/opencode/managed-config-file.test.js +168 -0
  184. package/server/lib/opencode/managed-plugin-config.js +33 -13
  185. package/server/lib/opencode/mcp.js +43 -149
  186. package/server/lib/opencode/network-runtime.js +6 -7
  187. package/server/lib/opencode/openchamber-routes.js +29 -11
  188. package/server/lib/opencode/openchamber-routes.test.js +18 -1
  189. package/server/lib/opencode/plugin-routes.js +3 -3
  190. package/server/lib/opencode/plugin-routes.test.js +6 -24
  191. package/server/lib/opencode/plugins.js +91 -40
  192. package/server/lib/opencode/plugins.test.js +28 -15
  193. package/server/lib/opencode/provider-source-route.test.js +59 -0
  194. package/server/lib/opencode/providers.js +66 -83
  195. package/server/lib/opencode/providers.test.js +190 -59
  196. package/server/lib/opencode/proxy-agent-wiring.test.js +4 -2
  197. package/server/lib/opencode/proxy.js +179 -129
  198. package/server/lib/opencode/pwa-manifest-routes.js +4 -2
  199. package/server/lib/opencode/pwa-manifest-routes.test.js +3 -2
  200. package/server/lib/opencode/response-envelope.js +14 -0
  201. package/server/lib/opencode/response-envelope.test.js +23 -0
  202. package/server/lib/opencode/routes-upgrade.test.js +73 -116
  203. package/server/lib/opencode/routes.js +138 -428
  204. package/server/lib/opencode/server-utils-runtime.js +10 -4
  205. package/server/lib/opencode/session-activity.js +78 -0
  206. package/server/lib/opencode/session-runtime.js +21 -10
  207. package/server/lib/opencode/session-runtime.test.js +9 -9
  208. package/server/lib/opencode/settings-helpers.js +15 -8
  209. package/server/lib/opencode/settings-helpers.test.js +7 -12
  210. package/server/lib/opencode/settings-registry.json +20 -8
  211. package/server/lib/opencode/settings-runtime.js +19 -1
  212. package/server/lib/opencode/settings-runtime.test.js +31 -2
  213. package/server/lib/opencode/shared.js +86 -24
  214. package/server/lib/opencode/shared.test.js +87 -5
  215. package/server/lib/opencode/shutdown-runtime.js +54 -7
  216. package/server/lib/opencode/shutdown-runtime.test.js +224 -30
  217. package/server/lib/opencode/skill-routes.js +51 -36
  218. package/server/lib/opencode/skill-routes.test.js +121 -1
  219. package/server/lib/opencode/skills.js +7 -5
  220. package/server/lib/opencode/tunnel-wiring-runtime.js +2 -1
  221. package/server/lib/opencode/upgrade-capability.js +0 -14
  222. package/server/lib/opencode/upgrade-capability.test.js +1 -1
  223. package/server/lib/opencode/v1-migration-topup.js +294 -0
  224. package/server/lib/opencode/v1-migration-topup.test.js +274 -0
  225. package/server/lib/opencode/v2-install.d.ts +9 -0
  226. package/server/lib/opencode/v2-install.js +159 -0
  227. package/server/lib/opencode/v2-install.test.js +133 -0
  228. package/server/lib/opencode/watcher.js +10 -3
  229. package/server/lib/opencode/watcher.test.js +17 -21
  230. package/server/lib/opencode/websearch-config.js +78 -0
  231. package/server/lib/permission-auto-accept/runtime.js +38 -22
  232. package/server/lib/permission-auto-accept/runtime.test.js +39 -17
  233. package/server/lib/quota/DOCUMENTATION.md +4 -0
  234. package/server/lib/quota/providers/kimi.js +1 -1
  235. package/server/lib/quota/providers/xai.js +4 -4
  236. package/server/lib/relay/tunnel-host.js +4 -1
  237. package/server/lib/relay/tunnel-host.test.js +7 -0
  238. package/server/lib/routing/DOCUMENTATION.md +52 -21
  239. package/server/lib/routing/defaults.js +23 -6
  240. package/server/lib/routing/jev.js +17 -7
  241. package/server/lib/routing/routes.http.test.js +68 -33
  242. package/server/lib/routing/routes.js +65 -22
  243. package/server/lib/routing/runtime.js +145 -48
  244. package/server/lib/routing/runtime.test.js +79 -55
  245. package/server/lib/scheduled-tasks/DOCUMENTATION.md +4 -0
  246. package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +51 -46
  247. package/server/lib/scheduled-tasks/runtime.js +81 -74
  248. package/server/lib/scheduled-tasks/runtime.test.js +53 -1
  249. package/server/lib/session-assist/DOCUMENTATION.md +25 -8
  250. package/server/lib/session-assist/context.js +122 -46
  251. package/server/lib/session-assist/context.test.js +117 -49
  252. package/server/lib/session-assist/runtime.js +71 -24
  253. package/server/lib/session-assist/runtime.test.js +153 -173
  254. package/server/lib/session-goal/DOCUMENTATION.md +34 -15
  255. package/server/lib/session-goal/create.js +9 -12
  256. package/server/lib/session-goal/create.test.js +27 -28
  257. package/server/lib/session-goal/runtime.js +164 -77
  258. package/server/lib/session-goal/runtime.test.js +271 -519
  259. package/server/lib/session-knowledge/DOCUMENTATION.md +5 -0
  260. package/server/lib/session-knowledge/runtime.js +59 -41
  261. package/server/lib/session-knowledge/runtime.test.js +90 -20
  262. package/server/lib/small-model/DOCUMENTATION.md +154 -208
  263. package/server/lib/small-model/client.js +113 -0
  264. package/server/lib/small-model/index.js +296 -158
  265. package/server/lib/small-model/index.test.js +423 -256
  266. package/server/lib/small-model/routes.js +1 -1
  267. package/server/lib/spaces/DOCUMENTATION.md +807 -0
  268. package/server/lib/spaces/code-in-bait.js +185 -0
  269. package/server/lib/spaces/code-in.js +641 -0
  270. package/server/lib/spaces/code-in.test.js +1048 -0
  271. package/server/lib/spaces/errors.js +8 -0
  272. package/server/lib/spaces/exec-http.js +94 -0
  273. package/server/lib/spaces/gatekeeper-channel.js +202 -0
  274. package/server/lib/spaces/gatekeeper-channel.test.js +215 -0
  275. package/server/lib/spaces/gatekeeper-program.cjs +914 -0
  276. package/server/lib/spaces/gatekeeper-program.test.js +1391 -0
  277. package/server/lib/spaces/hardening.js +457 -0
  278. package/server/lib/spaces/hardening.test.js +368 -0
  279. package/server/lib/spaces/host-git.js +127 -0
  280. package/server/lib/spaces/host-git.test.js +137 -0
  281. package/server/lib/spaces/labels.js +234 -0
  282. package/server/lib/spaces/labels.test.js +219 -0
  283. package/server/lib/spaces/layout.js +184 -0
  284. package/server/lib/spaces/layout.test.js +30 -0
  285. package/server/lib/spaces/manager.js +82 -0
  286. package/server/lib/spaces/manager.test.js +114 -0
  287. package/server/lib/spaces/places/code-in.docker.live.test.js +216 -0
  288. package/server/lib/spaces/places/contract-suite.js +156 -0
  289. package/server/lib/spaces/places/contract.docker.live.test.js +7 -0
  290. package/server/lib/spaces/places/contract.test.js +6 -0
  291. package/server/lib/spaces/places/docker-engine.js +126 -0
  292. package/server/lib/spaces/places/docker-live-support.js +202 -0
  293. package/server/lib/spaces/places/docker-tools.js +186 -0
  294. package/server/lib/spaces/places/docker.js +587 -0
  295. package/server/lib/spaces/places/docker.test.js +1610 -0
  296. package/server/lib/spaces/places/escape-suite.js +1018 -0
  297. package/server/lib/spaces/places/escape.docker.live.test.js +7 -0
  298. package/server/lib/spaces/places/fake-docker.js +375 -0
  299. package/server/lib/spaces/places/memory-place.js +103 -0
  300. package/server/lib/spaces/places/packed.docker.live.test.js +77 -0
  301. package/server/lib/spaces/places/registry.js +43 -0
  302. package/server/lib/spaces/places/registry.test.js +50 -0
  303. package/server/lib/spaces/places/server.docker.live.test.js +225 -0
  304. package/server/lib/spaces/run-command.js +261 -0
  305. package/server/lib/spaces/run-command.test.js +396 -0
  306. package/server/lib/spaces/space-server.js +190 -0
  307. package/server/lib/spaces/space-server.test.js +335 -0
  308. package/server/lib/spaces/tools-filler.js +82 -0
  309. package/server/lib/spaces/tools-filler.test.js +148 -0
  310. package/server/lib/spaces/tools-pack.js +49 -0
  311. package/server/lib/spaces/tools-pack.test.js +57 -0
  312. package/server/lib/spaces/tools.js +137 -0
  313. package/server/lib/spaces/tools.test.js +153 -0
  314. package/server/lib/tts/openai-sdk.js +11 -0
  315. package/server/lib/tts/service.js +7 -5
  316. package/server/lib/tts/stt.js +3 -2
  317. package/server/lib/tunnels/DOCUMENTATION.md +2 -0
  318. package/server/lib/tunnels/routes.js +7 -0
  319. package/server/lib/tunnels/routes.test.js +55 -0
  320. package/server/lib/ui-auth/ui-auth.js +38 -2
  321. package/server/lib/ui-auth/ui-auth.test.js +42 -0
  322. package/server/lib/ui-auth/ui-passkeys.js +12 -10
  323. package/server/lib/walkthrough/DOCUMENTATION.md +10 -1
  324. package/server/lib/walkthrough/pull-request.js +61 -8
  325. package/server/lib/walkthrough/pull-request.test.js +54 -1
  326. package/server/lib/walkthrough/routes.js +20 -0
  327. package/server/lib/walkthrough/routes.test.js +19 -0
  328. package/server/opencode-proxy.test.js +190 -166
  329. package/server/opencode-worktree-readiness.test.js +5 -4
  330. package/dist/assets/DiffView-Ce0oBXXQ.js +0 -4
  331. package/dist/assets/FilesView-DtXueAWP.js +0 -13
  332. package/dist/assets/LinearIssuesView-z_9p2GuO.js +0 -1
  333. package/dist/assets/MarkdownImageGallery-BC-BNN-s.js +0 -1
  334. package/dist/assets/MarkdownRendererImpl-DyaBTUbH.js +0 -12
  335. package/dist/assets/OnboardingScreen-DKU_yTb6.js +0 -1
  336. package/dist/assets/PlanView-CrfB4qqY.js +0 -5
  337. package/dist/assets/PluginPane-B5cn-jPy.js +0 -3
  338. package/dist/assets/SettingsView-DMKKwezx.js +0 -29
  339. package/dist/assets/SettingsWindow-DwbnVzOC.js +0 -1
  340. package/dist/assets/SubmoduleDiffSummary-hkGcvs0E.js +0 -1
  341. package/dist/assets/ToolOutputDialog-DuoIOc0j.js +0 -15
  342. package/dist/assets/ToolPartDiffPreview-t1Bvq_2Y.js +0 -8
  343. package/dist/assets/appThemeRegistry-DnOVbJjF.js +0 -1
  344. package/dist/assets/commitAndPush-DLWNZkkY.js +0 -1
  345. package/dist/assets/de-zEHaAIi3.js +0 -10
  346. package/dist/assets/es-CBDgEzgk.js +0 -16
  347. package/dist/assets/fr-DjiTptT_.js +0 -14
  348. package/dist/assets/index-AgOdanig.css +0 -1
  349. package/dist/assets/index-B-2_X4DD.js +0 -40
  350. package/dist/assets/index-CkA4p2IK.js +0 -1
  351. package/dist/assets/ja-CerMgj3r.js +0 -16
  352. package/dist/assets/ko-DHYDAze5.js +0 -16
  353. package/dist/assets/main-BDka4W43.js +0 -896
  354. package/dist/assets/main-Dl7Dyge_.js +0 -2
  355. package/dist/assets/markdownCore-DFmr0rUR.js +0 -5
  356. package/dist/assets/miniChat-CLKQPPpO.js +0 -2
  357. package/dist/assets/mobile--giD2Q1L.js +0 -2
  358. package/dist/assets/patchFileDiff-DRh-AQvd.js +0 -13
  359. package/dist/assets/pl-BTB_93bq.js +0 -16
  360. package/dist/assets/pt-BR-BwA3oyCK.js +0 -16
  361. package/dist/assets/renderElectronMiniChatApp-DmB7zpVK.js +0 -2
  362. package/dist/assets/renderMobileApp-pMfOuQfl.js +0 -25
  363. package/dist/assets/runtimeEndpointReset-Gqhmkm3U.js +0 -25
  364. package/dist/assets/scheduledTasksApi-CeRAIUmW.js +0 -1
  365. package/dist/assets/tr-CcPsJoNM.js +0 -7
  366. package/dist/assets/uk-B68WibXi.js +0 -16
  367. package/dist/assets/useAppFontEffects-DcdrFv2Z.js +0 -7333
  368. package/dist/assets/useInlineCommentController-Cq4SUjsA.js +0 -2
  369. package/dist/assets/useRootScrollLock-CSdR6Wnm.js +0 -2
  370. package/dist/assets/vendor-cron-parser-CUcP7OfX.js +0 -2
  371. package/dist/assets/vendor-opencode-sdk-BJ73u-bH.js +0 -7
  372. package/dist/assets/vendor-zod-CgAdXWZO.js +0 -39
  373. package/dist/assets/zh-CN-DbFHYXwP.js +0 -16
  374. package/dist/assets/zh-TW-DmXAwdty.js +0 -16
  375. package/server/lib/opencode/mcp-oauth-callback.test.js +0 -111
  376. package/server/lib/routing/feature-flag.js +0 -11
  377. package/server/lib/small-model/call.js +0 -851
  378. package/server/lib/small-model/call.test.js +0 -1292
  379. package/server/lib/small-model/catalog.js +0 -13
  380. package/server/lib/small-model/resolve.js +0 -131
  381. package/server/lib/small-model/resolve.test.js +0 -197
  382. package/server/lib/small-model/runtime-providers.js +0 -164
  383. package/server/lib/small-model/runtime-providers.test.js +0 -118
  384. package/server/lib/system-prompt/DOCUMENTATION.md +0 -36
  385. package/server/lib/system-prompt/runtime.js +0 -49
  386. package/server/lib/system-prompt/runtime.test.js +0 -76
  387. package/server/lib/walkthrough/reproduce-2607.test.js +0 -148
@@ -0,0 +1,483 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import {
4
+ permissionMapToRules,
5
+ normalizePermissionRules,
6
+ normalizePermissionAction,
7
+ effectiveAgentRules,
8
+ readGlobalPermissionRules,
9
+ parseModelSelection,
10
+ formatModelSelection,
11
+ toAgentEntity,
12
+ writeWarmingEnabled,
13
+ fromAgentEntity,
14
+ isLegacyAgentFrontmatter,
15
+ toCommandEntity,
16
+ toMcpEntity,
17
+ toProviderEntity,
18
+ toPluginEntity,
19
+ fromPluginEntity,
20
+ readSectionEntry,
21
+ writeSectionEntry,
22
+ deleteSectionEntry,
23
+ readMcpEntries,
24
+ readLayeredMcpEntries,
25
+ writeMcpEntry,
26
+ parseWebSearchSelection,
27
+ writeWebSearchSelection,
28
+ findWebSearchProjectOverride,
29
+ } from './config-v2.js';
30
+
31
+ describe('permission translation', () => {
32
+ it('renames the v1 actions v2 renamed', () => {
33
+ expect(normalizePermissionAction('bash')).toBe('shell');
34
+ expect(normalizePermissionAction('task')).toBe('subagent');
35
+ expect(normalizePermissionAction('write')).toBe('edit');
36
+ expect(normalizePermissionAction('patch')).toBe('edit');
37
+ expect(normalizePermissionAction('read')).toBe('read');
38
+ });
39
+
40
+ it('turns a v1 permission map into an ordered rule array', () => {
41
+ expect(permissionMapToRules({
42
+ bash: { 'git push *': 'ask' },
43
+ edit: 'allow',
44
+ task: 'deny',
45
+ })).toEqual([
46
+ { action: 'shell', resource: 'git push *', effect: 'ask' },
47
+ { action: 'edit', resource: '*', effect: 'allow' },
48
+ { action: 'subagent', resource: '*', effect: 'deny' },
49
+ ]);
50
+ });
51
+
52
+ it('turns a bare v1 permission string into a catch-all rule', () => {
53
+ expect(permissionMapToRules('ask')).toEqual([{ action: '*', resource: '*', effect: 'ask' }]);
54
+ expect(permissionMapToRules('nonsense')).toEqual([]);
55
+ });
56
+
57
+ it('passes a v2 rule array through and drops malformed rules', () => {
58
+ expect(normalizePermissionRules([
59
+ { action: 'shell', resource: '*', effect: 'allow' },
60
+ { action: 'shell', resource: '*', effect: 'maybe' },
61
+ 'nope',
62
+ ])).toEqual([{ action: 'shell', resource: '*', effect: 'allow' }]);
63
+ });
64
+
65
+ it('reads global rules from tools, permission and permissions in normalizer order', () => {
66
+ expect(readGlobalPermissionRules({
67
+ tools: { websearch: false },
68
+ permission: { bash: 'ask' },
69
+ permissions: [{ action: 'read', resource: '*', effect: 'allow' }],
70
+ })).toEqual([
71
+ { action: 'websearch', resource: '*', effect: 'deny' },
72
+ { action: 'shell', resource: '*', effect: 'ask' },
73
+ { action: 'read', resource: '*', effect: 'allow' },
74
+ ]);
75
+ });
76
+
77
+ it('puts global rules before agent rules so the agent wins on a tie', () => {
78
+ expect(effectiveAgentRules(
79
+ [{ action: 'edit', resource: '*', effect: 'allow' }],
80
+ { edit: 'deny' },
81
+ )).toEqual([
82
+ { action: 'edit', resource: '*', effect: 'allow', source: 'global' },
83
+ { action: 'edit', resource: '*', effect: 'deny', source: 'agent' },
84
+ ]);
85
+ });
86
+ });
87
+
88
+ describe('model selection', () => {
89
+ it('splits provider/model#variant', () => {
90
+ expect(parseModelSelection('anthropic/claude-sonnet-4-5#high')).toEqual({
91
+ providerID: 'anthropic',
92
+ modelID: 'claude-sonnet-4-5',
93
+ variant: 'high',
94
+ });
95
+ });
96
+
97
+ it('joins a separate v1 variant onto the model reference', () => {
98
+ expect(formatModelSelection(parseModelSelection('anthropic/claude-sonnet-4-5', 'high')))
99
+ .toBe('anthropic/claude-sonnet-4-5#high');
100
+ });
101
+
102
+ it('rejects references v2 would not parse', () => {
103
+ expect(parseModelSelection('claude-sonnet')).toBeNull();
104
+ expect(parseModelSelection('/model')).toBeNull();
105
+ expect(parseModelSelection('anthropic/')).toBeNull();
106
+ });
107
+ });
108
+
109
+ describe('agent entity', () => {
110
+ it('reads a v1 agent into the v2 shape', () => {
111
+ expect(toAgentEntity({
112
+ prompt: 'Review carefully.',
113
+ model: 'anthropic/claude-sonnet-4-5',
114
+ variant: 'high',
115
+ temperature: 0.7,
116
+ top_p: 0.9,
117
+ maxSteps: 12,
118
+ disable: false,
119
+ permission: { bash: 'ask', edit: 'deny' },
120
+ })).toEqual({
121
+ system: 'Review carefully.',
122
+ model: 'anthropic/claude-sonnet-4-5#high',
123
+ steps: 12,
124
+ disabled: false,
125
+ request: { body: { temperature: 0.7, top_p: 0.9 } },
126
+ permissions: [
127
+ { action: 'shell', resource: '*', effect: 'ask' },
128
+ { action: 'edit', resource: '*', effect: 'deny' },
129
+ ],
130
+ });
131
+ });
132
+
133
+ it('reads a native v2 agent unchanged', () => {
134
+ const native = {
135
+ system: 'Be brief.',
136
+ model: 'openai/gpt-5#low',
137
+ mode: 'subagent',
138
+ hidden: true,
139
+ color: '#aabbcc',
140
+ steps: 4,
141
+ permissions: [{ action: 'read', resource: '*', effect: 'allow' }],
142
+ };
143
+ expect(toAgentEntity(native)).toEqual(native);
144
+ });
145
+
146
+ it('maps a v1 theme color onto the hex OpenCode migrates it to', () => {
147
+ // v2 only decodes `#rrggbb`; OpenCode's migration turns anything else into #aaaaaa.
148
+ expect(toAgentEntity({ color: 'primary' }).color).toBe('#aaaaaa');
149
+ expect(toAgentEntity({ color: '#abc' }).color).toBe('#aaaaaa');
150
+ expect(toAgentEntity({ color: '#AABBCC' }).color).toBe('#AABBCC');
151
+ expect(toAgentEntity({ color: '' }).color).toBeUndefined();
152
+ expect(fromAgentEntity({ color: 'accent', description: 'A' }).fields).toEqual({
153
+ color: '#aaaaaa',
154
+ description: 'A',
155
+ });
156
+ });
157
+
158
+ it('lets the markdown body win over a frontmatter system field', () => {
159
+ expect(toAgentEntity({ system: 'from frontmatter' }, 'from body').system).toBe('from body');
160
+ });
161
+
162
+ it('splits the system prompt out for markdown persistence', () => {
163
+ expect(fromAgentEntity({ system: 'Body text.', description: 'Agent' })).toEqual({
164
+ fields: { description: 'Agent' },
165
+ system: 'Body text.',
166
+ });
167
+ });
168
+
169
+ it('flags frontmatter that OpenCode would route through its v1 decoder', () => {
170
+ expect(isLegacyAgentFrontmatter({ model: 'a/b', permissions: [] })).toBe(false);
171
+ expect(isLegacyAgentFrontmatter({ model: 'a/b', variant: 'high' })).toBe(false);
172
+ expect(isLegacyAgentFrontmatter({ temperature: 0.5 })).toBe(true);
173
+ expect(isLegacyAgentFrontmatter({ permission: { bash: 'ask' } })).toBe(true);
174
+ });
175
+ });
176
+
177
+ describe('command entity', () => {
178
+ it('renames subtask to subagent and joins the variant', () => {
179
+ expect(toCommandEntity({
180
+ template: 'Review the current changes.',
181
+ model: 'anthropic/claude-sonnet-4-5',
182
+ variant: 'high',
183
+ subtask: true,
184
+ })).toEqual({
185
+ template: 'Review the current changes.',
186
+ model: 'anthropic/claude-sonnet-4-5#high',
187
+ subagent: true,
188
+ });
189
+ });
190
+ });
191
+
192
+ describe('mcp entity', () => {
193
+ it('migrates a v1 local server', () => {
194
+ expect(toMcpEntity({
195
+ type: 'local',
196
+ command: ['npx', '@playwright/mcp'],
197
+ enabled: true,
198
+ timeout: 30000,
199
+ })).toEqual({
200
+ type: 'local',
201
+ command: ['npx', '@playwright/mcp'],
202
+ disabled: false,
203
+ timeout: { catalog: 30000, execution: 30000 },
204
+ });
205
+ });
206
+
207
+ it('migrates v1 camelCase OAuth to snake_case', () => {
208
+ expect(toMcpEntity({
209
+ type: 'remote',
210
+ url: 'https://mcp.example.com',
211
+ oauth: { clientId: 'id', clientSecret: 'secret', callbackPort: 4242, redirectUri: 'http://localhost/cb' },
212
+ enabled: false,
213
+ })).toEqual({
214
+ type: 'remote',
215
+ url: 'https://mcp.example.com',
216
+ oauth: {
217
+ client_id: 'id',
218
+ client_secret: 'secret',
219
+ callback_port: 4242,
220
+ redirect_uri: 'http://localhost/cb',
221
+ },
222
+ disabled: true,
223
+ });
224
+ });
225
+
226
+ it('keeps a non-default protocol on both transports', () => {
227
+ expect(toMcpEntity({ type: 'local', command: ['a'], protocol: 'auto' }).protocol).toBe('auto');
228
+ expect(toMcpEntity({
229
+ type: 'remote',
230
+ url: 'https://mcp.example.com',
231
+ protocol: '2026-07-28',
232
+ }).protocol).toBe('2026-07-28');
233
+ });
234
+
235
+ it('drops the protocol key for legacy, for an unknown value and for a removal', () => {
236
+ // The editor saves "legacy" as `null`: absent is what OpenCode calls legacy,
237
+ // so the config file only ever names a non-default negotiation.
238
+ expect(toMcpEntity({ type: 'local', command: ['a'], protocol: null })).not.toHaveProperty('protocol');
239
+ expect(toMcpEntity({ type: 'local', command: ['a'], protocol: 'made-up' })).not.toHaveProperty('protocol');
240
+ expect(toMcpEntity({ type: 'local', command: ['a'], protocol: 'legacy' }).protocol).toBe('legacy');
241
+ });
242
+
243
+ it('keeps auth_server_metadata_url and drops it again when emptied', () => {
244
+ expect(toMcpEntity({
245
+ type: 'remote',
246
+ url: 'https://mcp.example.com',
247
+ oauth: {
248
+ client_id: 'id',
249
+ auth_server_metadata_url: 'https://auth.example.com/.well-known/oauth-authorization-server',
250
+ },
251
+ }).oauth).toEqual({
252
+ client_id: 'id',
253
+ auth_server_metadata_url: 'https://auth.example.com/.well-known/oauth-authorization-server',
254
+ });
255
+
256
+ // An emptied field arrives as '' because the editor rebuilds the whole
257
+ // oauth block; the key must not survive.
258
+ expect(toMcpEntity({
259
+ type: 'remote',
260
+ url: 'https://mcp.example.com',
261
+ oauth: { client_id: 'id', auth_server_metadata_url: ' ' },
262
+ }).oauth).toEqual({ client_id: 'id' });
263
+
264
+ // Nothing left in the block at all removes `oauth` itself.
265
+ expect(toMcpEntity({
266
+ type: 'remote',
267
+ url: 'https://mcp.example.com',
268
+ oauth: { auth_server_metadata_url: '' },
269
+ })).not.toHaveProperty('oauth');
270
+ });
271
+
272
+ it('reads v1 mcp.<name> and v2 mcp.servers, with v2 winning', () => {
273
+ const config = {
274
+ mcp: {
275
+ timeout: { catalog: 1000 },
276
+ legacy: { type: 'local', command: ['a'] },
277
+ shared: { type: 'local', command: ['old'] },
278
+ servers: { shared: { type: 'local', command: ['new'] } },
279
+ },
280
+ };
281
+ const entries = readMcpEntries(config);
282
+ expect([...entries.keys()]).toEqual(['legacy', 'shared']);
283
+ expect(entries.get('shared').value.command).toEqual(['new']);
284
+ });
285
+
286
+ it('applies layer precedence after normalizing each layer', () => {
287
+ // A raw deep merge would leave user `mcp.servers.shared` next to project
288
+ // `mcp.shared`, and the v2 spelling would then shadow the project override.
289
+ const user = { mcp: { servers: { shared: { type: 'remote', url: 'https://global' }, only: { type: 'local', command: ['u'] } } } };
290
+ const project = { mcp: { shared: { type: 'remote', url: 'https://project' } } };
291
+ const entries = readLayeredMcpEntries([user, project]);
292
+ expect(entries.get('shared')).toEqual({
293
+ value: { type: 'remote', url: 'https://project' },
294
+ key: 'mcp',
295
+ legacy: true,
296
+ });
297
+ expect(entries.get('only').value.command).toEqual(['u']);
298
+ expect(readLayeredMcpEntries([project, user]).get('shared').value.url).toBe('https://global');
299
+ });
300
+
301
+ it('rewrites a v1 mcp entry into mcp.servers in place', () => {
302
+ const config = { mcp: { legacy: { type: 'local', command: ['a'] } } };
303
+ writeMcpEntry(config, 'legacy', { type: 'local', command: ['b'] });
304
+ expect(config.mcp).toEqual({ servers: { legacy: { type: 'local', command: ['b'] } } });
305
+ });
306
+ });
307
+
308
+ describe('provider entity', () => {
309
+ it('migrates npm/api/options into package/settings', () => {
310
+ expect(toProviderEntity({
311
+ npm: '@ai-sdk/openai-compatible',
312
+ api: 'https://llm.example.com/v1',
313
+ options: { apiKey: '{env:ACME_API_KEY}', headers: { 'X-A': '1' } },
314
+ })).toEqual({
315
+ package: 'aisdk:@ai-sdk/openai-compatible',
316
+ settings: { apiKey: '{env:ACME_API_KEY}', baseURL: 'https://llm.example.com/v1' },
317
+ headers: { 'X-A': '1' },
318
+ });
319
+ });
320
+
321
+ it('keeps the v2-only canonical and compatibility fields', () => {
322
+ const native = {
323
+ canonical: 'openai',
324
+ name: 'Proxy',
325
+ package: 'aisdk:@ai-sdk/openai-compatible',
326
+ settings: { baseURL: 'https://proxy.example.com/v1' },
327
+ models: {
328
+ m: {
329
+ modelID: 'm',
330
+ name: 'M',
331
+ compatibility: { reasoningField: 'reasoning_content', requireReasoning: true, maxTokensField: 'max_tokens' },
332
+ },
333
+ },
334
+ };
335
+ expect(toProviderEntity(native)).toEqual(native);
336
+ expect(toProviderEntity({ models: { m: { compatibility: {} } } }).models.m).toEqual({});
337
+ });
338
+
339
+ it('migrates v1 interleaved into compatibility.reasoningField', () => {
340
+ const models = toProviderEntity({
341
+ models: {
342
+ text: { interleaved: 'reasoning_text' },
343
+ field: { interleaved: { field: 'reasoning' } },
344
+ flag: { interleaved: true },
345
+ },
346
+ }).models;
347
+ expect(models.text).toEqual({ compatibility: { reasoningField: 'reasoning_text' } });
348
+ expect(models.field).toEqual({ compatibility: { reasoningField: 'reasoning' } });
349
+ expect(models.flag).toEqual({});
350
+ });
351
+
352
+ it('migrates model fields', () => {
353
+ expect(toProviderEntity({
354
+ models: {
355
+ m: {
356
+ id: 'real-model-id',
357
+ name: 'M',
358
+ tool_call: false,
359
+ modalities: { input: ['text'], output: ['text'] },
360
+ status: 'deprecated',
361
+ cost: { input: 1, output: 2, cache_read: 0.1, cache_write: 0.2 },
362
+ variants: { high: { reasoningEffort: 'high' } },
363
+ },
364
+ },
365
+ }).models.m).toEqual({
366
+ modelID: 'real-model-id',
367
+ name: 'M',
368
+ capabilities: { tools: false, input: ['text'], output: ['text'] },
369
+ variants: [{ id: 'high', settings: { reasoningEffort: 'high' } }],
370
+ cost: { input: 1, output: 2, cache: { read: 0.1, write: 0.2 } },
371
+ disabled: true,
372
+ });
373
+ });
374
+ });
375
+
376
+ describe('plugin entity', () => {
377
+ it('accepts v1 strings and tuples and v2 objects', () => {
378
+ expect(toPluginEntity('pkg')).toEqual({ package: 'pkg' });
379
+ expect(toPluginEntity(['pkg', { a: 1 }])).toEqual({ package: 'pkg', options: { a: 1 } });
380
+ expect(toPluginEntity({ package: 'pkg', options: { a: 1 } })).toEqual({ package: 'pkg', options: { a: 1 } });
381
+ expect(toPluginEntity(42)).toBeNull();
382
+ });
383
+
384
+ it('serializes to a bare string or a v2 object, never a tuple', () => {
385
+ expect(fromPluginEntity(['pkg', {}])).toBe('pkg');
386
+ expect(fromPluginEntity(['pkg', { a: 1 }])).toEqual({ package: 'pkg', options: { a: 1 } });
387
+ });
388
+ });
389
+
390
+ describe('config sections', () => {
391
+ it('prefers the v2 key and reports where an entry was found', () => {
392
+ expect(readSectionEntry({ agent: { a: { prompt: 'x' } } }, 'agents', 'a'))
393
+ .toEqual({ value: { prompt: 'x' }, key: 'agent', legacy: true });
394
+ expect(readSectionEntry({ agent: { a: 1 }, agents: { a: 2 } }, 'agents', 'a'))
395
+ .toEqual({ value: 2, key: 'agents', legacy: false });
396
+ });
397
+
398
+ it('rewrites a v1 entry into the v2 key and leaves siblings alone', () => {
399
+ const config = { agent: { a: { prompt: 'x' }, b: { prompt: 'y' } } };
400
+ writeSectionEntry(config, 'agents', 'a', { system: 'x' });
401
+ expect(config).toEqual({ agent: { b: { prompt: 'y' } }, agents: { a: { system: 'x' } } });
402
+ });
403
+
404
+ it('drops the v1 map entirely when its last entry moves', () => {
405
+ const config = { agent: { a: { prompt: 'x' } } };
406
+ writeSectionEntry(config, 'agents', 'a', { system: 'x' });
407
+ expect(config).toEqual({ agents: { a: { system: 'x' } } });
408
+ });
409
+
410
+ it('deletes an entry under either spelling', () => {
411
+ const config = { agent: { a: 1 }, agents: { a: 2 } };
412
+ expect(deleteSectionEntry(config, 'agents', 'a')).toBe(true);
413
+ expect(config).toEqual({});
414
+ });
415
+ });
416
+
417
+ describe('web search choice', () => {
418
+ it('accepts off, remove, random and a provider id, and nothing else', () => {
419
+ expect(parseWebSearchSelection(false)).toBe(false);
420
+ expect(parseWebSearchSelection(null)).toBe(null);
421
+ expect(parseWebSearchSelection('random')).toBe('random');
422
+ expect(parseWebSearchSelection(' exa ')).toBe('exa');
423
+ expect(parseWebSearchSelection('')).toBeUndefined();
424
+ expect(parseWebSearchSelection(true)).toBeUndefined();
425
+ expect(parseWebSearchSelection(undefined)).toBeUndefined();
426
+ expect(parseWebSearchSelection({ provider: 'exa' })).toBeUndefined();
427
+ });
428
+
429
+ it('writes the OpenCode shape and leaves other keys alone', () => {
430
+ const config = { model: 'openai/gpt-5' };
431
+ expect(writeWebSearchSelection(config, 'exa')).toBe(true);
432
+ expect(config).toEqual({ model: 'openai/gpt-5', websearch: { provider: 'exa' } });
433
+ expect(writeWebSearchSelection(config, 'exa')).toBe(false);
434
+ expect(writeWebSearchSelection(config, false)).toBe(true);
435
+ expect(config.websearch).toBe(false);
436
+ expect(writeWebSearchSelection(config, null)).toBe(true);
437
+ expect(config).toEqual({ model: 'openai/gpt-5' });
438
+ expect(writeWebSearchSelection(config, null)).toBe(false);
439
+ });
440
+ });
441
+
442
+ describe('findWebSearchProjectOverride', () => {
443
+ const userPath = '/home/u/.config/opencode/opencode.json';
444
+ const layers = (customConfig = {}) => ({ userConfig: { websearch: false }, projectConfig: {}, customConfig, paths: { userPath, projectPath: null } });
445
+
446
+ it('names the deepest project file that sets websearch', () => {
447
+ const files = [
448
+ { path: '/repo/app/.opencode/opencode.json', config: { plugins: [] } },
449
+ { path: '/repo/opencode.json', config: { websearch: false } },
450
+ ];
451
+ expect(findWebSearchProjectOverride(layers(), files)).toBe('/repo/opencode.json');
452
+ expect(findWebSearchProjectOverride(layers(), [{ path: '/repo/app/opencode.json', config: { websearch: { provider: 'exa' } } }, ...files])).toBe('/repo/app/opencode.json');
453
+ });
454
+
455
+ it('is null when no project file sets websearch', () => {
456
+ expect(findWebSearchProjectOverride(layers(), [{ path: '/repo/opencode.json', config: { model: 'x' } }])).toBeNull();
457
+ expect(findWebSearchProjectOverride(layers(), [])).toBeNull();
458
+ });
459
+
460
+ it('is null when OPENCODE_CONFIG sets websearch too, since it wins', () => {
461
+ expect(findWebSearchProjectOverride(layers({ websearch: { provider: 'exa' } }), [{ path: '/repo/opencode.json', config: { websearch: false } }])).toBeNull();
462
+ });
463
+
464
+ it('ignores the user config showing up among project files', () => {
465
+ expect(findWebSearchProjectOverride(layers(), [{ path: userPath, config: { websearch: false } }])).toBeNull();
466
+ });
467
+ });
468
+
469
+ describe('session warming', () => {
470
+ it('turns warming on and off, keeping a hand-tuned object', () => {
471
+ const config = { model: 'openai/gpt-5' };
472
+ expect(writeWarmingEnabled(config, true)).toBe(true);
473
+ expect(config.warming).toBe(true);
474
+ expect(writeWarmingEnabled(config, true)).toBe(false);
475
+ expect(writeWarmingEnabled(config, false)).toBe(true);
476
+ expect(config).toEqual({ model: 'openai/gpt-5' });
477
+ expect(writeWarmingEnabled(config, false)).toBe(false);
478
+
479
+ const tuned = { warming: { interval: '3 minutes' } };
480
+ expect(writeWarmingEnabled(tuned, true)).toBe(false);
481
+ expect(tuned.warming).toEqual({ interval: '3 minutes' });
482
+ });
483
+ });
@@ -94,6 +94,7 @@ export const registerServerStatusRoutes = (app, dependencies) => {
94
94
  'api.health.v1',
95
95
  'api.runtime-url.v1',
96
96
  'api.raw-file.v1',
97
+ 'api.notifications.emit.v1',
97
98
  'realtime.sse.v1',
98
99
  'realtime.websocket.global-events.v1',
99
100
  'terminal.websocket.v1',
@@ -1093,6 +1094,8 @@ export const registerCommonRequestMiddleware = (app, dependencies) => {
1093
1094
  req.path.startsWith('/api/config/settings') ||
1094
1095
  req.path.startsWith('/api/config/skills') ||
1095
1096
  req.path.startsWith('/api/config/plugins') ||
1097
+ req.path.startsWith('/api/config/websearch') ||
1098
+ req.path.startsWith('/api/config/warming') ||
1096
1099
  req.path.startsWith('/api/projects') ||
1097
1100
  req.path.startsWith('/api/fs') ||
1098
1101
  req.path.startsWith('/api/git') ||
@@ -127,6 +127,21 @@ describe('core-routes', () => {
127
127
  expect(response.body).toEqual({ body: { content: 'Snippet body' } });
128
128
  });
129
129
 
130
+ it('should parse JSON bodies for the web search config route', async () => {
131
+ const app = express();
132
+ registerCommonRequestMiddleware(app, { express });
133
+ app.put('/api/config/websearch', (req, res) => {
134
+ res.json({ body: req.body });
135
+ });
136
+
137
+ const response = await request(app)
138
+ .put('/api/config/websearch')
139
+ .send({ selection: 'random' })
140
+ .expect(200);
141
+
142
+ expect(response.body).toEqual({ body: { selection: 'random' } });
143
+ });
144
+
130
145
  it('should parse JSON bodies for custom provider upsert routes', async () => {
131
146
  const app = express();
132
147
  registerCommonRequestMiddleware(app, { express });
@@ -0,0 +1,144 @@
1
+ /**
2
+ * READ-ONLY view of the credentials OpenCode 2.x keeps in its SQLite database.
3
+ *
4
+ * OpenCode 2.x imports the legacy `auth.json` once and from then on stores
5
+ * every credential in `<data>/opencode.db`, table `credential`, as plain JSON.
6
+ * There is no HTTP route that hands a key back, so the quota providers and
7
+ * voice keys would only ever see credentials that predate the upgrade. This
8
+ * module reads the table directly and projects each row into the legacy
9
+ * `auth.json` entry shape the rest of the server already understands, so a
10
+ * key added through OpenCode after the upgrade works like one that was
11
+ * imported. The database is opened read-only and never written.
12
+ *
13
+ * The table layout is OpenCode's private schema (verified against v2.0.x
14
+ * `packages/core/src/credential/sql.ts`); a schema change makes this reader
15
+ * return null and the caller falls back to `auth.json`.
16
+ *
17
+ * `node:sqlite` ships with Node 22.13+, `bun:sqlite` with Bun; a runtime
18
+ * without either also falls back to the file, silently.
19
+ */
20
+
21
+ import { createRequire } from 'node:module';
22
+
23
+ const DB_FILE_NAME = 'opencode.db';
24
+
25
+ /**
26
+ * A minimal read-only connection: `all(sql)` and `close()`. Node provides it
27
+ * through `node:sqlite`, Bun through `bun:sqlite`; both are built in. Neither
28
+ * being available yields null and the caller falls back to `auth.json`.
29
+ */
30
+ let openConnection;
31
+ const loadSqlite = () => {
32
+ if (openConnection !== undefined) return openConnection;
33
+ const require = createRequire(import.meta.url);
34
+ openConnection = null;
35
+ try {
36
+ const node = typeof process.getBuiltinModule === 'function' ? process.getBuiltinModule('node:sqlite') : null;
37
+ const { DatabaseSync } = node ?? require('node:sqlite');
38
+ if (typeof DatabaseSync === 'function') {
39
+ openConnection = (dbPath) => {
40
+ const db = new DatabaseSync(dbPath, { readOnly: true });
41
+ return { all: (sql) => db.prepare(sql).all(), close: () => db.close() };
42
+ };
43
+ return openConnection;
44
+ }
45
+ } catch {
46
+ // Not Node, or a Node without node:sqlite; try Bun next.
47
+ }
48
+ try {
49
+ const { Database } = require('bun:sqlite');
50
+ if (typeof Database === 'function') {
51
+ openConnection = (dbPath) => {
52
+ const db = new Database(dbPath, { readonly: true });
53
+ return { all: (sql) => db.query(sql).all(), close: () => db.close() };
54
+ };
55
+ }
56
+ } catch {
57
+ // No sqlite runtime at all.
58
+ }
59
+ return openConnection;
60
+ };
61
+
62
+ /**
63
+ * Where OpenCode keeps its database: `OPENCODE_DB` when set (absolute or
64
+ * relative to the data dir), else `opencode.db` in the data dir.
65
+ * @param {{ dataDir: string, env?: NodeJS.ProcessEnv, path: typeof import('node:path') }} options
66
+ */
67
+ export const resolveCredentialDbPath = ({ dataDir, env = process.env, path }) => {
68
+ const configured = (env.OPENCODE_DB ?? '').trim();
69
+ if (configured && configured !== ':memory:') return path.resolve(dataDir, configured);
70
+ return path.join(dataDir, DB_FILE_NAME);
71
+ };
72
+
73
+ /**
74
+ * Project one stored `credential.value` into the legacy `auth.json` entry
75
+ * shape (`{ type: 'api', key }` / `{ type: 'oauth', access, refresh, expires }`).
76
+ * Returns null for a value this reader does not understand.
77
+ */
78
+ export const projectCredentialValue = (raw) => {
79
+ let value;
80
+ try {
81
+ value = typeof raw === 'string' ? JSON.parse(raw) : raw;
82
+ } catch {
83
+ return null;
84
+ }
85
+ if (!value || typeof value !== 'object') return null;
86
+ if (value.type === 'key' && typeof value.key === 'string') {
87
+ const entry = { type: 'api', key: value.key };
88
+ if (value.metadata && typeof value.metadata === 'object') entry.metadata = value.metadata;
89
+ return entry;
90
+ }
91
+ if (value.type === 'oauth' && typeof value.access === 'string' && typeof value.refresh === 'string') {
92
+ const entry = { type: 'oauth', access: value.access, refresh: value.refresh, expires: Number(value.expires) || 0 };
93
+ const metadata = value.metadata && typeof value.metadata === 'object' ? value.metadata : {};
94
+ if (typeof metadata.accountID === 'string') entry.accountId = metadata.accountID;
95
+ if (typeof metadata.enterpriseUrl === 'string') entry.enterpriseUrl = metadata.enterpriseUrl;
96
+ return entry;
97
+ }
98
+ return null;
99
+ };
100
+
101
+ /**
102
+ * Read every integration's selected credential from the database.
103
+ *
104
+ * An integration may hold several credentials; the one OpenCode uses is the
105
+ * `active` row, else the most recently updated one, which mirrors how
106
+ * OpenCode itself picks. The result is keyed by integration id, which for
107
+ * providers is the provider id (`openai`, `github-copilot`, ...).
108
+ *
109
+ * @returns {Record<string, object> | null} null when the database or the
110
+ * sqlite runtime is unavailable, so the caller can tell "no credentials"
111
+ * from "could not look".
112
+ */
113
+ export const readCredentialsFromDb = ({ dbPath, fs }) => {
114
+ const open = loadSqlite();
115
+ if (!open) return null;
116
+ if (!fs.existsSync(dbPath)) return null;
117
+
118
+ let db;
119
+ try {
120
+ db = open(dbPath);
121
+ const rows = db.all(
122
+ 'SELECT integration_id, value, active, time_updated FROM credential ' +
123
+ 'WHERE integration_id IS NOT NULL ' +
124
+ 'ORDER BY integration_id, active DESC, time_updated DESC',
125
+ );
126
+ const result = {};
127
+ for (const row of rows) {
128
+ const id = typeof row.integration_id === 'string' ? row.integration_id : '';
129
+ if (!id || id in result) continue;
130
+ const entry = projectCredentialValue(row.value);
131
+ if (entry) result[id] = entry;
132
+ }
133
+ return result;
134
+ } catch (error) {
135
+ console.warn('Could not read OpenCode credentials database:', error instanceof Error ? error.message : error);
136
+ return null;
137
+ } finally {
138
+ try {
139
+ db?.close();
140
+ } catch {
141
+ // The connection is read-only; a failed close changes nothing.
142
+ }
143
+ }
144
+ };