@songsid/agend 2.3.5-beta.5 → 2.4.0-alpha.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 (1502) hide show
  1. package/README.md +2 -0
  2. package/README.zh-TW.md +2 -0
  3. package/THIRD_PARTY_NOTICES.md +71 -0
  4. package/dist/accounts-profiles.d.ts +102 -0
  5. package/dist/accounts-profiles.js +194 -0
  6. package/dist/accounts-profiles.js.map +1 -0
  7. package/dist/accounts-signout.d.ts +59 -0
  8. package/dist/accounts-signout.js +181 -0
  9. package/dist/accounts-signout.js.map +1 -0
  10. package/dist/accounts-view.d.ts +189 -0
  11. package/dist/accounts-view.js +204 -0
  12. package/dist/accounts-view.js.map +1 -0
  13. package/dist/agent-endpoint.d.ts +5 -1
  14. package/dist/agent-endpoint.js +12 -2
  15. package/dist/agent-endpoint.js.map +1 -1
  16. package/dist/agent-export.d.ts +74 -0
  17. package/dist/agent-export.js +362 -0
  18. package/dist/agent-export.js.map +1 -0
  19. package/dist/agent-file-read.js +1 -1
  20. package/dist/agent-file-read.js.map +1 -1
  21. package/dist/agent-runtime-api.d.ts +4 -0
  22. package/dist/agent-runtime-api.js +59 -0
  23. package/dist/agent-runtime-api.js.map +1 -0
  24. package/dist/agent-runtime-change.d.ts +76 -0
  25. package/dist/agent-runtime-change.js +114 -0
  26. package/dist/agent-runtime-change.js.map +1 -0
  27. package/dist/agent-whats-new.js +10 -3
  28. package/dist/agent-whats-new.js.map +1 -1
  29. package/dist/agent-workspace.d.ts +103 -0
  30. package/dist/agent-workspace.js +360 -0
  31. package/dist/agent-workspace.js.map +1 -0
  32. package/dist/apply-job.d.ts +5 -0
  33. package/dist/apply-job.js +10 -3
  34. package/dist/apply-job.js.map +1 -1
  35. package/dist/auth-api.d.ts +78 -0
  36. package/dist/auth-api.js +350 -16
  37. package/dist/auth-api.js.map +1 -1
  38. package/dist/authority/company-join.d.ts +16 -0
  39. package/dist/authority/company-join.js +37 -0
  40. package/dist/authority/company-join.js.map +1 -0
  41. package/dist/authority/hub-initialization.d.ts +13 -0
  42. package/dist/authority/hub-initialization.js +30 -0
  43. package/dist/authority/hub-initialization.js.map +1 -0
  44. package/dist/authority/settings-role.d.ts +56 -0
  45. package/dist/authority/settings-role.js +48 -0
  46. package/dist/authority/settings-role.js.map +1 -0
  47. package/dist/authority/web-authority.d.ts +25 -2
  48. package/dist/authority/web-authority.js +37 -4
  49. package/dist/authority/web-authority.js.map +1 -1
  50. package/dist/backend/claude-code.d.ts +19 -16
  51. package/dist/backend/claude-code.js +179 -144
  52. package/dist/backend/claude-code.js.map +1 -1
  53. package/dist/backend/claude-context.d.ts +17 -0
  54. package/dist/backend/claude-context.js +30 -0
  55. package/dist/backend/claude-context.js.map +1 -0
  56. package/dist/backend/codex-footer-hints.d.ts +3 -0
  57. package/dist/backend/codex-footer-hints.js +14 -0
  58. package/dist/backend/codex-footer-hints.js.map +1 -1
  59. package/dist/backend/codex-package.d.ts +5 -2
  60. package/dist/backend/codex-package.js +1 -5
  61. package/dist/backend/codex-package.js.map +1 -1
  62. package/dist/backend/codex-quota-history.js +4 -19
  63. package/dist/backend/codex-quota-history.js.map +1 -1
  64. package/dist/backend/codex.d.ts +149 -129
  65. package/dist/backend/codex.js +1323 -1233
  66. package/dist/backend/codex.js.map +1 -1
  67. package/dist/backend/credential-profile.d.ts +21 -0
  68. package/dist/backend/credential-profile.js +48 -1
  69. package/dist/backend/credential-profile.js.map +1 -1
  70. package/dist/backend/effort-metadata.d.ts +38 -2
  71. package/dist/backend/effort-metadata.js +145 -8
  72. package/dist/backend/effort-metadata.js.map +1 -1
  73. package/dist/backend/grok-mcp.d.ts +5 -0
  74. package/dist/backend/grok-mcp.js +221 -0
  75. package/dist/backend/grok-mcp.js.map +1 -0
  76. package/dist/backend/grok-model-cache.d.ts +7 -0
  77. package/dist/backend/grok-model-cache.js +65 -0
  78. package/dist/backend/grok-model-cache.js.map +1 -0
  79. package/dist/backend/grok.d.ts +7 -10
  80. package/dist/backend/grok.js +44 -88
  81. package/dist/backend/grok.js.map +1 -1
  82. package/dist/backend/kiro.js +1 -1
  83. package/dist/backend/kiro.js.map +1 -1
  84. package/dist/backend/launch-effort.d.ts +1 -1
  85. package/dist/backend/launch-effort.js +7 -3
  86. package/dist/backend/launch-effort.js.map +1 -1
  87. package/dist/backend/native-pane.d.ts +11 -0
  88. package/dist/backend/native-pane.js +59 -0
  89. package/dist/backend/native-pane.js.map +1 -0
  90. package/dist/backend/types.d.ts +20 -1
  91. package/dist/backend/types.js.map +1 -1
  92. package/dist/backend-availability.d.ts +15 -0
  93. package/dist/backend-availability.js +37 -1
  94. package/dist/backend-availability.js.map +1 -1
  95. package/dist/backend-signin-pending.d.ts +8 -2
  96. package/dist/backend-signin-pending.js +6 -2
  97. package/dist/backend-signin-pending.js.map +1 -1
  98. package/dist/browser-backend-signins.d.ts +2 -1
  99. package/dist/browser-backend-signins.js +1 -1
  100. package/dist/browser-backend-signins.js.map +1 -1
  101. package/dist/build-provenance-cli.d.ts +3 -0
  102. package/dist/build-provenance-cli.js +11 -0
  103. package/dist/build-provenance-cli.js.map +1 -0
  104. package/dist/build-provenance.d.ts +20 -0
  105. package/dist/build-provenance.js +67 -0
  106. package/dist/build-provenance.js.map +1 -0
  107. package/dist/build-provenance.json +1 -0
  108. package/dist/bundled-tmux-guard.d.ts +0 -2
  109. package/dist/bundled-tmux-guard.js +10 -23
  110. package/dist/bundled-tmux-guard.js.map +1 -1
  111. package/dist/channel/ipc-bridge.d.ts +2 -0
  112. package/dist/channel/mcp-tools.js +4 -4
  113. package/dist/channel/mcp-tools.js.map +1 -1
  114. package/dist/classic-bindings.d.ts +13 -0
  115. package/dist/classic-bindings.js +28 -2
  116. package/dist/classic-bindings.js.map +1 -1
  117. package/dist/claude-auth-status.d.ts +60 -0
  118. package/dist/claude-auth-status.js +165 -0
  119. package/dist/claude-auth-status.js.map +1 -0
  120. package/dist/cli-audited.d.ts +60 -0
  121. package/dist/cli-audited.js +84 -0
  122. package/dist/cli-audited.js.map +1 -0
  123. package/dist/cli-capability.d.ts +217 -0
  124. package/dist/cli-capability.js +55 -0
  125. package/dist/cli-capability.js.map +1 -0
  126. package/dist/cli-caps-module.d.ts +33 -0
  127. package/dist/cli-caps-module.js +45 -0
  128. package/dist/cli-caps-module.js.map +1 -0
  129. package/dist/cli-registry-check.d.ts +28 -0
  130. package/dist/cli-registry-check.js +237 -0
  131. package/dist/cli-registry-check.js.map +1 -0
  132. package/dist/cli-registry.d.ts +578 -0
  133. package/dist/cli-registry.js +83 -0
  134. package/dist/cli-registry.js.map +1 -0
  135. package/dist/cli-spec-antigravity.d.ts +71 -0
  136. package/dist/cli-spec-antigravity.js +47 -0
  137. package/dist/cli-spec-antigravity.js.map +1 -0
  138. package/dist/cli-spec-claude-code.d.ts +93 -0
  139. package/dist/cli-spec-claude-code.js +37 -0
  140. package/dist/cli-spec-claude-code.js.map +1 -0
  141. package/dist/cli-spec-codex.d.ts +87 -0
  142. package/dist/cli-spec-codex.js +40 -0
  143. package/dist/cli-spec-codex.js.map +1 -0
  144. package/dist/cli-spec-grok.d.ts +64 -0
  145. package/dist/cli-spec-grok.js +40 -0
  146. package/dist/cli-spec-grok.js.map +1 -0
  147. package/dist/cli-spec-kiro-cli.d.ts +79 -0
  148. package/dist/cli-spec-kiro-cli.js +40 -0
  149. package/dist/cli-spec-kiro-cli.js.map +1 -0
  150. package/dist/cli-spec-muse.d.ts +54 -0
  151. package/dist/cli-spec-muse.js +40 -0
  152. package/dist/cli-spec-muse.js.map +1 -0
  153. package/dist/cli-spec-opencode.d.ts +60 -0
  154. package/dist/cli-spec-opencode.js +42 -0
  155. package/dist/cli-spec-opencode.js.map +1 -0
  156. package/dist/cli.js +311 -54
  157. package/dist/cli.js.map +1 -1
  158. package/dist/codex-pane-ownership.d.ts +13 -0
  159. package/dist/codex-pane-ownership.js +192 -0
  160. package/dist/codex-pane-ownership.js.map +1 -0
  161. package/dist/config-validator.js +93 -2
  162. package/dist/config-validator.js.map +1 -1
  163. package/dist/config.js +16 -0
  164. package/dist/config.js.map +1 -1
  165. package/dist/create-host-account.d.ts +17 -0
  166. package/dist/create-host-account.js +47 -0
  167. package/dist/create-host-account.js.map +1 -0
  168. package/dist/daemon.d.ts +101 -7
  169. package/dist/daemon.js +1058 -282
  170. package/dist/daemon.js.map +1 -1
  171. package/dist/delivery-consumed-watch.d.ts +15 -3
  172. package/dist/delivery-consumed-watch.js +23 -1
  173. package/dist/delivery-consumed-watch.js.map +1 -1
  174. package/dist/delivery-outbox.d.ts +9 -0
  175. package/dist/delivery-outbox.js +43 -4
  176. package/dist/delivery-outbox.js.map +1 -1
  177. package/dist/delivery-reconciliation.d.ts +2 -42
  178. package/dist/delivery-reconciliation.js +2 -164
  179. package/dist/delivery-reconciliation.js.map +1 -1
  180. package/dist/dispatcher-liveness.d.ts +172 -0
  181. package/dist/dispatcher-liveness.js +238 -0
  182. package/dist/dispatcher-liveness.js.map +1 -0
  183. package/dist/doctor.js +19 -9
  184. package/dist/doctor.js.map +1 -1
  185. package/dist/e2e-isolation.js +5 -2
  186. package/dist/e2e-isolation.js.map +1 -1
  187. package/dist/fleet-context.d.ts +7 -3
  188. package/dist/fleet-control-audit.d.ts +1 -1
  189. package/dist/fleet-level-config.d.ts +1 -1
  190. package/dist/fleet-level-config.js +2 -0
  191. package/dist/fleet-level-config.js.map +1 -1
  192. package/dist/fleet-manager.d.ts +1079 -29
  193. package/dist/fleet-manager.js +5564 -420
  194. package/dist/fleet-manager.js.map +1 -1
  195. package/dist/fleet-windows-runtime.d.ts +98 -0
  196. package/dist/fleet-windows-runtime.js +467 -0
  197. package/dist/fleet-windows-runtime.js.map +1 -0
  198. package/dist/general-binding.d.ts +85 -0
  199. package/dist/general-binding.js +298 -0
  200. package/dist/general-binding.js.map +1 -0
  201. package/dist/general-host-owner.d.ts +8 -0
  202. package/dist/general-host-owner.js +26 -0
  203. package/dist/general-host-owner.js.map +1 -0
  204. package/dist/general-instance.d.ts +7 -0
  205. package/dist/general-instance.js +20 -3
  206. package/dist/general-instance.js.map +1 -1
  207. package/dist/general-knowledge/skills/concepts/SKILL.md +75 -23
  208. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +23 -9
  209. package/dist/general-knowledge/skills/fleet-config/SKILL.md +1 -1
  210. package/dist/general-knowledge/skills/fleet-health/SKILL.md +2 -2
  211. package/dist/general-knowledge/skills/fleet-restart/SKILL.md +1 -1
  212. package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +1 -1
  213. package/dist/general-knowledge/skills/session-management/SKILL.md +1 -1
  214. package/dist/general-knowledge/skills/tui-effort/SKILL.md +10 -10
  215. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +48 -26
  216. package/dist/general-knowledge/steering/core-rules.md +2 -2
  217. package/dist/general-role.d.ts +5 -0
  218. package/dist/general-role.js +27 -0
  219. package/dist/general-role.js.map +1 -0
  220. package/dist/hub/admission.d.ts +28 -0
  221. package/dist/hub/admission.js +62 -0
  222. package/dist/hub/admission.js.map +1 -0
  223. package/dist/hub/attachments/limits.d.ts +20 -0
  224. package/dist/hub/attachments/limits.js +48 -0
  225. package/dist/hub/attachments/limits.js.map +1 -0
  226. package/dist/hub/attachments/store.d.ts +116 -0
  227. package/dist/hub/attachments/store.js +246 -0
  228. package/dist/hub/attachments/store.js.map +1 -0
  229. package/dist/hub/audit/index.d.ts +62 -0
  230. package/dist/hub/audit/index.js +344 -0
  231. package/dist/hub/audit/index.js.map +1 -0
  232. package/dist/hub/browser-certificate.d.ts +38 -0
  233. package/dist/hub/browser-certificate.js +247 -0
  234. package/dist/hub/browser-certificate.js.map +1 -0
  235. package/dist/hub/buttons-model.d.ts +9 -0
  236. package/dist/hub/buttons-model.js +42 -0
  237. package/dist/hub/buttons-model.js.map +1 -0
  238. package/dist/hub/buttons.d.ts +54 -0
  239. package/dist/hub/buttons.js +348 -0
  240. package/dist/hub/buttons.js.map +1 -0
  241. package/dist/hub/catalog.d.ts +74 -0
  242. package/dist/hub/catalog.js +380 -0
  243. package/dist/hub/catalog.js.map +1 -0
  244. package/dist/hub/client.d.ts +71 -0
  245. package/dist/hub/client.js +333 -0
  246. package/dist/hub/client.js.map +1 -0
  247. package/dist/hub/compose/member.d.ts +145 -0
  248. package/dist/hub/compose/member.js +467 -0
  249. package/dist/hub/compose/member.js.map +1 -0
  250. package/dist/hub/compose/server.d.ts +170 -0
  251. package/dist/hub/compose/server.js +494 -0
  252. package/dist/hub/compose/server.js.map +1 -0
  253. package/dist/hub/compose/storage.d.ts +5 -0
  254. package/dist/hub/compose/storage.js +28 -0
  255. package/dist/hub/compose/storage.js.map +1 -0
  256. package/dist/hub/compose/views.d.ts +12 -0
  257. package/dist/hub/compose/views.js +4 -0
  258. package/dist/hub/compose/views.js.map +1 -0
  259. package/dist/hub/db.d.ts +58 -0
  260. package/dist/hub/db.js +215 -0
  261. package/dist/hub/db.js.map +1 -0
  262. package/dist/hub/directory/config.d.ts +39 -0
  263. package/dist/hub/directory/config.js +108 -0
  264. package/dist/hub/directory/config.js.map +1 -0
  265. package/dist/hub/directory/directory.d.ts +25 -0
  266. package/dist/hub/directory/directory.js +588 -0
  267. package/dist/hub/directory/directory.js.map +1 -0
  268. package/dist/hub/directory/groups.d.ts +55 -0
  269. package/dist/hub/directory/groups.js +30 -0
  270. package/dist/hub/directory/groups.js.map +1 -0
  271. package/dist/hub/directory/index.d.ts +8 -0
  272. package/dist/hub/directory/index.js +4 -0
  273. package/dist/hub/directory/index.js.map +1 -0
  274. package/dist/hub/directory/profiles.d.ts +41 -0
  275. package/dist/hub/directory/profiles.js +90 -0
  276. package/dist/hub/directory/profiles.js.map +1 -0
  277. package/dist/hub/directory/types.d.ts +84 -0
  278. package/dist/hub/directory/types.js +14 -0
  279. package/dist/hub/directory/types.js.map +1 -0
  280. package/dist/hub/directory-response-owner.d.ts +38 -0
  281. package/dist/hub/directory-response-owner.js +191 -0
  282. package/dist/hub/directory-response-owner.js.map +1 -0
  283. package/dist/hub/enrollment-budget.d.ts +6 -0
  284. package/dist/hub/enrollment-budget.js +24 -0
  285. package/dist/hub/enrollment-budget.js.map +1 -0
  286. package/dist/hub/execution/cli-provider.d.ts +23 -0
  287. package/dist/hub/execution/cli-provider.js +341 -0
  288. package/dist/hub/execution/cli-provider.js.map +1 -0
  289. package/dist/hub/execution/index.d.ts +13 -0
  290. package/dist/hub/execution/index.js +8 -0
  291. package/dist/hub/execution/index.js.map +1 -0
  292. package/dist/hub/execution/model-broker.d.ts +24 -0
  293. package/dist/hub/execution/model-broker.js +208 -0
  294. package/dist/hub/execution/model-broker.js.map +1 -0
  295. package/dist/hub/execution/provider-setup.d.ts +11 -0
  296. package/dist/hub/execution/provider-setup.js +21 -0
  297. package/dist/hub/execution/provider-setup.js.map +1 -0
  298. package/dist/hub/execution/sandbox-runner.d.ts +1 -0
  299. package/dist/hub/execution/sandbox-runner.js +221 -0
  300. package/dist/hub/execution/sandbox-runner.js.map +1 -0
  301. package/dist/hub/execution/service.d.ts +136 -0
  302. package/dist/hub/execution/service.js +459 -0
  303. package/dist/hub/execution/service.js.map +1 -0
  304. package/dist/hub/execution/store.d.ts +61 -0
  305. package/dist/hub/execution/store.js +182 -0
  306. package/dist/hub/execution/store.js.map +1 -0
  307. package/dist/hub/execution/views.d.ts +20 -0
  308. package/dist/hub/execution/views.js +48 -0
  309. package/dist/hub/execution/views.js.map +1 -0
  310. package/dist/hub/fleet-revocation.d.ts +3 -0
  311. package/dist/hub/fleet-revocation.js +7 -0
  312. package/dist/hub/fleet-revocation.js.map +1 -0
  313. package/dist/hub/group-policy/admin-api.d.ts +30 -0
  314. package/dist/hub/group-policy/admin-api.js +92 -0
  315. package/dist/hub/group-policy/admin-api.js.map +1 -0
  316. package/dist/hub/group-policy/admin-context.d.ts +23 -0
  317. package/dist/hub/group-policy/admin-context.js +52 -0
  318. package/dist/hub/group-policy/admin-context.js.map +1 -0
  319. package/dist/hub/group-policy/admin-control.d.ts +35 -0
  320. package/dist/hub/group-policy/admin-control.js +260 -0
  321. package/dist/hub/group-policy/admin-control.js.map +1 -0
  322. package/dist/hub/group-policy/admin-dto.d.ts +259 -0
  323. package/dist/hub/group-policy/admin-dto.js +57 -0
  324. package/dist/hub/group-policy/admin-dto.js.map +1 -0
  325. package/dist/hub/group-policy/admin-facts.d.ts +17 -0
  326. package/dist/hub/group-policy/admin-facts.js +33 -0
  327. package/dist/hub/group-policy/admin-facts.js.map +1 -0
  328. package/dist/hub/group-policy/admin-impact.d.ts +51 -0
  329. package/dist/hub/group-policy/admin-impact.js +88 -0
  330. package/dist/hub/group-policy/admin-impact.js.map +1 -0
  331. package/dist/hub/group-policy/admin-inventory.d.ts +24 -0
  332. package/dist/hub/group-policy/admin-inventory.js +72 -0
  333. package/dist/hub/group-policy/admin-inventory.js.map +1 -0
  334. package/dist/hub/group-policy/admin-read.d.ts +21 -0
  335. package/dist/hub/group-policy/admin-read.js +95 -0
  336. package/dist/hub/group-policy/admin-read.js.map +1 -0
  337. package/dist/hub/group-policy/admin-search.d.ts +14 -0
  338. package/dist/hub/group-policy/admin-search.js +72 -0
  339. package/dist/hub/group-policy/admin-search.js.map +1 -0
  340. package/dist/hub/group-policy/authorization.d.ts +65 -0
  341. package/dist/hub/group-policy/authorization.js +315 -0
  342. package/dist/hub/group-policy/authorization.js.map +1 -0
  343. package/dist/hub/group-policy/impact-inventory.d.ts +21 -0
  344. package/dist/hub/group-policy/impact-inventory.js +75 -0
  345. package/dist/hub/group-policy/impact-inventory.js.map +1 -0
  346. package/dist/hub/group-policy/model.d.ts +56 -0
  347. package/dist/hub/group-policy/model.js +46 -0
  348. package/dist/hub/group-policy/model.js.map +1 -0
  349. package/dist/hub/group-policy/resources.d.ts +72 -0
  350. package/dist/hub/group-policy/resources.js +260 -0
  351. package/dist/hub/group-policy/resources.js.map +1 -0
  352. package/dist/hub/group-policy/store.d.ts +69 -0
  353. package/dist/hub/group-policy/store.js +210 -0
  354. package/dist/hub/group-policy/store.js.map +1 -0
  355. package/dist/hub/group-policy/welcome.d.ts +36 -0
  356. package/dist/hub/group-policy/welcome.js +55 -0
  357. package/dist/hub/group-policy/welcome.js.map +1 -0
  358. package/dist/hub/http/compose.d.ts +24 -0
  359. package/dist/hub/http/compose.js +742 -0
  360. package/dist/hub/http/compose.js.map +1 -0
  361. package/dist/hub/http/core.d.ts +71 -0
  362. package/dist/hub/http/core.js +266 -0
  363. package/dist/hub/http/core.js.map +1 -0
  364. package/dist/hub/http/deps.d.ts +79 -0
  365. package/dist/hub/http/deps.js +2 -0
  366. package/dist/hub/http/deps.js.map +1 -0
  367. package/dist/hub/http/schema.d.ts +14 -0
  368. package/dist/hub/http/schema.js +84 -0
  369. package/dist/hub/http/schema.js.map +1 -0
  370. package/dist/hub/identity.d.ts +32 -0
  371. package/dist/hub/identity.js +80 -0
  372. package/dist/hub/identity.js.map +1 -0
  373. package/dist/hub/init/browser-certificate.d.ts +14 -0
  374. package/dist/hub/init/browser-certificate.js +99 -0
  375. package/dist/hub/init/browser-certificate.js.map +1 -0
  376. package/dist/hub/init/browser-tls.d.ts +18 -0
  377. package/dist/hub/init/browser-tls.js +62 -0
  378. package/dist/hub/init/browser-tls.js.map +1 -0
  379. package/dist/hub/init/cli.d.ts +3 -0
  380. package/dist/hub/init/cli.js +83 -0
  381. package/dist/hub/init/cli.js.map +1 -0
  382. package/dist/hub/init/directory-certificate.d.ts +24 -0
  383. package/dist/hub/init/directory-certificate.js +229 -0
  384. package/dist/hub/init/directory-certificate.js.map +1 -0
  385. package/dist/hub/init/existing-fleet.d.ts +6 -0
  386. package/dist/hub/init/existing-fleet.js +58 -0
  387. package/dist/hub/init/existing-fleet.js.map +1 -0
  388. package/dist/hub/init/handoff.d.ts +8 -0
  389. package/dist/hub/init/handoff.js +36 -0
  390. package/dist/hub/init/handoff.js.map +1 -0
  391. package/dist/hub/init/identity.d.ts +5 -0
  392. package/dist/hub/init/identity.js +24 -0
  393. package/dist/hub/init/identity.js.map +1 -0
  394. package/dist/hub/init/initializer.d.ts +34 -0
  395. package/dist/hub/init/initializer.js +504 -0
  396. package/dist/hub/init/initializer.js.map +1 -0
  397. package/dist/hub/init/inventory.d.ts +17 -0
  398. package/dist/hub/init/inventory.js +33 -0
  399. package/dist/hub/init/inventory.js.map +1 -0
  400. package/dist/hub/init/layout.d.ts +32 -0
  401. package/dist/hub/init/layout.js +53 -0
  402. package/dist/hub/init/layout.js.map +1 -0
  403. package/dist/hub/init/network.d.ts +20 -0
  404. package/dist/hub/init/network.js +108 -0
  405. package/dist/hub/init/network.js.map +1 -0
  406. package/dist/hub/init/plan-digest.d.ts +5 -0
  407. package/dist/hub/init/plan-digest.js +49 -0
  408. package/dist/hub/init/plan-digest.js.map +1 -0
  409. package/dist/hub/init/prompt.d.ts +26 -0
  410. package/dist/hub/init/prompt.js +111 -0
  411. package/dist/hub/init/prompt.js.map +1 -0
  412. package/dist/hub/init/secret-file.d.ts +1 -0
  413. package/dist/hub/init/secret-file.js +59 -0
  414. package/dist/hub/init/secret-file.js.map +1 -0
  415. package/dist/hub/init/text.d.ts +129 -0
  416. package/dist/hub/init/text.js +251 -0
  417. package/dist/hub/init/text.js.map +1 -0
  418. package/dist/hub/init/types.d.ts +142 -0
  419. package/dist/hub/init/types.js +9 -0
  420. package/dist/hub/init/types.js.map +1 -0
  421. package/dist/hub/init/web-audit-import.d.ts +12 -0
  422. package/dist/hub/init/web-audit-import.js +39 -0
  423. package/dist/hub/init/web-audit-import.js.map +1 -0
  424. package/dist/hub/init/web-audit.d.ts +30 -0
  425. package/dist/hub/init/web-audit.js +42 -0
  426. package/dist/hub/init/web-audit.js.map +1 -0
  427. package/dist/hub/init/web-error.d.ts +6 -0
  428. package/dist/hub/init/web-error.js +8 -0
  429. package/dist/hub/init/web-error.js.map +1 -0
  430. package/dist/hub/init/web-http.d.ts +9 -0
  431. package/dist/hub/init/web-http.js +103 -0
  432. package/dist/hub/init/web-http.js.map +1 -0
  433. package/dist/hub/init/web.d.ts +118 -0
  434. package/dist/hub/init/web.js +428 -0
  435. package/dist/hub/init/web.js.map +1 -0
  436. package/dist/hub/init/wizard.d.ts +34 -0
  437. package/dist/hub/init/wizard.js +580 -0
  438. package/dist/hub/init/wizard.js.map +1 -0
  439. package/dist/hub/initialization.d.ts +23 -0
  440. package/dist/hub/initialization.js +28 -0
  441. package/dist/hub/initialization.js.map +1 -0
  442. package/dist/hub/join/client.d.ts +52 -0
  443. package/dist/hub/join/client.js +136 -0
  444. package/dist/hub/join/client.js.map +1 -0
  445. package/dist/hub/join/descriptor.d.ts +52 -0
  446. package/dist/hub/join/descriptor.js +59 -0
  447. package/dist/hub/join/descriptor.js.map +1 -0
  448. package/dist/hub/join/display.d.ts +18 -0
  449. package/dist/hub/join/display.js +53 -0
  450. package/dist/hub/join/display.js.map +1 -0
  451. package/dist/hub/join/fleet-authority.d.ts +2 -0
  452. package/dist/hub/join/fleet-authority.js +3 -0
  453. package/dist/hub/join/fleet-authority.js.map +1 -0
  454. package/dist/hub/join/http.d.ts +8 -0
  455. package/dist/hub/join/http.js +122 -0
  456. package/dist/hub/join/http.js.map +1 -0
  457. package/dist/hub/join/invitation.d.ts +28 -0
  458. package/dist/hub/join/invitation.js +28 -0
  459. package/dist/hub/join/invitation.js.map +1 -0
  460. package/dist/hub/join/local-journal.d.ts +84 -0
  461. package/dist/hub/join/local-journal.js +65 -0
  462. package/dist/hub/join/local-journal.js.map +1 -0
  463. package/dist/hub/join/local.d.ts +228 -0
  464. package/dist/hub/join/local.js +613 -0
  465. package/dist/hub/join/local.js.map +1 -0
  466. package/dist/hub/join/private.d.ts +3 -0
  467. package/dist/hub/join/private.js +46 -0
  468. package/dist/hub/join/private.js.map +1 -0
  469. package/dist/hub/join/protocol.d.ts +69 -0
  470. package/dist/hub/join/protocol.js +96 -0
  471. package/dist/hub/join/protocol.js.map +1 -0
  472. package/dist/hub/join/receipt.d.ts +42 -0
  473. package/dist/hub/join/receipt.js +75 -0
  474. package/dist/hub/join/receipt.js.map +1 -0
  475. package/dist/hub/join/service.d.ts +194 -0
  476. package/dist/hub/join/service.js +631 -0
  477. package/dist/hub/join/service.js.map +1 -0
  478. package/dist/hub/join/store.d.ts +134 -0
  479. package/dist/hub/join/store.js +136 -0
  480. package/dist/hub/join/store.js.map +1 -0
  481. package/dist/hub/join/trust.d.ts +19 -0
  482. package/dist/hub/join/trust.js +94 -0
  483. package/dist/hub/join/trust.js.map +1 -0
  484. package/dist/hub/member/agent-mode.d.ts +6 -0
  485. package/dist/hub/member/agent-mode.js +23 -0
  486. package/dist/hub/member/agent-mode.js.map +1 -0
  487. package/dist/hub/member/attachments.d.ts +29 -0
  488. package/dist/hub/member/attachments.js +107 -0
  489. package/dist/hub/member/attachments.js.map +1 -0
  490. package/dist/hub/member/exposure-api.d.ts +89 -0
  491. package/dist/hub/member/exposure-api.js +66 -0
  492. package/dist/hub/member/exposure-api.js.map +1 -0
  493. package/dist/hub/member/exposures.d.ts +123 -0
  494. package/dist/hub/member/exposures.js +282 -0
  495. package/dist/hub/member/exposures.js.map +1 -0
  496. package/dist/hub/member/pairing-api.d.ts +101 -0
  497. package/dist/hub/member/pairing-api.js +429 -0
  498. package/dist/hub/member/pairing-api.js.map +1 -0
  499. package/dist/hub/member/pairing-notices.d.ts +18 -0
  500. package/dist/hub/member/pairing-notices.js +60 -0
  501. package/dist/hub/member/pairing-notices.js.map +1 -0
  502. package/dist/hub/member/quota.d.ts +20 -0
  503. package/dist/hub/member/quota.js +98 -0
  504. package/dist/hub/member/quota.js.map +1 -0
  505. package/dist/hub/member-journal.d.ts +104 -0
  506. package/dist/hub/member-journal.js +336 -0
  507. package/dist/hub/member-journal.js.map +1 -0
  508. package/dist/hub/member-reconciliation.d.ts +14 -0
  509. package/dist/hub/member-reconciliation.js +97 -0
  510. package/dist/hub/member-reconciliation.js.map +1 -0
  511. package/dist/hub/mount.d.ts +50 -0
  512. package/dist/hub/mount.js +157 -0
  513. package/dist/hub/mount.js.map +1 -0
  514. package/dist/hub/pairing-client.d.ts +17 -0
  515. package/dist/hub/pairing-client.js +108 -0
  516. package/dist/hub/pairing-client.js.map +1 -0
  517. package/dist/hub/pairing-notices.d.ts +47 -0
  518. package/dist/hub/pairing-notices.js +246 -0
  519. package/dist/hub/pairing-notices.js.map +1 -0
  520. package/dist/hub/pairing.d.ts +111 -0
  521. package/dist/hub/pairing.js +526 -0
  522. package/dist/hub/pairing.js.map +1 -0
  523. package/dist/hub/policy.d.ts +65 -0
  524. package/dist/hub/policy.js +154 -0
  525. package/dist/hub/policy.js.map +1 -0
  526. package/dist/hub/preview.d.ts +32 -0
  527. package/dist/hub/preview.js +64 -0
  528. package/dist/hub/preview.js.map +1 -0
  529. package/dist/hub/private-files.d.ts +5 -0
  530. package/dist/hub/private-files.js +44 -0
  531. package/dist/hub/private-files.js.map +1 -0
  532. package/dist/hub/profile.d.ts +59 -0
  533. package/dist/hub/profile.js +73 -0
  534. package/dist/hub/profile.js.map +1 -0
  535. package/dist/hub/protocol.d.ts +848 -0
  536. package/dist/hub/protocol.js +103 -0
  537. package/dist/hub/protocol.js.map +1 -0
  538. package/dist/hub/quota.d.ts +24 -0
  539. package/dist/hub/quota.js +112 -0
  540. package/dist/hub/quota.js.map +1 -0
  541. package/dist/hub/representative.d.ts +141 -0
  542. package/dist/hub/representative.js +528 -0
  543. package/dist/hub/representative.js.map +1 -0
  544. package/dist/hub/retention.d.ts +17 -0
  545. package/dist/hub/retention.js +45 -0
  546. package/dist/hub/retention.js.map +1 -0
  547. package/dist/hub/room-read-pacer.d.ts +14 -0
  548. package/dist/hub/room-read-pacer.js +51 -0
  549. package/dist/hub/room-read-pacer.js.map +1 -0
  550. package/dist/hub/rooms.d.ts +127 -0
  551. package/dist/hub/rooms.js +597 -0
  552. package/dist/hub/rooms.js.map +1 -0
  553. package/dist/hub/runtime.d.ts +163 -0
  554. package/dist/hub/runtime.js +708 -0
  555. package/dist/hub/runtime.js.map +1 -0
  556. package/dist/hub/server.d.ts +61 -0
  557. package/dist/hub/server.js +249 -0
  558. package/dist/hub/server.js.map +1 -0
  559. package/dist/hub/service-start.d.ts +17 -0
  560. package/dist/hub/service-start.js +109 -0
  561. package/dist/hub/service-start.js.map +1 -0
  562. package/dist/hub/session-directory-transition.d.ts +48 -0
  563. package/dist/hub/session-directory-transition.js +118 -0
  564. package/dist/hub/session-directory-transition.js.map +1 -0
  565. package/dist/hub/session-epoch.d.ts +16 -0
  566. package/dist/hub/session-epoch.js +50 -0
  567. package/dist/hub/session-epoch.js.map +1 -0
  568. package/dist/hub/sessions.d.ts +66 -0
  569. package/dist/hub/sessions.js +217 -0
  570. package/dist/hub/sessions.js.map +1 -0
  571. package/dist/hub/settings-api.d.ts +50 -0
  572. package/dist/hub/settings-api.js +92 -0
  573. package/dist/hub/settings-api.js.map +1 -0
  574. package/dist/hub/settings-commit.d.ts +108 -0
  575. package/dist/hub/settings-commit.js +537 -0
  576. package/dist/hub/settings-commit.js.map +1 -0
  577. package/dist/hub/settings-directory-ca.d.ts +31 -0
  578. package/dist/hub/settings-directory-ca.js +115 -0
  579. package/dist/hub/settings-directory-ca.js.map +1 -0
  580. package/dist/hub/settings-directory-control.d.ts +58 -0
  581. package/dist/hub/settings-directory-control.js +117 -0
  582. package/dist/hub/settings-directory-control.js.map +1 -0
  583. package/dist/hub/settings-directory-decision.d.ts +465 -0
  584. package/dist/hub/settings-directory-decision.js +322 -0
  585. package/dist/hub/settings-directory-decision.js.map +1 -0
  586. package/dist/hub/settings-directory-host-http.d.ts +9 -0
  587. package/dist/hub/settings-directory-host-http.js +75 -0
  588. package/dist/hub/settings-directory-host-http.js.map +1 -0
  589. package/dist/hub/settings-directory-host-notice-http.d.ts +9 -0
  590. package/dist/hub/settings-directory-host-notice-http.js +78 -0
  591. package/dist/hub/settings-directory-host-notice-http.js.map +1 -0
  592. package/dist/hub/settings-directory-host-notices.d.ts +11 -0
  593. package/dist/hub/settings-directory-host-notices.js +39 -0
  594. package/dist/hub/settings-directory-host-notices.js.map +1 -0
  595. package/dist/hub/settings-directory-http.d.ts +33 -0
  596. package/dist/hub/settings-directory-http.js +109 -0
  597. package/dist/hub/settings-directory-http.js.map +1 -0
  598. package/dist/hub/settings-directory-mount.d.ts +24 -0
  599. package/dist/hub/settings-directory-mount.js +77 -0
  600. package/dist/hub/settings-directory-mount.js.map +1 -0
  601. package/dist/hub/settings-directory-notices.d.ts +61 -0
  602. package/dist/hub/settings-directory-notices.js +132 -0
  603. package/dist/hub/settings-directory-notices.js.map +1 -0
  604. package/dist/hub/settings-directory-proof.d.ts +77 -0
  605. package/dist/hub/settings-directory-proof.js +313 -0
  606. package/dist/hub/settings-directory-proof.js.map +1 -0
  607. package/dist/hub/settings-directory-recovery-intent.d.ts +13 -0
  608. package/dist/hub/settings-directory-recovery-intent.js +29 -0
  609. package/dist/hub/settings-directory-recovery-intent.js.map +1 -0
  610. package/dist/hub/settings-directory-recovery.d.ts +45 -0
  611. package/dist/hub/settings-directory-recovery.js +178 -0
  612. package/dist/hub/settings-directory-recovery.js.map +1 -0
  613. package/dist/hub/settings-directory-runtime.d.ts +17 -0
  614. package/dist/hub/settings-directory-runtime.js +2 -0
  615. package/dist/hub/settings-directory-runtime.js.map +1 -0
  616. package/dist/hub/settings-directory-save.d.ts +37 -0
  617. package/dist/hub/settings-directory-save.js +175 -0
  618. package/dist/hub/settings-directory-save.js.map +1 -0
  619. package/dist/hub/settings-web-address-control.d.ts +49 -0
  620. package/dist/hub/settings-web-address-control.js +99 -0
  621. package/dist/hub/settings-web-address-control.js.map +1 -0
  622. package/dist/hub/settings-web-address-decision.d.ts +91 -0
  623. package/dist/hub/settings-web-address-decision.js +163 -0
  624. package/dist/hub/settings-web-address-decision.js.map +1 -0
  625. package/dist/hub/settings-web-address-http.d.ts +9 -0
  626. package/dist/hub/settings-web-address-http.js +74 -0
  627. package/dist/hub/settings-web-address-http.js.map +1 -0
  628. package/dist/hub/settings-web-address-network.d.ts +2 -0
  629. package/dist/hub/settings-web-address-network.js +25 -0
  630. package/dist/hub/settings-web-address-network.js.map +1 -0
  631. package/dist/hub/settings-web-address-policy.d.ts +27 -0
  632. package/dist/hub/settings-web-address-policy.js +47 -0
  633. package/dist/hub/settings-web-address-policy.js.map +1 -0
  634. package/dist/hub/settings-web-address.d.ts +64 -0
  635. package/dist/hub/settings-web-address.js +226 -0
  636. package/dist/hub/settings-web-address.js.map +1 -0
  637. package/dist/hub/socket.d.ts +24 -0
  638. package/dist/hub/socket.js +79 -0
  639. package/dist/hub/socket.js.map +1 -0
  640. package/dist/hub/store.d.ts +87 -0
  641. package/dist/hub/store.js +108 -0
  642. package/dist/hub/store.js.map +1 -0
  643. package/dist/hub/tls.d.ts +31 -0
  644. package/dist/hub/tls.js +135 -0
  645. package/dist/hub/tls.js.map +1 -0
  646. package/dist/hub/types.d.ts +421 -0
  647. package/dist/hub/types.js +2 -0
  648. package/dist/hub/types.js.map +1 -0
  649. package/dist/hub/validation.d.ts +33 -0
  650. package/dist/hub/validation.js +136 -0
  651. package/dist/hub/validation.js.map +1 -0
  652. package/dist/hub/version-floor.d.ts +10 -0
  653. package/dist/hub/version-floor.js +45 -0
  654. package/dist/hub/version-floor.js.map +1 -0
  655. package/dist/hub-browser-certificate-policy.d.ts +31 -0
  656. package/dist/hub-browser-certificate-policy.js +25 -0
  657. package/dist/hub-browser-certificate-policy.js.map +1 -0
  658. package/dist/hub-host-settings.d.ts +48 -0
  659. package/dist/hub-host-settings.js +85 -0
  660. package/dist/hub-host-settings.js.map +1 -0
  661. package/dist/hub-membership-settings.d.ts +6 -0
  662. package/dist/hub-membership-settings.js +21 -0
  663. package/dist/hub-membership-settings.js.map +1 -0
  664. package/dist/hub-mode.d.ts +15 -0
  665. package/dist/hub-mode.js +17 -0
  666. package/dist/hub-mode.js.map +1 -0
  667. package/dist/hub-pairing-summary.d.ts +50 -0
  668. package/dist/hub-pairing-summary.js +39 -0
  669. package/dist/hub-pairing-summary.js.map +1 -0
  670. package/dist/hub-report-target.d.ts +32 -0
  671. package/dist/hub-report-target.js +33 -0
  672. package/dist/hub-report-target.js.map +1 -0
  673. package/dist/hub-retention-policy.d.ts +14 -0
  674. package/dist/hub-retention-policy.js +15 -0
  675. package/dist/hub-retention-policy.js.map +1 -0
  676. package/dist/install-user-systemd.d.ts +20 -0
  677. package/dist/install-user-systemd.js +55 -0
  678. package/dist/install-user-systemd.js.map +1 -0
  679. package/dist/instance-config-impact.js +9 -0
  680. package/dist/instance-config-impact.js.map +1 -1
  681. package/dist/instance-lifecycle.d.ts +42 -4
  682. package/dist/instance-lifecycle.js +460 -202
  683. package/dist/instance-lifecycle.js.map +1 -1
  684. package/dist/instructions.d.ts +2 -0
  685. package/dist/instructions.js +6 -0
  686. package/dist/instructions.js.map +1 -1
  687. package/dist/launchd-service-domain.d.ts +5 -0
  688. package/dist/launchd-service-domain.js +21 -0
  689. package/dist/launchd-service-domain.js.map +1 -0
  690. package/dist/linux-launchers.d.ts +88 -0
  691. package/dist/linux-launchers.js +296 -0
  692. package/dist/linux-launchers.js.map +1 -0
  693. package/dist/local-pane-endpoint.d.ts +46 -0
  694. package/dist/local-pane-endpoint.js +189 -0
  695. package/dist/local-pane-endpoint.js.map +1 -0
  696. package/dist/local-pane-launcher.d.ts +2 -0
  697. package/dist/local-pane-launcher.js +38 -0
  698. package/dist/local-pane-launcher.js.map +1 -0
  699. package/dist/local-pane-stage.ps1 +101 -0
  700. package/dist/locale.js +402 -14
  701. package/dist/locale.js.map +1 -1
  702. package/dist/login-controller.d.ts +14 -1
  703. package/dist/login-controller.js +31 -1
  704. package/dist/login-controller.js.map +1 -1
  705. package/dist/login-flows.d.ts +12 -8
  706. package/dist/login-flows.js +34 -16
  707. package/dist/login-flows.js.map +1 -1
  708. package/dist/login-manager.d.ts +2 -2
  709. package/dist/login-manager.js +3 -2
  710. package/dist/login-manager.js.map +1 -1
  711. package/dist/login-window-lock.d.ts +2 -1
  712. package/dist/login-window-lock.js.map +1 -1
  713. package/dist/ls-rows.d.ts +1 -1
  714. package/dist/ls-rows.js +3 -4
  715. package/dist/ls-rows.js.map +1 -1
  716. package/dist/machine-accounts.d.ts +110 -0
  717. package/dist/machine-accounts.js +229 -0
  718. package/dist/machine-accounts.js.map +1 -0
  719. package/dist/machine-signins.d.ts +89 -0
  720. package/dist/machine-signins.js +182 -0
  721. package/dist/machine-signins.js.map +1 -0
  722. package/dist/model-catalog-defaults.d.ts +14 -0
  723. package/dist/model-catalog-defaults.js +20 -0
  724. package/dist/model-catalog-defaults.js.map +1 -0
  725. package/dist/native-agent-admission.d.ts +7 -0
  726. package/dist/native-agent-admission.js +26 -0
  727. package/dist/native-agent-admission.js.map +1 -0
  728. package/dist/native-daemon-client.d.ts +13 -0
  729. package/dist/native-daemon-client.js +28 -0
  730. package/dist/native-daemon-client.js.map +1 -0
  731. package/dist/native-instance-api.d.ts +13 -0
  732. package/dist/native-instance-api.js +217 -0
  733. package/dist/native-instance-api.js.map +1 -0
  734. package/dist/native-instance-input.d.ts +87 -0
  735. package/dist/native-instance-input.js +59 -0
  736. package/dist/native-instance-input.js.map +1 -0
  737. package/dist/native-instance-registry.d.ts +38 -0
  738. package/dist/native-instance-registry.js +129 -0
  739. package/dist/native-instance-registry.js.map +1 -0
  740. package/dist/native-mcp.d.ts +43 -0
  741. package/dist/native-mcp.js +291 -0
  742. package/dist/native-mcp.js.map +1 -0
  743. package/dist/native-model-catalog.d.ts +25 -0
  744. package/dist/native-model-catalog.js +181 -0
  745. package/dist/native-model-catalog.js.map +1 -0
  746. package/dist/native-pane-crash-budget.d.ts +20 -0
  747. package/dist/native-pane-crash-budget.js +60 -0
  748. package/dist/native-pane-crash-budget.js.map +1 -0
  749. package/dist/native-pane-create.d.ts +26 -0
  750. package/dist/native-pane-create.js +53 -0
  751. package/dist/native-pane-create.js.map +1 -0
  752. package/dist/native-pane-lifecycle.d.ts +73 -0
  753. package/dist/native-pane-lifecycle.js +239 -0
  754. package/dist/native-pane-lifecycle.js.map +1 -0
  755. package/dist/native-pane-manager.d.ts +59 -0
  756. package/dist/native-pane-manager.js +592 -0
  757. package/dist/native-pane-manager.js.map +1 -0
  758. package/dist/native-pane-output-log.d.ts +15 -0
  759. package/dist/native-pane-output-log.js +108 -0
  760. package/dist/native-pane-output-log.js.map +1 -0
  761. package/dist/native-pane-reconciliation.d.ts +4 -0
  762. package/dist/native-pane-reconciliation.js +40 -0
  763. package/dist/native-pane-reconciliation.js.map +1 -0
  764. package/dist/native-pane-recovery.d.ts +12 -0
  765. package/dist/native-pane-recovery.js +10 -0
  766. package/dist/native-pane-recovery.js.map +1 -0
  767. package/dist/native-pane-tools.d.ts +2 -0
  768. package/dist/native-pane-tools.js +14 -0
  769. package/dist/native-pane-tools.js.map +1 -0
  770. package/dist/needs-you-hub.d.ts +8 -0
  771. package/dist/needs-you-hub.js +31 -5
  772. package/dist/needs-you-hub.js.map +1 -1
  773. package/dist/needs-you.d.ts +80 -3
  774. package/dist/needs-you.js +46 -3
  775. package/dist/needs-you.js.map +1 -1
  776. package/dist/office-share-page.js +3 -3
  777. package/dist/office-share-page.js.map +1 -1
  778. package/dist/office-share.d.ts +28 -2
  779. package/dist/office-share.js +32 -3
  780. package/dist/office-share.js.map +1 -1
  781. package/dist/office-talk.d.ts +26 -0
  782. package/dist/office-talk.js +50 -0
  783. package/dist/office-talk.js.map +1 -0
  784. package/dist/outbound-handlers.d.ts +30 -2
  785. package/dist/outbound-handlers.js +120 -4
  786. package/dist/outbound-handlers.js.map +1 -1
  787. package/dist/outbound-schemas.d.ts +79 -1
  788. package/dist/outbound-schemas.js +37 -14
  789. package/dist/outbound-schemas.js.map +1 -1
  790. package/dist/pane-port.d.ts +118 -0
  791. package/dist/pane-port.js +2 -0
  792. package/dist/pane-port.js.map +1 -0
  793. package/dist/pane-quota-history.d.ts +2 -0
  794. package/dist/pane-quota-history.js +20 -0
  795. package/dist/pane-quota-history.js.map +1 -1
  796. package/dist/pause-marker.d.ts +1 -1
  797. package/dist/pause-marker.js +1 -1
  798. package/dist/pause-marker.js.map +1 -1
  799. package/dist/profile-signins.d.ts +107 -0
  800. package/dist/profile-signins.js +249 -0
  801. package/dist/profile-signins.js.map +1 -0
  802. package/dist/public-web-gateway.js +17 -1
  803. package/dist/public-web-gateway.js.map +1 -1
  804. package/dist/public-web-link.d.ts +16 -0
  805. package/dist/public-web-link.js +21 -0
  806. package/dist/public-web-link.js.map +1 -1
  807. package/dist/quickstart-api.js +9 -5
  808. package/dist/quickstart-api.js.map +1 -1
  809. package/dist/quickstart.d.ts +6 -0
  810. package/dist/quickstart.js +31 -4
  811. package/dist/quickstart.js.map +1 -1
  812. package/dist/quiet-run.d.ts +31 -0
  813. package/dist/quiet-run.js +50 -0
  814. package/dist/quiet-run.js.map +1 -0
  815. package/dist/runtime-api.d.ts +23 -0
  816. package/dist/runtime-api.js +413 -0
  817. package/dist/runtime-api.js.map +1 -0
  818. package/dist/runtime-assets/@xterm/addon-serialize/LICENSE +21 -0
  819. package/dist/runtime-assets/@xterm/addon-serialize/lib/addon-serialize.js +2 -0
  820. package/dist/runtime-assets/@xterm/addon-serialize/lib/addon-serialize.mjs +19 -0
  821. package/dist/runtime-assets/@xterm/addon-serialize/package.json +29 -0
  822. package/dist/runtime-assets/@xterm/headless/LICENSE +21 -0
  823. package/dist/runtime-assets/@xterm/headless/lib-headless/xterm-headless.js +2 -0
  824. package/dist/runtime-assets/@xterm/headless/lib-headless/xterm-headless.mjs +46 -0
  825. package/dist/runtime-assets/@xterm/headless/package.json +29 -0
  826. package/dist/runtime-assets/node-pty/CONPTY-LICENSE +21 -0
  827. package/dist/runtime-assets/node-pty/CONPTY-NOTICE.md +503 -0
  828. package/dist/runtime-assets/node-pty/LICENSE +69 -0
  829. package/dist/runtime-assets/node-pty/lib/conpty_console_list_agent.js +16 -0
  830. package/dist/runtime-assets/node-pty/lib/eventEmitter2.js +47 -0
  831. package/dist/runtime-assets/node-pty/lib/index.js +52 -0
  832. package/dist/runtime-assets/node-pty/lib/interfaces.js +7 -0
  833. package/dist/runtime-assets/node-pty/lib/shared/conout.js +11 -0
  834. package/dist/runtime-assets/node-pty/lib/terminal.js +190 -0
  835. package/dist/runtime-assets/node-pty/lib/types.js +7 -0
  836. package/dist/runtime-assets/node-pty/lib/unixTerminal.js +346 -0
  837. package/dist/runtime-assets/node-pty/lib/utils.js +39 -0
  838. package/dist/runtime-assets/node-pty/lib/windowsConoutConnection.js +125 -0
  839. package/dist/runtime-assets/node-pty/lib/windowsPtyAgent.js +320 -0
  840. package/dist/runtime-assets/node-pty/lib/windowsTerminal.js +199 -0
  841. package/dist/runtime-assets/node-pty/lib/worker/conoutSocketWorker.js +22 -0
  842. package/dist/runtime-assets/node-pty/package.json +64 -0
  843. package/dist/runtime-assets/node-pty/prebuilds/win32-arm64/conpty/OpenConsole.exe +0 -0
  844. package/dist/runtime-assets/node-pty/prebuilds/win32-arm64/conpty/conpty.dll +0 -0
  845. package/dist/runtime-assets/node-pty/prebuilds/win32-arm64/conpty.node +0 -0
  846. package/dist/runtime-assets/node-pty/prebuilds/win32-arm64/conpty_console_list.node +0 -0
  847. package/dist/runtime-assets/node-pty/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
  848. package/dist/runtime-assets/node-pty/prebuilds/win32-x64/conpty/conpty.dll +0 -0
  849. package/dist/runtime-assets/node-pty/prebuilds/win32-x64/conpty.node +0 -0
  850. package/dist/runtime-assets/node-pty/prebuilds/win32-x64/conpty_console_list.node +0 -0
  851. package/dist/runtime-autostart.d.ts +61 -0
  852. package/dist/runtime-autostart.js +161 -0
  853. package/dist/runtime-autostart.js.map +1 -0
  854. package/dist/runtime-background.d.ts +200 -0
  855. package/dist/runtime-background.js +480 -0
  856. package/dist/runtime-background.js.map +1 -0
  857. package/dist/runtime-build-info.d.ts +10 -0
  858. package/dist/runtime-build-info.js +64 -0
  859. package/dist/runtime-build-info.js.map +1 -0
  860. package/dist/runtime-bundle.d.ts +22 -0
  861. package/dist/runtime-bundle.js +158 -0
  862. package/dist/runtime-bundle.js.map +1 -0
  863. package/dist/runtime-cli-background.d.ts +92 -0
  864. package/dist/runtime-cli-background.js +336 -0
  865. package/dist/runtime-cli-background.js.map +1 -0
  866. package/dist/runtime-cli-install.d.ts +295 -0
  867. package/dist/runtime-cli-install.js +869 -0
  868. package/dist/runtime-cli-install.js.map +1 -0
  869. package/dist/runtime-cli.d.ts +21 -0
  870. package/dist/runtime-cli.js +578 -0
  871. package/dist/runtime-cli.js.map +1 -0
  872. package/dist/runtime-client-store.d.ts +86 -0
  873. package/dist/runtime-client-store.js +392 -0
  874. package/dist/runtime-client-store.js.map +1 -0
  875. package/dist/runtime-client.d.ts +258 -0
  876. package/dist/runtime-client.js +1353 -0
  877. package/dist/runtime-client.js.map +1 -0
  878. package/dist/runtime-connection.d.ts +22 -0
  879. package/dist/runtime-connection.js +93 -0
  880. package/dist/runtime-connection.js.map +1 -0
  881. package/dist/runtime-coordinator.d.ts +201 -0
  882. package/dist/runtime-coordinator.js +1514 -0
  883. package/dist/runtime-coordinator.js.map +1 -0
  884. package/dist/runtime-credential-profiles.d.ts +89 -0
  885. package/dist/runtime-credential-profiles.js +304 -0
  886. package/dist/runtime-credential-profiles.js.map +1 -0
  887. package/dist/runtime-enroll-notice.d.ts +4 -0
  888. package/dist/runtime-enroll-notice.js +21 -0
  889. package/dist/runtime-enroll-notice.js.map +1 -0
  890. package/dist/runtime-enrollment.d.ts +21 -0
  891. package/dist/runtime-enrollment.js +52 -0
  892. package/dist/runtime-enrollment.js.map +1 -0
  893. package/dist/runtime-general-protocol.d.ts +22 -0
  894. package/dist/runtime-general-protocol.js +57 -0
  895. package/dist/runtime-general-protocol.js.map +1 -0
  896. package/dist/runtime-general-workspace.d.ts +17 -0
  897. package/dist/runtime-general-workspace.js +213 -0
  898. package/dist/runtime-general-workspace.js.map +1 -0
  899. package/dist/runtime-install.d.ts +50 -0
  900. package/dist/runtime-install.js +189 -0
  901. package/dist/runtime-install.js.map +1 -0
  902. package/dist/runtime-pane-assets.d.ts +17 -0
  903. package/dist/runtime-pane-assets.js +23 -0
  904. package/dist/runtime-pane-assets.js.map +1 -0
  905. package/dist/runtime-pane-boot.d.ts +9 -0
  906. package/dist/runtime-pane-boot.js +47 -0
  907. package/dist/runtime-pane-boot.js.map +1 -0
  908. package/dist/runtime-pane-codex-index.d.ts +10 -0
  909. package/dist/runtime-pane-codex-index.js +151 -0
  910. package/dist/runtime-pane-codex-index.js.map +1 -0
  911. package/dist/runtime-pane-config.d.ts +16 -0
  912. package/dist/runtime-pane-config.js +54 -0
  913. package/dist/runtime-pane-config.js.map +1 -0
  914. package/dist/runtime-pane-host.d.ts +63 -0
  915. package/dist/runtime-pane-host.js +467 -0
  916. package/dist/runtime-pane-host.js.map +1 -0
  917. package/dist/runtime-pane-job-owner.d.ts +1 -0
  918. package/dist/runtime-pane-job-owner.js +29 -0
  919. package/dist/runtime-pane-job-owner.js.map +1 -0
  920. package/dist/runtime-pane-job.ps1 +116 -0
  921. package/dist/runtime-pane-link.d.ts +47 -0
  922. package/dist/runtime-pane-link.js +338 -0
  923. package/dist/runtime-pane-link.js.map +1 -0
  924. package/dist/runtime-pane-mcp-protocol.d.ts +32 -0
  925. package/dist/runtime-pane-mcp-protocol.js +39 -0
  926. package/dist/runtime-pane-mcp-protocol.js.map +1 -0
  927. package/dist/runtime-pane-mcp-relay.d.ts +18 -0
  928. package/dist/runtime-pane-mcp-relay.js +80 -0
  929. package/dist/runtime-pane-mcp-relay.js.map +1 -0
  930. package/dist/runtime-pane-mcp.d.ts +55 -0
  931. package/dist/runtime-pane-mcp.js +153 -0
  932. package/dist/runtime-pane-mcp.js.map +1 -0
  933. package/dist/runtime-pane-native.d.ts +75 -0
  934. package/dist/runtime-pane-native.js +114 -0
  935. package/dist/runtime-pane-native.js.map +1 -0
  936. package/dist/runtime-pane-output.d.ts +19 -0
  937. package/dist/runtime-pane-output.js +53 -0
  938. package/dist/runtime-pane-output.js.map +1 -0
  939. package/dist/runtime-pane-port.d.ts +144 -0
  940. package/dist/runtime-pane-port.js +574 -0
  941. package/dist/runtime-pane-port.js.map +1 -0
  942. package/dist/runtime-pane-private.d.ts +16 -0
  943. package/dist/runtime-pane-private.js +76 -0
  944. package/dist/runtime-pane-private.js.map +1 -0
  945. package/dist/runtime-pane-private.ps1 +81 -0
  946. package/dist/runtime-pane-process.d.ts +4 -0
  947. package/dist/runtime-pane-process.js +117 -0
  948. package/dist/runtime-pane-process.js.map +1 -0
  949. package/dist/runtime-pane-protocol.d.ts +182 -0
  950. package/dist/runtime-pane-protocol.js +217 -0
  951. package/dist/runtime-pane-protocol.js.map +1 -0
  952. package/dist/runtime-pane-quota-history.d.ts +6 -0
  953. package/dist/runtime-pane-quota-history.js +44 -0
  954. package/dist/runtime-pane-quota-history.js.map +1 -0
  955. package/dist/runtime-pane-screen.d.ts +19 -0
  956. package/dist/runtime-pane-screen.js +76 -0
  957. package/dist/runtime-pane-screen.js.map +1 -0
  958. package/dist/runtime-pane-service.d.ts +16 -0
  959. package/dist/runtime-pane-service.js +256 -0
  960. package/dist/runtime-pane-service.js.map +1 -0
  961. package/dist/runtime-pane-stdio-protocol.d.ts +54 -0
  962. package/dist/runtime-pane-stdio-protocol.js +94 -0
  963. package/dist/runtime-pane-stdio-protocol.js.map +1 -0
  964. package/dist/runtime-pane-stdio.d.ts +3 -0
  965. package/dist/runtime-pane-stdio.js +123 -0
  966. package/dist/runtime-pane-stdio.js.map +1 -0
  967. package/dist/runtime-pane-store.d.ts +43 -0
  968. package/dist/runtime-pane-store.js +176 -0
  969. package/dist/runtime-pane-store.js.map +1 -0
  970. package/dist/runtime-pane-transcript-protocol.d.ts +43 -0
  971. package/dist/runtime-pane-transcript-protocol.js +58 -0
  972. package/dist/runtime-pane-transcript-protocol.js.map +1 -0
  973. package/dist/runtime-pane-transcript.d.ts +50 -0
  974. package/dist/runtime-pane-transcript.js +666 -0
  975. package/dist/runtime-pane-transcript.js.map +1 -0
  976. package/dist/runtime-pane-worker.d.ts +1 -0
  977. package/dist/runtime-pane-worker.js +167 -0
  978. package/dist/runtime-pane-worker.js.map +1 -0
  979. package/dist/runtime-profile-ownership.d.ts +66 -0
  980. package/dist/runtime-profile-ownership.js +391 -0
  981. package/dist/runtime-profile-ownership.js.map +1 -0
  982. package/dist/runtime-protocol.d.ts +340 -0
  983. package/dist/runtime-protocol.js +179 -0
  984. package/dist/runtime-protocol.js.map +1 -0
  985. package/dist/runtime-remote-accounts.d.ts +209 -0
  986. package/dist/runtime-remote-accounts.js +714 -0
  987. package/dist/runtime-remote-accounts.js.map +1 -0
  988. package/dist/runtime-remote-setup.d.ts +108 -0
  989. package/dist/runtime-remote-setup.js +532 -0
  990. package/dist/runtime-remote-setup.js.map +1 -0
  991. package/dist/runtime-signin-transport.d.ts +39 -0
  992. package/dist/runtime-signin-transport.js +111 -0
  993. package/dist/runtime-signin-transport.js.map +1 -0
  994. package/dist/runtime-signin.d.ts +132 -0
  995. package/dist/runtime-signin.js +290 -0
  996. package/dist/runtime-signin.js.map +1 -0
  997. package/dist/runtime-switches.d.ts +79 -0
  998. package/dist/runtime-switches.js +90 -0
  999. package/dist/runtime-switches.js.map +1 -0
  1000. package/dist/runtime-transcript-delta-reader.d.ts +23 -0
  1001. package/dist/runtime-transcript-delta-reader.js +74 -0
  1002. package/dist/runtime-transcript-delta-reader.js.map +1 -0
  1003. package/dist/runtime-transcript-source.d.ts +36 -0
  1004. package/dist/runtime-transcript-source.js +189 -0
  1005. package/dist/runtime-transcript-source.js.map +1 -0
  1006. package/dist/runtime-update-activity.d.ts +21 -0
  1007. package/dist/runtime-update-activity.js +51 -0
  1008. package/dist/runtime-update-activity.js.map +1 -0
  1009. package/dist/runtime-update-artifact.d.ts +31 -0
  1010. package/dist/runtime-update-artifact.js +252 -0
  1011. package/dist/runtime-update-artifact.js.map +1 -0
  1012. package/dist/runtime-update-attention.d.ts +4 -0
  1013. package/dist/runtime-update-attention.js +11 -0
  1014. package/dist/runtime-update-attention.js.map +1 -0
  1015. package/dist/runtime-update-controller.d.ts +86 -0
  1016. package/dist/runtime-update-controller.js +743 -0
  1017. package/dist/runtime-update-controller.js.map +1 -0
  1018. package/dist/runtime-update-install.d.ts +31 -0
  1019. package/dist/runtime-update-install.js +205 -0
  1020. package/dist/runtime-update-install.js.map +1 -0
  1021. package/dist/runtime-update-ipc.d.ts +42 -0
  1022. package/dist/runtime-update-ipc.js +144 -0
  1023. package/dist/runtime-update-ipc.js.map +1 -0
  1024. package/dist/runtime-update-journal.d.ts +49 -0
  1025. package/dist/runtime-update-journal.js +128 -0
  1026. package/dist/runtime-update-journal.js.map +1 -0
  1027. package/dist/runtime-update-lock.d.ts +48 -0
  1028. package/dist/runtime-update-lock.js +232 -0
  1029. package/dist/runtime-update-lock.js.map +1 -0
  1030. package/dist/runtime-update-owners.d.ts +29 -0
  1031. package/dist/runtime-update-owners.js +240 -0
  1032. package/dist/runtime-update-owners.js.map +1 -0
  1033. package/dist/runtime-update-protocol.d.ts +15 -0
  1034. package/dist/runtime-update-protocol.js +13 -0
  1035. package/dist/runtime-update-protocol.js.map +1 -0
  1036. package/dist/runtime-update-status.d.ts +30 -0
  1037. package/dist/runtime-update-status.js +31 -0
  1038. package/dist/runtime-update-status.js.map +1 -0
  1039. package/dist/runtime-windows-bridge.d.ts +42 -0
  1040. package/dist/runtime-windows-bridge.js +167 -0
  1041. package/dist/runtime-windows-bridge.js.map +1 -0
  1042. package/dist/scheduler/db.d.ts +3 -0
  1043. package/dist/scheduler/db.js +4 -0
  1044. package/dist/scheduler/db.js.map +1 -1
  1045. package/dist/scheduler/task-board-text.js +1 -1
  1046. package/dist/scheduler/task-board-text.js.map +1 -1
  1047. package/dist/scheduler/task-board.d.ts +4 -0
  1048. package/dist/scheduler/task-board.js +9 -3
  1049. package/dist/scheduler/task-board.js.map +1 -1
  1050. package/dist/scheduler/task-liveness.d.ts +34 -0
  1051. package/dist/scheduler/task-liveness.js +49 -0
  1052. package/dist/scheduler/task-liveness.js.map +1 -0
  1053. package/dist/selection-card.d.ts +4 -3
  1054. package/dist/selection-card.js +2 -1
  1055. package/dist/selection-card.js.map +1 -1
  1056. package/dist/service-drain.d.ts +19 -0
  1057. package/dist/service-drain.js +64 -0
  1058. package/dist/service-drain.js.map +1 -0
  1059. package/dist/service-installer.d.ts +7 -2
  1060. package/dist/service-installer.js +24 -12
  1061. package/dist/service-installer.js.map +1 -1
  1062. package/dist/settings-api.d.ts +37 -2
  1063. package/dist/settings-api.js +866 -12
  1064. package/dist/settings-api.js.map +1 -1
  1065. package/dist/settings-baseline.d.ts +7 -0
  1066. package/dist/settings-baseline.js +3 -1
  1067. package/dist/settings-baseline.js.map +1 -1
  1068. package/dist/settings-change.d.ts +7 -3
  1069. package/dist/settings-change.js +128 -30
  1070. package/dist/settings-change.js.map +1 -1
  1071. package/dist/settings-confirmation.d.ts +67 -7
  1072. package/dist/settings-confirmation.js +68 -15
  1073. package/dist/settings-confirmation.js.map +1 -1
  1074. package/dist/settings-effect.d.ts +26 -0
  1075. package/dist/settings-effect.js +317 -5
  1076. package/dist/settings-effect.js.map +1 -1
  1077. package/dist/settings-http-confirmation.d.ts +37 -0
  1078. package/dist/settings-http-confirmation.js +162 -15
  1079. package/dist/settings-http-confirmation.js.map +1 -1
  1080. package/dist/settings-request-capability.d.ts +14 -0
  1081. package/dist/settings-request-capability.js +12 -1
  1082. package/dist/settings-request-capability.js.map +1 -1
  1083. package/dist/settings-route-lifetime.d.ts +14 -0
  1084. package/dist/settings-route-lifetime.js +48 -0
  1085. package/dist/settings-route-lifetime.js.map +1 -0
  1086. package/dist/settings-summary.d.ts +24 -0
  1087. package/dist/settings-summary.js +42 -0
  1088. package/dist/settings-summary.js.map +1 -0
  1089. package/dist/settings-transaction.d.ts +4 -0
  1090. package/dist/settings-transaction.js +9 -0
  1091. package/dist/settings-transaction.js.map +1 -1
  1092. package/dist/setup-form.js +6 -3
  1093. package/dist/setup-form.js.map +1 -1
  1094. package/dist/setup-host.js +1 -1
  1095. package/dist/setup-host.js.map +1 -1
  1096. package/dist/setup-i18n.js +3 -0
  1097. package/dist/setup-i18n.js.map +1 -1
  1098. package/dist/setup-wizard.js +4 -2
  1099. package/dist/setup-wizard.js.map +1 -1
  1100. package/dist/signin-keepalive.d.ts +206 -0
  1101. package/dist/signin-keepalive.js +681 -0
  1102. package/dist/signin-keepalive.js.map +1 -0
  1103. package/dist/structured-signin-transport.d.ts +20 -2
  1104. package/dist/structured-signin-transport.js +57 -2
  1105. package/dist/structured-signin-transport.js.map +1 -1
  1106. package/dist/structured-signin.d.ts +11 -2
  1107. package/dist/structured-signin.js +5 -7
  1108. package/dist/structured-signin.js.map +1 -1
  1109. package/dist/task-board-tool.d.ts +2 -1
  1110. package/dist/task-board-tool.js +76 -7
  1111. package/dist/task-board-tool.js.map +1 -1
  1112. package/dist/tmux-binary.d.ts +59 -0
  1113. package/dist/tmux-binary.js +189 -0
  1114. package/dist/tmux-binary.js.map +1 -0
  1115. package/dist/tmux-control.d.ts +2 -1
  1116. package/dist/tmux-control.js +4 -4
  1117. package/dist/tmux-control.js.map +1 -1
  1118. package/dist/tmux-exec-helper.js +32 -1
  1119. package/dist/tmux-exec-helper.js.map +1 -1
  1120. package/dist/tmux-legacy.d.ts +94 -0
  1121. package/dist/tmux-legacy.js +309 -0
  1122. package/dist/tmux-legacy.js.map +1 -0
  1123. package/dist/tmux-manager.d.ts +11 -4
  1124. package/dist/tmux-manager.js +61 -40
  1125. package/dist/tmux-manager.js.map +1 -1
  1126. package/dist/tmux-pane-host.d.ts +26 -0
  1127. package/dist/tmux-pane-host.js +25 -0
  1128. package/dist/tmux-pane-host.js.map +1 -0
  1129. package/dist/tmux-read.js +4 -3
  1130. package/dist/tmux-read.js.map +1 -1
  1131. package/dist/tmux-rollback.d.ts +42 -0
  1132. package/dist/tmux-rollback.js +78 -0
  1133. package/dist/tmux-rollback.js.map +1 -0
  1134. package/dist/tmux-server.d.ts +102 -0
  1135. package/dist/tmux-server.js +248 -0
  1136. package/dist/tmux-server.js.map +1 -0
  1137. package/dist/tool-permissions.js +2 -1
  1138. package/dist/tool-permissions.js.map +1 -1
  1139. package/dist/topic-commands.js +9 -5
  1140. package/dist/topic-commands.js.map +1 -1
  1141. package/dist/transcript-delta-reader.d.ts +10 -2
  1142. package/dist/transcript-delta-reader.js +38 -9
  1143. package/dist/transcript-delta-reader.js.map +1 -1
  1144. package/dist/transcript-monitor.d.ts +3 -0
  1145. package/dist/transcript-monitor.js +68 -54
  1146. package/dist/transcript-monitor.js.map +1 -1
  1147. package/dist/transcript-needles.d.ts +42 -0
  1148. package/dist/transcript-needles.js +166 -0
  1149. package/dist/transcript-needles.js.map +1 -0
  1150. package/dist/transcript-records.d.ts +22 -0
  1151. package/dist/transcript-records.js +144 -0
  1152. package/dist/transcript-records.js.map +1 -0
  1153. package/dist/transcript-sources.d.ts +5 -0
  1154. package/dist/transcript-sources.js +11 -79
  1155. package/dist/transcript-sources.js.map +1 -1
  1156. package/dist/types.d.ts +39 -0
  1157. package/dist/ui/account-identity.js +29 -0
  1158. package/dist/ui/accounts-keepalive.js +111 -0
  1159. package/dist/ui/accounts-manage.js +256 -0
  1160. package/dist/ui/accounts-view.js +481 -0
  1161. package/dist/ui/agent-details-settings.js +326 -0
  1162. package/dist/ui/agent-export-dialog.js +170 -0
  1163. package/dist/ui/agent-export-strings.js +81 -0
  1164. package/dist/ui/agent-instructions-field.js +69 -0
  1165. package/dist/ui/agent-page-strings.js +148 -0
  1166. package/dist/ui/agent-proposals.js +90 -0
  1167. package/dist/ui/agent-runtime-settings.js +70 -0
  1168. package/dist/ui/agent-runtime.js +124 -0
  1169. package/dist/ui/backend-signin.js +109 -37
  1170. package/dist/ui/chat-ambient.js +1 -1
  1171. package/dist/ui/chat-md-strings.js +3 -9
  1172. package/dist/ui/chat-quote.js +20 -17
  1173. package/dist/ui/chat-render.js +3 -682
  1174. package/dist/ui/chat-store.js +39 -7
  1175. package/dist/ui/chat-strings.js +3 -285
  1176. package/dist/ui/chat-thread.js +3 -969
  1177. package/dist/ui/chat-time.js +3 -80
  1178. package/dist/ui/chat-tour.js +2 -2
  1179. package/dist/ui/chat-workspace-navigation.js +125 -0
  1180. package/dist/ui/chat-workspace.js +255 -0
  1181. package/dist/ui/cli-caps.js +15 -0
  1182. package/dist/ui/cli-picker.js +42 -0
  1183. package/dist/ui/credential-profile-select.js +54 -0
  1184. package/dist/ui/effort-field-strings.js +18 -0
  1185. package/dist/ui/fleet-office-dialogue.d.ts +30 -0
  1186. package/dist/ui/fleet-office-dialogue.js +382 -0
  1187. package/dist/ui/fleet-office-levels.js +17 -1
  1188. package/dist/ui/fleet-office-pack.d.ts +19 -1
  1189. package/dist/ui/fleet-office-pack.js +177 -24
  1190. package/dist/ui/fleet-office-skin.js +23 -5
  1191. package/dist/ui/fleet-office-store.js +13 -3
  1192. package/dist/ui/fleet-office-zones.js +124 -9
  1193. package/dist/ui/fleet-office.js +203 -19
  1194. package/dist/ui/fleet-task-card.js +8 -4
  1195. package/dist/ui/fleet-task-common.js +2 -2
  1196. package/dist/ui/fleet-task-menu.js +188 -0
  1197. package/dist/ui/fleet-task-stats.js +124 -0
  1198. package/dist/ui/fleet-task-view.js +340 -0
  1199. package/dist/ui/fleet-tasks.js +125 -39
  1200. package/dist/ui/general-location.js +85 -0
  1201. package/dist/ui/host-install.js +290 -0
  1202. package/dist/ui/html-attachment.js +3 -40
  1203. package/dist/ui/hub-agent-copy.js +23 -0
  1204. package/dist/ui/hub-attachments.js +90 -0
  1205. package/dist/ui/hub-button-actions.js +65 -0
  1206. package/dist/ui/hub-chat-store.js +168 -0
  1207. package/dist/ui/hub-chat-strings.js +79 -0
  1208. package/dist/ui/hub-client.js +410 -0
  1209. package/dist/ui/hub-company-join-strings.js +77 -0
  1210. package/dist/ui/hub-company-join.js +165 -0
  1211. package/dist/ui/hub-directory-editor-strings.js +56 -0
  1212. package/dist/ui/hub-directory-editor.js +163 -0
  1213. package/dist/ui/hub-directory-notice-strings.js +28 -0
  1214. package/dist/ui/hub-directory-notices.js +66 -0
  1215. package/dist/ui/hub-grant-strings.js +13 -0
  1216. package/dist/ui/hub-group-policy.js +183 -0
  1217. package/dist/ui/hub-group-strings.js +110 -0
  1218. package/dist/ui/hub-host-security-notices.js +28 -0
  1219. package/dist/ui/hub-join-one-strings.js +131 -0
  1220. package/dist/ui/hub-owner-strings.js +56 -0
  1221. package/dist/ui/hub-pairing-progress-strings.js +15 -0
  1222. package/dist/ui/hub-preview.js +101 -0
  1223. package/dist/ui/hub-provider-guidance.js +31 -0
  1224. package/dist/ui/hub-quick-pairing.js +209 -0
  1225. package/dist/ui/hub-quick-strings.js +43 -0
  1226. package/dist/ui/hub-quota.js +85 -0
  1227. package/dist/ui/hub-read-strings.js +7 -0
  1228. package/dist/ui/hub-strings.js +168 -0
  1229. package/dist/ui/hub-switcher.js +27 -0
  1230. package/dist/ui/hub-this-hub.js +113 -0
  1231. package/dist/ui/hub-welcome.js +102 -0
  1232. package/dist/ui/image-lightbox.js +11 -3
  1233. package/dist/ui/machine-signin.js +56 -0
  1234. package/dist/ui/model-picker.js +18 -14
  1235. package/dist/ui/native-instance-settings.js +81 -0
  1236. package/dist/ui/native-pane-recovery.js +45 -0
  1237. package/dist/ui/office-share-page.js +4 -2
  1238. package/dist/ui/panel-chat.js +245 -116
  1239. package/dist/ui/panel-details.js +46 -17
  1240. package/dist/ui/panel-fleet.js +113 -20
  1241. package/dist/ui/panel-hub.js +974 -0
  1242. package/dist/ui/panel-log.js +9 -6
  1243. package/dist/ui/panel-needs.js +175 -9
  1244. package/dist/ui/panel-runtimes.js +645 -0
  1245. package/dist/ui/panel-settings.js +325 -213
  1246. package/dist/ui/panel-windows-agent.js +87 -0
  1247. package/dist/ui/panel-windows-cli.js +189 -0
  1248. package/dist/ui/preview-pages.js +3 -41
  1249. package/dist/ui/preview-panel-actions.js +3 -161
  1250. package/dist/ui/preview-panel.js +11 -550
  1251. package/dist/ui/preview-versions.js +3 -155
  1252. package/dist/ui/preview.js +3 -476
  1253. package/dist/ui/provider-marks.js +83 -0
  1254. package/dist/ui/runtime-catalog.js +55 -0
  1255. package/dist/ui/runtime-cli-install.js +214 -0
  1256. package/dist/ui/runtime-commands.d.ts +6 -0
  1257. package/dist/ui/runtime-commands.js +92 -0
  1258. package/dist/ui/runtime-update-commands.d.ts +2 -0
  1259. package/dist/ui/runtime-update-commands.js +11 -0
  1260. package/dist/ui/runtime-update-status.js +53 -0
  1261. package/dist/ui/search-dialog.js +3 -0
  1262. package/dist/ui/settings-access-overview.js +188 -0
  1263. package/dist/ui/settings-access-strings.js +42 -0
  1264. package/dist/ui/settings-agent-filters.js +94 -0
  1265. package/dist/ui/settings-appearance.js +122 -23
  1266. package/dist/ui/settings-apply.js +12 -5
  1267. package/dist/ui/settings-build-version.js +35 -0
  1268. package/dist/ui/settings-catalog.js +68 -16
  1269. package/dist/ui/settings-confirm.js +112 -14
  1270. package/dist/ui/settings-devices.js +283 -0
  1271. package/dist/ui/settings-dialogs.js +360 -140
  1272. package/dist/ui/settings-guests.js +25 -11
  1273. package/dist/ui/settings-hub-browser-certificate.js +76 -0
  1274. package/dist/ui/settings-hub-company-join.js +270 -0
  1275. package/dist/ui/settings-hub-connection.js +172 -0
  1276. package/dist/ui/settings-hub-directory.js +29 -0
  1277. package/dist/ui/settings-hub-membership.js +93 -0
  1278. package/dist/ui/settings-hub-preview.js +74 -0
  1279. package/dist/ui/settings-hub-retention.js +54 -0
  1280. package/dist/ui/settings-hub-run.js +61 -0
  1281. package/dist/ui/settings-hub-section.js +67 -0
  1282. package/dist/ui/settings-hub-setup-strings.js +70 -0
  1283. package/dist/ui/settings-hub-setup.js +195 -0
  1284. package/dist/ui/settings-hub.js +276 -0
  1285. package/dist/ui/settings-layout.js +246 -0
  1286. package/dist/ui/settings-level-titles.js +73 -0
  1287. package/dist/ui/settings-model.js +26 -2
  1288. package/dist/ui/settings-named-test.js +2 -2
  1289. package/dist/ui/settings-outside.js +310 -0
  1290. package/dist/ui/settings-quota-notice.js +3 -3
  1291. package/dist/ui/settings-registry.js +26 -5
  1292. package/dist/ui/settings-restart-strings.js +17 -0
  1293. package/dist/ui/settings-revoke-strings.js +28 -0
  1294. package/dist/ui/settings-shared-strings.js +161 -0
  1295. package/dist/ui/settings-shared.js +354 -0
  1296. package/dist/ui/settings-shortcuts.js +65 -0
  1297. package/dist/ui/settings-strings.js +127 -46
  1298. package/dist/ui/settings-web-authority.js +27 -14
  1299. package/dist/ui/shared/access-overview.css +48 -0
  1300. package/dist/ui/shared/accounts-keepalive.css +12 -0
  1301. package/dist/ui/shared/accounts.css +88 -0
  1302. package/dist/ui/shared/agend-auth.js +8 -1
  1303. package/dist/ui/shared/app-ctx.js +22 -1
  1304. package/dist/ui/shared/app-i18n.js +17 -16
  1305. package/dist/ui/shared/app-nav.js +34 -11
  1306. package/dist/ui/shared/app-route.js +12 -3
  1307. package/dist/ui/shared/app-session.js +17 -12
  1308. package/dist/ui/shared/app-shell.js +454 -55
  1309. package/dist/ui/shared/app-store.js +3 -0
  1310. package/dist/ui/shared/app-stream.js +3 -1
  1311. package/dist/ui/shared/app.css +1586 -10
  1312. package/dist/ui/shared/app.js +28 -3
  1313. package/dist/ui/shared/chat-composer.js +74 -0
  1314. package/dist/ui/shared/chat-md-strings.js +9 -0
  1315. package/dist/ui/shared/chat-render.js +694 -0
  1316. package/dist/ui/shared/chat-strings.js +333 -0
  1317. package/dist/ui/shared/chat-thread.js +969 -0
  1318. package/dist/ui/shared/chat-time.js +80 -0
  1319. package/dist/ui/shared/chat-work-bar.css +5 -0
  1320. package/dist/ui/shared/chat-workspace-memory.js +14 -0
  1321. package/dist/ui/shared/chat-workspace-model.js +76 -0
  1322. package/dist/ui/shared/device-roles.js +27 -0
  1323. package/dist/ui/shared/header-tools.js +9 -9
  1324. package/dist/ui/shared/host-install.css +10 -0
  1325. package/dist/ui/shared/html-attachment.js +42 -0
  1326. package/dist/ui/shared/hub-chat.css +98 -0
  1327. package/dist/ui/shared/hub-groups.css +28 -0
  1328. package/dist/ui/shared/hub-owner.css +57 -0
  1329. package/dist/ui/shared/hub-quota.css +8 -0
  1330. package/dist/ui/shared/hub-signin.css +24 -0
  1331. package/dist/ui/shared/hub.css +78 -0
  1332. package/dist/ui/shared/instance-nav.js +44 -8
  1333. package/dist/ui/shared/instance-switch.js +12 -4
  1334. package/dist/ui/shared/machine-name.js +13 -0
  1335. package/dist/ui/shared/model-picker.css +13 -1
  1336. package/dist/ui/shared/page-head.js +8 -0
  1337. package/dist/ui/shared/panel-view.js +39 -26
  1338. package/dist/ui/shared/preview-pages.js +41 -0
  1339. package/dist/ui/shared/preview-panel-actions.js +168 -0
  1340. package/dist/ui/shared/preview-panel.js +576 -0
  1341. package/dist/ui/shared/preview-versions.js +155 -0
  1342. package/dist/ui/shared/preview.js +476 -0
  1343. package/dist/ui/shared/qrcode.module.js +2237 -0
  1344. package/dist/ui/shared/runtime-install.css +55 -0
  1345. package/dist/ui/shared/settings-width.js +31 -0
  1346. package/dist/ui/shared/side-rail.js +15 -0
  1347. package/dist/ui/shared/signin.js +392 -34
  1348. package/dist/ui/shared/task-board.css +95 -0
  1349. package/dist/ui/shared/tokens.css +1 -0
  1350. package/dist/ui/shared/ui-dialog.js +2 -2
  1351. package/dist/ui/shared/ui-menu.js +36 -10
  1352. package/dist/ui/shared/usage-dialog.js +3 -72
  1353. package/dist/ui/shared/usage-meter.js +84 -0
  1354. package/dist/ui/shared/vendor/qrcode-generator.LICENSE +27 -0
  1355. package/dist/ui/shared/vendor/vendor.json +19 -2
  1356. package/dist/ui/shared/view-roster-store.js +8 -0
  1357. package/dist/ui/shared/view-strings.js +14 -4
  1358. package/dist/ui/shared/web-authorize.js +53 -3
  1359. package/dist/ui/shared/workspace-follow.css +19 -0
  1360. package/dist/ui/shared/workspace.css +20 -0
  1361. package/dist/ui/signin.html +41 -8
  1362. package/dist/ui/structured-signin.js +67 -17
  1363. package/dist/ui/windows-agents-nav.js +2 -0
  1364. package/dist/ui/windows-cli-catalog.js +108 -0
  1365. package/dist/ui/workspace-follow-strings.js +28 -0
  1366. package/dist/ui/workspace-panel.js +378 -0
  1367. package/dist/ui/workspace-strings.js +35 -0
  1368. package/dist/unattended-install.js +2 -1
  1369. package/dist/unattended-install.js.map +1 -1
  1370. package/dist/update-dispatch.d.ts +62 -0
  1371. package/dist/update-dispatch.js +69 -2
  1372. package/dist/update-dispatch.js.map +1 -1
  1373. package/dist/update-install.d.ts +7 -0
  1374. package/dist/update-install.js +23 -0
  1375. package/dist/update-install.js.map +1 -1
  1376. package/dist/update-marker.d.ts +2 -0
  1377. package/dist/update-marker.js.map +1 -1
  1378. package/dist/usage/providers.d.ts +2 -0
  1379. package/dist/usage/providers.js +20 -19
  1380. package/dist/usage/providers.js.map +1 -1
  1381. package/dist/usage/usage-api.d.ts +1 -1
  1382. package/dist/usage/usage-api.js +3 -10
  1383. package/dist/usage/usage-api.js.map +1 -1
  1384. package/dist/view-api.js +5 -7
  1385. package/dist/view-api.js.map +1 -1
  1386. package/dist/web-api.d.ts +167 -4
  1387. package/dist/web-api.js +1579 -266
  1388. package/dist/web-api.js.map +1 -1
  1389. package/dist/web-backend-login.d.ts +41 -3
  1390. package/dist/web-backend-login.js +25 -17
  1391. package/dist/web-backend-login.js.map +1 -1
  1392. package/dist/web-chat-history.d.ts +19 -2
  1393. package/dist/web-chat-history.js +72 -3
  1394. package/dist/web-chat-history.js.map +1 -1
  1395. package/dist/web-commands.d.ts +10 -1
  1396. package/dist/web-commands.js +1 -1
  1397. package/dist/web-commands.js.map +1 -1
  1398. package/dist/web-device-login.d.ts +153 -0
  1399. package/dist/web-device-login.js +278 -0
  1400. package/dist/web-device-login.js.map +1 -0
  1401. package/dist/web-host-install.d.ts +127 -0
  1402. package/dist/web-host-install.js +165 -0
  1403. package/dist/web-host-install.js.map +1 -0
  1404. package/dist/web-login.d.ts +35 -1
  1405. package/dist/web-login.js +51 -5
  1406. package/dist/web-login.js.map +1 -1
  1407. package/dist/web-model-groups.d.ts +40 -0
  1408. package/dist/web-model-groups.js +70 -0
  1409. package/dist/web-model-groups.js.map +1 -0
  1410. package/dist/web-notices.d.ts +9 -0
  1411. package/dist/web-notices.js +19 -0
  1412. package/dist/web-notices.js.map +1 -1
  1413. package/dist/web-office-skins.d.ts +9 -0
  1414. package/dist/web-office-skins.js +16 -1
  1415. package/dist/web-office-skins.js.map +1 -1
  1416. package/dist/web-office-store.d.ts +35 -2
  1417. package/dist/web-office-store.js +64 -15
  1418. package/dist/web-office-store.js.map +1 -1
  1419. package/dist/web-only-fleet.d.ts +20 -0
  1420. package/dist/web-only-fleet.js +21 -0
  1421. package/dist/web-only-fleet.js.map +1 -1
  1422. package/dist/web-remote-access.d.ts +341 -0
  1423. package/dist/web-remote-access.js +801 -0
  1424. package/dist/web-remote-access.js.map +1 -0
  1425. package/dist/web-session.d.ts +63 -0
  1426. package/dist/web-session.js +50 -1
  1427. package/dist/web-session.js.map +1 -1
  1428. package/dist/web-settings-patch.d.ts +3 -1
  1429. package/dist/web-settings-patch.js +4 -1
  1430. package/dist/web-settings-patch.js.map +1 -1
  1431. package/dist/web-shell-routes.d.ts +10 -1
  1432. package/dist/web-shell-routes.js +14 -2
  1433. package/dist/web-shell-routes.js.map +1 -1
  1434. package/dist/web-signin-device.d.ts +16 -0
  1435. package/dist/web-signin-device.js +81 -0
  1436. package/dist/web-signin-device.js.map +1 -0
  1437. package/dist/web-signin-link.d.ts +42 -0
  1438. package/dist/web-signin-link.js +110 -0
  1439. package/dist/web-signin-link.js.map +1 -0
  1440. package/dist/web-terminal.d.ts +11 -30
  1441. package/dist/web-terminal.js +23 -8
  1442. package/dist/web-terminal.js.map +1 -1
  1443. package/dist/web-update.d.ts +1 -0
  1444. package/dist/web-update.js +4 -2
  1445. package/dist/web-update.js.map +1 -1
  1446. package/dist/windows-agents.d.ts +127 -0
  1447. package/dist/windows-agents.js +491 -0
  1448. package/dist/windows-agents.js.map +1 -0
  1449. package/dist/windows-cli-api.d.ts +48 -0
  1450. package/dist/windows-cli-api.js +207 -0
  1451. package/dist/windows-cli-api.js.map +1 -0
  1452. package/dist/windows-cli-providers.d.ts +109 -0
  1453. package/dist/windows-cli-providers.js +396 -0
  1454. package/dist/windows-cli-providers.js.map +1 -0
  1455. package/dist/windows-cli-worker.d.ts +99 -0
  1456. package/dist/windows-cli-worker.js +729 -0
  1457. package/dist/windows-cli-worker.js.map +1 -0
  1458. package/dist/windows-cli.d.ts +130 -0
  1459. package/dist/windows-cli.js +424 -0
  1460. package/dist/windows-cli.js.map +1 -0
  1461. package/dist/windows-native-mcp.d.ts +19 -0
  1462. package/dist/windows-native-mcp.js +143 -0
  1463. package/dist/windows-native-mcp.js.map +1 -0
  1464. package/dist/windows-pane-mcp.d.ts +26 -0
  1465. package/dist/windows-pane-mcp.js +187 -0
  1466. package/dist/windows-pane-mcp.js.map +1 -0
  1467. package/dist/windows-shortcuts.d.ts +29 -5
  1468. package/dist/windows-shortcuts.js +52 -9
  1469. package/dist/windows-shortcuts.js.map +1 -1
  1470. package/dist/workspace-file-policy.d.ts +2 -0
  1471. package/dist/workspace-file-policy.js +31 -0
  1472. package/dist/workspace-file-policy.js.map +1 -0
  1473. package/dist/workspace-follow-parse.d.ts +36 -0
  1474. package/dist/workspace-follow-parse.js +208 -0
  1475. package/dist/workspace-follow-parse.js.map +1 -0
  1476. package/dist/workspace-follow-records.d.ts +17 -0
  1477. package/dist/workspace-follow-records.js +88 -0
  1478. package/dist/workspace-follow-records.js.map +1 -0
  1479. package/dist/workspace-follow.d.ts +41 -0
  1480. package/dist/workspace-follow.js +144 -0
  1481. package/dist/workspace-follow.js.map +1 -0
  1482. package/dist/wsl-detect.d.ts +1 -0
  1483. package/dist/wsl-detect.js +20 -0
  1484. package/dist/wsl-detect.js.map +1 -0
  1485. package/dist/yaml-shared-nodes.js +8 -3
  1486. package/dist/yaml-shared-nodes.js.map +1 -1
  1487. package/launcher/agend-install.cjs +15 -2
  1488. package/launcher/launchd-session-type.cjs +14 -0
  1489. package/launcher/postinstall.cjs +27 -2
  1490. package/launcher/tmux-bundle.cjs +263 -0
  1491. package/package.json +16 -5
  1492. package/templates/icons/agend-restart.ico +0 -0
  1493. package/templates/icons/agend.ico +0 -0
  1494. package/templates/launchd.plist.ejs +3 -1
  1495. package/templates/runtime-assets/conpty-LICENSE +21 -0
  1496. package/templates/runtime-assets/conpty-NOTICE.md +503 -0
  1497. package/templates/runtime-assets/local-pane-stage.ps1 +101 -0
  1498. package/templates/runtime-assets/runtime-pane-job.ps1 +116 -0
  1499. package/templates/runtime-assets/runtime-pane-private.ps1 +81 -0
  1500. package/templates/runtime-assets/xterm-LICENSE +21 -0
  1501. package/templates/runtime-install/install.ps1 +618 -0
  1502. package/templates/windows-shortcuts.ps1 +45 -12
