@songsid/agend 2.4.0-alpha.3 → 2.4.0-beta.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 (426) hide show
  1. package/dist/agent-cli-instructions.md +8 -4
  2. package/dist/agent-whats-new.js +8 -8
  3. package/dist/agent-whats-new.js.map +1 -1
  4. package/dist/auth-api.js +8 -1
  5. package/dist/auth-api.js.map +1 -1
  6. package/dist/backend/claude-code.d.ts +8 -0
  7. package/dist/backend/claude-code.js +11 -4
  8. package/dist/backend/claude-code.js.map +1 -1
  9. package/dist/backend/codex.js +7 -3
  10. package/dist/backend/codex.js.map +1 -1
  11. package/dist/backend/grok.d.ts +19 -0
  12. package/dist/backend/grok.js +112 -1
  13. package/dist/backend/grok.js.map +1 -1
  14. package/dist/backend/types.d.ts +10 -0
  15. package/dist/backend/types.js.map +1 -1
  16. package/dist/build-provenance.json +1 -1
  17. package/dist/channel/mcp-tools.js +2 -2
  18. package/dist/channel/mcp-tools.js.map +1 -1
  19. package/dist/child-process.d.ts +1 -0
  20. package/dist/child-process.js.map +1 -1
  21. package/dist/claude-model-observation.d.ts +71 -0
  22. package/dist/claude-model-observation.js +169 -0
  23. package/dist/claude-model-observation.js.map +1 -0
  24. package/dist/cross-instance-envelope.d.ts +4 -1
  25. package/dist/cross-instance-envelope.js +12 -7
  26. package/dist/cross-instance-envelope.js.map +1 -1
  27. package/dist/daemon.d.ts +24 -2
  28. package/dist/daemon.js +263 -35
  29. package/dist/daemon.js.map +1 -1
  30. package/dist/delivery-consumed-watch.d.ts +24 -0
  31. package/dist/delivery-consumed-watch.js +21 -10
  32. package/dist/delivery-consumed-watch.js.map +1 -1
  33. package/dist/delivery-outbox.d.ts +5 -1
  34. package/dist/delivery-outbox.js +5 -0
  35. package/dist/delivery-outbox.js.map +1 -1
  36. package/dist/fleet-manager.d.ts +11 -1
  37. package/dist/fleet-manager.js +80 -2
  38. package/dist/fleet-manager.js.map +1 -1
  39. package/dist/general-knowledge/skills/concepts/SKILL.md +16 -3
  40. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +8 -2
  41. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +5 -3
  42. package/dist/general-knowledge/skills/hub/SKILL.md +203 -10
  43. package/dist/general-knowledge/skills/multi-channel/SKILL.md +1 -1
  44. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +18 -7
  45. package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +1 -1
  46. package/dist/grok-delivery-proof.d.ts +24 -0
  47. package/dist/grok-delivery-proof.js +124 -0
  48. package/dist/grok-delivery-proof.js.map +1 -0
  49. package/dist/hub/assistant/admin-types.d.ts +43 -0
  50. package/dist/hub/assistant/admin-types.js +2 -0
  51. package/dist/hub/assistant/admin-types.js.map +1 -0
  52. package/dist/hub/assistant/claude-host.d.ts +17 -0
  53. package/dist/hub/assistant/claude-host.js +300 -0
  54. package/dist/hub/assistant/claude-host.js.map +1 -0
  55. package/dist/hub/assistant/context.d.ts +3 -0
  56. package/dist/hub/assistant/context.js +7 -0
  57. package/dist/hub/assistant/context.js.map +1 -0
  58. package/dist/hub/assistant/fleet-host.d.ts +19 -0
  59. package/dist/hub/assistant/fleet-host.js +28 -0
  60. package/dist/hub/assistant/fleet-host.js.map +1 -0
  61. package/dist/hub/assistant/runner.d.ts +64 -0
  62. package/dist/hub/assistant/runner.js +239 -0
  63. package/dist/hub/assistant/runner.js.map +1 -0
  64. package/dist/hub/assistant/service.d.ts +51 -0
  65. package/dist/hub/assistant/service.js +143 -0
  66. package/dist/hub/assistant/service.js.map +1 -0
  67. package/dist/hub/assistant/store.d.ts +3 -0
  68. package/dist/hub/assistant/store.js +65 -0
  69. package/dist/hub/assistant/store.js.map +1 -0
  70. package/dist/hub/assistant/types.d.ts +60 -0
  71. package/dist/hub/assistant/types.js +2 -0
  72. package/dist/hub/assistant/types.js.map +1 -0
  73. package/dist/hub/catalog.d.ts +1 -1
  74. package/dist/hub/catalog.js +55 -12
  75. package/dist/hub/catalog.js.map +1 -1
  76. package/dist/hub/client.d.ts +10 -0
  77. package/dist/hub/client.js +48 -8
  78. package/dist/hub/client.js.map +1 -1
  79. package/dist/hub/compose/member.d.ts +8 -1
  80. package/dist/hub/compose/member.js +224 -58
  81. package/dist/hub/compose/member.js.map +1 -1
  82. package/dist/hub/compose/server.d.ts +12 -1
  83. package/dist/hub/compose/server.js +74 -11
  84. package/dist/hub/compose/server.js.map +1 -1
  85. package/dist/hub/directory/admission.d.ts +15 -0
  86. package/dist/hub/directory/admission.js +56 -0
  87. package/dist/hub/directory/admission.js.map +1 -0
  88. package/dist/hub/directory/directory.d.ts +1 -1
  89. package/dist/hub/directory/directory.js +63 -0
  90. package/dist/hub/directory/directory.js.map +1 -1
  91. package/dist/hub/directory/types.d.ts +13 -0
  92. package/dist/hub/directory/types.js.map +1 -1
  93. package/dist/hub/grant-access.js +23 -3
  94. package/dist/hub/grant-access.js.map +1 -1
  95. package/dist/hub/grant-search.js +13 -1
  96. package/dist/hub/grant-search.js.map +1 -1
  97. package/dist/hub/group-policy/admin-control.d.ts +1 -0
  98. package/dist/hub/group-policy/admin-control.js +4 -2
  99. package/dist/hub/group-policy/admin-control.js.map +1 -1
  100. package/dist/hub/group-policy/admin-facts.d.ts +1 -0
  101. package/dist/hub/group-policy/admin-facts.js +2 -1
  102. package/dist/hub/group-policy/admin-facts.js.map +1 -1
  103. package/dist/hub/group-policy/admin-read.d.ts +1 -0
  104. package/dist/hub/group-policy/admin-read.js +3 -2
  105. package/dist/hub/group-policy/admin-read.js.map +1 -1
  106. package/dist/hub/group-policy/errors.d.ts +9 -0
  107. package/dist/hub/group-policy/errors.js +13 -0
  108. package/dist/hub/group-policy/errors.js.map +1 -0
  109. package/dist/hub/group-policy/impact-inventory.js +18 -2
  110. package/dist/hub/group-policy/impact-inventory.js.map +1 -1
  111. package/dist/hub/group-policy/store.d.ts +3 -9
  112. package/dist/hub/group-policy/store.js +5 -29
  113. package/dist/hub/group-policy/store.js.map +1 -1
  114. package/dist/hub/http/compose.d.ts +1 -0
  115. package/dist/hub/http/compose.js +482 -15
  116. package/dist/hub/http/compose.js.map +1 -1
  117. package/dist/hub/http/core.d.ts +6 -5
  118. package/dist/hub/http/core.js +74 -48
  119. package/dist/hub/http/core.js.map +1 -1
  120. package/dist/hub/http/deps.d.ts +20 -0
  121. package/dist/hub/http/schema.js +8 -0
  122. package/dist/hub/http/schema.js.map +1 -1
  123. package/dist/hub/init/member-certificate.d.ts +1 -0
  124. package/dist/hub/init/member-certificate.js +39 -0
  125. package/dist/hub/init/member-certificate.js.map +1 -0
  126. package/dist/hub/init/plan-digest.js +1 -0
  127. package/dist/hub/init/plan-digest.js.map +1 -1
  128. package/dist/hub/invitations.d.ts +96 -0
  129. package/dist/hub/invitations.js +292 -0
  130. package/dist/hub/invitations.js.map +1 -0
  131. package/dist/hub/join/certificate-trust.d.ts +13 -0
  132. package/dist/hub/join/certificate-trust.js +41 -0
  133. package/dist/hub/join/certificate-trust.js.map +1 -0
  134. package/dist/hub/join/certificate.d.ts +11 -0
  135. package/dist/hub/join/certificate.js +67 -0
  136. package/dist/hub/join/certificate.js.map +1 -0
  137. package/dist/hub/join/client.d.ts +5 -0
  138. package/dist/hub/join/client.js +30 -3
  139. package/dist/hub/join/client.js.map +1 -1
  140. package/dist/hub/join/http.js +5 -3
  141. package/dist/hub/join/http.js.map +1 -1
  142. package/dist/hub/join/local.d.ts +32 -1
  143. package/dist/hub/join/local.js +116 -11
  144. package/dist/hub/join/local.js.map +1 -1
  145. package/dist/hub/join/service.d.ts +17 -0
  146. package/dist/hub/join/service.js +12 -0
  147. package/dist/hub/join/service.js.map +1 -1
  148. package/dist/hub/join/store.d.ts +5 -0
  149. package/dist/hub/join/store.js +12 -2
  150. package/dist/hub/join/store.js.map +1 -1
  151. package/dist/hub/join/trust.d.ts +9 -0
  152. package/dist/hub/join/trust.js +35 -0
  153. package/dist/hub/join/trust.js.map +1 -1
  154. package/dist/hub/member/pairing-api.js +9 -1
  155. package/dist/hub/member/pairing-api.js.map +1 -1
  156. package/dist/hub/member/room-ask.d.ts +137 -0
  157. package/dist/hub/member/room-ask.js +358 -0
  158. package/dist/hub/member/room-ask.js.map +1 -0
  159. package/dist/hub/member-journal.d.ts +18 -1
  160. package/dist/hub/member-journal.js +76 -3
  161. package/dist/hub/member-journal.js.map +1 -1
  162. package/dist/hub/member-origin.d.ts +177 -0
  163. package/dist/hub/member-origin.js +314 -0
  164. package/dist/hub/member-origin.js.map +1 -0
  165. package/dist/hub/pairing-notices.d.ts +1 -0
  166. package/dist/hub/pairing-notices.js +2 -1
  167. package/dist/hub/pairing-notices.js.map +1 -1
  168. package/dist/hub/pairing.d.ts +8 -0
  169. package/dist/hub/pairing.js +32 -5
  170. package/dist/hub/pairing.js.map +1 -1
  171. package/dist/hub/protocol.d.ts +159 -0
  172. package/dist/hub/protocol.js +19 -1
  173. package/dist/hub/protocol.js.map +1 -1
  174. package/dist/hub/roles/clock.d.ts +18 -0
  175. package/dist/hub/roles/clock.js +58 -0
  176. package/dist/hub/roles/clock.js.map +1 -0
  177. package/dist/hub/roles/cutover-marker.d.ts +57 -0
  178. package/dist/hub/roles/cutover-marker.js +26 -0
  179. package/dist/hub/roles/cutover-marker.js.map +1 -0
  180. package/dist/hub/roles/cutover.js +3 -17
  181. package/dist/hub/roles/cutover.js.map +1 -1
  182. package/dist/hub/roles/read.d.ts +7 -3
  183. package/dist/hub/roles/read.js +9 -1
  184. package/dist/hub/roles/read.js.map +1 -1
  185. package/dist/hub/rooms/admin.d.ts +45 -0
  186. package/dist/hub/rooms/admin.js +105 -0
  187. package/dist/hub/rooms/admin.js.map +1 -0
  188. package/dist/hub/rooms/agents.d.ts +74 -0
  189. package/dist/hub/rooms/agents.js +333 -0
  190. package/dist/hub/rooms/agents.js.map +1 -0
  191. package/dist/hub/rooms/assistant.d.ts +44 -0
  192. package/dist/hub/rooms/assistant.js +179 -0
  193. package/dist/hub/rooms/assistant.js.map +1 -0
  194. package/dist/hub/rooms/context.d.ts +10 -0
  195. package/dist/hub/rooms/context.js +24 -0
  196. package/dist/hub/rooms/context.js.map +1 -0
  197. package/dist/hub/rooms/direct-view.d.ts +39 -0
  198. package/dist/hub/rooms/direct-view.js +38 -0
  199. package/dist/hub/rooms/direct-view.js.map +1 -0
  200. package/dist/hub/rooms/directory.d.ts +35 -0
  201. package/dist/hub/rooms/directory.js +98 -0
  202. package/dist/hub/rooms/directory.js.map +1 -0
  203. package/dist/hub/rooms/schema.d.ts +11 -0
  204. package/dist/hub/rooms/schema.js +73 -0
  205. package/dist/hub/rooms/schema.js.map +1 -0
  206. package/dist/hub/rooms/service.d.ts +449 -0
  207. package/dist/hub/rooms/service.js +581 -0
  208. package/dist/hub/rooms/service.js.map +1 -0
  209. package/dist/hub/rooms/types.d.ts +79 -0
  210. package/dist/hub/rooms/types.js +2 -0
  211. package/dist/hub/rooms/types.js.map +1 -0
  212. package/dist/hub/rooms.d.ts +7 -1
  213. package/dist/hub/rooms.js +30 -5
  214. package/dist/hub/rooms.js.map +1 -1
  215. package/dist/hub/runtime.d.ts +8 -0
  216. package/dist/hub/runtime.js +57 -3
  217. package/dist/hub/runtime.js.map +1 -1
  218. package/dist/hub/server.d.ts +25 -0
  219. package/dist/hub/server.js +63 -5
  220. package/dist/hub/server.js.map +1 -1
  221. package/dist/hub/sessions.js +1 -1
  222. package/dist/hub/sessions.js.map +1 -1
  223. package/dist/hub/settings-commit.d.ts +6 -1
  224. package/dist/hub/settings-commit.js +15 -0
  225. package/dist/hub/settings-commit.js.map +1 -1
  226. package/dist/hub/settings-directory-recovery.d.ts +5 -0
  227. package/dist/hub/settings-directory-recovery.js +11 -1
  228. package/dist/hub/settings-directory-recovery.js.map +1 -1
  229. package/dist/hub/settings-member-address-control.d.ts +84 -0
  230. package/dist/hub/settings-member-address-control.js +150 -0
  231. package/dist/hub/settings-member-address-control.js.map +1 -0
  232. package/dist/hub/settings-member-address-decision.d.ts +229 -0
  233. package/dist/hub/settings-member-address-decision.js +320 -0
  234. package/dist/hub/settings-member-address-decision.js.map +1 -0
  235. package/dist/hub/settings-member-address-http.d.ts +9 -0
  236. package/dist/hub/settings-member-address-http.js +79 -0
  237. package/dist/hub/settings-member-address-http.js.map +1 -0
  238. package/dist/hub/settings-member-address-network.d.ts +2 -0
  239. package/dist/hub/settings-member-address-network.js +22 -0
  240. package/dist/hub/settings-member-address-network.js.map +1 -0
  241. package/dist/hub/settings-member-address-notices.d.ts +22 -0
  242. package/dist/hub/settings-member-address-notices.js +21 -0
  243. package/dist/hub/settings-member-address-notices.js.map +1 -0
  244. package/dist/hub/settings-member-address-policy.d.ts +22 -0
  245. package/dist/hub/settings-member-address-policy.js +36 -0
  246. package/dist/hub/settings-member-address-policy.js.map +1 -0
  247. package/dist/hub/settings-member-address.d.ts +64 -0
  248. package/dist/hub/settings-member-address.js +239 -0
  249. package/dist/hub/settings-member-address.js.map +1 -0
  250. package/dist/hub/settings-web-address-decision.js +3 -1
  251. package/dist/hub/settings-web-address-decision.js.map +1 -1
  252. package/dist/hub/settings-web-address-http.js +3 -2
  253. package/dist/hub/settings-web-address-http.js.map +1 -1
  254. package/dist/hub/settings-web-address-policy.d.ts +3 -2
  255. package/dist/hub/settings-web-address-policy.js +3 -1
  256. package/dist/hub/settings-web-address-policy.js.map +1 -1
  257. package/dist/hub/socket.d.ts +2 -0
  258. package/dist/hub/socket.js +2 -0
  259. package/dist/hub/socket.js.map +1 -1
  260. package/dist/hub/teams/grant-schema.d.ts +2 -0
  261. package/dist/hub/teams/grant-schema.js +13 -0
  262. package/dist/hub/teams/grant-schema.js.map +1 -0
  263. package/dist/hub/teams/index.d.ts +7 -0
  264. package/dist/hub/teams/index.js +273 -0
  265. package/dist/hub/teams/index.js.map +1 -0
  266. package/dist/hub/teams/store.d.ts +34 -0
  267. package/dist/hub/teams/store.js +57 -0
  268. package/dist/hub/teams/store.js.map +1 -0
  269. package/dist/hub/teams/types.d.ts +98 -0
  270. package/dist/hub/teams/types.js +2 -0
  271. package/dist/hub/teams/types.js.map +1 -0
  272. package/dist/hub/tls.d.ts +47 -0
  273. package/dist/hub/tls.js +23 -6
  274. package/dist/hub/tls.js.map +1 -1
  275. package/dist/hub/types.d.ts +54 -3
  276. package/dist/hub/validation.d.ts +1 -1
  277. package/dist/hub/validation.js +2 -2
  278. package/dist/hub/validation.js.map +1 -1
  279. package/dist/hub/web-origin.d.ts +20 -7
  280. package/dist/hub/web-origin.js +26 -15
  281. package/dist/hub/web-origin.js.map +1 -1
  282. package/dist/hub-pilot-trust-settings.d.ts +4 -0
  283. package/dist/hub-pilot-trust-settings.js +13 -0
  284. package/dist/hub-pilot-trust-settings.js.map +1 -0
  285. package/dist/human-delivery-receipts.d.ts +4 -2
  286. package/dist/human-delivery-receipts.js +20 -13
  287. package/dist/human-delivery-receipts.js.map +1 -1
  288. package/dist/inbound-presentation.d.ts +28 -0
  289. package/dist/inbound-presentation.js +48 -0
  290. package/dist/inbound-presentation.js.map +1 -0
  291. package/dist/instance-lifecycle.js +1 -0
  292. package/dist/instance-lifecycle.js.map +1 -1
  293. package/dist/instructions.d.ts +4 -2
  294. package/dist/instructions.js +7 -4
  295. package/dist/instructions.js.map +1 -1
  296. package/dist/locale.js +16 -0
  297. package/dist/locale.js.map +1 -1
  298. package/dist/log-service.d.ts +3 -0
  299. package/dist/log-service.js +39 -22
  300. package/dist/log-service.js.map +1 -1
  301. package/dist/log-steps.d.ts +56 -1
  302. package/dist/log-steps.js +318 -56
  303. package/dist/log-steps.js.map +1 -1
  304. package/dist/needs-you-hub.js +6 -2
  305. package/dist/needs-you-hub.js.map +1 -1
  306. package/dist/needs-you.d.ts +5 -1
  307. package/dist/needs-you.js +4 -8
  308. package/dist/needs-you.js.map +1 -1
  309. package/dist/office-share-page.js +1 -1
  310. package/dist/office-share-page.js.map +1 -1
  311. package/dist/outbound-handlers.d.ts +1 -0
  312. package/dist/outbound-handlers.js +6 -0
  313. package/dist/outbound-handlers.js.map +1 -1
  314. package/dist/outbound-schemas.d.ts +1 -0
  315. package/dist/outbound-schemas.js +1 -0
  316. package/dist/outbound-schemas.js.map +1 -1
  317. package/dist/queued-handoffs.d.ts +3 -1
  318. package/dist/queued-handoffs.js +1 -1
  319. package/dist/queued-handoffs.js.map +1 -1
  320. package/dist/runtime-transcript-source.d.ts +2 -0
  321. package/dist/runtime-transcript-source.js +23 -1
  322. package/dist/runtime-transcript-source.js.map +1 -1
  323. package/dist/settings-api.d.ts +1 -0
  324. package/dist/settings-api.js +15 -8
  325. package/dist/settings-api.js.map +1 -1
  326. package/dist/settings-baseline.d.ts +3 -0
  327. package/dist/settings-baseline.js +2 -2
  328. package/dist/settings-baseline.js.map +1 -1
  329. package/dist/settings-effect.d.ts +3 -0
  330. package/dist/settings-effect.js +12 -2
  331. package/dist/settings-effect.js.map +1 -1
  332. package/dist/topic-commands.js +2 -1
  333. package/dist/topic-commands.js.map +1 -1
  334. package/dist/transcript-jsonl.d.ts +24 -0
  335. package/dist/transcript-jsonl.js +72 -22
  336. package/dist/transcript-jsonl.js.map +1 -1
  337. package/dist/transcript-monitor.d.ts +5 -1
  338. package/dist/transcript-monitor.js +65 -3
  339. package/dist/transcript-monitor.js.map +1 -1
  340. package/dist/transcript-needles.d.ts +1 -1
  341. package/dist/transcript-needles.js +1 -1
  342. package/dist/transcript-records.d.ts +2 -1
  343. package/dist/transcript-records.js.map +1 -1
  344. package/dist/transcript-sources.d.ts +4 -0
  345. package/dist/transcript-sources.js +2 -0
  346. package/dist/transcript-sources.js.map +1 -1
  347. package/dist/ui/agent-details-settings.js +10 -1
  348. package/dist/ui/chat-activity.js +2 -2
  349. package/dist/ui/fleet-canvas.js +5 -2
  350. package/dist/ui/fleet-office-card.js +4 -2
  351. package/dist/ui/fleet-org.js +2 -0
  352. package/dist/ui/hub-admin-rooms-strings.js +28 -0
  353. package/dist/ui/hub-admin-rooms.js +77 -0
  354. package/dist/ui/hub-assistant-admin-strings.js +26 -0
  355. package/dist/ui/hub-assistant-admin.js +85 -0
  356. package/dist/ui/hub-client.js +178 -14
  357. package/dist/ui/hub-grant-picker.js +14 -5
  358. package/dist/ui/hub-group-strings.js +3 -3
  359. package/dist/ui/hub-invitations-strings.js +30 -0
  360. package/dist/ui/hub-invitations.js +108 -0
  361. package/dist/ui/hub-join-one-strings.js +2 -0
  362. package/dist/ui/hub-pairing-form-strings.js +48 -0
  363. package/dist/ui/hub-pilot-trust-strings.js +27 -0
  364. package/dist/ui/hub-pilot-trust.js +41 -0
  365. package/dist/ui/hub-room-composer.js +123 -0
  366. package/dist/ui/hub-room-favorites.js +90 -0
  367. package/dist/ui/hub-room-list.js +152 -0
  368. package/dist/ui/hub-room-members-strings.js +12 -0
  369. package/dist/ui/hub-room-members.js +104 -0
  370. package/dist/ui/hub-room-new-strings.js +46 -0
  371. package/dist/ui/hub-room-new.js +135 -0
  372. package/dist/ui/hub-room-presence.js +123 -0
  373. package/dist/ui/hub-room-settings-strings.js +26 -0
  374. package/dist/ui/hub-room-settings.js +134 -0
  375. package/dist/ui/hub-room-strings.js +224 -0
  376. package/dist/ui/hub-room-thread.js +288 -0
  377. package/dist/ui/hub-room-unread.js +51 -0
  378. package/dist/ui/hub-room-working.js +29 -0
  379. package/dist/ui/hub-strings.js +2 -0
  380. package/dist/ui/hub-teams-strings.js +34 -0
  381. package/dist/ui/hub-teams.js +169 -0
  382. package/dist/ui/log-row.js +14 -5
  383. package/dist/ui/panel-details.js +6 -1
  384. package/dist/ui/panel-hub.js +115 -57
  385. package/dist/ui/panel-needs.js +2 -0
  386. package/dist/ui/settings-hub-company-join.js +31 -11
  387. package/dist/ui/settings-hub-connection.js +9 -3
  388. package/dist/ui/settings-hub-member-address.js +220 -0
  389. package/dist/ui/settings-hub-section.js +4 -2
  390. package/dist/ui/settings-hub-web-address.js +21 -5
  391. package/dist/ui/settings-hub.js +10 -4
  392. package/dist/ui/settings-layout.js +5 -1
  393. package/dist/ui/shared/app-i18n.js +2 -2
  394. package/dist/ui/shared/app-needs.js +3 -0
  395. package/dist/ui/shared/app-shell.js +7 -4
  396. package/dist/ui/shared/app.css +8 -0
  397. package/dist/ui/shared/chat-render.js +10 -0
  398. package/dist/ui/shared/chat-thread.js +15 -5
  399. package/dist/ui/shared/hub-chat.css +22 -0
  400. package/dist/ui/shared/hub-rooms-u2.css +42 -0
  401. package/dist/ui/shared/hub-signin.css +2 -0
  402. package/dist/ui/shared/hub-teams.css +31 -0
  403. package/dist/ui/shared/model-observation.js +16 -0
  404. package/dist/ui/shared/page-head.js +3 -2
  405. package/dist/ui/shared/stale-tab.css +6 -0
  406. package/dist/ui/shared/stale-tab.js +50 -0
  407. package/dist/ui/shared/usage-dialog.js +2 -1
  408. package/dist/ui/shared/view-strings.js +2 -0
  409. package/dist/usage/agent-output.js +1 -0
  410. package/dist/usage/agent-output.js.map +1 -1
  411. package/dist/usage/i18n-keys.d.ts +1 -1
  412. package/dist/usage/i18n-keys.js +1 -1
  413. package/dist/usage/i18n-keys.js.map +1 -1
  414. package/dist/usage/i18n.d.ts +1 -1
  415. package/dist/usage/i18n.js +2 -1
  416. package/dist/usage/i18n.js.map +1 -1
  417. package/dist/usage/providers.d.ts +4 -1
  418. package/dist/usage/providers.js +25 -10
  419. package/dist/usage/providers.js.map +1 -1
  420. package/dist/usage/usage-api.d.ts +1 -1
  421. package/dist/usage/usage-api.js +4 -4
  422. package/dist/usage/usage-api.js.map +1 -1
  423. package/dist/web-api.d.ts +2 -0
  424. package/dist/web-api.js +6 -2
  425. package/dist/web-api.js.map +1 -1
  426. 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";
