@openchamber/web 2.3.2 → 2.3.3

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 (213) hide show
  1. package/dist/assets/{AboutDialog-MZbHWRua.js → AboutDialog-Ctk2zvrv.js} +1 -1
  2. package/dist/assets/{ArchiveView-CkeSWPcI.js → ArchiveView-sbNreasJ.js} +1 -1
  3. package/dist/assets/{CommandPalette-CtKzNzwW.js → CommandPalette-BICwnwAZ.js} +2 -2
  4. package/dist/assets/{DiffView-DaXjHTAq.js → DiffView-B5yeuxv8.js} +1 -1
  5. package/dist/assets/{FilesView-DMNYEydF.js → FilesView-ni2zfAwL.js} +7 -7
  6. package/dist/assets/{GitView-HXttTpUw.js → GitView-C0QgeC9O.js} +3 -3
  7. package/dist/assets/{GuestSurfacePane-KzguENQG.js → GuestSurfacePane-D1gLktSj.js} +1 -1
  8. package/dist/assets/{HelpDialog-9YZGhBgT.js → HelpDialog-CxC6qTaS.js} +1 -1
  9. package/dist/assets/{InProgressOperationBanner-DzGIwGH2.js → InProgressOperationBanner-JFV70YFh.js} +1 -1
  10. package/dist/assets/{JsonTreeView-D9rP8jM8.js → JsonTreeView-RsbV4Usa.js} +1 -1
  11. package/dist/assets/MarkdownRendererImpl-CZK5DoOX.js +1 -0
  12. package/dist/assets/{MemoryDebugPanel-Ct0h3RWh.js → MemoryDebugPanel-caUWOKiz.js} +1 -1
  13. package/dist/assets/{OnboardingScreen-B5Zzb1Mp.js → OnboardingScreen-BDT-J2JP.js} +1 -1
  14. package/dist/assets/{OpenCodeStatusDialog-CXBWWRh8.js → OpenCodeStatusDialog-Cxa2yqOB.js} +1 -1
  15. package/dist/assets/{PatchDiff-DhDAQ5em.js → PatchDiff-C1pnbAsJ.js} +1 -1
  16. package/dist/assets/{PierreDiffViewer-DPa08AmN.js → PierreDiffViewer-D0zX2Msu.js} +1 -1
  17. package/dist/assets/PlanView-BxRCMuGe.js +5 -0
  18. package/dist/assets/{ProjectActionsDialog-DATu0aBc.js → ProjectActionsDialog-D660By4K.js} +1 -1
  19. package/dist/assets/{RunOverview-D6xy_vME.js → RunOverview-C1uTMnQS.js} +2 -2
  20. package/dist/assets/{ScheduledTasksDialog-BWXVnfrf.js → ScheduledTasksDialog-S-gAgo7Z.js} +5 -5
  21. package/dist/assets/SettingsView-CVpfbdob.js +30 -0
  22. package/dist/assets/{SettingsWindow-Cx6TrtY0.js → SettingsWindow-Dd1hHvgh.js} +1 -1
  23. package/dist/assets/SourceBoardView-DbGWAxtS.js +1 -0
  24. package/dist/assets/SpaceAccessDialog-muTSsEJ9.js +1 -0
  25. package/dist/assets/{SpaceApplyDialog-BtuwtlaG.js → SpaceApplyDialog-Dsf6MNGm.js} +1 -1
  26. package/dist/assets/{SpaceRow-MXqvd-dr.js → SpaceRow-7Z6ebRtm.js} +1 -1
  27. package/dist/assets/{SpaceSetupOutput-Uo5LS7Jy.js → SpaceSetupOutput-BytPfCOC.js} +1 -1
  28. package/dist/assets/{SpacesView-DvoOh4sM.js → SpacesView-CYCrlp0D.js} +1 -1
  29. package/dist/assets/{SubmoduleDiffSummary-CyMwDeoP.js → SubmoduleDiffSummary-VrNUbIqF.js} +1 -1
  30. package/dist/assets/{ToolOutputDialog-BaUZIVzc.js → ToolOutputDialog-DHORjBND.js} +7 -7
  31. package/dist/assets/{ToolPartDiffPreview-DmMwdcF4.js → ToolPartDiffPreview-BLAXe7C5.js} +1 -1
  32. package/dist/assets/{UsageStatsView-D7WrDBTC.js → UsageStatsView-BxtYEAa0.js} +1 -1
  33. package/dist/assets/{Virtualizer-CnU8pYMb.js → Virtualizer-Bl4Cf-H-.js} +1 -1
  34. package/dist/assets/{WalkthroughView-r0Ho9F4Z.js → WalkthroughView-B2BJJ4u5.js} +2 -2
  35. package/dist/assets/{WorktreesView-C-t7uxq1.js → WorktreesView-Dv0AO9dF.js} +1 -1
  36. package/dist/assets/{appThemeRegistry-BUY7Ge9i.js → appThemeRegistry-xm_W0svA.js} +1 -1
  37. package/dist/assets/{ar-HauNhDvN.js → ar-Cj8UF12m.js} +4 -4
  38. package/dist/assets/{computeVirtualFileMetrics-CUof18z3.js → computeVirtualFileMetrics-Cx05cmWI.js} +2 -2
  39. package/dist/assets/{de-fEoJ_Yyp.js → de-fSQ1ho01.js} +4 -4
  40. package/dist/assets/{decorate-BkTSGAlD.js → decorate-jpF7GA6t.js} +2 -2
  41. package/dist/assets/{es-CKNTBsZW.js → es-DrdzhSlK.js} +5 -5
  42. package/dist/assets/{fileContentPoller-BJWgy1fX.js → fileContentPoller-C0f20jNG.js} +3 -3
  43. package/dist/assets/{flexokiTheme-BArobfXV.js → flexokiTheme-DKNCYSqL.js} +1 -1
  44. package/dist/assets/{fr-C23655Pi.js → fr-Cmz6Da4q.js} +4 -4
  45. package/dist/assets/{he-CphXS_Fv.js → he-COJRUNy4.js} +4 -4
  46. package/dist/assets/{index-B27cSA9V.js → index-C8Mw8uvl.js} +1 -1
  47. package/dist/assets/{initializeSharedPreferences-CucsmDMw.js → initializeSharedPreferences-U9-v9mfq.js} +1 -1
  48. package/dist/assets/{isDiffPlainText-DSCjvV0m.js → isDiffPlainText-DW43IghW.js} +1 -1
  49. package/dist/assets/{isFilePlainText-C7g4UPox.js → isFilePlainText-Duq5CiuG.js} +1 -1
  50. package/dist/assets/{ja-BmsU2iQe.js → ja-Ce0NvDHZ.js} +4 -4
  51. package/dist/assets/katex-BZNCT55U.css +1 -0
  52. package/dist/assets/katex.min-EZjpSwGK.js +65 -0
  53. package/dist/assets/{ko-CxISpkje.js → ko-BGFcCLLq.js} +4 -4
  54. package/dist/assets/main-BUetg9hg.js +1048 -0
  55. package/dist/assets/{main-CGPiw9fS.js → main-Be_jmIlF.js} +2 -2
  56. package/dist/assets/markdownCore-BkTeS4gA.js +10 -0
  57. package/dist/assets/{miniChat-DVEKVYKe.js → miniChat-g1RgiLLS.js} +2 -2
  58. package/dist/assets/{mobile-Q_FVBe4I.js → mobile-DBli3U-T.js} +2 -2
  59. package/dist/assets/{moveWorkspacePath-CyZJ-2aD.js → moveWorkspacePath-CnYc96Xo.js} +1 -1
  60. package/dist/assets/{nl-jnTBQ_gU.js → nl-Cu1nxo5t.js} +4 -4
  61. package/dist/assets/{parseDiffFromFile-OHXXXyzL.js → parseDiffFromFile-DEjkjYod.js} +3 -3
  62. package/dist/assets/{patchFileDiff-BZrb6h2u.js → patchFileDiff-D__42sau.js} +5 -5
  63. package/dist/assets/{pierreDiffTint-DHf2xvyt.js → pierreDiffTint-3oatL635.js} +4 -4
  64. package/dist/assets/pl-4LdEMgWI.js +20 -0
  65. package/dist/assets/{pt-BR-BfpsFrHv.js → pt-BR-2UbEBNgC.js} +5 -5
  66. package/dist/assets/{relocateRestoredSession-DInneXVI.js → relocateRestoredSession-pkxyd_lV.js} +1 -1
  67. package/dist/assets/renderElectronMiniChatApp-D0tKJFBB.js +2 -0
  68. package/dist/assets/renderMobileApp-D6bOYHuP.js +25 -0
  69. package/dist/assets/{restartOpenCode-DwBaMPJK.js → restartOpenCode-FYqjpaWc.js} +1 -1
  70. package/dist/assets/runtimeEndpointReset-6CNNzem4.js +74 -0
  71. package/dist/assets/{scheduledTasksApi-ClJplEhR.js → scheduledTasksApi-BbnQ4W-W.js} +1 -1
  72. package/dist/assets/{selectionMarkdown-BuveYuup.js → selectionMarkdown-D8QAxC44.js} +1 -1
  73. package/dist/assets/sessionOwnership-BBuf0UCB.js +1 -0
  74. package/dist/assets/{shikiHighlight-DJAESrna.js → shikiHighlight-CweIj1cL.js} +1 -1
  75. package/dist/assets/{space-apply-DWFLwXbI.js → space-apply-CEi013sa.js} +1 -1
  76. package/dist/assets/{space-close-BYDbwdWc.js → space-close-BuStkLrZ.js} +1 -1
  77. package/dist/assets/{spaceNetwork-DHrhfbKM.js → spaceNetwork-tH2d5Mgs.js} +1 -1
  78. package/dist/assets/{textMateThemeFromAppTheme-DcAZmUlv.js → textMateThemeFromAppTheme-DLJBL6al.js} +1 -1
  79. package/dist/assets/tr-Bg0Qt-mG.js +11 -0
  80. package/dist/assets/{uk-C82aEtvs.js → uk-vcnOugr0.js} +5 -5
  81. package/dist/assets/useAppFontEffects-Cs6k0JKv.js +773 -0
  82. package/dist/assets/{useCallableModelProviders-BU_455MN.js → useCallableModelProviders-BsGEzsl2.js} +1 -1
  83. package/dist/assets/{useInlineCommentController-AuUrVz9U.js → useInlineCommentController-CVYaPzfO.js} +2 -2
  84. package/dist/assets/{useRootScrollLock-Cpk7NmBa.js → useRootScrollLock-Dov-44ov.js} +2 -2
  85. package/dist/assets/{vendor-codemirror-language-data-BYGweLoh.js → vendor-codemirror-language-data-DBekkZIx.js} +2 -2
  86. package/dist/assets/vendor-tanstack-react-virtual-Dozz-7fb.js +1 -0
  87. package/dist/assets/vendor-tanstack-virtual-core-DKBj55Em.js +1 -0
  88. package/dist/assets/{vendor-yaml-3778uTud.js → vendor-yaml-CE-D_49-.js} +1 -1
  89. package/dist/assets/{zh-CN-DEq7j9I5.js → zh-CN-C3UhwFsk.js} +5 -5
  90. package/dist/assets/{zh-TW-DgCN99T-.js → zh-TW-D0CmmMvp.js} +5 -5
  91. package/dist/index.html +3 -3
  92. package/dist/mini-chat.html +3 -3
  93. package/dist/mobile.html +3 -3
  94. package/package.json +5 -5
  95. package/server/index.js +13 -1
  96. package/server/lib/agent-memory/actions.js +22 -9
  97. package/server/lib/agent-memory/actions.test.js +57 -0
  98. package/server/lib/agent-memory/runtime.js +8 -5
  99. package/server/lib/agent-tool/DOCUMENTATION.md +17 -1
  100. package/server/lib/agent-tool/runtime.js +41 -7
  101. package/server/lib/agent-tool/runtime.test.js +11 -0
  102. package/server/lib/git/DOCUMENTATION.md +17 -5
  103. package/server/lib/git/lfs-discovery.js +7 -4
  104. package/server/lib/git/lfs-discovery.test.js +60 -0
  105. package/server/lib/git/network-operations.js +9 -3
  106. package/server/lib/git/network-operations.test.js +31 -2
  107. package/server/lib/git/service.js +72 -12
  108. package/server/lib/git/service.test.js +65 -0
  109. package/server/lib/github/DOCUMENTATION.md +1 -0
  110. package/server/lib/github/reference-search.js +49 -18
  111. package/server/lib/github/reference-search.test.js +28 -6
  112. package/server/lib/github/routes.js +87 -1
  113. package/server/lib/github/routes.mutations.test.js +38 -0
  114. package/server/lib/github/routes.test.js +1 -0
  115. package/server/lib/gitlab/DOCUMENTATION.md +4 -0
  116. package/server/lib/gitlab/client.js +23 -0
  117. package/server/lib/gitlab/client.test.js +28 -1
  118. package/server/lib/gitlab/mappers.js +9 -0
  119. package/server/lib/gitlab/resources.js +153 -4
  120. package/server/lib/gitlab/resources.test.js +107 -0
  121. package/server/lib/gitlab/routes.js +120 -1
  122. package/server/lib/gitlab/routes.test.js +59 -0
  123. package/server/lib/markdown-image-grants/DOCUMENTATION.md +4 -0
  124. package/server/lib/markdown-image-grants/routes.js +14 -2
  125. package/server/lib/markdown-image-grants/routes.test.js +23 -0
  126. package/server/lib/notifications/APNS.md +24 -23
  127. package/server/lib/notifications/DOCUMENTATION.md +2 -2
  128. package/server/lib/notifications/apns-runtime.js +8 -5
  129. package/server/lib/notifications/apns-runtime.test.js +26 -0
  130. package/server/lib/notifications/message.js +5 -3
  131. package/server/lib/notifications/message.test.js +9 -0
  132. package/server/lib/notifications/runtime.js +44 -9
  133. package/server/lib/notifications/trigger-runtime.test.js +84 -0
  134. package/server/lib/openchamber-control/DOCUMENTATION.md +6 -1
  135. package/server/lib/openchamber-control/actions.js +18 -2
  136. package/server/lib/openchamber-control/project-knowledge.js +17 -3
  137. package/server/lib/openchamber-control/project-knowledge.test.js +14 -0
  138. package/server/lib/openchamber-control/render-page.js +58 -0
  139. package/server/lib/openchamber-control/service.js +9 -0
  140. package/server/lib/openchamber-control/service.test.js +43 -0
  141. package/server/lib/openchamber-sessions/routes.js +1 -0
  142. package/server/lib/openchamber-sessions/worktree-move.js +26 -10
  143. package/server/lib/openchamber-sessions/worktree-move.test.js +36 -0
  144. package/server/lib/opencode/DOCUMENTATION.md +1 -1
  145. package/server/lib/opencode/managed-config-file.js +3 -2
  146. package/server/lib/opencode/managed-config-file.test.js +20 -6
  147. package/server/lib/opencode/settings-helpers.js +3 -0
  148. package/server/lib/opencode/settings-helpers.test.js +1 -1
  149. package/server/lib/opencode/settings-registry.json +3 -0
  150. package/server/lib/opencode/settings-runtime.js +1 -0
  151. package/server/lib/project-context/DOCUMENTATION.md +25 -1
  152. package/server/lib/project-context/plan-progress.js +69 -0
  153. package/server/lib/project-context/plan-progress.test.js +58 -0
  154. package/server/lib/project-context/routes.http.test.js +22 -0
  155. package/server/lib/project-context/routes.js +20 -0
  156. package/server/lib/project-context/runtime.js +132 -18
  157. package/server/lib/project-context/runtime.test.js +58 -0
  158. package/server/lib/provider-read-cache/index.js +7 -1
  159. package/server/lib/provider-read-cache/index.test.js +12 -0
  160. package/server/lib/relay/DOCUMENTATION.md +17 -1
  161. package/server/lib/session-knowledge/DOCUMENTATION.md +17 -0
  162. package/server/lib/session-knowledge/runtime.js +29 -6
  163. package/server/lib/session-knowledge/runtime.test.js +26 -1
  164. package/server/lib/source-control/audit-storage.js +1 -0
  165. package/server/lib/source-control/mutation-storage.js +3 -0
  166. package/server/lib/spaces/DOCUMENTATION.md +14 -9
  167. package/server/lib/spaces/code-out.js +13 -4
  168. package/server/lib/spaces/code-out.test.js +5 -3
  169. package/server/lib/spaces/dispatcher.js +12 -5
  170. package/server/lib/spaces/dispatcher.test.js +19 -1
  171. package/server/lib/spaces/gatekeeper-channel.js +8 -7
  172. package/server/lib/spaces/gatekeeper-channel.test.js +10 -0
  173. package/server/lib/spaces/gatekeeper-program.cjs +38 -3
  174. package/server/lib/spaces/gatekeeper-program.test.js +20 -0
  175. package/server/lib/spaces/hardening.js +14 -1
  176. package/server/lib/spaces/hardening.test.js +5 -0
  177. package/server/lib/spaces/host-providers.js +165 -0
  178. package/server/lib/spaces/host-providers.test.js +100 -0
  179. package/server/lib/spaces/host.js +16 -4
  180. package/server/lib/spaces/journey.js +87 -17
  181. package/server/lib/spaces/journey.test.js +90 -2
  182. package/server/lib/spaces/layout.js +15 -5
  183. package/server/lib/spaces/places/docker-live-support.js +2 -0
  184. package/server/lib/spaces/places/docker.test.js +2 -0
  185. package/server/lib/spaces/places/fake-docker.js +3 -0
  186. package/server/lib/spaces/places/grants.docker.live.test.js +71 -7
  187. package/server/lib/spaces/routes.js +9 -0
  188. package/server/lib/spaces/routes.test.js +4 -2
  189. package/server/lib/spaces/space-opencode.js +31 -14
  190. package/server/lib/spaces/space-opencode.test.js +15 -2
  191. package/server/lib/spaces/space-records.js +8 -0
  192. package/server/lib/spaces/space-records.test.js +7 -3
  193. package/server/lib/spaces/websocket.test.js +13 -1
  194. package/server/lib/ui-auth/ui-auth.js +28 -3
  195. package/server/lib/ui-auth/ui-auth.test.js +31 -0
  196. package/dist/assets/MarkdownRendererImpl-B2LsA09C.js +0 -1
  197. package/dist/assets/PlanView-Dt5EN_JK.js +0 -5
  198. package/dist/assets/SettingsView-BolP_tuu.js +0 -30
  199. package/dist/assets/SourceBoardView-yca1qvgB.js +0 -1
  200. package/dist/assets/SpaceAccessDialog-CZ-u75py.js +0 -1
  201. package/dist/assets/katex-rNcbfUj4.css +0 -1
  202. package/dist/assets/katex.min-DQ8qF6NR.js +0 -65
  203. package/dist/assets/main-CVHM3_8W.js +0 -1048
  204. package/dist/assets/markdownCore-D5ZOJXeO.js +0 -9
  205. package/dist/assets/pl-Bj-Hy0X5.js +0 -20
  206. package/dist/assets/renderElectronMiniChatApp-B_5BeSF6.js +0 -2
  207. package/dist/assets/renderMobileApp-DGEXUTk-.js +0 -25
  208. package/dist/assets/runtimeEndpointReset-CIpvn8QG.js +0 -59
  209. package/dist/assets/sessionOwnership-BZoGed9N.js +0 -1
  210. package/dist/assets/tr-qMRMBQ8r.js +0 -11
  211. package/dist/assets/useAppFontEffects-Bih1DxXi.js +0 -745
  212. package/dist/assets/vendor-tanstack-react-virtual-CvuLsk7D.js +0 -1
  213. package/dist/assets/vendor-tanstack-virtual-core-DPaNcJcT.js +0 -1
