@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,168 @@
1
+ import fs from 'node:fs/promises';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+ import { afterEach, describe, expect, it, vi } from 'vitest';
5
+
6
+ import { createManagedConfigRuntime, MANAGED_CONFIG_FILE_NAME } from './managed-config-file.js';
7
+
8
+ const temporaryDirectories = [];
9
+
10
+ afterEach(async () => {
11
+ await Promise.all(temporaryDirectories.splice(0).map((directory) => fs.rm(directory, { recursive: true, force: true })));
12
+ });
13
+
14
+ const createHarness = async ({ settings = {}, env = {}, memoryAvailable = true } = {}) => {
15
+ const dataDir = await fs.mkdtemp(path.join(os.tmpdir(), 'openchamber-managed-config-'));
16
+ temporaryDirectories.push(dataDir);
17
+ const agentToolRuntime = {
18
+ pluginDirectory: path.join(dataDir, 'agent-tool', 'openchamber-agent-tool'),
19
+ materializePlugin: vi.fn(async (flags) => {
20
+ await fs.mkdir(agentToolRuntime.pluginDirectory, { recursive: true });
21
+ await fs.writeFile(path.join(agentToolRuntime.pluginDirectory, 'flags.json'), JSON.stringify(flags));
22
+ return agentToolRuntime.pluginDirectory;
23
+ }),
24
+ createChildEnv: vi.fn(() => ({
25
+ OPENCHAMBER_AGENT_TOOL_URL: 'http://127.0.0.1:3901/api/openchamber/agent-tool',
26
+ OPENCHAMBER_AGENT_TOOL_TOKEN: 'token',
27
+ })),
28
+ };
29
+ const current = { settings };
30
+ const runtime = createManagedConfigRuntime({
31
+ fsPromises: fs,
32
+ path,
33
+ dataDir,
34
+ env,
35
+ agentToolRuntime,
36
+ readSettings: () => current.settings,
37
+ isAgentMemoryAvailable: () => memoryAvailable,
38
+ });
39
+ const readConfigFile = async () => JSON.parse(await fs.readFile(path.join(dataDir, MANAGED_CONFIG_FILE_NAME), 'utf8'));
40
+ return { dataDir, runtime, agentToolRuntime, current, readConfigFile };
41
+ };
42
+
43
+ describe('managed OpenCode config file', () => {
44
+ it('points the child at a config file listing the enabled plugins', async () => {
45
+ const { dataDir, runtime, readConfigFile } = await createHarness({
46
+ settings: {},
47
+ });
48
+
49
+ const childEnv = await runtime.buildManagedChildEnv();
50
+
51
+ expect(childEnv.OPENCODE_CONFIG).toBe(path.join(dataDir, MANAGED_CONFIG_FILE_NAME));
52
+ expect(childEnv.OPENCODE_CONFIG_CONTENT).toBeUndefined();
53
+ expect(childEnv.OPENCHAMBER_AGENT_TOOL_TOKEN).toBe('token');
54
+ expect(await readConfigFile()).toEqual({
55
+ plugins: ['-opencode.browser', path.join(dataDir, 'agent-tool', 'openchamber-agent-tool')],
56
+ });
57
+ });
58
+
59
+ it('materializes every listed plugin directory before naming it', async () => {
60
+ const { runtime, readConfigFile } = await createHarness({ settings: {} });
61
+
62
+ await runtime.buildManagedChildEnv();
63
+
64
+ for (const directory of (await readConfigFile()).plugins.filter((entry) => !entry.startsWith('-'))) {
65
+ expect((await fs.stat(directory)).isDirectory()).toBe(true);
66
+ }
67
+ });
68
+
69
+ it('keeps the callback token in the child env while every tool is off', async () => {
70
+ const { runtime, agentToolRuntime, readConfigFile } = await createHarness({
71
+ settings: { agentControlToolEnabled: false, agentWebToolEnabled: false, agentMemoryToolEnabled: false },
72
+ });
73
+
74
+ const childEnv = await runtime.buildManagedChildEnv();
75
+
76
+ expect(agentToolRuntime.materializePlugin).not.toHaveBeenCalled();
77
+ expect(await readConfigFile()).toEqual({ plugins: ['-opencode.browser'] });
78
+ // A tool switched on later reaches a process that can already call back.
79
+ expect(childEnv.OPENCHAMBER_AGENT_TOOL_TOKEN).toBe('token');
80
+ });
81
+
82
+ it('rewrites the file when a tool is turned off, without a new token', async () => {
83
+ const { dataDir, runtime, current, agentToolRuntime, readConfigFile } = await createHarness({
84
+ settings: {},
85
+ });
86
+ await runtime.buildManagedChildEnv();
87
+
88
+ current.settings = { agentControlToolEnabled: false, agentWebToolEnabled: false };
89
+ expect(await runtime.refreshManagedConfigFile()).toEqual({ updated: true });
90
+
91
+ const { plugins } = await readConfigFile();
92
+ expect(plugins).toEqual(['-opencode.browser']);
93
+ expect(agentToolRuntime.createChildEnv).toHaveBeenCalledTimes(1);
94
+ });
95
+
96
+ it('turns a tool back on without a restart', async () => {
97
+ const { runtime, current, agentToolRuntime, readConfigFile } = await createHarness({
98
+ settings: { agentControlToolEnabled: false, agentWebToolEnabled: false },
99
+ });
100
+ await runtime.buildManagedChildEnv();
101
+
102
+ current.settings = { agentControlToolEnabled: false, agentWebToolEnabled: true };
103
+ await runtime.refreshManagedConfigFile();
104
+
105
+ expect((await readConfigFile()).plugins).toHaveLength(2);
106
+ expect(agentToolRuntime.materializePlugin).toHaveBeenCalledWith({
107
+ includeControl: false,
108
+ includeWeb: true,
109
+ includeMemory: false,
110
+ includeNotify: false,
111
+ });
112
+ });
113
+
114
+ it('injects the notify tool only when it is switched on', async () => {
115
+ const { runtime, agentToolRuntime } = await createHarness({
116
+ settings: { agentControlToolEnabled: false, agentWebToolEnabled: false, agentNotifyToolEnabled: true },
117
+ });
118
+
119
+ await runtime.buildManagedChildEnv();
120
+
121
+ expect(agentToolRuntime.materializePlugin).toHaveBeenCalledWith({
122
+ includeControl: false,
123
+ includeWeb: false,
124
+ includeMemory: false,
125
+ includeNotify: true,
126
+ });
127
+ });
128
+
129
+ it('leaves a config file the user owns alone and keeps the restart requirement', async () => {
130
+ const { dataDir, runtime } = await createHarness({
131
+ settings: {},
132
+ env: { OPENCODE_CONFIG: '/home/user/opencode.json', OPENCODE_CONFIG_CONTENT: '{"model":"test/model"}' },
133
+ });
134
+
135
+ const childEnv = await runtime.buildManagedChildEnv();
136
+
137
+ expect(childEnv.OPENCODE_CONFIG).toBeUndefined();
138
+ expect(JSON.parse(childEnv.OPENCODE_CONFIG_CONTENT)).toEqual({
139
+ model: 'test/model',
140
+ plugins: ['-opencode.browser', path.join(dataDir, 'agent-tool', 'openchamber-agent-tool')],
141
+ });
142
+ await expect(fs.stat(path.join(dataDir, MANAGED_CONFIG_FILE_NAME))).rejects.toThrow();
143
+ expect(await runtime.refreshManagedConfigFile()).toEqual({ updated: false, reason: 'external-config' });
144
+ });
145
+
146
+ it('leaves no temp file behind and never publishes a partial list', async () => {
147
+ const { dataDir, runtime } = await createHarness({ settings: {} });
148
+
149
+ await runtime.buildManagedChildEnv();
150
+ await runtime.refreshManagedConfigFile();
151
+
152
+ const entries = await fs.readdir(dataDir);
153
+ expect(entries.filter((entry) => entry.includes('.tmp-'))).toEqual([]);
154
+ expect(entries).toContain(MANAGED_CONFIG_FILE_NAME);
155
+ });
156
+
157
+ it('ignores the memory tool while the feature is unavailable', async () => {
158
+ const { runtime, agentToolRuntime, readConfigFile } = await createHarness({
159
+ settings: { agentControlToolEnabled: false, agentWebToolEnabled: false, agentMemoryToolEnabled: true },
160
+ memoryAvailable: false,
161
+ });
162
+
163
+ await runtime.buildManagedChildEnv();
164
+
165
+ expect(agentToolRuntime.materializePlugin).not.toHaveBeenCalled();
166
+ expect(await readConfigFile()).toEqual({ plugins: ['-opencode.browser'] });
167
+ });
168
+ });
@@ -2,34 +2,54 @@ import { parse as parseJsonc } from 'jsonc-parser';
2
2
 