@@ -27,6 +28,9 @@ import { HubCatalogService } from "../catalog.js";
27
28
  import { HubGrantSearch } from "../grant-search.js";
28
29
  import { HubPolicyService } from "../policy.js";
29
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";
30
34
  import { HubAttachmentRefused } from "../attachments/store.js";
31
35
  import { HubQuotaService } from "../quota.js";
32
36
  import { HubCore, pairingOwnerByLogin } from "./core.js";
@@ -36,6 +40,7 @@ import { serveHubWorkspaceShell } from "../../web-api.js";
36
40
  import { servePublicAsset } from "../../auth-api.js";
37
41
  import { handleCompanyJoin, companyFlowCookie } from "../join/http.js";
38
42
  import { CompanyJoinCodeRefusal, CompanyJoinLimit, CompanyJoinOfferPending } from "../join/service.js";
43
+ import { HubMemberAddressError } from "../settings-member-address-policy.js";
39
44
  export { HUB_HTTP_MIGRATIONS };
40
45
  /** S5's lazy entry (HubHttpEntry): this module itself — `createHubHttp` and `migrations`. */
41
46
  export const migrations = HUB_HTTP_MIGRATIONS;
@@ -46,7 +51,20 @@ export const HUB_UI_MODULES = Object.freeze(["panel-hub.js", "hub-client.js", "h
46
51
  // Hub UX U2 (M-2932): the group-search picker (its own words inside), shared with B2's join-code scope.
47
52
  "hub-group-search.js", "hub-join-steps.js", "hub-grant-picker.js",
48
53
  // B2: code management and the same-request Hub approval queue.
49
- "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", "hub-teams.js", "hub-teams-strings.js"]);
50
68
  const BODY_LIMIT = 96 * 1024;
