@songsid/agend 2.4.0-alpha.2 → 2.4.0-alpha.4

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 (654) hide show
  1. package/dist/account-isolation.d.ts +6 -0
  2. package/dist/account-isolation.js +40 -0
  3. package/dist/account-isolation.js.map +1 -0
  4. package/dist/accounts-signout.d.ts +15 -2
  5. package/dist/accounts-signout.js +52 -4
  6. package/dist/accounts-signout.js.map +1 -1
  7. package/dist/accounts-view.d.ts +114 -27
  8. package/dist/accounts-view.js +123 -60
  9. package/dist/accounts-view.js.map +1 -1
  10. package/dist/agent-cli-instructions.md +15 -9
  11. package/dist/agent-cli.js +47 -20
  12. package/dist/agent-cli.js.map +1 -1
  13. package/dist/agent-endpoint.js +23 -8
  14. package/dist/agent-endpoint.js.map +1 -1
  15. package/dist/agent-list-output.d.ts +23 -0
  16. package/dist/agent-list-output.js +53 -0
  17. package/dist/agent-list-output.js.map +1 -0
  18. package/dist/agent-runtime-change.js +4 -4
  19. package/dist/agent-runtime-change.js.map +1 -1
  20. package/dist/agent-whats-new.js +9 -7
  21. package/dist/agent-whats-new.js.map +1 -1
  22. package/dist/antigravity-first-run.d.ts +4 -0
  23. package/dist/antigravity-first-run.js +57 -0
  24. package/dist/antigravity-first-run.js.map +1 -0
  25. package/dist/antigravity-identity.d.ts +6 -0
  26. package/dist/antigravity-identity.js +27 -0
  27. package/dist/antigravity-identity.js.map +1 -0
  28. package/dist/antigravity-store.d.ts +22 -0
  29. package/dist/antigravity-store.js +79 -0
  30. package/dist/antigravity-store.js.map +1 -0
  31. package/dist/auth-api.js +11 -1
  32. package/dist/auth-api.js.map +1 -1
  33. package/dist/backend/agy-onboarding.d.ts +14 -0
  34. package/dist/backend/agy-onboarding.js +114 -0
  35. package/dist/backend/agy-onboarding.js.map +1 -0
  36. package/dist/backend/antigravity.d.ts +15 -0
  37. package/dist/backend/antigravity.js +44 -4
  38. package/dist/backend/antigravity.js.map +1 -1
  39. package/dist/backend/claude-code.d.ts +8 -0
  40. package/dist/backend/claude-code.js +11 -4
  41. package/dist/backend/claude-code.js.map +1 -1
  42. package/dist/backend/codex.js +7 -3
  43. package/dist/backend/codex.js.map +1 -1
  44. package/dist/backend/credential-profile.d.ts +22 -3
  45. package/dist/backend/credential-profile.js +61 -9
  46. package/dist/backend/credential-profile.js.map +1 -1
  47. package/dist/backend/grok.d.ts +19 -0
  48. package/dist/backend/grok.js +112 -1
  49. package/dist/backend/grok.js.map +1 -1
  50. package/dist/backend/types.d.ts +10 -0
  51. package/dist/backend/types.js.map +1 -1
  52. package/dist/backend-availability.d.ts +6 -0
  53. package/dist/backend-availability.js +11 -0
  54. package/dist/backend-availability.js.map +1 -1
  55. package/dist/browser-backend-signins.d.ts +9 -1
  56. package/dist/browser-backend-signins.js +9 -5
  57. package/dist/browser-backend-signins.js.map +1 -1
  58. package/dist/build-provenance.json +1 -1
  59. package/dist/channel/mcp-tools.js +10 -10
  60. package/dist/channel/mcp-tools.js.map +1 -1
  61. package/dist/child-process.d.ts +1 -0
  62. package/dist/child-process.js.map +1 -1
  63. package/dist/claude-auth-status.d.ts +1 -0
  64. package/dist/claude-auth-status.js +25 -0
  65. package/dist/claude-auth-status.js.map +1 -1
  66. package/dist/claude-model-observation.d.ts +71 -0
  67. package/dist/claude-model-observation.js +169 -0
  68. package/dist/claude-model-observation.js.map +1 -0
  69. package/dist/cli-capability.d.ts +104 -19
  70. package/dist/cli-capability.js +3 -1
  71. package/dist/cli-capability.js.map +1 -1
  72. package/dist/cli-caps-module.d.ts +14 -0
  73. package/dist/cli-caps-module.js +8 -1
  74. package/dist/cli-caps-module.js.map +1 -1
  75. package/dist/cli-registry-check.js +114 -18
  76. package/dist/cli-registry-check.js.map +1 -1
  77. package/dist/cli-registry.d.ts +116 -12
  78. package/dist/cli-registry.js +16 -1
  79. package/dist/cli-registry.js.map +1 -1
  80. package/dist/cli-spec-antigravity.d.ts +53 -11
  81. package/dist/cli-spec-antigravity.js +44 -13
  82. package/dist/cli-spec-antigravity.js.map +1 -1
  83. package/dist/cli-spec-claude-code.d.ts +14 -1
  84. package/dist/cli-spec-claude-code.js +5 -4
  85. package/dist/cli-spec-claude-code.js.map +1 -1
  86. package/dist/cli-spec-codex.d.ts +8 -0
  87. package/dist/cli-spec-codex.js +4 -3
  88. package/dist/cli-spec-codex.js.map +1 -1
  89. package/dist/cli-spec-grok.d.ts +4 -0
  90. package/dist/cli-spec-grok.js +2 -1
  91. package/dist/cli-spec-grok.js.map +1 -1
  92. package/dist/cli-spec-kiro-cli.d.ts +7 -0
  93. package/dist/cli-spec-kiro-cli.js +3 -2
  94. package/dist/cli-spec-kiro-cli.js.map +1 -1
  95. package/dist/cli-spec-muse.d.ts +4 -0
  96. package/dist/cli-spec-muse.js +2 -1
  97. package/dist/cli-spec-muse.js.map +1 -1
  98. package/dist/cli-spec-opencode.d.ts +1 -0
  99. package/dist/cli-spec-opencode.js +1 -0
  100. package/dist/cli-spec-opencode.js.map +1 -1
  101. package/dist/credential-store-proof.d.ts +6 -0
  102. package/dist/credential-store-proof.js +30 -0
  103. package/dist/credential-store-proof.js.map +1 -0
  104. package/dist/cross-instance-envelope.d.ts +4 -1
  105. package/dist/cross-instance-envelope.js +12 -7
  106. package/dist/cross-instance-envelope.js.map +1 -1
  107. package/dist/daemon.d.ts +24 -2
  108. package/dist/daemon.js +265 -37
  109. package/dist/daemon.js.map +1 -1
  110. package/dist/decision-list.d.ts +5 -4
  111. package/dist/decision-list.js +22 -8
  112. package/dist/decision-list.js.map +1 -1
  113. package/dist/delivery-consumed-watch.d.ts +24 -0
  114. package/dist/delivery-consumed-watch.js +21 -10
  115. package/dist/delivery-consumed-watch.js.map +1 -1
  116. package/dist/delivery-outbox.d.ts +5 -1
  117. package/dist/delivery-outbox.js +5 -0
  118. package/dist/delivery-outbox.js.map +1 -1
  119. package/dist/fleet-manager.d.ts +31 -2
  120. package/dist/fleet-manager.js +238 -56
  121. package/dist/fleet-manager.js.map +1 -1
  122. package/dist/fleet-windows-runtime.js +6 -6
  123. package/dist/fleet-windows-runtime.js.map +1 -1
  124. package/dist/general-knowledge/skills/concepts/SKILL.md +48 -7
  125. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +23 -6
  126. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +18 -8
  127. package/dist/general-knowledge/skills/fleet-health/SKILL.md +16 -0
  128. package/dist/general-knowledge/skills/hub/SKILL.md +518 -0
  129. package/dist/general-knowledge/skills/multi-channel/SKILL.md +1 -1
  130. package/dist/general-knowledge/skills/scheduling/SKILL.md +1 -1
  131. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +199 -40
  132. package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +5 -1
  133. package/dist/general-role.d.ts +1 -1
  134. package/dist/general-role.js +1 -0
  135. package/dist/general-role.js.map +1 -1
  136. package/dist/grok-delivery-proof.d.ts +24 -0
  137. package/dist/grok-delivery-proof.js +124 -0
  138. package/dist/grok-delivery-proof.js.map +1 -0
  139. package/dist/hub/assistant/admin-types.d.ts +43 -0
  140. package/dist/hub/assistant/admin-types.js +2 -0
  141. package/dist/hub/assistant/admin-types.js.map +1 -0
  142. package/dist/hub/assistant/claude-host.d.ts +17 -0
  143. package/dist/hub/assistant/claude-host.js +300 -0
  144. package/dist/hub/assistant/claude-host.js.map +1 -0
  145. package/dist/hub/assistant/context.d.ts +3 -0
  146. package/dist/hub/assistant/context.js +7 -0
  147. package/dist/hub/assistant/context.js.map +1 -0
  148. package/dist/hub/assistant/fleet-host.d.ts +19 -0
  149. package/dist/hub/assistant/fleet-host.js +28 -0
  150. package/dist/hub/assistant/fleet-host.js.map +1 -0
  151. package/dist/hub/assistant/runner.d.ts +64 -0
  152. package/dist/hub/assistant/runner.js +239 -0
  153. package/dist/hub/assistant/runner.js.map +1 -0
  154. package/dist/hub/assistant/service.d.ts +51 -0
  155. package/dist/hub/assistant/service.js +143 -0
  156. package/dist/hub/assistant/service.js.map +1 -0
  157. package/dist/hub/assistant/store.d.ts +3 -0
  158. package/dist/hub/assistant/store.js +65 -0
  159. package/dist/hub/assistant/store.js.map +1 -0
  160. package/dist/hub/assistant/types.d.ts +60 -0
  161. package/dist/hub/assistant/types.js +2 -0
  162. package/dist/hub/assistant/types.js.map +1 -0
  163. package/dist/hub/buttons.d.ts +3 -0
  164. package/dist/hub/buttons.js +11 -11
  165. package/dist/hub/buttons.js.map +1 -1
  166. package/dist/hub/catalog.d.ts +13 -6
  167. package/dist/hub/catalog.js +127 -35
  168. package/dist/hub/catalog.js.map +1 -1
  169. package/dist/hub/client.d.ts +16 -0
  170. package/dist/hub/client.js +52 -9
  171. package/dist/hub/client.js.map +1 -1
  172. package/dist/hub/compose/member.d.ts +8 -1
  173. package/dist/hub/compose/member.js +238 -57
  174. package/dist/hub/compose/member.js.map +1 -1
  175. package/dist/hub/compose/server.d.ts +17 -1
  176. package/dist/hub/compose/server.js +76 -13
  177. package/dist/hub/compose/server.js.map +1 -1
  178. package/dist/hub/directory/admission.d.ts +15 -0
  179. package/dist/hub/directory/admission.js +56 -0
  180. package/dist/hub/directory/admission.js.map +1 -0
  181. package/dist/hub/directory/directory.d.ts +1 -1
  182. package/dist/hub/directory/directory.js +114 -0
  183. package/dist/hub/directory/directory.js.map +1 -1
  184. package/dist/hub/directory/types.d.ts +27 -0
  185. package/dist/hub/directory/types.js.map +1 -1
  186. package/dist/hub/enrolment-code.d.ts +1 -1
  187. package/dist/hub/enrolment-code.js +4 -4
  188. package/dist/hub/enrolment-code.js.map +1 -1
  189. package/dist/hub/grant-access.d.ts +11 -0
  190. package/dist/hub/grant-access.js +113 -0
  191. package/dist/hub/grant-access.js.map +1 -0
  192. package/dist/hub/grant-search.d.ts +9 -0
  193. package/dist/hub/grant-search.js +92 -0
  194. package/dist/hub/grant-search.js.map +1 -0
  195. package/dist/hub/group-policy/admin-control.d.ts +1 -0
  196. package/dist/hub/group-policy/admin-control.js +4 -2
  197. package/dist/hub/group-policy/admin-control.js.map +1 -1
  198. package/dist/hub/group-policy/admin-facts.d.ts +1 -0
  199. package/dist/hub/group-policy/admin-facts.js +2 -1
  200. package/dist/hub/group-policy/admin-facts.js.map +1 -1
  201. package/dist/hub/group-policy/admin-impact.d.ts +2 -0
  202. package/dist/hub/group-policy/admin-impact.js +10 -2
  203. package/dist/hub/group-policy/admin-impact.js.map +1 -1
  204. package/dist/hub/group-policy/admin-inventory.js +1 -1
  205. package/dist/hub/group-policy/admin-inventory.js.map +1 -1
  206. package/dist/hub/group-policy/admin-read.d.ts +1 -0
  207. package/dist/hub/group-policy/admin-read.js +3 -2
  208. package/dist/hub/group-policy/admin-read.js.map +1 -1
  209. package/dist/hub/group-policy/authorization.d.ts +5 -2
  210. package/dist/hub/group-policy/authorization.js +73 -32
  211. package/dist/hub/group-policy/authorization.js.map +1 -1
  212. package/dist/hub/group-policy/errors.d.ts +9 -0
  213. package/dist/hub/group-policy/errors.js +13 -0
  214. package/dist/hub/group-policy/errors.js.map +1 -0
  215. package/dist/hub/group-policy/impact-inventory.js +20 -4
  216. package/dist/hub/group-policy/impact-inventory.js.map +1 -1
  217. package/dist/hub/group-policy/resources.d.ts +4 -5
  218. package/dist/hub/group-policy/resources.js +26 -19
  219. package/dist/hub/group-policy/resources.js.map +1 -1
  220. package/dist/hub/group-policy/store.d.ts +21 -12
  221. package/dist/hub/group-policy/store.js +99 -109
  222. package/dist/hub/group-policy/store.js.map +1 -1
  223. package/dist/hub/group-policy/welcome.js.map +1 -1
  224. package/dist/hub/http/compose.d.ts +1 -0
  225. package/dist/hub/http/compose.js +463 -20
  226. package/dist/hub/http/compose.js.map +1 -1
  227. package/dist/hub/http/core.d.ts +24 -5
  228. package/dist/hub/http/core.js +181 -54
  229. package/dist/hub/http/core.js.map +1 -1
  230. package/dist/hub/http/deps.d.ts +26 -0
  231. package/dist/hub/http/schema.js +19 -0
  232. package/dist/hub/http/schema.js.map +1 -1
  233. package/dist/hub/init/member-certificate.d.ts +1 -0
  234. package/dist/hub/init/member-certificate.js +39 -0
  235. package/dist/hub/init/member-certificate.js.map +1 -0
  236. package/dist/hub/init/plan-digest.js +1 -0
  237. package/dist/hub/init/plan-digest.js.map +1 -1
  238. package/dist/hub/invitations.d.ts +96 -0
  239. package/dist/hub/invitations.js +292 -0
  240. package/dist/hub/invitations.js.map +1 -0
  241. package/dist/hub/join/certificate-trust.d.ts +13 -0
  242. package/dist/hub/join/certificate-trust.js +41 -0
  243. package/dist/hub/join/certificate-trust.js.map +1 -0
  244. package/dist/hub/join/certificate.d.ts +11 -0
  245. package/dist/hub/join/certificate.js +67 -0
  246. package/dist/hub/join/certificate.js.map +1 -0
  247. package/dist/hub/join/client.d.ts +5 -0
  248. package/dist/hub/join/client.js +30 -3
  249. package/dist/hub/join/client.js.map +1 -1
  250. package/dist/hub/join/http.js +5 -3
  251. package/dist/hub/join/http.js.map +1 -1
  252. package/dist/hub/join/local.d.ts +37 -1
  253. package/dist/hub/join/local.js +142 -14
  254. package/dist/hub/join/local.js.map +1 -1
  255. package/dist/hub/join/service.d.ts +19 -0
  256. package/dist/hub/join/service.js +46 -35
  257. package/dist/hub/join/service.js.map +1 -1
  258. package/dist/hub/join/trust.d.ts +9 -0
  259. package/dist/hub/join/trust.js +35 -0
  260. package/dist/hub/join/trust.js.map +1 -1
  261. package/dist/hub/member/pairing-api.js +12 -1
  262. package/dist/hub/member/pairing-api.js.map +1 -1
  263. package/dist/hub/member/room-ask.d.ts +137 -0
  264. package/dist/hub/member/room-ask.js +358 -0
  265. package/dist/hub/member/room-ask.js.map +1 -0
  266. package/dist/hub/member-journal.d.ts +18 -1
  267. package/dist/hub/member-journal.js +76 -3
  268. package/dist/hub/member-journal.js.map +1 -1
  269. package/dist/hub/member-origin.d.ts +177 -0
  270. package/dist/hub/member-origin.js +314 -0
  271. package/dist/hub/member-origin.js.map +1 -0
  272. package/dist/hub/pairing-notices.d.ts +1 -0
  273. package/dist/hub/pairing-notices.js +2 -1
  274. package/dist/hub/pairing-notices.js.map +1 -1
  275. package/dist/hub/pairing.d.ts +11 -0
  276. package/dist/hub/pairing.js +69 -21
  277. package/dist/hub/pairing.js.map +1 -1
  278. package/dist/hub/policy.d.ts +1 -1
  279. package/dist/hub/policy.js +19 -6
  280. package/dist/hub/policy.js.map +1 -1
  281. package/dist/hub/protocol.d.ts +172 -0
  282. package/dist/hub/protocol.js +25 -2
  283. package/dist/hub/protocol.js.map +1 -1
  284. package/dist/hub/quota.d.ts +2 -1
  285. package/dist/hub/quota.js +2 -2
  286. package/dist/hub/quota.js.map +1 -1
  287. package/dist/hub/roles/authority.d.ts +45 -0
  288. package/dist/hub/roles/authority.js +199 -0
  289. package/dist/hub/roles/authority.js.map +1 -0
  290. package/dist/hub/roles/change.d.ts +18 -0
  291. package/dist/hub/roles/change.js +76 -0
  292. package/dist/hub/roles/change.js.map +1 -0
  293. package/dist/hub/roles/clock.d.ts +18 -0
  294. package/dist/hub/roles/clock.js +58 -0
  295. package/dist/hub/roles/clock.js.map +1 -0
  296. package/dist/hub/roles/convert.d.ts +11 -0
  297. package/dist/hub/roles/convert.js +27 -0
  298. package/dist/hub/roles/convert.js.map +1 -0
  299. package/dist/hub/roles/cutover-inventory.d.ts +14 -0
  300. package/dist/hub/roles/cutover-inventory.js +42 -0
  301. package/dist/hub/roles/cutover-inventory.js.map +1 -0
  302. package/dist/hub/roles/cutover-marker.d.ts +57 -0
  303. package/dist/hub/roles/cutover-marker.js +26 -0
  304. package/dist/hub/roles/cutover-marker.js.map +1 -0
  305. package/dist/hub/roles/cutover.d.ts +32 -0
  306. package/dist/hub/roles/cutover.js +170 -0
  307. package/dist/hub/roles/cutover.js.map +1 -0
  308. package/dist/hub/roles/delegation.d.ts +24 -0
  309. package/dist/hub/roles/delegation.js +111 -0
  310. package/dist/hub/roles/delegation.js.map +1 -0
  311. package/dist/hub/roles/evaluate.d.ts +50 -0
  312. package/dist/hub/roles/evaluate.js +96 -0
  313. package/dist/hub/roles/evaluate.js.map +1 -0
  314. package/dist/hub/roles/expiry.d.ts +46 -0
  315. package/dist/hub/roles/expiry.js +180 -0
  316. package/dist/hub/roles/expiry.js.map +1 -0
  317. package/dist/hub/roles/mode-effects.d.ts +5 -0
  318. package/dist/hub/roles/mode-effects.js +21 -0
  319. package/dist/hub/roles/mode-effects.js.map +1 -0
  320. package/dist/hub/roles/model.d.ts +171 -0
  321. package/dist/hub/roles/model.js +79 -0
  322. package/dist/hub/roles/model.js.map +1 -0
  323. package/dist/hub/roles/read.d.ts +33 -0
  324. package/dist/hub/roles/read.js +55 -0
  325. package/dist/hub/roles/read.js.map +1 -0
  326. package/dist/hub/roles/writer.d.ts +80 -0
  327. package/dist/hub/roles/writer.js +427 -0
  328. package/dist/hub/roles/writer.js.map +1 -0
  329. package/dist/hub/rooms/admin.d.ts +45 -0
  330. package/dist/hub/rooms/admin.js +105 -0
  331. package/dist/hub/rooms/admin.js.map +1 -0
  332. package/dist/hub/rooms/agents.d.ts +74 -0
  333. package/dist/hub/rooms/agents.js +333 -0
  334. package/dist/hub/rooms/agents.js.map +1 -0
  335. package/dist/hub/rooms/assistant.d.ts +44 -0
  336. package/dist/hub/rooms/assistant.js +179 -0
  337. package/dist/hub/rooms/assistant.js.map +1 -0
  338. package/dist/hub/rooms/context.d.ts +10 -0
  339. package/dist/hub/rooms/context.js +24 -0
  340. package/dist/hub/rooms/context.js.map +1 -0
  341. package/dist/hub/rooms/direct-view.d.ts +39 -0
  342. package/dist/hub/rooms/direct-view.js +38 -0
  343. package/dist/hub/rooms/direct-view.js.map +1 -0
  344. package/dist/hub/rooms/directory.d.ts +35 -0
  345. package/dist/hub/rooms/directory.js +98 -0
  346. package/dist/hub/rooms/directory.js.map +1 -0
  347. package/dist/hub/rooms/schema.d.ts +11 -0
  348. package/dist/hub/rooms/schema.js +73 -0
  349. package/dist/hub/rooms/schema.js.map +1 -0
  350. package/dist/hub/rooms/service.d.ts +449 -0
  351. package/dist/hub/rooms/service.js +581 -0
  352. package/dist/hub/rooms/service.js.map +1 -0
  353. package/dist/hub/rooms/types.d.ts +79 -0
  354. package/dist/hub/rooms/types.js +2 -0
  355. package/dist/hub/rooms/types.js.map +1 -0
  356. package/dist/hub/rooms.d.ts +15 -1
  357. package/dist/hub/rooms.js +76 -31
  358. package/dist/hub/rooms.js.map +1 -1
  359. package/dist/hub/runtime.d.ts +8 -0
  360. package/dist/hub/runtime.js +57 -3
  361. package/dist/hub/runtime.js.map +1 -1
  362. package/dist/hub/server.d.ts +28 -0
  363. package/dist/hub/server.js +66 -6
  364. package/dist/hub/server.js.map +1 -1
  365. package/dist/hub/sessions.js +6 -2
  366. package/dist/hub/sessions.js.map +1 -1
  367. package/dist/hub/settings-commit.d.ts +6 -1
  368. package/dist/hub/settings-commit.js +15 -0
  369. package/dist/hub/settings-commit.js.map +1 -1
  370. package/dist/hub/settings-directory-decision.d.ts +2 -2
  371. package/dist/hub/settings-directory-decision.js +7 -5
  372. package/dist/hub/settings-directory-decision.js.map +1 -1
  373. package/dist/hub/settings-directory-proof.js +3 -1
  374. package/dist/hub/settings-directory-proof.js.map +1 -1
  375. package/dist/hub/settings-directory-recovery.d.ts +5 -0
  376. package/dist/hub/settings-directory-recovery.js +14 -4
  377. package/dist/hub/settings-directory-recovery.js.map +1 -1
  378. package/dist/hub/settings-member-address-control.d.ts +84 -0
  379. package/dist/hub/settings-member-address-control.js +150 -0
  380. package/dist/hub/settings-member-address-control.js.map +1 -0
  381. package/dist/hub/settings-member-address-decision.d.ts +229 -0
  382. package/dist/hub/settings-member-address-decision.js +318 -0
  383. package/dist/hub/settings-member-address-decision.js.map +1 -0
  384. package/dist/hub/settings-member-address-http.d.ts +9 -0
  385. package/dist/hub/settings-member-address-http.js +78 -0
  386. package/dist/hub/settings-member-address-http.js.map +1 -0
  387. package/dist/hub/settings-member-address-network.d.ts +2 -0
  388. package/dist/hub/settings-member-address-network.js +22 -0
  389. package/dist/hub/settings-member-address-network.js.map +1 -0
  390. package/dist/hub/settings-member-address-notices.d.ts +22 -0
  391. package/dist/hub/settings-member-address-notices.js +21 -0
  392. package/dist/hub/settings-member-address-notices.js.map +1 -0
  393. package/dist/hub/settings-member-address-policy.d.ts +21 -0
  394. package/dist/hub/settings-member-address-policy.js +34 -0
  395. package/dist/hub/settings-member-address-policy.js.map +1 -0
  396. package/dist/hub/settings-member-address.d.ts +64 -0
  397. package/dist/hub/settings-member-address.js +239 -0
  398. package/dist/hub/settings-member-address.js.map +1 -0
  399. package/dist/hub/sharing.d.ts +10 -0
  400. package/dist/hub/sharing.js +74 -0
  401. package/dist/hub/sharing.js.map +1 -0
  402. package/dist/hub/socket.d.ts +2 -0
  403. package/dist/hub/socket.js +2 -0
  404. package/dist/hub/socket.js.map +1 -1
  405. package/dist/hub/store.js +6 -2
  406. package/dist/hub/store.js.map +1 -1
  407. package/dist/hub/teams/types.d.ts +41 -0
  408. package/dist/hub/teams/types.js +2 -0
  409. package/dist/hub/teams/types.js.map +1 -0
  410. package/dist/hub/tls.d.ts +47 -0
  411. package/dist/hub/tls.js +23 -6
  412. package/dist/hub/tls.js.map +1 -1
  413. package/dist/hub/types.d.ts +68 -4
  414. package/dist/hub/validation.d.ts +1 -1
  415. package/dist/hub/validation.js +2 -2
  416. package/dist/hub/validation.js.map +1 -1
  417. package/dist/hub/web-origin.d.ts +93 -0
  418. package/dist/hub/web-origin.js +174 -0
  419. package/dist/hub/web-origin.js.map +1 -0
  420. package/dist/hub-pilot-trust-settings.d.ts +4 -0
  421. package/dist/hub-pilot-trust-settings.js +13 -0
  422. package/dist/hub-pilot-trust-settings.js.map +1 -0
  423. package/dist/human-delivery-receipts.d.ts +4 -2
  424. package/dist/human-delivery-receipts.js +20 -13
  425. package/dist/human-delivery-receipts.js.map +1 -1
  426. package/dist/inbound-presentation.d.ts +28 -0
  427. package/dist/inbound-presentation.js +48 -0
  428. package/dist/inbound-presentation.js.map +1 -0
  429. package/dist/instance-lifecycle.d.ts +13 -1
  430. package/dist/instance-lifecycle.js +33 -10
  431. package/dist/instance-lifecycle.js.map +1 -1
  432. package/dist/instructions.d.ts +10 -2
  433. package/dist/instructions.js +32 -7
  434. package/dist/instructions.js.map +1 -1
  435. package/dist/locale.js +20 -6
  436. package/dist/locale.js.map +1 -1
  437. package/dist/log-service.d.ts +3 -0
  438. package/dist/log-service.js +39 -22
  439. package/dist/log-service.js.map +1 -1
  440. package/dist/log-steps.d.ts +56 -1
  441. package/dist/log-steps.js +318 -56
  442. package/dist/log-steps.js.map +1 -1
  443. package/dist/login-flows.d.ts +24 -2
  444. package/dist/login-flows.js +53 -22
  445. package/dist/login-flows.js.map +1 -1
  446. package/dist/login-url.js +3 -0
  447. package/dist/login-url.js.map +1 -1
  448. package/dist/machine-accounts.d.ts +42 -12
  449. package/dist/machine-accounts.js +144 -46
  450. package/dist/machine-accounts.js.map +1 -1
  451. package/dist/machine-signins.d.ts +35 -13
  452. package/dist/machine-signins.js +57 -27
  453. package/dist/machine-signins.js.map +1 -1
  454. package/dist/native-instance-input.js +4 -4
  455. package/dist/native-instance-input.js.map +1 -1
  456. package/dist/native-instance-registry.d.ts +3 -3
  457. package/dist/native-instance-registry.js +11 -10
  458. package/dist/native-instance-registry.js.map +1 -1
  459. package/dist/needs-you-hub.js +6 -2
  460. package/dist/needs-you-hub.js.map +1 -1
  461. package/dist/needs-you.d.ts +5 -1
  462. package/dist/needs-you.js +4 -8
  463. package/dist/needs-you.js.map +1 -1
  464. package/dist/office-share-page.js +1 -1
  465. package/dist/office-share-page.js.map +1 -1
  466. package/dist/outbound-handlers.d.ts +1 -0
  467. package/dist/outbound-handlers.js +25 -19
  468. package/dist/outbound-handlers.js.map +1 -1
  469. package/dist/outbound-schemas.d.ts +19 -0
  470. package/dist/outbound-schemas.js +23 -4
  471. package/dist/outbound-schemas.js.map +1 -1
  472. package/dist/profile-signins.d.ts +5 -0
  473. package/dist/profile-signins.js +1 -0
  474. package/dist/profile-signins.js.map +1 -1
  475. package/dist/queued-handoffs.d.ts +3 -1
  476. package/dist/queued-handoffs.js +1 -1
  477. package/dist/queued-handoffs.js.map +1 -1
  478. package/dist/runtime-build-info.js +6 -2
  479. package/dist/runtime-build-info.js.map +1 -1
  480. package/dist/runtime-cli.js +33 -11
  481. package/dist/runtime-cli.js.map +1 -1
  482. package/dist/runtime-client.d.ts +18 -2
  483. package/dist/runtime-client.js +84 -21
  484. package/dist/runtime-client.js.map +1 -1
  485. package/dist/runtime-credential-profiles.d.ts +36 -4
  486. package/dist/runtime-credential-profiles.js +82 -16
  487. package/dist/runtime-credential-profiles.js.map +1 -1
  488. package/dist/runtime-profile-ownership.d.ts +2 -2
  489. package/dist/runtime-profile-ownership.js +3 -3
  490. package/dist/runtime-profile-ownership.js.map +1 -1
  491. package/dist/runtime-protocol.d.ts +5 -3
  492. package/dist/runtime-protocol.js +4 -0
  493. package/dist/runtime-protocol.js.map +1 -1
  494. package/dist/runtime-remote-accounts.d.ts +72 -5
  495. package/dist/runtime-remote-accounts.js +293 -52
  496. package/dist/runtime-remote-accounts.js.map +1 -1
  497. package/dist/runtime-remote-setup.d.ts +2 -2
  498. package/dist/runtime-remote-setup.js +2 -2
  499. package/dist/runtime-remote-setup.js.map +1 -1
  500. package/dist/runtime-signin-transport.d.ts +22 -4
  501. package/dist/runtime-signin-transport.js +50 -12
  502. package/dist/runtime-signin-transport.js.map +1 -1
  503. package/dist/runtime-signin.d.ts +42 -0
  504. package/dist/runtime-signin.js +105 -9
  505. package/dist/runtime-signin.js.map +1 -1
  506. package/dist/runtime-transcript-source.d.ts +2 -0
  507. package/dist/runtime-transcript-source.js +23 -1
  508. package/dist/runtime-transcript-source.js.map +1 -1
  509. package/dist/runtime-windows-bridge.js +6 -1
  510. package/dist/runtime-windows-bridge.js.map +1 -1
  511. package/dist/scheduler/task-board.d.ts +1 -0
  512. package/dist/scheduler/task-board.js +10 -1
  513. package/dist/scheduler/task-board.js.map +1 -1
  514. package/dist/settings-api.d.ts +1 -0
  515. package/dist/settings-api.js +15 -8
  516. package/dist/settings-api.js.map +1 -1
  517. package/dist/settings-baseline.d.ts +3 -0
  518. package/dist/settings-baseline.js +2 -2
  519. package/dist/settings-baseline.js.map +1 -1
  520. package/dist/settings-effect.d.ts +3 -0
  521. package/dist/settings-effect.js +12 -2
  522. package/dist/settings-effect.js.map +1 -1
  523. package/dist/signin-keepalive.d.ts +31 -2
  524. package/dist/signin-keepalive.js +123 -12
  525. package/dist/signin-keepalive.js.map +1 -1
  526. package/dist/structured-signin-transport.d.ts +2 -2
  527. package/dist/structured-signin-transport.js +27 -6
  528. package/dist/structured-signin-transport.js.map +1 -1
  529. package/dist/structured-signin.d.ts +16 -2
  530. package/dist/structured-signin.js +59 -4
  531. package/dist/structured-signin.js.map +1 -1
  532. package/dist/task-board-tool.d.ts +0 -13
  533. package/dist/task-board-tool.js +42 -6
  534. package/dist/task-board-tool.js.map +1 -1
  535. package/dist/tool-receipt-output.d.ts +151 -0
  536. package/dist/tool-receipt-output.js +50 -0
  537. package/dist/tool-receipt-output.js.map +1 -0
  538. package/dist/topic-commands.js +2 -1
  539. package/dist/topic-commands.js.map +1 -1
  540. package/dist/transcript-jsonl.d.ts +24 -0
  541. package/dist/transcript-jsonl.js +72 -22
  542. package/dist/transcript-jsonl.js.map +1 -1
  543. package/dist/transcript-monitor.d.ts +5 -1
  544. package/dist/transcript-monitor.js +65 -3
  545. package/dist/transcript-monitor.js.map +1 -1
  546. package/dist/transcript-needles.d.ts +1 -1
  547. package/dist/transcript-needles.js +1 -1
  548. package/dist/transcript-records.d.ts +2 -1
  549. package/dist/transcript-records.js.map +1 -1
  550. package/dist/transcript-sources.d.ts +4 -0
  551. package/dist/transcript-sources.js +2 -0
  552. package/dist/transcript-sources.js.map +1 -1
  553. package/dist/ui/accounts-keepalive.js +15 -6
  554. package/dist/ui/accounts-manage.js +25 -5
  555. package/dist/ui/accounts-view.js +28 -24
  556. package/dist/ui/agent-details-settings.js +10 -1
  557. package/dist/ui/agent-proposals.js +22 -2
  558. package/dist/ui/agent-runtime-settings.js +3 -3
  559. package/dist/ui/backend-signin.js +4 -4
  560. package/dist/ui/chat-activity.js +2 -2
  561. package/dist/ui/cli-caps.js +7 -7
  562. package/dist/ui/credential-profile-select.js +32 -19
  563. package/dist/ui/fleet-canvas.js +5 -2
  564. package/dist/ui/fleet-office-card.js +4 -2
  565. package/dist/ui/fleet-org.js +2 -0
  566. package/dist/ui/hub-admin-rooms-strings.js +28 -0
  567. package/dist/ui/hub-admin-rooms.js +77 -0
  568. package/dist/ui/hub-assistant-admin-strings.js +26 -0
  569. package/dist/ui/hub-assistant-admin.js +85 -0
  570. package/dist/ui/hub-chat-store.js +8 -4
  571. package/dist/ui/hub-client.js +224 -33
  572. package/dist/ui/hub-enrolment-code.js +1 -1
  573. package/dist/ui/hub-grant-picker.js +100 -0
  574. package/dist/ui/hub-group-search.js +2 -2
  575. package/dist/ui/hub-invitations-strings.js +30 -0
  576. package/dist/ui/hub-invitations.js +108 -0
  577. package/dist/ui/hub-join-one-strings.js +4 -2
  578. package/dist/ui/hub-join-steps.js +5 -2
  579. package/dist/ui/hub-pairing-form-strings.js +48 -0
  580. package/dist/ui/hub-pilot-trust-strings.js +27 -0
  581. package/dist/ui/hub-pilot-trust.js +41 -0
  582. package/dist/ui/hub-room-composer.js +113 -0
  583. package/dist/ui/hub-room-favorites.js +90 -0
  584. package/dist/ui/hub-room-list.js +152 -0
  585. package/dist/ui/hub-room-members-strings.js +12 -0
  586. package/dist/ui/hub-room-members.js +104 -0
  587. package/dist/ui/hub-room-new-strings.js +46 -0
  588. package/dist/ui/hub-room-new.js +135 -0
  589. package/dist/ui/hub-room-presence.js +123 -0
  590. package/dist/ui/hub-room-settings-strings.js +26 -0
  591. package/dist/ui/hub-room-settings.js +134 -0
  592. package/dist/ui/hub-room-strings.js +222 -0
  593. package/dist/ui/hub-room-thread.js +262 -0
  594. package/dist/ui/hub-room-unread.js +51 -0
  595. package/dist/ui/hub-room-working.js +29 -0
  596. package/dist/ui/log-row.js +14 -5
  597. package/dist/ui/machine-signin.js +47 -14
  598. package/dist/ui/panel-details.js +6 -1
  599. package/dist/ui/panel-fleet.js +2 -2
  600. package/dist/ui/panel-hub.js +145 -59
  601. package/dist/ui/panel-needs.js +2 -0
  602. package/dist/ui/panel-settings.js +2 -2
  603. package/dist/ui/settings-hub-company-join.js +32 -11
  604. package/dist/ui/settings-hub-connection.js +9 -3
  605. package/dist/ui/settings-hub-member-address.js +205 -0
  606. package/dist/ui/settings-hub-section.js +4 -0
  607. package/dist/ui/settings-hub-web-address.js +233 -0
  608. package/dist/ui/settings-hub.js +16 -4
  609. package/dist/ui/shared/accounts-keepalive.css +8 -0
  610. package/dist/ui/shared/accounts-usage-pool.css +10 -0
  611. package/dist/ui/shared/accounts.css +9 -0
  612. package/dist/ui/shared/app-i18n.js +2 -2
  613. package/dist/ui/shared/app-needs.js +3 -0
  614. package/dist/ui/shared/app-shell.js +4 -1
  615. package/dist/ui/shared/app.css +43 -5
  616. package/dist/ui/shared/chat-render.js +10 -0
  617. package/dist/ui/shared/chat-thread.js +14 -5
  618. package/dist/ui/shared/hub-chat.css +17 -0
  619. package/dist/ui/shared/hub-grant-picker.css +4 -0
  620. package/dist/ui/shared/hub-rooms-u2.css +42 -0
  621. package/dist/ui/shared/hub-sharing.css +4 -0
  622. package/dist/ui/shared/model-observation.js +16 -0
  623. package/dist/ui/shared/stale-tab.css +6 -0
  624. package/dist/ui/shared/stale-tab.js +50 -0
  625. package/dist/ui/shared/view-strings.js +2 -2
  626. package/dist/ui/structured-signin.js +19 -6
  627. package/dist/ui/usage-pool.js +76 -0
  628. package/dist/usage/agent-output.d.ts +144 -0
  629. package/dist/usage/agent-output.js +75 -0
  630. package/dist/usage/agent-output.js.map +1 -0
  631. package/dist/usage/provider-alerts.d.ts +6 -0
  632. package/dist/usage/provider-alerts.js +6 -0
  633. package/dist/usage/provider-alerts.js.map +1 -1
  634. package/dist/usage/providers.d.ts +2 -2
  635. package/dist/usage/providers.js +60 -18
  636. package/dist/usage/providers.js.map +1 -1
  637. package/dist/usage/usage-api.d.ts +12 -0
  638. package/dist/usage/usage-api.js +39 -0
  639. package/dist/usage/usage-api.js.map +1 -1
  640. package/dist/web-api.d.ts +4 -0
  641. package/dist/web-api.js +32 -13
  642. package/dist/web-api.js.map +1 -1
  643. package/dist/web-backend-login.d.ts +4 -1
  644. package/dist/web-backend-login.js.map +1 -1
  645. package/dist/windows-cli-providers.js +5 -1
  646. package/dist/windows-cli-providers.js.map +1 -1
  647. package/dist/windows-cli-worker.d.ts +33 -1
  648. package/dist/windows-cli-worker.js +150 -10
  649. package/dist/windows-cli-worker.js.map +1 -1
  650. package/dist/windows-cli.d.ts +7 -1
  651. package/dist/windows-cli.js +19 -2
  652. package/dist/windows-cli.js.map +1 -1
  653. package/dist/workflow-templates/default.md +2 -2
  654. package/package.json +1 -1