package/dist/web-api.js CHANGED
@@ -1,11 +1,15 @@
1
+ import { buildAgentExport, parseAgentExport } from "./agent-export.js";
2
+ import { hubModeOf, hubNameOf } from "./hub-mode.js";
3
+ import { validCredentialProfileName } from "./runtime-credential-profiles.js";
1
4
  import { CANVAS_WORKER_EXPERIMENTAL_MESSAGE } from "./web-experimental.js";
5
+ import { MachineSlotLimitError } from "./windows-agents.js";
2
6
  import { daemonTopicMode } from "./web-only-fleet.js";
3
7
  import { webHumanOrigin } from "./human-delivery-receipts.js";
4
8
  import { classifyWebPeer, confirmAfterBody, noAuthority } from "./authority/web-authority.js";
5
9
  import { guestChatRefusal, guestCommandText, guestDeliveries, GUEST_PREF_MAX_BYTES, GUEST_SEARCHES, guestFrameData, guestHistory, guestMessages, guestOwnPrefs, guestPollBody, guestPrefs, guestRequestOf, guestSeesMessage, guestStatus } from "./web-guest-access.js";
6
10
  import { withSpawnHoldReply } from "./spawn-hold-reply.js";
7
11
  import { binaryProbe } from "./binary-probe.js";