51
69
  const UPLOADS_PER_SESSION = 2, UPLOADS_TOTAL = 8;
52
70
  const UUID = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
@@ -138,11 +156,22 @@ const int = (v) => { const n = typeof v === "string" && /^\d{1,15}$/.test(v) ? N
138
156
  /** Build S3's HTTP handler and member receiver over S5's deps. `sql` is S5's `hubTxDatabase`. */
139
157
  export function createHubHttp(deps, sql) {
140
158
  let closed = false;
141
- const core = new HubCore(deps, sql, () => !closed);
159
+ const teamFactory = deps.teams;
160
+ // Keep the caller's other dependency reads live, without installing Team state on its shared object.
161
+ const mountedDeps = teamFactory ? Object.create(deps) : deps;
162
+ const core = new HubCore(mountedDeps, sql, () => !closed);
163
+ const teams = teamFactory?.(core);
164
+ if (teams)
165
+ Object.defineProperties(mountedDeps, {
166
+ roomTeams: { value: teams }, roomTeamCandidates: { value: teams.candidates.bind(teams) },
167
+ });
142
168
  const sharing = new HubSharingService(core);
143
169
  const sessions = new HubSessions(core), catalog = new HubCatalogService(core), policy = new HubPolicyService(core);
144
170
  const grantSearch = new HubGrantSearch(core);
145
171
  const rooms = new HubRoomsService(core, policy);
172
+ const groupRooms = new HubGroupRooms(core);
173
+ const invitations = deps.roomInvitations?.(core, groupRooms.invitationHost());
174
+ const roomAdmin = new HubRoomAdmin(core, event => groupRooms.publish(event), id => { groupRooms.assistant.forget(id); groupRooms.agents.sweep(id); });
146
175
  const quota = new HubQuotaService(core);
147
176
  const uiDir = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "ui");
148
177
  const live = () => !closed && core.live();
@@ -181,8 +210,8 @@ export function createHubHttp(deps, sql) {
181
210
  };
182
211
  const m = (re) => re.exec(path);
183
212
  // Composed routes, not enrollment authority or the administrator's on/off switch. Older Hubs omit unsupported cards.
184
- const offered = [...(deps.refreshAuthorization ? ["sharing-pause-v1"] : []), ...(deps.groupHttp ? [GROUP_POLICY_FEATURE, ...(deps.pairingNotices ? ["quick-pairing-v1"] : [])] : []), ...(grantSubjectsOffered() ? ["grant-subjects-v1"] : []),
185
- ...(deps.companyJoin ? ["company-join-v1", "enrolment-code-v1"] : []), ...(deps.directoryNotices ? ["directory-security-notices-v1"] : []),
213
+ const offered = ["rooms-v1", ...(teams ? ["teams-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"] : []),
214
+ ...(deps.companyJoin ? ["company-join-v1", "enrolment-code-v1"] : []), ...(deps.directoryNotices ? ["directory-security-notices-v1"] : []), ...(deps.memberAddressNotices ? ["member-address-notices-v1"] : []),
186
215
  ...(deps.directorySettings ? [HUB_DIRECTORY_SETTINGS_FEATURE, HUB_DIRECTORY_CA_FEATURE, HUB_DIRECTORY_EDITOR_FEATURE] : [])];
187
216
  const features = offered.length ? { features: offered } : {};
188
217
  let r;
@@ -260,6 +289,34 @@ export function createHubHttp(deps, sql) {
260
289
  }
261
290
  throw new HttpError(405, "method");
262
291
  }
292
+ if (deps.memberAddressNotices) {
293
+ const notices = deps.memberAddressNotices;
294
+ if (path === "/hub/v1/security-notices/member-address") {
295
+ if (method !== "GET")
296
+ throw new HttpError(405, "method");
297
+ signedIn();
298
+ if ([...query.keys()].some(k => k !== "before") || query.getAll("before").length > 1
299
+ || query.has("before") && !/^[1-9][0-9]{0,15}$/.test(query.get("before")))
300
+ throw new HubProtocolError("invalid");
301
+ const page = await guard(() => notices.forSession(ctx, query.has("before") ? Number(query.get("before")) : undefined));
302
+ if (!live())
303
+ throw new HubProtocolError("unavailable");
304
+ signedIn();
305
+ return send(res, 200, page);
306
+ }
307
+ if ((r = m(/^\/hub\/v1\/security-notices\/member-address\/([^/]+)\/ack$/))) {
308
+ if (method !== "POST")
309
+ throw new HttpError(405, "method");
310
+ if ([...query.keys()].length)
311
+ throw new HubProtocolError("invalid");
312
+ csrf();
313
+ await guard(() => notices.acknowledgeSession(ctx, uuid(r[1])));
314
+ if (!live())
315
+ throw new HubProtocolError("unavailable");
316
+ signedIn();
317
+ return send(res, 200, { ok: true });
318
+ }
319
+ }
263
320
  if (deps.directoryNotices) {
264
321
  const notices = deps.directoryNotices;
265
322
  if (path === "/hub/v1/security-notices/directory") {
@@ -431,12 +488,19 @@ export function createHubHttp(deps, sql) {
431
488
  signedIn();
432
489
  return send(res, 200, { activity: await guard(() => rooms.activity(ctx, uuid(r[1]))) });
433
490
  }
491
+ if ((r = m(/^\/hub\/v1\/exposures\/([^/]+)\/rooms$/))) {
492
+ if (method !== "GET")
493
+ throw new HttpError(405, "method");
494
+ signedIn();
495
+ return send(res, 200, { rooms: await guard(() => groupRooms.roomsForExposure(ctx, uuid(r[1]))) });
496
+ }
434
497
  if ((r = m(/^\/hub\/v1\/exposures\/([^/]+)\/sharing$/))) {
435
498
  if (method !== "POST")
436
499
  throw new HttpError(405, "method");
437
500
  csrf();
438
501
  const b = await body();
439
502
  await guard(() => sharing.change(ctx, uuid(r[1]), b));
503
+ groupRooms.agents.publicationChanged(undefined, uuid(r[1]));
440
504
  return send(res, 200, { ok: true });
441
505
  }
442
506
  if ((r = m(/^\/hub\/v1\/exposures\/([^/]+)\/freeze$/))) {
@@ -458,20 +522,353 @@ export function createHubHttp(deps, sql) {
458
522
  await guard(() => quota.setVisible(ctx, exposureId, int(b.revision), b.visible));
459
523
  return send(res, 200, { quotaVisible: b.visible, ...quota.projection(exposureId) });
460
524
  }
525
+ if (path === "/hub/v1/teams/candidates") {
526
+ if (!teams)
527
+ throw new HttpError(404, "not-found");
528
+ if (method !== "GET")
529
+ throw new HttpError(405, "method");
530
+ signedIn();
531
+ return send(res, 200, { candidates: await guard(() => teams.suggestions(ctx, {
532
+ kind: query.get("kind"), q: query.get("q"), ...(query.has("teamId") ? { teamId: query.get("teamId") } : {}),
533
+ })) });
534
+ }
535
+ if (path === "/hub/v1/teams") {
536
+ if (!teams)
537
+ throw new HttpError(404, "not-found");
538
+ if (method === "GET") {
539
+ signedIn();
540
+ return send(res, 200, { teams: await guard(() => teams.list(ctx)) });
541
+ }
542
+ if (method === "POST") {
543
+ csrf();
544
+ const b = await body();
545
+ return send(res, 201, { team: await guard(() => teams.create(ctx, b)) });
546
+ }
547
+ throw new HttpError(405, "method");
548
+ }
549
+ if ((r = m(/^\/hub\/v1\/teams\/([^/]+)$/))) {
550
+ if (!teams)
551
+ throw new HttpError(404, "not-found");
552
+ const id = uuid(r[1]);
553
+ if (method === "GET") {
554
+ signedIn();
555
+ return send(res, 200, { team: await guard(() => teams.get(ctx, id)) });
556
+ }
557
+ if (method === "PATCH") {
558
+ csrf();
559
+ const b = await body();
560
+ return send(res, 200, { team: await guard(() => teams.update(ctx, id, b)) });
561
+ }
562
+ if (method === "DELETE") {
563
+ csrf();
564
+ await guard(() => teams.remove(ctx, id));
565
+ return send(res, 200, { ok: true });
566
+ }
567
+ throw new HttpError(405, "method");
568
+ }
569
+ if (path === "/hub/v1/admin/assistant" || path === "/hub/v1/admin/assistant/usage" || /^\/hub\/v1\/admin\/assistant\/rooms\/[^/]+\/stop$/.test(path)) {
570
+ const port = deps.roomAssistant && deps.assistantAdmin;
571
+ if (!port)
572
+ throw new HttpError(404, "not-found");
573
+ if (mutation)
574
+ csrf();
575
+ else
576
+ signedIn();
577
+ const permit = await guard(() => core.management(ctx, "hub.admin"));
578
+ const call = async (work) => {
579
+ permit.assertCurrent();
580
+ let result;
581
+ try {
582
+ result = await work();
583
+ }
584
+ catch {
585
+ permit.assertCurrent();
586
+ throw new HttpError(503, "unavailable");
587
+ }
588
+ permit.assertCurrent();
589
+ return result;
590
+ };
591
+ if (path === "/hub/v1/admin/assistant") {
592
+ if (method === "GET")
593
+ return send(res, 200, await guard(() => call(() => port.settings())));
594
+ if (method === "PUT") {
595
+ const b = await body();
596
+ return send(res, 200, await guard(() => call(() => port.configure(b))));
597
+ }
598
+ }
599
+ else if (path.endsWith("/usage") && method === "GET")
600
+ return send(res, 200, await guard(() => call(() => port.usage())));
601
+ else if (method === "POST") {
602
+ const id = uuid(path.split("/")[6]);
603
+ await guard(() => call(() => { groupRooms.assistant.cancel(id); return port.stopRoom(id); }));
604
+ return send(res, 200, { ok: true });
605
+ }
606
+ throw new HttpError(405, "method");
607
+ }
608
+ if (path === "/hub/v1/admin/rooms/creators") {
609
+ if (method === "GET") {
610
+ signedIn();
611
+ return send(res, 200, await guard(() => roomAdmin.creators(ctx)));
612
+ }
613
+ if (method === "PUT") {
614
+ csrf();
615
+ const b = await body();
616
+ return send(res, 200, await guard(() => roomAdmin.creators(ctx, b)));
617
+ }
618
+ throw new HttpError(405, "method");
619
+ }
620
+ if (path === "/hub/v1/admin/rooms") {
621
+ if (method !== "GET")
622
+ throw new HttpError(405, "method");
623
+ signedIn();
624
+ return send(res, 200, await guard(() => roomAdmin.list(ctx)));
625
+ }
626
+ if ((r = m(/^\/hub\/v1\/admin\/rooms\/([^/]+)(?:\/(join))?$/))) {
627
+ const roomId = uuid(r[1]);
628
+ csrf();
629
+ if (r[2] === "join" && method === "POST")
630
+ return send(res, 200, await guard(() => roomAdmin.join(ctx, roomId)));
631
+ if (!r[2] && method === "PATCH") {
632
+ const b = await body();
633
+ return send(res, 200, await guard(() => roomAdmin.archive(ctx, roomId, b)));
634
+ }
635
+ throw new HttpError(405, "method");
636
+ }
637
+ if (path === "/hub/v1/rooms/candidates") {
638
+ if (method !== "GET")
639
+ throw new HttpError(405, "method");
640
+ signedIn();
641
+ return send(res, 200, { candidates: await guard(() => groupRooms.candidates(ctx, query.get("q") ?? "", query.get("kind") ?? "person")) });
642
+ }
643
+ if ((r = m(/^\/hub\/v1\/rooms\/candidates\/group\/([^/]+)$/))) {
644
+ if (method !== "GET")
645
+ throw new HttpError(405, "method");
646
+ signedIn();
647
+ return send(res, 200, await guard(() => groupRooms.groupCandidate(ctx, uuid(r[1]))));
648
+ }
649
+ if (path === "/hub/v1/invitations") {
650
+ if (!invitations)
651
+ throw new HttpError(404, "not-found");
652
+ if (method !== "GET")
653
+ throw new HttpError(405, "method");
654
+ signedIn();
655
+ return send(res, 200, await guard(() => invitations.pending(ctx)));
656
+ }
657
+ if ((r = m(/^\/hub\/v1\/invitations\/([^/]+)\/(accept|decline)$/))) {
658
+ if (!invitations)
659
+ throw new HttpError(404, "not-found");
660
+ if (method !== "POST")
661
+ throw new HttpError(405, "method");
662
+ csrf();
663
+ const id = uuid(r[1]);
664
+ return send(res, 200, await guard(() => r[2] === "accept" ? invitations.accept(ctx, id) : invitations.decline(ctx, id)));
665
+ }
666
+ if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/invitations(?:\/([^/]+))?$/))) {
667
+ if (!invitations)
668
+ throw new HttpError(404, "not-found");
669
+ csrf();
670
+ const id = uuid(r[1]);
671
+ if (method === "DELETE" && r[2])
672
+ return send(res, 200, await guard(() => invitations.cancel(ctx, id, uuid(r[2]))));
673
+ if (method === "POST" && !r[2]) {
674
+ const b = await body();
675
+ if (Object.keys(b).length !== 1 || !(Array.isArray(b.agents) || typeof b.team === "string"))
676
+ throw new HubProtocolError("invalid");
677
+ const input = Array.isArray(b.agents) ? { agents: b.agents.map(value => uuid(value)) } : { team: uuid(b.team) };
678
+ if (input.agents && input.agents.length > 64)
679
+ throw new HubProtocolError("invalid");
680
+ return send(res, 200, await guard(() => invitations.invite(ctx, id, input)));
681
+ }
682
+ throw new HttpError(405, "method");
683
+ }
684
+ if (path === "/hub/v1/rooms/events") {
685
+ if (method !== "GET")
686
+ throw new HttpError(405, "method");
687
+ const streamSession = signedIn(), streamPerson = personKeyString(await guard(() => ctx.requirePerson()));
688
+ const requestedNotices = query.get("notices"), notices = deps.pairingNotices;
689
+ const noticeVersion = requestedNotices === "3" && deps.companyJoin ? 3 : requestedNotices === "2" || requestedNotices === "3" ? 2 : null;
690
+ const initialNotices = notices && noticeVersion ? await guard(() => notices.forSession(ctx, noticeVersion)) : null;
691
+ if (streams.size >= 64 || !ctx.isCurrent?.())
692
+ throw new HubProtocolError("backpressure");
693
+ res.writeHead(200, { ...API_HEADERS, "Content-Type": "text/event-stream; charset=utf-8", Connection: "keep-alive", "X-Accel-Buffering": "no" });
694
+ let ended = false, queued = 0, tail = Promise.resolve(), noticesRunning = false, noticesDirty = false;
695
+ let offNotices = () => { };
696
+ const close = () => { if (ended)
697
+ return; ended = true; off(); offNotices(); clearInterval(heartbeat); streams.delete(close); res.end(); };
698
+ const off = groupRooms.subscribe(event => {
699
+ if (ended)
700
+ return;
701
+ if (event.audiencePerson && event.audiencePerson !== streamPerson)
702
+ return;
703
+ if (!event.audiencePerson && !groupRooms.interested(streamPerson, event))
704
+ return;
705
+ if (++queued > 64) {
706
+ close();
707
+ return;
708
+ }
709
+ tail = tail.then(async () => {
710
+ if (ended)
711
+ return;
712
+ let data;
713
+ // Concurrent agent checks can briefly fill the person's physical read slots. Keep this event in the bounded
714
+ // queue and re-read it after a short delay; persistent overload and all other failures still close the stream.
715
+ for (let attempt = 0;; attempt++) {
716
+ try {
717
+ if (event.audiencePerson) {
718
+ if (event.type === "invitation.changed") {
719
+ data = personKeyString(await ctx.requirePerson()) === event.audiencePerson ? {} : null;
720
+ }
721
+ else {
722
+ const view = await rooms.view(ctx, event.roomId);
723
+ if (event.type === "unread.changed")
724
+ data = { roomId: event.roomId, unread: directUnread(core, view) };
725
+ else if (event.type === "room.changed")
726
+ data = { roomId: event.roomId, room: directRoomView(view, rooms.presence(view.exposureId), directUnread(core, view)) };
727
+ else {
728
+ const page = await rooms.readPage(ctx, event.roomId, 0, streamSession.sessionId, { before: null, limit: 100 });
729
+ const message = directMessages(page.room, page.entries, streamSession.displayName).find(m => m.id === event.data.messageId);
730
+ data = message ? { roomId: event.roomId, message } : null;
731
+ }
732
+ }
733
+ }
734
+ else
735
+ data = await groupRooms.event(ctx, event);
736
+ break;
737
+ }
738
+ catch (error) {
739
+ if (!(error instanceof HubProtocolError) || error.code !== "backpressure" || attempt >= 3)
740
+ throw error;
741
+ await new Promise(resolve => setTimeout(resolve, 25 * 2 ** attempt));
742
+ if (ended || !live() || !ctx.isCurrent?.())
743
+ return close();
744
+ }
745
+ }
746
+ if (ended || !live() || !ctx.isCurrent?.())
747
+ return close();
748
+ if (data && !res.write(`event: ${event.type}\ndata: ${JSON.stringify(data)}\n\n`))
749
+ close();
750
+ }).catch(close).finally(() => { queued--; });
751
+ });
752
+ const pushNotices = async () => {
753
+ if (ended || !notices || !noticeVersion)
754
+ return;
755
+ if (noticesRunning) {
756
+ noticesDirty = true;
757
+ return;
758
+ }
759
+ noticesRunning = true;
760
+ try {
761
+ do {
762
+ noticesDirty = false;
763
+ const rows = await notices.forSession(ctx, noticeVersion);
764
+ if (ended || !live() || !ctx.isCurrent?.())
765
+ return close();
766
+ if (!res.write(`event: notices\ndata: ${JSON.stringify({ notices: rows })}\n\n`))
767
+ return close();
768
+ } while (noticesDirty);
769
+ }
770
+ catch {
771
+ close();
772
+ }
773
+ finally {
774
+ noticesRunning = false;
775
+ }
776
+ };
777
+ const heartbeat = setInterval(() => { if (!live() || !ctx.isCurrent?.())
778
+ close();
779
+ else if (!res.write(": heartbeat\n\n"))
780
+ close(); }, 15_000);
781
+ heartbeat.unref();
782
+ try {
783
+ if (notices && noticeVersion)
784
+ offNotices = notices.subscribe(() => void pushNotices());
785
+ }
786
+ catch {
787
+ close();
788
+ return;
789
+ }
790
+ streams.add(close);
791
+ res.on("close", close);
792
+ if (initialNotices)
793
+ res.write(`event: notices\ndata: ${JSON.stringify({ notices: initialNotices })}\n\n`);
794
+ res.write(": connected\n\n");
795
+ return;
796
+ }
461
797
  if (path === "/hub/v1/rooms") {
462
798
  if (method === "GET") {
463
799
  signedIn();
464
800
  const view = await guard(() => rooms.listAuthorized(ctx));
465
- return send(res, 200, { rooms: view.rooms.map(room => ({ ...room, ...quota.roomProjection(room, view.grantProof) })) });
801
+ // Cached clients draw every row as a direct agent conversation. New roomList() opts into group rows.
802
+ if (query.get("v") !== "2")
803
+ return send(res, 200, { rooms: view.rooms.map(room => ({ ...room, ...quota.roomProjection(room, view.grantProof) })) });
804
+ const groups = await guard(() => groupRooms.list(ctx));
805
+ const pending = invitations ? await guard(() => invitations.pending(ctx)) : null;
806
+ 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) }))] });
466
807
  }