@@ -13,6 +13,7 @@
13
13
  * - `receive(frame, link)` is S1's HubServer callback for an authenticated member link.
14
14
  * - `close()` forgets the links. S5 closes the DB.
15
15
  */
16
+ import { HubGroupPolicyError } from "../group-policy/errors.js";
16
17
  import { GROUP_POLICY_FEATURE, handleGroupHttp } from "../group-policy/admin-api.js";
17
18
  import { handleHubDirectorySettingsHttp, HUB_DIRECTORY_SETTINGS_FEATURE, HUB_DIRECTORY_CA_FEATURE, HUB_DIRECTORY_EDITOR_FEATURE } from "../settings-directory-http.js";
18
19
  import { handleHubSettingsHttp } from "../settings-api.js";
@@ -24,16 +25,22 @@ import { personKeyString } from "../identity.js";
24
25
  import { HubEnrolmentCodeLimit } from "../enrolment-code.js";
25
26
  import { HubSessions, hubClearCookie, hubSetCookie } from "../sessions.js";
26
27
  import { HubCatalogService } from "../catalog.js";
28
+ import { HubGrantSearch } from "../grant-search.js";
27
29
  import { HubPolicyService } from "../policy.js";
28
30
  import { HubRoomsService } from "../rooms.js";
31
+ import { HubRoomAdmin } from "../rooms/admin.js";
32
+ import { HubGroupRooms, HubRoomRefusal } from "../rooms/service.js";
33
+ import { directMessages, directRoomView, directUnread, markDirectRead } from "../rooms/direct-view.js";
29
34
  import { HubAttachmentRefused } from "../attachments/store.js";