8
- import { settingsRequestExecution, settingsWrite, isSettingsReplay } from "./settings-request-capability.js";
12
+ import { settingsRequestExecution, settingsRequestLocalAdmin, settingsRequestRequester, settingsWrite, isSettingsReplay } from "./settings-request-capability.js";
9
13
  import { readBoundedWebBody } from "./web-body.js";
10
14
  import { APP_ICON_MAX_BYTES } from "./web-app-icon.js";
11
15
  import { withAppIconLinks } from "./web-icons.js";
@@ -18,6 +22,9 @@ import { SKIN_WIRE_BYTES } from "./web-office-skins.js";
18
22
  import { gatewayRequestContext } from "./web-request-context.js";
19
23
  import { crossInstanceVisibility } from "./cross-instance-notice.js";
20
24
  import { permitWebContinuation } from "./web-continuation.js";
25
+ import { HOST_CLI_PATHS, isRuntimeCliInstallPath } from "./settings-effect.js";
26
+ import { hostUpdateAckError } from "./web-host-install.js";
27
+ import { LATEST_ACK_FIELD } from "./cli-audited.js";
21
28
  /**
22
29
  * Web UI HTTP API handler.
23
30
  * All /ui/* routes are handled here, extracted from fleet-manager.ts.
@@ -32,18 +39,24 @@ import { shellRoute } from "./web-shell-routes.js";
32
39
  import { createReadStream, createWriteStream, readFileSync } from "node:fs";
33
40
  import { join, dirname } from "node:path";
34
41
  import { fileURLToPath } from "node:url";
42
+ import { createHash, createHmac, randomUUID } from "node:crypto";
35
43
  import { CreateInstanceArgs, CreateScheduleArgs, UpdateScheduleArgs, validateArgs } from "./outbound-schemas.js";
36
44
  import { scheduleView } from "./web-schedules.js";
37
45
  import { DEFAULT_SCHEDULER_CONFIG } from "./scheduler/index.js";
38
46
  import { CARD_PRIORITIES, CARD_SIZES, CARD_STATUSES, TaskBoardError } from "./scheduler/task-board.js";
39
47
  import { readStatuslineModel, resolveInstanceContext } from "./topic-commands.js";
40
48
  import { z } from "zod";
49
+ import { ONBOARDING_BACKENDS, ONBOARDING_BROWSER_BACKENDS } from "./backend-signin-pending.js";
41
50
  import { evaluateWebRequest, isPassiveWebRead, isSecureRequest, isWebRequestAuthorized, WEB_TOKEN_INVALID_MESSAGE } from "./web-auth.js";
42
51
  import { dashboardOriginFor } from "./web-preview.js";
43
52
  import { WEB_CHAT_CARDS_OVERFLOW, catchUpWindow, newWebMessageId, parseLastEventId, webChatReplyRef, webChatReplyText } from "./web-chat-history.js";
44
53
  import { PAGE_SHARE_LIMITS, htmlFences, htmlTitle } from "./page-share.js";
45
54
  import { attachmentDelivery, createPartFile, displayName, fileTooLargeText, INLINE_MIME, isFileId, MEDIA_RANGE_MAX, publicAttachment, UPLOAD_LIMITS, UPLOAD_MAX_MS, UPLOAD_STALL_MS, UploadSniffer, uploadLimits, wellFormed } from "./web-upload.js";
46
55
  import { getAgendHome } from "./paths.js";
56
+ import { workspaceChanges, workspaceFile, workspaceFileDiff, workspaceImage, workspaceList, workspaceRoot, WorkspaceError } from "./agent-workspace.js";
57
+ import { resolveFollowSteps } from "./workspace-follow.js";
58
+ import { isGeneralInstance } from "./general-instance.js";
59
+ import { resolveToolSet } from "./tool-permissions.js";
47
60
  import { OPERATOR, isOwnerEffectKey } from "./web-prefs.js";
48
61
  import { WEB_NAME_FALLBACK, webPersonKey } from "./web-profile.js";
49
62
  import { commitTeamCreate, commitTeamUpdate } from "./outbound-handlers.js";
@@ -54,6 +67,15 @@ import { resolveTz } from "./tz-utils.js";
54
67
  import { QUERY_MAX_CHARS, RESULT_MAX, SEARCH_SOURCES } from "./search/search-store.js";
55
68
  import { xmsgShown } from "./search/search-docs.js";
56
69
  import { WebSendDedupe } from "./web-send-dedupe.js";
70
+ import { handleWindowsCliRequest, nativeCliAuthorization } from "./windows-cli-api.js";
71
+ import { resolveCreateAccount } from "./create-host-account.js";
72
+ import { createNativeInstance, handleNativeInstanceRequest } from "./native-instance-api.js";
73
+ import { handleAgentRuntimeChange } from "./agent-runtime-api.js";
74
+ import { isWindowsInstance, isNativePaneInstance, isNativeExecInstance } from "./native-instance-registry.js";
75
+ import { handleNativeModelCatalog, refreshNativeModelCatalog } from "./native-model-catalog.js";
76
+ import { claudeDocumentedModels } from "./model-catalog-defaults.js";
77
+ import { shapeDocumentedClaudeModels, shapeWebModelCatalog } from "./web-model-groups.js";
78
+ import { handleRuntimeRequest } from "./runtime-api.js";
57
79
  import { taskBoardOffNames } from "./dashboard-permissions.js";
58
80
  import { topicFields } from "./instance-topic-delete.js";
59
81
  // ── Strict public-facing schemas ────────────────────────────────────────────
@@ -234,8 +256,10 @@ function visibleNeeds(ctx, gateway, items) {
234
256
  const { hidden } = boardHiding(ctx, true);
235
257
  return items.filter((i) => {
236
258
  const item = i;
237
- if (item.type === "config")
238
- return false; // private operator configuration diagnostics never cross a public link
259
+ if (item.type === "config" || item.type === "hub")
260
+ return false; // member-local diagnostics/proposals never cross a public link
261
+ if (item.type === "runtime")
262
+ return false;
239
263
  if (item.type !== "task")
240
264
  return true;
241
265
  const code = item.card?.code;
@@ -339,6 +363,21 @@ function jsonText(res, status, body) {
339
363
  const boardBodies = new WeakMap();
340
364
  /** #2316 review: the same for who works on what (GET /ui/tasks/work), per (revision, names asked for). */