467
808
  if (method === "POST") {
468
809
  csrf();
469
810
  const b = await body();
811
+ if (b.exposureId === undefined)
812
+ return send(res, 200, await guard(() => groupRooms.create(ctx, b)));
470
813
  const room = await guard(() => rooms.open(ctx, uuid(b.exposureId), uuid(b.grantId)));
471
814
  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) } });
472
815
  }
473
816
  throw new HttpError(405, "method");
474
817
  }
818
+ if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)$/))) {
819
+ signedIn();
820
+ const roomId = uuid(r[1]);
821
+ if (groupRooms.has(roomId)) {
822
+ if (method === "GET") {
823
+ const view = await guard(() => groupRooms.detail(ctx, roomId));
824
+ const invited = invitations && view.me.role === "manager" && !view.room.archived ? await guard(() => invitations.forRoom(ctx, roomId)) : [];
825
+ return send(res, 200, { ...view, invited });
826
+ }
827
+ if (method === "PATCH") {
828
+ csrf();
829
+ const b = await body();
830
+ return send(res, 200, await guard(() => groupRooms.patch(ctx, roomId, b)));
831
+ }
832
+ }
833
+ else if (method === "GET") {
834
+ const room = await guard(() => rooms.view(ctx, roomId));
835
+ const person = personKeyString(room.asker), name = signedIn().displayName;
836
+ return send(res, 200, { room: directRoomView(room, rooms.presence(room.exposureId), directUnread(core, room)), me: { id: person, role: "member" },
837
+ members: [{ id: person, kind: "person", name, role: "member", presence: "online" }, { id: room.exposureId, kind: "agent", name: room.exposureName,
838
+ owner: { name: room.ownerName }, role: "member", presence: rooms.presence(room.exposureId), canAsk: room.state === "active" }],
839
+ settings: { allMention: false, historyForNew: "all" }, invited: [] });
840
+ }
841
+ throw new HttpError(405, "method");
842
+ }
843
+ if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/members(?:\/([^/]+))?$/))) {
844
+ csrf();
845
+ const roomId = uuid(r[1]), memberId = r[2] ? uuid(r[2]) : null;
846
+ if (method === "POST" && !memberId) {
847
+ const b = await body();
848
+ return send(res, 200, await guard(() => groupRooms.add(ctx, roomId, b)));
849
+ }
850
+ if (method === "DELETE" && memberId)
851
+ return send(res, 200, await guard(() => groupRooms.changeMember(ctx, roomId, memberId)));
852
+ if (method === "PATCH" && memberId) {
853
+ const b = await body();
854
+ if (Object.keys(b).length !== 1 || !["manager", "member"].includes(String(b.role)))
855
+ throw new HubProtocolError("invalid");
856
+ return send(res, 200, await guard(() => groupRooms.changeMember(ctx, roomId, memberId, b.role)));
857
+ }
858
+ throw new HttpError(405, "method");
859
+ }
860
+ if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/read$/))) {
861
+ if (method !== "POST")
862
+ throw new HttpError(405, "method");
863
+ csrf();
864
+ const b = await body(), roomId = uuid(r[1]);
865
+ if (groupRooms.has(roomId))
866
+ return send(res, 200, await guard(() => groupRooms.markRead(ctx, roomId, b.upTo)));
867
+ const room = await guard(() => rooms.view(ctx, roomId));
868
+ markDirectRead(core, roomId, str(b.upTo));
869
+ groupRooms.publish({ type: "unread.changed", roomId, data: { roomId }, audiencePerson: personKeyString(room.asker) });
870
+ return send(res, 200, { ok: true });
871
+ }
475
872
  if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/buttons$/))) {
476
873
  if (method !== "POST")
477
874
  throw new HttpError(405, "method");
@@ -481,18 +878,43 @@ export function createHubHttp(deps, sql) {
481
878
  }
482
879
  if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/messages$/))) {
483
880
  const roomId = uuid(r[1]);
881
+ if (groupRooms.has(roomId)) {
882
+ if (method === "GET") {
883
+ signedIn();
884
+ return send(res, 200, await guard(() => groupRooms.messages(ctx, roomId, query.get("before"), int(query.get("limit") ?? "50"))));
885
+ }
886
+ if (method === "POST") {
887
+ csrf();
888
+ const b = await body();
889
+ return send(res, 200, await guard(() => groupRooms.post(ctx, roomId, b)));
890
+ }
891
+ throw new HttpError(405, "method");
892
+ }
484
893
  if (method === "GET") {
485
894
  const s = signedIn();
486
895
  // #3226 B + G: the room comes with its entries, fresh each poll — its view (state, grant's end, what its link
487
896
  // negotiated) and its quota projection (G; absent when hidden or not shared).
488
- const { entries, room: view, grantProof } = await guard(() => rooms.readPage(ctx, roomId, int(query.get("after") ?? "0"), s.sessionId));
489
- return send(res, 200, { entries, room: { ...view, ...quota.roomProjection(view, grantProof) } });
897
+ 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") }));
898
+ let messages = directMessages(view, entries, s.displayName);
899
+ const cursor = query.get("before"), index = cursor ? messages.findIndex(m => m.id === cursor) : -1;
900
+ if (index >= 0)
901
+ messages = messages.slice(0, index);
902
+ const limit = int(query.get("limit") ?? "50"), overflow = !query.has("after") && messages.length > limit;
903
+ if (overflow)
904
+ messages = messages.slice(-limit);
905
+ return send(res, 200, { entries, room: { ...view, ...quota.roomProjection(view, grantProof) }, messages, more: (more ?? false) || overflow });
490
906
  }
491
907
  if (method === "POST") {
492
908
  csrf();
493
909
  const b = await body();
494
910
  const files = b.files === undefined ? [] : Array.isArray(b.files) && b.files.length <= 10 ? b.files.map(uuid) : (() => { throw new HubProtocolError("invalid"); })();
495
- return send(res, 200, { receipt: await guard(() => rooms.ask(ctx, roomId, uuid(b.idempotencyKey), typeof b.text === "string" ? b.text : "", files)) });
911
+ if (b.mentions !== undefined && (!Array.isArray(b.mentions) || b.mentions.length))
912
+ throw new HubProtocolError("invalid");
913
+ const receipt = await guard(() => rooms.ask(ctx, roomId, uuid(b.idempotencyKey), typeof b.text === "string" ? b.text : "", files));
914
+ const room = await guard(() => rooms.view(ctx, roomId));
915
+ groupRooms.publish({ type: "message.added", roomId, data: { roomId, messageId: receipt.messageId }, audiencePerson: personKeyString(room.asker) });
916
+ return send(res, 200, { id: receipt.messageId, roomId, at: receipt.at, author: { kind: "person", id: personKeyString(room.asker), name: signedIn().displayName },
917
+ text: typeof b.text === "string" ? b.text : "", mentions: [], idempotencyKey: b.idempotencyKey, receipt });
496
918
  }
497
919
  throw new HttpError(405, "method");
498
920
  }