@@ -59,6 +59,7 @@ Creating, finding, stopping, starting, and removing isolated spaces on a place,
59
59
  - `dispatcher.js`: `createSpaceDispatcher({ transport })`. The thin layer in front of the host's routes that forwards a request addressed to a space, and the two guards. See "Dispatcher".
60
60
  - `host.js`: `createSpacesHost({ dataDir, dockerPath, sshDockerHost, gitPath, hostEnvironment, listProjectDirectories })`. What `server/index.js` builds when the switch is on: the owner id, the Docker place and, when the settings name a machine, the Docker over SSH place, the registry, the manager that routes by record, the dispatcher, the gatekeeper channel, code in and code out on one host git, the records and the journey, with the hooks the rest of the server takes from it. Every channel to a space goes through the manager, so each reaches the space's own place.
61
61
  - `login-keeper.js`: `createLoginKeeper({ readLogin, renewLogin, exchange, holders, say })` and `createLoginExchange({ fetch, userAgent })`. Keeps the host's browser login fresh for the running spaces that hold it, and says it to their gatekeepers again when it changed. See "Grants".
62
+ - `host-providers.js`: `createHostProviders({ readLayers, readStoredKey, hostEnvironment })`. The providers the user defined in the host's OpenCode configuration, "custom" in Settings, as a space can be given them: `read(providerId, directory)` one with its key, `list(directory)` all of them without. Also `windowUpstreamOf`, which sends "this machine" in a base URL to the Docker host, and `headerOfPackage`. See "Grants".
62
63
  - `journey.js`: `createSpaceJourney({ manager, place, gatekeeper, codeIn, codeOut, records, serverInside, restartOpenCodeInside, listProjectDirectories, announce, onSpacesChanged })`. The journey of a space as the host drives it, written once on top of those: create in the background with progress, list with state and what is broken, start with the network said again, stop, the two restarts of the repair, remove with the refs and the record, stop all for the switch, the journal, the apply preview and the apply. See "The journey".
63
64
  - `routes.js`: `registerSpaceRoutes(app, { getJourney, getPlaces, readSwitch, setSwitch })`, the HTTP of the journey under `/api/openchamber/spaces`, which translates and nothing else; and `createSwitchController({ getHost, setHost, buildHost, startHost, persist })`, the switch as `index.js` runs it, one change at a time.
64
65
  - `space-archive.js`: `createSpaceArchive({ dataDir, hostOpenCode })`. Since 5e-2, the chats of a deleted space: saved into the host's OpenCode before the space goes, listed for the Archive page, and kept read-only by `guard`. See "Chat archive" under "The journey".
@@ -344,7 +345,7 @@ Measured on Docker 29.2.1, Colima, linux/arm64, with the pinned image:
344
345
 
345
346
  ### The gatekeeper container
346
347
 
347
- `buildGatekeeperCreateArgs` and `findGatekeeperHardeningViolations` belong together, exactly as the space's pair does. The gatekeeper gets everything the space gets: `--init`, `--user 1000:1000`, `--read-only`, a size-limited `nosuid` tmpfs, `--security-opt no-new-privileges`, `--cap-drop ALL`, `--pids-limit 512`, equal `--memory` and `--memory-swap`, `--shm-size 64m`, `--ipc private --cgroupns private`, the same log cap, no bind mount, no `--volumes-from`, no runtime socket, no sysctl, no device, no published port, and none of the forbidden environment variables. Three things differ, and the checker demands each of them:
348
+ `buildGatekeeperCreateArgs` and `findGatekeeperHardeningViolations` belong together, exactly as the space's pair does. The gatekeeper gets everything the space gets: `--init`, `--user 1000:1000`, `--read-only`, a size-limited `nosuid` tmpfs, `--security-opt no-new-privileges`, `--cap-drop ALL`, `--pids-limit 512`, equal `--memory` and `--memory-swap`, `--shm-size 64m`, `--ipc private --cgroupns private`, the same log cap, no bind mount, no `--volumes-from`, no runtime socket, no sysctl, no device, no published port, and none of the forbidden environment variables. Four things differ; the checker demands the first three and allows the fourth and nothing beyond it:
348
349
 