3
3
  const isJsonObject = (value) => value !== null && value !== undefined && Object.getPrototypeOf(value) === Object.prototype;
4
4
 
5
+ const matchesEntry = (value, pluginDirectory) => (
6
+ value === pluginDirectory || (Array.isArray(value) && value[0] === pluginDirectory)
7
+ );
8
+
5
9
  /**
6
- * Append a managed OpenChamber plugin to the `plugin` list of an
10
+ * Append a managed OpenChamber plugin to the `plugins` list of an
7
11
  * `OPENCODE_CONFIG_CONTENT` value.
8
12
  *
9
- * Existing entries are preserved; an earlier entry for the same URL is dropped
10
- * so a restart never registers the same plugin twice. Every managed plugin
11
- * (agent tools, system prompt optimizer) goes through this one
12
- * merge so they compose in any order.
13
+ * OpenCode 2 loads a configured plugin from a DIRECTORY that carries a
14
+ * `package.json` resolving an entrypoint; a path to a single `.js` file is
15
+ * rejected with "configured plugin path must be a directory". So the value
16
+ * merged here is an absolute directory path, not a `file://` URL.
17
+ *
18
+ * Existing entries are preserved and an earlier entry for the same directory is
19
+ * dropped, so a restart never registers the same plugin twice. A legacy
20
+ * `plugin` key is folded into `plugins` and removed: OpenCode still decodes it,
21
+ * but keeping two keys would mean two places to dedupe against.
22
+ *
23
+ * This is the FALLBACK path only, taken when the user's own environment owns
24
+ * `OPENCODE_CONFIG`. Otherwise managed plugins are published through the
25
+ * watched config file in `managed-config-file.js`, which is what makes a
26
+ * managed-tool toggle apply without a restart.
13
27
  *
14
28
  * @param {string | undefined} rawConfig the current `OPENCODE_CONFIG_CONTENT`, JSONC or unset
15
- * @param {string} pluginUrl `file://` URL of the materialized plugin
29
+ * @param {string} pluginDirectory absolute path of the materialized plugin directory
16
30
  * @param {string} purpose short noun phrase for the error message, e.g. "managed tool"
17
31
  * @returns {string} the merged config as JSON
18
32
  */
