@openchamber/web 2.0.0 → 2.0.2

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 (233) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-hJbl3JX4.js → CodeMirrorCommentWidgets-CmKmyb9T.js} +1 -1
  2. package/dist/assets/DiffView-8-PFpZ2p.js +4 -0
  3. package/dist/assets/FilesView-0Ie20mEk.js +17 -0
  4. package/dist/assets/{GitView-DY4pelsO.js → GitView-DNUSu00w.js} +4 -4
  5. package/dist/assets/{GuestAttachDialog-D6mHDTB2.js → GuestAttachDialog-Cv6QzjHC.js} +1 -1
  6. package/dist/assets/GuestSurfacePane-Bt3jB_Ye.js +1 -0
  7. package/dist/assets/{JsonTreeView-DEXI2NvJ.js → JsonTreeView-BlyHTRhM.js} +1 -1
  8. package/dist/assets/{LinearIssuesView-BTNc-4dN.js → LinearIssuesView-CSl2MUfA.js} +1 -1
  9. package/dist/assets/MarkdownImageGallery-2UXJF-5B.js +1 -0
  10. package/dist/assets/MarkdownRendererImpl-DVHqZoug.js +12 -0
  11. package/dist/assets/{OnboardingScreen-FJUreEgI.js → OnboardingScreen-CIdXJpfc.js} +1 -1
  12. package/dist/assets/{PatchDiff-C0oOkKnO.js → PatchDiff-ByvnbG5T.js} +1 -1
  13. package/dist/assets/{PierreDiffViewer-asuSQAsf.js → PierreDiffViewer-BXieg0mH.js} +3 -3
  14. package/dist/assets/{PlanView-DGbasNHP.js → PlanView-DEIi3Q7M.js} +4 -4
  15. package/dist/assets/PluginPane-BEPUWVho.js +3 -0
  16. package/dist/assets/SettingsView-CiNh-RbW.js +30 -0
  17. package/dist/assets/{SettingsWindow-By4cqnqy.js → SettingsWindow-BIz224xs.js} +1 -1
  18. package/dist/assets/{SubmoduleDiffSummary-C0P2tXLU.js → SubmoduleDiffSummary-CXKmlps9.js} +1 -1
  19. package/dist/assets/{ToolOutputDialog-Cayc-yIM.js → ToolOutputDialog-BsgAK8xu.js} +6 -6
  20. package/dist/assets/{ToolPartDiffPreview-B0jmpPQz.js → ToolPartDiffPreview-vdPObXOf.js} +2 -2
  21. package/dist/assets/{VirtualizedFileDiff-DsOpvWZD.js → VirtualizedFileDiff-BkFNKWS5.js} +1 -1
  22. package/dist/assets/{WalkthroughView-CCakjyn9.js → WalkthroughView-6oE-MuDL.js} +2 -2
  23. package/dist/assets/{appThemeRegistry-Bw5oTm41.js → appThemeRegistry-aHUNHoqP.js} +1 -1
  24. package/dist/assets/changesTree-CePHbFcj.js +1 -0
  25. package/dist/assets/commitAndPush-Bon9r94r.js +1 -0
  26. package/dist/assets/{computeVirtualFileMetrics-B-4aLf4A.js → computeVirtualFileMetrics-DKqr_1AQ.js} +2 -2
  27. package/dist/assets/de-CgAJ51z7.js +10 -0
  28. package/dist/assets/es-zGi_ravM.js +16 -0
  29. package/dist/assets/fr-CPfogrWx.js +14 -0
  30. package/dist/assets/index-CHfphYL3.js +41 -0
  31. package/dist/assets/{index-B6r0Kv-B.js → index-DpFttslC.js} +1 -1
  32. package/dist/assets/index-DvMJ3w6V.css +1 -0
  33. package/dist/assets/{isDiffPlainText-Ok-kgtJA.js → isDiffPlainText-kzAgpIgi.js} +1 -1
  34. package/dist/assets/{isFilePlainText-0dLnkYm8.js → isFilePlainText-Uj6y-jzz.js} +1 -1
  35. package/dist/assets/ja-DMk6wd-U.js +16 -0
  36. package/dist/assets/ko-BFpzJ8jc.js +16 -0
  37. package/dist/assets/{main-CjXBM_Xe.js → main-CbfMxn-I.js} +2 -2
  38. package/dist/assets/main-anyZFMIs.js +896 -0
  39. package/dist/assets/{markdown-shiki.worker-CahLvHIq.js → markdown-shiki.worker-Bg8SoAJJ.js} +8 -5
  40. package/dist/assets/markdownCore-CmM47cAE.js +7 -0
  41. package/dist/assets/{miniChat-DZ3OAeLN.js → miniChat-CiAKBC10.js} +2 -2
  42. package/dist/assets/{mobile-CH0LOIF-.js → mobile-CsT4sJwC.js} +2 -2
  43. package/dist/assets/patchFileDiff-DeaE08W0.js +13 -0
  44. package/dist/assets/pl-VdRPcZrB.js +16 -0
  45. package/dist/assets/pt-BR-BRys_lOW.js +16 -0
  46. package/dist/assets/{renderElectronMiniChatApp-CB1uLYvh.js → renderElectronMiniChatApp-C5677jy0.js} +2 -2
  47. package/dist/assets/renderMobileApp-D4dBBAqQ.js +25 -0
  48. package/dist/assets/runtimeEndpointReset-5r0hkd-2.js +27 -0
  49. package/dist/assets/scheduledTasksApi-BZCNJ588.js +1 -0
  50. package/dist/assets/{shikiHighlight-CocY80VR.js → shikiHighlight-BSUEa3yF.js} +1 -1
  51. package/dist/assets/{textMateThemeFromAppTheme-CF77r8FA.js → textMateThemeFromAppTheme-CsATFZIV.js} +1 -1
  52. package/dist/assets/tr-CA9ckNnm.js +7 -0
  53. package/dist/assets/uk-byjR-y8D.js +16 -0
  54. package/dist/assets/{useAppFontEffects-Dc5nTHi8.js → useAppFontEffects-BWQZ5DeI.js} +161 -157
  55. package/dist/assets/{useInlineCommentController-Dbza5c8l.js → useInlineCommentController-DlFyVfBu.js} +2 -2
  56. package/dist/assets/{useRootScrollLock-CSCLv396.js → useRootScrollLock-Cp1eFoM2.js} +2 -2
  57. package/dist/assets/{vendor-codemirror-language-data-CkmYWcRI.js → vendor-codemirror-language-data-BwwommM0.js} +2 -2
  58. package/dist/assets/{vendor-opencode-client-_BAHQo4R.js → vendor-opencode-client-DYdsLbCM.js} +2 -2
  59. package/dist/assets/vendor-zod-BSoePkpP.js +39 -0
  60. package/dist/assets/{web-components-nsStrYq9.js → web-components-D3Yjr4Zx.js} +1 -1
  61. package/dist/assets/zh-CN-DRabgxdG.js +16 -0
  62. package/dist/assets/zh-TW-rbY5c9UK.js +16 -0
  63. package/dist/index.html +5 -5
  64. package/dist/mini-chat.html +5 -5
  65. package/dist/mobile.html +5 -5
  66. package/package.json +4 -4
  67. package/server/index.js +82 -0
  68. package/server/lib/agent-tool/DOCUMENTATION.md +5 -0
  69. package/server/lib/agent-tool/runtime.js +34 -6
  70. package/server/lib/agent-tool/runtime.test.js +15 -0
  71. package/server/lib/browser-control/DOCUMENTATION.md +14 -2
  72. package/server/lib/event-stream/global-hub.js +23 -1
  73. package/server/lib/event-stream/global-hub.test.js +35 -0
  74. package/server/lib/event-stream/global-ws-bridge.js +3 -1
  75. package/server/lib/event-stream/upstream-reader.js +3 -2
  76. package/server/lib/git/DOCUMENTATION.md +1 -1
  77. package/server/lib/git/service.js +22 -0
  78. package/server/lib/git/service.test.js +8 -0
  79. package/server/lib/guests/DOCUMENTATION.md +4 -3
  80. package/server/lib/guests/catalog.js +19 -1
  81. package/server/lib/guests/catalog.test.js +22 -0
  82. package/server/lib/guests/html-styles.js +5 -3
  83. package/server/lib/guests/html-styles.test.js +3 -1
  84. package/server/lib/guests/routes.js +11 -3
  85. package/server/lib/guests/service.js +5 -0
  86. package/server/lib/guests/surface.js +55 -9
  87. package/server/lib/guests/surface.test.js +56 -6
  88. package/server/lib/notifications/DOCUMENTATION.md +10 -0
  89. package/server/lib/notifications/emit-route.js +118 -0
  90. package/server/lib/notifications/emit-route.test.js +112 -0
  91. package/server/lib/openchamber-control/actions.js +16 -2
  92. package/server/lib/openchamber-control/service.js +23 -0
  93. package/server/lib/openchamber-control/service.test.js +31 -0
  94. package/server/lib/openchamber-sessions/fork-inheritance.js +103 -0
  95. package/server/lib/openchamber-sessions/fork-inheritance.test.js +69 -0
  96. package/server/lib/openchamber-sessions/routes.js +11 -0
  97. package/server/lib/openchamber-sessions/routes.test.js +18 -0
  98. package/server/lib/opencode/DOCUMENTATION.md +37 -24
  99. package/server/lib/opencode/bootstrap-runtime.js +14 -1
  100. package/server/lib/opencode/compatibility.js +6 -3
  101. package/server/lib/opencode/compatibility.test.js +8 -0
  102. package/server/lib/opencode/config-entity-v2.test.js +27 -0
  103. package/server/lib/opencode/config-paths.test.js +12 -0
  104. package/server/lib/opencode/config-v2.d.ts +2 -0
  105. package/server/lib/opencode/config-v2.js +42 -0
  106. package/server/lib/opencode/config-v2.test.js +17 -0
  107. package/server/lib/opencode/core-routes.js +20 -4
  108. package/server/lib/opencode/core-routes.test.js +41 -0
  109. package/server/lib/opencode/env-runtime.js +1 -8
  110. package/server/lib/opencode/feature-routes-runtime.js +2 -1
  111. package/server/lib/opencode/lifecycle.js +30 -2
  112. package/server/lib/opencode/lifecycle.test.js +27 -0
  113. package/server/lib/opencode/managed-config-file.js +18 -6
  114. package/server/lib/opencode/managed-config-file.test.js +23 -7
  115. package/server/lib/opencode/mcp.js +7 -2
  116. package/server/lib/opencode/openchamber-routes.js +29 -11
  117. package/server/lib/opencode/openchamber-routes.test.js +18 -0
  118. package/server/lib/opencode/project-directory-runtime.js +8 -0
  119. package/server/lib/opencode/project-directory-runtime.test.js +13 -0
  120. package/server/lib/opencode/provider-source-route.test.js +59 -0
  121. package/server/lib/opencode/providers.js +3 -0
  122. package/server/lib/opencode/providers.test.js +62 -0
  123. package/server/lib/opencode/proxy.js +38 -2
  124. package/server/lib/opencode/routes-upgrade.test.js +1 -1
  125. package/server/lib/opencode/routes.js +36 -1
  126. package/server/lib/opencode/server-utils-runtime.js +5 -0
  127. package/server/lib/opencode/settings-helpers.js +10 -0
  128. package/server/lib/opencode/settings-helpers.test.js +2 -2
  129. package/server/lib/opencode/settings-registry.json +17 -0
  130. package/server/lib/opencode/settings-runtime.js +1 -0
  131. package/server/lib/opencode/shared.js +49 -4
  132. package/server/lib/opencode/shared.test.js +79 -1
  133. package/server/lib/opencode/shutdown-runtime.js +3 -0
  134. package/server/lib/opencode/skill-routes.js +28 -12
  135. package/server/lib/opencode/skill-routes.test.js +121 -1
  136. package/server/lib/opencode/upgrade-capability.js +0 -14
  137. package/server/lib/opencode/v1-migration-topup.js +21 -15
  138. package/server/lib/opencode/v1-migration-topup.test.js +14 -6
  139. package/server/lib/opencode/v2-install.d.ts +1 -0
  140. package/server/lib/opencode/v2-install.js +8 -7
  141. package/server/lib/opencode/v2-install.test.js +13 -4
  142. package/server/lib/opencode/watcher.js +3 -1
  143. package/server/lib/opencode/websearch-config.js +13 -1
  144. package/server/lib/quota/providers/kimi.js +1 -1
  145. package/server/lib/realtime-proxy.js +5 -1
  146. package/server/lib/realtime-proxy.test.js +29 -0
  147. package/server/lib/relay/tunnel-host.js +4 -1
  148. package/server/lib/relay/tunnel-host.test.js +11 -0
  149. package/server/lib/session-assist/DOCUMENTATION.md +17 -5
  150. package/server/lib/session-assist/runtime.js +19 -2
  151. package/server/lib/session-assist/runtime.test.js +8 -0
  152. package/server/lib/session-goal/DOCUMENTATION.md +11 -0
  153. package/server/lib/small-model/DOCUMENTATION.md +11 -10
  154. package/server/lib/small-model/index.js +27 -32
  155. package/server/lib/small-model/index.test.js +28 -16
  156. package/server/lib/spaces/DOCUMENTATION.md +381 -20
  157. package/server/lib/spaces/code-in-bait.js +145 -6
  158. package/server/lib/spaces/code-in.js +10 -150
  159. package/server/lib/spaces/code-in.test.js +7 -83
  160. package/server/lib/spaces/code-out.js +1819 -0
  161. package/server/lib/spaces/code-out.test.js +3945 -0
  162. package/server/lib/spaces/code-transfer.js +173 -0
  163. package/server/lib/spaces/command-stream.test.js +181 -0
  164. package/server/lib/spaces/dispatcher.js +670 -0
  165. package/server/lib/spaces/dispatcher.test.js +582 -0
  166. package/server/lib/spaces/gatekeeper-channel.js +2 -0
  167. package/server/lib/spaces/gatekeeper-channel.test.js +9 -3
  168. package/server/lib/spaces/gatekeeper-program.cjs +4 -1
  169. package/server/lib/spaces/gatekeeper-program.test.js +3 -0
  170. package/server/lib/spaces/hardening.js +20 -4
  171. package/server/lib/spaces/hardening.test.js +18 -3
  172. package/server/lib/spaces/host-git.js +7 -4
  173. package/server/lib/spaces/host-git.test.js +6 -2
  174. package/server/lib/spaces/host.js +304 -0
  175. package/server/lib/spaces/host.test.js +273 -0
  176. package/server/lib/spaces/journey.js +393 -0
  177. package/server/lib/spaces/journey.test.js +384 -0
  178. package/server/lib/spaces/layout.js +26 -2
  179. package/server/lib/spaces/manager.js +4 -3
  180. package/server/lib/spaces/manager.test.js +6 -0
  181. package/server/lib/spaces/places/code-out.docker.live.test.js +412 -0
  182. package/server/lib/spaces/places/contract-suite.js +36 -0
  183. package/server/lib/spaces/places/dispatcher.docker.live.test.js +296 -0
  184. package/server/lib/spaces/places/docker.js +15 -3
  185. package/server/lib/spaces/places/docker.test.js +33 -2
  186. package/server/lib/spaces/places/escape-suite.js +86 -14
  187. package/server/lib/spaces/places/memory-place.js +24 -1
  188. package/server/lib/spaces/places/registry.js +1 -1
  189. package/server/lib/spaces/places/server.docker.live.test.js +69 -33
  190. package/server/lib/spaces/places/sessions.docker.live.test.js +220 -0
  191. package/server/lib/spaces/routes.js +207 -0
  192. package/server/lib/spaces/routes.test.js +211 -0
  193. package/server/lib/spaces/run-command.js +261 -8
  194. package/server/lib/spaces/run-command.test.js +193 -3
  195. package/server/lib/spaces/space-events.js +153 -0
  196. package/server/lib/spaces/space-events.test.js +160 -0
  197. package/server/lib/spaces/space-records.js +98 -0
  198. package/server/lib/spaces/space-records.test.js +73 -0
  199. package/server/lib/spaces/space-sessions.js +210 -0
  200. package/server/lib/spaces/space-sessions.test.js +161 -0
  201. package/server/lib/spaces/websocket.js +329 -0
  202. package/server/lib/spaces/websocket.test.js +345 -0
  203. package/server/lib/ui-auth/ui-auth.js +8 -2
  204. package/server/lib/ui-auth/ui-auth.test.js +29 -0
  205. package/server/opencode-proxy.test.js +113 -0
  206. package/dist/assets/DiffView-BucGEJYa.js +0 -4
  207. package/dist/assets/FilesView-CQcaaAVP.js +0 -17
  208. package/dist/assets/GuestSurfacePane--DJ7rsmY.js +0 -1
  209. package/dist/assets/MarkdownImageGallery-wcUUcf8l.js +0 -1
  210. package/dist/assets/MarkdownRendererImpl-BPe2TVV2.js +0 -12
  211. package/dist/assets/PluginPane-DImv8hV2.js +0 -3
  212. package/dist/assets/SettingsView-DOjuOljf.js +0 -29
  213. package/dist/assets/commitAndPush-sGEelpjh.js +0 -1
  214. package/dist/assets/de-CD9utsNj.js +0 -10
  215. package/dist/assets/es-NNum2rX8.js +0 -16
  216. package/dist/assets/fr-CJLGmduQ.js +0 -14
  217. package/dist/assets/index-DjGPR5vW.js +0 -41
  218. package/dist/assets/index-fCXJ-8Qt.css +0 -1
  219. package/dist/assets/ja-BuddHNi6.js +0 -16
  220. package/dist/assets/ko-BrwMbHmf.js +0 -16
  221. package/dist/assets/main-CxVyUDU_.js +0 -896
  222. package/dist/assets/markdownCore-B6PpX409.js +0 -5
  223. package/dist/assets/patchFileDiff-BFRGKaGH.js +0 -13
  224. package/dist/assets/pl-BwN4TNlP.js +0 -16
  225. package/dist/assets/pt-BR-BhMtownO.js +0 -16
  226. package/dist/assets/renderMobileApp-nQ4sjQtb.js +0 -25
  227. package/dist/assets/runtimeEndpointReset-9ZGlXU4J.js +0 -27
  228. package/dist/assets/scheduledTasksApi-6DsL_SwM.js +0 -1
  229. package/dist/assets/tr-DRzvqMdi.js +0 -7
  230. package/dist/assets/uk-b2aYOSNh.js +0 -16
  231. package/dist/assets/vendor-zod-Gea9uBlY.js +0 -39
  232. package/dist/assets/zh-CN-DZeUThm_.js +0 -16
  233. package/dist/assets/zh-TW-2fRE7uc6.js +0 -16