349
350
  | Difference | Why |
350
351
  |---|---|
@@ -352,6 +353,7 @@ Measured on Docker 29.2.1, Colima, linux/arm64, with the pinned image:
352
353
  | No mount at all. The checker demands zero mounts. | Its only writable place is its tmpfs, which is gone when the container stops. It holds no volume, so nothing it holds survives it, and there is no shared volume for an agent to read. |
353
354
  | `--memory 256m --memory-swap 256m`, and the checker demands that exact value. | Measured: an idle gatekeeper with its three listeners holds about 24 MiB. 256 MiB is ten times that. The tunnel cap is 64 and two sockets with their buffers cost well under a megabyte each, so a gatekeeper at its busiest stays far below the limit, and a leak is still capped. A space's 4 GiB would be for an agent, and this is not one. |
354
355
  | `--tmpfs /tmp:rw,noexec,nosuid,size=16m` where a space gets `rw,exec,nosuid,size=256m`. | One file lives there, the program, and Node reads it. Nothing runs from it. |
356
+ | `--add-host host.docker.internal:host-gateway`, and the checker allows that one extra name and no other; a space gets none, and the checker reports any. | A custom provider of the user's that listens on the Docker host, Ollama on the user's own machine the common case, is granted with its loopback address replaced by this name (see "Grants"). Docker Desktop and Colima resolve the name on their own, and a request to it reaches a service on the Mac's loopback. A Linux daemon needs `host-gateway`, which gives it the address of the host's bridge, `172.17.0.1` by default: a service bound to `127.0.0.1` only, Ollama's default, does not answer there, so on Linux the service must listen on the bridge address or on all interfaces, or every request of the space lands in the journal as `failed:ECONNREFUSED` while the dialog says "Has access". Known limit, not measured on a Linux daemon yet. The space's network has no way to the host, so a name there would resolve to nothing the space can reach, and it gets none. |
355
357
 
356
358
  Its environment is `HOME=/tmp` and nothing else: the root filesystem is read-only, and a program that resolves HOME must land somewhere writable. No secret is ever in the environment, in an argument, in a label, or on disk. A grant arrives on the stdin of an `exec` and lives in the program's memory.
357
359
 
@@ -409,7 +411,7 @@ An HTTP CONNECT proxy on the space-facing interface. Stage 0 proved that OpenCod
409
411
 
410
412
  ### Window
411
413
 
412
- A reverse proxy on the same interface, for services whose secret must not enter the space. `/model/<grant id>/<rest>` goes to that grant's upstream with `<rest>` appended to the upstream's path unchanged, and with the grant's own header set: `Authorization: Bearer <key>` for OpenAI-style APIs, `x-api-key: <key>` for Anthropic, `x-goog-api-key` for Google. Whatever the space sent as `authorization`, `x-api-key`, `proxy-authorization` or under the grant's own header name is removed first. Since 5b a grant may have no secret, an opened domain: the window then adds nothing and forwards the request as the space made it, less those credential headers. The path stays `/model/` for both kinds; it names the window, not what is behind it. An unknown grant id is 403 and journalled. A grant id is never guessable from inside, and it is treated as public anyway: nothing relies on it being secret.
414
+ A reverse proxy on the same interface, for services whose secret must not enter the space. `/model/<grant id>/<rest>` goes to that grant's upstream with `<rest>` appended to the upstream's path unchanged, and with the grant's own header set: `Authorization: Bearer <key>` for OpenAI-style APIs, `x-api-key: <key>` for Anthropic, `x-goog-api-key` for Google. Whatever the space sent as `authorization`, `x-api-key`, `proxy-authorization` or under the grant's own header name is removed first. A grant may carry extra headers of its own, a custom provider's from Settings: the window sets each one over whatever the space sent under its name, so they are as hidden from the space as the key. Their names may not be the credential names, `host`, `content-length` or the hop-by-hop ones, at most 32 of them, each value text up to the secret's length. Since 5b a grant may have no secret, an opened domain: the window then adds nothing and forwards the request as the space made it, less those credential headers. The path stays `/model/` for both kinds; it names the window, not what is behind it. An unknown grant id is 403 and journalled. A grant id is never guessable from inside, and it is treated as public anyway: nothing relies on it being secret.
413
415
 
414
416
  A grant opens a place on a host, not the host: a rest of the path that climbs out of it is refused with `deny:path-walks-out`, because with git and a private registry the path is what says which repository or which package. It is the same host and the same credential either way, so this is a door closed before those windows land rather than an escape today.
415
417
 
@@ -431,7 +433,7 @@ An HTTP listener on the gatekeeper's own loopback, which the space cannot reach.
431
433
  |---|---|
432
434
  | `GET /health` | Answers 200 once all three listeners are up. It is the last to bind, so an answer means the corridor accepts connections. |
433
435
  | `POST /network` | `{ mode, domains }`. Replaces both. |
434
- | `POST /grants` | `{ id, upstream, header, secret }`, or `{ id, upstream }` for an opened domain. Adds or replaces one grant. A header without a secret, or a secret without a header, is refused. |
436
+ | `POST /grants` | `{ id, upstream, header, secret }`, or `{ id, upstream }` for an opened domain, either with an optional `headers` object of the grant's own. Adds or replaces one grant. A header without a secret, or a secret without a header, is refused; so is a `headers` name the window owns, the one that carries the secret among them. |
435
437
  | `GET /policy` | Since 5b: `{ mode, domains, grants }`, the ids of the grants and never a secret, so the host can tell a gatekeeper that forgot from one that remembers. |
436
438
  | `GET /journal` | The records and how many were dropped. |
437
439
 
@@ -464,6 +466,7 @@ The decisions are `allow`, `failed:<error code>` for a host that was allowed and
464
466
 
465
467
  - The corridor and the window listen on the gatekeeper's address on the space's inner network only, since 5b. Before that they listened on every interface, and **on Linux that included the user's own machine**: a Linux Docker host routes into the bridge subnet, so any local process could reach both listeners without a published port. Measured on Debian 13, amd64, Engine 29.8.1, before the change: from the host, `curl http://<the gatekeeper's outer address>:8080/` connected and read the window's answer. On macOS and Windows a virtual machine stands between the host and the bridge, which is why a Mac-only run could never have shown it. The space could never use it, and that was not the point: an unprivileged local process on a Linux desktop could have spent the user's model key once a real one sat behind the window, which 5b is the first stage to do. Of the two ways considered, a secret the host hands the window with the grant that every request carries, or binding the window to the inner address, the bind address was taken: the host decides where the gatekeeper listens, and the program has no policy of its own. The escape suite proves it with a neighbour on the outer network, which reaches the stand-in upstream beside it and is refused on the gatekeeper's outer address on all three ports, and the same measurement from a Linux host is repeated with each stage that touches the listeners.
466
468
  - Nothing attached to the space's outer network can use the two listeners either, for the same reason; the stand-in upstream of the escape suite is the neighbour that proves it.
469
+ - The program is written at a start, so a gatekeeper made before the custom provider headers runs the program it started with until its space is stopped and started once. That program reads no `headers` on a grant and ignores the field: a headers grant to such a space answers success and the window sends every request without them until the next start. The feature is behind the hidden switch, so only development spaces meet this; a check of the running program at grant time is a follow-up.
467
470
  - A tunnel the upstream half-closed stays open, because a close travels in each direction on its own. Measured: 64 of those with live clients means the 65th is refused, and all 64 places come back as the clients let go. That is the tunnel cap doing its job on genuinely open tunnels rather than a leak, and the idle limit ends one that goes quiet.
468
471
  - Port 443 only. A tool that needs another port cannot be reached until the grant dialog can open one.
469
472
  - The corridor takes names, so a tool that only knows an address, and that the user cannot give a name, cannot be reached either.
@@ -519,7 +522,7 @@ The dispatcher reads no body, so a prefixed request whose body names a directory
519
522
 
520
523
  Refused with 403 and `host_only_route`, whatever the server inside would say: `/api/provider`, `/api/providers`, `/api/integration`, `/api/credential`, `/api/auth`, `/api/config/settings`, `/api/config/themes`, `/api/themes`, `/api/github`, `/api/linear`, `/api/voice`, `/api/tts`, `/api/dictation`, `/api/guests`, `/api/projects`, `/api/client-auth`, `/api/system`, `/api/push`, `/api/notifications` and `/api/openchamber/tunnel`. Refused with 403 and `refused_across_boundary`: `/api/git/worktrees`, `/api/git/project-worktrees`, `/api/git/worktree-type`, `/api/git/integrate`, `/api/fs/preview` (and the older `/api/fs/serve`), `/api/preview/proxy` and `/api/session/<id>/move`. A route matches as a whole path segment, so `/api/config/agents` is forwarded while `/api/config/settings` is not. The lists are `HOST_ONLY_ROUTES` and `REFUSED_ACROSS_BOUNDARY_ROUTES` in `dispatcher.js`.
521
524
 
522
- An unknown or malformed space id is 404 with `space_not_found`. A space that is stopped or in the middle of a move is 503 with the place's code. A token that cannot be read, a setup step that failed inside, and a refused login are 502 with their code. Everything else on the way, the bridge included, is 502 with `space_unreachable`.
525
+ An unknown or malformed space id is 404 with `space_not_found`, but only when every configured place answered its list: while one could not be asked, an id no list holds is that place's failure, 502 with `space_unreachable`, since the space may well be there. A space that is stopped or in the middle of a move is 503 with the place's code. A token that cannot be read, a setup step that failed inside, and a refused login are 502 with their code. Everything else on the way, the bridge included, is 502 with `space_unreachable`.
523
526
 
524
527
  ### What comes back
525
528
 
@@ -541,7 +544,7 @@ The new paths joined the three allowlists by shape, as the guest surfaces did, i
541
544
 
542
545
  The merged list and the rules for it live in `space-sessions.js`, pure; `host.js` reads the spaces and the proxy asks for the merge.
543
546
 
544
- **The merged session list.** `GET /api/session` on the host is the host's list, sanitized and overlaid as before, plus every space's sessions after it, on the first page of the global list only: a request with a `cursor` is a later page of the host's list, and a request with a `directory`, in the query or in the `x-opencode-directory` header, which is what the sidebar reads once per project, is that directory's list; neither carries a space. The host reads its list of spaces, cached for two seconds, and asks every space at the same time for `/api/session` over the dispatcher's own channel, in pages of a hundred, at most ten pages, with a ten-second limit per page; a space's accepted list is served again for two seconds without asking it, so a burst of list requests costs each space one read. The answer carries a mark per space in `spaces`: `complete`, `partial` when the space had more pages than were read, `stale` when the space did not answer and its last accepted list stands in, and `unknown` when it never answered, in which case it has no records. Each mark also names the space: its `name` from the label, the registered host project it was made for as `projectDirectory`, resolved from the label's hash of the project path against the projects `server/index.js` hands the host, and the project's path inside as `directory`, both `null` when the project is not registered here. The UI's sidebar hangs the space's group on that project. A missing answer never means deletion: a stopped or unreachable space keeps the sessions it last listed, and the client learns from the mark that they are old. An empty answer is an answer, and empties the space's list. A host list when no space exists goes back as the very same object, untouched. The order is the place's list, so the merged list reads the same from one call to the next.
547
+ **The merged session list.** `GET /api/session` on the host is the host's list, sanitized and overlaid as before, plus every space's sessions after it, on the first page of the global list only: a request with a `cursor` is a later page of the host's list, and a request with a `directory`, in the query or in the `x-opencode-directory` header, which is what the sidebar reads once per project, is that directory's list; neither carries a space. The host reads its list of spaces, cached for two seconds, and asks every space at the same time for `/api/session` over the dispatcher's own channel, in pages of a hundred, at most ten pages, with a ten-second limit per page; a space's accepted list is served again for two seconds without asking it, so a burst of list requests costs each space one read. The answer carries a mark per space in `spaces`: `complete`, `partial` when the space had more pages than were read, `stale` when the space did not answer and its last accepted list stands in, and `unknown` when it never answered, in which case it has no records. Each mark also names the space: its `name` from the label, the registered host project it was made for as `projectDirectory`, resolved from the label's hash of the project path against the projects `server/index.js` hands the host, and the project's path inside as `directory`, both `null` when the project is not registered here. The UI's sidebar hangs the space's group on that project. A missing answer never means deletion: a stopped or unreachable space keeps the sessions it last listed, and the client learns from the mark that they are old. The sidebar puts a warning mark beside the group's name only when the line under the group says nothing, which leaves a running space whose list came back in part; a space that is stopped, out of reach or not answering says so in that line, and a second warning beside it would read like a fault. An empty answer is an answer, and empties the space's list. A host list when no space exists goes back as the very same object, untouched. The order is the place's list, so the merged list reads the same from one call to the next.
545
548
 
546
549
  **What a space may claim.** Every record of a space is untrusted. A record is dropped, and the drop logged as a code with the space id and never with the record, when it is not an object with an `id`, when its `location.directory` is missing or lies outside `/spaces/<id>`, another space's directory included, when its id is one of the host's, or when another space already listed that id; a duplicate within one list keeps the first. What is kept is passed through the proxy's own field allowlist, so a space cannot add a field the host's list would not carry. The host's ids are learned from every host list that passes through the proxy and from every `session.created` event of the host's, the last fifty thousand of them. The rule is one-way on purpose: the host's id always wins, and a space that lists a host id loses that record, whatever it says about it. Which of two spaces keeps an id they both list is whichever answered first; neither is the host, so nothing of the user's is at stake, and a real collision of two random ids does not happen. Once a space holds an id, listed or created, no other space speaks for it: any event of another space that names that session is dropped as `space_session_claimed`. One drop goes unlogged: the catalog events OpenCode inside sends for locations under its home, `/home/space`, its config folder among them, at boot and at the first prompt, about a dozen per start, which are outside the root like any other and were a dozen warnings per start in the host's log.
547
550
 
@@ -591,6 +594,7 @@ All under `/api/openchamber/spaces`, a namespace of the host's beside `/api/open
591
594
  | `GET /idle-stop`, `PUT /idle-stop` | Since 5d-3: the idle stop setting, `{ enabled, hours }`, kept in the host's settings and told to every running space. See "Idle stop". |