@@ -662,7 +1084,9 @@ export function createHubHttp(deps, sql) {
662
1084
  void req;
663
1085
  throw new HttpError(404, "not-found");
664
1086
  }
665
- function fail(res, e) {
1087
+ function fail(res, e, method, path) {
1088
+ if (e instanceof HubRoomRefusal)
1089
+ return send(res, e.status, { code: e.code, ...e.details });
666
1090
  if (e instanceof HubEnrolmentCodeLimit)
667
1091
  return send(res, 429, { code: "backpressure", reason: e.reason });
668
1092
  if (e instanceof CompanyJoinCodeRefusal)
@@ -677,10 +1101,19 @@ export function createHubHttp(deps, sql) {
677
1101
  return send(res, e.status, { code: e.code });
678
1102
  if (e instanceof HubSharingPaused)
679
1103
  return send(res, 409, { code: "sharing-paused" });
1104
+ if (e instanceof HubMemberAddressError)
1105
+ return send(res, STATUS[e.code] ?? 503, { code: e.code });
680
1106
  if (e instanceof HubAttachmentRefused)
681
1107
  return send(res, 415, { code: e.refusal });
682
1108
  if (e instanceof HubProtocolError) {
683
1109
  const status = STATUS[e.code] ?? 400;
1110
+ if (status === 503) {
1111
+ try {
1112
+ deps.log?.("warn", "Hub HTTP unavailable", { method, path, code: e.code,
1113
+ cause: e.cause instanceof HubGroupPolicyError ? e.cause.message : e.code });
1114
+ }
1115
+ catch { /* diagnostics cannot replace the response */ }
1116
+ }
684
1117
  return send(res, status, { code: e.code }, status === 429 ? { "Retry-After": "10" } : {});
685
1118
  }
686
1119
  send(res, 500, { code: "unavailable" });
@@ -697,7 +1130,7 @@ export function createHubHttp(deps, sql) {
697
1130
  if (deps.companyJoin && live() && handleCompanyJoin(req, res, deps.companyJoin))
698
1131
  return true;
699
1132
  if (path.startsWith("/hub/v1/")) {
700
- void api(req, res, path, url.searchParams).catch((e) => fail(res, e));
1133
+ void api(req, res, path, url.searchParams).catch((e) => fail(res, e, method, path));
701
1134
  return true;
702
1135
  }
703
1136
  if (method !== "GET" && method !== "HEAD")
@@ -738,12 +1171,27 @@ export function createHubHttp(deps, sql) {
738
1171
  throw new HubProtocolError("stale");
739
1172
  rooms.noteLink(link);
740
1173
  quota.noteLink(link);
1174
+ groupRooms.agents.noteLink(link);
741
1175
  deps.pairingNotices?.noteLink(link);
742
1176
  const reply = { v: 1, requestId: frame.requestId, linkEpoch: link.linkEpoch };
743
1177
  switch (frame.type) {
1178
+ case "room.answer":
1179
+ try {
1180
+ return { ...reply, type: "room.answer-ack", payload: await groupRooms.agents.answer(frame.payload, link) };
1181
+ }
1182
+ catch (error) {
1183
+ // No ACK means the Fleet retains its frozen answer. A pause or transient read must not break its member link.
1184
+ if (error instanceof HubProtocolError && ["unavailable", "backpressure", "revoked", "not-found", "stale"].includes(error.code))
1185
+ return;
1186
+ throw error;
1187
+ }
1188
+ case "agent.state":
1189
+ groupRooms.agents.state(frame.payload, link);
1190
+ return;
744
1191
  case "exposure.snapshot":
745
1192
  await catalog.receiveSnapshot(frame.payload, link, frame.requestId);
746
1193
  quota.prune();
1194
+ groupRooms.agents.publicationChanged(link.fleetId);
747
1195
  return;
748
1196
  case "exposure.quota":
749
1197
  quota.receive(frame.payload, link);
@@ -753,8 +1201,16 @@ export function createHubHttp(deps, sql) {
753
1201
  throw new HubProtocolError("incompatible");
754
1202
  deps.pairingNotices.acknowledgeFleet(link, frame.payload.id);
755
1203
  return;
756
- case "receipt": return { ...reply, type: "receipt", payload: rooms.receipt(frame.payload, link) };
757
- case "answer": return { ...reply, type: "receipt", payload: await rooms.answer(frame.payload, link) };
1204
+ case "receipt": {
1205
+ const payload = rooms.receipt(frame.payload, link);
1206
+ directChanged(payload.messageId, false);
1207
+ return { ...reply, type: "receipt", payload };
1208
+ }
1209
+ case "answer": {
1210
+ const payload = await rooms.answer(frame.payload, link);
1211
+ directChanged(payload.messageId, true);
1212
+ return { ...reply, type: "receipt", payload };
1213
+ }
758
1214
  case "authorize.request": return { ...reply, type: "authorize.result", payload: await policy.authorize(frame.payload, link) };
759
1215
  case "reconcile": {
760
1216
  const page = rooms.reconcile(frame.payload, link);
@@ -768,27 +1224,38 @@ export function createHubHttp(deps, sql) {
768
1224
  case "error": return;
769
1225
  }
770
1226
  }
1227
+ function directChanged(messageId, answer) {
1228
+ const row = core.atomic(db => db.prepare("SELECT room_id,asker FROM hub_messages WHERE id=?").get(messageId));
1229
+ if (!row)
1230
+ return;
1231
+ 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 });
1232
+ groupRooms.publish({ type: "unread.changed", roomId: row.room_id, data: { roomId: row.room_id }, audiencePerson: row.asker });
1233
+ }
771
1234
  function flushSoon(link, attempt = 0) {
772
1235
  const t = setTimeout(() => {
773
1236
  if (!live() || !link.current())
774
1237
  return;
775
1238
  void rooms.flush(link.fleetId).then((sent) => { if (!sent && attempt < 5)
776
1239
  flushSoon(link, attempt + 1); }, () => { });
1240
+ groupRooms.agents.wake();
777
1241
  void deps.pairingNotices?.flushFleet(link).catch(() => { });
778
1242
  }, attempt === 0 ? 0 : 100 * attempt);
779
1243
  t.unref?.();
780
1244
  }
781
1245
  rooms.buttons.start();
1246
+ groupRooms.agents.wake();
1247
+ groupRooms.assistant.start();
782
1248
  return {
783
1249
  directorySessions: Object.freeze({
784
1250
  recentAuthentication: actor => sessions.recentAuthentication(actor),
785
1251
  prepareDirectoryRotation: (token, actor) => sessions.prepareDirectoryRotation(token, actor),
786
1252
  completeDirectoryRotation: (rotation, operationId) => sessions.completeDirectoryRotation(rotation, operationId),
787
1253
  }),
788
- handle, receive, features: Object.freeze([...(deps.refreshAuthorization ? ["sharing-pause-v1"] : []), ...(deps.groupHttp ? [GROUP_POLICY_FEATURE, ...(deps.pairingNotices ? ["quick-pairing-v1"] : [])] : []), ...(grantSubjectsOffered() ? ["grant-subjects-v1"] : []),
789
- ...(deps.directoryNotices ? ["directory-security-notices-v1"] : []), ...(deps.directorySettings ? [HUB_DIRECTORY_SETTINGS_FEATURE, HUB_DIRECTORY_CA_FEATURE, HUB_DIRECTORY_EDITOR_FEATURE] : [])]),
1254
+ handle, receive, memberClosed: fleetId => { if (live())
1255
+ groupRooms.agents.disconnected(fleetId); }, features: Object.freeze(["rooms-v1", "room-ask-v1", ...(teams ? ["teams-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"] : []),
1256
+ ...(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] : [])]),
790
1257
  async close() { closed = true; grantSearch.close(); for (const end of streams)
791
- end(); await rooms.buttons.close(); rooms.forget(); quota.close(); },
1258
+ end(); await groupRooms.close(); await rooms.buttons.close(); rooms.forget(); quota.close(); },
792
1259
  };
793
1260
  }
794
1261
  //# sourceMappingURL=compose.js.map