@@ -10,7 +10,7 @@ This module provides OpenCode server integration utilities for the web server ru
10
10
  - `packages/web/server/lib/opencode/cli-options.js`: CLI/environment option parsing for server startup arguments.
11
11
  - `packages/web/server/lib/opencode/cli-entry-runtime.js`: CLI entrypoint runtime that detects direct execution, parses CLI options, and starts server bootstrap.
12
12
  - `packages/web/server/lib/opencode/routes.js`: OpenCode/provider settings and auth-related route registration.
13
- - `packages/web/server/lib/opencode/v1-migration-topup.js`: re-arms OpenCode's own V1 -> V2 session import for V1 sessions created after that migration already completed; runs only before a managed spawn. See "v1-migration-topup.js" below.
13
+ - `packages/web/server/lib/opencode/v1-migration-topup.js`: re-arms OpenCode's own V1 -> V2 session import for V1 sessions changed by 1.x after the last completed import; runs only before a managed spawn. See "v1-migration-topup.js" below.
14
14
  - `packages/web/server/lib/opencode/lifecycle.js`: OpenCode process lifecycle runtime (startup, restart, readiness, health monitoring). After readiness it warms the most recently used directories (`getWarmupDirectories` dep, sequential and best-effort) because OpenCode initializes each directory lazily on first request and that cost would otherwise be paid by the user's first interactive session open.