592
595
  | `POST /<id>/grants` | Since 5b: `{ kind: 'model', provider, upstream, secret: { kind: 'typed', value } \| { kind: 'env', name } }` or `{ kind: 'domain', upstream }`; since 7a `{ kind: 'login', provider }`. Answers `{ grant }`, the grant as the list carries it, with its window URL and never a value. See "Grants". |
593
596
  | `GET /logins` | Since 7c: `{ logins: [{ provider, method, expires, state }] }`, the host's own browser logins a space can be given, `state` one of `usable`, `expired` and `unsupported`, never a token; a host whose OpenCode cannot be asked fails rather than answering none. See "Grants". |
597
+ | `GET /custom-providers?directory=<project>` | `{ providers: [{ id, name, package, baseURL, loopback, models, hasKey, supported }] }`, the providers the user defined in the host's OpenCode configuration for that project, as a space can be given them, never a key; a catalog provider overridden there is left to its own row. See "Grants". |
594
598
  | `POST /<id>/network/domains` | Since 5d: `{ domain }`. Adds a name to a running space's allowlist, live, then to the record, so every later start says it again. Answers `{ network }`. See "Grants". |
595
599
  | `GET /<id>/journal` | The gatekeeper's journal, `{ records, dropped, since }`; 409 `space_not_running` for a stopped space, because the journal is gone with it. |
596
600
  | `GET /<id>/apply` | Brings the work out and describes what an apply would do, writing nothing of the user's: `bringCodeOut`'s answer and `describeApplyState`'s in one object. A running space only: a stopped one answers `space_not_running` before anything reaches into it, so the apply dialog can offer Start. |
@@ -682,7 +686,7 @@ Decisions 4, 5 and 13, and "Words" in the design above. Stage 5b takes two kinds
682
686
 
683
687
  - A model grant names the provider as the host's catalog does, `anthropic`, `openai` and so on, and its id is the provider id, so a second grant for the same provider replaces the first: that is how a key is changed, and a grant is never taken back. The upstream is the provider's API. The create dialog takes it from each provider's own SDK default, listed in the UI's `lib/spaces/model-access.ts` and matching what the bundled OpenCode uses, and never from the host's catalog: a catalog entry can be a browser login that points somewhere else. The header is decided here by provider, `x-api-key` for Anthropic, `x-goog-api-key` for Google, a bearer token for the rest. The key comes typed once, or as the name of an environment variable of the host's, read from the host's own environment now; OpenChamber remembers the name and never the value, and a variable that is not set is refused with `secret_source_missing`.
684
688
  - An opened domain gets a random id, `open-<12 hex>`, and its window URL, `http://gatekeeper:8080/model/<id>`, which the answer carries so a screen can show it. Nothing inside is configured for it in this stage.
685
- - The key goes to the gatekeeper first, then the grant without its value goes to the record, and for a model grant OpenCode inside is told: `space-opencode.js` writes the whole global configuration, `$HOME/.config/opencode/opencode.json`, from the record's model grants, each provider with `options.baseURL` at its window URL and a placeholder `apiKey`, so OpenCode's own auth plugins stay out of the way and the window throws the placeholder away. That file cooperates and enforces nothing: the agent can change it, and the gatekeeper is what keeps the key out. The catalog a space offers is the host's, so the model chosen in the composer works inside unchanged; that was the second decision of 2026-09-26. A grant the gatekeeper refused is not remembered. A grant goes to a running space only, `space_not_running` otherwise, and to one whose record can be read, `space_record_unreadable` otherwise, because a grant that cannot be remembered would be gone at the next start without a word. The configuration is the whole file, so anything the agent wrote into its global `opencode.json` is gone at the next model grant or start; a project's own `opencode.json` is not touched.
689
+ - The key goes to the gatekeeper first, then the grant without its value goes to the record, and for a model grant OpenCode inside is told: `space-opencode.js` writes the whole configuration file `/spaces/<id>/.opencode/opencode.json`, in the work volume beside the project's copy, from the record's model grants, each provider with `options.baseURL` at its window URL and a placeholder `apiKey`, so OpenCode's own auth plugins stay out of the way and the window throws the placeholder away. That place, and not the home directory's `opencode.json`, because OpenCode reads the `.opencode/opencode.json` of every folder above the project over the project's own `opencode.json`, which travels in with the code; the layers from weakest to strongest, measured on 2.0.27 and read in 2.0.28, are the user's file, the `OPENCODE_CONFIG` file, the project's `opencode.json`, the `.opencode` folders from the root down to the project's own, and `OPENCODE_CONFIG_CONTENT`. A project that defines a provider in its own `opencode.json` therefore gets the host's entry at the window all the same, see the custom grant below. The folder starts with a dot, which no project folder name can, and lies outside the project's repository, so it never comes out with the code; OpenCode writes nothing into it, measured. That file cooperates and enforces nothing: the agent can change it, and the gatekeeper is what keeps the key out. The catalog a space offers is the host's, so the model chosen in the composer works inside unchanged; that was the second decision of 2026-09-26. A grant the gatekeeper refused is not remembered. A grant goes to a running space only, `space_not_running` otherwise, and to one whose record can be read, `space_record_unreadable` otherwise, because a grant that cannot be remembered would be gone at the next start without a word. The configuration is the whole file, so anything the agent wrote into it is gone at the next model grant or start; a project's own `opencode.json` is not touched. The same write removes `$HOME/.config/opencode/opencode.json`, where the host wrote the configuration before: a space made then still holds it, and OpenCode merges a provider's settings across layers field by field, so a stale entry there would put a key grant's placeholder into a later login's settings. The host always wrote that file whole, so its removal takes nothing a grant would not have overwritten.
686
690
  - The providers a model grant takes are the ones whose header this module knows: `anthropic` and `google` with their own headers, and `openai`, `openrouter`, `groq`, `mistral`, `deepseek` and `xai` with a bearer token. Any other is refused with `provider_not_supported` rather than accepted and failing every turn with a 401 upstream; Azure, Bedrock and Vertex read their key another way or sign requests. The grant dialog decides how the list grows.
687
691
  - A login grant, since 7a, `{ kind: 'login', provider }`, is the host's own browser login for a provider, `openai` and since 7d `github-copilot`, given the way decision 13 says since 2026-10-09: the token lives in the gatekeeper and never in the space. The host reads the login its OpenCode has selected, `getStoredLogin` in `opencode/auth.js`, with the method it was made by; `space-opencode.js` knows where OpenCode sends that method's requests, `https://api.openai.com/v1` for "Sign in with ChatGPT", `https://chatgpt.com/backend-api/codex` for the two legacy Codex logins, and for Copilot's `device` login what its plugin's `copilotBaseURL` picks, the address GitHub told it at login (`metadata.apiEndpoint`), else the enterprise address, else `https://api.githubcopilot.com`; the window grant carries the access token there as a bearer, under the grant id of the provider, so a login and a key for the same provider replace each other. The record keeps the provider and the method and nothing else: at every start, and when the host starts and finds a gatekeeper that forgot, the login is read from the host's OpenCode again, and a host that is signed out, signed in by another method since, or whose token has already ended leaves the grant in `needsAccess` until the user grants once more. Inside, `POST /api/credential` on OpenCode, through the server inside, writes one row per provider under the id `cred_openchamber_space_<provider>`: the same method, and of the metadata what that method needs, for the ChatGPT logins only the account id, client id and scopes, which name the account and never a secret, and for Copilot only `apiEndpoint` set to the window's URL, because the plugin sends its model list and every turn to that address and reads no `baseURL` from the configuration, measured on 2.0.25, so a Copilot login writes no provider entry there; the enterprise address stays on the host. A space made before 7d holds its one row under the id every provider shared, `cred_openchamber_space`; a removal takes that id out as well, because OpenCode activates the newest remaining row of an integration when the active one goes, and a legacy row left behind would come back as the login. Placeholder tokens that expire in 2100, so OpenCode inside never refreshes and sends the headers that upstream wants with a bearer the window throws away. OpenCode takes the row at once, measured on 2.0.25, so a grant to a running space needs no restart; a row the agent put under that id is replaced like the host's own. The row lives in the home volume and survives a stop; a start repairs it in the background, once the server inside answers: from the record and the host's login as they are then, so a grant that came in the meantime is not undone, it writes the row again for a login grant the host can say and takes it out otherwise, which repairs a write or a removal that failed at the grant. The repair waits for an action under way, and a grant that arrives while the repair writes waits for that write, a few hundred milliseconds, so a user who grants right after a start is never told the space is busy; a grant still under way after ten seconds keeps its own row and the repair is skipped. The provider configuration points `baseURL` at the window with `transport: "http"`, because the legacy mode opens a WebSocket by default and the window carries none. A key that replaces a login takes the row out before the key goes to the gatekeeper. Refused: `login_not_found` when the host has no browser login for the provider, `login_not_supported` for a method this module does not know, `login_expired` for a token that has already ended and could not be renewed. Copilot's GitHub token has no end: the plugin stores `expires: 0` and has no refresh, so `loginEndOf` answers null for it, it is never expired, `GET /logins` says `expires: null`, and the dialogs warn that the login does not expire and that deleting the space is how it is taken back; it lives until the user revokes it on GitHub, which stops the host's own OpenCode too. The live grants test proves the token absent from everything the space can read, the database among it, and present at the stand-in upstream in OpenCode's own request.
