@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
@@ -100,6 +100,27 @@ export function hubClient() {
100
100
  export function setHubClient(next) { client = next; }
101
101
 
102
102
  /** UX checks only (the server parses and canonicalizes): an https:// origin, and a code of the shape people type. */
103
+ /** The session feature a Hub with rooms (seam 1) lists. */
104
+ export const ROOMS_FEATURE = "rooms-v1";
105
+ /** The live stream's events (seam 1). */
106
+ /**
107
+ * The live stream's events (seam 1, as agreed with Lumen): message.added / message.updated { roomId, message, parent?:
108
+ * { id, ask } } (a reply that changes its question's counts carries them), presence.changed { roomId, memberId, presence,
109
+ * presenceNote? }, member.changed { roomId } (joined, left, role: read the room again), room.changed { roomId, room } or
110
+ * { roomId, removed: true } (no longer a member: drop it), unread.changed { roomId, unread }, invitation.changed {}.
111
+ */
112
+ export const ROOM_EVENTS = Object.freeze(["message.added", "message.updated", "presence.changed", "member.changed", "room.changed", "unread.changed", "invitation.changed"]);
113
+ /**
114
+ * Today's room (one asker, one agent; GET /hub/v1/rooms before ROOMS_FEATURE) in the rooms list's shape: a direct room
115
+ * named after its agent, the old item kept under `legacy` (its state, its agent's state, its grant's end, its features),
116
+ * and `limited: true`: that Hub has no members, presence or unread, so the page leaves those controls out.
117
+ */
118
+ export function legacyRoom(item) {
119
+ if (!item || typeof item !== "object" || typeof item.id !== "string") return null;
120
+ return { id: item.id, kind: "direct", name: String(item.exposureName || ""), people: 1, agents: 1, online: null, unread: 0,
121
+ lastAt: Number.isFinite(item.lastAt) ? item.lastAt : 0, lastText: "", lastAuthor: "",
122
+ agent: { exposureId: String(item.exposureId || ""), owner: { name: String(item.ownerName || "") }, presence: null }, limited: true, legacy: item };
123
+ }
103
124
  export const ADDRESS_HINT = /^https:\/\/[^\s/?#@]+\/?$/i;
104
125
  export const CODE_HINT = /^[A-Za-z0-9][A-Za-z0-9 -]{4,62}[A-Za-z0-9]$/;
105
126
  /** The part of a fingerprint people compare: its first 32 hex digits (128 bits) in 8 groups of 4. */
@@ -204,39 +225,65 @@ export function createStubClient({ now = () => Date.now(), agents = () => [] } =
204
225
  * session cookie (HttpOnly; this page never sees it) and the CSRF token /hub/v1/session gives a same-origin read.
205
226
  * Every answer is { ok: true, ...body } or { ok: false, status, code }; a 401 also tells the page the session ended.
206
227
  */
207
- export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
208
- let csrf = null, codeNotices = false, generation = 0;
209
- const ended = new Set(), pendingReads = new Map(), waits = new Set();
228
+ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a), readTimeoutMs = 120_000 } = {}) {
229
+ // The factory override is for owned transports/rehearsals; the page uses the finite default.
230
+ const readBudget = Number.isInteger(readTimeoutMs) && readTimeoutMs > 0 && readTimeoutMs <= 300_000 ? readTimeoutMs : 120_000;
231
+ let csrf = null, codeNotices = false, roomsLive = false, generation = 0;
232
+ const ended = new Set(), pendingReads = new Map(), waits = new Set(), readControllers = new Set();
210
233
  let readTail = Promise.resolve();
211
234
  const retired = () => ({ ok: false, status: 401, code: "unauthenticated" });
212
- const retireReads = () => { generation++; pendingReads.clear(); for (const wake of waits) wake(); };
213
- const pause = ms => new Promise(resolve => {
214
- const wake = () => { clearTimeout(timer); waits.delete(wake); resolve(); };
215
- const timer = setTimeout(wake, ms); waits.add(wake);
235
+ const unreachable = () => ({ ok: false, status: 0, code: "unreachable" });
236
+ const retireReads = () => {
237
+ generation++; pendingReads.clear();
238
+ for (const controller of readControllers) controller.abort();
239
+ for (const wake of waits) wake();
240
+ };
241
+ const pause = (ms, signal) => new Promise(resolve => {
242
+ const wake = () => { clearTimeout(timer); waits.delete(wake); signal.removeEventListener("abort", wake); resolve(); };
243
+ const timer = setTimeout(wake, ms); waits.add(wake); signal.addEventListener("abort", wake, { once: true });
244
+ if (signal.aborted) wake();
216
245
  });
217
- // Private reads share fresh directory eligibility admission. One read per client, with only simultaneous identical
218
- // reads shared (never an allow-cache). Other tabs/writes can still fill the server pool, so back off at most 3 times.
246
+ // Private reads share fresh directory eligibility admission. Only simultaneous signal-less GETs coalesce;
247
+ // a caller-owned signal stays independent. No successful-response cache and no automatic write replay.
219
248
  function call(method, path, body, signal) {
220
249
  if (method !== "GET") { pendingReads.clear(); return request(method, path, body, signal); }
221
250
  if (!signal && pendingReads.has(path)) return pendingReads.get(path);
222
- const mine = generation;
251
+ const mine = generation, controller = new AbortController();
252
+ let timedOut = false;
253
+ readControllers.add(controller);
254
+ const aborted = () => mine !== generation ? retired() : { ...unreachable(), ...(timedOut ? { timedOut: true } : {}) };
255
+ let stop;
256
+ const stopped = new Promise(resolve => { stop = () => resolve(aborted()); controller.signal.addEventListener("abort", stop, { once: true }); });
257
+ const cancel = () => controller.abort();
258
+ signal?.addEventListener("abort", cancel, { once: true });
259
+ if (signal?.aborted) cancel();
223
260
  const run = async () => {
224
261
  for (let attempt = 0; ; attempt++) {
225
262
  if (mine !== generation) return retired();
226
- if (signal?.aborted) return { ok: false, status: 0, code: "unreachable" };
227
- const result = await request(method, path, body, signal);
263
+ if (controller.signal.aborted) return aborted();
264
+ // Budget begins when this attempt is admitted, and covers BOTH headers and JSON body. Abort the actual
265
+ // transport before settling the timeout; the race also fences late/non-cooperative transport completions.
266
+ const timer = setTimeout(() => { timedOut = true; cancel(); }, readBudget);
267
+ let result;
268
+ try { result = await Promise.race([request(method, path, body, controller.signal), stopped]); }
269
+ finally { clearTimeout(timer); }
228
270
  if (mine !== generation) return retired();
271
+ if (controller.signal.aborted) return aborted();
229
272
  if (result.ok || result.status !== 429 || result.code !== "backpressure" || attempt === 3) return result;
230
- await pause(Math.min(2000, Math.max(500 * 2 ** attempt, Number(result.retryAfter) * 1000 || 0)));
273
+ await pause(Math.min(2000, Math.max(500 * 2 ** attempt, Number(result.retryAfter) * 1000 || 0)), controller.signal);
231
274
  }
232
275
  };
233
- const result = readTail.then(run, run);
234
- readTail = result.then(() => {}, () => {});
235
- if (!signal) {
236
- pendingReads.set(path, result);
237
- const forget = () => { if (pendingReads.get(path) === result) pendingReads.delete(path); };
238
- void result.then(forget, forget);
239
- }
276
+ const queued = readTail.then(run, run);
277
+ // A queued caller can cancel promptly, but does not let later work jump its still-running predecessor.
278
+ readTail = queued.then(() => {}, () => {});
279
+ const result = Promise.race([queued, stopped]);
280
+ const forget = () => {
281
+ readControllers.delete(controller); controller.signal.removeEventListener("abort", stop);
282
+ signal?.removeEventListener("abort", cancel);
283
+ if (pendingReads.get(path) === result) pendingReads.delete(path);
284
+ };
285
+ void result.then(forget, forget);
286
+ if (!signal) pendingReads.set(path, result);
240
287
  return result;
241
288
  }
242
289
  async function request(method, path, body, signal) {
@@ -247,24 +294,81 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
247
294
  let r;
248
295
  try { r = await fetchImpl(path, { method, headers, credentials: "same-origin", cache: "no-store", ...(signal ? { signal } : {}), body: body === undefined ? undefined : JSON.stringify(body) }); }
249
296
  catch { return { ok: false, status: 0, code: "unreachable" }; }
297
+ if (method === "GET" && signal?.aborted) return unreachable();
250
298
  let json = null;
251
299
  try { json = await r.json(); } catch { json = null; }
252
- if (r.status === 401 && mine === generation) { retireReads(); csrf = null; codeNotices = false; for (const fn of ended) { try { fn(); } catch { /* a listener's own failure */ } } }
300
+ if (method === "GET" && signal?.aborted) return unreachable();
301
+ if (r.status === 401 && mine === generation) { retireReads(); csrf = null; codeNotices = false; roomsLive = false; for (const fn of ended) { try { fn(); } catch { /* a listener's own failure */ } } }
253
302
  if (!r.ok) return { ok: false, status: r.status, code: (json && typeof json.code === "string" && json.code) || "failed", retryAfter: Number(r.headers.get("Retry-After")) || 0,
254
303
  ...(method === "POST" && path === "/hub/v1/admin/enrolment-codes" && r.status === 429 && json?.code === "backpressure"
255
- && ["live-code-limit", "hourly-code-limit"].includes(json.reason) ? { reason: json.reason } : {}) };
304
+ && ["live-code-limit", "hourly-code-limit"].includes(json.reason) ? { reason: json.reason } : {}), ...roomRefusal(json) };
256
305
  return { ok: true, ...(json && typeof json === "object" ? json : {}) };
257
306
  }
258
307
  const id = (v) => encodeURIComponent(String(v));
308
+ // Track U2: a refused room write says what the person is told — 409 people-limit the room's would-be head count (the
309
+ // deduplicated union, the creator and current members included) and the limit; 503 group-unavailable which group.
310
+ const roomRefusal = (json) => json?.code === "people-limit" && Number.isSafeInteger(json.people)
311
+ ? { people: json.people, limit: Number.isSafeInteger(json.limit) ? json.limit : 100 }
312
+ : json?.code === "group-unavailable" && typeof json.group === "string" ? { group: json.group } : {};
313
+ // One stream per tab (#1580): every live subscription shares one EventSource. A Hub with rooms carries the notices on
314
+ // its rooms stream too (`notices` = the notice version); before that the notices have their own. Listeners are kept
315
+ // per event name; the stream closes with its last listener, and a refused (CLOSED) stream tells every subscriber once.
316
+ // One dispatcher per event name per source, added when the name first listens and kept while that source lives (with no
317
+ // listeners it reads an empty set), so a name that listens again while the stream stays open is heard once (Fable on #3848).
318
+ const stream = { source: null, url: "", listeners: new Map(), dispatchers: new Map(), closers: new Set() };
319
+ const attach = (name) => { if (stream.source && !stream.dispatchers.has(name)) { const fn = dispatch(name); stream.dispatchers.set(name, fn); stream.source.addEventListener(name, fn); } };
320
+ const dispatch = (name) => (event) => {
321
+ let data; try { data = JSON.parse(event.data); } catch { return; }
322
+ for (const fn of [...(stream.listeners.get(name) || [])]) { try { fn(data); } catch { /* a listener's own failure */ } }
323
+ };
324
+ function listen(url, handlers, onClosed) {
325
+ if (typeof EventSource === "undefined") return () => {};
326
+ if (stream.source && stream.url !== url) { stream.source.close(); stream.source = null; stream.dispatchers.clear(); } // the session changed what it may hear
327
+ const mine = [];
328
+ for (const [name, fn] of Object.entries(handlers)) {
329
+ if (typeof fn !== "function") continue;
330
+ if (!stream.listeners.has(name)) stream.listeners.set(name, new Set());
331
+ attach(name);
332
+ stream.listeners.get(name).add(fn); mine.push([name, fn]);
333
+ }
334
+ stream.closers.add(onClosed);
335
+ if (!stream.source) {
336
+ const source = new EventSource(url); stream.source = source; stream.url = url; stream.dispatchers.clear();
337
+ for (const name of stream.listeners.keys()) attach(name);
338
+ source.addEventListener("error", () => {
339
+ // A refused handshake is CLOSED, unlike a transient disconnect that EventSource itself reconnects.
340
+ if (stream.source !== source || source.readyState !== 2) return;
341
+ source.close(); stream.source = null; stream.listeners.clear(); stream.dispatchers.clear();
342
+ const closers = [...stream.closers]; stream.closers.clear();
343
+ for (const fn of closers) { try { fn(); } catch { /* a subscriber's own failure */ } }
344
+ });
345
+ }
346
+ let live = true;
347
+ return () => {
348
+ if (!live) return; live = false;
349
+ for (const [name, fn] of mine) { const set = stream.listeners.get(name); set?.delete(fn); if (set && !set.size) stream.listeners.delete(name); }
350
+ stream.closers.delete(onClosed);
351
+ if (!stream.listeners.size && stream.source) { stream.source.close(); stream.source = null; stream.dispatchers.clear(); }
352
+ };
353
+ }
354
+ const noticeVersion = (version) => version === 3 && codeNotices ? 3 : 2;
355
+ const streamUrl = (version) => roomsLive ? `/hub/v1/rooms/events?notices=${noticeVersion(version)}` : `/hub/v1/notices/events?v=${noticeVersion(version)}`;
259
356
  return {
260
357
  stub: false, web: true,
261
358
  /** Hear the session end (a 401 anywhere). @returns {() => void} */
262
359
  onSignedOut(fn) { ended.add(fn); return () => ended.delete(fn); },
263
- async session() { const r = await call("GET", "/hub/v1/session"); if (r.ok) { csrf = r.signedIn ? r.csrf || null : null; codeNotices = r.signedIn === true && r.features?.includes("enrolment-code-v1") === true; } return r; },
264
- async signIn(login, password) { retireReads(); const r = await call("POST", "/hub/v1/session", { login, password }); if (r.ok) { csrf = r.csrf || null; codeNotices = r.features?.includes("enrolment-code-v1") === true; } return r; },
265
- async signOut() { retireReads(); const r = await call("DELETE", "/hub/v1/session"); csrf = null; codeNotices = false; return r; },
360
+ async session() { const r = await call("GET", "/hub/v1/session"); if (r.ok) { csrf = r.signedIn ? r.csrf || null : null; codeNotices = r.signedIn === true && r.features?.includes("enrolment-code-v1") === true; roomsLive = r.signedIn === true && r.features?.includes(ROOMS_FEATURE) === true; } return r; },
361
+ async signIn(login, password) { retireReads(); const r = await call("POST", "/hub/v1/session", { login, password }); if (r.ok) { csrf = r.csrf || null; codeNotices = r.features?.includes("enrolment-code-v1") === true; roomsLive = r.features?.includes(ROOMS_FEATURE) === true; } return r; },
362
+ async signOut() { retireReads(); const r = await call("DELETE", "/hub/v1/session"); csrf = null; codeNotices = false; roomsLive = false; return r; },
266
363
  catalog() { return call("GET", "/hub/v1/exposures"); },
364
+ sharingPauseV1: true,
365
+ sharing(exposureId, revision, sharingEpoch, paused) { return call("POST", `/hub/v1/exposures/${id(exposureId)}/sharing`, { revision, sharingEpoch, paused }); },
267
366
  grant(input) { return call("POST", "/hub/v1/grants", input); },
367
+ grantSubjectsV1: true,
368
+ async searchGrantSubjects(exposureId, exposureRevision, kind, q, signal) {
369
+ const out = await call("POST", `/hub/v1/exposures/${id(exposureId)}/grant-subjects/search`, { exposureRevision, kind, q }, signal);
370
+ return signal?.aborted ? { ok: false, status: 0, code: "unreachable" } : out;
371
+ },
268
372
  revokeGrant(grantId, revision) { return call("DELETE", `/hub/v1/grants/${id(grantId)}?revision=${id(revision)}`); },
269
373
  activity(exposureId) { return call("GET", `/hub/v1/exposures/${id(exposureId)}/activity`); },
270
374
  freeze(exposureId, revision, admin = false) { return call("POST", `/hub/v1/${admin ? "admin/" : ""}exposures/${id(exposureId)}/freeze`, { revision }); },
@@ -294,6 +398,94 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
294
398
  },
295
399
  read(roomId, after = 0) { return call("GET", `/hub/v1/rooms/${id(roomId)}/messages?after=${id(after)}`); },
296
400
  chooseButtons(roomId, input) { return call("POST", `/hub/v1/rooms/${id(roomId)}/buttons`, input); },
401
+ // Hub rooms (docs/design/hub-rooms-split.md, seams 1, 3 and 5). The Hub speaks them once its session lists
402
+ // ROOMS_FEATURE; before that it has today's rooms (one asker, one agent), which roomList() still answers in the same
403
+ // shape (kind "direct", the old item under `legacy`), and whose messages stay with hub-chat-store.js.
404
+ roomsV1: true,
405
+ /** The Hub answers the rooms calls (seam 1) — otherwise only roomList() is meaningful. */
406
+ roomsLive() { return roomsLive; },
407
+ /**
408
+ * → { ok, rooms: [{ id, kind: "direct" | "group", name, people, agents, online, unread, lastAt, lastText, lastAuthor }] }.
409
+ * `?v=2` (Ridge, #3858): the combined list; GET /hub/v1/rooms itself stays direct-only for older cached tabs, and a
410
+ * server without rooms ignores the parameter (its answer is then normalised here).
411
+ */
412
+ async roomList() {
413
+ const r = await call("GET", "/hub/v1/rooms?v=2");
414
+ if (!r.ok || roomsLive) return r;
415
+ return { ...r, rooms: (Array.isArray(r.rooms) ? r.rooms : []).map(legacyRoom).filter(Boolean) };
416
+ },
417
+ /** → { ok, room, me: { role }, members: [Member], settings: { allMention, historyForNew } } */
418
+ room(roomId) { return call("GET", `/hub/v1/rooms/${id(roomId)}`); },
419
+ /** A group room: { name, people: [personId], teams: [teamId], groups: [groupId], agents: [exposureId], assistant }. */
420
+ createRoom(input) { return call("POST", "/hub/v1/rooms", input); },
421
+ /** { name?, allMention?, historyForNew?, assistant?, archived? } */
422
+ updateRoom(roomId, patch) { return call("PATCH", `/hub/v1/rooms/${id(roomId)}`, patch); },
423
+ /** One member: { kind: "person" | "team" | "group" | "agent" | "assistant", id? } (the assistant has no id). */
424
+ addRoomMember(roomId, member) { return call("POST", `/hub/v1/rooms/${id(roomId)}/members`, member); },
425
+ removeRoomMember(roomId, memberId) { return call("DELETE", `/hub/v1/rooms/${id(roomId)}/members/${id(memberId)}`); },
426
+ /** A page of Message, newest last: the latest `limit`, or those before the message `before`. */
427
+ roomMessages(roomId, { before, limit } = {}) {
428
+ const q = new URLSearchParams();
429
+ if (before) q.set("before", String(before));
430
+ if (Number.isSafeInteger(limit) && limit > 0) q.set("limit", String(limit));
431
+ const query = q.toString();
432
+ return call("GET", `/hub/v1/rooms/${id(roomId)}/messages${query ? `?${query}` : ""}`);
433
+ },
434
+ /** { text, mentions: ["all" | "assistant" | exposureId], replyTo?, files?: [fileId], idempotencyKey } → the stored Message. */
435
+ sendRoomMessage(roomId, { text, mentions = [], replyTo, files, idempotencyKey }) {
436
+ return call("POST", `/hub/v1/rooms/${id(roomId)}/messages`, { text, mentions, idempotencyKey,
437
+ ...(replyTo ? { replyTo } : {}), ...(Array.isArray(files) && files.length ? { files } : {}) });
438
+ },
439
+ markRoomRead(roomId, upTo) { return call("POST", `/hub/v1/rooms/${id(roomId)}/read`, { upTo }); },
440
+ /**
441
+ * The one live stream of everything this person may see (seam 1): `handlers[name](data)` for each of ROOM_EVENTS,
442
+ * on the tab's one stream (which also carries the notices). A refused stream (CLOSED) calls onClosed once; a
443
+ * transient drop reconnects by itself. → unsubscribe.
444
+ */
445
+ subscribeRooms(handlers = {}, onClosed = () => {}) {
446
+ if (!roomsLive) return () => {};
447
+ const mine = {};
448
+ for (const name of ROOM_EVENTS) if (typeof handlers[name] === "function") mine[name] = (data) => { if (data && typeof data === "object") handlers[name](data); };
449
+ return listen(streamUrl(codeNotices ? 3 : 2), mine, onClosed);
450
+ },
451
+ // Seam 3: agents enter a room by their owner's consent.
452
+ inviteToRoom(roomId, input) { return call("POST", `/hub/v1/rooms/${id(roomId)}/invitations`, input); },
453
+ invitations() { return call("GET", "/hub/v1/invitations"); },
454
+ acceptInvitation(invitationId) { return call("POST", `/hub/v1/invitations/${id(invitationId)}/accept`, {}); },
455
+ declineInvitation(invitationId) { return call("POST", `/hub/v1/invitations/${id(invitationId)}/decline`, {}); },
456
+ // Seam 5: teams, who may open rooms, and the administrator's list of rooms (names and members, no content).
457
+ teams() { return call("GET", "/hub/v1/teams"); },
458
+ team(teamId) { return call("GET", `/hub/v1/teams/${id(teamId)}`); },
459
+ createTeam(input) { return call("POST", "/hub/v1/teams", input); },
460
+ updateTeam(teamId, patch) { return call("PATCH", `/hub/v1/teams/${id(teamId)}`, patch); },
461
+ deleteTeam(teamId) { return call("DELETE", `/hub/v1/teams/${id(teamId)}`); },
462
+ roomCreators() { return call("GET", "/hub/v1/admin/rooms/creators"); },
463
+ saveRoomCreators(input) { return call("PUT", "/hub/v1/admin/rooms/creators", input); },
464
+ adminRooms() { return call("GET", "/hub/v1/admin/rooms"); },
465
+ // Track U2 (dev-claude2): pickers, roles, invitations, leave, the agent's rooms, admin rooms.
466
+ // Leaving is removeRoomMember(roomId, <my id>) (409 last-manager); `me.assistant` comes with roomList()'s answer.
467
+ /** The new-room and add-member pickers → { ok, candidates: [{ kind: "person" | "team" | "group" | "agent", id, name, people?, owner?: { name }, mine? }] }. */
468
+ roomCandidates(q, kind, signal) {
469
+ const s = new URLSearchParams({ q: String(q ?? "") });
470
+ if (kind) s.set("kind", kind);
471
+ return call("GET", `/hub/v1/rooms/candidates?${s}`, undefined, signal);
472
+ },
473
+ /**
474
+ * A chosen AD group's label and head count → { ok, kind: "group", id, name, people } (its direct members now, nested
475
+ * groups not followed; creating the room or adding the group reads the list again). 503 group-unavailable when the
476
+ * directory cannot read the whole list.
477
+ */
478
+ roomGroup(groupId) { return call("GET", `/hub/v1/rooms/candidates/group/${id(groupId)}`); },
479
+ /** 設為房間管理 / 改為成員. */
480
+ setRoomMemberRole(roomId, memberId, role) { return call("PATCH", `/hub/v1/rooms/${id(roomId)}/members/${id(memberId)}`, { role }); },
481
+ /** A room manager withdraws a pending (or clears an expired) invitation; 重新邀請 is a new inviteToRoom(). */
482
+ cancelRoomInvitation(roomId, invitationId) { return call("DELETE", `/hub/v1/rooms/${id(roomId)}/invitations/${id(invitationId)}`); },
483
+ /** The rooms one of my shared agents is in → { ok, rooms: [{ id, name, people, memberId }] }; 退出這個房間 is removeRoomMember(id, memberId). */
484
+ agentRooms(exposureId) { return call("GET", `/hub/v1/exposures/${id(exposureId)}/rooms`); },
485
+ /** 管理 → 房間: 加入自己成為房間管理 (the room gets a system line). */
486
+ joinRoomAsAdmin(roomId) { return call("POST", `/hub/v1/admin/rooms/${id(roomId)}/join`, {}); },
487
+ /** 管理 → 房間: 封存. */
488
+ archiveRoomAsAdmin(roomId, archived = true) { return call("PATCH", `/hub/v1/admin/rooms/${id(roomId)}`, { archived }); },
297
489
  pairings() { return call("GET", "/hub/v1/pairings"); },
298
490
  quickPairingV1: true,
299
491
  createQuickPairing(label) { return call("POST", "/hub/v1/quick-pairing", { label }); },
@@ -314,14 +506,7 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
314
506
  pairingNoticeSnapshotV1: typeof EventSource !== "undefined",
315
507
  acknowledgePairingNotice(noticeId) { return call("POST", `/hub/v1/notices/${id(noticeId)}/ack`); },
316
508
  subscribePairingNotices(fn, onClosed = () => {}, version = 2) {
317
- if (typeof EventSource === "undefined") return () => {};
318
- const events = new EventSource(`/hub/v1/notices/events?v=${version === 3 && codeNotices ? 3 : 2}`); let live = true;
319
- events.addEventListener("notices", (event) => { if (!live) return; try { const value = JSON.parse(event.data); if (Array.isArray(value.notices)) fn(value.notices); } catch { /* bounded server DTO only */ } });
320
- events.addEventListener("error", () => {
321
- // A refused handshake is CLOSED, unlike a transient disconnect that EventSource itself reconnects.
322
- if (live && events.readyState === 2) { live = false; events.close(); onClosed(); }
323
- });
324
- return () => { live = false; events.close(); };
509
+ return listen(streamUrl(version), { notices: (value) => { if (value && Array.isArray(value.notices)) fn(value.notices); } }, onClosed);
325
510
  },
326
511
  confirmPairing(pairingId, fingerprint) { return call("POST", `/hub/v1/pairings/${id(pairingId)}/confirm`, { fingerprint }); },
327
512
  companyJoinSettings() { return call("GET", "/hub/v1/admin/company-join"); },
@@ -367,6 +552,12 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
367
552
  fetchDirectoryCa(input, signal) { return call("POST", "/hub/v1/admin/hub/directory/ca/fetch", input, signal); },
368
553
  /** This client has the group permissions calls (a cached older client does not: the pages then hide them). */
369
554
  groupPolicyV1: true,
555
+ // Track A (Sentinel): the room assistant's admin page.
556
+ assistantAdminV1: true,
557
+ assistantSettings() { return call("GET", "/hub/v1/admin/assistant"); },
558
+ saveAssistantSettings(input) { return call("PUT", "/hub/v1/admin/assistant", input); },
559
+ assistantUsage() { return call("GET", "/hub/v1/admin/assistant/usage"); },
560
+ stopRoomAssistant(roomId) { return call("POST", `/hub/v1/admin/assistant/rooms/${id(roomId)}/stop`); },
370
561
  };
