dsh-plugin-dev-kb 1.8.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/CHANGELOG.md +186 -178
  2. package/README.en.md +172 -172
  3. package/README.md +183 -183
  4. package/kb/INDEX.md +236 -234
  5. package/kb/README.md +88 -88
  6. package/kb/extra/AGENTS.md +77 -77
  7. package/kb/extra/deepseek-llm-api-wire-extensions.md +162 -162
  8. package/kb/extra/deepseek-llm-api-wire-extensions.zh.md +162 -162
  9. package/kb/extra/defensive-patterns/package-surface.md +233 -232
  10. package/kb/extra/defensive-patterns/package-surface.zh.md +233 -232
  11. package/kb/extra/defensive-patterns/remote-and-api.md +117 -117
  12. package/kb/extra/defensive-patterns/remote-and-api.zh.md +117 -117
  13. package/kb/extra/development.md +221 -221
  14. package/kb/extra/development.zh.md +228 -228
  15. package/kb/extra/event-producer-consumer.md +133 -123
  16. package/kb/extra/event-producer-consumer.zh.md +135 -125
  17. package/kb/extra/module-graph.md +1961 -1888
  18. package/kb/extra/module-graph.zh.md +1963 -1890
  19. package/kb/extra/persistence-changes/2026-11-05-timeline-priority-notice.md +60 -0
  20. package/kb/extra/persistence-changes/2026-11-05-timeline-priority-notice.zh.md +60 -0
  21. package/kb/extra/persistence-changes/README.md +92 -92
  22. package/kb/extra/persistence-changes/README.zh.md +92 -92
  23. package/kb/extra/persistence-changes/historical-formats/README.md +75 -75
  24. package/kb/extra/persistence-changes/historical-formats/README.zh.md +75 -75
  25. package/kb/extra/persistence-changes/releases/README.md +103 -103
  26. package/kb/extra/persistence-changes/releases/README.zh.md +103 -103
  27. package/kb/extra/rescope.md +55 -55
  28. package/kb/extra/rescope.zh.md +55 -55
  29. package/kb/extra/subsystems/boot.md +631 -621
  30. package/kb/extra/subsystems/boot.zh.md +631 -621
  31. package/kb/extra/subsystems/computer-use.md +179 -137
  32. package/kb/extra/subsystems/computer-use.zh.md +179 -137
  33. package/kb/extra/subsystems/extensions.md +387 -384
  34. package/kb/extra/subsystems/extensions.zh.md +387 -384
  35. package/kb/extra/subsystems/feedback.md +418 -400
  36. package/kb/extra/subsystems/feedback.zh.md +418 -400
  37. package/kb/extra/subsystems/forge.md +2169 -1226
  38. package/kb/extra/subsystems/forge.zh.md +2171 -1226
  39. package/kb/extra/subsystems/liveshare.md +167 -158
  40. package/kb/extra/subsystems/liveshare.zh.md +167 -158
  41. package/kb/extra/subsystems/mcp.md +237 -234
  42. package/kb/extra/subsystems/mcp.zh.md +237 -234
  43. package/kb/extra/subsystems/office-kit.md +122 -0
  44. package/kb/extra/subsystems/office-kit.zh.md +122 -0
  45. package/kb/extra/subsystems/working-directory.md +95 -64
  46. package/kb/extra/subsystems/working-directory.zh.md +95 -64
  47. package/kb/extra/subsystems/worktrees.md +187 -127
  48. package/kb/extra/subsystems/worktrees.zh.md +187 -127
  49. package/kb/extra/upgrade-guide/v0.2.1-alpha.1/python-ptc-sandbox/guide.md +21 -21
  50. package/kb/extra/upgrade-guide/v0.2.1-alpha.1/python-ptc-sandbox/guide.zh.md +21 -21
  51. package/kb/extra/upgrade-guide/v0.2.1-rc.4/sandbox-unsupported-policy-error/guide.md +18 -0
  52. package/kb/extra/upgrade-guide/v0.2.1-rc.4/sandbox-unsupported-policy-error/guide.zh.md +18 -0
  53. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/llm-error-builtin-codes/guide.md +18 -0
  54. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/llm-error-builtin-codes/guide.zh.md +18 -0
  55. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-kit-package/guide.md +34 -0
  56. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-kit-package/guide.zh.md +34 -0
  57. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-operation-tools/guide.md +49 -0
  58. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-operation-tools/guide.zh.md +49 -0
  59. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-skill-resources/guide.md +36 -0
  60. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-skill-resources/guide.zh.md +36 -0
  61. package/kb/extra/upgrade-guide/v0.2.2-rc.1/account-notification-fields/guide.md +26 -0
  62. package/kb/extra/upgrade-guide/v0.2.2-rc.1/account-notification-fields/guide.zh.md +26 -0
  63. package/kb/extra/upgrade-guide/v0.2.2-rc.1/account-remote-provider/guide.md +22 -0
  64. package/kb/extra/upgrade-guide/v0.2.2-rc.1/account-remote-provider/guide.zh.md +22 -0
  65. package/kb/extra/upgrade-guide/v0.2.2-rc.1/archive-worktrees/guide.md +21 -0
  66. package/kb/extra/upgrade-guide/v0.2.2-rc.1/archive-worktrees/guide.zh.md +21 -0
  67. package/kb/extra/upgrade-guide/v0.2.2-rc.1/attachment-error-codes/guide.md +23 -0
  68. package/kb/extra/upgrade-guide/v0.2.2-rc.1/attachment-error-codes/guide.zh.md +23 -0
  69. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-ax-read-limits/guide.md +20 -0
  70. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-ax-read-limits/guide.zh.md +20 -0
  71. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-hover-ax-only/guide.md +18 -0
  72. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-hover-ax-only/guide.zh.md +18 -0
  73. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-native-platform/guide.md +23 -0
  74. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-native-platform/guide.zh.md +23 -0
  75. package/kb/extra/upgrade-guide/v0.2.2-rc.1/dsh-doc-skill/guide.md +35 -0
  76. package/kb/extra/upgrade-guide/v0.2.2-rc.1/dsh-doc-skill/guide.zh.md +35 -0
  77. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-change-request-overview/guide.md +26 -0
  78. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-change-request-overview/guide.zh.md +26 -0
  79. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-pinned-diff/guide.md +26 -0
  80. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-pinned-diff/guide.zh.md +26 -0
  81. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-review-reads/guide.md +19 -0
  82. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-review-reads/guide.zh.md +19 -0
  83. package/kb/extra/upgrade-guide/v0.2.2-rc.1/package-export-cleanup/guide.md +26 -0
  84. package/kb/extra/upgrade-guide/v0.2.2-rc.1/package-export-cleanup/guide.zh.md +26 -0
  85. package/kb/extra/upgrade-guide/v0.2.2-rc.1/plugin-update-method/guide.md +22 -0
  86. package/kb/extra/upgrade-guide/v0.2.2-rc.1/plugin-update-method/guide.zh.md +22 -0
  87. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-bootstrap-protocol/guide.md +25 -0
  88. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-bootstrap-protocol/guide.zh.md +25 -0
  89. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-inspect-output/guide.md +48 -0
  90. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-inspect-output/guide.zh.md +48 -0
  91. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-scoped-repl-default/guide.md +45 -0
  92. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-scoped-repl-default/guide.zh.md +45 -0
  93. package/kb/extra/upgrade-guide/v0.2.2-rc.1/runtime-context-reminders/guide.md +19 -0
  94. package/kb/extra/upgrade-guide/v0.2.2-rc.1/runtime-context-reminders/guide.zh.md +19 -0
  95. package/kb/extra/upgrade-guide/v0.2.2-rc.1/session-append-overloads/guide.md +17 -0
  96. package/kb/extra/upgrade-guide/v0.2.2-rc.1/session-append-overloads/guide.zh.md +17 -0
  97. package/kb/extra/upgrade-guide/v0.2.2-rc.1/subagent-interrupt-default/guide.md +27 -0
  98. package/kb/extra/upgrade-guide/v0.2.2-rc.1/subagent-interrupt-default/guide.zh.md +27 -0
  99. package/kb/extra/upgrade-guide/v0.2.2-rc.1/terminal-backend-cleanup-error/guide.md +20 -0
  100. package/kb/extra/upgrade-guide/v0.2.2-rc.1/terminal-backend-cleanup-error/guide.zh.md +20 -0
  101. package/kb/extra/upgrade-guide/v0.2.2-rc.1/terminal-bundle-sidebar-backend/guide.md +19 -0
  102. package/kb/extra/upgrade-guide/v0.2.2-rc.1/terminal-bundle-sidebar-backend/guide.zh.md +19 -0
  103. package/kb/extra/upgrade-guide/v0.2.2-rc.1/web-fetch-transport-error-codes/guide.md +18 -0
  104. package/kb/extra/upgrade-guide/v0.2.2-rc.1/web-fetch-transport-error-codes/guide.zh.md +18 -0
  105. package/kb/extra/upgrade-guide/v0.2.2-rc.1/web-search-billing/guide.md +41 -0
  106. package/kb/extra/upgrade-guide/v0.2.2-rc.1/web-search-billing/guide.zh.md +41 -0
  107. package/kb/extra/upgrade-guide/v0.2.2-rc.1/window-drag-regions/guide.md +21 -0
  108. package/kb/extra/upgrade-guide/v0.2.2-rc.1/window-drag-regions/guide.zh.md +21 -0
  109. package/kb/extra/upgrade-guide/v0.2.2-rc.2/client-module-metadata/guide.md +29 -0
  110. package/kb/extra/upgrade-guide/v0.2.2-rc.2/client-module-metadata/guide.zh.md +29 -0
  111. package/kb/extra/upgrade-guide/v0.2.2-rc.2/connection-page-peer/guide.md +25 -0
  112. package/kb/extra/upgrade-guide/v0.2.2-rc.2/connection-page-peer/guide.zh.md +25 -0
  113. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cordis-root-and-intercept-metadata/guide.md +31 -0
  114. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cordis-root-and-intercept-metadata/guide.zh.md +31 -0
  115. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-agents-without-preset/guide.md +24 -0
  116. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-agents-without-preset/guide.zh.md +24 -0
  117. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-macos-provider/guide.md +24 -0
  118. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-macos-provider/guide.zh.md +24 -0
  119. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-partial-observations/guide.md +19 -0
  120. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-partial-observations/guide.zh.md +19 -0
  121. package/kb/extra/upgrade-guide/v0.2.2-rc.2/deepseek-files-timeout/guide.md +15 -0
  122. package/kb/extra/upgrade-guide/v0.2.2-rc.2/deepseek-files-timeout/guide.zh.md +15 -0
  123. package/kb/extra/upgrade-guide/v0.2.2-rc.2/experimental-tool-error-codes/guide.md +28 -0
  124. package/kb/extra/upgrade-guide/v0.2.2-rc.2/experimental-tool-error-codes/guide.zh.md +28 -0
  125. package/kb/extra/upgrade-guide/v0.2.2-rc.2/package-export-cleanup/guide.md +36 -0
  126. package/kb/extra/upgrade-guide/v0.2.2-rc.2/package-export-cleanup/guide.zh.md +36 -0
  127. package/kb/extra/upgrade-guide/v0.2.2-rc.2/python-ptc-removal/guide.md +22 -0
  128. package/kb/extra/upgrade-guide/v0.2.2-rc.2/python-ptc-removal/guide.zh.md +22 -0
  129. package/kb/extra/upgrade-guide/v0.2.2-rc.2/session-status-package/guide.md +31 -0
  130. package/kb/extra/upgrade-guide/v0.2.2-rc.2/session-status-package/guide.zh.md +31 -0
  131. package/kb/extra/upgrade-guide/v0.2.2-rc.2/shared-search-filter/guide.md +18 -0
  132. package/kb/extra/upgrade-guide/v0.2.2-rc.2/shared-search-filter/guide.zh.md +18 -0
  133. package/kb/extra/upgrade-guide/v0.2.2-rc.2/shell-fs-tool-error-codes/guide.md +30 -0
  134. package/kb/extra/upgrade-guide/v0.2.2-rc.2/shell-fs-tool-error-codes/guide.zh.md +30 -0
  135. package/kb/extra/web-styling.md +57 -57
  136. package/kb/extra/web-styling.zh.md +57 -57
  137. package/kb/meta/search-index.json +4508 -3980
  138. package/kb/meta/source.json +18 -18
  139. package/kb/site/develop/practice/llm-adapter.md +192 -192
  140. package/kb/site/en/develop/practice/llm-adapter.md +192 -192
  141. package/kb/site/en/guide/desktop-uninstall-cleanup.md +63 -0
  142. package/kb/site/en/guide/plugin-market.md +153 -151
  143. package/kb/site/en/guide/providers.md +234 -234
  144. package/kb/site/en/guide/quickstart.md +35 -34
  145. package/kb/site/en/reference/capability-seams.md +789 -767
  146. package/kb/site/en/reference/config-catalog.md +5432 -5128
  147. package/kb/site/en/reference/cookbook/adding-a-package.md +175 -175
  148. package/kb/site/en/reference/cookbook/adding-a-tool.md +105 -104
  149. package/kb/site/en/reference/cookbook/extension-cookbook.md +178 -135
  150. package/kb/site/en/reference/cordis-api/context.md +373 -369
  151. package/kb/site/en/reference/cordis-api/fiber.md +457 -433
  152. package/kb/site/en/reference/cordis-api/inherited.md +44 -44
  153. package/kb/site/en/reference/cordis-api/service.md +118 -107
  154. package/kb/site/en/reference/experimental-persistence-catalog.md +36 -23
  155. package/kb/site/en/reference/index.md +174 -174
  156. package/kb/site/en/reference/persistence-catalog.md +9453 -9432
  157. package/kb/site/en/reference/subsystems/compaction.md +288 -288
  158. package/kb/site/en/reference/subsystems/core.md +1172 -1171
  159. package/kb/site/en/reference/subsystems/credentials.md +526 -497
  160. package/kb/site/en/reference/subsystems/filesystem.md +708 -708
  161. package/kb/site/en/reference/subsystems/index.md +82 -82
  162. package/kb/site/en/reference/subsystems/llm-streaming.md +1290 -1288
  163. package/kb/site/en/reference/subsystems/lsp.md +230 -206
  164. package/kb/site/en/reference/subsystems/persistence.md +451 -432
  165. package/kb/site/en/reference/subsystems/plan.md +91 -91
  166. package/kb/site/en/reference/subsystems/ptc-runtime.md +295 -261
  167. package/kb/site/en/reference/subsystems/sandbox.md +250 -232
  168. package/kb/site/en/reference/subsystems/session-query.md +525 -515
  169. package/kb/site/en/reference/subsystems/session-reference.md +231 -229
  170. package/kb/site/en/reference/subsystems/session.md +1478 -1431
  171. package/kb/site/en/reference/subsystems/sidebar-right.md +165 -165
  172. package/kb/site/en/reference/subsystems/skills.md +356 -356
  173. package/kb/site/en/reference/subsystems/slots.md +235 -231
  174. package/kb/site/en/reference/subsystems/terminal.md +188 -188
  175. package/kb/site/en/reference/subsystems/tools.md +902 -891
  176. package/kb/site/en/reference/subsystems/user-questions.md +330 -327
  177. package/kb/site/en/reference/subsystems/web-client.md +161 -104
  178. package/kb/site/en/reference/subsystems/web-server.md +434 -351
  179. package/kb/site/en/reference/subsystems/web.md +268 -268
  180. package/kb/site/en/reference/subsystems/workflow.md +287 -282
  181. package/kb/site/en/reference/subsystems/workspace.md +743 -651
  182. package/kb/site/en/reference/tool-catalog.md +2867 -2704
  183. package/kb/site/guide/desktop-uninstall-cleanup.md +63 -0
  184. package/kb/site/guide/plugin-market.md +153 -151
  185. package/kb/site/guide/providers.md +234 -234
  186. package/kb/site/guide/quickstart.md +35 -34
  187. package/kb/site/reference/capability-seams.md +789 -767
  188. package/kb/site/reference/config-catalog.md +5432 -5128
  189. package/kb/site/reference/cookbook/adding-a-package.md +175 -175
  190. package/kb/site/reference/cookbook/adding-a-tool.md +107 -106
  191. package/kb/site/reference/cookbook/extension-cookbook.md +182 -139
  192. package/kb/site/reference/cordis-api/context.md +373 -369
  193. package/kb/site/reference/cordis-api/fiber.md +459 -435
  194. package/kb/site/reference/cordis-api/inherited.md +44 -44
  195. package/kb/site/reference/cordis-api/service.md +118 -107
  196. package/kb/site/reference/experimental-persistence-catalog.md +36 -23
  197. package/kb/site/reference/index.md +178 -178
  198. package/kb/site/reference/persistence-catalog.md +9453 -9432
  199. package/kb/site/reference/subsystems/compaction.md +288 -288
  200. package/kb/site/reference/subsystems/core.md +1184 -1183
  201. package/kb/site/reference/subsystems/credentials.md +526 -497
  202. package/kb/site/reference/subsystems/filesystem.md +708 -708
  203. package/kb/site/reference/subsystems/index.md +82 -82
  204. package/kb/site/reference/subsystems/llm-streaming.md +1296 -1294
  205. package/kb/site/reference/subsystems/lsp.md +230 -206
  206. package/kb/site/reference/subsystems/persistence.md +451 -432
  207. package/kb/site/reference/subsystems/plan.md +91 -91
  208. package/kb/site/reference/subsystems/ptc-runtime.md +295 -261
  209. package/kb/site/reference/subsystems/sandbox.md +250 -232
  210. package/kb/site/reference/subsystems/session-query.md +525 -515
  211. package/kb/site/reference/subsystems/session-reference.md +231 -229
  212. package/kb/site/reference/subsystems/session.md +1482 -1435
  213. package/kb/site/reference/subsystems/sidebar-right.md +165 -165
  214. package/kb/site/reference/subsystems/skills.md +356 -356
  215. package/kb/site/reference/subsystems/slots.md +239 -235
  216. package/kb/site/reference/subsystems/terminal.md +188 -188
  217. package/kb/site/reference/subsystems/tools.md +902 -891
  218. package/kb/site/reference/subsystems/user-questions.md +330 -327
  219. package/kb/site/reference/subsystems/web-client.md +161 -104
  220. package/kb/site/reference/subsystems/web-server.md +434 -351
  221. package/kb/site/reference/subsystems/web.md +268 -268
  222. package/kb/site/reference/subsystems/workflow.md +287 -282
  223. package/kb/site/reference/subsystems/workspace.md +743 -651
  224. package/kb/site/reference/tool-catalog.md +2872 -2709
  225. package/lib/index.js +359 -359
  226. package/package.json +68 -68
  227. package/skills/dsh-plugin-dev-kb.md +71 -70
  228. package/kb/extra/subsystems/office-to-pdf.md +0 -87
  229. package/kb/extra/subsystems/office-to-pdf.zh.md +0 -87