688
692
  - The grant dialogs offer the login, since 7c, when the host has one to give: `GET /logins` says, for each provider of `LOGIN_PROVIDERS` in `space-opencode.js`, the method of the host's login, when it ends and whether it is `usable` now, has `expired` and could not be renewed, or is `unsupported`, a method the window does not know. It reads the login through the keeper like a grant does, so a login about to end is renewed by the read. The UI shows the choice "Use my ChatGPT login" in the OpenAI row of both dialogs only for a `usable` login, and nothing when there is none, and uses the same answer to say why a login grant needs the user again: run out, signed out, or to be given once more. A failed read of the route leaves the dialogs without the choice and without a word about the login; it never reads as "signed out".
@@ -702,7 +706,8 @@ Decisions 4, 5 and 13, and "Words" in the design above. Stage 5b takes two kinds
702
706
  - The phone's layout has no Archive page at all, for any archived chat; the notice after a delete has no "Open" there.
703
707
  - A run of the setup commands is one process's memory: a host that restarts in the middle lists it as interrupted, while the command inside may still go on to its end or its hour. A second run started then may run beside it.
704
708
  - Whether OpenCode inside takes a provider granted after the instance of the space's project started, without a restart, is what the live file of 5b measures; see the pull request of 5b for the outcome. The restart action of the repair stage is the lever if it does not.
705
- - A grant for a provider the host's catalog does not know is written inside all the same; OpenCode inside then has no `npm` package for it and the turn fails with a provider error. The grant dialog offers the host's catalog, so this is a request nothing in the app makes.
709
+ - A custom grant, `{ kind: 'custom', provider }`, is a provider the user defined in the host's OpenCode configuration, "custom" in Settings → Providers: a self-hosted gateway or a model server on the user's own machine or network, which the catalog does not know, with the models the user listed for it. The maintainer's call of 2026-10-14, for openchamber/openchamber#4846: the provider is defined once, in Settings, and the dialogs offer it from there under its own name, with no key to type, so the record names only the provider, `{ kind: 'custom', id, provider }`, and everything else is read from the host again at every grant and every start, like a login's token. `host-providers.js` reads the winning layer of the project's configuration, custom over project over the user's files, in either spelling, and takes only an entry that names its SDK in `package`; the key is resolved as OpenCode resolves it for the host, measured on 2.0.26: the credential OpenCode stores for the provider, then the first set variable the entry's `env` names, then a literal `apiKey` in its settings, and a provider with none is given with no key, so the window forwards the request as the space made it, less its credential headers. The header is the SDK's, `authorization` for `@ai-sdk/openai-compatible` and `@ai-sdk/openai`, `x-api-key` for `@ai-sdk/anthropic`; any other SDK is refused with `provider_not_supported`, a provider the configuration no longer defines with `provider_not_found`, and a provider's own headers, the ones its entry in Settings sets on every request, go to the gatekeeper with the key and stay there: the window sets them beside the credential, over whatever the space sent under their names, so the space can neither read nor override them, and the record and the configuration inside name none of them. "This machine" in the base URL, `localhost`, `127.0.0.1`, `::1` or `0.0.0.0`, names the gatekeeper itself from inside, so `windowUpstreamOf` sends it to `host.docker.internal`, the Docker host, which the gatekeeper is created with (see "The gatekeeper container"); measured on 2026-10-14 on Colima: a container reached Ollama on the user's Mac, listening on the Mac's loopback only, through that name with no change to Ollama. On a Docker over SSH place the Docker host is that machine, so a loopback address there names the machine's own services and never the user's computer; the dialogs say so under such a provider when the space runs on a machine, and a provider on the user's computer is reached from there by its network address, with the server listening on it. Inside, the configuration carries the entry as the host's does, in OpenCode 2's own spelling under `providers`: the name, the SDK, the models, and `settings.baseURL` at the window with the placeholder key; the catalog providers keep the spelling measured on 2.0.25 under `provider`, and OpenCode reads both in one file. A definition the host cannot read at a start leaves that grant in `needsAccess` and its entry out of the configuration; a provider edited in Settings reaches the space at its next start, or at "Grant again" in the dialog. The UI reads `GET /custom-providers` for every project its spaces belong to when the journey list arrives, so the composer's rule on a model the space has no access to knows the user's own providers; a project not read yet refuses nothing. A custom provider defined in the project's own `opencode.json` travels into the space with the code, with its real address, which nothing inside can reach; the host's entry beside the project wins over that copy, see the model grant above, so the turn goes through the window. Measured on 2026-10-14 before the entry moved there: written in the home directory it lost, OpenCode inside connected to `localhost` from within the container, the turn retried without end, the journal stayed empty and the Access dialog said "Has access". Known limit: a provider defined in the project's own `.opencode/opencode.json` still wins over the host's entry, since the project's own folder is the strongest file layer; such a space fails the same way. Not yet: a key the user types for a custom provider, which Settings holds. The live grants test grants a custom provider of the project's own configuration with a key and a header of its own and proves both at the stand-in, as hashes, and absent from the record, the containers' metadata, the configuration inside and everything the space can read.
710
+ - A grant for a catalog provider the host's catalog does not know is written inside all the same; OpenCode inside then has no `npm` package for it and the turn fails with a provider error. The grant dialog offers the host's catalog, so this is a request nothing in the app makes.
706
711
 
707
712
  ### Preview
708
713
 
@@ -1167,7 +1172,7 @@ OPENCHAMBER_TEST_DOCKER=1 bun run --cwd packages/web test -- server/lib/spaces
1167
1172
  OPENCHAMBER_TEST_DOCKER_PACKED=1 bun run --cwd packages/web test -- server/lib/spaces/places/packed
1168
1173
  ```
1169
1174
 
1170
- The second command also runs the live files against the local Docker daemon, or, with `OPENCHAMBER_TEST_DOCKER_HOST=ssh://<machine>` set as well, against that machine's daemon through the Docker over SSH place, the helper containers of the escape suite included; that is how the contract and the escape suite are run against the "another machine" place. The live files are `places/contract.docker.live.test.js`, `places/escape.docker.live.test.js`, `places/server.docker.live.test.js`, and since 3a `places/code-in.docker.live.test.js`. Since 3b it also runs `places/code-out.docker.live.test.js`, since 4a `places/dispatcher.docker.live.test.js`, since 4b `places/sessions.docker.live.test.js`, and since 5b `places/grants.docker.live.test.js`: a space made through the journey, a real key behind the window against the stand-in upstream, which sees its hash, the key absent from the record, both containers' metadata and everything the space can read, a turn of OpenCode inside arriving at the stand-in with the key, a provider granted after the instance started, measured, and the grants said again after a stop and a start. Since 7a the same file grants the host's ChatGPT login, given by the test as the host's OpenCode would hand it over: the stand-in sees the token's hash at the login method's upstream path, the row inside holds the placeholder tokens and the method, the token is absent from the record, both containers' metadata and everything the space can read, its database included, a turn of OpenCode inside arrives in its ChatGPT mode with the session headers that upstream wants, the login is said again after a stop and a start, and a key that replaces it takes the row with it. Since 7b it also moves the host's login the way the host's OpenCode would and the way the keeper's renewal would, and the window carries each new token on the keeper's next look while the space never sees any of them. Since 7d it grants the host's GitHub Copilot login next to the OpenAI key: the stand-in sees the GitHub token's hash at the address GitHub gave, with no path of its own, the row inside names the `device` method and the window as its address and the configuration names no Copilot, the token and that address are absent from everything the space can read, the plugin inside reads its model list from the window with the token and a turn arrives at `/chat/completions` with Copilot's headers, the keeper renews nothing, and the login is said again after a stop and a start. The stand-in answers a `GET` for `/models` with one model in GitHub's shape, because the plugin loads no models otherwise. The escape suite gained two tests in 5b: a neighbour on the outer network refused on the gatekeeper's outer address on all three ports while the space still reaches both listeners by name, and an opened domain that gets no credential from the window. The third runs `places/packed.docker.live.test.js`. It compiles the sdk and packs the local `web` and `sdk`, so it needs the workspace dependencies installed.
1175
+ The second command also runs the live files against the local Docker daemon, or, with `OPENCHAMBER_TEST_DOCKER_HOST=ssh://<machine>` set as well, against that machine's daemon through the Docker over SSH place, the helper containers of the escape suite included; that is how the contract and the escape suite are run against the "another machine" place. The live files are `places/contract.docker.live.test.js`, `places/escape.docker.live.test.js`, `places/server.docker.live.test.js`, and since 3a `places/code-in.docker.live.test.js`. Since 3b it also runs `places/code-out.docker.live.test.js`, since 4a `places/dispatcher.docker.live.test.js`, since 4b `places/sessions.docker.live.test.js`, and since 5b `places/grants.docker.live.test.js`: a space made through the journey, a real key behind the window against the stand-in upstream, which sees its hash, the key absent from the record, both containers' metadata and everything the space can read, a turn of OpenCode inside arriving at the stand-in with the key, a provider granted after the instance started, measured, and the grants said again after a stop and a start. Since 7a the same file grants the host's ChatGPT login, given by the test as the host's OpenCode would hand it over: the stand-in sees the token's hash at the login method's upstream path, the row inside holds the placeholder tokens and the method, the token is absent from the record, both containers' metadata and everything the space can read, its database included, a turn of OpenCode inside arrives in its ChatGPT mode with the session headers that upstream wants, the login is said again after a stop and a start, and a key that replaces it takes the row with it. Since 7b it also moves the host's login the way the host's OpenCode would and the way the keeper's renewal would, and the window carries each new token on the keeper's next look while the space never sees any of them. Since 7d it grants the host's GitHub Copilot login next to the OpenAI key: the stand-in sees the GitHub token's hash at the address GitHub gave, with no path of its own, the row inside names the `device` method and the window as its address and the configuration names no Copilot, the token and that address are absent from everything the space can read, the plugin inside reads its model list from the window with the token and a turn arrives at `/chat/completions` with Copilot's headers, the keeper renews nothing, and the login is said again after a stop and a start. The stand-in answers a `GET` for `/models` with one model in GitHub's shape, because the plugin loads no models otherwise. Since the custom provider headers it also grants a provider of the project's own configuration with a key in a host variable and a header of its own: the stand-in sees the bearer's hash and the header's hash while the space sent another value under that name, both are absent from the record, the containers' metadata, the configuration inside and everything the space can read, and the grant is said again after a stop and a start; the definition is committed, so its copy with an unreachable address is in the space, and a turn with that provider's model arrives at the stand-in with the key, which proves the host's entry beside the project wins over the copy. The escape suite gained two tests in 5b: a neighbour on the outer network refused on the gatekeeper's outer address on all three ports while the space still reaches both listeners by name, and an opened domain that gets no credential from the window. The third runs `places/packed.docker.live.test.js`. It compiles the sdk and packs the local `web` and `sdk`, so it needs the workspace dependencies installed.
1171
1176
 