30
35
  import { HubQuotaService } from "../quota.js";
31
36
  import { HubCore, pairingOwnerByLogin } from "./core.js";
37
+ import { HubSharingPaused, HubSharingService } from "../sharing.js";
32
38
  import { HUB_HTTP_MIGRATIONS } from "./schema.js";
33
39
  import { serveHubWorkspaceShell } from "../../web-api.js";
34
40
  import { servePublicAsset } from "../../auth-api.js";
35
41
  import { handleCompanyJoin, companyFlowCookie } from "../join/http.js";
36
42
  import { CompanyJoinCodeRefusal, CompanyJoinLimit, CompanyJoinOfferPending } from "../join/service.js";
43
+ import { HubMemberAddressError } from "../settings-member-address-policy.js";
37
44
  export { HUB_HTTP_MIGRATIONS };
38
45
  /** S5's lazy entry (HubHttpEntry): this module itself — `createHubHttp` and `migrations`. */
39
46
  export const migrations = HUB_HTTP_MIGRATIONS;
@@ -42,9 +49,22 @@ export const HUB_UI_MODULES = Object.freeze(["panel-hub.js", "hub-client.js", "h
42
49
  // #3298 S-89 (lazy; loaded only when the session says "group-policy-v1"): the welcome, Group permissions and their words.
43
50
  "hub-welcome.js", "hub-group-policy.js", "hub-group-strings.js", "hub-read-strings.js", "hub-quick-pairing.js", "hub-quick-strings.js", "hub-company-join.js", "hub-company-join-strings.js", "hub-this-hub.js", "hub-directory-notices.js", "hub-directory-notice-strings.js", "hub-directory-editor.js", "hub-directory-editor-strings.js",
44
51
  // Hub UX U2 (M-2932): the group-search picker (its own words inside), shared with B2's join-code scope.
45
- "hub-group-search.js", "hub-join-steps.js",
52
+ "hub-group-search.js", "hub-join-steps.js", "hub-grant-picker.js",
46
53
  // B2: code management and the same-request Hub approval queue.
47
- "hub-enrolment-code.js", "hub-enrolment-code-strings.js", "hub-join-queue.js", "hub-join-approval.js", "hub-joincode-flow-strings.js"]);
54
+ "hub-enrolment-code.js", "hub-enrolment-code-strings.js", "hub-join-queue.js", "hub-join-approval.js", "hub-joincode-flow-strings.js",
55
+ // Hub rooms (hub-rooms-ux.md §§2,5): the rooms words (#3850) then the presence helper (pure, no DOM).
56
+ "hub-room-strings.js", "hub-room-presence.js",
57
+ // Hub rooms §12: unread counts and the Fleet desktop-notify rule (lazy; screens load it).
58
+ "hub-room-unread.js",
59
+ // Hub rooms, track U2 (dev-claude2; hub-rooms-split.md section 3): new room, room settings, members rail, invitations,
60
+ // 管理 → 房間.
61
+ "hub-room-new.js", "hub-room-new-strings.js", "hub-room-settings.js", "hub-room-settings-strings.js", "hub-room-members.js", "hub-room-members-strings.js", "hub-invitations.js", "hub-invitations-strings.js", "hub-admin-rooms.js", "hub-admin-rooms-strings.js",
62
+ // M-3092 (Hub rooms, track U): the conversation list, a room on the shared thread, its composer.
63
+ "hub-room-list.js", "hub-room-thread.js", "hub-room-composer.js", "hub-assistant-admin.js", "hub-assistant-admin-strings.js",
64
+ // M-3092 S-145: the list's favourites (the Fleet sidebar's #1664 rules; per browser until a Hub-side store).
65
+ "hub-room-favorites.js",
66
+ // S-148: the working bar's words (#3857), shared by the room thread.
67
+ "hub-room-working.js"]);
48
68
  const BODY_LIMIT = 96 * 1024;