19
- export const appendManagedPlugin = (rawConfig, pluginUrl, purpose) => {
33
+ export const appendManagedPlugin = (rawConfig, pluginDirectory, purpose) => {
20
34
  const errors = [];
21
35
  const text = (rawConfig ?? '').trim();
22
36
  const parsed = text ? parseJsonc(text, errors, { allowTrailingComma: true }) : {};
23
37
  if (errors.length > 0 || !isJsonObject(parsed)) {
24
38
  throw new Error(`OPENCODE_CONFIG_CONTENT must contain a valid JSON object before OpenChamber can inject its ${purpose}`);
25
39
  }
26
- if (parsed.plugin !== undefined && !Array.isArray(parsed.plugin)) {
27
- throw new Error(`OPENCODE_CONFIG_CONTENT plugin must be an array before OpenChamber can inject its ${purpose}`);
40
+ for (const key of ['plugin', 'plugins']) {
41
+ if (parsed[key] !== undefined && !Array.isArray(parsed[key])) {
42
+ throw new Error(`OPENCODE_CONFIG_CONTENT ${key} must be an array before OpenChamber can inject its ${purpose}`);
43
+ }
28
44
  }
29
- const configured = Array.isArray(parsed.plugin) ? parsed.plugin : [];
30
- parsed.plugin = [
31
- ...configured.filter((value) => value !== pluginUrl && (!Array.isArray(value) || value[0] !== pluginUrl)),
32
- pluginUrl,
45
+ const configured = [
46
+ ...(Array.isArray(parsed.plugin) ? parsed.plugin : []),
47
+ ...(Array.isArray(parsed.plugins) ? parsed.plugins : []),
48
+ ];
49
+ delete parsed.plugin;
50
+ parsed.plugins = [
51
+ ...configured.filter((value) => !matchesEntry(value, pluginDirectory)),
52
+ pluginDirectory,
33
53
  ];
34
54
  return JSON.stringify(parsed);
35
55
  };
@@ -9,8 +9,19 @@ import {
9
9
  getJsonWriteTarget,
10
10
  writeConfig,
11
11
  } from './shared.js';
12
+ import {
13
+ toMcpEntity,
14
+ readLayeredMcpEntries,
15
+ writeMcpEntry,
16
+ deleteMcpEntry,
17
+ } from './config-v2.js';
12
18
 
13
19
  // ============== MCP CONFIG HELPERS ==============
20
+ //
21
+ // OpenCode 2 keeps servers under `mcp.servers`; v1 kept them directly under
22
+ // `mcp`. OpenChamber reads both and always writes `mcp.servers` with the v2
23
+ // entry shape (`disabled`, `timeout: {catalog, execution}`, snake_case OAuth,
24
+ // required `type`).
14
25
 
15
26
  /**
16
27
  * Validate MCP server name
@@ -24,9 +35,6 @@ function validateMcpName(name) {
24
35
  }
25
36
  }
26
37
 
27
- /**
28
- * List all MCP server configs from user-level opencode.json
29
- */
30
38
  function resolveMcpScopeFromPath(layers, sourcePath) {
31
39
  if (!sourcePath) return null;
32
40
  return sourcePath === layers.paths.projectPath ? AGENT_SCOPE.PROJECT : AGENT_SCOPE.USER;
@@ -40,20 +48,23 @@ function ensureProjectMcpConfigPath(workingDirectory) {
40
48
  return path.join(configDir, 'opencode.json');
41
49
  }
42
50
 
51
+ /** Same precedence as `getJsonEntrySource`: custom > project > user. */
52
+ function readMcpEntriesAcrossLayers(layers) {
53
+ return readLayeredMcpEntries([layers?.userConfig, layers?.projectConfig, layers?.customConfig]);
54
+ }
55
+
43
56
  function listMcpConfigs(workingDirectory) {
44
57
  const layers = readConfigLayers(workingDirectory);
45
- const mcp = layers?.mergedConfig?.mcp || {};
46
-
47
- return Object.entries(mcp)
48
- .filter(([, entry]) => entry && typeof entry === 'object' && !Array.isArray(entry))
49
- .map(([name, entry]) => {
50
- const source = getJsonEntrySource(layers, 'mcp', name);
51
- return {
52
- name,
53
- ...buildMcpEntry(entry),
54
- scope: resolveMcpScopeFromPath(layers, source.path),
55
- };
56
- });
58
+ return Array.from(readMcpEntriesAcrossLayers(layers).entries()).map(([name, entry]) => {
59
+ const source = getJsonEntrySource(layers, 'mcp', name);
60
+ return {
61
+ name,
62
+ ...toMcpEntity(entry.value),
63
+ scope: resolveMcpScopeFromPath(layers, source.path),
64
+ sectionKey: source.sectionKey,
65
+ legacy: Boolean(source.legacy),
66
+ };
67
+ });
57
68
  }
58
69
 
59
70
  /**
@@ -61,7 +72,7 @@ function listMcpConfigs(workingDirectory) {
61
72
  */
62
73
  function getMcpConfig(name, workingDirectory) {
63
74
  const layers = readConfigLayers(workingDirectory);
64
- const entry = layers?.mergedConfig?.mcp?.[name];
75
+ const entry = readMcpEntriesAcrossLayers(layers).get(name);
65
76
 
66
77
  if (!entry) {
67
78
  return null;
@@ -69,8 +80,10 @@ function getMcpConfig(name, workingDirectory) {
69
80
  const source = getJsonEntrySource(layers, 'mcp', name);
70
81
  return {
71
82
  name,
72
- ...buildMcpEntry(entry),
83
+ ...toMcpEntity(entry.value),
73
84
  scope: resolveMcpScopeFromPath(layers, source.path),
85
+ sectionKey: source.sectionKey,
86
+ legacy: Boolean(source.legacy),
74
87
  };
75
88
  }
76
89
 
@@ -81,8 +94,7 @@ function createMcpConfig(name, mcpConfig, workingDirectory, scope) {
81
94
  validateMcpName(name);
82
95
 
83
96
  const layers = readConfigLayers(workingDirectory);
84
- const source = getJsonEntrySource(layers, 'mcp', name);
85
- if (source.exists) {
97
+ if (getJsonEntrySource(layers, 'mcp', name).exists) {
86
98
  throw new Error(`MCP server "${name}" already exists`);
87
99
  }
88
100
 
@@ -101,19 +113,17 @@ function createMcpConfig(name, mcpConfig, workingDirectory, scope) {
101
113
  config = jsonTarget.config || {};
102
114
  }
103
115
 
104
- if (!config.mcp || typeof config.mcp !== 'object' || Array.isArray(config.mcp)) {
105
- config.mcp = {};
106
- }
107
-
108
- const { name: _ignoredName, ...entryData } = mcpConfig;
109
- config.mcp[name] = buildMcpEntry(entryData);
116
+ const { name: _ignoredName, scope: _ignoredScope, ...entryData } = mcpConfig || {};
117
+ writeMcpEntry(config, name, toMcpEntity(entryData));
110
118
 
111
119
  writeConfig(config, targetPath);
112
120
  console.log(`Created MCP server config: ${name}`);
121
+ return { path: targetPath };
113
122
  }
114
123
 
115
124
  /**
116
- * Update an existing MCP server config entry
125
+ * Update an existing MCP server config entry. A server still stored under the
126
+ * v1 `mcp.<name>` key is rewritten into `mcp.servers` in the same file.
117
127
  */
118
128
  function updateMcpConfig(name, updates, workingDirectory) {
119
129
  const layers = readConfigLayers(workingDirectory);
@@ -126,17 +136,13 @@ function updateMcpConfig(name, updates, workingDirectory) {
126
136
  const targetPath = source.path || CONFIG_FILE;
127
137
  const config = source.config || (fs.existsSync(targetPath) ? readConfigFile(targetPath) : {});
128
138
 
129
- if (!config.mcp || typeof config.mcp !== 'object' || Array.isArray(config.mcp)) {
130
- config.mcp = {};
131
- }
132
-
133
- const existing = config.mcp[name];
134
- const { name: _ignoredName, ...updateData } = updates;
135
-
136
- config.mcp[name] = buildMcpEntry({ ...existing, ...updateData });
139
+ const existing = toMcpEntity(source.section);
140
+ const { name: _ignoredName, scope: _ignoredScope, ...updateData } = updates || {};
141
+ writeMcpEntry(config, name, toMcpEntity({ ...existing, ...updateData }));
137
142
 
138
143
  writeConfig(config, targetPath);
139
- console.log(`Updated MCP server config: ${name}`);
144
+ console.log(`Updated MCP server config: ${name} (${targetPath})`);
145
+ return { path: targetPath };
140
146
  }
141
147
 
142
148
  /**
@@ -148,125 +154,13 @@ function deleteMcpConfig(name, workingDirectory) {
148
154
  const targetPath = source.path || CONFIG_FILE;
149
155
  const config = source.config || (fs.existsSync(targetPath) ? readConfigFile(targetPath) : {});
150
156
 
151
- if (!config.mcp || typeof config.mcp !== 'object' || config.mcp[name] === undefined) {
157
+ if (!deleteMcpEntry(config, name)) {
152
158
  throw new Error(`MCP server "${name}" not found`);
153
159
  }
154
160
 
155
- delete config.mcp[name];
156
-
157
- if (Object.keys(config.mcp).length === 0) {
158
- delete config.mcp;
159
- }
160
-
161
161
  writeConfig(config, targetPath);
162
162
  console.log(`Deleted MCP server config: ${name}`);
163
- }
164
-
165
- /**
166
- * Build a clean MCP entry object, omitting undefined/null values
167
- */
168
- function buildMcpEntry(data) {
169
- const entry = (data && typeof data === 'object' && !Array.isArray(data))
170
- ? { ...data }
171
- : {};
172
-
173
- delete entry.name;
174
- delete entry.scope;
175
-
176
- // type is required
177
- entry.type = data.type === 'remote' ? 'remote' : 'local';
178
-
179
- if (entry.type === 'local') {
180
- // command must be a non-empty array of strings
181
- if (Array.isArray(data.command) && data.command.length > 0) {
182
- entry.command = data.command.map(String);
183
- } else {
184
- delete entry.command;
185
- }
186
-
187
- delete entry.url;
188
- delete entry.headers;
189
- delete entry.oauth;
190
- delete entry.timeout;
191
- } else {
192
- // remote: url required
193
- if (data.url && typeof data.url === 'string') {
194
- entry.url = data.url.trim();
195
- } else {
196
- delete entry.url;
197
- }
198
-
199
- delete entry.command;
200
-
201
- if (data.headers && typeof data.headers === 'object' && !Array.isArray(data.headers)) {
202
- const cleaned = {};
203
- for (const [k, v] of Object.entries(data.headers)) {
204
- if (k && v !== undefined && v !== null) {
205
- cleaned[k] = String(v);
206
- }
207
- }
208
- if (Object.keys(cleaned).length > 0) {
209
- entry.headers = cleaned;
210
- } else {
211
- delete entry.headers;
212
- }
213
- } else if (data.headers === undefined) {
214
- delete entry.headers;
215
- }
216
-
217
- if (data.oauth === false) {
218
- entry.oauth = false;
219
- } else if (data.oauth && typeof data.oauth === 'object' && !Array.isArray(data.oauth)) {
220
- const oauth = {};
221
- if (typeof data.oauth.clientId === 'string' && data.oauth.clientId.trim()) {
222
- oauth.clientId = data.oauth.clientId.trim();
223
- }
224
- if (typeof data.oauth.clientSecret === 'string' && data.oauth.clientSecret.trim()) {
225
- oauth.clientSecret = data.oauth.clientSecret.trim();
226
- }
227
- if (typeof data.oauth.scope === 'string' && data.oauth.scope.trim()) {
228
- oauth.scope = data.oauth.scope.trim();
229
- }
230
- if (typeof data.oauth.redirectUri === 'string' && data.oauth.redirectUri.trim()) {
231
- oauth.redirectUri = data.oauth.redirectUri.trim();
232
- }
233
- if (Object.keys(oauth).length > 0) {
234
- entry.oauth = oauth;
235
- } else {
236
- delete entry.oauth;
237
- }
238
- } else if (data.oauth === undefined) {
239
- delete entry.oauth;
240
- }
241
-
242
- if (typeof data.timeout === 'number' && Number.isFinite(data.timeout) && data.timeout > 0) {
243
- entry.timeout = data.timeout;
244
- } else if (data.timeout === undefined || data.timeout === null || data.timeout === '') {
245
- delete entry.timeout;
246
- }
247
- }
248
-
249
- // environment: flat Record<string, string>
250
- if (data.environment && typeof data.environment === 'object' && !Array.isArray(data.environment)) {
251
- const cleaned = {};
252
- for (const [k, v] of Object.entries(data.environment)) {
253
- if (k && v !== undefined && v !== null) {
254
- cleaned[k] = String(v);
255
- }
256
- }
257
- if (Object.keys(cleaned).length > 0) {
258
- entry.environment = cleaned;
259
- } else {
260
- delete entry.environment;
261
- }
262
- } else if (data.environment === undefined) {
263
- delete entry.environment;
264
- }
265
-
266
- // enabled defaults to true
267
- entry.enabled = data.enabled !== false;
268
-
269
- return entry;
163
+ return { path: targetPath };
270
164
  }
271
165
 
272
166
  export {
@@ -1,3 +1,4 @@
1
+ import { readOpenCodeInfo, isSupportedOpenCodeVersion } from './compatibility.js';
1
2
  export const createOpenCodeNetworkRuntime = (deps) => {
2
3
  const {
3
4
  state,
@@ -46,7 +47,9 @@ export const createOpenCodeNetworkRuntime = (deps) => {
46
47
  try {
47
48
  const controller = new AbortController();
48
49
  timeout = setTimeout(() => controller.abort(), 3000);
49
- const response = await fetch(`${url.replace(/\/+$/, '')}/global/health`, {
50
+ // OpenCode 2.0.8 replaced `/api/health` with `/api/info`: a 200 is the
51
+ // readiness signal, the payload carries no `healthy` field.
52
+ const response = await fetch(`${url.replace(/\/+$/, '')}/api/info`, {
50
53
  method: 'GET',
51
54
  headers: {
52
55
  Accept: 'application/json',
@@ -57,12 +60,8 @@ export const createOpenCodeNetworkRuntime = (deps) => {
57
60
  clearTimeout(timeout);
58
61
  timeout = null;
59
62
 
60
- if (response.ok) {
61
- const body = await response.json().catch(() => null);
62
- if (body?.healthy === true) {
63
- return true;
64
- }
65
- }
63
+ const info = await readOpenCodeInfo(response);
64
+ if (info && isSupportedOpenCodeVersion(info.version)) return true;
66
65
  } catch {
67
66
  } finally {
68
67
  if (timeout) {
@@ -71,6 +71,26 @@ export const registerOpenChamberRoutes = (app, dependencies) => {
71
71
 
72
72
  let desktopRestartError = null;
73
73
 
74
+ /**
75
+ * How this server was launched, read from its instance file. A foreground
76
+ * server outside systemd has no process that can restart it after an
77
+ * install, so it cannot update itself.
78
+ */
79
+ const readLaunchState = async () => {
80
+ const currentPort = server.address()?.port || 3000;
81
+ const instanceFilePath = path.join(openchamberDataDir, 'run', `openchamber-${currentPort}.json`);
82
+ let storedOptions = { port: currentPort, daemon: true };
83
+ try {
84
+ const content = await fs.promises.readFile(instanceFilePath, 'utf8');
85
+ storedOptions = JSON.parse(content);
86
+ } catch {
87
+ }
88
+ const launchMode = storedOptions.launchMode === 'foreground' ? 'foreground' : 'daemon';
89
+ const isForegroundService = launchMode === 'foreground';
90
+ const systemdServiceUnit = isForegroundService ? resolveSystemdServiceUnit(process.env) : null;
91
+ return { storedOptions, launchMode, isForegroundService, systemdServiceUnit };
92
+ };
93
+
74
94
  app.get('/api/openchamber/update-check', async (req, res) => {
75
95
  try {
76
96
  const parseString = (value) => (typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined);
@@ -121,6 +141,14 @@ export const registerOpenChamberRoutes = (app, dependencies) => {
121
141
  } else {
122
142
  const { checkForUpdates } = await import('../package-manager.js');
123
143
  updateInfo = await checkForUpdates(updateRequest);
144
+ // Tell clients up front that the install route will refuse, so they
145
+ // show the manual command instead of an Update button that fails.
146
+ if (updateInfo?.available && updateRequest.appType === 'web') {
147
+ const { isForegroundService, systemdServiceUnit } = await readLaunchState();
148
+ if (isForegroundService && !systemdServiceUnit) {
149
+ updateInfo = { ...updateInfo, installBlocked: 'service-manager' };
150
+ }
151
+ }
124
152
  }
125
153
  res.json(updateInfo);
126
154
  } catch (error) {
@@ -215,17 +243,7 @@ export const registerOpenChamberRoutes = (app, dependencies) => {
215
243
  return;
216
244
  }
217
245
 
218
- const currentPort = server.address()?.port || 3000;
219
- const instanceFilePath = path.join(openchamberDataDir, 'run', `openchamber-${currentPort}.json`);
220
- let storedOptions = { port: currentPort, daemon: true };
221
- try {
222
- const content = await fs.promises.readFile(instanceFilePath, 'utf8');
223
- storedOptions = JSON.parse(content);
224
- } catch {
225
- }
226
- const launchMode = storedOptions.launchMode === 'foreground' ? 'foreground' : 'daemon';
227
- const isForegroundService = launchMode === 'foreground';
228
- const systemdServiceUnit = isForegroundService ? resolveSystemdServiceUnit(process.env) : null;
246
+ const { storedOptions, launchMode, isForegroundService, systemdServiceUnit } = await readLaunchState();
229
247
 
230
248
  if (isForegroundService) {
231
249
  if (!systemdServiceUnit) {
@@ -203,6 +203,24 @@ describe('OpenChamber desktop host update route', () => {
203
203
  });
204
204
 
205
205
  describe('OpenChamber foreground update route', () => {
206
+ it('marks an available update as blocked when the foreground server has no service manager', async () => {
207
+ const { app } = createApp();
208
+
209
+ const response = await request(app).get('/api/openchamber/update-check?appType=web').expect(200);
210
+
211
+ expect(response.body).toMatchObject({ available: true, installBlocked: 'service-manager' });
212
+ });
213
+
214
+ it('leaves the update installable for a systemd-owned or daemon server', async () => {
215
+ const systemd = createApp({ environment: { INVOCATION_ID: 'systemd-invocation' } });
216
+ const daemon = createApp({ storedOptions: { launchMode: 'daemon' } });
217
+
218
+ for (const { app } of [systemd, daemon]) {
219
+ const response = await request(app).get('/api/openchamber/update-check?appType=web').expect(200);
220
+ expect(response.body.installBlocked).toBeUndefined();
221
+ }
222
+ });
223
+
206
224
  it('rejects a foreground update when the server is not owned by systemd', async () => {
207
225
  const { app } = createApp();
208
226
 
@@ -333,4 +351,3 @@ describe('OpenChamber web update route on Windows', () => {
333
351
  expect(logError).toHaveBeenCalledOnce();
334
352
  });
335
353
  });
336
-
@@ -3,7 +3,7 @@ import os from 'os';
3
3
 
4
4
  import { getNpmInfo as defaultGetNpmInfo } from './npm-registry.js';
5
5
  import { isExactSemver as defaultIsExactSemver, isPathSpec as defaultIsPathSpec, parseNpmSpec as defaultParseNpmSpec, parsePathSpec as defaultParsePathSpec } from './plugin-spec.js';
6
- import { buildDeferredRestartResponse } from './config-mutation-response.js';
6
+ import { buildAppliedResponse } from './config-mutation-response.js';
7
7
 
8
8
  const ENTRY_EXISTS_CODES = new Set(['ENTRY_EXISTS', 'EEXIST']);
9
9
  const FILE_EXISTS_CODES = new Set(['FILE_EXISTS', 'EEXIST']);
@@ -46,8 +46,8 @@ export const registerPluginRoutes = (app, dependencies) => {
46
46
  applyChange();
47
47
 
48
48
  const pastTense = operation.replace(/ion$/, 'ed').replace(/update$/, 'updated');
49
- return res.json(buildDeferredRestartResponse(
50
- `Plugin ${pastTense}. Restart OpenCode to apply.`,
49
+ return res.json(buildAppliedResponse(
50
+ `Plugin ${pastTense}.`,
51
51
  ));
52
52
  };
53
53