1172
1177
  Each live file uses an owner id of its own, removes its spaces, helper containers, and tools volumes in `afterAll`, and then fails if any container, network, or volume with that owner label remains. An owner of its own also means a tools volume of its own, so every live file pays for one fill of about 40 seconds. The first run pulls the image, about 1.6 GB.
1173
1178
 
@@ -1181,7 +1186,7 @@ Each live file uses an owner id of its own, removes its spaces, helper container
1181
1186
 
1182
1187
  `journey.test.js` runs the journey over the memory place with recording stand-ins for the gatekeeper channel, code in and code out: the order of the steps and the events of a create, what the record holds after it, a history that fails alone, a failure at the network or at code in that removes the space and lists the failure until it is dismissed, an unavailable place, an allowlist refused without host isolation, each bad field of the request refused before anything runs, stop and start with the network said again, a start without a record, the history sent again at start, remove with the refs and the record and with refs that would not go, every action refused while a creation is held at code in, stop all with one space that would not stop, no creation after the turn-off began until it is undone, a failed creation whose clean-up failed removed at its dismissal, the journal of a running and of a stopped space, the apply preview, the apply as a branch with the removal after it, as changes with the space kept, no removal when there was nothing to apply or the apply refused, and a remove, a stop and a journal read refused as busy while an apply holds the space. Since 5b also the grants: a typed key and an environment key delivered to the stand-in gatekeeper, remembered without their values and OpenCode inside told; the same provider replaced and a domain opened with no header; every bad request, a stopped space, a missing environment variable and an unreadable record refused; a refused grant not remembered; the grants said again after a start with the typed one and a variable no longer set in `needsAccess`, and a gatekeeper that refuses at the start leaving the space running; and the list asking only where there is something to ask and answering unknown on a failed read; since 7b the login said again for the keeper, and refused while an action holds the space. `login-keeper.test.js` covers the issuer request of each login method and a method refused, the login an answer makes with the metadata that method keeps, the exchange against a stand-in fetch with its refusals, and the keeper: a login with time left as it is, one about to end renewed once for callers that arrive together, a renewal that fails leaving the login that still has time and none for one that ended, each holding space told once per change, a busy space told on the next look and a refusing gatekeeper not, a renewal the issuer refused not asked again for the same login while a failing network is, an ended login answered as it is for the journey to refuse, a login of another method and a host without one left alone, a stopped space forgotten, and a host OpenCode that is away logged. `opencode/auth.test.js` covers `renewStoredLogin`: the refresh token handed to the exchange, the new row written first and the old removed after it, no exchange without a login, the exchanged tokens dropped for a row that changed meanwhile, the old row left when the exchange or the write fails, and a connection that cannot write refused. `routes.test.js` runs the routes over a stand-in journey: every route 404 while the feature is off with the switch still answering, the switch's preview and its turn-off, each route translated into its journey call, an id that is not a space id and a body that is not an object refused before the journey is asked, and the status of every code, the grant route among them since 5b; and the switch controller: the unknown list when the place cannot be asked, one host built for two turn-ons at once and closed once for two turn-offs, the order of stop, write and close, and a setting that cannot be written leaving the feature on and open. `space-records.test.js` covers the file, its mode, the update, an unreadable file never taken for a fresh record, the id check, the domain rule, since 5b a grant remembered without its value, a value under any name refused, and a record from before grants read back with none, and since Docker over SSH the listing with a record from before there were two places read as the local Docker place's. `manager.test.js` covers the routing: a space's operations on the place its record names without the other asked, a space without a record found on the place that lists it, a place that could not be asked never making a space gone, the list of every place with the remembered spaces of one that does not answer as `unreachable`, the pause after a failed list that doubles to its cap and ends when the place answers, and the remembered spaces of a place the registry no longer has. `journey.test.js` covers two places too: a space made on the named place and routed there, the first place taken when none is named, an unknown place refused, and a place that cannot be asked listed from the records, logged once, reported as not stopped by the switch, its space kept with its record after a delete that could not reach it, and read from its own list again when it answers after the pause. `places/docker.test.js` runs the Docker over SSH place over the fake with a runner that demands the host flag first in every call, the argv for git and the bridge with the flag, and the three remote failures of `check()` told apart. `places/ssh-host.test.js` covers the destination rule.
1183
1188
 
1184
- `gatekeeper-program.test.js` covers the program two ways. It requires the file and calls the rules directly: every blocked range with its edges, every IPv6 embedded form, the public addresses that must stay allowed, `refuseTarget` for both modes and both ports, thirty target forms that must be refused as addresses or non-names, including the integer, hex, short and octal spellings, ten ordinary names that must still pass, the address-family choice, and what `splitTarget` refuses. The program runs its listeners only as the container's main module, so requiring it binds nothing and there is no switch that changes a decision. Then it spawns the program the way `tools-filler.test.js` runs the filler and reads decisions back from its own journal: a name that does not resolve, `localhost` as the name that proves the check is on the resolved address, exact-match domains, the port rules of both modes, `auth.openai.com` by name and in fifteen address and non-name forms, the three Unicode full stops, which Node's own parser refuses before any rule of ours sees them and which are therefore checked against the rules directly, a plain proxy request, malformed CONNECT lines, a reset in the middle of the handshake, a 200,000 character header block, a flood of 600 sockets on each listener, the window's header rules against a local upstream, a grant that points back at the gatekeeper, journal redaction, the ring buffer's overflow, what the control channel refuses, and since 5b a grant without a secret that adds no header and still takes the space's credentials away, the grant's own header name taken away as well, the policy read back without a secret, and the bind file: the program listens on the address it holds and does not start when it is missing, empty, every interface or not an address. A tunnel that carries bytes needs a name that resolves to a public address, so the tunnel cap and every tunnel that carries something live in the escape suite, inside real containers.
1189
+ `gatekeeper-program.test.js` covers the program two ways. It requires the file and calls the rules directly: every blocked range with its edges, every IPv6 embedded form, the public addresses that must stay allowed, `refuseTarget` for both modes and both ports, thirty target forms that must be refused as addresses or non-names, including the integer, hex, short and octal spellings, ten ordinary names that must still pass, the address-family choice, and what `splitTarget` refuses. The program runs its listeners only as the container's main module, so requiring it binds nothing and there is no switch that changes a decision. Then it spawns the program the way `tools-filler.test.js` runs the filler and reads decisions back from its own journal: a name that does not resolve, `localhost` as the name that proves the check is on the resolved address, exact-match domains, the port rules of both modes, `auth.openai.com` by name and in fifteen address and non-name forms, the three Unicode full stops, which Node's own parser refuses before any rule of ours sees them and which are therefore checked against the rules directly, a plain proxy request, malformed CONNECT lines, a reset in the middle of the handshake, a 200,000 character header block, a flood of 600 sockets on each listener, the window's header rules against a local upstream, a grant that points back at the gatekeeper, journal redaction, the ring buffer's overflow, what the control channel refuses, and since 5b a grant without a secret that adds no header and still takes the space's credentials away, the grant's own header name taken away as well, the policy read back without a secret, and the bind file: the program listens on the address it holds and does not start when it is missing, empty, every interface or not an address. A tunnel that carries bytes needs a name that resolves to a public address, so the tunnel cap and every tunnel that carries something live in the escape suite, inside real containers. Since the custom provider headers, a grant's own headers: set beside the key over whatever the space sent under their names, carried by a keyless grant too, and refused when a name is the window's own, the one that carries the secret, a hop-by-hop name, a bad name, an empty value, a value Node's `http.request` would throw on, a non-object, or more than 32 of them.
1185
1190
 
1186
1191
  `tools-filler.test.js` runs the real filler program with Node against temporary directories, with a stand-in `npm` on PATH.
1187
1192
 