49
69
  const UPLOADS_PER_SESSION = 2, UPLOADS_TOTAL = 8;
50
70
  const UUID = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
@@ -137,11 +157,19 @@ const int = (v) => { const n = typeof v === "string" && /^\d{1,15}$/.test(v) ? N
137
157
  export function createHubHttp(deps, sql) {
138
158
  let closed = false;
139
159
  const core = new HubCore(deps, sql, () => !closed);
160
+ const sharing = new HubSharingService(core);
140
161
  const sessions = new HubSessions(core), catalog = new HubCatalogService(core), policy = new HubPolicyService(core);
162
+ const grantSearch = new HubGrantSearch(core);
141
163
  const rooms = new HubRoomsService(core, policy);
164
+ const groupRooms = new HubGroupRooms(core);
165
+ const invitations = deps.roomInvitations?.(core, groupRooms.invitationHost());
166
+ const roomAdmin = new HubRoomAdmin(core, event => groupRooms.publish(event), id => { groupRooms.assistant.forget(id); groupRooms.agents.sweep(id); });
142
167
  const quota = new HubQuotaService(core);
143
168
  const uiDir = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "ui");
144
169
  const live = () => !closed && core.live();
170
+ const grantSubjectsOffered = () => !!deps.grantDirectory && deps.directory.groupPolicy === "ad-direct-guid"
171
+ && typeof deps.directory.searchPolicyGroups === "function" && typeof deps.directory.searchGrantPeople === "function"
172
+ && typeof deps.directory.resolvePolicyGroup === "function" && typeof deps.directory.readPolicyGroups === "function";
145
173
  /** Upload bodies being read now, per session and in all (each up to the file limit in memory). */
146
174
  const uploading = new Map();
147
175
  let uploadingTotal = 0;
@@ -174,8 +202,8 @@ export function createHubHttp(deps, sql) {
174
202
  };
175
203
  const m = (re) => re.exec(path);
176
204
  // Composed routes, not enrollment authority or the administrator's on/off switch. Older Hubs omit unsupported cards.
177
- const offered = [...(deps.groupHttp ? [GROUP_POLICY_FEATURE, ...(deps.pairingNotices ? ["quick-pairing-v1"] : [])] : []),
178
- ...(deps.companyJoin ? ["company-join-v1", "enrolment-code-v1"] : []), ...(deps.directoryNotices ? ["directory-security-notices-v1"] : []),
205
+ const offered = ["rooms-v1", ...(deps.roomAssistant && deps.assistantAdmin ? ["room-assistant-v1"] : []), ...(deps.refreshAuthorization ? ["sharing-pause-v1"] : []), ...(deps.groupHttp ? [GROUP_POLICY_FEATURE, ...(deps.pairingNotices ? ["quick-pairing-v1"] : [])] : []), ...(grantSubjectsOffered() ? ["grant-subjects-v1"] : []),
206
+ ...(deps.companyJoin ? ["company-join-v1", "enrolment-code-v1"] : []), ...(deps.directoryNotices ? ["directory-security-notices-v1"] : []), ...(deps.memberAddressNotices ? ["member-address-notices-v1"] : []),
179
207
  ...(deps.directorySettings ? [HUB_DIRECTORY_SETTINGS_FEATURE, HUB_DIRECTORY_CA_FEATURE, HUB_DIRECTORY_EDITOR_FEATURE] : [])];
180
208
  const features = offered.length ? { features: offered } : {};
181
209
  let r;
@@ -225,8 +253,9 @@ export function createHubHttp(deps, sql) {
225
253
  if (deps.companyJoin && path === "/hub/v1/admin/company-join") {
226
254
  if (method === "GET") {
227
255
  signedIn();
228
- await ctx.requireAdmin();
229
- return send(res, 200, deps.companyJoin.adminView());
256
+ const permit = await core.management(ctx, "join.manage"), view = deps.companyJoin.adminView();
257
+ permit.assertCurrent();
258
+ return send(res, 200, view);
230
259
  }
231
260
  if (method !== "PUT")
232
261
  throw new HttpError(405, "method");
@@ -252,6 +281,34 @@ export function createHubHttp(deps, sql) {
252
281
  }
253
282
  throw new HttpError(405, "method");
254
283
  }
284
+ if (deps.memberAddressNotices) {
285
+ const notices = deps.memberAddressNotices;
286
+ if (path === "/hub/v1/security-notices/member-address") {
287
+ if (method !== "GET")
288
+ throw new HttpError(405, "method");
289
+ signedIn();
290
+ if ([...query.keys()].some(k => k !== "before") || query.getAll("before").length > 1
291
+ || query.has("before") && !/^[1-9][0-9]{0,15}$/.test(query.get("before")))
292
+ throw new HubProtocolError("invalid");
293
+ const page = await guard(() => notices.forSession(ctx, query.has("before") ? Number(query.get("before")) : undefined));
294
+ if (!live())
295
+ throw new HubProtocolError("unavailable");
296
+ signedIn();
297
+ return send(res, 200, page);
298
+ }
299
+ if ((r = m(/^\/hub\/v1\/security-notices\/member-address\/([^/]+)\/ack$/))) {
300
+ if (method !== "POST")
301
+ throw new HttpError(405, "method");
302
+ if ([...query.keys()].length)
303
+ throw new HubProtocolError("invalid");
304
+ csrf();
305
+ await guard(() => notices.acknowledgeSession(ctx, uuid(r[1])));
306
+ if (!live())
307
+ throw new HubProtocolError("unavailable");
308
+ signedIn();
309
+ return send(res, 200, { ok: true });
310
+ }
311
+ }
255
312
  if (deps.directoryNotices) {
256
313
  const notices = deps.directoryNotices;
257
314
  if (path === "/hub/v1/security-notices/directory") {
@@ -386,6 +443,14 @@ export function createHubHttp(deps, sql) {
386
443
  return;
387
444
  }
388
445
  }
446
+ if ((r = m(/^\/hub\/v1\/exposures\/([^/]+)\/grant-subjects\/search$/))) {
447
+ if (method !== "POST")
448
+ throw new HttpError(405, "method");
449
+ csrf();
450
+ const input = await body(), response = await guard(() => grantSearch.search(ctx, uuid(r[1]), input));
451
+ const limited = response?.reason === "limited";
452
+ return send(res, limited ? 429 : 200, response, limited ? { "Retry-After": "60" } : {});
453
+ }
389
454
  if (path === "/hub/v1/exposures" || path === "/hub/v1/grants") {
390
455
  if (method === "GET") {
391
456
  signedIn();
@@ -395,7 +460,8 @@ export function createHubHttp(deps, sql) {
395
460
  if (path === "/hub/v1/grants" && method === "POST") {
396
461
  csrf();
397
462
  const b = await body();
398
- const g = await guard(() => catalog.grant(ctx, { exposureId: uuid(b.exposureId), exposureRevision: int(b.exposureRevision), login: str(b.login), days: int(b.days) }));
463
+ const g = await guard(() => catalog.grant(ctx, { exposureId: uuid(b.exposureId), exposureRevision: int(b.exposureRevision),
464
+ ...(b.login !== undefined ? { login: str(b.login) } : {}), ...(b.subject !== undefined ? { subject: b.subject } : {}), days: int(b.days) }));
399
465
  return send(res, 200, { grant: g });
400
466
  }
401
467
  throw new HttpError(405, "method");
@@ -414,6 +480,21 @@ export function createHubHttp(deps, sql) {
414
480
  signedIn();
415
481
  return send(res, 200, { activity: await guard(() => rooms.activity(ctx, uuid(r[1]))) });
416
482
  }
483
+ if ((r = m(/^\/hub\/v1\/exposures\/([^/]+)\/rooms$/))) {
484
+ if (method !== "GET")
485
+ throw new HttpError(405, "method");
486
+ signedIn();
487
+ return send(res, 200, { rooms: await guard(() => groupRooms.roomsForExposure(ctx, uuid(r[1]))) });
488
+ }
489
+ if ((r = m(/^\/hub\/v1\/exposures\/([^/]+)\/sharing$/))) {
490
+ if (method !== "POST")
491
+ throw new HttpError(405, "method");
492
+ csrf();
493
+ const b = await body();
494
+ await guard(() => sharing.change(ctx, uuid(r[1]), b));
495
+ groupRooms.agents.publicationChanged(undefined, uuid(r[1]));
496
+ return send(res, 200, { ok: true });
497
+ }
417
498
  if ((r = m(/^\/hub\/v1\/exposures\/([^/]+)\/freeze$/))) {
418
499
  if (method !== "POST")
419
500
  throw new HttpError(405, "method");
@@ -433,19 +514,309 @@ export function createHubHttp(deps, sql) {
433
514
  await guard(() => quota.setVisible(ctx, exposureId, int(b.revision), b.visible));
434
515
  return send(res, 200, { quotaVisible: b.visible, ...quota.projection(exposureId) });
435
516
  }
517
+ if (path === "/hub/v1/admin/assistant" || path === "/hub/v1/admin/assistant/usage" || /^\/hub\/v1\/admin\/assistant\/rooms\/[^/]+\/stop$/.test(path)) {
518
+ const port = deps.roomAssistant && deps.assistantAdmin;
519
+ if (!port)
520
+ throw new HttpError(404, "not-found");
521
+ if (mutation)
522
+ csrf();
523
+ else
524
+ signedIn();
525
+ const permit = await guard(() => core.management(ctx, "hub.admin"));
526
+ const call = async (work) => {
527
+ permit.assertCurrent();
528
+ let result;
529
+ try {
530
+ result = await work();
531
+ }
532
+ catch {
533
+ permit.assertCurrent();
534
+ throw new HttpError(503, "unavailable");
535
+ }
536
+ permit.assertCurrent();
537
+ return result;
538
+ };
539
+ if (path === "/hub/v1/admin/assistant") {
540
+ if (method === "GET")
541
+ return send(res, 200, await guard(() => call(() => port.settings())));
542
+ if (method === "PUT") {
543
+ const b = await body();
544
+ return send(res, 200, await guard(() => call(() => port.configure(b))));
545
+ }
546
+ }
547
+ else if (path.endsWith("/usage") && method === "GET")
548
+ return send(res, 200, await guard(() => call(() => port.usage())));
549
+ else if (method === "POST") {
550
+ const id = uuid(path.split("/")[6]);
551
+ await guard(() => call(() => { groupRooms.assistant.cancel(id); return port.stopRoom(id); }));
552
+ return send(res, 200, { ok: true });
553
+ }
554
+ throw new HttpError(405, "method");
555
+ }
556
+ if (path === "/hub/v1/admin/rooms/creators") {
557
+ if (method === "GET") {
558
+ signedIn();
559
+ return send(res, 200, await guard(() => roomAdmin.creators(ctx)));
560
+ }
561
+ if (method === "PUT") {
562
+ csrf();
563
+ const b = await body();
564
+ return send(res, 200, await guard(() => roomAdmin.creators(ctx, b)));
565
+ }
566
+ throw new HttpError(405, "method");
567
+ }
568
+ if (path === "/hub/v1/admin/rooms") {
569
+ if (method !== "GET")
570
+ throw new HttpError(405, "method");
571
+ signedIn();
572
+ return send(res, 200, await guard(() => roomAdmin.list(ctx)));
573
+ }
574
+ if ((r = m(/^\/hub\/v1\/admin\/rooms\/([^/]+)(?:\/(join))?$/))) {
575
+ const roomId = uuid(r[1]);
576
+ csrf();
577
+ if (r[2] === "join" && method === "POST")
578
+ return send(res, 200, await guard(() => roomAdmin.join(ctx, roomId)));
579
+ if (!r[2] && method === "PATCH") {
580
+ const b = await body();
581
+ return send(res, 200, await guard(() => roomAdmin.archive(ctx, roomId, b)));
582
+ }
583
+ throw new HttpError(405, "method");
584
+ }
585
+ if (path === "/hub/v1/rooms/candidates") {
586
+ if (method !== "GET")
587
+ throw new HttpError(405, "method");
588
+ signedIn();
589
+ return send(res, 200, { candidates: await guard(() => groupRooms.candidates(ctx, query.get("q") ?? "", query.get("kind") ?? "person")) });
590
+ }
591
+ if ((r = m(/^\/hub\/v1\/rooms\/candidates\/group\/([^/]+)$/))) {
592
+ if (method !== "GET")
593
+ throw new HttpError(405, "method");
594
+ signedIn();
595
+ return send(res, 200, await guard(() => groupRooms.groupCandidate(ctx, uuid(r[1]))));
596
+ }
597
+ if (path === "/hub/v1/invitations") {
598
+ if (!invitations)
599
+ throw new HttpError(404, "not-found");
600
+ if (method !== "GET")
601
+ throw new HttpError(405, "method");
602
+ signedIn();
603
+ return send(res, 200, await guard(() => invitations.pending(ctx)));
604
+ }
605
+ if ((r = m(/^\/hub\/v1\/invitations\/([^/]+)\/(accept|decline)$/))) {
606
+ if (!invitations)
607
+ throw new HttpError(404, "not-found");
608
+ if (method !== "POST")
609
+ throw new HttpError(405, "method");
610
+ csrf();
611
+ const id = uuid(r[1]);
612
+ return send(res, 200, await guard(() => r[2] === "accept" ? invitations.accept(ctx, id) : invitations.decline(ctx, id)));
613
+ }
614
+ if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/invitations(?:\/([^/]+))?$/))) {
615
+ if (!invitations)
616
+ throw new HttpError(404, "not-found");
617
+ csrf();
618
+ const id = uuid(r[1]);
619
+ if (method === "DELETE" && r[2])
620
+ return send(res, 200, await guard(() => invitations.cancel(ctx, id, uuid(r[2]))));
621
+ if (method === "POST" && !r[2]) {
622
+ const b = await body();
623
+ if (Object.keys(b).length !== 1 || !(Array.isArray(b.agents) || typeof b.team === "string"))
624
+ throw new HubProtocolError("invalid");
625
+ const input = Array.isArray(b.agents) ? { agents: b.agents.map(value => uuid(value)) } : { team: uuid(b.team) };
626
+ if (input.agents && input.agents.length > 64)
627
+ throw new HubProtocolError("invalid");
628
+ return send(res, 200, await guard(() => invitations.invite(ctx, id, input)));
629
+ }
630
+ throw new HttpError(405, "method");
631
+ }
632
+ if (path === "/hub/v1/rooms/events") {
633
+ if (method !== "GET")
634
+ throw new HttpError(405, "method");
635
+ const streamSession = signedIn(), streamPerson = personKeyString(await guard(() => ctx.requirePerson()));
636
+ const requestedNotices = query.get("notices"), notices = deps.pairingNotices;
637
+ const noticeVersion = requestedNotices === "3" && deps.companyJoin ? 3 : requestedNotices === "2" || requestedNotices === "3" ? 2 : null;
638
+ const initialNotices = notices && noticeVersion ? await guard(() => notices.forSession(ctx, noticeVersion)) : null;
639
+ if (streams.size >= 64 || !ctx.isCurrent?.())
640
+ throw new HubProtocolError("backpressure");
641
+ res.writeHead(200, { ...API_HEADERS, "Content-Type": "text/event-stream; charset=utf-8", Connection: "keep-alive", "X-Accel-Buffering": "no" });
642
+ let ended = false, queued = 0, tail = Promise.resolve(), noticesRunning = false, noticesDirty = false;
643
+ let offNotices = () => { };
644
+ const close = () => { if (ended)
645
+ return; ended = true; off(); offNotices(); clearInterval(heartbeat); streams.delete(close); res.end(); };
646
+ const off = groupRooms.subscribe(event => {
647
+ if (ended)
648
+ return;
649
+ if (event.audiencePerson && event.audiencePerson !== streamPerson)
650
+ return;
651
+ if (!event.audiencePerson && !groupRooms.interested(streamPerson, event))
652
+ return;
653
+ if (++queued > 64) {
654
+ close();
655
+ return;
656
+ }
657
+ tail = tail.then(async () => {
658
+ if (ended)
659
+ return;
660
+ let data;
661
+ // Concurrent agent checks can briefly fill the person's physical read slots. Keep this event in the bounded
662
+ // queue and re-read it after a short delay; persistent overload and all other failures still close the stream.
663
+ for (let attempt = 0;; attempt++) {
664
+ try {
665
+ if (event.audiencePerson) {
666
+ if (event.type === "invitation.changed") {
667
+ data = personKeyString(await ctx.requirePerson()) === event.audiencePerson ? {} : null;
668
+ }
669
+ else {
670
+ const view = await rooms.view(ctx, event.roomId);
671
+ if (event.type === "unread.changed")
672
+ data = { roomId: event.roomId, unread: directUnread(core, view) };
673
+ else if (event.type === "room.changed")
674
+ data = { roomId: event.roomId, room: directRoomView(view, rooms.presence(view.exposureId), directUnread(core, view)) };
675
+ else {
676
+ const page = await rooms.readPage(ctx, event.roomId, 0, streamSession.sessionId, { before: null, limit: 100 });
677
+ const message = directMessages(page.room, page.entries, streamSession.displayName).find(m => m.id === event.data.messageId);
678
+ data = message ? { roomId: event.roomId, message } : null;
679
+ }
680
+ }
681
+ }
682
+ else
683
+ data = await groupRooms.event(ctx, event);
684
+ break;
685
+ }
686
+ catch (error) {
687
+ if (!(error instanceof HubProtocolError) || error.code !== "backpressure" || attempt >= 3)
688
+ throw error;
689
+ await new Promise(resolve => setTimeout(resolve, 25 * 2 ** attempt));
690
+ if (ended || !live() || !ctx.isCurrent?.())
691
+ return close();
692
+ }
693
+ }
694
+ if (ended || !live() || !ctx.isCurrent?.())
695
+ return close();
696
+ if (data && !res.write(`event: ${event.type}\ndata: ${JSON.stringify(data)}\n\n`))
697
+ close();
698
+ }).catch(close).finally(() => { queued--; });
699
+ });
700
+ const pushNotices = async () => {
701
+ if (ended || !notices || !noticeVersion)
702
+ return;
703
+ if (noticesRunning) {
704
+ noticesDirty = true;
705
+ return;
706
+ }
707
+ noticesRunning = true;
708
+ try {
709
+ do {
710
+ noticesDirty = false;
711
+ const rows = await notices.forSession(ctx, noticeVersion);
712
+ if (ended || !live() || !ctx.isCurrent?.())
713
+ return close();
714
+ if (!res.write(`event: notices\ndata: ${JSON.stringify({ notices: rows })}\n\n`))
715
+ return close();
716
+ } while (noticesDirty);
717
+ }
718
+ catch {
719
+ close();
720
+ }
721
+ finally {
722
+ noticesRunning = false;
723
+ }
724
+ };
725
+ const heartbeat = setInterval(() => { if (!live() || !ctx.isCurrent?.())
726
+ close();
727
+ else if (!res.write(": heartbeat\n\n"))
728
+ close(); }, 15_000);
729
+ heartbeat.unref();
730
+ try {
731
+ if (notices && noticeVersion)
732
+ offNotices = notices.subscribe(() => void pushNotices());
733
+ }
734
+ catch {
735
+ close();
736
+ return;
737
+ }
738
+ streams.add(close);
739
+ res.on("close", close);
740
+ if (initialNotices)
741
+ res.write(`event: notices\ndata: ${JSON.stringify({ notices: initialNotices })}\n\n`);
742
+ res.write(": connected\n\n");
743
+ return;
744
+ }
436
745
  if (path === "/hub/v1/rooms") {
437
746
  if (method === "GET") {
438
747
  signedIn();
439
- return send(res, 200, { rooms: (await guard(() => rooms.list(ctx))).map(room => ({ ...room, ...quota.roomProjection(room) })) });
748
+ const view = await guard(() => rooms.listAuthorized(ctx));
749
+ // Cached clients draw every row as a direct agent conversation. New roomList() opts into group rows.
750
+ if (query.get("v") !== "2")
751
+ return send(res, 200, { rooms: view.rooms.map(room => ({ ...room, ...quota.roomProjection(room, view.grantProof) })) });
752
+ const groups = await guard(() => groupRooms.list(ctx));
753
+ const pending = invitations ? await guard(() => invitations.pending(ctx)) : null;
754
+ return send(res, 200, { ...groups, invitations: pending?.invitations.length ?? 0, rooms: [...groups.rooms, ...view.rooms.map(room => ({ ...directRoomView(room, rooms.presence(room.exposureId), directUnread(core, room)), ...quota.roomProjection(room, view.grantProof) }))] });
440
755
  }
441
756
  if (method === "POST") {
442
757
  csrf();
443
758
  const b = await body();
759
+ if (b.exposureId === undefined)
760
+ return send(res, 200, await guard(() => groupRooms.create(ctx, b)));
444
761
  const room = await guard(() => rooms.open(ctx, uuid(b.exposureId), uuid(b.grantId)));
445
- return send(res, 200, { room: { id: room.id, exposureId: room.exposureId, grantId: room.grantId, state: room.state, exposureName: room.exposure.displayName, features: rooms.features(room.exposure.fleetId), ...quota.projection(room.exposureId) } });
762
+ return send(res, 200, { room: { id: room.id, exposureId: room.exposureId, grantId: room.grantId, state: room.state, exposureName: room.exposure.displayName, features: rooms.features(room.exposure.fleetId), ...quota.roomProjection(room, room.grantProof) } });
763
+ }
764
+ throw new HttpError(405, "method");
765
+ }
766
+ if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)$/))) {
767
+ signedIn();
768
+ const roomId = uuid(r[1]);
769
+ if (groupRooms.has(roomId)) {
770
+ if (method === "GET") {
771
+ const view = await guard(() => groupRooms.detail(ctx, roomId));
772
+ const invited = invitations && view.me.role === "manager" && !view.room.archived ? await guard(() => invitations.forRoom(ctx, roomId)) : [];
773
+ return send(res, 200, { ...view, invited });
774
+ }
775
+ if (method === "PATCH") {
776
+ csrf();
777
+ const b = await body();
778
+ return send(res, 200, await guard(() => groupRooms.patch(ctx, roomId, b)));
779
+ }
780
+ }
781
+ else if (method === "GET") {
782
+ const room = await guard(() => rooms.view(ctx, roomId));
783
+ const person = personKeyString(room.asker), name = signedIn().displayName;
784
+ return send(res, 200, { room: directRoomView(room, rooms.presence(room.exposureId), directUnread(core, room)), me: { id: person, role: "member" },
785
+ members: [{ id: person, kind: "person", name, role: "member", presence: "online" }, { id: room.exposureId, kind: "agent", name: room.exposureName,
786
+ owner: { name: room.ownerName }, role: "member", presence: rooms.presence(room.exposureId), canAsk: room.state === "active" }],
787
+ settings: { allMention: false, historyForNew: "all" }, invited: [] });
446
788
  }
447
789
  throw new HttpError(405, "method");
448
790
  }
791
+ if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/members(?:\/([^/]+))?$/))) {
792
+ csrf();
793
+ const roomId = uuid(r[1]), memberId = r[2] ? uuid(r[2]) : null;
794
+ if (method === "POST" && !memberId) {
795
+ const b = await body();
796
+ return send(res, 200, await guard(() => groupRooms.add(ctx, roomId, b)));
797
+ }
798
+ if (method === "DELETE" && memberId)
799
+ return send(res, 200, await guard(() => groupRooms.changeMember(ctx, roomId, memberId)));
800
+ if (method === "PATCH" && memberId) {
801
+ const b = await body();
802
+ if (Object.keys(b).length !== 1 || !["manager", "member"].includes(String(b.role)))
803
+ throw new HubProtocolError("invalid");
804
+ return send(res, 200, await guard(() => groupRooms.changeMember(ctx, roomId, memberId, b.role)));
805
+ }
806
+ throw new HttpError(405, "method");
807
+ }
808
+ if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/read$/))) {
809
+ if (method !== "POST")
810
+ throw new HttpError(405, "method");
811
+ csrf();
812
+ const b = await body(), roomId = uuid(r[1]);
813
+ if (groupRooms.has(roomId))
814
+ return send(res, 200, await guard(() => groupRooms.markRead(ctx, roomId, b.upTo)));
815
+ const room = await guard(() => rooms.view(ctx, roomId));
816
+ markDirectRead(core, roomId, str(b.upTo));
817
+ groupRooms.publish({ type: "unread.changed", roomId, data: { roomId }, audiencePerson: personKeyString(room.asker) });
818
+ return send(res, 200, { ok: true });
819
+ }
449
820
  if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/buttons$/))) {
450
821
  if (method !== "POST")
451
822
  throw new HttpError(405, "method");
@@ -455,18 +826,43 @@ export function createHubHttp(deps, sql) {
455
826
  }
456
827
  if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/messages$/))) {
457
828
  const roomId = uuid(r[1]);
829
+ if (groupRooms.has(roomId)) {
830
+ if (method === "GET") {
831
+ signedIn();
832
+ return send(res, 200, await guard(() => groupRooms.messages(ctx, roomId, query.get("before"), int(query.get("limit") ?? "50"))));
833
+ }
834
+ if (method === "POST") {
835
+ csrf();
836
+ const b = await body();
837
+ return send(res, 200, await guard(() => groupRooms.post(ctx, roomId, b)));
838
+ }
839
+ throw new HttpError(405, "method");
840
+ }
458
841
  if (method === "GET") {
459
842
  const s = signedIn();
460
843
  // #3226 B + G: the room comes with its entries, fresh each poll — its view (state, grant's end, what its link
461
844
  // negotiated) and its quota projection (G; absent when hidden or not shared).
462
- const { entries, room: view } = await guard(() => rooms.readPage(ctx, roomId, int(query.get("after") ?? "0"), s.sessionId));
463
- return send(res, 200, { entries, room: { ...view, ...quota.roomProjection(view) } });
845
+ const { entries, room: view, grantProof, more } = await guard(() => rooms.readPage(ctx, roomId, int(query.get("after") ?? "0"), s.sessionId, query.has("after") ? undefined : { before: query.get("before"), limit: int(query.get("limit") ?? "50") }));
846
+ let messages = directMessages(view, entries, s.displayName);
847
+ const cursor = query.get("before"), index = cursor ? messages.findIndex(m => m.id === cursor) : -1;
848
+ if (index >= 0)
849
+ messages = messages.slice(0, index);
850
+ const limit = int(query.get("limit") ?? "50"), overflow = !query.has("after") && messages.length > limit;
851
+ if (overflow)
852
+ messages = messages.slice(-limit);
853
+ return send(res, 200, { entries, room: { ...view, ...quota.roomProjection(view, grantProof) }, messages, more: (more ?? false) || overflow });
464
854
  }
465
855
  if (method === "POST") {
466
856
  csrf();
467
857
  const b = await body();
468
858
  const files = b.files === undefined ? [] : Array.isArray(b.files) && b.files.length <= 10 ? b.files.map(uuid) : (() => { throw new HubProtocolError("invalid"); })();
469
- return send(res, 200, { receipt: await guard(() => rooms.ask(ctx, roomId, uuid(b.idempotencyKey), typeof b.text === "string" ? b.text : "", files)) });
859
+ if (b.mentions !== undefined && (!Array.isArray(b.mentions) || b.mentions.length))
860
+ throw new HubProtocolError("invalid");
861
+ const receipt = await guard(() => rooms.ask(ctx, roomId, uuid(b.idempotencyKey), typeof b.text === "string" ? b.text : "", files));
862
+ const room = await guard(() => rooms.view(ctx, roomId));
863
+ groupRooms.publish({ type: "message.added", roomId, data: { roomId, messageId: receipt.messageId }, audiencePerson: personKeyString(room.asker) });
864
+ return send(res, 200, { id: receipt.messageId, roomId, at: receipt.at, author: { kind: "person", id: personKeyString(room.asker), name: signedIn().displayName },
865
+ text: typeof b.text === "string" ? b.text : "", mentions: [], idempotencyKey: b.idempotencyKey, receipt });
470
866
  }
471
867
  throw new HttpError(405, "method");
472
868
  }