341
365
  const workBodies = new WeakMap();
366
+ /**
367
+ * The catalog Web Settings lists for a backend and instance (and credential profile): the fleet's shaped cache
368
+ * (web-model-groups.ts), else — a hand-built context — the plain list, shaped the same way.
369
+ */
370
+ function webCatalog(ctx, backend, instance, profile, plain) {
371
+ if (ctx.modelCatalogForWeb)
372
+ return profile !== null ? ctx.modelCatalogForWeb(backend, instance, { profile }) : ctx.modelCatalogForWeb(backend, instance);
373
+ const flat = plain ?? (profile !== null ? ctx.modelCatalogFor?.(backend, instance, { profile }) : ctx.modelCatalogFor?.(backend, instance)) ?? [];
374
+ return shapeWebModelCatalog(backend, flat);
375
+ }
376
+ /** claude's fallback when no account list is readable: the documentation's `claude-*` ids for the host's CLI version, unverified. */
377
+ function documentedClaudeCatalog(ctx) {
378
+ const version = ctx.backendAvailabilityRows?.().find(row => row.backend === "claude-code")?.version;
379
+ return shapeDocumentedClaudeModels(claudeDocumentedModels(version));
380
+ }
342
381
  /**
343
382
  * #1630 (#1635 review): an answer that waited on something (a list, a download) is sent only if the request is still
344
383
  * allowed — the session not revoked meanwhile, a public link's exposure still current. Otherwise 401, and nothing.
@@ -802,6 +841,76 @@ function handlePageShare(req, res, url, ctx, path, method) {
802
841
  });
803
842
  return true;
804
843
  }
844
+ /**
845
+ * #2716/#3679: an Office-wide setting kept in web-offices.json beside the offices (PUT { <key>: value }): who may save
846
+ * the offices may set it — an admin session, never the CLI token or the public link; asked again once the body is in;
847
+ * counted with the offices' saves (OfficeWriteLimiter); every page hears `offices` and reads again.
848
+ */
849
+ function officeSettingPut(req, res, url, ctx, o) {
850
+ const store = ctx.officeStore;
851
+ if (!store) {
852
+ json(res, 404, { error: "Offices are not kept on this fleet" });
853
+ return true;
854
+ }
855
+ if (gatewayRequestContext(req)) {
856
+ json(res, 403, { error: "offices_not_over_public_link" });
857
+ return true;
858
+ }
859
+ const who = () => {
860
+ const verdict = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
861
+ if (verdict.kind !== "allow")
862
+ return { status: 401 };
863
+ return verdict.via === "session" && verdict.session?.tier === "admin" ? { person: verdict.session.owner ? webPersonKey(verdict.session.owner) : "admin-session" } : { status: 403 };
864
+ };
865
+ const refuse = (status) => json(res, status, { error: status === 401 ? WEB_TOKEN_INVALID_MESSAGE : "offices_need_an_admin_session" });
866
+ const first = who();
867
+ if ("status" in first) {
868
+ refuse(first.status);
869
+ return true;
870
+ }
871
+ (async () => {
872
+ let body;
873
+ try {
874
+ body = await parseBody(req);
875
+ }
876
+ catch {
877
+ json(res, 400, { error: "Invalid JSON" });
878
+ return;
879
+ }
880
+ if (!permitWebContinuation(req, res, ctx))
881
+ return;
882
+ const now = who();
883
+ if ("status" in now) {
884
+ refuse(now.status);
885
+ return;
886
+ }
887
+ if (!body || typeof body !== "object" || Array.isArray(body) || !(o.key in body) || Object.keys(body).some(k => k !== o.key)) {
888
+ json(res, 400, { error: o.invalid, detail: o.shape });
889
+ return;
890
+ }
891
+ const limiter = ctx.officeWrites, allowed = limiter ? limiter.check(now.person) : { ok: true };
892
+ if (!allowed.ok) {
893
+ res.setHeader("Retry-After", String(allowed.retry_after_s));
894
+ json(res, 429, { error: "offices_rate_limited", retry_after_s: allowed.retry_after_s });
895
+ return;
896
+ }
897
+ const r = o.apply(store, body[o.key]);
898
+ if (!r.ok) {
899
+ json(res, r.status, { error: r.error, ...(r.detail ? { detail: r.detail } : {}) });
900
+ return;
901
+ }
902
+ limiter?.record(now.person);
903
+ ctx.emitSseEvent("offices", { rev: r.rev });
904
+ json(res, 200, { rev: r.rev, ...r.answer });
905
+ })().catch(err => {
906
+ ctx.logger.error({ err: err.message }, o.failed);
907
+ try {
908
+ json(res, 500, { error: o.failed });
909
+ }
910
+ catch { /* already answered */ }
911
+ });
912
+ return true;
913
+ }
805
914
  /**
806
915
  * #2513: the Office view's skin packs (web-office-skins.ts). The reads are the offices' (GET /ui/offices): whoever may
807
916
  * open the org chart, the public link too (its manifest lists them; a guest's routes do not): the list, a pack's
@@ -1223,18 +1332,142 @@ function handleBrowserBackendSignIns(req, res, url, ctx) {
1223
1332
  json(res, 403, { error: "sign_in_needs_a_local_admin" });
1224
1333
  return true;
1225
1334
  }
1226
- if (!["GET", "POST"].includes(req.method ?? "") || [...url.searchParams.keys()].length) {
1335
+ if (!["GET", "POST"].includes(req.method ?? "")) {
1227
1336
  json(res, 404, { error: "not_found" });
1228
1337
  return true;
1229
1338
  }
1230
- const service = ctx.browserBackendSignIns;
1231
- if (!service) {
1339
+ // #3190 Part 3c: `?machine=<id>&profile=<name>` addresses the same sign-in controls for a credential profile on a paired computer (machine-signins.ts). #3212:
1340
+ // `?backend=<cli>&profile=<name>` addresses them for a named account on THIS host (profile-signins.ts). Nothing else is accepted in the query, and both are checked
1341
+ // in full before anything else happens.
1342
+ const keys = [...url.searchParams.keys()];
1343
+ let target = null;
1344
+ let account = null;
1345
+ if (keys.length) {
1346
+ const machine = url.searchParams.get("machine"), backend = url.searchParams.get("backend"), profile = url.searchParams.get("profile");
1347
+ const shape = keys.length === 2 && new Set(keys).size === 2 && profile && validCredentialProfileName(profile);
1348
+ if (shape && machine && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(machine) && !backend)
1349
+ target = { machine, profile };
1350
+ else if (shape && backend === "claude-code" && !machine)
1351
+ account = { backend, profile };
1352
+ else {
1353
+ json(res, 404, { error: "not_found" });
1354
+ return true;
1355
+ }
1356
+ }
1357
+ // Only the one that is asked for is looked up: the host's creates its checklist state, a computer's or a named account's does not need it.
1358
+ const service = target || account ? undefined : ctx.browserBackendSignIns, machines = target ? ctx.machineSignIns : undefined, accounts = account ? ctx.profileSignIns : undefined;
1359
+ if (target ? !machines : account ? !accounts : !service) {
1232
1360
  json(res, 404, { error: "sign_in_unavailable" });
1233
1361
  return true;
1234
1362
  }
1235
1363
  void (async () => {
1236
1364
  let result;
1237
- if (reading)
1365
+ if (target && machines) {
1366
+ if (reading)
1367
+ result = machines.snapshot(owner, target);
1368
+ else {
1369
+ let bytes;
1370
+ try {
1371
+ bytes = await readBoundedWebBody(req, 8192);
1372
+ }
1373
+ catch {
1374
+ json(res, 413, { error: "sign_in_body_bound" });
1375
+ return;
1376
+ }
1377
+ if (!permitWebContinuation(req, res, ctx))
1378
+ return;
1379
+ if (who() !== owner) {
1380
+ json(res, 409, { error: "signin_session_expired" });
1381
+ return;
1382
+ }
1383
+ let body;
1384
+ try {
1385
+ body = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
1386
+ }
1387
+ catch {
1388
+ json(res, 400, { error: "sign_in_json" });
1389
+ return;
1390
+ }
1391
+ // Only what a computer's sign-in can do: start (Claude Code, subscription: the Runtime builds the command), answer a prompt, cancel, read again.
1392
+ const parsed = z.discriminatedUnion("operation", [
1393
+ z.strictObject({ operation: z.literal("start"), backend: z.literal("claude-code"), relogin: z.boolean().optional() }),
1394
+ z.strictObject({ operation: z.literal("input"), id: z.string().regex(/^[0-9a-f]{32}$/), revision: z.number().int().nonnegative(), action: z.discriminatedUnion("kind", [
1395
+ z.strictObject({ kind: z.literal("method"), choice: z.string().max(32) }),
1396
+ z.strictObject({ kind: z.enum(["code", "start_url", "region"]), value: z.string().max(4096) }),
1397
+ ]) }),
1398
+ z.strictObject({ operation: z.literal("cancel") }), z.strictObject({ operation: z.literal("refresh") }),
1399
+ ]).safeParse(body);
1400
+ if (!parsed.success) {
1401
+ json(res, 400, { error: "invalid_signin_action" });
1402
+ return;
1403
+ }
1404
+ const action = parsed.data;
1405
+ if (action.operation === "start")
1406
+ result = await machines.begin(owner, target, action.relogin === true);
1407
+ else if (action.operation === "input")
1408
+ result = await machines.input(owner, target, action.id, action.revision, action.action);
1409
+ else if (action.operation === "cancel")
1410
+ result = await machines.cancel(owner, target);
1411
+ else
1412
+ result = machines.snapshot(owner, target);
1413
+ }
1414
+ }
1415
+ else if (account && accounts) {
1416
+ if (reading)
1417
+ result = await accounts.refresh(owner, account);
1418
+ else {
1419
+ let bytes;
1420
+ try {
1421
+ bytes = await readBoundedWebBody(req, 8192);
1422
+ }
1423
+ catch {
1424
+ json(res, 413, { error: "sign_in_body_bound" });
1425
+ return;
1426
+ }
1427
+ if (!permitWebContinuation(req, res, ctx))
1428
+ return;
1429
+ if (who() !== owner) {
1430
+ json(res, 409, { error: "signin_session_expired" });
1431
+ return;
1432
+ }
1433
+ let body;
1434
+ try {
1435
+ body = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
1436
+ }
1437
+ catch {
1438
+ json(res, 400, { error: "sign_in_json" });
1439
+ return;
1440
+ }
1441
+ // The same controls as the default account's, for the one account in the address: start (its backend must be the address's), answer a prompt, cancel, read again.
1442
+ // No checklist here: no select, no skip.
1443
+ const parsed = z.discriminatedUnion("operation", [
1444
+ z.strictObject({ operation: z.literal("start"), backend: z.literal(account.backend), relogin: z.boolean().optional() }),
1445
+ z.strictObject({ operation: z.literal("input"), id: z.string().regex(/^[0-9a-f]{32}$/), revision: z.number().int().nonnegative(), action: z.discriminatedUnion("kind", [
1446
+ z.strictObject({ kind: z.literal("method"), choice: z.string().max(32) }),
1447
+ z.strictObject({ kind: z.enum(["code", "start_url", "region"]), value: z.string().max(4096) }),
1448
+ ]) }),
1449
+ z.strictObject({ operation: z.literal("cancel"), id: z.string().regex(/^[0-9a-f]{32}$/).optional() }), z.strictObject({ operation: z.literal("refresh") }),
1450
+ ]).safeParse(body);
1451
+ if (!parsed.success) {
1452
+ json(res, 400, { error: "invalid_signin_action" });
1453
+ return;
1454
+ }
1455
+ const action = parsed.data;
1456
+ if (action.operation === "start")
1457
+ result = await accounts.begin(owner, account, action.relogin === true);
1458
+ else if (action.operation === "input")
1459
+ result = await accounts.input(owner, account, action.id, action.revision, action.action);
1460
+ else if (action.operation === "cancel")
1461
+ result = await accounts.cancel(owner, account, action.id);
1462
+ else
1463
+ result = await accounts.refresh(owner, account, true);
1464
+ }
1465
+ }
1466
+ else if (!service) {
1467
+ json(res, 404, { error: "sign_in_unavailable" });
1468
+ return;
1469
+ }
1470
+ else if (reading)
1238
1471
  result = await service.refresh(owner);
1239
1472
  else {
1240
1473
  let bytes;
@@ -1260,13 +1493,13 @@ function handleBrowserBackendSignIns(req, res, url, ctx) {
1260
1493
  return;
1261
1494
  }
1262
1495
  const parsed = z.discriminatedUnion("operation", [
1263
- z.strictObject({ operation: z.literal("select"), backends: z.array(z.enum(["kiro-cli", "claude-code", "codex", "antigravity"])).max(4) }),
1264
- z.strictObject({ operation: z.literal("start"), backend: z.enum(["kiro-cli", "claude-code", "codex"]), relogin: z.boolean().optional() }),
1496
+ z.strictObject({ operation: z.literal("select"), backends: z.array(z.enum(ONBOARDING_BACKENDS)).max(ONBOARDING_BACKENDS.length) }),
1497
+ z.strictObject({ operation: z.literal("start"), backend: z.enum(ONBOARDING_BROWSER_BACKENDS), relogin: z.boolean().optional() }),
1265
1498
  z.strictObject({ operation: z.literal("input"), id: z.string().regex(/^[0-9a-f]{32}$/), revision: z.number().int().nonnegative(), action: z.discriminatedUnion("kind", [
1266
1499
  z.strictObject({ kind: z.literal("method"), choice: z.string().max(32) }),
1267
1500
  z.strictObject({ kind: z.enum(["code", "start_url", "region"]), value: z.string().max(4096) }),
1268
1501
  ]) }),
1269
- z.strictObject({ operation: z.literal("skip"), backend: z.enum(["kiro-cli", "claude-code", "codex", "antigravity"]) }),
1502
+ z.strictObject({ operation: z.literal("skip"), backend: z.enum(ONBOARDING_BACKENDS) }),
1270
1503
  z.strictObject({ operation: z.literal("cancel") }), z.strictObject({ operation: z.literal("refresh") }),
1271
1504
  ]).safeParse(body);
1272
1505
  if (!parsed.success) {
@@ -1296,7 +1529,7 @@ function handleBrowserBackendSignIns(req, res, url, ctx) {
1296
1529
  json(res, 200, result);
1297
1530
  })().catch(error => {
1298
1531
  const code = error instanceof Error ? error.message : "";
1299
- const safe = /^(?:signin_(?:session_expired|console_only|cleanup_failed|action_(?:stale|invalid|ended|busy))|invalid_signin_(?:action|checklist))$/.test(code) ? code : "signin_failed";
1532
+ const safe = /^(?:signin_(?:session_expired|console_only|cleanup_failed|busy|profile_unknown|action_(?:stale|invalid|ended|busy))|invalid_signin_(?:action|checklist|target)|machine_(?:unknown|offline|unsupported|accounts_off|unreachable|profile_not_owned|busy)|invalid_machine_target)$/.test(code) ? code : "signin_failed";
1300
1533
  if (!res.destroyed && !res.writableEnded)
1301
1534
  json(res, safe === "signin_cleanup_failed" || safe === "signin_failed" ? 503 : 409, { error: safe });
1302
1535
  });
@@ -1335,7 +1568,18 @@ function handleBackendLogin(req, res, url, ctx, path, method) {
1335
1568
  }
1336
1569
  const action = /^\/ui\/backend-login\/(check|start|cancel)$/.exec(path)?.[1];
1337
1570
  if (reading && path === "/ui/backend-login" && [...url.searchParams.keys()].length === 0) {
1338
- json(res, 200, { login: logins.view(first.handle), targets: ctx.backendSignInTargets?.() ?? [] });
1571
+ // The sign-in view (its access code included) is answered at once and never waits for an account to be read: that happens in the background
1572
+ // and the page is told to read again when something new is known.
1573
+ try {
1574
+ ctx.refreshSignInIdentities?.();
1575
+ }
1576
+ catch { /* the list is served with what is known */ }
1577
+ try {
1578
+ json(res, 200, { login: logins.view(first.handle), targets: ctx.backendSignInTargets?.() ?? [] });
1579
+ }
1580
+ catch {
1581
+ json(res, 503, { error: "sign_in_unavailable" });
1582
+ }
1339
1583
  return true;