371
562
  }
372
563
 
@@ -78,7 +78,7 @@ export function HubEnrolmentCode({ client = hubClient(), enabled = false, host =
78
78
  if (!current(mine) || writing.current) return;
79
79
  setLoading(false);
80
80
  if (r.ok && Array.isArray(r.codes)) { setData({ client, codes: r.codes }); setError(null); return true; }
81
- else { if (r.code !== "backpressure") setData(null); setError(errorText(r, "loadFailed")); }
81
+ else { if (r.code !== "backpressure" && r.timedOut !== true) setData(null); setError(errorText(r, "loadFailed")); }
82
82
  };
83
83
  refresh.current = read;
84
84
  useEffect(() => {
@@ -0,0 +1,100 @@
1
+ /** Exact owner/exposure suggestions; the server re-resolves the selected immutable identity at commit. */
2
+ import { html, useEffect, useMemo, useRef, useState } from "/assets/app-html.js";
3
+ import { register, t } from "/assets/app-i18n.js";
4
+ import { Dialog } from "/assets/ui-dialog.js";
5
+ import { GroupSearch } from "./hub-group-search.js";
6
+ import { hubClient } from "./hub-client.js";
7
+ register("hubGrantPicker", {
8
+ en: {
9
+ title: "Allow access to {0}", kind: "Allow", person: "A person", group: "An AD security group", findPerson: "Find a person", query: "Name or login", hint: "Type 2 to 64 characters.",
10
+ searching: "Searching…", none: "No matching people. Try more of their name or login.", more: "More people match. Type more of the name.", pick: "Choose {0}", choose: "Choose", change: "Choose someone else",
11
+ failed: "The directory could not be searched just now. Try again.", unsupported: "This directory does not support that search.", limited: "Too many searches. Try again shortly.", retry: "Search again",
12
+ days: "Access lasts", day: "{0} days", expiry: "Choose up to 90 days. Access expires automatically; removing the grant also ends access to its chats.",
13
+ groupHint: "Direct members are checked again for every action. Nested and primary groups are not included. Whoever manages this AD group can change who may ask. Each person has a private chat.",
14
+ save: "Allow", cancel: "Cancel", refused: "The selected person or group changed or is no longer available. Search and choose again.", saveFailed: "Access could not be saved. Check the current agent and try again.",
15
+ },
16
+ "zh-TW": {
17
+ title: "允許向 {0} 提問", kind: "允許對象", person: "個人", group: "AD 安全性群組", findPerson: "尋找同仁", query: "姓名或登入帳號", hint: "請輸入 2 到 64 個字。",
18
+ searching: "搜尋中…", none: "找不到符合的同仁。請多輸入幾個姓名或帳號的字。", more: "還有更多同仁符合,請多輸入幾個字。", pick: "選擇 {0}", choose: "選擇", change: "重新選擇對象",
19
+ failed: "目前無法搜尋目錄,請再試一次。", unsupported: "這個目錄不支援這項搜尋。", limited: "搜尋太多次了,請稍後再試。", retry: "重新搜尋",
20
+ days: "允許多久", day: "{0} 天", expiry: "最長 90 天,到期自動失效;移除授權也會結束其聊天存取權。",
21
+ groupHint: "每次操作都會重新檢查直接成員,不含巢狀或主要群組。能管理這個 AD 群組的人,也能改變誰可以提問。每個人都有自己的私人對話。",
22
+ save: "允許提問", cancel: "取消", refused: "選取的同仁或群組已變更或無法使用,請重新搜尋選擇。", saveFailed: "無法儲存授權,請確認目前的 Agent 後再試。",
23
+ },
24
+ });
25
+ const g = (key, ...args) => t(`hubGrantPicker.${key}`, ...args);
26
+ /** Fresh lazy picker rules must not depend on the shell's retained app.css. */
27
+ export function linkHubGrantPickerCss(doc = typeof document !== "undefined" ? document : null) {
28
+ try {
29
+ if (!doc?.head || doc.querySelector('link[data-hub-grant-picker-css="1"]')) return;
30
+ const link = doc.createElement("link");
31
+ link.setAttribute("rel", "stylesheet"); link.setAttribute("href", "/assets/hub-grant-picker.css"); link.setAttribute("data-hub-grant-picker-css", "1");
32
+ doc.head.appendChild(link);
33
+ } catch { /* The form's existing controls still work if the stylesheet cannot be linked. */ }
34
+ }
35
+ function PeopleSearch({ search, disabled, onPick }) {
36
+ const [query, setQuery] = useState(""), [answer, setAnswer] = useState(null), [busy, setBusy] = useState(false), [retry, setRetry] = useState(0);
37
+ const sequence = useRef(0);
38
+ useEffect(() => {
39
+ const mine = ++sequence.current, q = query.trim(); setAnswer(null);
40
+ if (q.length < 2 || q.length > 64) { setBusy(false); return; }
41
+ setBusy(true); const timer = setTimeout(async () => {
42
+ let out; try { out = await search("person", q); } catch { out = { ok: false }; }
43
+ if (mine !== sequence.current) return;
44
+ setBusy(false); setAnswer(out);
45
+ }, 300);
46
+ return () => { clearTimeout(timer); sequence.current++; };
47
+ }, [query, search, retry]);
48
+ const hits = answer?.ok && Array.isArray(answer.people) ? answer.people.slice(0, 20) : [];
49
+ return html`<div class="hub-group-search">
50
+ <label class="field" for="hubGrantPerson"><span>${g("findPerson")}</span><input id="hubGrantPerson" type="search" autocomplete="off" spellcheck=${false}
51
+ disabled=${disabled} value=${query} placeholder=${g("query")} aria-describedby="hubGrantPersonNote" onInput=${e => setQuery(e.target.value)} /></label>
52
+ <p id="hubGrantPersonNote" class="note" role="status">${busy ? g("searching") : !answer ? g("hint") : answer.ok ? hits.length ? answer.truncated ? g("more") : "" : g("none") : answer.status === 429 ? g("limited") : g("failed")}</p>
53
+ ${answer && !answer.ok && !busy ? html`<button type="button" class="btn btn-sm" disabled=${disabled} onClick=${() => setRetry(n => n + 1)}>${g("retry")}</button>` : null}
54
+ ${hits.length ? html`<ul class="hub-group-hits" role="list">${hits.map(p => html`<li key=${`${p.person?.realm}/${p.person?.objectId}`} class="s-row"><span class="hub-row-text"><strong>${p.displayName || p.login}</strong><small class="note"><code>${p.login}</code></small></span>
55
+ <button type="button" class="btn btn-sm" disabled=${disabled} aria-label=${g("pick", p.displayName || p.login)} onClick=${() => onPick(p)}>${g("choose")}</button></li>`)}</ul>` : null}
56
+ </div>`;
57
+ }
58
+ export function HubGrantPicker({ x, client, act, onClose }) {
59
+ const [kind, setKind] = useState("person"), [selected, setSelected] = useState(null), [days, setDays] = useState(7), [busy, setBusy] = useState(false), [error, setError] = useState(null), [unsupported, setUnsupported] = useState(false);
60
+ const life = useRef(0), writing = useRef(false), controllers = useRef(new Set());
61
+ const search = useMemo(() => async (kind, q) => {
62
+ const controller = new AbortController(); for (const old of controllers.current) old.abort(); controllers.current.add(controller);
63
+ const timer = setTimeout(() => controller.abort(), 10_000);
64
+ try { return await client.searchGrantSubjects(x.id, x.revision, kind, q, controller.signal); }
65
+ finally { clearTimeout(timer); controllers.current.delete(controller); }
66
+ }, [client, x.id, x.revision]);
67
+ const groupClient = useMemo(() => ({ searchGroups: q => search("group", q) }), [search]);
68
+ useEffect(() => {
69
+ linkHubGrantPickerCss();
70
+ const mine = life.current;
71
+ const end = client.onSignedOut?.(() => { if (life.current === mine) { life.current++; onClose(); } });
72
+ return () => { life.current++; end?.(); for (const c of controllers.current) c.abort(); controllers.current.clear(); };
73
+ }, [client, x.id, x.revision]);
74
+ const change = () => { setSelected(null); setError(null); setUnsupported(false); };
75
+ const submit = async event => {
76
+ event?.preventDefault?.(); if (writing.current || !selected || client !== hubClient()) return;
77
+ writing.current = true; setBusy(true); setError(null); const mine = life.current;
78
+ const subject = kind === "group" ? { kind: "group", group: { realm: selected.realm, objectId: selected.objectId }, dn: selected.dn }
79
+ : { kind: "person", person: { ...selected.person } };
80
+ const input = { exposureId: x.id, exposureRevision: x.revision, days, subject, ...(kind === "person" ? { login: selected.login } : {}) };
81
+ try {
82
+ const out = await act(() => client.grant(input), undefined, () => { if (mine === life.current) setError(g("refused")); });
83
+ if (mine === life.current && client === hubClient()) { if (out?.ok) onClose(); else setError(g("refused")); }
84
+ } catch { if (mine === life.current) setError(g("saveFailed")); }
85
+ finally { if (mine === life.current) { writing.current = false; setBusy(false); } }
86
+ };
87
+ return html`<${Dialog} title=${g("title", x.displayName)} onClose=${onClose} actions=${html`<button type="button" class="btn" onClick=${onClose}>${g("cancel")}</button><button type="button" class="btn btn-primary" disabled=${busy || !selected} onClick=${submit}>${g("save")}</button>`}>
88
+ <form class="form hub-grant" data-grant-picker onSubmit=${submit}>
89
+ ${error ? html`<p class="err" role="alert">${error}</p>` : null}
90
+ <label class="field"><span>${g("kind")}</span><select data-grant-kind value=${kind} disabled=${busy} onChange=${e => { change(); setKind(e.target.value); }}><option value="person">${g("person")}</option><option value="group">${g("group")}</option></select></label>
91
+ ${selected ? html`<div class="s-row"><span class="hub-row-text"><strong>${selected.displayName || selected.cn || selected.login}</strong><small class="note"><code>${selected.login || selected.dn}</code></small></span><button type="button" class="btn btn-sm" disabled=${busy} onClick=${change}>${g("change")}</button></div>`
92
+ : kind === "person" ? html`<${PeopleSearch} search=${search} disabled=${busy} onPick=${setSelected} />`
93
+ : html`<${GroupSearch} client=${groupClient} id="hubGrantGroup" disabled=${busy} unknownHint=${g("failed")} onUnsupported=${() => setUnsupported(true)} onPick=${p => setSelected({ ...p, realm: x.owner?.realm || "" })} />`}
94
+ ${unsupported ? html`<p class="err" role="status">${g("unsupported")}</p>` : null}
95
+ ${kind === "group" ? html`<p class="note">${g("groupHint")}</p>` : null}
96
+ <label class="field"><span>${g("days")}</span><select data-grant-days value=${String(days)} disabled=${busy} onChange=${e => setDays(Number(e.target.value))}>${[1, 7, 30, 90].map(d => html`<option value=${String(d)}>${g("day", d)}</option>`)}</select></label>
97
+ <p class="note">${g("expiry")}</p>
98
+ </form>
99
+ </${Dialog}>`;
100
+ }
@@ -47,7 +47,7 @@ export async function searchGroups(client, q) {
47
47
  }
48
48
 
49
49
  /** The search box: 300 ms after typing stops, the newest answer for the text in the box only. */
50
- export function GroupSearch({ client, disabled = false, exclude = [], label, onPick, onUnsupported, id = "hubGroupSearch" } = {}) {
50
+ export function GroupSearch({ client, disabled = false, exclude = [], label, onPick, onUnsupported, unknownHint, id = "hubGroupSearch" } = {}) {
51
51
  const noteId = `${id}Note`;
52
52
  const [q, setQ] = useState(""), [answer, setAnswer] = useState(null), [busy, setBusy] = useState(false);
53
53
  const seq = useRef(0), told = useRef(false), live = useRef(true);
@@ -69,7 +69,7 @@ export function GroupSearch({ client, disabled = false, exclude = [], label, onP
69
69
  const message = busy ? g("searching")
70
70
  : !answer ? (q.trim() && q.trim().length < 2 ? g("hint") : null)
71
71
  : answer.ok ? (hits.length ? (answer.truncated ? g("more") : null) : g("none", answer.q))
72
- : answer.reason === "limited" ? g("limited", answer.retryAfter ?? 60) : answer.reason === "invalid" ? g("invalid") : g("unknown");
72
+ : answer.reason === "limited" ? g("limited", answer.retryAfter ?? 60) : answer.reason === "invalid" ? g("invalid") : unknownHint || g("unknown");
73
73
  return html`<div class="hub-group-search">
74
74
  <label class="field" for=${id}><span>${label || g("label")}</span>
75
75
  <input id=${id} type="search" value=${q} disabled=${disabled} autocomplete="off" spellcheck=${false} placeholder=${g("placeholder")}
@@ -0,0 +1,30 @@
1
+ // Hub rooms, invitations on the owner's side (docs/design/hub-rooms-ux.md section 8): only the words the shared room
2
+ // vocabulary (hub-room-strings.js, namespace hubRoom) does not have. A module of its own, so a tab holding an older
3
+ // dictionary still has every word (upgrade skew).
4
+ import { register, t } from "/assets/app-i18n.js";
5
+
6
+ register("hubInvitations", {
7
+ en: {
8
+ leadOne: "The 1 person in the room can @ it there; everyone in the room sees its answers.",
9
+ gone: "This invitation is no longer open.",
10
+ failed: "That did not go through. Try again.",
11
+ loadFailed: "Invitations could not be loaded.",
12
+ retry: "Try again",
13
+ roomPeople: "{0} · {1} people",
14
+ leaveFailed: "It did not leave the room. Try again.",
15
+ readsRecent: "When @-ed, it reads the room's recent messages.",
16
+ invitations: "Invitations",
17
+ },
18
+ "zh-TW": {
19
+ leadOne: "房間裡的 1 個人可以在那裡 @ 它;它的回答房間裡的人都看得到。",
20
+ gone: "這個邀請已經不在了。",
21
+ failed: "沒有送出,請再試一次。",
22
+ loadFailed: "無法載入邀請。",
23
+ retry: "再試一次",
24
+ roomPeople: "{0} · {1} 人",
25
+ leaveFailed: "沒有退出房間,請再試一次。",
26
+ readsRecent: "被 @ 時,它會讀到房間最近的訊息。",
27
+ invitations: "邀請",
28
+ },
29
+ });
30
+ export const hi = (key, ...args) => t(`hubInvitations.${key}`, ...args);
@@ -0,0 +1,108 @@
1
+ // Hub rooms, invitations on the owner's side (docs/design/hub-rooms-ux.md section 8; seam 3 in hub-rooms-split.md).
2
+ // A room manager invited one of my shared agents; I agree (it joins the room) or decline. Two places show the same list:
3
+ // the Invitations page (the shell's sidebar row 「邀請」 with its count opens it) and the top of My shared agents. The list
4
+ // follows the rooms stream's invitation.changed, so an answer given in another tab, or an invitation that lapsed after
5
+ // 7 days, leaves both places at once.
6
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
7
+ import { hubClient } from "./hub-client.js";
8
+ import { hi } from "./hub-invitations-strings.js";
9
+ import { hroom } from "./hub-room-strings.js";
10
+ import { linkRoomsU2Css } from "./hub-room-new-strings.js";
11
+
12
+ linkRoomsU2Css();
13
+
14
+ /** The pending invitations to my agents: { list (null while loading), error, reload, answer(id, accept) → Promise<boolean> }. */
15
+ export function useInvitations(client = hubClient()) {
16
+ const [list, setList] = useState(null), [error, setError] = useState(false);
17
+ const live = useRef(true), asked = useRef(0);
18
+ const reload = async () => {
19
+ const mine = ++asked.current;
20
+ const r = await client.invitations();
21
+ if (!live.current || mine !== asked.current) return;
22
+ if (r?.ok && Array.isArray(r.invitations)) { setList(r.invitations.filter(valid)); setError(false); }
23
+ else setError(true);
24
+ };
25
+ useEffect(() => {
26
+ live.current = true; void reload();
27
+ const off = client.subscribeRooms?.({ "invitation.changed": () => { void reload(); } }) ?? (() => {});
28
+ return () => { live.current = false; off(); };
29
+ }, [client]);
30
+ const answer = async (invitationId, accept) => {
31
+ const r = await (accept ? client.acceptInvitation(invitationId) : client.declineInvitation(invitationId));
32
+ if (!live.current) return r;
33
+ if (r?.ok) setList(old => old ? old.filter(x => x.id !== invitationId) : old);
34
+ else if (r?.status === 404) { setList(old => old ? old.filter(x => x.id !== invitationId) : old); void reload(); }
35
+ return r;
36
+ };
37
+ return { list, error, reload, answer };
38
+ }
39
+ const valid = (x) => x && typeof x.id === "string" && x.room && typeof x.room.name === "string" && x.agent && typeof x.agent.name === "string";
40
+
41
+ /**
42
+ * The invitations themselves, each with 同意 / 不要. Nothing when there are none (My shared agents shows no empty box).
43
+ * heading: the list's own 「邀請」 title — false where the page already says it (the invitations page's header).
44
+ */
45
+ export function InvitationsList({ client = hubClient(), heading = true } = {}) { // onOpenRoom: not used — the owner is not a member of the inviting room
46
+ const { list, error, reload, answer } = useInvitations(client);
47
+ const [busy, setBusy] = useState(null), [note, setNote] = useState(null), inflight = useRef(false);
48
+ if (error && !list) return html`<p class="note hub-invitations-error" role="alert">${hi("loadFailed")} <button type="button" class="btn btn-link" onClick=${() => { void reload(); }}>${hi("retry")}</button></p>`;
49
+ if (!list?.length) return note ? html`<p class="note" role="status">${note.text}</p>` : null;
50
+ const act = async (item, accept) => {
51
+ if (inflight.current) return; // one answer at a time, even before the disabled buttons are drawn
52
+ inflight.current = true; setBusy(item.id); setNote(null);
53
+ const r = await answer(item.id, accept);
54
+ inflight.current = false; setBusy(null);
55
+ if (!r?.ok) setNote({ id: item.id, text: r?.status === 404 ? hi("gone") : hi("failed") });
56
+ };
57
+ return html`<section class="hub-invitations" aria-label=${hi("invitations")}>
58
+ ${heading ? html`<h3>${hi("invitations")}</h3>` : null}
59
+ ${list.map(item => html`<article class="hub-invitation" key=${item.id}>
60
+ <p>${hroom("inviteLead", item.by?.name || "", item.agent.name, item.room.name)}</p>
61
+ <small class="note">${Number(item.room.people) === 1 ? hi("leadOne") : hroom("inviteHint", Number(item.room.people) || 0)}</small>
62
+ <small class="note">${hi("readsRecent")}</small>
63
+ ${note?.id === item.id ? html`<p class="note" role="alert">${note.text}</p>` : null}
64
+ <div class="field-row">
65
+ <button type="button" class="btn btn-primary" disabled=${busy !== null} onClick=${() => act(item, true)}>${hroom("agree")}</button>
66
+ <button type="button" class="btn" disabled=${busy !== null} onClick=${() => act(item, false)}>${hroom("decline")}</button>
67
+ </div>
68
+ </article>`)}
69
+ ${note && !list.some(x => x.id === note.id) ? html`<p class="note" role="status">${note.text}</p>` : null}
70
+ </section>`;
71
+ }
72
+
73
+ /**
74
+ * 「在這些房間裡」 on one of my shared agents' pages (section 8): the rooms it was let into, each with 退出這個房間.
75
+ * Nothing when it is in none. Follows member.changed / room.changed for those rooms, and invitation.changed (an accepted
76
+ * invitation adds a room). onRooms(count): after each read of the agent's rooms (0 included) and after a Leave, so the
77
+ * page can say 「在 N 個房間裡」 from this one read.
78
+ */
79
+ export function AgentRoomsSection({ client = hubClient(), exposureId, onRooms } = {}) {
80
+ const [rooms, setRooms] = useState(null), [busy, setBusy] = useState(null), [failed, setFailed] = useState(null);
81
+ const live = useRef(true), asked = useRef(0), told = useRef(onRooms);
82
+ told.current = onRooms;
83
+ useEffect(() => { if (rooms) told.current?.(rooms.length); }, [rooms]); // each read (a new list) and each Leave
84
+ const reload = async () => {
85
+ const mine = ++asked.current;
86
+ const r = await client.agentRooms(exposureId);
87
+ if (live.current && mine === asked.current && r?.ok && Array.isArray(r.rooms)) setRooms(r.rooms.filter(x => x && typeof x.id === "string"));
88
+ };
89
+ useEffect(() => {
90
+ live.current = true; void reload();
91
+ const again = () => { void reload(); };
92
+ const off = client.subscribeRooms?.({ "invitation.changed": again, "member.changed": again, "room.changed": again }) ?? (() => {});
93
+ return () => { live.current = false; off(); };
94
+ }, [client, exposureId]);
95
+ if (!rooms?.length) return null;
96
+ const leave = async (room) => {
97
+ setBusy(room.id); setFailed(null);
98
+ const r = await client.removeRoomMember(room.id, room.memberId || exposureId);
99
+ if (!live.current) return;
100
+ setBusy(null);
101
+ if (r?.ok) setRooms(old => old.filter(x => x.id !== room.id)); else setFailed(room.id);
102
+ };
103
+ return html`<section class="hub-agent-rooms"><h4>${hroom("inTheseRooms")}</h4>
104
+ <ul>${rooms.map(room => html`<li key=${room.id} data-room=${room.id}><span>${hi("roomPeople", room.name, Number(room.people) || 0)}</span>
105
+ <button type="button" class="btn btn-link" disabled=${busy !== null} onClick=${() => { void leave(room); }}>${hroom("leaveThisRoom")}</button>
106
+ ${failed === room.id ? html`<p class="note" role="alert">${hi("leaveFailed")}</p>` : null}</li>`)}</ul>
107
+ </section>`;
108
+ }