15
15
  - `packages/web/server/lib/opencode/provider-env-aliases.js`: mirrors known provider credential env aliases into the managed OpenCode process environment (for example `GEMINI_API_KEY` → `GOOGLE_GENERATIVE_AI_API_KEY`) so OpenCode connection detection and the upstream AI SDK agree on the same key names. Canonical implementation shared by web lifecycle and the VS Code managed spawn path (`packages/vscode/src/provider-env-aliases.ts` re-exports this module).
16
16
  - `packages/web/server/lib/opencode/env-runtime.js`: OpenCode CLI/binary resolution and shell environment runtime.
@@ -150,13 +150,14 @@ with the same loader strategy as `credential-db.js` — `node:sqlite` on Node,
150
150
  and logs one line; there is no HTTP route and no UI.
151
151
 
152
152
  What it does: when the migration row says `completed` and some `session` rows
153
- have no `session_v2` twin AND were created after the migration completed
154
- (`time_created` past the row's `time_updated`), it sets the row to
155
- `{"phase":"sessions","cursor":…}`. The time test matters because a v2 delete
156
- leaves the legacy row behind (`Session.remove` publishes `session.deleted`,
157
- `bus.remove` then wipes that session's durable events, `session_v2` cascades):
158
- a legacy session the migration already walked and that is absent now was
159
- deleted, not missed, and is never re-imported.
153
+ have no `session_v2` twin AND were changed by 1.x after the last completed
154
+ import (`session.time_updated` past the row's `time_updated`, which OpenCode
155
+ stamps on completion), it sets the row to `{"phase":"sessions","cursor":…}`.
156
+ The time test matters because a v2 delete leaves the legacy row behind
157
+ (`Session.remove` publishes `session.deleted`, `bus.remove` then wipes that
158
+ session's durable events, `session_v2` cascades), and only OpenCode 1.x writes
159
+ the legacy table: when nobody ran 1.x since the last import, nothing qualifies
160
+ and the top-up skips, so sessions deleted in v2 stay deleted.
160
161
  The cursor is the largest missing id plus `U+FFFF`, because OpenCode's loop
161
162
  walks `id < cursor` in descending id order and ids are fixed width, so nothing
162
163
  real can fall between an id and that cursor. Ids are compared the way SQLite
@@ -165,7 +166,7 @@ encode time descending in a field that wraps, so id order is **not** time
165
166
  order — an August session can sort far below a newer one, and the code never
166
167
  assumes otherwise.
167
168
 
168
- Two hard rules, both verified against v2.0.8
169
+ Hard rules, verified against v2.0.8 (the completion stamp against v2.0.16)
169
170
  `packages/core/src/database/v1-migration.bun.ts`:
170
171
 
171
172
  - **Never clear or delete the `migration.v1-v2` row.** With no row at all
@@ -180,11 +181,10 @@ Two hard rules, both verified against v2.0.8
180
181
  `compaction`). Any hit and nothing is written: the outcome is `unsafe`
181
182
  (`revisited-sessions-have-v2-activity`) and a single warning names how many
182
183
  sessions stay missing.
183
- - **Never resurrect a session deleted in v2.** OpenCode's loop walks every
184
- legacy row under the cursor, so a deleted session sorting below a
185
- never-imported one would come back. The top-up refuses that too
186
- (`unsafe`, `deleted-sessions-would-return`); the never-imported sessions
187
- then stay missing until upstream offers an import route.
184
+ - **Only 1.x activity triggers an import** (maintainer, 2026-09-24). When 1.x
185
+ was used again, OpenCode's loop still walks every legacy row under the
186
+ cursor, so a deleted session sorting below a fresh one comes back with it;
187
+ avoiding that needs an upstream import route that takes explicit ids.
188
188
 
189
189
  ## Public exports (providers.js)
190
190
  - `getProviderSources(providerId, workingDirectory)`: Resolves which OpenCode config layers define a provider.
@@ -231,8 +231,8 @@ Two hard rules, both verified against v2.0.8
231
231
  `upgrade`, without a shell or client-supplied arguments. OpenCode chooses the
232
232
  installer. Web, hosted mobile, Capacitor, and Desktop with a separately installed
233
233
  CLI use this server path. VS Code uses the same executor from its extension host.
234
- Bundled Desktop, external URL connections, unavailable CLIs, and the Windows
235
- ARM64 workaround remain unsupported at the host boundary.
234
+ Bundled Desktop, external URL connections, and unavailable CLIs remain
235
+ unsupported at the host boundary.
236
236
 
237
237
  An upgrade leaves the current server running. The toast's Reload action restarts
238
238
  it using the installed version. Failed installations return an error and can be
@@ -244,7 +244,11 @@ limit, and the VS Code bridge does not apply its usual 30-second request timeout
244
244
  ### Migrating an installed v1 CLI
245
245
 
246
246
  `GET /api/opencode/compatibility` reads the local CLI version without starting
247
- its server, or probes an external server's JSON version contract. A confirmed
247
+ its server, or probes an external server's JSON version contract (`/api/info`,
248
+ then v1's `/global/health` even when the first probe fails or hangs). When
249
+ `OPENCODE_HOST`/`OPENCODE_PORT` points at a server that identifies as v1 or a
250
+ 2.x below the minimum, startup attaches to it as external and not ready rather
251
+ than spawning a managed instance, so this check reports its version. A confirmed
248
252
  managed v1 CLI on macOS, Linux or Windows (x64/arm64) advertises `canInstall`;
249
253
  bundled binaries and external connections do not.
250
254
 
@@ -253,8 +257,8 @@ across concurrent clients. `v2-install.js` resolves a validated stable v2
253
257
  release from npm. On macOS/Linux it downloads the official
254
258
  `https://opencode.ai/v2/install` script and runs it with that release and
255
259
  `--no-modify-path`. That script is bash, so on Windows it downloads the npm
256
- platform package the script would fetch, `@opencode/cli-windows-x64-baseline`
257
- (arm64 too, like the desktop bundle), checks it against the `sha512` integrity
260
+ platform package the script would fetch (`@opencode/cli-windows-arm64` on
261
+ arm64, `@opencode/cli-windows-x64-baseline` on x64, like the desktop bundle), checks it against the `sha512` integrity
258
262
  npm publishes, and unpacks `opencode.exe` with the system `tar.exe`. Both
259
263
  paths then verify the resulting executable.
260
264
  It installs into the host user's standard `~/.opencode/bin`. Existing npm/Bun
@@ -454,7 +458,7 @@ ConPTY or Console Window Host behavior.
454
458
  - `readCustomThemesFromDisk()`
455
459
 
456
460
  ## Public exports (project-directory-runtime.js)
457
- - `createProjectDirectoryRuntime(dependencies)`: creates runtime for request/project directory candidate normalization and validation.
461
+ - `createProjectDirectoryRuntime(dependencies)`: creates runtime for request/project directory candidate normalization and validation. `dependencies.refuseDirectory(candidate)` answers the reason a resolved directory may not be used on this host, or null; `validateDirectoryPath` asks it before it looks at the disk, so a refused directory is never touched and never falls back to another one. The isolated-spaces host refuses `/spaces/...` through it while its switch is on.
458
462
  - Returned API:
459
463
  - `resolveDirectoryCandidate(value)`
460
464
  - `validateDirectoryPath(candidate)`
@@ -728,6 +732,7 @@ headers }` or v1 `{ npm, options }`. The stored entry is always a
728
732
  - conditional JSON body parser behavior for `/api/*` vs non-API requests
729
733
  - URL-encoded parser setup
730
734
  - request logging middleware
735
+ - `dependencies.skipBodyParsing(req)` names a request both parsers leave alone, so its body reaches its route untouched; the isolated-spaces dispatcher uses it for `/api/spaces/<id>/...`, which it streams into a space
731
736
 
732
737
  ## Public exports (cli-options.js)
733
738
  - `parseServeCliOptions(options)`: parses serve CLI flags and environment-derived defaults:
@@ -907,7 +912,10 @@ The VS Code extension owns its separate Git and proxy implementation.
907
912
 
908
913
  The behavior `GET /api/behavior/agents-md` response includes `path`, the effective
909
914
  server-side filename, whether or not the file exists. Settings displays this
910
- path without deriving a directory from the browser environment.
915
+ path without deriving a directory from the browser environment. A `PUT` may send
916
+ `expectedContent` (the content the editor loaded, `null` for no file); when the
917
+ file on disk no longer matches, the write is refused with `409` and code
918
+ `AGENTS_MD_CONFLICT` instead of overwriting an edit made elsewhere.
911
919
 
912
920
  ## Managed OpenCode config layer (managed-config-file.js)
913
921
 
@@ -916,8 +924,12 @@ through the process environment, because an environment variable cannot change
916
924
  under a running child.
917
925
 
918
926
  - Contract: the managed child gets `OPENCODE_CONFIG=<data-dir>/opencode.managed.json`.
919
- The file contains only `plugins`, holding the absolute directory of every
920
- OpenChamber plugin currently switched on. Its layer sits above the user's
927
+ The file contains only `plugins`: `-opencode.browser` first, then the absolute
928
+ directory of every OpenChamber plugin currently switched on. OpenCode's
929
+ built-in browser tools need OpenCode's own desktop app to attach a browser;
930
+ OpenChamber does not, so they would always fail with `browser.disconnected`
931
+ and steer agents away from `openchamber_web`. A project config listing
932
+ `opencode.browser` re-enables it. The fallback path merges the same entry. Its layer sits above the user's
921
933
  global `opencode.json` and below their project config.
922
934
  - `OPENCODE_CONFIG_CONTENT` is passed through untouched, so whatever the user
923
935
  put there still applies.
@@ -925,7 +937,8 @@ under a running child.
925
937
  always in the child environment, including while every managed tool is off —
926
938
  a tool switched on later then reaches a process that can already call back.
927
939
  - `persistSettings` rewrites the file (temp + rename) whenever
928
- `agentControlToolEnabled`, `agentWebToolEnabled` or `agentMemoryToolEnabled`
940
+ `agentControlToolEnabled`, `agentWebToolEnabled`, `agentMemoryToolEnabled` or
941
+ `agentNotifyToolEnabled`
929
942
  changes. Plugin directories are written before the
930
943
  file names them, and a disabled plugin is removed from the list. OpenCode
931
944
  reloads within a couple of seconds; no restart is involved.
@@ -1,3 +1,5 @@
1
+ import { registerNotificationEmitRoutes } from '../notifications/emit-route.js';
2
+
1
3
  export const createBootstrapRuntime = (dependencies) => {
2
4
  const {
3
5
  createUiAuth,
@@ -63,7 +65,9 @@ export const createBootstrapRuntime = (dependencies) => {
63
65
  getCachedZenModels,
64
66
  setAutoAcceptSession,
65
67
  agentToolRuntime,
68
+ pluginNotificationEmitter,
66
69
  desktopUpdater,
70
+ skipBodyParsing,
67
71
  } = options;
68
72
 
69
73
  const uiAuthController = createUiAuth({
@@ -90,10 +94,17 @@ export const createBootstrapRuntime = (dependencies) => {
90
94
  uiAuthController,
91
95
  });
92
96
 
93
- registerCommonRequestMiddleware(app, { express, verboseRequestLogs });
97
+ registerCommonRequestMiddleware(app, { express, verboseRequestLogs, skipBodyParsing });
94
98
 
95
99
  registerAgentToolRoutes(app, { express, agentToolRuntime });
96
100
 
101
+ const notificationEmitRoutes = registerNotificationEmitRoutes(app, {
102
+ express,
103
+ isAgentToolRequestAuthorized: (req) => agentToolRuntime?.authorizeRequest?.(req) === true,
104
+ emitter: pluginNotificationEmitter,
105
+ });
106
+ notificationEmitRoutes.registerPluginRoute();
107
+
97
108
  registerAuthAndAccessRoutes(app, {
98
109
  express,
99
110
  tunnelAuthController,
@@ -110,6 +121,8 @@ export const createBootstrapRuntime = (dependencies) => {
110
121
  normalizeTunnelSessionTtlMs,
111
122
  });
112
123
 
124
+ notificationEmitRoutes.registerApiRoute();
125
+
113
126
  registerTtsRoutes(app, { sayTTSCapability });
114
127
 
115
128
  registerNotificationRoutes(app, {
@@ -63,13 +63,16 @@ export const requireOpenCodeV2 = async (launch, options) => {
63
63
 
64
64
  // External URLs have no local executable. A legacy probe identifies v1 only
65
65
  // from its JSON contract; neither HTML fallbacks nor auth failures imply v1.
66
+ // v1 has no `/api/info`: its catch-all serves the web UI, and a v1 build
67
+ // without the embedded UI proxies that path to app.opencode.ai, which can hang
68
+ // or fail. A failed v2 probe therefore still falls through to the v1 probe.
66
69
  export const readExternalOpenCodeVersion = async (baseUrl, headers, fetchImpl = fetch) => {
67
70
  const request = (pathname) => fetchImpl(new URL(pathname, baseUrl), {
68
71
  headers: { ...headers, Accept: 'application/json' }, redirect: 'error', signal: AbortSignal.timeout(5000),
69
72
  });
70
- const response = await request('/api/info');
71
- if (response.status === 401 || response.status === 403) return null;
72
- const info = await readOpenCodeInfo(response);
73
+ const response = await request('/api/info').catch(() => null);
74
+ if (response && (response.status === 401 || response.status === 403)) return null;
75
+ const info = response ? await readOpenCodeInfo(response) : null;
73
76
  if (info) return info.version;
74
77
  const legacy = await request('/global/health');
75
78
  if (!legacy.ok) return null;
@@ -30,6 +30,14 @@ describe('OpenCode compatibility', () => {
30
30
  expect(requests).toEqual(['/api/info', '/global/health']);
31
31
  });
32
32
 
33
+ it('still identifies v1 when its /api/info fallback hangs or fails', async () => {
34
+ const fetchImpl = async (url) => {
35
+ if (url.pathname === '/api/info') throw new DOMException('The operation timed out.', 'TimeoutError');
36
+ return Response.json({ healthy: true, version: '1.18.32' });
37
+ };
38
+ expect(await readExternalOpenCodeVersion('http://localhost:4096', {}, fetchImpl)).toBe('1.18.32');
39
+ });
40
+
33
41
  it.each([401, 403])('does not call an auth failure v1 (%s)', async (status) => {
34
42
  let requests = 0;
35
43
  expect(await readExternalOpenCodeVersion('http://localhost:4096', {}, async () => {
@@ -261,6 +261,33 @@ describe('entity modules speak OpenCode 2 shapes', () => {
261
261
  }
262
262
  });
263
263
 
264
+ it('lists servers from a global opencode.jsonc next to opencode.json and edits them in place', () => {
265
+ const configDir = path.join(process.env.XDG_CONFIG_HOME, 'opencode');
266
+ const jsonPath = path.join(configDir, 'opencode.json');
267
+ const jsoncPath = path.join(configDir, 'opencode.jsonc');
268
+ fs.mkdirSync(configDir, { recursive: true });
269
+ fs.writeFileSync(jsonPath, JSON.stringify({ autoupdate: true }, null, 2), 'utf8');
270
+ fs.writeFileSync(jsoncPath, [
271
+ '{',
272
+ ' // servers live only in the jsonc file',
273
+ ' "mcp": { "servers": { "docs": { "type": "remote", "url": "https://docs.example.com/mcp" } } }',
274
+ '}',
275
+ ].join('\n'), 'utf8');
276
+
277
+ try {
278
+ expect(listMcpConfigs(projectDir).map((entry) => entry.name)).toContain('docs');
279
+ expect(getMcpConfig('docs', projectDir)).toEqual(expect.objectContaining({ scope: 'user' }));
280
+
281
+ updateMcpConfig('docs', { disabled: true }, projectDir);
282
+
283
+ expect(getMcpConfig('docs', projectDir)).toEqual(expect.objectContaining({ disabled: true }));
284
+ expect(readJson(jsonPath)).toEqual({ autoupdate: true });
285
+ } finally {
286
+ fs.rmSync(jsonPath, { force: true });
287
+ fs.rmSync(jsoncPath, { force: true });
288
+ }
289
+ });
290
+
264
291
  it('reads a v1 mcp entry and rewrites it under mcp.servers in the same file', () => {
265
292
  const configPath = write('opencode.json', JSON.stringify({
266
293
  mcp: {
@@ -111,6 +111,18 @@ describe('OpenCode global config paths', () => {
111
111
  expect(response.json).toHaveBeenLastCalledWith({
112
112
  content: 'Global behavior', exists: true, path: path.join(process.env.XDG_CONFIG_HOME, 'opencode', 'AGENTS.md'),
113
113
  });
114
+
115
+ // A write based on an outdated copy is refused and leaves the file alone.
116
+ await handlers.get('PUT /api/behavior/agents-md')({
117
+ body: { content: 'Stale draft', expectedContent: 'Older behavior' },
118
+ }, response);
119
+ expect(response.status).toHaveBeenLastCalledWith(409);
120
+ expect(fs.readFileSync(path.join(process.env.XDG_CONFIG_HOME, 'opencode', 'AGENTS.md'), 'utf8')).toBe('Global behavior');
121
+
122
+ await handlers.get('PUT /api/behavior/agents-md')({
123
+ body: { content: 'Current draft', expectedContent: 'Global behavior' },
124
+ }, response);
125
+ expect(fs.readFileSync(path.join(process.env.XDG_CONFIG_HOME, 'opencode', 'AGENTS.md'), 'utf8')).toBe('Current draft');
114
126
  fs.rmSync(root, { recursive: true, force: true });
115
127
  });
116
128
  });
@@ -162,6 +162,7 @@ export function deleteMcpEntry(config: Record<string, unknown>, name: string): b
162
162
  export function toProviderPackage(value: unknown): string | undefined;
163
163
  export function toNpmPackage(value: unknown): string | undefined;
164
164
  export function toProviderEntity(raw: unknown): ProviderEntity;
165
+ export function readStoredProviderEntry(configs: unknown[], providerId: string): ProviderEntity | null;
165
166
 
166
167
  export function toPluginEntity(raw: unknown): PluginEntity | null;
167
168
  export function fromPluginEntity(entity: unknown): string | PluginEntity | null;
@@ -171,6 +172,7 @@ export function readPluginList(config: unknown): Array<{ entry: PluginEntity; ke
171
172
  export type WebSearchSelection = false | string | null;
172
173
  export function parseWebSearchSelection(value: unknown): WebSearchSelection | undefined;
173
174
  export function writeWebSearchSelection(config: Record<string, unknown>, selection: WebSearchSelection): boolean;
175
+ export function writeWarmingEnabled(config: Record<string, unknown>, enabled: boolean): boolean;
174
176
  export interface WebSearchConfigLayers {
175
177
  userConfig: object | null;
176
178
  projectConfig: object | null;
@@ -668,6 +668,28 @@ function toProviderEntity(raw) {
668
668
  ]);
669
669
  }
670
670
 
671
+ /**
672
+ * The provider entry an editor should start from: the winning config layer's
673
+ * stored entry (layers passed highest precedence first) in v2 shape, without
674
+ * the literal `settings.apiKey` secret. Returns null when no layer defines it.
675
+ * Unlike the live provider OpenCode serves, this carries `env` and only the
676
+ * reasoning levels the user wrote.
677
+ */
678
+ function readStoredProviderEntry(configs, providerId) {
679
+ for (const config of configs) {
680
+ const { value } = readSectionEntry(config, 'providers', providerId);
681
+ if (value === undefined) continue;
682
+ const entity = toProviderEntity(value);
683
+ if (entity.settings && 'apiKey' in entity.settings) {
684
+ const { apiKey: _secret, ...settings } = entity.settings;
685
+ if (Object.keys(settings).length) entity.settings = settings;
686
+ else delete entity.settings;
687
+ }
688
+ return entity;
689
+ }
690
+ return null;
691
+ }
692
+
671
693
  // ============== PLUGINS ==============
672
694
 
673
695
  const PLUGIN_SECTION = { v2: 'plugins', v1: 'plugin' };
@@ -742,6 +764,24 @@ function writeWebSearchSelection(config, selection) {
742
764
  return JSON.stringify(config.websearch) !== before;
743
765
  }
744
766
 
767
+ // ============== SESSION WARMING ==============
768
+
769
+ /**
770
+ * The `warming` key: `true` keeps idle sessions' prompt cache warm with
771
+ * OpenCode's defaults, an object tunes prompt/interval/duration. Turning it on
772
+ * keeps a hand-tuned object as is; turning it off removes the key (OpenCode's
773
+ * default is off). Returns whether the config changed.
774
+ */
775
+ function writeWarmingEnabled(config, enabled) {
776
+ const before = JSON.stringify(config.warming);
777
+ if (!enabled) {
778
+ delete config.warming;
779
+ } else if (typeof config.warming !== 'object' || config.warming === null) {
780
+ config.warming = true;
781
+ }
782
+ return JSON.stringify(config.warming) !== before;
783
+ }
784
+
745
785
  const hasWebSearchKey = (config) => config != null && Object.hasOwn(config, 'websearch');
746
786
 
747
787
  /**
@@ -792,10 +832,12 @@ export {
792
832
  toProviderPackage,
793
833
  toNpmPackage,
794
834
  toProviderEntity,
835
+ readStoredProviderEntry,
795
836
  toPluginEntity,
796
837
  fromPluginEntity,
797
838
  readPluginList,
798
839
  parseWebSearchSelection,
799
840
  writeWebSearchSelection,
800
841
  findWebSearchProjectOverride,
842
+ writeWarmingEnabled,
801
843
  };
@@ -9,6 +9,7 @@ import {
9
9
  parseModelSelection,
10
10
  formatModelSelection,
11
11
  toAgentEntity,
12
+ writeWarmingEnabled,
12
13
  fromAgentEntity,
13
14
  isLegacyAgentFrontmatter,
14
15
  toCommandEntity,
@@ -464,3 +465,19 @@ describe('findWebSearchProjectOverride', () => {
464
465
  expect(findWebSearchProjectOverride(layers(), [{ path: userPath, config: { websearch: false } }])).toBeNull();
465
466
  });
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',
@@ -1074,10 +1075,15 @@ export const registerSettingsUtilityRoutes = (app, dependencies) => {
1074
1075
  };
1075
1076
 
1076
1077
  export const registerCommonRequestMiddleware = (app, dependencies) => {
1077
- const { express, verboseRequestLogs = false } = dependencies;
1078
+ // `skipBodyParsing(req)` names a request whose body must reach its route untouched: a
1079
+ // request the isolated-spaces dispatcher streams into a space, where a parsed body would
1080
+ // otherwise be consumed here and lost.
1081
+ const { express, verboseRequestLogs = false, skipBodyParsing = () => false } = dependencies;
1078
1082
 
1079
1083
  app.use((req, res, next) => {
1080
- if (req.path === '/api/config/themes' || req.path.startsWith('/api/config/themes/')) {
1084
+ if (skipBodyParsing(req)) {
1085
+ next();
1086
+ } else if (req.path === '/api/config/themes' || req.path.startsWith('/api/config/themes/')) {
1081
1087
  express.json({ limit: '1mb' })(req, res, next);
1082
1088
  } else if (req.path.startsWith('/api/behavior')) {
1083
1089
  const contentLength = parseInt(req.headers['content-length'] || '0', 10);
@@ -1093,6 +1099,8 @@ export const registerCommonRequestMiddleware = (app, dependencies) => {
1093
1099
  req.path.startsWith('/api/config/settings') ||
1094
1100
  req.path.startsWith('/api/config/skills') ||
1095
1101
  req.path.startsWith('/api/config/plugins') ||
1102
+ req.path.startsWith('/api/config/websearch') ||
1103
+ req.path.startsWith('/api/config/warming') ||
1096
1104
  req.path.startsWith('/api/projects') ||
1097
1105
  req.path.startsWith('/api/fs') ||
1098
1106
  req.path.startsWith('/api/git') ||
@@ -1112,7 +1120,8 @@ export const registerCommonRequestMiddleware = (app, dependencies) => {
1112
1120
  req.path.startsWith('/api/text') ||
1113
1121
  req.path.startsWith('/api/voice') ||
1114
1122
  req.path.startsWith('/api/tts') ||
1115
- req.path.startsWith('/api/openchamber/tunnel')
1123
+ req.path.startsWith('/api/openchamber/tunnel') ||
1124
+ req.path.startsWith('/api/openchamber/spaces')
1116
1125
  ) {
1117
1126
  express.json({ limit: '50mb' })(req, res, next);
1118
1127
  } else if (req.path.startsWith('/api')) {
@@ -1122,7 +1131,14 @@ export const registerCommonRequestMiddleware = (app, dependencies) => {
1122
1131
  }
1123
1132
  });
1124
1133
 
1125
- app.use(express.urlencoded({ extended: true, limit: '50mb' }));
1134
+ const urlencoded = express.urlencoded({ extended: true, limit: '50mb' });
1135
+ app.use((req, res, next) => {
1136
+ if (skipBodyParsing(req)) {
1137
+ next();
1138
+ return;
1139
+ }
1140
+ urlencoded(req, res, next);
1141
+ });
1126
1142
 
1127
1143
  app.use((req, _res, next) => {
1128
1144
  if (verboseRequestLogs) {
@@ -127,6 +127,47 @@ describe('core-routes', () => {
127
127
  expect(response.body).toEqual({ body: { content: 'Snippet body' } });
128
128
  });
129
129
 
130
+ it('leaves the body of a request alone when told to, for both parsers', async () => {
131
+ const app = express();
132
+ registerCommonRequestMiddleware(app, { express, skipBodyParsing: (req) => req.path.startsWith('/api/spaces/') });
133
+ const raw = (req, res) => {
134
+ // A body a parser read is complete already, and its stream ends no second time.
135
+ if (req.complete) {
136
+ res.json({ body: req.body ?? null, raw: '' });
137
+ return;
138
+ }
139
+ const chunks = [];
140
+ req.on('data', (chunk) => chunks.push(chunk));
141
+ req.on('end', () => res.json({ body: req.body ?? null, raw: Buffer.concat(chunks).toString('utf8') }));
142
+ };
143
+ app.post('/api/spaces/abc/form', raw);
144
+ app.post('/api/spaces/abc/config/snippets/x', raw);
145
+ app.post('/api/other/form', raw);
146
+
147
+ const kept = await request(app).post('/api/spaces/abc/form').type('form').send('a=1&b=2').expect(200);
148
+ expect(kept.body).toEqual({ body: null, raw: 'a=1&b=2' });
149
+ const keptJson = await request(app).post('/api/spaces/abc/config/snippets/x').send({ content: 'x' }).expect(200);
150
+ expect(keptJson.body).toEqual({ body: null, raw: '{"content":"x"}' });
151
+ // Elsewhere the parsers still run, and a parsed body leaves nothing to read.
152
+ const parsed = await request(app).post('/api/other/form').type('form').send('a=1&b=2').expect(200);
153
+ expect(parsed.body).toEqual({ body: { a: '1', b: '2' }, raw: '' });
154
+ });
155
+
156
+ it('should parse JSON bodies for the web search config route', async () => {
157
+ const app = express();
158
+ registerCommonRequestMiddleware(app, { express });
159
+ app.put('/api/config/websearch', (req, res) => {
160
+ res.json({ body: req.body });
161
+ });
162
+
163
+ const response = await request(app)
164
+ .put('/api/config/websearch')
165
+ .send({ selection: 'random' })
166
+ .expect(200);
167
+
168
+ expect(response.body).toEqual({ body: { selection: 'random' } });
169
+ });
170
+
130
171
  it('should parse JSON bodies for custom provider upsert routes', async () => {
131
172
  const app = express();
132
173
  registerCommonRequestMiddleware(app, { express });
@@ -698,15 +698,8 @@ export const createOpenCodeEnvRuntime = (deps) => {
698
698
  ];
699
699
 
700
700
  const getWindowsNativeOpencodePackageNames = () => {
701
- // TEMPORARY WORKAROUND — Windows ARM64: native opencode.exe fails with a Bun
702
- // FFI/TinyCC dlopen error (https://github.com/anomalyco/opencode/issues/19130).
703
- // prepare-opencode-cli.mjs bundles x64-baseline instead; match that here so
704
- // the runtime resolver looks for the same x64-baseline package. Restore the
705
- // arm64 branch below when the upstream issue is resolved.
706
701
  if (process.arch === 'arm64') {
707
- // --- ORIGINAL (restore when ARM64 is fixed) ---
708
- // return ['@opencode/cli-windows-arm64', 'opencode-windows-arm64'];
709
- return WINDOWS_X64_NATIVE_PACKAGES;
702
+ return [path.join('@opencode', 'cli-windows-arm64'), 'opencode-windows-arm64'];
710
703
  }
711
704
  if (process.arch === 'x64') {
712
705
  // Prefer the baseline build when bypassing package-manager wrappers so the
@@ -103,6 +103,7 @@ export const createFeatureRoutesRuntime = (dependencies) => {
103
103
  createFsSearchRuntime,
104
104
  openchamberDataDir,
105
105
  onGuestDeactivated,
106
+ surfaceViewerHeaders,
106
107
  openchamberUserConfigRoot,
107
108
  managedChatsRoot,
108
109
  normalizeDirectoryPath,
@@ -331,7 +332,7 @@ export const createFeatureRoutesRuntime = (dependencies) => {
331
332
  registerGitHubRoutes(app);
332
333
  registerLinearRoutes(app);
333
334
  await registerBuiltInGuests({ persistPath: extensionsPersistPath(openchamberDataDir), root: routeDependencies.builtInExtensionsDir });
334
- registerGuestRoutes(app, { openchamberDataDir, openchamberVersion, resolveGitBinaryForSpawn, resolveOptionalProjectDirectory, getSmallModelService, onGuestDeactivated });
335
+ registerGuestRoutes(app, { openchamberDataDir, openchamberVersion, resolveGitBinaryForSpawn, resolveOptionalProjectDirectory, getSmallModelService, onGuestDeactivated, surfaceViewerHeaders });
335
336
  registerGitRoutes(app, {
336
337
  emitWorktreeChanged: ({ directories, at }) => {
337
338
  const clients = getOpenChamberEventClients();
@@ -1,4 +1,4 @@
1
- import { readOpenCodeInfo, isSupportedOpenCodeVersion, requireOpenCodeV2, UnsupportedOpenCodeVersionError } from './compatibility.js';
1
+ import { readOpenCodeInfo, readExternalOpenCodeVersion, isSupportedOpenCodeVersion, requireOpenCodeV2, UnsupportedOpenCodeVersionError } from './compatibility.js';
2
2
  import { spawn, spawnSync } from 'node:child_process';
3
3
  import net from 'node:net';
4
4
  import { stripAppImageArgv0Leak } from '../inherited-env.js';
@@ -677,6 +677,16 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
677
677
  }
678
678
  };
679
679
 
680
+ // The version of an explicitly configured server that answered but is not a
681
+ // supported OpenCode (v1, or 2.x below the minimum); null for anything else,
682
+ // including a server that is down.
683
+ const readUnsupportedExternalOpenCodeVersion = async (port, origin) => {
684
+ if (!port || port <= 0) return null;
685
+ const version = await readExternalOpenCodeVersion(origin ?? `http://127.0.0.1:${port}`, getOpenCodeAuthHeaders())
686
+ .catch(() => null);
687
+ return version && !isSupportedOpenCodeVersion(version) ? version : null;
688
+ };
689
+
680
690
  const waitForOpenCodePort = async (timeoutMs = 15000) => {
681
691
  if (state.openCodePort !== null) {
682
692
  return state.openCodePort;
@@ -991,7 +1001,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
991
1001
  }
992
1002
 
993
1003
  const info = await readOpenCodeInfo(response);
994
- if (!info) throw new Error('OpenCode did not return valid version information.');
1004
+ if (!info) throw new Error('The server did not identify itself as OpenCode 2.x. OpenChamber requires OpenCode 2.x; if the server runs an older OpenCode, upgrade it.');
995
1005
  if (!isSupportedOpenCodeVersion(info.version)) throw new UnsupportedOpenCodeVersionError(info.version);
996
1006
  state.isOpenCodeReady = true;
997
1007
  state.lastOpenCodeError = null;
@@ -1090,6 +1100,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
1090
1100
  const bootstrapOpenCodeAtStartup = async () => {
1091
1101
  const bootstrapStartedAt = performance.now();
1092
1102
  let bootstrapError = null;
1103
+ let unsupportedExternalVersion = null;
1093
1104
  recordStartupPerformance('opencode.bootstrap.start');
1094
1105
  try {
1095
1106
  // Before doing anything, reap any OpenCode process WE spawned in a prior
@@ -1130,6 +1141,20 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
1130
1141
  state.lastOpenCodeError = null;
1131
1142
  state.openCodeNotReadySince = 0;
1132
1143
  syncToHmrState();
1144
+ } else if (env.ENV_EFFECTIVE_PORT && (unsupportedExternalVersion = await readUnsupportedExternalOpenCodeVersion(
1145
+ env.ENV_EFFECTIVE_PORT,
1146
+ env.ENV_CONFIGURED_OPENCODE_HOST?.origin,
1147
+ ))) {
1148
+ // The configured server is an OpenCode this OpenChamber cannot use.
1149
+ // Attach to it anyway, not ready, so the compatibility check reports
1150
+ // its version instead of a managed instance silently replacing it.
1151
+ const label = env.ENV_CONFIGURED_OPENCODE_HOST ? env.ENV_CONFIGURED_OPENCODE_HOST.origin : `http://localhost:${env.ENV_EFFECTIVE_PORT}`;
1152
+ console.warn(`OpenCode ${unsupportedExternalVersion} at ${label} is not supported by this OpenChamber`);
1153
+ state.openCodeBaseUrl = env.ENV_CONFIGURED_OPENCODE_HOST?.origin ?? null;
1154
+ setOpenCodePort(env.ENV_EFFECTIVE_PORT);
1155
+ state.isExternalOpenCode = true;
1156
+ syncToHmrState();
1157
+ throw new UnsupportedOpenCodeVersionError(unsupportedExternalVersion);
1133
1158
  } else {
1134
1159
  // We never auto-attach to an arbitrary pre-existing OpenCode instance.
1135
1160
  // Attaching to an external server requires explicit opt-in via env
@@ -1156,6 +1181,9 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
1156
1181
  await waitForOpenCodeReady();
1157
1182
  } catch (error) {
1158
1183
  bootstrapError = error;
1184
+ // Skip-start mode assumed readiness up front; a server that never
1185
+ // proved itself must not keep reporting ready to startup diagnostics.
1186
+ state.isOpenCodeReady = false;
1159
1187
  console.error(`OpenCode readiness check failed: ${error.message}`);
1160
1188
  }
1161
1189
  } catch (error) {
@@ -240,6 +240,33 @@ describe('OpenCode lifecycle', () => {
240
240
  expect(runtime.testState.openCodeBaseUrl).toBe('http://seamus:4095');
241
241
  });
242
242
 
243
+ it('attaches to an OPENCODE_HOST running OpenCode v1 instead of starting a managed server', async () => {
244
+ const requested = [];
245
+ globalThis.fetch = vi.fn(async (url) => {
246
+ const href = String(url);
247
+ requested.push(href);
248
+ if (href.endsWith('/global/health')) return Response.json({ healthy: true, version: '1.18.32' });
249
+ return new Response('<html>OpenCode</html>', { headers: { 'content-type': 'text/html' } });
250
+ });
251
+ const runtime = createRuntime({
252
+ reapManagedOrphanedProcesses: vi.fn(async () => ({ reaped: 0 })),
253
+ }, {}, {
254
+ ENV_CONFIGURED_OPENCODE_PORT: null,
255
+ ENV_CONFIGURED_OPENCODE_HOST: { origin: 'http://seamus:4095', port: 4095 },
256
+ ENV_EFFECTIVE_PORT: 4095,
257
+ });
258
+
259
+ await runtime.bootstrapOpenCodeAtStartup();
260
+
261
+ expect(spawnMock).not.toHaveBeenCalled();
262
+ expect(requested).toContain('http://seamus:4095/global/health');
263
+ expect(runtime.testState.isExternalOpenCode).toBe(true);
264
+ expect(runtime.testState.isOpenCodeReady).toBe(false);
265
+ expect(runtime.testState.openCodeBaseUrl).toBe('http://seamus:4095');
266
+ expect(runtime.testState.openCodePort).toBe(4095);
267
+ expect(runtime.testState.lastOpenCodeError).toContain('1.18.32');
268
+ });
269
+
243
270
  it('warms recently used directories after a successful bootstrap', async () => {
244
271
  const fetchMock = vi.fn(async () => ({
245
272
  ok: true,