1340
1584
  }
1341
1585
  if (method !== "POST" || !action) {
@@ -1388,11 +1632,17 @@ function handleBackendLogin(req, res, url, ctx, path, method) {
1388
1632
  json(res, "error" in result ? 409 : 200, result);
1389
1633
  }
1390
1634
  else {
1391
- if (!z.strictObject({}).safeParse(body).success) {
1635
+ // `{}`: the explicit "Cancel sign-in" — whatever sign-in is running, as ever. `{ run, ifUnopened }`: the dialog's own Close (#3321 review), for
1636
+ // that one run and only while its terminal is unopened and it is this session's own; anything else is left alone and `cancelled` is false.
1637
+ const parsed = z.union([z.strictObject({}), z.strictObject({ run: z.string().regex(/^[0-9a-f]{32}$/), ifUnopened: z.literal(true) })]).safeParse(body);
1638
+ if (!parsed.success) {
1392
1639
  json(res, 400, { error: "sign_in_args" });
1393
1640
  return;
1394
1641
  }
1395
- json(res, 200, { message: await logins.cancel() });
1642
+ if ("run" in parsed.data)
1643
+ json(res, 200, await logins.closeRun(now, parsed.data.run));
1644
+ else
1645
+ json(res, 200, { message: await logins.cancel() });
1396
1646
  }
1397
1647
  })().catch(() => { try {
1398
1648
  json(res, 500, { error: "sign_in_request_failed" });
@@ -1401,166 +1651,515 @@ function handleBackendLogin(req, res, url, ctx, path, method) {
1401
1651
  return true;
1402
1652
  }
1403
1653
  /**
1404
- * #1629 r4 §4 (r4-5): mods — a person's import (stage, then commit), uninstall and export. Every route is a signed-in
1405
- * session's, writes an admin's: never the CLI's header token (the way an agent could reach it) and never the public link
1406
- * (absent from its manifest, and refused here too). `who()` is asked first and again once a body is in.
1654
+ * AGEND-133 (upstream #3521): installing a CLI on the AgEnD host from the dashboard (web-host-install.ts). The gate is the sign-in routes' own — a signed-in admin
1655
+ * session on the local surface; never the CLI's header token (an agent's), a guest, a read session, or the public link (refused before the body is read, and again
1656
+ * after it). `GET` reads the current install; `POST` `{ backend }` starts one — the browser names a CLI, the server looks up the registry's command, nothing it sends
1657
+ * is ever run; `POST …/cancel` `{}` stops the running one. Every answer is no-store.
1407
1658
  */
1408
- function handleMods(req, res, url, ctx, path, method) {
1409
- const mods = ctx.mods;
1410
- if (!mods) {
1411
- json(res, 404, { error: "Mods are not kept on this fleet" });
1412
- return true;
1413
- }
1659
+ const HOST_INSTALL_STATUS = { not_allowed: 403, unsupported: 400, already: 409, not_installed: 409, up_to_date: 409, version_unreadable: 409, busy: 409, shutting_down: 503, failed: 500 };
1660
+ function handleHostInstall(req, res, url, ctx, path, method) {
1661
+ res.setHeader("Cache-Control", "private, no-store");
1662
+ res.setHeader("X-Content-Type-Options", "nosniff");
1414
1663
  const reading = method === "GET";
1415
1664
  if (gatewayRequestContext(req)) {
1416
- json(res, reading ? 404 : 403, { error: "mods_not_over_public_link" });
1665
+ json(res, reading ? 404 : 403, { error: "install_not_over_public_link" });
1417
1666
  return true;
1418
1667
  }
1419
1668
  const who = () => {
1420
- const verdict = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
1421
- if (verdict.kind !== "allow")
1422
- return { status: 401, error: WEB_TOKEN_INVALID_MESSAGE };
1423
- if (verdict.via !== "session" || !verdict.session)
1424
- return { status: 403, error: "mods_need_a_signed_in_session" };
1425
- if (!reading && verdict.session.tier !== "admin")
1426
- return { status: 403, error: "mods_need_an_admin_session" };
1427
- return { person: webPersonKey(verdict.session.owner) };
1669
+ if (isSettingsReplay(req)) {
1670
+ const requester = settingsRequestRequester(req);
1671
+ if (!requester || !settingsRequestLocalAdmin(req))
1672
+ return { error: "install_needs_a_local_admin", status: 403 };
1673
+ return requester;
1674
+ }
1675
+ const v = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
1676
+ if (v.kind !== "allow")
1677
+ return { error: WEB_TOKEN_INVALID_MESSAGE, status: 401 };
1678
+ if (v.via !== "session" || v.session.tier !== "admin" || v.session.surface !== "local")
1679
+ return { error: "install_needs_a_local_admin", status: 403 };
1680
+ return { handle: v.session.handle, label: v.session.label };
1428
1681
  };
1429
1682
  const first = who();
1430
- if ("status" in first) {
1683
+ if ("error" in first) {
1431
1684
  json(res, first.status, { error: first.error });
1432
1685
  return true;
1433
1686
  }
1434
- const again = () => {
1435
- if (!permitWebContinuation(req, res, ctx))
1436
- return null;
1437
- const now = who();
1438
- if ("status" in now) {
1439
- json(res, now.status, { error: now.error });
1440
- return null;
1441
- }
1442
- if (now.person !== first.person) {
1443
- json(res, 409, { error: "mods_person_changed" });
1444
- return null;
1445
- }
1446
- return now.person;
1447
- };
1448
- const answer = (r, body) => {
1449
- if (r.ok)
1450
- json(res, 200, body);
1451
- else
1452
- json(res, r.status ?? 500, { error: r.error, ...(r.detail ? { detail: r.detail } : {}), ...(r.problems ? { problems: r.problems } : {}) });
1453
- };
1454
- const fail = (err) => {
1455
- ctx.logger.error({ err: err.message }, "Mod request failed");
1456
- try {
1457
- json(res, 500, { error: "Mod request failed" });
1458
- }
1459
- catch { /* already answered */ }
1460
- };
1461
- if (path === "/ui/mods" && method === "GET") {
1462
- json(res, 200, { ...mods.list(), staged: mods.staged(first.person), proposals: mods.proposals() });
1463
- return true;
1464
- }
1465
- // A staged mod's picture (this session's person's stage only): the plan shows the actual pictures before install.
1466
- const stagedPic = /^\/ui\/mods\/staged\/([0-9a-f]{32})$/.exec(path);
1467
- if (stagedPic && method === "GET") {
1468
- const pic = mods.stagedPicture(first.person, stagedPic[1]);
1469
- if (!pic) {
1470
- json(res, 404, { error: "No such image" });
1471
- return true;
1472
- }
1473
- res.writeHead(200, { "Content-Type": pic.mime, "X-Content-Type-Options": "nosniff", "Cache-Control": "private, no-store", "Content-Security-Policy": "default-src 'none'; sandbox" });
1474
- res.end(Buffer.from(pic.bytes));
1687
+ const installs = ctx.webHostInstalls;
1688
+ if (!installs) {
1689
+ json(res, 404, { error: "install_unavailable" });
1475
1690
  return true;
1476
1691
  }
1477
- const fileMatch = /^\/ui\/mods\/file\/([0-9a-f]{32})$/.exec(path);
1478
- if (fileMatch && method === "GET") {
1479
- const text = mods.bundleText(fileMatch[1]);
1480
- const rec = mods.list().mods.find(m => m.id === fileMatch[1]);
1481
- if (text === null || !rec) {
1482
- json(res, 404, { error: "no_such_mod" });
1483
- return true;
1692
+ if (reading && path === "/ui/host-install" && [...url.searchParams.keys()].length === 0) {
1693
+ try {
1694
+ json(res, 200, { install: installs.view() });
1484
1695
  }
1485
- // The file is the installed bundle, effects and all. #2799: a file that carries Canvas Worker effects (or can't be
1486
- // read to tell) is not handed out; one without is any admin's.
1487
- const fx = mods.bundleEffects(fileMatch[1]);
1488
- if (fx === "unknown" || (fx?.length ?? 0) > 0) {
1489
- json(res, 403, { error: "canvas_worker_experimental", message: CANVAS_WORKER_EXPERIMENTAL_MESSAGE });
1490
- return true;
1696
+ catch {
1697
+ json(res, 503, { error: "install_unavailable" });
1491
1698
  }
1492
- res.writeHead(200, { "Content-Type": "application/json; charset=utf-8", "X-Content-Type-Options": "nosniff", "Cache-Control": "private, no-store",
1493
- "Content-Disposition": `attachment; filename="${rec.name}-${rec.version}.agendmod.json"` });
1494
- res.end(text);
1495
1699
  return true;
1496
1700
  }
1497
- if (method !== "POST" || !["/ui/mods/stage", "/ui/mods/abort", "/ui/mods/commit", "/ui/mods/uninstall", "/ui/mods/export", "/ui/mods/proposal/stage", "/ui/mods/proposal/dismiss"].includes(path)) {
1498
- json(res, 404, { error: "not found" });
1701
+ // Cancel only takes something away (any local admin may stop it, as `/login cancel`): it is not a held change. Install and Update (AGEND-136) are, and run only as the gate's confirmed replay.
1702
+ if (method !== "POST" || (path !== "/ui/host-install/cancel" && !HOST_CLI_PATHS.has(path))) {
1703
+ json(res, 404, { error: "not_found" });
1499
1704
  return true;
1500
1705
  }
1501
1706
  (async () => {
1502
- if (path === "/ui/mods/stage") {
1503
- // Too large by its own declared length: answered before a byte is read (the body is drained, not cut off).
1504
- if (Number(req.headers["content-length"]) > MOD_MAX_BYTES) {
1505
- req.resume();
1506
- json(res, 413, { error: "mod_too_large", detail: `at most ${MOD_MAX_BYTES / 1024 / 1024} MiB` });
1507
- return;
1508
- }
1509
- let raw;
1510
- try {
1511
- raw = await readBoundedWebBody(req, MOD_MAX_BYTES);
1512
- }
1513
- catch {
1514
- json(res, 413, { error: "mod_too_large", detail: `at most ${MOD_MAX_BYTES / 1024 / 1024} MiB` });
1515
- return;
1516
- }
1517
- const person = again();
1518
- if (!person)
1519
- return;
1520
- let text;
1521
- try {
1522
- text = new TextDecoder("utf-8", { fatal: true }).decode(raw);
1523
- }
1524
- catch {
1525
- json(res, 400, { error: "mod_invalid", problems: [{ path: "", problem: "not UTF-8" }] });
1526
- return;
1527
- }
1528
- const r = mods.stage(person, text);
1529
- answer(r, r.ok ? { stage: r.stage, plan: r.plan, plan_hash: r.plan_hash } : null);
1530
- return;
1531
- }
1532
- let body;
1707
+ let bytes;
1533
1708
  try {
1534
- body = await parseBody(req);
1709
+ bytes = await readBoundedWebBody(req, 1024);
1535
1710
  }
1536
1711
  catch {
1537
- json(res, 400, { error: "Invalid JSON" });
1712
+ json(res, 413, { error: "install_body_bound" });
1538
1713
  return;
1539
1714
  }
1540
- const person = again();
1541
- if (!person)
1715
+ if (!permitWebContinuation(req, res, ctx))
1542
1716
  return;
1543
- if (!body || typeof body !== "object" || Array.isArray(body)) {
1544
- json(res, 400, { error: "an object" });
1717
+ const now = who();
1718
+ if ("error" in now) {
1719
+ json(res, now.status, { error: now.error });
1545
1720
  return;
1546
1721
  }
1547
- if (path === "/ui/mods/abort") {
1548
- const r = mods.abort(person, body.stage);
1549
- answer(r, { ok: true });
1722
+ if (now.handle !== first.handle) {
1723
+ json(res, 409, { error: "install_session_changed" });
1550
1724
  return;
1551
1725
  }
1552
- // r4-5b: an agent's proposal, opened into the usual review (staged as this person's), or dismissed.
1553
- if (path === "/ui/mods/proposal/stage") {
1554
- const r = mods.stageProposal(person, body.instance);
1555
- answer(r, r.ok ? { stage: r.stage, plan: r.plan, plan_hash: r.plan_hash } : null);
1556
- return;
1726
+ let body;
1727
+ try {
1728
+ body = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
1557
1729
  }
1558
- if (path === "/ui/mods/proposal/dismiss") {
1559
- const r = mods.dismiss(body.instance);
1560
- answer(r, { ok: true });
1730
+ catch {
1731
+ json(res, 400, { error: "install_json" });
1561
1732
  return;
1562
1733
  }
1563
- if (path === "/ui/mods/commit") {
1734
+ if (path === "/ui/host-install/cancel") {
1735
+ if (!z.strictObject({}).safeParse(body).success) {
1736
+ json(res, 400, { error: "install_args" });
1737
+ return;
1738
+ }
1739
+ json(res, 200, { cancelled: await installs.cancel() });
1740
+ return;
1741
+ }
1742
+ // AGEND-154 (Prism P2-1 on #3552): an update may carry `acceptLatestUnaudited: true` (only the page that knows the named exception sends it); the request and the registry must agree (below).
1743
+ const parsed = z.strictObject({ backend: z.string().regex(/^[a-z][a-z0-9-]{0,31}$/), ...(path === "/ui/host-update" ? { [LATEST_ACK_FIELD]: z.literal(true).optional() } : {}) }).safeParse(body);
1744
+ if (!parsed.success) {
1745
+ json(res, 400, { error: "install_args" });
1746
+ return;
1747
+ }
1748
+ if (!isSettingsReplay(req) || !settingsRequestExecution(req)) {
1749
+ json(res, 403, { error: "install_confirmation_required" });
1750
+ return;
1751
+ }
1752
+ if (path === "/ui/host-update") {
1753
+ const ackError = hostUpdateAckError(parsed.data.backend, parsed.data[LATEST_ACK_FIELD]);
1754
+ if (ackError) {
1755
+ json(res, 409, { error: ackError });
1756
+ return;
1757
+ }
1758
+ }
1759
+ // AGEND-136: `POST /ui/host-update { backend }` is the same request for an update: the server picks the command and the audited release; the page sends only the CLI's id.
1760
+ const result = await installs.begin(now, parsed.data.backend, settingsRequestExecution(req), path === "/ui/host-update" ? "update" : "install");
1761
+ if ("error" in result)
1762
+ json(res, HOST_INSTALL_STATUS[result.error] ?? 409, { error: result.error, ...(result.message ? { message: result.message } : {}) });
1763
+ else
1764
+ json(res, 200, result);
1765
+ })().catch(() => { try {
1766
+ json(res, 500, { error: "install_request_failed" });
1767
+ }
1768
+ catch { /* response ended */ } });
1769
+ return true;
1770
+ }
1771
+ /**
1772
+ * #3212 PR 2: Settings → Accounts — `POST /ui/accounts/<backend>` `{ name }` adds a named account (a credential profile's
1773
+ * folder); `DELETE /ui/accounts/<backend>/<name>` `{ confirm: <name> }` removes one (accounts-profiles.ts: every refusal
1774
+ * deletes nothing). PR 3: `POST /ui/accounts/<backend>/signout` `{ profile: <name> | null, confirm: true }` signs an
1775
+ * account out with the CLI's own logout (accounts-signout.ts). The fleet's local admin session only, as the sign-in routes: never the CLI's header token, a guest,
1776
+ * a read session, the public link or the gateway — refused before the body is read, and again after it.
1777
+ */
1778
+ const ACCOUNT_STATUS = {
1779
+ backend: 400, name: 400, confirm: 400, exists: 409, case_clash: 409, unsafe_root: 409, in_use: 409, users_unknown: 409, signing_in: 409, missing: 404,
1780
+ unsafe: 409, default_home: 409, failed: 500, unsupported: 400,
1781
+ // #3190 Part 3c: a paired computer (the Runtime there decides; these are what the server can say before it asks, or what the computer answered).
1782
+ machine_unknown: 404, machine_offline: 409, machine_unsupported: 409, machine_accounts_off: 409, machine_unreachable: 502, machine_profile_not_owned: 409,
1783
+ machine_refused: 409, machine_default_login: 409,
1784
+ };
1785
+ function handleAccountWrite(req, res, url, ctx, path, method) {
1786
+ res.setHeader("Cache-Control", "private, no-store");
1787
+ res.setHeader("X-Content-Type-Options", "nosniff");
1788
+ if (gatewayRequestContext(req)) {
1789
+ json(res, 403, { error: "accounts_not_over_public_link" });
1790
+ return true;
1791
+ }
1792
+ const who = () => {
1793
+ const v = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
1794
+ if (v.kind !== "allow")
1795
+ return { error: WEB_TOKEN_INVALID_MESSAGE, status: 401 };
1796
+ if (v.via !== "session" || v.session.tier !== "admin" || v.session.surface !== "local")
1797
+ return { error: "accounts_need_a_local_admin", status: 403 };
1798
+ return { handle: v.session.handle, label: v.session.label };
1799
+ };
1800
+ const first = who();
1801
+ if ("error" in first) {
1802
+ json(res, first.status, { error: first.error });
1803
+ return true;
1804
+ }
1805
+ const add = method === "POST" ? /^\/ui\/accounts\/([a-z][a-z0-9-]{0,31})$/.exec(path) : null;
1806
+ const remove = method === "DELETE" ? /^\/ui\/accounts\/([a-z][a-z0-9-]{0,31})\/([^/]{1,200})$/.exec(path) : null;
1807
+ const signout = method === "POST" ? /^\/ui\/accounts\/([a-z][a-z0-9-]{0,31})\/signout$/.exec(path) : null;
1808
+ if (!add && !remove && !signout) {
1809
+ json(res, 404, { error: "not_found" });
1810
+ return true;
1811
+ }
1812
+ const handler = add ? ctx.addAccountProfile : remove ? ctx.removeAccountProfile : ctx.signOutAccount;
1813
+ if (typeof handler !== "function") {
1814
+ json(res, 404, { error: "not_found" });
1815
+ return true;
1816
+ }
1817
+ let target = "";
1818
+ if (remove) {
1819
+ try {
1820
+ target = decodeURIComponent(remove[2]);
1821
+ }
1822
+ catch {
1823
+ json(res, 400, { error: "name" });
1824
+ return true;
1825
+ }
1826
+ }
1827
+ (async () => {
1828
+ let bytes;
1829
+ try {
1830
+ bytes = await readBoundedWebBody(req, 1024);
1831
+ }
1832
+ catch {
1833
+ json(res, 413, { error: "accounts_body_bound" });
1834
+ return;
1835
+ }
1836
+ if (!permitWebContinuation(req, res, ctx))
1837
+ return;
1838
+ const now = who();
1839
+ if ("error" in now) {
1840
+ json(res, now.status, { error: now.error });
1841
+ return;
1842
+ }
1843
+ if (now.handle !== first.handle) {
1844
+ json(res, 409, { error: "accounts_session_changed" });
1845
+ return;
1846
+ }
1847
+ let body;
1848
+ try {
1849
+ body = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
1850
+ }
1851
+ catch {
1852
+ json(res, 400, { error: "accounts_json" });
1853
+ return;
1854
+ }
1855
+ // #3190 Part 3c: `machine` (a paired computer's id) turns the same route into that computer's account; the person's audit name is the session's opaque handle.
1856
+ const machineId = z.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/).optional();
1857
+ const onMachine = (id) => {
1858
+ if (id === undefined)
1859
+ return undefined;
1860
+ return /^[a-f0-9]{16}$/.test(now.handle) ? { id, actor: `admin:${now.handle}` } : "refused";
1861
+ };
1862
+ const fail = (r) => json(res, ACCOUNT_STATUS[r.error] ?? 409, { error: r.error, ...(r.clash ? { clash: r.clash } : {}), ...(r.users ? { users: r.users } : {}), ...(r.message ? { message: r.message } : {}) });
1863
+ if (add) {
1864
+ const parsed = z.strictObject({ name: z.string().max(200), machine: machineId }).safeParse(body);
1865
+ if (!parsed.success) {
1866
+ json(res, 400, { error: "accounts_args" });
1867
+ return;
1868
+ }
1869
+ const machine = onMachine(parsed.data.machine);
1870
+ if (machine === "refused") {
1871
+ json(res, 403, { error: "accounts_need_a_local_admin" });
1872
+ return;
1873
+ }
1874
+ const r = await (machine ? ctx.addAccountProfile(add[1], parsed.data.name, now.label, machine) : ctx.addAccountProfile(add[1], parsed.data.name, now.label));
1875
+ if (r.ok)
1876
+ json(res, 200, { added: parsed.data.name, ...(machine ? { machine: machine.id } : {}) });
1877
+ else
1878
+ fail(r);
1879
+ }
1880
+ else if (remove) {
1881
+ // `cancelSignIn` (#3321 review): "Cancel sign-in and remove" — end the running sign-in of THIS account (and no other), then remove it, in one request.
1882
+ // A paired computer's sign-in is cancelled from that computer's side, so it is refused there.
1883
+ const parsed = z.strictObject({ confirm: z.string().max(200), machine: machineId, cancelSignIn: z.literal(true).optional() }).refine(a => !(a.machine && a.cancelSignIn)).safeParse(body);
1884
+ if (!parsed.success) {
1885
+ json(res, 400, { error: "accounts_args" });
1886
+ return;
1887
+ }
1888
+ const machine = onMachine(parsed.data.machine);
1889
+ if (machine === "refused") {
1890
+ json(res, 403, { error: "accounts_need_a_local_admin" });
1891
+ return;
1892
+ }
1893
+ const r = await (machine ? ctx.removeAccountProfile(remove[1], target, parsed.data.confirm, now.label, machine)
1894
+ : parsed.data.cancelSignIn ? ctx.removeAccountProfile(remove[1], target, parsed.data.confirm, now.label, undefined, { cancelSignIn: true })
1895
+ : ctx.removeAccountProfile(remove[1], target, parsed.data.confirm, now.label));
1896
+ if (r.ok)
1897
+ json(res, 200, { removed: target, ...(r.keychainLeft ? { keychainLeft: true } : {}) });
1898
+ else
1899
+ fail(r);
1900
+ }
1901
+ else {
1902
+ const parsed = z.strictObject({ profile: z.string().max(200).nullable(), confirm: z.literal(true), machine: machineId }).safeParse(body);
1903
+ if (!parsed.success) {
1904
+ json(res, 400, { error: "accounts_args" });
1905
+ return;
1906
+ }
1907
+ const machine = onMachine(parsed.data.machine);
1908
+ if (machine === "refused") {
1909
+ json(res, 403, { error: "accounts_need_a_local_admin" });
1910
+ return;
1911
+ }
1912
+ const r = await (machine ? ctx.signOutAccount(signout[1], parsed.data.profile, parsed.data.confirm, now.label, machine) : ctx.signOutAccount(signout[1], parsed.data.profile, parsed.data.confirm, now.label));
1913
+ if (r.ok)
1914
+ json(res, 200, { signedOut: parsed.data.profile, ...(r.keychainLeft ? { keychainLeft: true } : {}) });
1915
+ else
1916
+ fail(r);
1917
+ }
1918
+ })().catch(() => { try {
1919
+ json(res, 500, { error: "accounts_request_failed" });
1920
+ }
1921
+ catch { /* response ended */ } });
1922
+ return true;
1923
+ }
1924
+ /**
1925
+ * #3292: Settings → Accounts → Keep sign-in alive — `POST /ui/accounts/keep-alive` `{ backend, profile: <name> | null,
1926
+ * enabled, fallback? }`. The same gate as the other account writes: the fleet's local admin session only, refused before
1927
+ * the body is read and again after it; never the gateway, a guest, a read session or the CLI's header token.
1928
+ */
1929
+ const KEEPALIVE_STATUS = { backend: 400, profile: 400, fallback: 400, write: 500 };
1930
+ function handleAccountKeepAlive(req, res, url, ctx, method) {
1931
+ res.setHeader("Cache-Control", "private, no-store");
1932
+ res.setHeader("X-Content-Type-Options", "nosniff");
1933
+ if (gatewayRequestContext(req)) {
1934
+ json(res, 403, { error: "accounts_not_over_public_link" });
1935
+ return true;
1936
+ }
1937
+ if (method !== "POST") {
1938
+ json(res, 405, { error: "method_not_allowed" });
1939
+ return true;
1940
+ }
1941
+ const who = () => {
1942
+ const v = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
1943
+ if (v.kind !== "allow")
1944
+ return { error: WEB_TOKEN_INVALID_MESSAGE, status: 401 };
1945
+ if (v.via !== "session" || v.session.tier !== "admin" || v.session.surface !== "local")
1946
+ return { error: "accounts_need_a_local_admin", status: 403 };
1947
+ return { handle: v.session.handle, label: v.session.label };
1948
+ };
1949
+ const first = who();
1950
+ if ("error" in first) {
1951
+ json(res, first.status, { error: first.error });
1952
+ return true;
1953
+ }
1954
+ if (typeof ctx.setAccountKeepAlive !== "function") {
1955
+ json(res, 404, { error: "not_found" });
1956
+ return true;
1957
+ }
1958
+ (async () => {
1959
+ let bytes;
1960
+ try {
1961
+ bytes = await readBoundedWebBody(req, 1024);
1962
+ }
1963
+ catch {
1964
+ json(res, 413, { error: "accounts_body_bound" });
1965
+ return;
1966
+ }
1967
+ if (!permitWebContinuation(req, res, ctx))
1968
+ return;
1969
+ const now = who();
1970
+ if ("error" in now) {
1971
+ json(res, now.status, { error: now.error });
1972
+ return;
1973
+ }
1974
+ if (now.handle !== first.handle) {
1975
+ json(res, 409, { error: "accounts_session_changed" });
1976
+ return;
1977
+ }
1978
+ let body;
1979
+ try {
1980
+ body = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
1981
+ }
1982
+ catch {
1983
+ json(res, 400, { error: "accounts_json" });
1984
+ return;
1985
+ }
1986
+ const parsed = z.strictObject({ backend: z.string().max(32), profile: z.string().max(200).nullable(), enabled: z.boolean(), fallback: z.boolean().optional() }).safeParse(body);
1987
+ if (!parsed.success) {
1988
+ json(res, 400, { error: "accounts_args" });
1989
+ return;
1990
+ }
1991
+ const r = ctx.setAccountKeepAlive(parsed.data.backend, parsed.data.profile, parsed.data.enabled, parsed.data.fallback, now.label);
1992
+ if (r.ok)
1993
+ json(res, 200, { backend: parsed.data.backend, profile: parsed.data.profile, enabled: parsed.data.enabled });
1994
+ else
1995
+ json(res, KEEPALIVE_STATUS[r.error] ?? 409, { error: r.error });
1996
+ })().catch(() => { try {
1997
+ json(res, 500, { error: "accounts_request_failed" });
1998
+ }
1999
+ catch { /* response ended */ } });
2000
+ return true;
2001
+ }
2002
+ /**
2003
+ * #1629 r4 §4 (r4-5): mods — a person's import (stage, then commit), uninstall and export. Every route is a signed-in
2004
+ * session's, writes an admin's: never the CLI's header token (the way an agent could reach it) and never the public link
2005
+ * (absent from its manifest, and refused here too). `who()` is asked first and again once a body is in.
2006
+ */
2007
+ function handleMods(req, res, url, ctx, path, method) {
2008
+ const mods = ctx.mods;
2009
+ if (!mods) {
2010
+ json(res, 404, { error: "Mods are not kept on this fleet" });
2011
+ return true;
2012
+ }
2013
+ const reading = method === "GET";
2014
+ if (gatewayRequestContext(req)) {
2015
+ json(res, reading ? 404 : 403, { error: "mods_not_over_public_link" });
2016
+ return true;
2017
+ }
2018
+ const who = () => {
2019
+ const verdict = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
2020
+ if (verdict.kind !== "allow")
2021
+ return { status: 401, error: WEB_TOKEN_INVALID_MESSAGE };
2022
+ if (verdict.via !== "session" || !verdict.session)
2023
+ return { status: 403, error: "mods_need_a_signed_in_session" };
2024
+ if (!reading && verdict.session.tier !== "admin")
2025
+ return { status: 403, error: "mods_need_an_admin_session" };
2026
+ return { person: webPersonKey(verdict.session.owner) };
2027
+ };
2028
+ const first = who();
2029
+ if ("status" in first) {
2030
+ json(res, first.status, { error: first.error });
2031
+ return true;
2032
+ }
2033
+ const again = () => {
2034
+ if (!permitWebContinuation(req, res, ctx))
2035
+ return null;
2036
+ const now = who();
2037
+ if ("status" in now) {
2038
+ json(res, now.status, { error: now.error });
2039
+ return null;
2040
+ }
2041
+ if (now.person !== first.person) {
2042
+ json(res, 409, { error: "mods_person_changed" });
2043
+ return null;
2044
+ }
2045
+ return now.person;
2046
+ };
2047
+ const answer = (r, body) => {
2048
+ if (r.ok)
2049
+ json(res, 200, body);
2050
+ else
2051
+ json(res, r.status ?? 500, { error: r.error, ...(r.detail ? { detail: r.detail } : {}), ...(r.problems ? { problems: r.problems } : {}) });
2052
+ };
2053
+ const fail = (err) => {
2054
+ ctx.logger.error({ err: err.message }, "Mod request failed");
2055
+ try {
2056
+ json(res, 500, { error: "Mod request failed" });
2057
+ }
2058
+ catch { /* already answered */ }
2059
+ };
2060
+ if (path === "/ui/mods" && method === "GET") {
2061
+ json(res, 200, { ...mods.list(), staged: mods.staged(first.person), proposals: mods.proposals() });
2062
+ return true;
2063
+ }
2064
+ // A staged mod's picture (this session's person's stage only): the plan shows the actual pictures before install.
2065
+ const stagedPic = /^\/ui\/mods\/staged\/([0-9a-f]{32})$/.exec(path);
2066
+ if (stagedPic && method === "GET") {
2067
+ const pic = mods.stagedPicture(first.person, stagedPic[1]);
2068
+ if (!pic) {
2069
+ json(res, 404, { error: "No such image" });
2070
+ return true;
2071
+ }
2072
+ res.writeHead(200, { "Content-Type": pic.mime, "X-Content-Type-Options": "nosniff", "Cache-Control": "private, no-store", "Content-Security-Policy": "default-src 'none'; sandbox" });
2073
+ res.end(Buffer.from(pic.bytes));
2074
+ return true;
2075
+ }
2076
+ const fileMatch = /^\/ui\/mods\/file\/([0-9a-f]{32})$/.exec(path);
2077
+ if (fileMatch && method === "GET") {
2078
+ const text = mods.bundleText(fileMatch[1]);
2079
+ const rec = mods.list().mods.find(m => m.id === fileMatch[1]);
2080
+ if (text === null || !rec) {
2081
+ json(res, 404, { error: "no_such_mod" });
2082
+ return true;
2083
+ }
2084
+ // The file is the installed bundle, effects and all. #2799: a file that carries Canvas Worker effects (or can't be
2085
+ // read to tell) is not handed out; one without is any admin's.
2086
+ const fx = mods.bundleEffects(fileMatch[1]);
2087
+ if (fx === "unknown" || (fx?.length ?? 0) > 0) {
2088
+ json(res, 403, { error: "canvas_worker_experimental", message: CANVAS_WORKER_EXPERIMENTAL_MESSAGE });
2089
+ return true;
2090
+ }
2091
+ res.writeHead(200, { "Content-Type": "application/json; charset=utf-8", "X-Content-Type-Options": "nosniff", "Cache-Control": "private, no-store",
2092
+ "Content-Disposition": `attachment; filename="${rec.name}-${rec.version}.agendmod.json"` });
2093
+ res.end(text);
2094
+ return true;
2095
+ }
2096
+ if (method !== "POST" || !["/ui/mods/stage", "/ui/mods/abort", "/ui/mods/commit", "/ui/mods/uninstall", "/ui/mods/export", "/ui/mods/proposal/stage", "/ui/mods/proposal/dismiss"].includes(path)) {
2097
+ json(res, 404, { error: "not found" });
2098
+ return true;
2099
+ }
2100
+ (async () => {
2101
+ if (path === "/ui/mods/stage") {
2102
+ // Too large by its own declared length: answered before a byte is read (the body is drained, not cut off).
2103
+ if (Number(req.headers["content-length"]) > MOD_MAX_BYTES) {
2104
+ req.resume();
2105
+ json(res, 413, { error: "mod_too_large", detail: `at most ${MOD_MAX_BYTES / 1024 / 1024} MiB` });
2106
+ return;
2107
+ }
2108
+ let raw;
2109
+ try {
2110
+ raw = await readBoundedWebBody(req, MOD_MAX_BYTES);
2111
+ }
2112
+ catch {
2113
+ json(res, 413, { error: "mod_too_large", detail: `at most ${MOD_MAX_BYTES / 1024 / 1024} MiB` });
2114
+ return;
2115
+ }
2116
+ const person = again();
2117
+ if (!person)
2118
+ return;
2119
+ let text;
2120
+ try {
2121
+ text = new TextDecoder("utf-8", { fatal: true }).decode(raw);
2122
+ }
2123
+ catch {
2124
+ json(res, 400, { error: "mod_invalid", problems: [{ path: "", problem: "not UTF-8" }] });
2125
+ return;
2126
+ }
2127
+ const r = mods.stage(person, text);
2128
+ answer(r, r.ok ? { stage: r.stage, plan: r.plan, plan_hash: r.plan_hash } : null);
2129
+ return;
2130
+ }
2131
+ let body;
2132
+ try {
2133
+ body = await parseBody(req);
2134
+ }
2135
+ catch {
2136
+ json(res, 400, { error: "Invalid JSON" });
2137
+ return;
2138
+ }
2139
+ const person = again();
2140
+ if (!person)
2141
+ return;
2142
+ if (!body || typeof body !== "object" || Array.isArray(body)) {
2143
+ json(res, 400, { error: "an object" });
2144
+ return;
2145
+ }
2146
+ if (path === "/ui/mods/abort") {
2147
+ const r = mods.abort(person, body.stage);
2148
+ answer(r, { ok: true });
2149
+ return;
2150
+ }
2151
+ // r4-5b: an agent's proposal, opened into the usual review (staged as this person's), or dismissed.
2152
+ if (path === "/ui/mods/proposal/stage") {
2153
+ const r = mods.stageProposal(person, body.instance);
2154
+ answer(r, r.ok ? { stage: r.stage, plan: r.plan, plan_hash: r.plan_hash } : null);
2155
+ return;
2156
+ }
2157
+ if (path === "/ui/mods/proposal/dismiss") {
2158
+ const r = mods.dismiss(body.instance);
2159
+ answer(r, { ok: true });
2160
+ return;
2161
+ }
2162
+ if (path === "/ui/mods/commit") {
1564
2163
  const r = mods.commit(person, body);
1565
2164
  if (r.ok)
1566
2165
  ctx.emitSseEvent("status", ctx.getUiStatus()); // themes_rev and prefs_rev moved: every page re-reads
@@ -1978,7 +2577,7 @@ export function handleWebRequest(req, res, url, ctx) {
1978
2577
  // the panel instead of comparing null against a missing credential.
1979
2578
  if (path.startsWith("/ui")) {
1980
2579
  const approved = isSettingsReplay(req) && method === "POST"
1981
- && (path === "/ui/config" || path === "/ui/instances" || /^\/ui\/instances\/[^/]+\/delete$/.test(path))
2580
+ && (path === "/ui/config" || path === "/ui/instances" || /^\/ui\/instances\/[^/]+\/delete$/.test(path) || HOST_CLI_PATHS.has(path) || isRuntimeCliInstallPath(path))
1982
2581
  ? settingsRequestExecution(req) : undefined;
1983
2582
  if (approved) {
1984
2583
  try {
@@ -1998,6 +2597,29 @@ export function handleWebRequest(req, res, url, ctx) {
1998
2597
  return false;
1999
2598
  }
2000
2599
  // ── Static files ───────────────────────────────────────
2600
+ // Native local tools retain their administrator boundary on the shared chat/read/action routes.
2601
+ const nativePath = /^\/ui\/(?:chat|instance|cancel|stop|start|restart)\/([^/]+)$/.exec(path);
2602
+ let nativeTarget = url.searchParams.get("instance") ?? "";
2603
+ if (nativePath) {
2604
+ try {
2605
+ nativeTarget = decodeURIComponent(nativePath[1]);
2606
+ }
2607
+ catch {
2608
+ nativeTarget = "";
2609
+ }
2610
+ }
2611
+ if (isWindowsInstance(ctx.fleetConfig?.instances?.[nativeTarget]) && !nativeCliAuthorization(req, url, ctx)) {
2612
+ json(res, 403, { error: "Windows runtime requires an administrator on the local dashboard" });
2613
+ return true;
2614
+ }
2615
+ if (handleAgentRuntimeChange(req, res, url, ctx))
2616
+ return true;
2617
+ if (handleNativeInstanceRequest(req, res, url, ctx))
2618
+ return true;
2619
+ if (handleWindowsCliRequest(req, res, url, ctx))
2620
+ return true;
2621
+ if (handleRuntimeRequest(req, res, url, ctx))
2622
+ return true;
2001
2623
  // #1408: the app shell, for exactly the paths the classifier names (src/web-shell-routes.ts). One page for every
2002
2624
  // route; the client router mounts the panel. A malformed instance name is a 400, an unknown one is the shell (the
2003
2625
  // panel says "not found"), so the response never tells which names exist.
@@ -2006,6 +2628,11 @@ export function handleWebRequest(req, res, url, ctx) {
2006
2628
  json(res, 400, { error: "invalid instance name" });
2007
2629
  return true;
2008
2630
  }
2631
+ // AgEnD Hub P1: the Hub's pages live on a Hub's own listener (slice 1), never on this fleet's: the ordinary not-found.
2632
+ if (shell?.kind === "shell" && shell.route.panel === "hub") {
2633
+ json(res, 404, { error: "not found" });
2634
+ return true;
2635
+ }
2009
2636
  if (shell?.kind === "shell") {
2010
2637
  serveAppShell(req, res, ctx, "full");
2011
2638
  return true;
@@ -2067,7 +2694,7 @@ export function handleWebRequest(req, res, url, ctx) {
2067
2694
  json(res, 403, { error: "admin_required" });
2068
2695
  return;
2069
2696
  }
2070
- if (!body || Array.isArray(body) || typeof body !== "object" || Object.keys(body).some(k => k !== "backend" && k !== "instance")) {
2697
+ if (!body || Array.isArray(body) || typeof body !== "object" || Object.keys(body).some(k => !["backend", "instance", "runtime", "machineId", "profile"].includes(k))) {
2071
2698
  json(res, 400, { error: "invalid model target" });
2072
2699
  return;
2073
2700
  }
@@ -2076,22 +2703,107 @@ export function handleWebRequest(req, res, url, ctx) {
2076
2703
  json(res, 400, { error: "invalid model target" });
2077
2704
  return;
2078
2705
  }
2079
- if (!ctx.refreshModelCatalogFor) {
2706
+ const runtime = body.runtime, machineId = body.machineId, profile = body.profile;
2707
+ if (runtime !== undefined && runtime !== "windows" && runtime !== "wsl" || machineId !== undefined && (typeof machineId !== "string" || !/^[a-f0-9-]{36}$/i.test(machineId)) || profile !== undefined && (typeof profile !== "string" || profile !== "" && !/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(profile))) {
2708
+ json(res, 400, { error: "invalid model target" });
2709
+ return;
2710
+ }
2711
+ const target = { backend, instance, ...(runtime ? { runtime: runtime } : {}), ...(machineId ? { machineId: machineId } : {}), ...(profile !== undefined ? { profile: profile } : {}) };
2712
+ let result, fleetAnswered = false;
2713
+ try {
2714
+ result = await refreshNativeModelCatalog(req, url, ctx, target);
2715
+ // Recheck after runtime selection, before any portable probe is admitted.
2716
+ if (!permitWebContinuation(req, res, ctx))
2717
+ return;
2718
+ if (adminAdmissionOf(req, url, ctx) !== admission) {
2719
+ json(res, 403, { error: "admin_required" });
2720
+ return;
2721
+ }
2722
+ if (!result) {
2723
+ if (machineId || !ctx.refreshModelCatalogFor) {
2724
+ json(res, 503, { error: "model_refresh_unavailable" });
2725
+ return;
2726
+ }
2727
+ result = await (profile !== undefined ? ctx.refreshModelCatalogFor(backend, instance, { profile: profile }) : ctx.refreshModelCatalogFor(backend, instance));
2728
+ fleetAnswered = true;
2729
+ }
2730
+ }
2731
+ catch {
2732
+ if (!permitWebContinuation(req, res, ctx))
2733
+ return;
2080
2734
  json(res, 503, { error: "model_refresh_unavailable" });
2081
2735
  return;
2082
2736
  }
2083
- const result = await ctx.refreshModelCatalogFor(backend, instance);
2084
2737
  if (!permitWebContinuation(req, res, ctx))
2085
2738
  return;
2086
2739
  if (adminAdmissionOf(req, url, ctx) !== admission) {
2087
2740
  json(res, 403, { error: "admin_required" });
2088
2741
  return;
2089
2742
  }
2090
- json(res, 200, { backend, ...result });
2743
+ // The refreshed list is shaped as the passive read is (a refresh answered by a computer's own runtime is its own).
2744
+ // When the fleet answered, `webCatalog` re-reads the cache the refresh has just written, through the same shaping
2745
+ // as GET /ui/models, rather than shaping `result.models`: that list is the flat one (it has lost which tier each
2746
+ // model came from, and claude's aliases / [1m] variants are in it), so only the cache read can be grouped right.
2747
+ const models = fleetAnswered && Array.isArray(result.models) ? webCatalog(ctx, backend, instance, typeof profile === "string" ? profile : null, result.models) : result.models;
2748
+ // claude with no account list (the refresh could not read it, or the account has none) is answered as GET /ui/models
2749
+ // answers it: the documentation's ids, marked unverified — never an empty list that shows nothing to pick.
2750
+ if (fleetAnswered && backend === "claude-code" && Array.isArray(models) && models.length === 0) {
2751
+ json(res, 200, { backend, ...result, models: documentedClaudeCatalog(ctx), source: "official-catalog" });
2752
+ return;
2753
+ }
2754
+ json(res, 200, { backend, ...result, models });
2091
2755
  })().catch(() => { if (!res.headersSent)
2092
2756
  json(res, 500, { error: "model_refresh_failed" }); });
2093
2757
  return true;
2094
2758
  }
2759
+ // AGEND-163: an agent's portable settings as a file, and the way back. Both only compute (nothing is written: loading a
2760
+ // file fills the Settings form, and the person still saves it there), and both are for the admin, as Settings is.
2761
+ if (method === "POST" && (path === "/ui/agent-export/build" || path === "/ui/agent-export/parse")) {
2762
+ const admission = adminAdmissionOf(req, url, ctx);
2763
+ if (!admission) {
2764
+ json(res, 403, { error: "admin_required" });
2765
+ return true;
2766
+ }
2767
+ void (async () => {
2768
+ let body;
2769
+ try {
2770
+ body = await parseBody(req);
2771
+ }
2772
+ catch {
2773
+ json(res, 400, { error: "Invalid JSON" });
2774
+ return;
2775
+ }
2776
+ if (!permitWebContinuation(req, res, ctx))
2777
+ return;
2778
+ if (adminAdmissionOf(req, url, ctx) !== admission) {
2779
+ json(res, 403, { error: "admin_required" });
2780
+ return;
2781
+ }
2782
+ if (!body || Array.isArray(body) || typeof body !== "object") {
2783
+ json(res, 400, { error: "invalid_request" });
2784
+ return;
2785
+ }
2786
+ if (path === "/ui/agent-export/parse") {
2787
+ json(res, 200, parseAgentExport(body.text));
2788
+ return;
2789
+ }
2790
+ const name = body.instance, include = body.include;
2791
+ if (typeof name !== "string" || !isSafeInstanceName(name) || !Array.isArray(include) || include.some(g => typeof g !== "string")) {
2792
+ json(res, 400, { error: "invalid_request" });
2793
+ return;
2794
+ }
2795
+ // The agent's own saved settings: `ctx.fleetConfig.instances[name]` has the fleet's defaults merged into it, and an export
2796
+ // must hold only what this agent itself sets.
2797
+ const inst = Object.hasOwn(ctx.fleetConfig?.instances ?? {}, name) ? ctx.rawInstanceConfig?.(name) : undefined;
2798
+ if (!inst) {
2799
+ json(res, 404, { error: "unknown_instance" });
2800
+ return;
2801
+ }
2802
+ json(res, 200, buildAgentExport(name, inst, include));
2803
+ })().catch(() => { if (!res.headersSent)
2804
+ json(res, 500, { error: "agent_export_failed" }); });
2805
+ return true;
2806
+ }
2095
2807
  if (method === "GET" && path === "/ui/models") {
2096
2808
  const backend = url.searchParams.get("backend") ?? "";
2097
2809
  const instance = url.searchParams.get("instance");
@@ -2099,7 +2811,67 @@ export function handleWebRequest(req, res, url, ctx) {
2099
2811
  json(res, 400, { error: "backend (and optional instance) required" });
2100
2812
  return true;
2101
2813
  }
2102
- json(res, 200, { backend, models: ctx.modelCatalogFor?.(backend, instance) ?? [] });
2814
+ const runtime = url.searchParams.get("runtime"), refresh = url.searchParams.get("refresh");
2815
+ const machineId = url.searchParams.get("machineId");
2816
+ if (machineId !== null && (!/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(machineId) || runtime === "wsl")) {
2817
+ json(res, 400, { error: "Invalid model runtime machine" });
2818
+ return true;
2819
+ }
2820
+ if ((runtime !== null && runtime !== "wsl" && runtime !== "windows") || (refresh !== null && refresh !== "1")) {
2821
+ json(res, 400, { error: "Invalid model catalog options" });
2822
+ return true;
2823
+ }
2824
+ const profile = url.searchParams.get("profile");
2825
+ if (profile !== null && profile !== "" && !/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(profile)) {
2826
+ json(res, 400, { error: "Invalid model account" });
2827
+ return true;
2828
+ }
2829
+ if (handleNativeModelCatalog(req, res, url, ctx))
2830
+ return true;
2831
+ const models = webCatalog(ctx, backend, instance, profile);
2832
+ // claude with no account list — with or without a credential profile — is answered with the documentation's ids.
2833
+ const answerCatalog = () => {
2834
+ if (backend === "claude-code" && !models.length)
2835
+ json(res, 200, { backend, models: documentedClaudeCatalog(ctx), source: "official-catalog" });
2836
+ else
2837
+ json(res, 200, { backend, models });
2838
+ };
2839
+ // The existing catalog belongs to this instance/account and always wins.
2840
+ if (models.length || !ctx.cliModelCatalogFor || profile !== null) {
2841
+ answerCatalog();
2842
+ return true;
2843
+ }
2844
+ const canAnswer = () => !res.headersSent && !res.destroyed && !res.writableEnded && stillAuthorized(req, res, url, ctx);
2845
+ void (async () => {
2846
+ const cliModels = await ctx.cliModelCatalogFor?.(backend, instance) ?? [];
2847
+ if (!canAnswer())
2848
+ return;
2849
+ const shaped = shapeWebModelCatalog(backend, cliModels);
2850
+ if (shaped.length)
2851
+ json(res, 200, { backend, models: shaped, source: "cli-cache" });
2852
+ else
2853
+ answerCatalog();
2854
+ })().catch(() => {
2855
+ if (canAnswer())
2856
+ json(res, 503, { error: "CLI model cache unavailable" });
2857
+ });
2858
+ return true;
2859
+ }
2860
+ // The effort levels Settings → Runtime & model's dropdown offers for an agent and a (not yet saved) model — the chat chip's list.
2861
+ if (method === "GET" && path === "/ui/effort-options") {
2862
+ const instance = url.searchParams.get("instance") ?? "", model = url.searchParams.get("model");
2863
+ if (!instance || !isSafeInstanceName(instance) || (model !== null && (model.length > 256 || /[\x00-\x1f\x7f]/.test(model)))) {
2864
+ json(res, 400, { error: "instance (and optional model) required" });
2865
+ return true;
2866
+ }
2867
+ if (!Object.hasOwn(ctx.fleetConfig?.instances ?? {}, instance) || !ctx.effortOptionsFor) {
2868
+ json(res, 404, { error: "Not available" });
2869
+ return true;
2870
+ }
2871
+ const { levels, effort, source } = ctx.effortOptionsFor(instance, model || null);
2872
+ // `model`: the one saved for the agent (empty: it follows the default), so the page can tell a model it has not saved yet.
2873
+ const saved = ctx.fleetConfig.instances[instance].model;
2874
+ json(res, 200, { instance, levels, effort, source, model: typeof saved === "string" ? saved : "" });
2103
2875
  return true;
2104
2876
  }
2105
2877
  if (method === "GET" && path === "/ui/backends") {
@@ -2305,6 +3077,143 @@ export function handleWebRequest(req, res, url, ctx) {
2305
3077
  json(res, 200, { messages, boot: ctx.webChatHistory?.boot ?? null, lastId: ctx.webChatHistory?.lastId ?? 0, ...(allHidden ? { allHidden: true } : {}) });
2306
3078
  return true;
2307
3079
  }
3080
+ // ── #3212 PR 1: Settings → Agents → Accounts (read-only) ─────────────────────────────────
3081
+ // Each CLI's default sign-in and credential profiles, who uses them and their weekly usage. Names, states, the masked
3082
+ // identity and the host login command (which, as in the sign-in list, names the profile's folder) — no credential or
3083
+ // full e-mail: only for the fleet's local admin session — never the public link, a guest, a token or the gateway (the
3084
+ // same rule as the sign-in list it extends).
3085
+ if (method === "GET" && path === "/ui/accounts") {
3086
+ res.setHeader("Cache-Control", "private, no-store");
3087
+ if (gatewayRequestContext(req)) {
3088
+ json(res, 404, { error: "not_found" });
3089
+ return true;
3090
+ }
3091
+ const localAdmin = () => {
3092
+ const v = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
3093
+ return v.kind === "allow" && v.via === "session" && v.session.tier === "admin" && v.session.surface === "local" ? v.session : null;
3094
+ };
3095
+ const who = localAdmin();
3096
+ if (!who) {
3097
+ json(res, 403, { error: "accounts_need_a_local_admin" });
3098
+ return true;
3099
+ }
3100
+ if (typeof ctx.accountsView !== "function") {
3101
+ json(res, 404, { error: "not_found" });
3102
+ return true;
3103
+ }
3104
+ void ctx.accountsView().then(view => {
3105
+ if (localAdmin()?.handle !== who.handle) {
3106
+ json(res, 403, { error: "accounts_need_a_local_admin" });
3107
+ return;
3108
+ }
3109
+ json(res, 200, view);
3110
+ }, err => { ctx.logger.error({ err: err.message }, "Accounts view failed"); json(res, 500, { error: "could not read the accounts" }); });
3111
+ return true;
3112
+ }
3113
+ // ── #3153 P1: an agent's Files / Changes (read-only) ─────────────────────────────────
3114
+ // The fleet's local admin session only: never the public link, a guest, a token or a connection from outside. One
3115
+ // agent's own working directory (agent-workspace.ts confines and filters every path); not General or a coordinator
3116
+ // (they work in the fleet's own directory), not an agent on another machine.
3117
+ if (method === "GET" && path === "/ui/workspace") {
3118
+ res.setHeader("Cache-Control", "private, no-store");
3119
+ res.setHeader("X-Content-Type-Options", "nosniff");
3120
+ if (gatewayRequestContext(req)) {
3121
+ json(res, 404, { error: "not_found" });
3122
+ return true;
3123
+ }
3124
+ const localAdmin = () => {
3125
+ const v = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
3126
+ return v.kind === "allow" && v.via === "session" && v.session.tier === "admin" && v.session.surface === "local" ? v.session : null;
3127
+ };
3128
+ const who = localAdmin();
3129
+ if (!who) {
3130
+ json(res, 403, { error: "workspace_needs_a_local_admin" });
3131
+ return true;
3132
+ }
3133
+ const p = url.searchParams, instance = p.get("instance") ?? "", op = p.get("op") ?? "";
3134
+ const cfg = ctx.fleetConfig?.instances && Object.hasOwn(ctx.fleetConfig.instances, instance) ? ctx.fleetConfig.instances[instance] : undefined;
3135
+ if (!cfg) {
3136
+ json(res, 404, { error: "not_found" });
3137
+ return true;
3138
+ }
3139
+ const offered = !isGeneralInstance(ctx.fleetConfig, instance) && resolveToolSet(cfg, instance) !== "coordinator"
3140
+ && cfg.runtime !== "windows" && !cfg.machine_id;
3141
+ if (!offered) {
3142
+ json(res, 404, { error: "workspace_not_offered" });
3143
+ return true;
3144
+ }
3145
+ if (!["changes", "list", "file", "image", "diff", "follow"].includes(op)) {
3146
+ json(res, 400, { error: "op: changes | list | file | image | diff | follow" });
3147
+ return true;
3148
+ }
3149
+ const workDir = String(cfg.working_directory ?? "").replace(/^~(?=$|\/)/, process.env.HOME ?? "~");
3150
+ const backend = String(cfg.backend ?? ctx.fleetConfig?.defaults?.backend ?? "claude-code");
3151
+ const daemon = ctx.daemons.get(instance);
3152
+ void (async () => {
3153
+ try {
3154
+ const ws = await workspaceRoot(workDir, getAgendHome());
3155
+ // The session must still be the same one when the answer goes out (it may have ended while git ran).
3156
+ const answer = async () => {
3157
+ if (op === "changes")
3158
+ return { kind: "json", body: await workspaceChanges(ws) };
3159
+ if (op === "list")
3160
+ return { kind: "json", body: await workspaceList(ws, p.get("path") ?? "") };
3161
+ if (op === "file")
3162
+ return { kind: "json", body: await workspaceFile(ws, p.get("path")) };
3163
+ if (op === "diff")
3164
+ return { kind: "json", body: await workspaceFileDiff(ws, p.get("path")) };
3165
+ if (op === "follow") {
3166
+ // #3160: this turn's file steps, from the CLI's own record, confined to this folder (outside paths dropped,
3167
+ // secret-looking ones marked hidden). Polled by an open panel with Follow on; nothing is pushed.
3168
+ const supported = backend === "claude-code" || backend === "codex";
3169
+ const d = daemon;
3170
+ const after = Number(p.get("after") ?? 0), turnQ = p.get("turn");
3171
+ const snap = supported && d && typeof d.workspaceFollow === "function"
3172
+ ? d.workspaceFollow(Number.isSafeInteger(after) && after >= 0 ? after : 0, turnQ !== null && /^\d{1,9}$/.test(turnQ) ? Number(turnQ) : undefined, p.get("scope") ?? undefined)
3173
+ : { scope: "", turn: 0, steps: [], last: 0 };
3174
+ return { kind: "json", body: { supported, running: !!d, scope: snap.scope, turn: snap.turn, last: snap.last, steps: await resolveFollowSteps(ws, snap.steps) } };
3175
+ }
3176
+ return { kind: "image", body: await workspaceImage(ws, p.get("path")) };
3177
+ };
3178
+ const out = await answer();
3179
+ if (localAdmin()?.handle !== who.handle) {
3180
+ json(res, 403, { error: "workspace_needs_a_local_admin" });
3181
+ return;
3182
+ }
3183
+ const current = ctx.fleetConfig?.instances[instance];
3184
+ if (current !== cfg || String(current.working_directory ?? "").replace(/^~(?=$|\/)/, process.env.HOME ?? "~") !== workDir
3185
+ || String(current.backend ?? ctx.fleetConfig?.defaults?.backend ?? "claude-code") !== backend
3186
+ || current.runtime === "windows" || current.machine_id || isGeneralInstance(ctx.fleetConfig, instance)
3187
+ || resolveToolSet(current, instance) === "coordinator" || (op === "follow" && ctx.daemons.get(instance) !== daemon)) {
3188
+ json(res, 403, { error: "workspace_changed" });
3189
+ return;
3190
+ }
3191
+ if (op === "follow" && out.kind === "json") {
3192
+ const frame = out.body;
3193
+ const live = daemon;
3194
+ if (frame.supported && frame.running && frame.scope && live?.workspaceFollow?.(0).scope !== frame.scope) {
3195
+ json(res, 403, { error: "workspace_changed" });
3196
+ return;
3197
+ }
3198
+ }
3199
+ if (out.kind === "image") {
3200
+ res.writeHead(200, { "Content-Type": out.body.mime, "Content-Length": String(out.body.bytes.length), "Content-Security-Policy": "default-src 'none'; sandbox" });
3201
+ res.end(out.body.bytes);
3202
+ return;
3203
+ }
3204
+ json(res, 200, out.body);
3205
+ }
3206
+ catch (err) {
3207
+ if (err instanceof WorkspaceError) {
3208
+ json(res, err.code === "not_found" || err.code === "not_a_directory" ? 404 : 403, { error: err.code });
3209
+ return;
3210
+ }
3211
+ ctx.logger.error({ err: err.message, instance }, "Workspace read failed");
3212
+ json(res, 500, { error: "could not read the folder" });
3213
+ }
3214
+ })();
3215
+ return true;
3216
+ }
2308
3217
  // ── #1218: the Log tab ─────────────────────────────────
2309
3218
  // An instance's steps, read on demand from its own transcript (log-service.ts). Read-only, and offered on the public
2310
3219
  // link on purpose (the user's decision): the same masking applies to every viewer. Passive (web-auth.ts).
@@ -2525,115 +3434,31 @@ export function handleWebRequest(req, res, url, ctx) {
2525
3434
  json(res, typeof r.status === "number" ? r.status : 503, { error: r.error });
2526
3435
  return;
2527
3436
  }
2528
- json(res, 200, r);
2529
- })().catch(err => {
2530
- ctx.logger.error({ err: err.message }, "Theme reset/lock failed");
2531
- try {
2532
- json(res, 500, { error: "Theme change failed" });
2533
- }
2534
- catch { /* already answered */ }
2535
- });
2536
- return true;
2537
- }
2538
- // ── Fleet → Org chart → Office: the offices people made (web-offices.json, web-office-store.ts) ──
2539
- // GET /ui/offices: { rev, offices, readable } for whoever may open the org chart (the public link too: it reads the
2540
- // chart; a guest's routes do not include it). PUT /ui/offices { offices, rev? }: a person's change, as a theme's reset
2541
- // or lock is — an admin session only, never the CLI token, never the public link (absent from its manifest, and
2542
- // refused here too); asked again once the body is in. Every page hears `offices` on the stream and reads again.
2543
- if (method === "GET" && path === "/ui/offices") {
2544
- const store = ctx.officeStore;
2545
- if (!store) {
2546
- json(res, 404, { error: "Offices are not kept on this fleet" });
2547
- return true;
2548
- }
2549
- json(res, 200, store.list());
2550
- return true;
2551
- }
2552
- if (method === "PUT" && path === "/ui/offices") {
2553
- const store = ctx.officeStore;
2554
- if (!store) {
2555
- json(res, 404, { error: "Offices are not kept on this fleet" });
2556
- return true;
2557
- }
2558
- if (gatewayRequestContext(req)) {
2559
- json(res, 403, { error: "offices_not_over_public_link" });
2560
- return true;
2561
- }
2562
- // The person (an admin session's account), or the status that refuses the request.
2563
- const who = () => {
2564
- const verdict = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
2565
- if (verdict.kind !== "allow")
2566
- return { status: 401 };
2567
- return verdict.via === "session" && verdict.session?.tier === "admin" ? { person: verdict.session.owner ? webPersonKey(verdict.session.owner) : "admin-session" } : { status: 403 };
2568
- };
2569
- const refuse = (status) => json(res, status, { error: status === 401 ? WEB_TOKEN_INVALID_MESSAGE : "offices_need_an_admin_session" });
2570
- const first = who();
2571
- if ("status" in first) {
2572
- refuse(first.status);
2573
- return true;
2574
- }
2575
- (async () => {
2576
- let body;
2577
- try {
2578
- body = await parseBody(req);
2579
- }
2580
- catch {
2581
- json(res, 400, { error: "Invalid JSON" });
2582
- return;
2583
- }
2584
- if (!permitWebContinuation(req, res, ctx))
2585
- return;
2586
- const now = who();
2587
- if ("status" in now) {
2588
- refuse(now.status);
2589
- return;
2590
- }
2591
- if (!body || typeof body !== "object" || Array.isArray(body)) {
2592
- json(res, 400, { error: "offices required" });
2593
- return;
2594
- }
2595
- const extra = Object.keys(body).find(k => k !== "offices" && k !== "rev");
2596
- if (extra !== undefined) {
2597
- json(res, 400, { error: "offices_invalid", detail: `unknown key "${extra}"` });
2598
- return;
2599
- }
2600
- // Office review: the rev the page read is required — a save without one would overwrite another person's unseen.
2601
- if (body.rev === undefined) {
2602
- json(res, 428, { error: "offices_rev_required", detail: "send the rev you read (GET /ui/offices)" });
2603
- return;
2604
- }
2605
- if (!Number.isSafeInteger(body.rev)) {
2606
- json(res, 400, { error: "offices_invalid", detail: "rev: an integer" });
2607
- return;
2608
- }
2609
- const limiter = ctx.officeWrites, allowed = limiter ? limiter.check(now.person) : { ok: true };
2610
- if (!allowed.ok) {
2611
- res.setHeader("Retry-After", String(allowed.retry_after_s));
2612
- json(res, 429, { error: "offices_rate_limited", retry_after_s: allowed.retry_after_s });
2613
- return;
2614
- }
2615
- const r = store.replace(body.offices, body.rev);
2616
- if (!r.ok) {
2617
- json(res, r.status, { error: r.error, ...(r.detail ? { detail: r.detail } : {}) });
2618
- return;
2619
- }
2620
- limiter?.record(now.person);
2621
- ctx.emitSseEvent("offices", { rev: r.rev });
2622
- json(res, 200, { rev: r.rev, offices: r.offices });
3437
+ json(res, 200, r);
2623
3438
  })().catch(err => {
2624
- ctx.logger.error({ err: err.message }, "Saving offices failed");
3439
+ ctx.logger.error({ err: err.message }, "Theme reset/lock failed");
2625
3440
  try {
2626
- json(res, 500, { error: "Saving offices failed" });
3441
+ json(res, 500, { error: "Theme change failed" });
2627
3442
  }
2628
3443
  catch { /* already answered */ }
2629
3444
  });
2630
3445
  return true;
2631
3446
  }
2632
- // #2716: PUT /ui/office-style { skin }: the whole-fleet office's style for every viewer, device and share link (a skin
2633
- // id, or null for the default; read back as GET /ui/offices's autoSkin). Who may save the offices may set it, as they
2634
- // would: an admin session, never the CLI token or the public link; asked again once the body is in; counted with the
2635
- // offices' saves. Every page hears `offices` and reads again.
2636
- if (method === "PUT" && path === "/ui/office-style") {
3447
+ // ── Fleet → Org chart → Office: the offices people made (web-offices.json, web-office-store.ts) ──
3448
+ // GET /ui/offices: { rev, offices, readable } for whoever may open the org chart (the public link too: it reads the
3449
+ // chart; a guest's routes do not include it). PUT /ui/offices { offices, rev? }: a person's change, as a theme's reset
3450
+ // or lock is — an admin session only, never the CLI token, never the public link (absent from its manifest, and
3451
+ // refused here too); asked again once the body is in. Every page hears `offices` on the stream and reads again.
3452
+ if (method === "GET" && path === "/ui/offices") {
3453
+ const store = ctx.officeStore;
3454
+ if (!store) {
3455
+ json(res, 404, { error: "Offices are not kept on this fleet" });
3456
+ return true;
3457
+ }
3458
+ json(res, 200, store.list());
3459
+ return true;
3460
+ }
3461
+ if (method === "PUT" && path === "/ui/offices") {
2637
3462
  const store = ctx.officeStore;
2638
3463
  if (!store) {
2639
3464
  json(res, 404, { error: "Offices are not kept on this fleet" });
@@ -2643,6 +3468,7 @@ export function handleWebRequest(req, res, url, ctx) {
2643
3468
  json(res, 403, { error: "offices_not_over_public_link" });
2644
3469
  return true;
2645
3470
  }
3471
+ // The person (an admin session's account), or the status that refuses the request.
2646
3472
  const who = () => {
2647
3473
  const verdict = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
2648
3474
  if (verdict.kind !== "allow")
@@ -2671,8 +3497,22 @@ export function handleWebRequest(req, res, url, ctx) {
2671
3497
  refuse(now.status);
2672
3498
  return;
2673
3499
  }
2674
- if (!body || typeof body !== "object" || Array.isArray(body) || !("skin" in body) || Object.keys(body).some(k => k !== "skin")) {
2675
- json(res, 400, { error: "office_style_invalid", detail: "{ skin: a skin id, or null }" });
3500
+ if (!body || typeof body !== "object" || Array.isArray(body)) {
3501
+ json(res, 400, { error: "offices required" });
3502
+ return;
3503
+ }
3504
+ const extra = Object.keys(body).find(k => k !== "offices" && k !== "rev");
3505
+ if (extra !== undefined) {
3506
+ json(res, 400, { error: "offices_invalid", detail: `unknown key "${extra}"` });
3507
+ return;
3508
+ }
3509
+ // Office review: the rev the page read is required — a save without one would overwrite another person's unseen.
3510
+ if (body.rev === undefined) {
3511
+ json(res, 428, { error: "offices_rev_required", detail: "send the rev you read (GET /ui/offices)" });
3512
+ return;
3513
+ }
3514
+ if (!Number.isSafeInteger(body.rev)) {
3515
+ json(res, 400, { error: "offices_invalid", detail: "rev: an integer" });
2676
3516
  return;
2677
3517
  }
2678
3518
  const limiter = ctx.officeWrites, allowed = limiter ? limiter.check(now.person) : { ok: true };
@@ -2681,23 +3521,38 @@ export function handleWebRequest(req, res, url, ctx) {
2681
3521
  json(res, 429, { error: "offices_rate_limited", retry_after_s: allowed.retry_after_s });
2682
3522
  return;
2683
3523
  }
2684
- const r = store.setAutoSkin(body.skin);
3524
+ const r = store.replace(body.offices, body.rev);
2685
3525
  if (!r.ok) {
2686
3526
  json(res, r.status, { error: r.error, ...(r.detail ? { detail: r.detail } : {}) });
2687
3527
  return;
2688
3528
  }
2689
3529
  limiter?.record(now.person);
2690
3530
  ctx.emitSseEvent("offices", { rev: r.rev });
2691
- json(res, 200, { rev: r.rev, autoSkin: r.autoSkin });
3531
+ json(res, 200, { rev: r.rev, offices: r.offices });
2692
3532
  })().catch(err => {
2693
- ctx.logger.error({ err: err.message }, "Saving the office style failed");
3533
+ ctx.logger.error({ err: err.message }, "Saving offices failed");
2694
3534
  try {
2695
- json(res, 500, { error: "Saving the office style failed" });
3535
+ json(res, 500, { error: "Saving offices failed" });
2696
3536
  }
2697
3537
  catch { /* already answered */ }
2698
3538
  });
2699
3539
  return true;
2700
3540
  }
3541
+ // #2716: PUT /ui/office-style { skin }: the whole-fleet office's style for every viewer, device and share link (a skin
3542
+ // id, or null for the default; read back as GET /ui/offices's autoSkin). Who may save the offices may set it, as they
3543
+ // would: an admin session, never the CLI token or the public link; asked again once the body is in; counted with the
3544
+ // offices' saves. Every page hears `offices` and reads again.
3545
+ if (method === "PUT" && path === "/ui/office-style") {
3546
+ return officeSettingPut(req, res, url, ctx, { key: "skin", invalid: "office_style_invalid", shape: "{ skin: a skin id, or null }", failed: "Saving the office style failed",
3547
+ apply: (store, v) => { const r = store.setAutoSkin(v); return r.ok ? { ok: true, rev: r.rev, answer: { autoSkin: r.autoSkin } } : r; } });
3548
+ }
3549
+ // #3679: PUT /ui/office-level-titles { levels }: the fleet's own Office level titles for every office (`{ titles?,
3550
+ // fixed? }`, a pack's rules; null: none — read back as GET /ui/offices's levels). A pack's own `levels` still win for
3551
+ // the offices drawn in it (on the page). Who may set the style may set these, the same way.
3552
+ if (method === "PUT" && path === "/ui/office-level-titles") {
3553
+ return officeSettingPut(req, res, url, ctx, { key: "levels", invalid: "office_levels_invalid", shape: "{ levels: { titles?, fixed? }, or null }", failed: "Saving the level titles failed",
3554
+ apply: (store, v) => { const r = store.setLevels(v); return r.ok ? { ok: true, rev: r.rev, answer: { levels: r.levels } } : r; } });
3555
+ }
2701
3556
  // #2578: GET /ui/office-acts { acts }: the agents' live acts (office_set), read as the offices are (the public link
2702
3557
  // too, which has no stream); every change also comes as `office_acts` on the stream. Nothing here writes one.
2703
3558
  if (method === "GET" && path === "/ui/office-acts") {
@@ -3089,6 +3944,13 @@ export function handleWebRequest(req, res, url, ctx) {
3089
3944
  return handleBrowserBackendSignIns(req, res, url, ctx);
3090
3945
  if (path === "/ui/backend-login" || path.startsWith("/ui/backend-login/"))
3091
3946
  return handleBackendLogin(req, res, url, ctx, path, method);
3947
+ if (path === "/ui/host-install" || path === "/ui/host-install/cancel" || path === "/ui/host-update")
3948
+ return handleHostInstall(req, res, url, ctx, path, method);
3949
+ // #3292: before the accounts prefix — its Add pattern (`POST /ui/accounts/<backend>`) would read "keep-alive" as a backend.
3950
+ if (path === "/ui/accounts/keep-alive")
3951
+ return handleAccountKeepAlive(req, res, url, ctx, method);
3952
+ if (path.startsWith("/ui/accounts/"))
3953
+ return handleAccountWrite(req, res, url, ctx, path, method);
3092
3954
  // #1386: Acknowledge a "Needs you" delivery item — a session write (CSRF, checked by the gate) or the CLI's header
3093
3955
  // token. Who did it is recorded by principal: the session's public handle, never the session id or a credential.
3094
3956
  // #2910 D2: a web-only fleet's Notices — what General would have said. Admins only (never a guest: not in
@@ -3132,6 +3994,281 @@ export function handleWebRequest(req, res, url, ctx) {
3132
3994
  });
3133
3995
  return true;
3134
3996
  }
3997
+ // ── #3008: connections from outside (a web-only fleet) ──
3998
+ // GET /ui/outside: the state (any admin; over the outside link too, read-only). What changes it is an admin's, over a
3999
+ // direct connection (the fleet asks the live session each time; the public link refuses these routes outright):
4000
+ // POST /ui/outside/enroll (a new secret, shown once; AGEND-122: {code} — the current one — while the owner's stricter
4001
+ // option is on and this is not the AgEnD computer), POST /ui/outside/enroll/confirm {code}, POST /ui/outside/remove
4002
+ // ({code} likewise), POST /ui/outside/strict {on, code?} (your own "ask for my code" switch) and POST /ui/outside/switch {on} — the
4003
+ // switch stays this computer's admin's, on a web-only fleet. Each acts on the caller's own authenticator only (per admin).
4004
+ // Never a guest (not in GUEST_ROUTES).
4005
+ if (method === "GET" && path === "/ui/outside") {
4006
+ res.setHeader("Cache-Control", "no-store");
4007
+ json(res, 200, ctx.webOutsideStatus?.(req) ?? { webOnly: false, here: false, manage: false, codeNeeded: false, strict: false, enrolled: false, enrolledAt: null, outside: false, pausedForMs: 0, link: null });
4008
+ return true;
4009
+ }
4010
+ if (method === "POST" && (path === "/ui/outside/enroll" || path === "/ui/outside/enroll/confirm" || path === "/ui/outside/remove" || path === "/ui/outside/switch" || path === "/ui/outside/strict")) {
4011
+ if (gatewayRequestContext(req)) {
4012
+ json(res, 403, { error: "outside_not_here" });
4013
+ return true;
4014
+ }
4015
+ (async () => {
4016
+ let body;
4017
+ try {
4018
+ body = await parseBody(req);
4019
+ }
4020
+ catch {
4021
+ json(res, 400, { error: "Invalid JSON" });
4022
+ return;
4023
+ }
4024
+ if (!permitWebContinuation(req, res, ctx))
4025
+ return;
4026
+ res.setHeader("Cache-Control", "no-store");
4027
+ // AGEND-122: replacing or removing the authenticator asks for the current code while the owner's stricter option is on
4028
+ // and this is not the AgEnD computer's own browser (the fleet decides); the answer to a missing or wrong one is its own.
4029
+ const stepCode = body && typeof body === "object" && typeof body.code === "string" && body.code.length <= 32 ? body.code : undefined;
4030
+ const refusal = (r) => {
4031
+ if (r.error === "paused") {
4032
+ res.setHeader("Retry-After", String(Math.ceil((r.retryAfterMs ?? 60_000) / 1000)));
4033
+ json(res, 429, { error: "paused", retryAfterMs: r.retryAfterMs ?? null });
4034
+ return;
4035
+ }
4036
+ json(res, r.error === "wrong" ? 401 : r.error === "unavailable" ? 503 : r.error === "code_required" ? 400 : 403, { error: r.error === "not_here" ? "outside_not_here" : r.error });
4037
+ };
4038
+ if (path === "/ui/outside/enroll") {
4039
+ const r = ctx.webOutsideBeginEnrollment?.(req, stepCode) ?? null;
4040
+ if (!r) {
4041
+ json(res, 403, { error: "outside_not_here" });
4042
+ return;
4043
+ }
4044
+ if ("error" in r) {
4045
+ refusal(r);
4046
+ return;
4047
+ }
4048
+ json(res, 200, r);
4049
+ return;
4050
+ }
4051
+ if (path === "/ui/outside/enroll/confirm") {
4052
+ const code = body && typeof body === "object" ? body.code : undefined;
4053
+ if (typeof code !== "string" || code.length > 32) {
4054
+ json(res, 400, { error: "code required" });
4055
+ return;
4056
+ }
4057
+ const r = ctx.webOutsideConfirmEnrollment?.(req, code) ?? "not_here";
4058
+ json(res, r === "ok" ? 200 : r === "not_here" ? 403 : r === "unsaved" ? 503 : r === "full" ? 409 : 400, r === "ok" ? { ok: true } : { error: r === "not_here" ? "outside_not_here" : r });
4059
+ return;
4060
+ }
4061
+ if (path === "/ui/outside/remove") {
4062
+ const r = ctx.webOutsideRemove?.(req, stepCode) ?? "not_here";
4063
+ if (typeof r === "object") {
4064
+ refusal(r);
4065
+ return;
4066
+ }
4067
+ json(res, r === "ok" ? 200 : r === "unsaved" ? 503 : 403, r === "ok" ? { ok: true } : { error: r === "unsaved" ? "unsaved" : "outside_not_here" });
4068
+ return;
4069
+ }
4070
+ const on = body && typeof body === "object" ? body.on : undefined;
4071
+ if (typeof on !== "boolean") {
4072
+ json(res, 400, { error: "on must be true or false" });
4073
+ return;
4074
+ }
4075
+ if (path === "/ui/outside/strict") {
4076
+ // AGEND-122 (per admin): the caller's OWN "ask for my code" switch — on needs their app and asks nothing, off asks their current code.
4077
+ const sr = ctx.webOutsideStrict?.(req, on, stepCode) ?? "not_here";
4078
+ if (typeof sr === "object") {
4079
+ refusal(sr);
4080
+ return;
4081
+ }
4082
+ json(res, sr === "ok" ? 200 : sr === "not_here" ? 403 : sr === "unsaved" ? 503 : 409, sr === "ok" ? { ok: true } : { error: sr === "not_here" ? "outside_not_here" : sr });
4083
+ return;
4084
+ }
4085
+ const r = ctx.webOutsideSwitch?.(req, on) ?? "not_here";
4086
+ json(res, r === "ok" ? 200 : r === "not_here" ? 403 : r === "unsaved" ? 503 : 409, r === "ok" ? { ok: true } : { error: r === "not_here" ? "outside_not_here" : r });
4087
+ })().catch(err => {
4088
+ ctx.logger.error({ err: err.message }, "Outside connections change failed");
4089
+ try {
4090
+ json(res, 500, { error: "outside_failed" });
4091
+ }
4092
+ catch { /* already answered */ }
4093
+ });
4094
+ return true;
4095
+ }
4096
+ // ── Refs #3061 (P2a): signing a new device in with its 8-character code (a web-only fleet) ──
4097
+ // GET /ui/devices: whether this is such a fleet and whether THIS session may approve (it is the verified owner — this
4098
+ // computer's admin here, or signed in from outside with the authenticator's code). POST /ui/devices/lookup {code}: the
4099
+ // request that code names, for the confirm screen; POST /ui/devices/approve {code} and /ui/devices/deny {code}. Every
4100
+ // one asks the live session again in the fleet (webDeviceLoginAct) and answers 403 `owner_required` to anyone else —
4101
+ // a guest, a LAN or device-approved session, the CLI's header token. Over the public link only for the owner who
4102
+ // signed in from outside. A decision hands the new device nothing: its session is made by its own next poll.
4103
+ if (method === "GET" && path === "/ui/devices") {
4104
+ res.setHeader("Cache-Control", "no-store");
4105
+ json(res, 200, ctx.webDevicesStatus?.(req) ?? { webOnly: false, owner: false, devices: [] });
4106
+ return true;
4107
+ }
4108
+ // Refs #3061 (P2b): POST /ui/devices/signout {handle} — the verified owner ends another signed-in device. The same
4109
+ // authority as approving one, asked of the live session in the fleet after the body is in (webDeviceSignOut answers
4110
+ // 403 `owner_required` to anyone else before it looks the handle up). Over the public link only for the owner signed in
4111
+ // from outside, like approving.
4112
+ if (method === "POST" && path === "/ui/devices/signout") {
4113
+ const act = ctx.webDeviceSignOut?.bind(ctx);
4114
+ if (!act) {
4115
+ json(res, 404, { error: "not_found" });
4116
+ return true;
4117
+ }
4118
+ (async () => {
4119
+ let body;
4120
+ try {
4121
+ body = await parseBody(req);
4122
+ }
4123
+ catch {
4124
+ json(res, 400, { error: "Invalid JSON" });
4125
+ return;
4126
+ }
4127
+ if (!permitWebContinuation(req, res, ctx))
4128
+ return;
4129
+ const handle = body && typeof body === "object" ? body.handle : undefined;
4130
+ if (typeof handle !== "string" || !/^[0-9a-f]{16}$/.test(handle)) {
4131
+ json(res, 400, { error: "handle required" });
4132
+ return;
4133
+ }
4134
+ res.setHeader("Cache-Control", "no-store");
4135
+ const r = act(req, handle);
4136
+ json(res, r.status, r.body);
4137
+ })().catch(err => {
4138
+ ctx.logger.error({ err: err.message }, "Device sign-out failed");
4139
+ try {
4140
+ json(res, 500, { error: "devices_failed" });
4141
+ }
4142
+ catch { /* already answered */ }
4143
+ });
4144
+ return true;
4145
+ }
4146
+ // S-120 (D2a): POST /ui/public-link/close — 「立即關閉公開連結」 in Settings → 存取與安全 → 總覽. An admin session on this
4147
+ // fleet's own listener only: never over the public link itself (the gateway does not route it; refused here too), never
4148
+ // a guest, a read-only session or the CLI's header token. It only closes — nothing here opens a link — the way the chat
4149
+ // menu's 確定關閉 does (its remembered owner forgotten, so auto_open never reopens a deliberate close). A web-only fleet's
4150
+ // outside link is the owner's switch on this computer (#3008): 409 outside_link, left open.
4151
+ if (method === "POST" && path === "/ui/public-link/close") {
4152
+ if (gatewayRequestContext(req)) {
4153
+ json(res, 403, { error: "public_link_close_not_here" });
4154
+ return true;
4155
+ }
4156
+ const act = ctx.closePublicLinkFromWeb?.bind(ctx);
4157
+ if (!act) {
4158
+ json(res, 404, { error: "not_found" });
4159
+ return true;
4160
+ }
4161
+ (async () => {
4162
+ try {
4163
+ await parseBody(req);
4164
+ }
4165
+ catch {
4166
+ json(res, 400, { error: "Invalid JSON" });
4167
+ return;
4168
+ }
4169
+ if (!permitWebContinuation(req, res, ctx))
4170
+ return;
4171
+ const verdict = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
4172
+ if (verdict.kind !== "allow") {
4173
+ json(res, 401, { error: WEB_TOKEN_INVALID_MESSAGE });
4174
+ return;
4175
+ }
4176
+ if (verdict.via !== "session" || verdict.session?.tier !== "admin") {
4177
+ json(res, 403, { error: "public_link_close_needs_an_admin_session" });
4178
+ return;
4179
+ }
4180
+ res.setHeader("Cache-Control", "no-store");
4181
+ const r = await act();
4182
+ json(res, r.status, r.body);
4183
+ })().catch(err => {
4184
+ ctx.logger.error({ err: err.message }, "Public link close failed");
4185
+ try {
4186
+ json(res, 500, { error: "public_link_close_failed" });
4187
+ }
4188
+ catch { /* already answered */ }
4189
+ });
4190
+ return true;
4191
+ }
4192
+ if (method === "POST" && (path === "/ui/devices/lookup" || path === "/ui/devices/approve" || path === "/ui/devices/deny")) {
4193
+ const act = ctx.webDeviceLoginAct?.bind(ctx);
4194
+ if (!act) {
4195
+ json(res, 404, { error: "not_found" });
4196
+ return true;
4197
+ }
4198
+ const op = path === "/ui/devices/lookup" ? "lookup" : path === "/ui/devices/approve" ? "approve" : "deny";
4199
+ (async () => {
4200
+ let body;
4201
+ try {
4202
+ body = await parseBody(req);
4203
+ }
4204
+ catch {
4205
+ json(res, 400, { error: "Invalid JSON" });
4206
+ return;
4207
+ }
4208
+ if (!permitWebContinuation(req, res, ctx))
4209
+ return;
4210
+ const code = body && typeof body === "object" ? body.code : undefined;
4211
+ if (typeof code !== "string" || code.length > 32) {
4212
+ json(res, 400, { error: "code required" });
4213
+ return;
4214
+ }
4215
+ res.setHeader("Cache-Control", "no-store");
4216
+ const r = act(req, op, code);
4217
+ if (typeof r.body.retryAfterMs === "number")
4218
+ res.setHeader("Retry-After", String(Math.ceil(r.body.retryAfterMs / 1000)));
4219
+ json(res, r.status, r.body);
4220
+ })().catch(err => {
4221
+ ctx.logger.error({ err: err.message }, "New device approval failed");
4222
+ try {
4223
+ json(res, 500, { error: "devices_failed" });
4224
+ }
4225
+ catch { /* already answered */ }
4226
+ });
4227
+ return true;
4228
+ }
4229
+ // ── alpha.2 (M-2300): an agent's Windows request, decided by a web-only fleet's owner in Needs you ──
4230
+ // The list is the owner's only: anyone else (a guest, a LAN or public-link session, a chat fleet's admin) reads an
4231
+ // empty one, so nothing actionable ever reaches them. The stream's `agent_proposals` event carries nothing.
4232
+ if (method === "GET" && path === "/ui/agent-proposals") {
4233
+ const list = ctx.webAgentProposals?.(req) ?? null;
4234
+ json(res, 200, { owner: list !== null, proposals: list ?? [] });
4235
+ return true;
4236
+ }
4237
+ const proposalMatch = method === "POST" ? /^\/ui\/agent-proposals\/([0-9a-f]{32})$/.exec(path) : null;
4238
+ if (proposalMatch) {
4239
+ if (!ctx.webDecideAgentProposal) {
4240
+ json(res, 404, { error: "not_found" });
4241
+ return true;
4242
+ }
4243
+ const decide = ctx.webDecideAgentProposal.bind(ctx), id = proposalMatch[1];
4244
+ (async () => {
4245
+ let body;
4246
+ try {
4247
+ body = await parseBody(req);
4248
+ }
4249
+ catch {
4250
+ json(res, 400, { error: "Invalid JSON" });
4251
+ return;
4252
+ }
4253
+ if (!permitWebContinuation(req, res, ctx))
4254
+ return;
4255
+ const decision = body && typeof body === "object" ? body.decision : undefined;
4256
+ if (decision !== "confirm" && decision !== "reject") {
4257
+ json(res, 400, { error: "decision must be confirm or reject" });
4258
+ return;
4259
+ }
4260
+ const r = await decide(req, id, decision);
4261
+ if (!res.headersSent && !res.destroyed)
4262
+ json(res, r.status, r.body);
4263
+ })().catch(err => {
4264
+ ctx.logger.error({ err: err.message }, "Agent request decision failed");
4265
+ try {
4266
+ json(res, 500, { error: "decide_failed" });
4267
+ }
4268
+ catch { /* already answered */ }
4269
+ });
4270
+ return true;
4271
+ }
3135
4272
  if (method === "POST" && path === "/ui/needs/ack") {
3136
4273
  if (!ctx.acknowledgeNeedsItem) {
3137
4274
  json(res, 404, { error: "Nothing to acknowledge here" });
@@ -3257,6 +4394,20 @@ export function handleWebRequest(req, res, url, ctx) {
3257
4394
  json(res, 400, { error: "instance and command required" });
3258
4395
  return;
3259
4396
  }
4397
+ if (isNativeExecInstance(ctx.fleetConfig?.instances[instance])) {
4398
+ json(res, 400, { error: "This runtime does not support CLI control commands; use Agent settings or Cancel" });
4399
+ return;
4400
+ }
4401
+ if (isNativePaneInstance(ctx.fleetConfig?.instances[instance])) {
4402
+ if (!nativeCliAuthorization(req, url, ctx)) {
4403
+ json(res, 403, { error: "Windows runtime requires an administrator on the local dashboard" });
4404
+ return;
4405
+ }
4406
+ if (command !== "model") {
4407
+ json(res, 400, { error: "This persistent Windows runtime supports the model command; use its shared controls for other actions" });
4408
+ return;
4409
+ }
4410
+ }
3260
4411
  if (body.args !== undefined && str(body.args, MAX_COMMAND_ARGS) === undefined) {
3261
4412
  json(res, 400, { error: "args too long" });
3262
4413
  return;
@@ -3296,6 +4447,28 @@ export function handleWebRequest(req, res, url, ctx) {
3296
4447
  guestCommandsRunning.add(account);
3297
4448
  ctx.guestCommandRuns?.record(account);
3298
4449
  }
4450
+ if (isNativePaneInstance(ctx.fleetConfig?.instances[instance]) && body.action) {
4451
+ if (command !== "model" || body.action !== "refresh" || body.args) {
4452
+ json(res, 400, { error: "invalid model action" });
4453
+ return;
4454
+ }
4455
+ const target = ctx.fleetConfig.instances[instance];
4456
+ try {
4457
+ const refreshed = await refreshNativeModelCatalog(req, url, ctx, { backend: target.backend, instance });
4458
+ if (!stillAuthorized(req, res, url, ctx))
4459
+ return;
4460
+ if (!refreshed || ctx.fleetConfig?.instances[instance] !== target || !nativeCliAuthorization(req, url, ctx)) {
4461
+ json(res, 409, { error: "model target changed" });
4462
+ return;
4463
+ }
4464
+ json(res, 200, { choices: { current: target.model ?? null, options: refreshed.models.map(m => ({ id: m.id, label: m.label })), actions: ["refresh"] } });
4465
+ }
4466
+ catch {
4467
+ if (stillAuthorized(req, res, url, ctx))
4468
+ json(res, 503, { error: t("model.refresh_failed") });
4469
+ }
4470
+ return;
4471
+ }
3299
4472
  try {
3300
4473
  const { authority } = confirmAfterBody(arrival, webAuthorityOf(req, url, ctx, instance));
3301
4474
  const r = await run({ instance, command, args: str(body.args, MAX_COMMAND_ARGS), confirm: body.confirm, ...(body.action ? { action: body.action } : {}) }, { publicLink: !!gatewayRequestContext(req), person, authority, ...(guest ? { guest: true } : {}) });
@@ -3531,11 +4704,26 @@ export function handleWebRequest(req, res, url, ctx) {
3531
4704
  const body = await parseBody(req);
3532
4705
  if (!permitWebContinuation(req, res, ctx))
3533
4706
  return;
4707
+ if (body?.runtime === "windows") {
4708
+ await createNativeInstance(req, res, url, ctx, body);
4709
+ return;
4710
+ }
3534
4711
  const v = validateArgs(CreateInstanceArgs, body, "create_instance");
3535
4712
  if (!v.ok) {
3536
4713
  json(res, 400, { error: v.error });
3537
4714
  return;
3538
4715
  }
4716
+ // The account the form picked for this host's CLI: checked here, before anything is created, and written as the
4717
+ // agent's own backend_options.<cli>.credential_profile so its first start already runs under it.
4718
+ const account = resolveCreateAccount(ctx.dataDir, v.data, ctx.fleetConfig?.defaults?.backend);
4719
+ if (!account.ok) {
4720
+ const { ok: _ok, status, ...rest } = account;
4721
+ json(res, status, rest);
4722
+ return;
4723
+ }
4724
+ delete v.data.credentialProfile;
4725
+ if (account.backendOptions)
4726
+ v.data.backend_options = account.backendOptions;
3539
4727
  let result = null;
3540
4728
  let error;
3541
4729
  const respond = (r, e) => { result = r; error = e; };
@@ -4295,15 +5483,18 @@ function uploadRecipient(ctx, name) {
4295
5483
  /** Closed, path-free explanations; arbitrary launch errors stay in the host log. */
4296
5484
  function webDeliveryFailure(err) {
4297
5485
  const message = err instanceof Error ? err.message : "";
5486
+ // M-2297: the per-PC agent limit — say so, with the agents holding its slots (names only: no path, no id).
5487
+ if (err instanceof MachineSlotLimitError)
5488
+ return { reason: "machine_limit", error: message, limit: err.limit, holders: err.holders.map(h => ({ name: h.name, unknown: h.unknown })) };
4298
5489
  if (/No warm slot is free/.test(message))
4299
5490
  return { reason: "wake_capacity", error: "No slot is free to wake this instance. Retry when another instance is idle." };
4300
5491
  if (/login|log in|sign in|\bauth(?:entication|orization)?\b|credential|api.?key/i.test(message))
4301
- return { reason: "wake_credentials", error: "The instance could not sign in. Check its account on the host, then retry." };
5492
+ return { reason: "wake_credentials", error: "The instance could not sign in. Connect its AI account in Settings → Agents → AI accounts and API keys → Accounts, or send /login in chat, then retry." };
4302
5493
  if (/timed? out|timeout/i.test(message))
4303
- return { reason: "wake_timeout", error: "The instance did not become ready in time. Retry, or check its status on the host." };
5494
+ return { reason: "wake_timeout", error: "The instance did not become ready in time. Retry, or check its status in Fleet." };
4304
5495
  if (/Cannot wake stopped|no longer configured/.test(message))
4305
- return { reason: "instance_stopped", error: "This instance was stopped or removed. Start it on the host before retrying." };
4306
- return { reason: "delivery_unavailable", error: "The instance could not receive this message. Check its status on the host, then retry." };
5496
+ return { reason: "instance_stopped", error: "This instance was stopped or removed. Start it from the agent's chat menu → Start instance, then retry." };
5497
+ return { reason: "delivery_unavailable", error: "The instance could not receive this message. Check its status in Fleet, then retry." };
4307
5498
  }
4308
5499
  /** Handle POST /ui/send — extracted for readability. */
4309
5500
  /** Each web server's own memory of the sends it accepted by clientId (web-send-dedupe.ts). */
@@ -4342,6 +5533,15 @@ function handleSendMessage(req, res, ctx) {
4342
5533
  return;
4343
5534
  }
4344
5535
  const { instance, message: typed, attachments = [], replyTo, clientId } = parsed.data;
5536
+ const native = isWindowsInstance(ctx.fleetConfig?.instances[instance]);
5537
+ if (native && !nativeCliAuthorization(req, new URL(req.url ?? "/", "http://localhost"), ctx)) {
5538
+ json(res, 403, { error: "Windows runtime requires an administrator on the local dashboard" });
5539
+ return;
5540
+ }
5541
+ if (native && attachments.length) {
5542
+ json(res, 400, { error: "Attachments are not supported by this runtime yet" });
5543
+ return;
5544
+ }
4345
5545
  // #1920 step 2b: a guest writes only to an in-scope instance, while guests may chat, and never a command.
4346
5546
  const guest = guestRequestOf(req);
4347
5547
  const refused = guestChatRefusal(guest, instance);
@@ -4395,6 +5595,16 @@ function handleSendMessage(req, res, ctx) {
4395
5595
  break;
4396
5596
  }
4397
5597
  }
5598
+ const locationHold = ctx.generalLocationDeliveryHold?.(instance);
5599
+ if (locationHold) {
5600
+ const messageId = newWebMessageId(), ts = new Date().toISOString();
5601
+ // Settle this client ID as answered. A Retry after reconnect must never queue its old input.
5602
+ acceptedId = messageId;
5603
+ ctx.emitSseEvent("message", { instance, sender: person.name, role: "user", text: typed, ts, messageId, ...(person.bound ? { from: person.voterKey } : {}), ...(clientId ? { clientId } : {}) });
5604
+ ctx.emitSseEvent("message", { instance, role: "status", sender: "AgEnD", text: locationHold, ts, messageId: newWebMessageId() });
5605
+ json(res, 200, { sent: true, messageId, serviceResponse: true });
5606
+ return;
5607
+ }
4398
5608
  let files = [];
4399
5609
  if (attachments.length > 0) {
4400
5610
  const taken = ctx.webFiles?.takeForMessage(instance, attachments);
@@ -4417,15 +5627,39 @@ function handleSendMessage(req, res, ctx) {
4417
5627
  // Recheck the same admission all the way through a wake, before the facade's actual IPC handoff.
4418
5628
  const requestUrl = new URL(req.url ?? "/", "http://localhost");
4419
5629
  const admission = admissionOf(req, requestUrl, ctx);
4420
- const stillCurrent = () => !res.destroyed && admission !== null && admissionOf(req, requestUrl, ctx) === admission
5630
+ // The sender's authority, without the request's own lifetime: the same admission, the same guest still allowed, the
5631
+ // instance still registered (a Windows one still Windows). A Windows turn is journaled before /ui/send answers and its
5632
+ // process starts after, so the bridge rechecks this one (a revoke in between still stops it); never res, which a
5633
+ // finished response marks destroyed (S-30: every web-chat turn to a Windows agent was refused).
5634
+ const authorityCurrent = () => admission !== null && admissionOf(req, requestUrl, ctx) === admission
4421
5635
  && (!guest || (guest.current() && !guestChatRefusal(guest, instance)))
4422
- && (registered ? registeredChatInstance(ctx, instance) : ctx.instanceIpcClients.has(instance));
5636
+ && (native ? isWindowsInstance(ctx.fleetConfig?.instances[instance]) && nativeCliAuthorization(req, requestUrl, ctx)
5637
+ : registered ? registeredChatInstance(ctx, instance) : ctx.instanceIpcClients.has(instance));
5638
+ const stillCurrent = () => !res.destroyed && authorityCurrent();
4423
5639
  const message = typed;
4424
5640
  // #1939 S1: what the receipt records about who authorized it (observe only: agents still read web as recognition).
4425
5641
  const { authority } = confirmAfterBody(arrival, webAuthorityOf(req, new URL(req.url ?? "/", "http://localhost"), ctx, instance));
4426
5642
  const ts = new Date().toISOString();
4427
5643
  // The id the agent is given, and the one its delivery reports come back under: the page's ticks.
4428
- const messageId = newWebMessageId();
5644
+ const nativeRequestId = isNativeExecInstance(ctx.fleetConfig?.instances[instance]) ? (() => {
5645
+ if (!clientId)
5646
+ return randomUUID();
5647
+ const hash = createHash("sha256").update(`agend-native-web\0${WebSendDedupe.key(person.key, instance, clientId)}`).digest("hex");
5648
+ return `${hash.slice(0, 8)}-${hash.slice(8, 12)}-4${hash.slice(13, 16)}-8${hash.slice(17, 20)}-${hash.slice(20, 32)}`;
5649
+ })() : undefined;
5650
+ const messageId = nativeRequestId ? `native:${nativeRequestId}:user` : newWebMessageId();
5651
+ if (nativeRequestId && ctx.nativeInstanceRuntime) {
5652
+ const previous = ctx.nativeInstanceRuntime().get(instance)?.turns.find(turn => turn.id === nativeRequestId);
5653
+ if (previous) {
5654
+ if (previous.prompt !== delivery.text) {
5655
+ json(res, 409, { error: "clientId belongs to a different message" });
5656
+ return;
5657
+ }
5658
+ acceptedId = messageId;
5659
+ json(res, 200, { sent: true, messageId, repeated: true });
5660
+ return;
5661
+ }
5662
+ }
4429
5663
  // Use real Telegram context so daemon's lastChatId/lastThreadId are set,
4430
5664
  // enabling reply tool even when first message comes from Web UI.
4431
5665
  // Pure Web UI mode (no channel config) leaves these empty; the agent's reply then comes back to the
@@ -4471,11 +5705,12 @@ function handleSendMessage(req, res, ctx) {
4471
5705
  let delivered;
4472
5706
  try {
4473
5707
  const deliver = (name, payload) => ctx.deliverHumanToInstance
4474
- ? ctx.deliverHumanToInstance(name, payload, webHumanOrigin(false, authority), typed, { stillCurrent })
4475
- : ctx.deliverToInstance(name, payload, { stillCurrent });
5708
+ ? ctx.deliverHumanToInstance(name, payload, webHumanOrigin(false, authority), typed, { stillCurrent, ...(native ? { authorityCurrent } : {}) })
5709
+ : ctx.deliverToInstance(name, payload, { stillCurrent, ...(native ? { authorityCurrent } : {}) });
4476
5710
  delivered = await deliver(instance, {
4477
5711
  type: "fleet_inbound",
4478
5712
  content: delivery.text,
5713
+ ...(nativeRequestId ? { requestId: nativeRequestId } : {}),
4479
5714
  targetSession: instance,
4480
5715
  meta: {
4481
5716
  chat_id: groupId ? String(groupId) : "",
@@ -4872,6 +6107,45 @@ function shellHtmlTag(ctx, mode, viewer) {
4872
6107
  function shellOwnerCss(ctx, mode, viewer) {
4873
6108
  return mode === "full" && !viewer?.guest && viewer?.person !== null && viewer?.person !== undefined && ctx.ownerCss ? ctx.ownerCss.active(viewer.person) : null;
4874
6109
  }
6110
+ /**
6111
+ * AgEnD Hub P1 (docs/design/hub.md, docs/design/hub-ui-client.md): the page's Hub mark — presentation only, never
6112
+ * authority, set by the listener that serves the page (never a client's choice): `member` on this fleet's listener when
6113
+ * `hub_member.enabled`, never over the public link. `hub` is only the Hub listener's own workspace page
6114
+ * (serveHubWorkspaceShell). Nothing otherwise: no Hub UI is drawn and no Hub module loads.
6115
+ */
6116
+ function hubBodyAttrs(req, ctx) {
6117
+ // alpha.6 user report: the mark read the parsed FleetConfig, which never has `hub_member` — a saved switch (or one in the
6118
+ // file at start) never marked the page, so Connect to a Hub never loaded. It reads what the runtime reads: the raw file.
6119
+ let config = null;
6120
+ try {
6121
+ config = (ctx.getRawFleetConfig?.() ?? null);
6122
+ }
6123
+ catch {
6124
+ config = null;
6125
+ }
6126
+ // hub.md §1: member handlers are local-owner-only and unavailable through the public gateway — no member mark there.
6127
+ const member = hubModeOf(config).member && !gatewayRequestContext(req) ? ' data-hub="member"' : "";
6128
+ // #3298 S-89 (leader, #3372 N2): Settings → Hub's Group permissions row only when this fleet's own Hub has them composed —
6129
+ // learned in this process, never by reading a Hub session across origins. Never over the public link.
6130
+ let groups = false;
6131
+ try {
6132
+ groups = ctx.hubGroupPermissions?.() === true;
6133
+ }
6134
+ catch {
6135
+ groups = false;
6136
+ }
6137
+ let setup = false;
6138
+ try {
6139
+ setup = !!ctx.hubSetupSession?.(req);
6140
+ }
6141
+ catch { /* unavailable authority never offers setup */ }
6142
+ return member + (groups && !gatewayRequestContext(req) ? ' data-hub-groups="1"' : "")
6143
+ + (setup && !gatewayRequestContext(req) ? ' data-hub-setup="1"' : "")
6144
+ + (setup && !gatewayRequestContext(req) && typeof ctx.hubDirectorySettings === "function"
6145
+ && !!config?.hub?.hubId ? ' data-hub-directory-settings="1"' : "")
6146
+ + (setup && !gatewayRequestContext(req) && typeof ctx.hubDirectoryNotices === "function"
6147
+ && !!config?.hub?.hubId ? ' data-hub-directory-notices="1"' : "");
6148
+ }
4875
6149
  function guestBodyAttrs(ctx, owner, attr) {
4876
6150
  const badge = ctx.guestBadge?.(owner);
4877
6151
  const trusted = ctx.guestTrusted?.(owner) ? ' data-guest-level="trusted"' : "";
@@ -4890,7 +6164,11 @@ function shellBodyTag(req, ctx, mode, viewer) {
4890
6164
  const admission = evaluateWebRequest(req, new URL(req.url ?? "/", "http://localhost"), ctx.webToken ?? null, ctx.webSessions, { touch: false });
4891
6165
  const childMark = mode === "full" && !gatewayRequestContext(req) && !viewer?.guest && admission.kind === "allow"
4892
6166
  && (admission.via !== "session" || admission.session.tier === "admin");
4893
- return `<body data-mode="${mode}"${childMark ? ' data-subagents="1"' : ""}${mode === "full" && gatewayRequestContext(req) ? ' data-web-transport="poll"' : ""} data-dashboard-origin="${attr(p?.dashboardOrigin)}" data-preview-origin="${attr(p?.previewOrigin)}"`
6167
+ // #3637: display-only capability and a non-authorizing namespace. No account/session/token value reaches storage.
6168
+ const workspaceMark = mode === "full" && !gatewayRequestContext(req) && !viewer?.guest && admission.kind === "allow";
6169
+ const workspaceScope = workspaceMark && viewer?.person && ctx.webToken
6170
+ ? createHmac("sha256", ctx.webToken).update(`agend-chat-layout-v1\0${viewer.person}`).digest("hex") : null;
6171
+ return `<body data-mode="${mode}"${childMark ? ' data-subagents="1"' : ""}${workspaceMark ? ' data-chat-workspace="1"' : ""}${workspaceScope ? ` data-chat-layout-scope="${workspaceScope}"` : ""}${mode === "full" && gatewayRequestContext(req) ? ' data-web-transport="poll"' : ""} data-dashboard-origin="${attr(p?.dashboardOrigin)}" data-preview-origin="${attr(p?.previewOrigin)}"`
4894
6172
  + ` data-preview-boot="${attr(p?.previewOrigin ? p.boot : "")}" data-preview-reason="${attr(p ? p.reason : "Previews are not available on this fleet.")}"`
4895
6173
  // #1554: no availability asked (the public link, or not the full app) still says why, in the page's language.
4896
6174
  + ` data-preview-reason-code="${attr(p ? p.code ?? "" : gatewayRequestContext(req) ? "publicLink" : "notOffered")}"`
@@ -4911,12 +6189,47 @@ function shellBodyTag(req, ctx, mode, viewer) {
4911
6189
  + `${gatewayRequestContext(req) ? ' data-public-link="1"' : ""}`
4912
6190
  // #2478: search is offered over the public link unless web.search.public_link is false (the page then shows no entry).
4913
6191
  + `${gatewayRequestContext(req) && ctx.fleetConfig?.web?.search?.public_link === false ? ' data-search-link="0"' : ""}`
6192
+ // AgEnD Hub P1 (docs/design/hub-ui-client.md): the Hub's marks — only when a switch is on, never on a guest's page.
6193
+ + `${mode === "full" && !viewer?.guest ? hubBodyAttrs(req, ctx) : ""}`
4914
6194
  // #1920 phase 3: a guest's page — the shell shows only what a guest may use, and who it is signed in as.
4915
6195
  + `${mode === "full" && viewer?.guest && viewer.owner ? guestBodyAttrs(ctx, viewer.owner, attr) : ""}>`;
4916
6196
  }
6197
+ /**
6198
+ * AgEnD Hub P1, slice 3: the app shell as a Hub's own workspace (served only by the Hub's listener, at its own origin).
6199
+ * It boots Hub-only (app.js: no fleet stream, chat, Needs you, preferences or themes). Nothing of the request is read
6200
+ * — no cookie (the fleet's or the Hub's), no session, no Host: who is signed in is the page's own /hub/v1/session.
6201
+ */
6202
+ export const HUB_SHELL_DROPS = '<script src="/assets/agend-auth.js"></script>';
6203
+ export function serveHubWorkspaceShell(res, hub) {
6204
+ try {
6205
+ // Without the fleet's fetch wrapper (agend-auth.js): it reads the fleet's /auth/session for a CSRF value and answers
6206
+ // a 401 with the fleet's "session ended" banner. The Hub's pages carry the Hub's own CSRF (hub-client.js).
6207
+ const html = readFileSync(join(__dirname, "ui", "app.html"), "utf-8").replace(HUB_SHELL_DROPS, "");
6208
+ const attr = (v) => v.replace(/[&<>"']/g, c => `&#${c.charCodeAt(0)};`);
6209
+ const name = hubNameOf(hub.name);
6210
+ const preview = hub.preview;
6211
+ const previewAttrs = preview ? ` data-dashboard-origin="${attr(preview.dashboardOrigin)}"`
6212
+ + (preview.previewOrigin && preview.bootId ? ` data-preview-origin="${attr(preview.previewOrigin)}" data-preview-boot="${attr(preview.bootId)}"`
6213
+ : ` data-preview-reason-code="${attr(preview.reasonCode ?? "notOffered")}" data-preview-reason="${attr(preview.reason ?? "")}"`) : "";
6214
+ const body = `<body data-mode="full" data-web-transport="none" data-usage-panel="0" data-log-tab="0" data-hub="hub"${name ? ` data-hub-name="${attr(name)}"` : ""}${previewAttrs}>`;
6215
+ sendPanelHtml(res, withAppIconLinks(html).replace("<body>", body), 200, { "Cache-Control": "no-store" }, { mediaSrc: "'none'", ...(preview?.previewOrigin ? { frameSrc: `${preview.previewOrigin}/frame` } : {}) });
6216
+ }
6217
+ catch {
6218
+ json(res, 500, { error: "app.html not found" });
6219
+ }
6220
+ }
4917
6221
  /** The app shell page for one entry, under the panels' CSP; it may frame exactly <preview origin>/frame, and only
4918
6222
  * when this load chose one. */
4919
- export function serveAppShell(req, res, ctx, mode) {
6223
+ /**
6224
+ * The app shell page. `opts.hubWorkspace`: the page is a Hub's own workspace (slice 1's Hub listener only — the fleet's
6225
+ * listener never passes it), so it is drawn as the Hub shell.
6226
+ */
6227
+ export function serveAppShell(req, res, ctx, mode, opts = {}) {
6228
+ // A Hub workspace is drawn from nothing of this fleet's: no fleet cookie, session, preference or preview is read.
6229
+ if (opts.hubWorkspace) {
6230
+ serveHubWorkspaceShell(res, opts.hubWorkspace);
6231
+ return;
6232
+ }
4920
6233
  try {
4921
6234
  const html = readFileSync(join(__dirname, "ui", "app.html"), "utf-8");
4922
6235
  const viewer = mode === "full" ? prefsViewer(req, new URL(req.url ?? "/", "http://localhost"), ctx) : null;