@@ -564,10 +564,12 @@ const parseSizes = (text) => text.split('\n').filter(Boolean).map((entry) => {
564
564
  * is where the quarantine repository, the patch and an empty hooks folder live while one call runs.
565
565
  * `removeDirectory` is how that folder goes, injectable so a test can make it fail. `readBackTimeoutMs`
566
566
  * bounds the time one apply or read of its state spends reading the working tree back, see
567
- * `READ_BACK_TIMEOUT_MS`. `files` is how the working tree is read back, `node:fs/promises` unless a
568
- * test counts what is read.
567
+ * `READ_BACK_TIMEOUT_MS`. `sizePollMs` is how often the quarantine's size is read while a fetch
568
+ * runs, see `SIZE_POLL_MS`; a test that proves the cap after the fetch sets it past the fetch, so
569
+ * the fetch is never stopped in the middle on a slow machine. `files` is how the working tree is
570
+ * read back, `node:fs/promises` unless a test counts what is read.
569
571
  */
570
- export function createCodeOut({ git, place, temporaryDirectory = os.tmpdir(), removeDirectory, platform = process.platform, readBackTimeoutMs = READ_BACK_TIMEOUT_MS, files = fs }) {
572
+ export function createCodeOut({ git, place, temporaryDirectory = os.tmpdir(), removeDirectory, platform = process.platform, readBackTimeoutMs = READ_BACK_TIMEOUT_MS, sizePollMs = SIZE_POLL_MS, files = fs }) {
571
573
  const { withHostGit, requireGitVersion, requireWorkTree } = createTransferSession({ git, temporaryDirectory, removeDirectory, name: 'code out' });
572
574
 
573
575
  /** Runs `work`, and turns what it throws into what `bringCodeOut` rejects with, naming `step`. */
@@ -624,6 +626,12 @@ export function createCodeOut({ git, place, temporaryDirectory = os.tmpdir(), re
624
626
  );
625
627
  const controller = new AbortController();
626
628
  let finished = false;
629
+ // The watcher's pause ends with the fetch, so the fetch never waits a whole poll for it.
630
+ let wake = () => {};
631
+ const nextPoll = () => new Promise((resolve) => {
632
+ const timer = setTimeout(resolve, sizePollMs);
633
+ wake = () => { clearTimeout(timer); resolve(); };
634
+ });
627
635
  // It never throws: it runs beside the fetch and nothing awaits it until the fetch is over, so a
628
636
  // failure of its own would be an unhandled rejection in the server.
629
637
  const watch = (async () => {
@@ -633,7 +641,7 @@ export function createCodeOut({ git, place, temporaryDirectory = os.tmpdir(), re
633
641
  controller.abort(tooLarge());
634
642
  return;
635
643
  }
636
- await pause(SIZE_POLL_MS);
644
+ await nextPoll();
637
645
  }
638
646
  } catch {
639
647
  // The cap after the fetch still holds, see below.
@@ -647,6 +655,7 @@ export function createCodeOut({ git, place, temporaryDirectory = os.tmpdir(), re
647
655
  ], { timeoutMs, maxOutputBytes: FETCH_MAX_OUTPUT_BYTES, killTree: true, signal: controller.signal });
648
656
  } finally {
649
657
  finished = true;
658
+ wake();
650
659
  await watch;
651
660
  }
652
661
  // A fetch that finished between two polls is held to the same cap.
@@ -3551,14 +3551,16 @@ describe.skipIf(WIN)('bringCodeOut from a local stand-in for a space', () => {
3551
3551
  expect(space.g(['rev-parse', RESULT]).trim()).toBe(out.result);
3552
3552
  }, 60_000);
3553
3553
 
3554
- // A result small enough to arrive between two polls is held to the cap once the fetch is over. The
3555
- // space's own sender ends normally here, which is what tells the two checks apart.
3554
+ // A result that arrives between two polls is held to the cap once the fetch is over. The space's
3555
+ // own sender ends normally here, which is what tells the two checks apart. The poll is set past the
3556
+ // fetch, so a slow machine, the CI runner among them, cannot turn this into the case above.
3556
3557
  it('refuses a transfer over the cap that arrived in one piece', async () => {
3557
3558
  const host = createTestHost();
3558
3559
  const space = await spaceWithCode(host);
3559
3560
  space.write('middling.bin', crypto.randomBytes(1536 * 1024));
3560
3561
  const before = hostState(space.repo);
3561
- const failure = await space.out({ maxTransferBytes: 1024 * 1024 }).catch((error) => error);
3562
+ const codeOut = host.codeOut(space.local.place, { sizePollMs: 60_000 });
3563
+ const failure = await codeOut.bringCodeOut(space.request({ maxTransferBytes: 1024 * 1024 })).catch((error) => error);
3562
3564
  expect(failure).toMatchObject({ code: 'result_transfer_too_large', details: { step: 'fetch into the quarantine' } });
3563
3565
  expect(space.local.uploadPackExit(), 'the fetch was stopped in the middle, so this proves nothing about the cap after it').toBe('0');
3564
3566
  expect(anyChangeSince(before, space.repo)).toEqual([]);
@@ -297,7 +297,8 @@ export const stripCredentialQuery = (url) => {
297
297
 
298
298
  /**
299
299
  * `transport` is `{ listSpaceIds(), connect(spaceId), readToken(spaceId) }`: the ids from the
300
- * runtime's labels, the place's `connect`, and the token read back over `exec`. `now` and
300
+ * runtime's labels with the failure of a place that could not be asked, `{ ids, failure }`, the
301
+ * place's `connect`, and the token read back over `exec`. `now` and
301
302
  * `logger` are injectable for the tests.
302
303
  */
303
304
  export function createSpaceDispatcher({ transport, now = Date.now, logger = console, freeSocketTimeoutMs = FREE_SOCKET_TIMEOUT_MS }) {
@@ -305,25 +306,31 @@ export function createSpaceDispatcher({ transport, now = Date.now, logger = cons
305
306
  const tokens = new Map();
306
307
  const sessions = new Map();
307
308
  const logins = new Map();
308
- let known = { ids: new Set(), readAt: -Infinity };
309
+ let known = { ids: new Set(), failure: null, readAt: -Infinity };
309
310
  let listing = null;
310
311
 
311
312
  const readSpaceIds = async () => {
312
313
  if (!listing) {
313
314
  listing = transport.listSpaceIds()
314
- .then((ids) => { known = { ids: new Set(ids), readAt: now() }; })
315
+ .then(({ ids, failure }) => { known = { ids: new Set(ids), failure, readAt: now() }; })
315
316
  .finally(() => { listing = null; });
316
317
  }
317
318
  await listing;
318
319
  };
319
320
 
320
- /** Whether the runtime's labels name this space, read again when the answer is stale or a miss. */
321
+ /**
322
+ * Whether the runtime's labels name this space, read again when the answer is stale or a miss.
323
+ * A miss while a place could not be asked rejects with that place's failure: the space may well
324
+ * be there, so it is never called gone on a guess.
325
+ */
321
326
  const isKnownSpace = async (spaceId) => {
322
327
  const age = now() - known.readAt;
323
328
  if (age >= LIST_TTL_MS || (!known.ids.has(spaceId) && age >= LIST_MISS_RETRY_MS)) {
324
329
  await readSpaceIds();
325
330
  }
326
- return known.ids.has(spaceId);
331
+ if (known.ids.has(spaceId)) return true;
332
+ if (known.failure) throw known.failure;
333
+ return false;
327
334
  };
328
335
 
329
336
  const agentFor = (spaceId) => {
@@ -130,7 +130,9 @@ const transportTo = (currentInside, { ids = [ID], token = TOKEN } = {}) => {
130
130
  return {
131
131
  calls,
132
132
  ids,
133
- listSpaceIds: async () => { calls.list += 1; return ids; },
133
+ // The failure of a place that could not be asked, as the host's list reports it.
134
+ failure: null,
135
+ listSpaceIds: async function () { calls.list += 1; return { ids, failure: this.failure }; },
134
136
  connect: async (spaceId) => {
135
137
  calls.connect += 1;
136
138
  if (!ids.includes(spaceId)) throw new SpaceError('space_not_found', `Space ${spaceId} has no container`);
@@ -434,6 +436,22 @@ describe('space dispatcher', () => {
434
436
  expect(found.status).toBe(200);
435
437
  });
436
438
 
439
+ it('never calls a space gone while a place could not be asked, and serves the ones it lists', async () => {
440
+ await start();
441
+ transport.failure = new SpaceError('docker_command_failed', 'Cannot connect to the Docker daemon');
442
+ const unknown = await fetch(host.url(`/api/spaces/${OTHER}/echo`));
443
+ expect(unknown.status).toBe(502);
444
+ expect(await unknown.json()).toMatchObject({ code: 'space_unreachable' });
445
+ expect(transport.calls.connect).toBe(0);
446
+ expect((await fetch(host.url(`/api/spaces/${ID}/echo`))).status).toBe(200);
447
+
448
+ transport.failure = null;
449
+ await new Promise((resolve) => { setTimeout(resolve, 600); });
450
+ const gone = await fetch(host.url(`/api/spaces/${OTHER}/echo`));
451
+ expect(gone.status).toBe(404);
452
+ expect(await gone.json()).toMatchObject({ code: 'space_not_found' });
453
+ });
454
+
437
455
  it('lets no cookie through from a space, marks every answer nosniff, and serves a page as text', async () => {
438
456
  await start();
439
457
  const cookie = await fetch(host.url(`/api/spaces/${ID}/cookie`));
@@ -177,14 +177,15 @@ export function createGatekeeperChannel({ exec, wait = pause, now = Date.now })
177
177
  /**
178
178
  * One grant: a "uses without seeing" credential, whose secret is in the body and so out of every
179
179
  * argument list, or an opened domain with no secret and no header, which the window forwards to
180
- * as the space sent it.
180
+ * as the space sent it. `headers` are the provider's own, set on every request beside the
181
+ * credential; they travel in the body like the secret, and only when there are any.
181
182
  */
182
- const addGrant = (spaceId, { id, upstream, header = null, secret = null }) => command(
183
- spaceId,
184
- '/grants',
185
- secret === null ? { id, upstream } : { id, upstream, header, secret },
186
- `add the grant '${id}'`,
187
- );
183
+ const addGrant = (spaceId, { id, upstream, header = null, secret = null, headers = {} }) => {
184
+ const body = { id, upstream };
185
+ if (secret !== null) Object.assign(body, { header, secret });
186
+ if (Object.keys(headers).length > 0) body.headers = headers;
187
+ return command(spaceId, '/grants', body, `add the grant '${id}'`);
188
+ };
188
189
 
189
190
  /**
190
191
  * What the gatekeeper holds now: its mode, its allowlist and the ids of its grants, never a
@@ -93,6 +93,16 @@ describe('gatekeeper channel: control requests', () => {
93
93
  expect(JSON.parse(JSON.parse(data.slice('data-raw = '.length)))).toEqual({ id: 'open-0a1b2c3d4e5f', upstream: 'https://registry.example.com/npm/' });
94
94
  });
95
95
 
96
+ it('sends a grant\'s own headers in the body beside the secret, and only when there are any', async () => {
97
+ const { channel, calls } = channelWith(ok(http(200, '{"ok":true}')));
98
+ await channel.addGrant(ID, { id: 'lighthouse', upstream: 'https://lighthouse-gw.example.dev/v1', header: 'authorization', secret: SECRET, headers: { 'x-team': 'platform' } });
99
+ await channel.addGrant(ID, { id: 'plain', upstream: 'https://plain.example.dev/v1', header: 'authorization', secret: SECRET, headers: {} });
100
+ const bodyOf = (call) => JSON.parse(JSON.parse(call.options.stdin.split('\n').find((line) => line.startsWith('data-raw = ')).slice('data-raw = '.length)));
101
+ expect(bodyOf(calls[0])).toEqual({ id: 'lighthouse', upstream: 'https://lighthouse-gw.example.dev/v1', header: 'authorization', secret: SECRET, headers: { 'x-team': 'platform' } });
102
+ expect(bodyOf(calls[1])).toEqual({ id: 'plain', upstream: 'https://plain.example.dev/v1', header: 'authorization', secret: SECRET });
103
+ expect(calls[0].argv.join(' ')).not.toContain('platform');
104
+ });
105
+
96
106
  it('reads what the gatekeeper holds as data: mode, names and grant ids, capped, and never a secret', async () => {
97
107
  const { channel } = channelWith(ok(http(200, JSON.stringify({ mode: 'open', domains: ['a.example.com', 7, {}], grants: ['anthropic', ['x'], 'open-1'], secret: SECRET }))));
98
108
  expect(await channel.readPolicy(ID)).toEqual({ mode: 'open', domains: ['a.example.com', '7'], grants: ['anthropic', 'open-1'] });
@@ -108,6 +108,11 @@ const NUMERIC_LABEL = /^(\d+|0x[0-9a-f]+)$/;
108
108
  const GRANT_ID_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
109
109
  const HEADER_NAME_PATTERN = /^[A-Za-z0-9-]{1,64}$/;
110
110
  const MAX_SECRET_LENGTH = 8192;
111
+ // The headers of the user's own a grant may add beside its credential, for a provider that wants
112
+ // them on every request. Capped like the rest; the names the window owns are never among them.
113
+ const MAX_GRANT_HEADERS = 32;
114
+ const HEADER_VALUE_PATTERN = /^[\t\x20-\x7e\x80-\xff]+$/;
115
+ const RESERVED_HEADER_NAMES = ['host', 'content-length', 'transfer-encoding', 'connection', 'te', 'upgrade', 'keep-alive', 'proxy-connection', 'authorization', 'x-api-key', 'proxy-authorization'];
111
116
 
112
117
  /**
113
118
  * The address the corridor and the window listen on. An argument that starts with `/` is the
@@ -701,7 +706,9 @@ async function serveWindow(request, response) {
701
706
 
702
707
  // Whatever the space sent as credentials goes, and the grant's own header takes its place. A
703
708
  // grant without a secret, an opened domain, adds nothing: the upstream sees the request as the
704
- // space made it, less the credential headers.
709
+ // space made it, less the credential headers. The grant's own extra headers are set last, over
710
+ // whatever the space sent under their names (Node lowercases and joins incoming names, so the
711
+ // names match), and the space can neither read nor override them.
705
712
  const headers = { ...request.headers };
706
713
  for (const name of Object.keys(headers)) {
707
714
  const lower = name.toLowerCase();
@@ -711,6 +718,7 @@ async function serveWindow(request, response) {
711
718
  if (grant.secret !== null) {
712
719
  headers[grant.header] = grant.header === 'authorization' ? `Bearer ${grant.secret}` : grant.secret;
713
720
  }
721
+ Object.assign(headers, grant.headers);
714
722
 
715
723
  record('window', normalizeName(upstream.hostname), port, 'allow');
716
724
  const transport = upstream.protocol === 'https:' ? https : http;
@@ -796,10 +804,34 @@ function setNetwork(body) {
796
804
  return null;
797
805
  }
798
806
 
807
+ /**
808
+ * The extra headers of a grant as the window will set them, lowercased, or a refusal: text values
809
+ * under header names that the window does not own itself, at most MAX_GRANT_HEADERS of them.
810
+ */
811
+ function grantHeadersOf(value) {
812
+ if (value === undefined) return { headers: {} };
813
+ if (value === null || !(value instanceof Object) || Array.isArray(value)) return { refusal: 'the headers of a grant are an object of names to text' };
814
+ const entries = Object.entries(value);
815
+ if (entries.length > MAX_GRANT_HEADERS) return { refusal: `at most ${MAX_GRANT_HEADERS} headers on a grant` };
816
+ const headers = {};
817
+ for (const [name, text] of entries) {
818
+ const lower = name.toLowerCase();
819
+ if (!HEADER_NAME_PATTERN.test(lower)) return { refusal: 'a header name is 1 to 64 letters, digits or dashes' };
820
+ if (RESERVED_HEADER_NAMES.includes(lower)) return { refusal: `the header '${lower}' is the window's own` };
821
+ const asString = asText(text);
822
+ if (asString.length === 0 || asString.length > MAX_SECRET_LENGTH) return { refusal: 'a header of a grant is text, 1 to 8192 characters' };
823
+ // Node's own rule for a header value; one it refuses would break every request through this window after the grant said yes.
824
+ if (!HEADER_VALUE_PATTERN.test(asString)) return { refusal: 'a header of a grant is Latin-1 text without line breaks' };
825
+ headers[lower] = asString;
826
+ }
827
+ return { headers };
828
+ }
829
+
799
830
  /**
800
831
  * A grant with a secret names the header that carries it; a grant without one, an opened domain,
801
832
  * names no header and the window adds nothing. A body with a header and no secret, or a secret
802
- * and no header, is refused: either the grant hides a credential or it does not.
833
+ * and no header, is refused: either the grant hides a credential or it does not. Either kind may
834
+ * carry `headers`, the provider's own, set on every request beside the credential.
803
835
  */
804
836
  function addGrant(body) {
805
837
  const id = asText(body.id);
@@ -809,6 +841,9 @@ function addGrant(body) {
809
841
  const secret = withSecret ? asText(body.secret) : null;
810
842
  if (withSecret && !HEADER_NAME_PATTERN.test(header)) return 'a header name is 1 to 64 letters, digits or dashes';
811
843
  if (withSecret && (secret.length === 0 || secret.length > MAX_SECRET_LENGTH)) return 'a grant with a header needs a secret';
844
+ const extra = grantHeadersOf(body.headers);
845
+ if (extra.refusal) return extra.refusal;
846
+ if (header !== null && header in extra.headers) return `the header '${header}' carries the secret and cannot be set twice`;
812
847
  let upstream;
813
848
  try {
814
849
  upstream = new URL(asText(body.upstream));
@@ -816,7 +851,7 @@ function addGrant(body) {
816
851
  return 'the upstream of a grant is a URL';
817
852
  }
818
853
  if (upstream.protocol !== 'http:' && upstream.protocol !== 'https:') return 'the upstream of a grant is http or https';
819
- grants.set(id, { upstream: upstream.toString(), header, secret });
854
+ grants.set(id, { upstream: upstream.toString(), header, secret, headers: extra.headers });
820
855
  return null;
821
856
  }
822
857
 
@@ -765,6 +765,26 @@ describe('gatekeeper program', () => {
765
765
  expect(Object.keys(request.headers).some((name) => /key|auth|token/i.test(name))).toBe(false);
766
766
  });
767
767
 
768
+ it('sets the grant\'s own headers beside the key, over whatever the space sent under their names, and refuses the names it owns', async () => {
769
+ expect((await control('POST', '/grants', { id: 'lighthouse', upstream: `http://127.0.0.1:${upstreamPort}/v1`, header: 'authorization', secret: SECRET, headers: { 'X-Team': 'platform', 'x-gateway-token': 'gw-secret' } })).status).toBe(200);
770
+ const answer = await throughWindow('/model/lighthouse/chat/completions', { 'x-team': 'space-says-admin', 'x-keep-me': 'yes', authorization: 'Bearer space-window' });
771
+ expect(answer.status).toBe(200);
772
+ const request = seen.at(-1);
773
+ expect(request.headers.authorization).toBe(`Bearer ${SECRET}`);
774
+ expect(request.headers['x-team']).toBe('platform');
775
+ expect(request.headers['x-gateway-token']).toBe('gw-secret');
776
+ expect(request.headers['x-keep-me']).toBe('yes');
777
+ expect(answer.body).not.toContain('gw-secret');
778
+ // A keyless grant may carry headers too; the credential names and the hop-by-hop ones never.
779
+ expect((await control('POST', '/grants', { id: 'open-headers', upstream: `http://127.0.0.1:${upstreamPort}/v1`, headers: { 'x-team': 'platform' } })).status).toBe(200);
780
+ for (const bad of [{ host: 'evil' }, { authorization: 'x' }, { 'content-length': '0' }, { 'bad name!': 'x' }, { 'x-empty': '' }, { 'x-team': 'команда' }, { 'x-team': 'a\r\nx-injected: b' }, 'not-an-object', ['x-team', 'platform']]) {
781
+ expect((await control('POST', '/grants', { id: 'bad', upstream: `http://127.0.0.1:${upstreamPort}/v1`, headers: bad })).status, JSON.stringify(bad)).toBe(400);
782
+ }
783
+ expect((await control('POST', '/grants', { id: 'bad', upstream: `http://127.0.0.1:${upstreamPort}/v1`, header: 'x-api-key', secret: SECRET, headers: { 'x-api-key': 'twice' } })).status).toBe(400);
784
+ expect((await control('POST', '/grants', { id: 'bad', upstream: `http://127.0.0.1:${upstreamPort}/v1`, headers: Object.fromEntries(Array.from({ length: 33 }, (_, i) => [`x-h-${i}`, 'v'])) })).status).toBe(400);
785
+ expect((await throughWindow('/model/bad/x')).status).toBe(403);
786
+ });
787
+
768
788
  it('takes the grant\'s own header name away too, so a placeholder the space sends never reaches the upstream', async () => {
769
789
  expect((await control('POST', '/grants', { id: 'google', upstream: `http://127.0.0.1:${upstreamPort}/v1`, header: 'X-Goog-Api-Key', secret: SECRET })).status).toBe(200);
770
790
  await throughWindow('/model/google/models', { 'X-Goog-Api-Key': 'space-window' });
@@ -70,6 +70,13 @@ const LOG_ARGS = ['--log-driver', LOG_DRIVER, '--log-opt', `max-size=${LOG_MAX_S
70
70
  const GATEWAY_MODE_OPTION = 'com.docker.network.bridge.gateway_mode_ipv4';
71
71
  const GATEWAY_MODE = 'isolated';
72
72
 
73
+ // The name under which the gatekeeper reaches the machine Docker runs on, for a model grant whose
74
+ // provider listens on that machine's loopback (see "Grants" in DOCUMENTATION.md). Docker Desktop
75
+ // and Colima resolve the name on their own; on a Linux daemon `host-gateway` gives it the
76
+ // address of the host's bridge. The space never gets it: its network has no way to the host.
77
+ export const HOST_NAME = 'host.docker.internal';
78
+ const HOST_NAME_ENTRY = `${HOST_NAME}:host-gateway`;
79
+
73
80
  const NO_NEW_PRIVILEGES = ['no-new-privileges', 'no-new-privileges:true'];
74
81
  // What a correct container reports: '' for pid, uts and userns, 'private' for ipc and cgroupns.
75
82
  const PRIVATE_NAMESPACE_MODES = ['', 'private'];
@@ -143,6 +150,7 @@ export function buildGatekeeperCreateArgs({ containerName, labelArguments, netwo
143
150
  ...LOG_ARGS,
144
151
  '--network', network,
145
152
  '--network-alias', GATEKEEPER_ALIAS,
153
+ '--add-host', HOST_NAME_ENTRY,
146
154
  ...Object.entries(GATEKEEPER_ENVIRONMENT).flatMap(([name, value]) => ['--env', `${name}=${value}`]),
147
155
  image,
148
156
  ...GATEKEEPER_COMMAND,
@@ -276,7 +284,7 @@ const mentionsRuntimeSocket = (text) => String(text ?? '').includes('docker.sock
276
284
  * the tmpfs, the network the container must run on, and which mounts it may have, which
277
285
  * `mountViolations(mounts)` answers.
278
286
  */
279
- function findCommonViolations({ container, tmpfsOptions, networkMode, mountViolations, allowedEnvironment }) {
287
+ function findCommonViolations({ container, tmpfsOptions, networkMode, mountViolations, allowedEnvironment, allowedExtraHosts = [] }) {
280
288
  const violations = [];
281
289
  const violate = (check, message) => violations.push({ check, message });
282
290
 
@@ -284,6 +292,10 @@ function findCommonViolations({ container, tmpfsOptions, networkMode, mountViola
284
292
  const host = container?.HostConfig ?? {};
285
293
  const mounts = container?.Mounts ?? [];
286
294
 
295
+ // An extra name is an address the container is told about; only the ones a container is created with pass.
296
+ const unexpectedHosts = (host.ExtraHosts ?? []).filter((entry) => !allowedExtraHosts.includes(entry));
297
+ if (unexpectedHosts.length > 0) violate('extra_hosts', `The container was given names nobody set for it: ${unexpectedHosts.join(', ')}`);
298
+
287
299
  const variableNames = (config.Env ?? []).map((entry) => String(entry).split('=')[0]);
288
300
  const secretVariables = variableNames.filter((name) => FORBIDDEN_ENVIRONMENT.includes(name));
289
301
  if (secretVariables.length > 0) violate('environment', `The container environment holds a secret: ${secretVariables.join(', ')}`);
@@ -443,6 +455,7 @@ export function findGatekeeperHardeningViolations({ spaceId, owner, container, o
443
455
  message: `The gatekeeper has ${mounts.length} mount(s) and must have none: ${mounts.map((mount) => mount.Destination).join(', ')}`,
444
456
  }]),
445
457
  allowedEnvironment: GATEKEEPER_ENVIRONMENT_NAMES,
458
+ allowedExtraHosts: [HOST_NAME_ENTRY],
446
459
  });
447
460
  const violate = (check, message) => violations.push({ check, message });
448
461
 
@@ -126,6 +126,8 @@ describe('findHardeningViolations', () => {
126
126
  ['runtime', withHost({ Runtime: 'sysbox-runc' })],
127
127
  ['devices', withHost({ Devices: [{ PathOnHost: '/dev/kvm', PathInContainer: '/dev/kvm' }] })],
128
128
  ['port_bindings', withHost({ PortBindings: { '3000/tcp': [{ HostIp: '127.0.0.1', HostPort: '3000' }] } })],
129
+ // The name of the Docker host is the gatekeeper's, for a provider on that machine; a space has no name to it.
130
+ ['extra_hosts', withHost({ ExtraHosts: ['host.docker.internal:host-gateway'] })],
129
131
  ])('reports %s', (check, container) => {
130
132
  expect(checksFor({ container })).toEqual([check]);
131
133
  });
@@ -278,6 +280,7 @@ describe('findGatekeeperHardeningViolations', () => {
278
280
  memoryBytes: GATEKEEPER_MEMORY,
279
281
  tmpfs: '/tmp:rw,noexec,nosuid,size=16m',
280
282
  aliases: ['gatekeeper'],
283
+ extraHosts: ['host.docker.internal:host-gateway'],
281
284
  });
282
285
  container.NetworkSettings.Networks[OUTER] = {};
283
286
  return container;
@@ -334,6 +337,8 @@ describe('findGatekeeperHardeningViolations', () => {
334
337
  ['gatekeeper_port_bindings', withGatekeeperHost({ PortBindings: { '3128/tcp': [{ HostPort: '3128' }] } })],
335
338
  ['gatekeeper_network_mode', withGatekeeperHost({ NetworkMode: 'bridge' })],
336
339
  ['gatekeeper_memory_limit', withGatekeeperHost({ Memory: 4294967296, MemorySwap: 4294967296 })],
340
+ // The one extra name is the Docker host's; any other is a way to an address nobody granted.
341
+ ['gatekeeper_extra_hosts', withGatekeeperHost({ ExtraHosts: ['host.docker.internal:host-gateway', 'registry.internal:10.0.0.5'] })],
337
342
  ])('reports %s', (check, container) => {
338
343
  expect(gatekeeperChecks({ container })).toEqual([check]);
339
344
  });