@@ -636,7 +1032,9 @@ export function createHubHttp(deps, sql) {
636
1032
  void req;
637
1033
  throw new HttpError(404, "not-found");
638
1034
  }
639
- function fail(res, e) {
1035
+ function fail(res, e, method, path) {
1036
+ if (e instanceof HubRoomRefusal)
1037
+ return send(res, e.status, { code: e.code, ...e.details });
640
1038
  if (e instanceof HubEnrolmentCodeLimit)
641
1039
  return send(res, 429, { code: "backpressure", reason: e.reason });
642
1040
  if (e instanceof CompanyJoinCodeRefusal)
@@ -649,10 +1047,21 @@ export function createHubHttp(deps, sql) {
649
1047
  return send(res, 401, { code: "signed-out" });
650
1048
  if (e instanceof HttpError)
651
1049
  return send(res, e.status, { code: e.code });
1050
+ if (e instanceof HubSharingPaused)
1051
+ return send(res, 409, { code: "sharing-paused" });
1052
+ if (e instanceof HubMemberAddressError)
1053
+ return send(res, STATUS[e.code] ?? 503, { code: e.code });
652
1054
  if (e instanceof HubAttachmentRefused)
653
1055
  return send(res, 415, { code: e.refusal });
654
1056
  if (e instanceof HubProtocolError) {
655
1057
  const status = STATUS[e.code] ?? 400;
1058
+ if (status === 503) {
1059
+ try {
1060
+ deps.log?.("warn", "Hub HTTP unavailable", { method, path, code: e.code,
1061
+ cause: e.cause instanceof HubGroupPolicyError ? e.cause.message : e.code });
1062
+ }
1063
+ catch { /* diagnostics cannot replace the response */ }
1064
+ }
656
1065
  return send(res, status, { code: e.code }, status === 429 ? { "Retry-After": "10" } : {});
657
1066
  }
658
1067
  send(res, 500, { code: "unavailable" });
@@ -669,7 +1078,7 @@ export function createHubHttp(deps, sql) {
669
1078
  if (deps.companyJoin && live() && handleCompanyJoin(req, res, deps.companyJoin))
670
1079
  return true;
671
1080
  if (path.startsWith("/hub/v1/")) {
672
- void api(req, res, path, url.searchParams).catch((e) => fail(res, e));
1081
+ void api(req, res, path, url.searchParams).catch((e) => fail(res, e, method, path));
673
1082
  return true;
674
1083
  }
675
1084
  if (method !== "GET" && method !== "HEAD")
@@ -710,12 +1119,27 @@ export function createHubHttp(deps, sql) {
710
1119
  throw new HubProtocolError("stale");
711
1120
  rooms.noteLink(link);
712
1121
  quota.noteLink(link);
1122
+ groupRooms.agents.noteLink(link);
713
1123
  deps.pairingNotices?.noteLink(link);
714
1124
  const reply = { v: 1, requestId: frame.requestId, linkEpoch: link.linkEpoch };
715
1125
  switch (frame.type) {
1126
+ case "room.answer":
1127
+ try {
1128
+ return { ...reply, type: "room.answer-ack", payload: await groupRooms.agents.answer(frame.payload, link) };
1129
+ }
1130
+ catch (error) {
1131
+ // No ACK means the Fleet retains its frozen answer. A pause or transient read must not break its member link.
1132
+ if (error instanceof HubProtocolError && ["unavailable", "backpressure", "revoked", "not-found", "stale"].includes(error.code))
1133
+ return;
1134
+ throw error;
1135
+ }
1136
+ case "agent.state":
1137
+ groupRooms.agents.state(frame.payload, link);
1138
+ return;
716
1139
  case "exposure.snapshot":
717
1140
  await catalog.receiveSnapshot(frame.payload, link, frame.requestId);
718
1141
  quota.prune();
1142
+ groupRooms.agents.publicationChanged(link.fleetId);
719
1143
  return;
720
1144
  case "exposure.quota":
721
1145
  quota.receive(frame.payload, link);
@@ -725,8 +1149,16 @@ export function createHubHttp(deps, sql) {
725
1149
  throw new HubProtocolError("incompatible");
726
1150
  deps.pairingNotices.acknowledgeFleet(link, frame.payload.id);
727
1151
  return;
728
- case "receipt": return { ...reply, type: "receipt", payload: rooms.receipt(frame.payload, link) };
729
- case "answer": return { ...reply, type: "receipt", payload: await rooms.answer(frame.payload, link) };
1152
+ case "receipt": {
1153
+ const payload = rooms.receipt(frame.payload, link);
1154
+ directChanged(payload.messageId, false);
1155
+ return { ...reply, type: "receipt", payload };
1156
+ }
1157
+ case "answer": {
1158
+ const payload = await rooms.answer(frame.payload, link);
1159
+ directChanged(payload.messageId, true);
1160
+ return { ...reply, type: "receipt", payload };
1161
+ }
730
1162
  case "authorize.request": return { ...reply, type: "authorize.result", payload: await policy.authorize(frame.payload, link) };
731
1163
  case "reconcile": {
732
1164
  const page = rooms.reconcile(frame.payload, link);
@@ -740,27 +1172,38 @@ export function createHubHttp(deps, sql) {
740
1172
  case "error": return;
741
1173
  }
742
1174
  }
1175
+ function directChanged(messageId, answer) {
1176
+ const row = core.atomic(db => db.prepare("SELECT room_id,asker FROM hub_messages WHERE id=?").get(messageId));
1177
+ if (!row)
1178
+ return;
1179
+ groupRooms.publish({ type: answer ? "message.added" : "message.updated", roomId: row.room_id, data: { roomId: row.room_id, messageId: answer ? `${messageId}:answer` : messageId }, audiencePerson: row.asker });
1180
+ groupRooms.publish({ type: "unread.changed", roomId: row.room_id, data: { roomId: row.room_id }, audiencePerson: row.asker });
1181
+ }
743
1182
  function flushSoon(link, attempt = 0) {
744
1183
  const t = setTimeout(() => {
745
1184
  if (!live() || !link.current())
746
1185
  return;
747
1186
  void rooms.flush(link.fleetId).then((sent) => { if (!sent && attempt < 5)
748
1187
  flushSoon(link, attempt + 1); }, () => { });
1188
+ groupRooms.agents.wake();
749
1189
  void deps.pairingNotices?.flushFleet(link).catch(() => { });
750
1190
  }, attempt === 0 ? 0 : 100 * attempt);
751
1191
  t.unref?.();
752
1192
  }
753
1193
  rooms.buttons.start();
1194
+ groupRooms.agents.wake();
1195
+ groupRooms.assistant.start();
754
1196
  return {
755
1197
  directorySessions: Object.freeze({
756
1198
  recentAuthentication: actor => sessions.recentAuthentication(actor),
757
1199
  prepareDirectoryRotation: (token, actor) => sessions.prepareDirectoryRotation(token, actor),
758
1200
  completeDirectoryRotation: (rotation, operationId) => sessions.completeDirectoryRotation(rotation, operationId),
759
1201
  }),
760
- handle, receive, features: Object.freeze([...(deps.groupHttp ? [GROUP_POLICY_FEATURE, ...(deps.pairingNotices ? ["quick-pairing-v1"] : [])] : []),
761
- ...(deps.directoryNotices ? ["directory-security-notices-v1"] : []), ...(deps.directorySettings ? [HUB_DIRECTORY_SETTINGS_FEATURE, HUB_DIRECTORY_CA_FEATURE, HUB_DIRECTORY_EDITOR_FEATURE] : [])]),
762
- async close() { closed = true; for (const end of streams)
763
- end(); await rooms.buttons.close(); rooms.forget(); quota.close(); },
1202
+ handle, receive, memberClosed: fleetId => { if (live())
1203
+ groupRooms.agents.disconnected(fleetId); }, features: Object.freeze(["rooms-v1", "room-ask-v1", ...(deps.roomAssistant && deps.assistantAdmin ? ["room-assistant-v1"] : []), ...(deps.refreshAuthorization ? ["sharing-pause-v1"] : []), ...(deps.groupHttp ? [GROUP_POLICY_FEATURE, ...(deps.pairingNotices ? ["quick-pairing-v1"] : [])] : []), ...(grantSubjectsOffered() ? ["grant-subjects-v1"] : []),
1204
+ ...(deps.directoryNotices ? ["directory-security-notices-v1"] : []), ...(deps.memberAddressNotices ? ["member-address-notices-v1"] : []), ...(deps.directorySettings ? [HUB_DIRECTORY_SETTINGS_FEATURE, HUB_DIRECTORY_CA_FEATURE, HUB_DIRECTORY_EDITOR_FEATURE] : [])]),
1205
+ async close() { closed = true; grantSearch.close(); for (const end of streams)
1206
+ end(); await groupRooms.close(); await rooms.buttons.close(); rooms.forget(); quota.close(); },
764
1207
  };
765
1208
  }
766
1209
  //# sourceMappingURL=compose.js.map