@@ -1,351 +1,434 @@
1
- ---
2
- editSource: "docs/subsystems/web-server.md"
3
- rawMarkdownPath: "en/reference/subsystems/web-server.md"
4
- outline: [2,3]
5
- ---
6
-
7
- # HTTP Server
8
-
9
- [dsh-host-webserver](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/host/webserver) is the browser HTTP carrier for the GUI host: one `node:http` server — `node:https` when `tls` is configured — providing `ctx.webServer`, a named-route registry, optional gzip response compression, index.html transform callbacks, and one fallback, a handler or a resource, that a plugin may claim. It is not part of the agent loop and not a capability seam; its only harness concept is the Peer an index render speaks for, and another plugin registers every feature route, including the `/api` bridge, plugin bundles, and the HMR event stream ([layering reference](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/boot/app-boot/README.md)). It serves browsers only: Electron loads the built files over `file://` and sends fetch requests through an IPC bridge instead of this server.
10
-
11
- Source: [`packages/host/webserver/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/host/webserver/src/index.ts)
12
-
13
- ## Routes
14
-
15
- ```ts type-equiv
16
- /** Route match kind: 'exact' matches the pathname verbatim; 'prefix' p matches p and p/<anything>. */
17
- type WebRouteKind = 'exact' | 'prefix'
18
- ```
19
-
20
- ```ts type-equiv
21
- /** One named route registration. */
22
- interface WebRoute {
23
- kind: WebRouteKind
24
- /** Absolute pathname, no trailing slash. */
25
- path: string
26
- /** Owns the full response lifecycle (may hold the response open, e.g. SSE). */
27
- handler: (req: IncomingMessage, res: ServerResponse) => void | Promise<void>
28
- }
29
- ```
30
-
31
- ```ts type-equiv
32
- /**
33
- * Answers one GET or HEAD request with a Fetch response. An HTTP request
34
- * arrives without a Peer and carries the client's headers; an in-process
35
- * {@link WebServer.readResource} read passes the Peer its caller admitted.
36
- */
37
- type WebResource = (request: Request, peer?: PeerScope) => Promise<Response>
38
- ```
39
-
40
- ```ts type-equiv
41
- /** One named route answered by a resource instead of a handler. */
42
- interface WebResourceRoute {
43
- kind: WebRouteKind
44
- /** Absolute pathname, no trailing slash. */
45
- path: string
46
- /** Answers HTTP GET and HEAD requests and in-process reads. */
47
- resource: WebResource
48
- }
49
- ```
50
-
51
- Match order is fixed: exact table first, then longest matching prefix, then the registered fallback. Registration order carries no request-facing semantics — named routes are composed to be disjoint, and the fallback seat answers anything no named route claims; one owner only, a second registration throws. The shipped Web composition claims the seat with [`dsh-host-frontend-static`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/host/frontend-static/src/index.ts), the SPA dist server with locked semantics: Connection authenticates the dist root and configured index before their HTML is read; non-index assets remain public; non-GET/HEAD is 405, traversal outside the dist root is 403, existing files are served directly, absent or non-file targets are empty 404 responses, and unknown extensions ship as octet-stream.
52
-
53
- A route or the fallback may give a resource, a function from a Fetch `Request` to a `Response`, instead of a handler. HTTP `GET` and `HEAD` requests reach it without a Peer, and `readResource(request, peer)` reads it in process for the Peer its caller admitted; a read follows the same match order but reaches only resources, so a route that returns owner-private data or performs an action stays a handler even when it answers `GET`.
54
-
55
- <a id="config"></a>
56
-
57
- ## Config
58
-
59
- ```ts type-equiv
60
- /** Web server listen, TLS, and response-compression config. */
61
- interface Config {
62
- /**
63
- * Listen address: a concrete IPv4 or IPv6 literal of one local interface,
64
- * for example the container's own Pod address from `hostname -i`. A loopback
65
- * literal (any address in 127/8, `::1`, or a mapped form of either) keeps the
66
- * server on this machine; any other literal serves the network that address
67
- * belongs to, over plain HTTP unless `tls` is set. The unspecified address —
68
- * IPv4 any, IPv6 any, and the IPv4-mapped forms of IPv4 any — is rejected at
69
- * load: it would expose the port on every interface at once.
70
- */
71
- host: string
72
- /** Listen port; zero requests an OS-assigned port. */
73
- port: number
74
- /**
75
- * Serve HTTPS with this certificate and key instead of plain HTTP. Both files
76
- * are read once, before the listener binds: an unreadable or empty file,
77
- * invalid PEM, or a key that does not match the certificate rejects
78
- * initialization rather than falling back to HTTP. The material is never
79
- * re-read, so replacing a certificate takes a reload. Omitted or null listens
80
- * over plain HTTP.
81
- */
82
- tls?: TlsConfig
83
- /** Response compression for socket-backed HTTP requests. @default 'none' */
84
- compression?: 'none' | 'gzip'
85
- /** Gzip DEFLATE level from 0 through 9. @default 1 */
86
- compressionLevel?: number
87
- /** Minimum known response length eligible for gzip; unknown-length streams are eligible. @default 1024 */
88
- compressionThresholdBytes?: number
89
- }
90
- ```
91
-
92
- ```ts type-equiv
93
- /**
94
- * TLS material for the HTTPS listener: one certificate chain file and the
95
- * private key file it pairs with. Both hold PEM text and both resolve against
96
- * the process working directory.
97
- */
98
- interface TlsConfig {
99
- /** Certificate chain file, leaf certificate first, PEM, no passphrase. */
100
- certFile: string
101
- /** Private key file for the chain's leaf certificate; unencrypted PEM. */
102
- keyFile: string
103
- }
104
- ```
105
-
106
- No composition can bind every interface at once: the unspecified address is rejected at load. The exported `isWildcardHost` and `isLoopbackHost` classify a bind address from its parsed value, and an IPv6 `%zone` is kept for `listen` while classification reads the address alone. The carrier owns no authentication or Origin policy, and it serves plain HTTP unless `tls` supplies a certificate and key. `compression` defaults to `none`; the shipped Web bundle selects gzip level 1 with a 1024-byte threshold. The shipped `dsh web` command selects loopback by default and accepts one concrete `--host` address, warning at startup when a non-loopback bind serves plain HTTP; its Connection plugin supplies Host/Origin checks plus browser-session authentication for every Host API route and stream, and the bind address plus `--trusted-host` govern which browser Host is accepted; `--public-url` changes only the advertised URL. Other compositions own their bind and route-authentication policy. The dist location is an assembly fact of the frontend plugin that claims the seat.
107
-
108
- ## The service
109
-
110
- `WebServer` (`ctx.webServer`) listens immediately on activation; a listen failure (EADDRINUSE…) rejects initialization, and the boot process reports the failed fiber. The `tls` pair is read once before the listener binds, and an unreadable, empty, or mismatched pair rejects initialization the same way instead of falling back to HTTP. `register(route)` adds one named route and returns its disposer; a duplicate `(kind, path)` throws because route patterns are a composition-level contract and a collision is a misconfiguration. Gzip wraps eligible socket-backed responses inside the server, so handlers keep direct `ServerResponse` ownership, and a resource hands the service a `Response` to write back. Existing content encodings, `Cache-Control: no-transform`, ranges, SSE, ZIP, and the packaged `.gz` Worker image remain identity responses. `collectIndexInjections(peer)` gathers structured `IndexInjection` rows over one `webserver/index-inject` emit that passes the Peer the page speaks for, and `renderIndex(html, peer)` renders them into successful root and configured index responses before applying the raw `tapIndex(transform)` escape-hatch transforms in registration order; [dsh-client-modules](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/client/modules) answers the event with the boot manifest rows. `port` reads the listening port, including the port assigned by the OS when `config.port` is 0, and `protocol` reports the scheme the listener serves (`http:` or `https:`).
111
-
112
- A request whose handling throws (a malformed %-escape hitting `decodeURIComponent`, a client dropping mid-body) is logged as a warning and answered 400 — or the socket destroyed when headers are already out — never a process exit. Disposal pairs `close()` with `closeAllConnections()` because a handler may hold its response open (SSE) and such connections never end on their own; without the force-close, teardown would hang. A TLS socket counts as a connection only after its handshake, so the server tracks raw TLS sockets beside upgraded ones and destroys both at disposal. The package never prints: the URL line belongs to the shell. Per-package operational detail, including the dev-mode bundle watch pipeline, stays in the [README](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/host/webserver/README.md).
113
-
114
- <!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
115
-
116
- <a id="cordis-surface"></a>
117
-
118
- ## Cordis API
119
-
120
- Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnpm run verify-cordis-catalog` in doc-sync; regenerate with `pnpm run gen-cordis-catalog`) — the language sides differ only in locale-specific paired document paths. Signature blocks use a `ts cordis-catalog` fence and keep the original source JSDoc; dispatch modes are defined in the [primer](../cordis-primer.md#dispatch-modes), and the framework-inherited `ctx` API lives in [cordis-api/inherited.md](../cordis-api/inherited.md).
121
-
122
- <a id="ctxconnection--hostconnectionhandle"></a>
123
-
124
- ### `ctx.connection` — `HostConnectionHandle`
125
-
126
- Host `ctx.connection` members consumed by transport-independent adapters.
127
-
128
- ```ts cordis-catalog
129
- /**
130
- * Compose exact Fetch routes and the shared-channel RPC interceptor.
131
- * @param channel - shared channel mounted by Connection.
132
- * @returns Fetch handler for trusted, authenticated requests.
133
- */
134
- createSharedFetchHandler(channel: '/api'): ConnectionFetchHandler
135
-
136
- /**
137
- * Apply Connection's Host/Origin checks and browser authentication to
138
- * another Web route.
139
- * @param request - request headers from the HTTP or upgrade request.
140
- * @returns rejection status, or undefined when the route may accept the request.
141
- */
142
- requestRejection(request: ConnectionTrustRequest): ConnectionRequestRejection
143
-
144
- /**
145
- * Admit an HTTP request against its signed browser or API credential and live Peer.
146
- * @param request - request headers from the HTTP or upgrade request.
147
- * @returns the credential's Peer, or the rejection status.
148
- */
149
- admit(request: ConnectionTrustRequest): PeerAdmission
150
-
151
- /**
152
- * Create an independent in-process Peer, disposed with the Context that read `ctx.connection`.
153
- * @param options - fixed principal and optional interaction participation (default `answer`).
154
- * @returns a new Peer distinct from every other Peer.
155
- */
156
- createPeer(options: { readonly principal: Principal; readonly interactions?: 'answer' | 'none' }): PeerScope
157
-
158
- /**
159
- * Claim a physical socket for an API Peer; browser sockets share their owner Peer.
160
- * @param request - authenticated upgrade request headers.
161
- * @returns the Peer and idempotent release, or 409 for duplicate API ownership.
162
- * The carrier releases on socket termination or failed upgrade; release removes
163
- * API admission synchronously without cancelling independent HTTP calls.
164
- */
165
- admitConnection(request: ConnectionTrustRequest): ConnectionAdmission
166
-
167
- /**
168
- * Authenticate one frontend index request, owning a token redirect or 401.
169
- * The cookie this mints is `Secure` when the mounted Web carrier serves TLS,
170
- * which only that listener's protocol decides.
171
- * @param request - root or configured-index HTTP request.
172
- * @param response - response owned when the result is false.
173
- * @returns true only when the frontend may serve index.html.
174
- */
175
- authorizeIndex(request: ConnectionIndexRequest, response: ConnectionIndexResponse): boolean
176
-
177
- /**
178
- * Add the fresh process token to an ordinary Web application URL.
179
- * @param baseUrl - clean application URL whose authority and mount are preserved.
180
- * @returns tokenized URL for initial login; a mount proxy strips its prefix before {@link authorizeIndex}.
181
- */
182
- authenticatedUrl(baseUrl: string): string
183
- ```
184
-
185
- Types: [Principal](./typert.md)
186
-
187
- Source: [`packages/client/connection/src/rpc.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/client/connection/src/rpc.ts)
188
-
189
- <a id="ctxwebapp--webapp"></a>
190
-
191
- ### `ctx.webApp` — `WebApp`
192
-
193
- The Web GUI this process serves, provided by the `web-runtime` row.
194
-
195
- ```ts cordis-catalog
196
- /**
197
- * The URL this GUI advertises, also used for `DSH_WEB_URL` and the startup URL line.
198
- * @returns the configured `publicUrl`, otherwise the listener origin.
199
- */
200
- getAdvertisedUrl(): string
201
- ```
202
-
203
- Source: [`packages/bundle/web-app/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/bundle/web-app/src/index.ts)
204
-
205
- <a id="ctxwebserver--webserver"></a>
206
-
207
- ### `ctx.webServer` — `WebServer`
208
-
209
- The browser HTTP carrier service. Activation loads any configured TLS material, then listens immediately; a material or listen failure rejects initialization, and the boot process reports the failed fiber. Route registration order does not affect requests because configured named routes must be distinct, and a request no named route matches is answered 404 until the fallback owner registers.
210
-
211
- ```ts cordis-catalog
212
- /**
213
- * The root URL local clients use to reach the bound listener: the protocol,
214
- * the {@link bindUrlHost} form of the bind address, and the listening port.
215
- * @returns the origin, for example `http://127.0.0.1:3080`.
216
- * @throws before `listen` binds a port, or when the bind address has no URL form.
217
- */
218
- getOrigin(): string
219
-
220
- /**
221
- * Register a named route. Duplicate (kind, path) throws — route patterns are
222
- * a composition-level contract, so a collision is a misconfiguration.
223
- * @param route - kind, path, and the owning handler or resource.
224
- * @returns the disposer removing the route.
225
- */
226
- register(route: WebRoute | WebResourceRoute): () => void
227
-
228
- /**
229
- * Register an exact-path HTTP upgrade route. Duplicate paths throw because
230
- * one socket can have only one protocol owner.
231
- * @param route - pathname and handler owning negotiation plus socket use.
232
- * @returns the disposer removing the route.
233
- */
234
- registerUpgrade(route: WebUpgradeRoute): () => void
235
-
236
- /**
237
- * Claim the fallback seat: the handler or resource answering every request
238
- * no named route matches (the SPA dist server in the shipped Web
239
- * composition). One owner only — a second registration throws, because two
240
- * fallbacks cannot compose.
241
- * @param fallback - a handler owning the full response lifecycle of
242
- * unmatched requests, or `{ resource }` answering them.
243
- * @returns the disposer releasing the seat.
244
- */
245
- registerFallback(fallback: WebRoute['handler'] | Pick<WebResourceRoute, 'resource'>): () => void
246
-
247
- /**
248
- * Read the response an HTTP request for the same URL would receive, as the
249
- * resource computes it for `peer`, without an HTTP exchange. The request
250
- * path picks the responder by the HTTP match order — exact, longest prefix,
251
- * then the fallback — and only a resource answers. This method checks no
252
- * cookie, Host, or Origin: the caller admits the reader before reading.
253
- * @param request - the read; its URL path selects the responder.
254
- * @param peer - the Peer the read speaks for, passed to the resource.
255
- * @returns the resource's response, without a body for HEAD as over HTTP;
256
- * 405 with `Allow: GET, HEAD` for any other method, checked before matching,
257
- * where over HTTP a handler route or an unmatched path answers such a
258
- * method itself; 404 when the path matches a handler route, or reaches the
259
- * fallback seat while it is unclaimed or holds a handler. A resource that
260
- * throws rejects the read, where an HTTP request would receive 400.
261
- */
262
- async readResource(request: Request, peer: PeerScope): Promise<Response>
263
-
264
- /**
265
- * Register a raw-HTML index transform, the escape hatch for markup no
266
- * {@link IndexInjection} row expresses: {@link renderIndex} applies taps in
267
- * registration order after rendering the structured rows.
268
- * @param transform - pure html-to-html function.
269
- * @returns the disposer removing the transform.
270
- */
271
- tapIndex(transform: (html: string) => string): () => void
272
-
273
- /**
274
- * Run an index.html body through the registered taps in registration order
275
- * — called by the fallback owner on every index response it renders.
276
- * @param html - the raw index.html body.
277
- * @returns the transformed body.
278
- */
279
- applyIndexTaps(html: string): string
280
-
281
- /**
282
- * Gather the structured injection table for one Peer: one
283
- * `webserver/index-inject` emit, every subscriber pushes its current rows.
284
- * Fresh per call, so subscribers read live state (module graph, theme
285
- * preference, the Peer's access) at emit time.
286
- * @param peer - the Peer the page speaks for.
287
- * @returns rows in subscriber activation order.
288
- */
289
- collectIndexInjections(peer: PeerScope): IndexInjection[]
290
-
291
- /**
292
- * Render one index.html body for one Peer: the structured injection table
293
- * first, then the raw `tapIndex` transforms over the result.
294
- * @param html - the raw index.html body.
295
- * @param peer - the Peer the page speaks for.
296
- * @returns the transformed body.
297
- */
298
- renderIndex(html: string, peer: PeerScope): string
299
- ```
300
-
301
- Source: [`packages/host/webserver/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/host/webserver/src/index.ts)
302
-
303
- <a id="connection-events"></a>
304
-
305
- ### `connection/*` events
306
-
307
- <a id="connectionrequest--waterfall"></a>
308
-
309
- #### `connection/request` — waterfall
310
-
311
- Admit or wrap an authenticated shared API request, including body transfer. Existing requests continue when a listener refuses subsequent requests.
312
-
313
- ```ts cordis-catalog
314
- /**
315
- * Admit or wrap an authenticated shared API request, including body transfer.
316
- * Existing requests continue when a listener refuses subsequent requests.
317
- * @param request - Authenticated incoming HTTP request.
318
- * @param response - Response owned until the delegated bridge settles.
319
- * @param next - Delegate to the next listener or the shared API bridge.
320
- * @mode waterfall
321
- */
322
- 'connection/request'(request: IncomingMessage, response: ServerResponse, next: () => Promise<void>): Promise<void>
323
- ```
324
-
325
- Source: [`packages/client/connection/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/client/connection/src/index.ts)
326
-
327
- <a id="webserver-events"></a>
328
-
329
- ### `webserver/*` events
330
-
331
- <a id="webserverindex-inject--emit"></a>
332
-
333
- #### `webserver/index-inject` — emit
334
-
335
- Collect the structured index injection table for the page `peer` speaks for. Emitted on every index render and every worker boot-payload request; listeners push their current rows, so a row's data is read fresh at emit time.
336
-
337
- ```ts cordis-catalog
338
- /**
339
- * Collect the structured index injection table for the page `peer` speaks
340
- * for. Emitted on every index render and every worker boot-payload
341
- * request; listeners push their current rows, so a row's data is read
342
- * fresh at emit time.
343
- * @param table - Mutable row table; listeners append in activation order.
344
- * @param peer - The Peer the rendered page speaks for.
345
- * @mode emit
346
- */
347
- 'webserver/index-inject'(table: IndexInjection[], peer: PeerScope): void
348
- ```
349
-
350
- Source: [`packages/host/webserver/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/host/webserver/src/index.ts)
351
- <!-- END GENERATED cordis-surface -->
1
+ ---
2
+ editSource: "docs/subsystems/web-server.md"
3
+ rawMarkdownPath: "en/reference/subsystems/web-server.md"
4
+ outline: [2,3]
5
+ ---
6
+
7
+ # HTTP Server
8
+
9
+ [dsh-host-webserver](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/host/webserver) provides the GUI Host's HTTP or TLS listener, route matching and admission, optional gzip, index rendering, and one fallback. Feature plugins register their own routes; Connection supplies source and credential decisions through `webserver/authorize`. The carrier passes each admitted Peer directly to the handler or resource rather than constructing a request-context container ([layering reference](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/boot/app-boot/README.md)).
10
+
11
+ Source: [`packages/host/webserver/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/host/webserver/src/index.ts)
12
+
13
+ ## Routes
14
+
15
+ ```ts type-equiv
16
+ /** Route match kind: 'exact' matches the pathname verbatim; 'prefix' p matches p and p/<anything>. */
17
+ type WebRouteKind = 'exact' | 'prefix'
18
+ ```
19
+
20
+ ```ts type-equiv
21
+ /** One named route registration. */
22
+ interface WebRoute {
23
+ kind: WebRouteKind
24
+ /** Absolute pathname, no trailing slash. */
25
+ path: string
26
+ /** Owns the full response lifecycle (may hold the response open, e.g. SSE). */
27
+ handler: (req: IncomingMessage, res: ServerResponse, peer?: PeerScope) => void | Promise<void>
28
+ /** Defaults to required. Anonymous handlers may receive no Peer. */
29
+ auth?: WebAuthenticationRule
30
+ }
31
+ ```
32
+
33
+ ```ts type-equiv
34
+ /**
35
+ * Answers one GET or HEAD request with a Fetch response and its admitted Peer.
36
+ * Anonymous HTTP admission may omit the Peer; an in-process
37
+ * {@link WebServer.readResource} read passes the Peer its caller admitted.
38
+ */
39
+ type WebResource = (request: Request, peer?: PeerScope) => Promise<Response>
40
+ ```
41
+
42
+ ```ts type-equiv
43
+ /** One named route answered by a resource instead of a handler. */
44
+ interface WebResourceRoute {
45
+ kind: WebRouteKind
46
+ /** Absolute pathname, no trailing slash. */
47
+ path: string
48
+ /** Answers HTTP GET and HEAD requests and in-process reads. */
49
+ resource: WebResource
50
+ /** Defaults to required; in-process reads still enforce deny. */
51
+ auth?: WebAuthenticationRule
52
+ }
53
+ ```
54
+
55
+ All `webserver/*` events use the corresponding WebServer as their dispatch subject, including `index-inject` and `entry-url`. Ordinary listeners match the emitter's `webServer` isolation; explicit `{ global: true }` listeners bypass that filter. Passing a Peer as event data does not select listeners. Custom carriers and application emitters must supply the WebServer subject.
56
+
57
+ Match order is exact, longest prefix, then the single-owner fallback; upgrades match exact paths. After matching, `auth` resolves to `anonymous`, `required` (default), or `deny`, either directly or through a synchronous request selector. `deny` returns 403 without an authorization event. Other policies emit synchronous `webserver/authorize`; the first decision wins. Without a decision, `anonymous` allows and `required` returns 503. Connection checks sources for both and calls ConnectionAuthentication only for authenticated routes. Anonymous assets are therefore credential-free, not exempt from active Connection source policy.
58
+
59
+ Handlers receive the admitted Peer as their trailing parameter; resources receive it through the existing `resource(request, peer?)` argument. Authenticated routes require a live Peer; anonymous routes may omit it. After admission, resources accept only GET/HEAD. Trusted `readResource(request, peer)` follows the same match order and reaches only resources, bypassing source and credential checks but still returning 403 for a resolved `deny`. The [frontend fallback](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/host/frontend-static/README.md) selects authenticated index access and anonymous static assets, then renders index startup data for the supplied Peer.
60
+
61
+ `webserver/request(request, response, next)` remains an HTTP waterfall before route selection and admission; a listener owns the response or awaits `next()`. The [Token plugin](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/host/authentication-token/README.md) uses it for root Token exchange and registers `/connect` with anonymous auth, verifying the launch token after Connection source checks. Page resources consume their admitted Peer without repeating authentication.
62
+
63
+ After successful upgrade admission, `webserver/upgrade(req, socket, head, peer, next)` runs before the registered protocol handler. It carries the admitted Peer, or `undefined` for anonymous access; denied requests never enter it. Listeners handle the Socket or await `next()`; the fallback awaits the route handler, including asynchronous completion. Middleware or handler failures are logged and destroy the Socket. On `/api/remote.mux`, Token applies single-Socket ownership and credential revocation only to API Peers in its own map; other Providers delegate without Token policy.
64
+
65
+ `webserver/entry-url(baseUrl, entries)` synchronously collects complete entry URLs for a supplied server base URL as `WebEntryUrl` records with `label`, complete `url`, and boolean `open`. WebApp emits it after Loader settlement and startup audit, prints each entry when configured, and opens only the first eligible entry outside SSH. An empty list produces neither output nor opening. Token contributes its signed URL without reading WebApp services; public-address configuration remains in WebApp.
66
+
67
+ <a id="config"></a>
68
+
69
+ ## Config
70
+
71
+ ```ts type-equiv
72
+ /** Web server listen, TLS, and response-compression config. */
73
+ interface Config {
74
+ /**
75
+ * Listen address: a concrete IPv4 or IPv6 literal of one local interface,
76
+ * for example the container's own Pod address from `hostname -i`. A loopback
77
+ * literal (any address in 127/8, `::1`, or a mapped form of either) keeps the
78
+ * server on this machine; any other literal serves the network that address
79
+ * belongs to, over plain HTTP unless `tls` is set. The unspecified address —
80
+ * IPv4 any, IPv6 any, and the IPv4-mapped forms of IPv4 any — is rejected at
81
+ * load: it would expose the port on every interface at once.
82
+ */
83
+ host: string
84
+ /** Listen port; zero requests an OS-assigned port. */
85
+ port: number
86
+ /**
87
+ * Serve HTTPS with this certificate and key instead of plain HTTP. Both files
88
+ * are read once, before the listener binds: an unreadable or empty file,
89
+ * invalid PEM, or a key that does not match the certificate rejects
90
+ * initialization rather than falling back to HTTP. The material is never
91
+ * re-read, so replacing a certificate takes a reload. Omitted or null listens
92
+ * over plain HTTP.
93
+ */
94
+ tls?: TlsConfig
95
+ /** Response compression for socket-backed HTTP requests. @default 'none' */
96
+ compression?: 'none' | 'gzip'
97
+ /** Gzip DEFLATE level from 0 through 9. @default 1 */
98
+ compressionLevel?: number
99
+ /** Minimum known response length eligible for gzip; unknown-length streams are eligible. @default 1024 */
100
+ compressionThresholdBytes?: number
101
+ }
102
+ ```
103
+
104
+ ```ts type-equiv
105
+ /**
106
+ * TLS material for the HTTPS listener: one certificate chain file and the
107
+ * private key file it pairs with. Both hold PEM text and both resolve against
108
+ * the process working directory.
109
+ */
110
+ interface TlsConfig {
111
+ /** Certificate chain file, leaf certificate first, PEM, no passphrase. */
112
+ certFile: string
113
+ /** Private key file for the chain's leaf certificate; unencrypted PEM. */
114
+ keyFile: string
115
+ }
116
+ ```
117
+
118
+ No composition can bind every interface at once: the unspecified address is rejected at load. The exported `isWildcardHost` and `isLoopbackHost` classify a bind address from its parsed value, and an IPv6 `%zone` is kept for `listen` while classification reads the address alone. The carrier enforces route auth declarations; Connection owns source checks and ConnectionAuthentication owns credential verification. It serves plain HTTP unless `tls` supplies a certificate and key. `compression` defaults to `none`; the shipped Web bundle selects gzip level 1 with a 1024-byte threshold. The shipped `dsh web` command selects loopback by default and accepts one concrete `--host` address, warning at startup when a non-loopback bind serves plain HTTP; its Connection plugin checks Host/Origin on matched anonymous and authenticated routes and verifies credentials where authentication is required, and the bind address plus `--trusted-host` govern which browser Host is accepted; `--public-url` changes only the advertised URL. Other compositions own their bind and route-authentication policy. The dist location is an assembly fact of the frontend plugin that claims the seat.
119
+
120
+ ## The service
121
+
122
+ The nested `connection.authentication` service selects a Peer through registered Providers; Connection applies source policy and WebServer passes the selected Peer to each call. The [Token plugin](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/host/authentication-token/README.md) contributes its signed login URL; WebApp owns startup printing and browser opening. [Desktop](https://github.com/deepseek-ai/deepseek-harness/blob/master/apps/desktop/README.md#application-overview) registers a separate Provider using a credential delivered over its private parent–Host IPC channel; its ready message carries the ordinary Host address and startup injections.
123
+
124
+ `WebServer` (`ctx.webServer`) listens immediately on activation; a listen failure (EADDRINUSE…) rejects initialization, and the boot process reports the failed fiber. The `tls` pair is read once before the listener binds, and an unreadable, empty, or mismatched pair rejects initialization the same way instead of falling back to HTTP. `register(route)` adds one named route and returns its disposer; a duplicate `(kind, path)` throws because route patterns are a composition-level contract and a collision is a misconfiguration. Gzip wraps eligible socket-backed responses inside the server, so handlers keep direct `ServerResponse` ownership, and a resource hands the service a `Response` to write back. Existing content encodings, `Cache-Control: no-transform`, ranges, SSE, ZIP, and the packaged `.gz` Worker image remain identity responses. `collectIndexInjections(peer)` gathers structured `IndexInjection` rows over one `webserver/index-inject` emit that passes the Peer the page speaks for, and `renderIndex(html, peer)` renders them into successful root and configured index responses before applying the raw `tapIndex(transform)` escape-hatch transforms in registration order; [dsh-client-modules](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/client/modules) answers the event with the boot manifest rows. `port` reads the listening port, including the port assigned by the OS when `config.port` is 0, and `protocol` reports the scheme the listener serves (`http:` or `https:`).
125
+
126
+ A request whose handling throws (a malformed %-escape hitting `decodeURIComponent`, a client dropping mid-body) is logged as a warning and answered 400 — or the socket destroyed when headers are already out — never a process exit. Disposal pairs `close()` with `closeAllConnections()` because a handler may hold its response open (SSE) and such connections never end on their own; without the force-close, teardown would hang. A TLS socket counts as a connection only after its handshake, so the server tracks raw TLS sockets beside upgraded ones and destroys both at disposal. WebApp owns entry-URL printing and browser opening; this server owns HTTP delivery. Per-package operational detail, including the dev-mode bundle watch pipeline, stays in the [README](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/host/webserver/README.md).
127
+
128
+ <!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
129
+
130
+ <a id="cordis-surface"></a>
131
+
132
+ ## Cordis API
133
+
134
+ Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnpm run verify-cordis-catalog` in doc-sync; regenerate with `pnpm run gen-cordis-catalog`) — the language sides differ only in locale-specific paired document paths. Signature blocks use a `ts cordis-catalog` fence and keep the original source JSDoc; dispatch modes are defined in the [primer](../cordis-primer.md#dispatch-modes), and the framework-inherited `ctx` API lives in [cordis-api/inherited.md](../cordis-api/inherited.md).
135
+
136
+ <a id="ctxconnection--hostconnectionhandle"></a>
137
+
138
+ ### `ctx.connection` — `HostConnectionHandle`
139
+
140
+ Host `ctx.connection` members consumed by transport-independent adapters.
141
+
142
+ ```ts cordis-catalog
143
+ /**
144
+ * Compose exact Fetch routes and the shared-channel RPC interceptor.
145
+ * @param channel - shared channel mounted by Connection.
146
+ * @returns Fetch handler for trusted, authenticated requests.
147
+ */
148
+ createSharedFetchHandler(channel: '/api'): ConnectionFetchHandler
149
+
150
+ /**
151
+ * Apply Host/Origin checks and admit the first live Peer returned by a registered credential verifier.
152
+ * @param request - request headers from the HTTP or upgrade request.
153
+ * @returns the credential's Peer, or the rejection status.
154
+ */
155
+ admit(request: ConnectionTrustRequest): PeerAdmission
156
+
157
+ /**
158
+ * Create an independent in-process Peer, disposed with the Context that read `ctx.connection`.
159
+ * @param options - fixed principal and interaction participation (default answer).
160
+ * @returns a new Peer distinct from every other Peer.
161
+ */
162
+ createPeer(options: { readonly principal: Principal; readonly interactions?: 'answer' | 'none' }): PeerScope
163
+ ```
164
+
165
+ Types: [Principal](./typert.md)
166
+
167
+ Source: [`packages/client/connection/src/rpc.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/client/connection/src/rpc.ts)
168
+
169
+ <a id="ctxconnectionauthentication--connectionauthentication"></a>
170
+
171
+ ### `ctx.connection.authentication` — `ConnectionAuthentication`
172
+
173
+ Credential verifier registry whose registrations belong to the calling plugin.
174
+
175
+ ```ts cordis-catalog
176
+ /**
177
+ * Add a credential verifier after the existing registrations.
178
+ * @param provider - verifier owning its credential and Peer selection.
179
+ * @returns disposer withdrawing this registration; the calling scope also withdraws it on unload.
180
+ */
181
+ register(provider: AuthenticationProvider): () => Promise<void>
182
+
183
+ /**
184
+ * Verify credentials without applying an HTTP response or source policy.
185
+ * @param request - current carrier headers and cancellation facts.
186
+ * @returns the first live Peer, 401 if no provider accepts, or 503 when verification failed without success.
187
+ */
188
+ authenticate(request: ConnectionTrustRequest): PeerAdmission
189
+ ```
190
+
191
+ Types: [AuthenticationProvider](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/client/connection/README.md#browser-authentication-and-request-trust)
192
+
193
+ Source: [`packages/client/connection/src/authentication.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/client/connection/src/authentication.ts)
194
+
195
+ <a id="ctxwebapp--webapp"></a>
196
+
197
+ ### `ctx.webApp` — `WebApp`
198
+
199
+ The Web GUI this process serves, provided by the `web-runtime` row.
200
+
201
+ ```ts cordis-catalog
202
+ /**
203
+ * The URL this GUI advertises, also used for `DSH_WEB_URL` and the startup URL line.
204
+ * @returns the configured `publicUrl`, otherwise the listener origin.
205
+ */
206
+ getAdvertisedUrl(): string
207
+ ```
208
+
209
+ Source: [`packages/bundle/web-app/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/bundle/web-app/src/index.ts)
210
+
211
+ <a id="ctxwebserver--webserver"></a>
212
+
213
+ ### `ctx.webServer` — `WebServer`
214
+
215
+ The browser HTTP carrier service. Activation loads any configured TLS material, then listens immediately; a material or listen failure rejects initialization, and the boot process reports the failed fiber. Route registration order does not affect requests because configured named routes must be distinct, and a request no named route matches is answered 404 until the fallback owner registers. HTTP and upgrade admission refusals carry `Cache-Control: no-store`.
216
+
217
+ ```ts cordis-catalog
218
+ /**
219
+ * The root URL local clients use to reach the bound listener: the protocol,
220
+ * the {@link bindUrlHost} form of the bind address, and the listening port.
221
+ * @returns the origin, for example `http://127.0.0.1:3080`.
222
+ * @throws before `listen` binds a port, or when the bind address has no URL form.
223
+ */
224
+ getOrigin(): string
225
+
226
+ /**
227
+ * Register a named route. Duplicate (kind, path) throws — route patterns are
228
+ * a composition-level contract, so a collision is a misconfiguration.
229
+ * @param route - kind, path, and the owning handler or resource.
230
+ * @returns the disposer removing the route.
231
+ */
232
+ register(route: WebRoute | WebResourceRoute): () => void
233
+
234
+ /**
235
+ * Register an exact-path HTTP upgrade route. Duplicate paths throw because
236
+ * one socket can have only one protocol owner.
237
+ * @param route - pathname and handler owning negotiation plus socket use.
238
+ * @returns the disposer removing the route.
239
+ */
240
+ registerUpgrade(route: WebUpgradeRoute): () => void
241
+
242
+ /**
243
+ * Claim the fallback seat: the handler or resource answering every request
244
+ * no named route matches (the SPA dist server in the shipped Web
245
+ * composition). One owner only — a second registration throws, because two
246
+ * fallbacks cannot compose.
247
+ * @param fallback - a handler owning the full response lifecycle of
248
+ * unmatched requests, or an object declaring `handler` or `resource` and auth.
249
+ * @returns the disposer releasing the seat.
250
+ */
251
+ registerFallback(fallback: WebRoute['handler'] | WebFallback): () => void
252
+
253
+ /**
254
+ * Read the response an HTTP request for the same URL would receive, as the
255
+ * resource computes it for `peer`, without an HTTP exchange. The request
256
+ * path picks the responder by the HTTP match order — exact, longest prefix,
257
+ * then the fallback — and only a resource answers. This method checks no
258
+ * cookie, Host, or Origin: the caller admits the reader before reading.
259
+ * A resolved deny policy returns 403 even for an explicitly admitted Peer.
260
+ * @param request - the read; its URL path selects the responder.
261
+ * @param peer - the Peer the read speaks for, passed to the resource.
262
+ * @returns the resource's response, without a body for HEAD as over HTTP;
263
+ * 405 with `Allow: GET, HEAD` for any other method, checked before matching,
264
+ * where over HTTP a handler route or an unmatched path answers such a
265
+ * method itself; 404 when the path matches a handler route, or reaches the
266
+ * fallback seat while it is unclaimed or holds a handler. A resource that
267
+ * throws rejects the read, where an HTTP request would receive 400.
268
+ */
269
+ async readResource(request: Request, peer: PeerScope): Promise<Response>
270
+
271
+ /**
272
+ * Register a raw-HTML index transform, the escape hatch for markup no
273
+ * {@link IndexInjection} row expresses: {@link renderIndex} applies taps in
274
+ * registration order after rendering the structured rows.
275
+ * @param transform - pure html-to-html function.
276
+ * @returns the disposer removing the transform.
277
+ */
278
+ tapIndex(transform: (html: string) => string): () => void
279
+
280
+ /**
281
+ * Run an index.html body through the registered taps in registration order
282
+ * — called by the fallback owner on every index response it renders.
283
+ * @param html - the raw index.html body.
284
+ * @returns the transformed body.
285
+ */
286
+ applyIndexTaps(html: string): string
287
+
288
+ /**
289
+ * Gather the structured injection table for one Peer: one
290
+ * `webserver/index-inject` emit, every subscriber pushes its current rows.
291
+ * Fresh per call, so subscribers read live state (module graph, theme
292
+ * preference, the Peer's access) at emit time.
293
+ * @param peer - the Peer the page speaks for.
294
+ * @returns rows in subscriber activation order.
295
+ */
296
+ collectIndexInjections(peer: PeerScope): IndexInjection[]
297
+
298
+ /**
299
+ * Render one index.html body for one Peer: the structured injection table
300
+ * first, then the raw `tapIndex` transforms over the result.
301
+ * @param html - the raw index.html body.
302
+ * @param peer - the Peer the page speaks for.
303
+ * @returns the transformed body.
304
+ */
305
+ renderIndex(html: string, peer: PeerScope): string
306
+ ```
307
+
308
+ Source: [`packages/host/webserver/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/host/webserver/src/index.ts)
309
+
310
+ <a id="connection-events"></a>
311
+
312
+ ### `connection/*` events
313
+
314
+ <a id="connectionrequest--waterfall"></a>
315
+
316
+ #### `connection/request` — waterfall
317
+
318
+ Admit or wrap an authenticated shared API request, including body transfer. Existing requests continue when a listener refuses subsequent requests.
319
+
320
+ ```ts cordis-catalog
321
+ /**
322
+ * Admit or wrap an authenticated shared API request, including body transfer.
323
+ * Existing requests continue when a listener refuses subsequent requests.
324
+ * @param request - Authenticated incoming HTTP request.
325
+ * @param response - Response owned until the delegated bridge settles.
326
+ * @param next - Delegate to the next listener or the shared API bridge.
327
+ * @mode waterfall
328
+ */
329
+ 'connection/request'(request: IncomingMessage, response: ServerResponse, next: () => Promise<void>): Promise<void>
330
+ ```
331
+
332
+ Source: [`packages/client/connection/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/client/connection/src/index.ts)
333
+
334
+ <a id="webserver-events"></a>
335
+
336
+ ### `webserver/*` events
337
+
338
+ <a id="webserverauthorize--bail"></a>
339
+
340
+ #### `webserver/authorize` — bail
341
+
342
+ Admit a matched request synchronously; the first decision wins.
343
+
344
+ ```ts cordis-catalog
345
+ /**
346
+ * Admit a matched request synchronously; the first decision wins.
347
+ * @param request - headers, target, transport, and available cancellation state.
348
+ * @param policy - resolved route policy; deny never emits this event.
349
+ * @mode bail
350
+ */
351
+ 'webserver/authorize'(request: WebAuthRequest, policy: WebAuthPolicy): WebAdmission | undefined
352
+ ```
353
+
354
+ Source: [`packages/host/webserver/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/host/webserver/src/index.ts)
355
+
356
+ <a id="webserverentry-url--emit"></a>
357
+
358
+ #### `webserver/entry-url` — emit
359
+
360
+ Collect complete entry URLs for an advertised server address.
361
+
362
+ ```ts cordis-catalog
363
+ /**
364
+ * Collect complete entry URLs for an advertised server address.
365
+ * @param baseUrl - advertised server base URL without provider credentials.
366
+ * @param entries - entries appended synchronously in listener order.
367
+ * @mode emit
368
+ */
369
+ 'webserver/entry-url'(baseUrl: string, entries: WebEntryUrl[]): void
370
+ ```
371
+
372
+ Source: [`packages/host/webserver/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/host/webserver/src/index.ts)
373
+
374
+ <a id="webserverindex-inject--emit"></a>
375
+
376
+ #### `webserver/index-inject` — emit
377
+
378
+ Collect the structured index injection table for the page `peer` speaks for. Emitted on every index render and every worker boot-payload request; listeners push their current rows, so a row's data is read fresh at emit time.
379
+
380
+ ```ts cordis-catalog
381
+ /**
382
+ * Collect the structured index injection table for the page `peer` speaks
383
+ * for. Emitted on every index render and every worker boot-payload
384
+ * request; listeners push their current rows, so a row's data is read
385
+ * fresh at emit time.
386
+ * @param table - Mutable row table; listeners append in activation order.
387
+ * @param peer - The Peer the rendered page speaks for.
388
+ * @mode emit
389
+ */
390
+ 'webserver/index-inject'(table: IndexInjection[], peer: PeerScope): void
391
+ ```
392
+
393
+ Source: [`packages/host/webserver/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/host/webserver/src/index.ts)
394
+
395
+ <a id="webserverrequest--waterfall"></a>
396
+
397
+ #### `webserver/request` — waterfall
398
+
399
+ Handle an HTTP request before named-route and fallback dispatch.
400
+
401
+ ```ts cordis-catalog
402
+ /**
403
+ * Handle an HTTP request before named-route and fallback dispatch.
404
+ * @param request - original incoming HTTP request.
405
+ * @param response - response owned by the listener or its delegated handler.
406
+ * @param next - dispatch to the next listener or the matching route.
407
+ * @mode waterfall
408
+ */
409
+ 'webserver/request'(request: IncomingMessage, response: ServerResponse, next: () => Promise<void>): Promise<void>
410
+ ```
411
+
412
+ Source: [`packages/host/webserver/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/host/webserver/src/index.ts)
413
+
414
+ <a id="webserverupgrade--waterfall"></a>
415
+
416
+ #### `webserver/upgrade` — waterfall
417
+
418
+ Handle an admitted upgrade before its registered protocol handler.
419
+
420
+ ```ts cordis-catalog
421
+ /**
422
+ * Handle an admitted upgrade before its registered protocol handler.
423
+ * @param request - original upgrade request.
424
+ * @param socket - transport owned by the upgrade.
425
+ * @param head - bytes received after the HTTP headers.
426
+ * @param peer - authenticated identity, absent for anonymous admission.
427
+ * @param next - delegate to the next listener or protocol handler.
428
+ * @mode waterfall
429
+ */
430
+ 'webserver/upgrade'( request: IncomingMessage, socket: Duplex, head: Buffer, peer: PeerScope | undefined, next: () => Promise<void>, ): Promise<void>
431
+ ```
432
+
433
+ Source: [`packages/host/webserver/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/host/webserver/src/index.ts)
434
+ <!-- END GENERATED cordis-surface -->