@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
@@ -1,3 +1,4 @@
1
+ import { modelSwitchText, modelName, observationLabel } from "/assets/model-observation.js";
1
2
  // #2661: a person's profile card in the Office (fleet-office.js opens it): a popover beside them, not a modal — the Office
2
3
  // keeps running and is not dimmed; on a phone, a bottom sheet swiped down to close. Fixed 320 px wide.
3
4
  //
@@ -60,7 +61,7 @@ export function cardModel({ node, lv, levels, share = false, state, now, where }
60
61
  const detail = !share && !!e && e.workTokens !== undefined;
61
62
  const xp = showLevel && detail ? xpOf(e.level, e.workTokens, lv.unit) : null;
62
63
  const rows = [[tc("office"), where]];
63
- if (!share && it.model) rows.push([tc("model"), modelText(it)]);
64
+ if (!share && it.model) rows.push(it.model_observation ? [observationLabel("selection"), modelName(it.model_observation.session) || observationLabel("unresolved")] : [tc("model"), modelText(it)]);
64
65
  if (!share && it.backend) rows.push([tc("backend"), backendLabel(it.backend)]);
65
66
  if (detail) rows.push([tc("today"), tc("todayN", tokens(e.today.workTokens), e.today.requests)]);
66
67
  if (detail && e.firstSeen) rows.push([tc("firstSeen"), tc("day", dayOf(e.firstSeen))]);
@@ -70,7 +71,7 @@ export function cardModel({ node, lv, levels, share = false, state, now, where }
70
71
  badge: on && fx && fx.hideLevel ? { mark: true, tier: 0 } : e ? { text: badgeText(e.level), tier: tierOf(e.level) } : null,
71
72
  level: showLevel ? { line1: detail ? `${tc("level", e.level)} · ${tc("work", tokens(e.workTokens))}` : tc("level", e.level), estimated: detail && e.estimated,
72
73
  line2: xp ? tc("toNext", tokens(xp.toNext), xp.next) : null, pct: xp ? xp.pct : null, next: xp ? xp.next : null } : null,
73
- rows, now,
74
+ rows, now, modelSwitch: !share ? modelSwitchText(it.model_observation?.active) : "",
74
75
  };
75
76
  }
76
77
 
@@ -89,6 +90,7 @@ export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onC
89
90
  return html`<div ref=${box} class=${`oo-card${sheet ? " sheet" : ""}`} role="dialog" aria-modal="false" aria-label=${tc("card", m.name)}
90
91
  onPointerDown=${down} onPointerUp=${up} onPointerCancel=${() => { swipe.current = null; }}>
91
92
  ${sheet ? html`<div class="oo-card-grip" aria-hidden="true"></div>` : null}
93
+ ${m.modelSwitch ? html`<p class="oo-card-now model-switch" role="status"><strong>${m.modelSwitch}</strong></p>` : null}
92
94
  <div class="oo-card-head">
93
95
  <div class="oo-card-avatar"><canvas ref=${canvas} width="56" height="56" aria-hidden="true"></canvas>
94
96
  ${m.badge ? html`<span class=${`oo-badge tier-${m.badge.tier}${m.badge.mark ? " mark" : ""}`} aria-hidden="true">${m.badge.mark ? "" : m.badge.text}</span>` : null}</div>
@@ -1,3 +1,4 @@
1
+ import { modelSwitchText, modelName, observationLabel } from "/assets/model-observation.js";
1
2
  // #1389: Fleet → Org chart (/ui/fleet/org) — General at the top, then the teams fleet.yaml defines, then their
2
3
  // instances; each node names the instance, says what it does, which backend and model it runs, how it is doing now,
3
4
  // and links to its thread. Behind the session gate (/ui/js/), imported by the Fleet panel.
@@ -129,6 +130,7 @@ function Node({ n, sending }) {
129
130
  ${n.i ? html`<div class="org-meta">${n.i.backend ? html`<span class="org-chip">${n.i.backend}</span>` : null}
130
131
  ${model ? html`<span class="org-model mono" title=${model}>${model}</span>` : null}
131
132
  ${n.info.classic ? html`<span class="org-chip">${to("classic")}</span>` : null}</div>` : null}
133
+ ${n.i?.model_observation?.active ? html`<p class="note model-switch" role="status">${modelSwitchText(n.i.model_observation.active)}</p>` : null}
132
134
  ${n.i || thread ? html`<div class="org-links">
133
135
  ${thread ? html`<a class="org-link" href=${thread.url} target="_blank" rel="noopener noreferrer">
134
136
  <${Icon} name="external" size=${14} />${to(`thread_${thread.platform}`)}<span class="sr-only"> ${to("newTab")}</span></a>` : null}
@@ -0,0 +1,28 @@
1
+ // Hub rooms, Administration → Rooms (docs/design/hub-rooms-ux.md section 11): only the words the shared room vocabulary
2
+ // (hub-room-strings.js, namespace hubRoom) does not have. A module of its own, so a tab holding an older dictionary still
3
+ // has every word (upgrade skew).
4
+ import { register, t } from "/assets/app-i18n.js";
5
+
6
+ register("hubAdminRooms", {
7
+ en: {
8
+ adminOnly: "Right now only Hub administrators can start rooms.",
9
+ colPeople: "People", colAgents: "Agents", colLast: "Last activity", colState: "Status",
10
+ none: "No rooms yet.",
11
+ rowMenu: "More for {0}",
12
+ saveFailed: "That was not saved. Try again.",
13
+ loadFailed: "Rooms could not be loaded.", retry: "Try again",
14
+ archiveAsk: "Archive “{0}”? The room becomes read-only; its members can still read it.",
15
+ joined: "You are a room manager of “{0}” now. A line in the room says so.",
16
+ },
17
+ "zh-TW": {
18
+ adminOnly: "目前只有 Hub 管理員可以開房間。",
19
+ colPeople: "人數", colAgents: "Agent 數", colLast: "最後活動", colState: "狀態",
20
+ none: "還沒有房間。",
21
+ rowMenu: "{0} 的更多動作",
22
+ saveFailed: "沒有儲存,請再試一次。",
23
+ loadFailed: "無法載入房間。", retry: "再試一次",
24
+ archiveAsk: "要封存「{0}」嗎?房間會變成唯讀,成員仍然看得到內容。",
25
+ joined: "你現在是「{0}」的房間管理,房間裡會出現一則說明。",
26
+ },
27
+ });
28
+ export const ha = (key, ...args) => t(`hubAdminRooms.${key}`, ...args);
@@ -0,0 +1,77 @@
1
+ // Hub rooms, Administration → Rooms (docs/design/hub-rooms-ux.md section 11), for the Hub administrator:
2
+ // - 「誰可以開房間」: people and teams who may start rooms besides the administrators (empty: administrators only);
3
+ // saved as soon as it changes; everyone can always start a one-to-one chat.
4
+ // - 「所有房間」: every group room's name, people, agents, managers, last activity and status, never its content. Each
5
+ // row's menu: 加入自己成為房間管理 (the room then shows a line saying so) and 封存 (after a confirmation).
6
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
7
+ import { Menu } from "/assets/ui-menu.js";
8
+ import { confirmDialog } from "/assets/ui-confirm.js";
9
+ import { chatTime } from "/assets/chat-time.js";
10
+ import { hubClient } from "./hub-client.js";
11
+ import { hroom } from "./hub-room-strings.js";
12
+ import { ha } from "./hub-admin-rooms-strings.js";
13
+ import { RoomPicker } from "./hub-room-new.js";
14
+ import { linkRoomsU2Css } from "./hub-room-new-strings.js";
15
+
16
+ linkRoomsU2Css();
17
+
18
+ export function AdminRooms({ client = hubClient() } = {}) {
19
+ const [creators, setCreators] = useState(null), [rooms, setRooms] = useState(null), [failed, setFailed] = useState(false);
20
+ const [error, setError] = useState(""), [note, setNote] = useState(""), [busy, setBusy] = useState(false);
21
+ const live = useRef(true);
22
+ const load = async () => {
23
+ const [c, r] = await Promise.all([client.roomCreators(), client.adminRooms()]);
24
+ if (!live.current) return;
25
+ if (!c?.ok || !r?.ok) { setFailed(true); return; }
26
+ setFailed(false);
27
+ setCreators([...(c.people ?? []).map(x => ({ kind: "person", ...named(x) })), ...(c.teams ?? []).map(x => ({ kind: "team", ...named(x) }))]);
28
+ setRooms(Array.isArray(r.rooms) ? r.rooms : []);
29
+ };
30
+ useEffect(() => { live.current = true; void load(); return () => { live.current = false; }; }, [client]);
31
+ if (failed && !rooms) return html`<section class="hub-admin-rooms"><p class="note" role="alert">${ha("loadFailed")} <button type="button" class="btn btn-link" onClick=${() => { void load(); }}>${ha("retry")}</button></p></section>`;
32
+ if (!rooms || !creators) return html`<section class="hub-admin-rooms" aria-busy="true"></section>`;
33
+ const saveCreators = async (next) => {
34
+ const before = creators;
35
+ setCreators(next); setBusy(true); setError(""); setNote("");
36
+ const r = await client.saveRoomCreators({ people: next.filter(x => x.kind === "person").map(x => x.id), teams: next.filter(x => x.kind === "team").map(x => x.id) });
37
+ if (!live.current) return;
38
+ setBusy(false);
39
+ if (!r?.ok) { setCreators(before); setError(ha("saveFailed")); }
40
+ };
41
+ const act = async (send, after) => {
42
+ setBusy(true); setError(""); setNote("");
43
+ const r = await send();
44
+ if (!live.current) return;
45
+ setBusy(false);
46
+ if (!r?.ok) { setError(ha("saveFailed")); return; }
47
+ after?.(); void load();
48
+ };
49
+ const archive = async (room) => {
50
+ if (!await confirmDialog({ title: hroom("archiveRoom"), message: ha("archiveAsk", room.name), confirmLabel: hroom("archive"), danger: true })) return;
51
+ await act(() => client.archiveRoomAsAdmin(room.id, true));
52
+ };
53
+ return html`<section class="hub-admin-rooms">
54
+ ${error ? html`<p class="note" role="alert">${error}</p>` : null}
55
+ ${note ? html`<p class="note" role="status">${note}</p>` : null}
56
+ <section class="form hub-admin-creators"><h3>${hroom("whoCanCreate")}</h3>
57
+ <${RoomPicker} client=${client} id="hubRoomCreators" kinds=${["person", "team"]} label=${hroom("addPeopleOrTeams")} placeholder=${hroom("addPeopleOrTeams")}
58
+ picked=${creators} onChange=${(next) => { if (!busy) void saveCreators(next); }} />
59
+ ${creators.length ? null : html`<p class="note">${ha("adminOnly")}</p>`}
60
+ <p class="note">${hroom("everyoneDirect")}</p>
61
+ </section>
62
+ <section class="hub-admin-all-rooms"><h3>${hroom("allRooms")}</h3>
63
+ <p class="note">${hroom("noContent")}</p>
64
+ ${rooms.length ? html`<table class="hub-admin-rooms-table"><thead><tr><th>${hroom("name")}</th><th>${ha("colPeople")}</th><th>${ha("colAgents")}</th><th>${hroom("roomManager")}</th><th>${ha("colLast")}</th><th>${ha("colState")}</th><th></th></tr></thead>
65
+ <tbody>${rooms.map(room => html`<tr key=${room.id} data-room=${room.id}>
66
+ <td>${room.name}</td><td>${Number(room.people) || 0}</td><td>${Number(room.agents) || 0}</td>
67
+ <td>${Array.isArray(room.managers) ? room.managers.join("、") : ""}</td>
68
+ <td>${room.lastAt ? chatTime(room.lastAt) : ""}</td>
69
+ <td>${room.archived ? hroom("archived") : hroom("active")}</td>
70
+ <td><${Menu} label=${ha("rowMenu", room.name)} disabled=${busy} items=${[
71
+ { key: "join", label: hroom("joinAsManager"), onSelect: () => { void act(() => client.joinRoomAsAdmin(room.id), () => setNote(ha("joined", room.name))); } },
72
+ room.archived ? null : { key: "archive", label: hroom("archive"), danger: true, onSelect: () => { void archive(room); } },
73
+ ]} /></td></tr>`)}</tbody></table>` : html`<p class="note">${ha("none")}</p>`}
74
+ </section>
75
+ </section>`;
76
+ }
77
+ const named = (x) => typeof x === "string" ? { id: x, name: x } : { id: String(x?.id ?? ""), name: String(x?.name ?? x?.id ?? ""), ...(Number.isFinite(x?.people) ? { people: x.people } : {}) };
@@ -0,0 +1,26 @@
1
+ import { register, t } from "/assets/app-i18n.js";
2
+ register("hubAssistantAdmin", {
3
+ en: {
4
+ accountSignedIn: "Signed in.", accountNeedsSignIn: "Sign-in needed. Sign in under AgEnD settings on this Hub computer.",
5
+ accountUnknown: "Sign-in status unknown. Sign in under AgEnD settings on this Hub computer.",
6
+ backend: "Backend", account: "Account", defaultAccount: "Default account", unknown: "Unknown",
7
+ save: "Save", saved: "Saved", refresh: "Refresh", noneRunning: "No room assistants are working or idle.",
8
+ loadFailed: "Could not read room assistant settings. Try again.", saveFailed: "Could not save. Your changes are still here; try again.",
9
+ stoppedRefreshFailed: "Stopped this room assistant. Could not refresh its status; use Refresh to try again.",
10
+ stopFailed: "Could not stop this room assistant. Try again.", usageFailed: "Could not read usage. Try again.",
11
+ usageNotSaved: "Some answer counts could not be saved. The answers were still sent.", quotaPending: "Quota status not available yet",
12
+ starting: "Starting", stopping: "Stopping", failed: "Needs attention", day: "Date (UTC)", answers: "Answers",
13
+ },
14
+ "zh-TW": {
15
+ accountSignedIn: "已登入", accountNeedsSignIn: "需要登入。請在 Hub 這台電腦的 AgEnD 設定裡登入。",
16
+ accountUnknown: "登入狀態未知。請在 Hub 這台電腦的 AgEnD 設定裡登入。",
17
+ backend: "後端", account: "帳號", defaultAccount: "預設帳號", unknown: "未知",
18
+ save: "儲存", saved: "已儲存", refresh: "重新整理", noneRunning: "目前沒有執行中或待命的房間助理。",
19
+ loadFailed: "未能讀取房間助理設定,請再試一次。", saveFailed: "未能儲存,修改仍保留在這裡,請再試一次。",
20
+ stoppedRefreshFailed: "已停止這個房間助理,但未能更新狀態,請按「重新整理」再試一次。",
21
+ stopFailed: "未能停止這個房間助理,請再試一次。", usageFailed: "未能讀取用量,請再試一次。",
22
+ usageNotSaved: "部分回答次數未能儲存,回答仍已送出。", quotaPending: "尚未取得額度狀態",
23
+ starting: "啟動中", stopping: "停止中", failed: "需要處理", day: "日期(UTC)", answers: "回答次數",
24
+ },
25
+ });
26
+ export const ha = (key, ...args) => t(`hubAssistantAdmin.${key}`, ...args);
@@ -0,0 +1,85 @@
1
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
2
+ import { Empty, ErrorState, Skeleton } from "/assets/ui-states.js";
3
+ import { hroom } from "./hub-room-strings.js";
4
+ import { ha } from "./hub-assistant-admin-strings.js";
5
+
6
+ const fields = value => ({ enabled: value.enabled === true, backend: value.backend, account: value.account ?? null, cap: Number(value.cap), idleMinutes: Number(value.idleMinutes) });
7
+ const validLimits = value => Number.isInteger(Number(value?.cap)) && Number(value.cap) >= 1 && Number(value.cap) <= 16 && Number.isInteger(Number(value?.idleMinutes)) && Number(value.idleMinutes) >= 1 && Number(value.idleMinutes) <= 240;
8
+ const accountWord = row => row.state === "signed-in" ? hroom("signedIn") : row.state === "needs-sign-in" ? hroom("needsSignIn") : ha("unknown");
9
+ const accountHelp = row => ha(row?.state === "signed-in" ? "accountSignedIn" : row?.state === "needs-sign-in" ? "accountNeedsSignIn" : "accountUnknown");
10
+ const stateWord = state => state === "idle" ? hroom("stIdle") : state === "working" ? hroom("stWorking") : ha(["starting", "stopping", "failed"].includes(state) ? state : "unknown");
11
+ const quotaWord = band => band === "available" ? hroom("quotaPlenty") : band === "near_limit" ? hroom("quotaLow") : band === "exhausted" ? hroom("quotaGone") : ha("quotaPending");
12
+
13
+ /** Hub-only admin cards; the existing client owns same-origin session/CSRF. No Fleet endpoint is called. */
14
+ export function HubAssistantAdmin({ client }) {
15
+ const [view, setView] = useState(null), [form, setForm] = useState(null), [usage, setUsage] = useState(null);
16
+ const [error, setError] = useState(null), [busy, setBusy] = useState(false), [saved, setSaved] = useState(false);
17
+ const generation = useRef(0);
18
+ const load = async (replaceForm = true) => {
19
+ const mine = ++generation.current;
20
+ const results = await Promise.allSettled([Promise.resolve().then(() => client.assistantSettings()), Promise.resolve().then(() => client.assistantUsage())]);
21
+ const settings = results[0].status === "fulfilled" ? results[0].value : { ok: false };
22
+ const counts = results[1].status === "fulfilled" ? results[1].value : { ok: false };
23
+ if (mine !== generation.current) return;
24
+ if (!settings?.ok) { setError(ha("loadFailed")); return; }
25
+ setView(settings); setForm(value => replaceForm || value === null ? fields(settings) : value); setUsage(counts?.ok ? counts : { ok: false }); setError(null);
26
+ };
27
+ useEffect(() => { setBusy(false); setView(null); setForm(null); void load(); return () => { generation.current++; }; }, [client]);
28
+ const edit = patch => { setSaved(false); setForm(value => ({ ...value, ...patch })); };
29
+ const save = async event => {
30
+ event.preventDefault(); if (busy || !validLimits(form)) return;
31
+ setBusy(true); setError(null); setSaved(false);
32
+ const mine = generation.current;
33
+ let result;
34
+ try { result = await client.saveAssistantSettings(fields(form)); } catch { result = { ok: false }; }
35
+ if (mine !== generation.current) return;
36
+ setBusy(false);
37
+ if (!result?.ok) { setError(ha("saveFailed")); return; }
38
+ setView(result); setForm(fields(result)); setSaved(true);
39
+ };
40
+ const stop = async roomId => {
41
+ if (busy) return; setBusy(true); setError(null);
42
+ const mine = generation.current;
43
+ let result, latest;
44
+ try { result = await client.stopRoomAssistant(roomId); } catch { result = { ok: false }; }
45
+ if (result?.ok) { try { latest = await client.assistantSettings(); } catch { latest = { ok: false }; } }
46
+ if (mine !== generation.current) return;
47
+ setBusy(false);
48
+ if (!result?.ok) { setError(ha("stopFailed")); return; }
49
+ if (!latest?.ok) {
50
+ setView(value => ({ ...value, running: value.running.filter(row => row.roomId !== roomId) }));
51
+ setError(ha("stoppedRefreshFailed")); return;
52
+ }
53
+ setView(latest); // a status refresh must not discard unsaved settings
54
+ };
55
+ if (!view) return html`<section class="card" aria-label=${hroom("roomAssistant")}><h3>${hroom("roomAssistant")}</h3>${error
56
+ ? html`<${ErrorState} message=${error} onRetry=${() => load(false)} />` : html`<${Skeleton} variant="rows" lines=${3} />`}</section>`;
57
+ const backends = Array.isArray(view.backends) ? view.backends : [], backend = backends.find(row => row.id === form.backend);
58
+ const accounts = backend?.accounts || [], selected = accounts.find(row => row.id === form.account);
59
+ const canEnable = accounts.some(row => row.state !== "needs-sign-in"), running = Array.isArray(view.running) ? view.running : [];
60
+ return html`<section class="card" aria-label=${hroom("roomAssistant")}><h3>${hroom("roomAssistant")}</h3>
61
+ ${!view.enabled ? html`<p class="note">${hroom("assistantNotEnabled")}</p>` : null}
62
+ ${!backends.length ? html`<${Empty} title=${hroom("assistantNotEnabled")} hint=${hroom("assistantEnableHint")} />` : null}
63
+ <form class="form" onSubmit=${save}>
64
+ <label class="s-row"><span>${hroom("enableAssistant")}</span><input class="s-ui-toggle" type="checkbox" role="switch" aria-label=${hroom("enableAssistant")} checked=${form.enabled} disabled=${busy || !canEnable && !form.enabled} onChange=${e => edit({ enabled: e.target.checked })} /></label>
65
+ <div class="s-group"><h4>${hroom("aiAccount")}</h4><div class="grid2">
66
+ <label class="field"><span>${ha("backend")}</span><select aria-label=${ha("backend")} value=${form.backend} disabled=${busy || !backends.length} onChange=${e => edit({ backend: e.target.value, account: null })}>
67
+ ${backends.map(row => html`<option key=${row.id} value=${row.id}>${row.name}</option>`)}</select></label>
68
+ <label class="field"><span>${ha("account")}</span><select aria-label=${ha("account")} value=${form.account ?? ""} disabled=${busy || !accounts.length} onChange=${e => edit({ account: e.target.value || null })}>
69
+ ${accounts.map(row => html`<option key=${row.id ?? "default"} value=${row.id ?? ""} disabled=${row.state === "needs-sign-in"}>${row.id === null ? ha("defaultAccount") : row.name} · ${accountWord(row)}</option>`)}</select></label>
70
+ </div><p class="note">${accountHelp(selected)}</p><p class="note">${hroom("assistantQuota")}</p></div>
71
+ <div class="grid2"><label class="field"><span>${hroom("cap")}</span><input aria-label=${hroom("cap")} type="number" inputmode="numeric" min="1" max="16" step="1" required value=${form.cap} disabled=${busy} onInput=${e => edit({ cap: e.target.value })} /></label>
72
+ <label class="field"><span>${hroom("idleMinutes")}</span><input aria-label=${hroom("idleMinutes")} type="number" inputmode="numeric" min="1" max="240" step="1" required value=${form.idleMinutes} disabled=${busy} onInput=${e => edit({ idleMinutes: e.target.value })} /></label></div>
73
+ ${error ? html`<p class="err" role="alert">${error}</p>` : null}${saved ? html`<p class="note" role="status">${ha("saved")}</p>` : null}
74
+ <div class="field-row"><button type="submit" class="btn btn-primary" disabled=${busy || !validLimits(form) || form.enabled && !selected}>${ha("save")}</button></div>
75
+ </form>
76
+ </section>
77
+ <section class="card" aria-label=${hroom("runningNow")}><div class="hub-card-head"><h3>${hroom("runningNow")}</h3><button type="button" class="btn btn-sm btn-ghost" disabled=${busy} onClick=${() => load(false)}>${ha("refresh")}</button></div>
78
+ ${running.length ? html`<div class="hub-rows">${running.map(row => html`<div class="s-row hub-row" key=${row.roomId}><span class="hub-row-text"><strong title=${row.roomName}>${row.roomName}</strong><small class="note">${hroom("lastUsed")} · ${new Date(row.lastUsed).toLocaleString(undefined, { dateStyle: "short", timeStyle: "short", hour12: false })}</small></span>
79
+ <span class=${`tag ${row.state === "failed" ? "warn" : ""}`}>${stateWord(row.state)}</span><button type="button" class="btn btn-sm" disabled=${busy || row.state === "stopping"} onClick=${() => stop(row.roomId)}>${hroom("stop")}</button></div>`)}</div>` : html`<p class="note">${ha("noneRunning")}</p>`}
80
+ </section>
81
+ <section class="card" aria-label=${hroom("usage")}><h3>${hroom("usage")}</h3><p class="note">${hroom("usageLead")}</p>
82
+ ${usage?.ok ? html`<div class="s-row note"><span>${ha("day")}</span><span>${ha("answers")}</span></div><div class="hub-rows">${usage.days.map(row => html`<div class="s-row" key=${row.day}><time datetime=${row.day}>${new Date(`${row.day}T00:00:00Z`).toLocaleDateString(undefined, { month: "numeric", day: "numeric", timeZone: "UTC" })}</time><strong>${row.count}</strong></div>`)}</div><p>${hroom("aiAccount")} · <span class="tag">${quotaWord(usage.quota?.band)}</span></p>
83
+ ${usage.note === "usage-not-saved" ? html`<p class="note" role="status">${ha("usageNotSaved")}</p>` : null}` : html`<${ErrorState} message=${ha("usageFailed")} onRetry=${() => load(false)} />`}
84
+ </section>`;
85
+ }
@@ -100,6 +100,28 @@ 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
+ export const TEAMS_FEATURE = "teams-v1";
106
+ /** The live stream's events (seam 1). */
107
+ /**
108
+ * The live stream's events (seam 1, as agreed with Lumen): message.added / message.updated { roomId, message, parent?:
109
+ * { id, ask } } (a reply that changes its question's counts carries them), presence.changed { roomId, memberId, presence,
110
+ * presenceNote? }, member.changed { roomId } (joined, left, role: read the room again), room.changed { roomId, room } or
111
+ * { roomId, removed: true } (no longer a member: drop it), unread.changed { roomId, unread }, invitation.changed {}.
112
+ */
113
+ export const ROOM_EVENTS = Object.freeze(["message.added", "message.updated", "presence.changed", "member.changed", "room.changed", "unread.changed", "invitation.changed"]);
114
+ /**
115
+ * Today's room (one asker, one agent; GET /hub/v1/rooms before ROOMS_FEATURE) in the rooms list's shape: a direct room
116
+ * named after its agent, the old item kept under `legacy` (its state, its agent's state, its grant's end, its features),
117
+ * and `limited: true`: that Hub has no members, presence or unread, so the page leaves those controls out.
118
+ */
119
+ export function legacyRoom(item) {
120
+ if (!item || typeof item !== "object" || typeof item.id !== "string") return null;
121
+ return { id: item.id, kind: "direct", name: String(item.exposureName || ""), people: 1, agents: 1, online: null, unread: 0,
122
+ lastAt: Number.isFinite(item.lastAt) ? item.lastAt : 0, lastText: "", lastAuthor: "",
123
+ agent: { exposureId: String(item.exposureId || ""), owner: { name: String(item.ownerName || "") }, presence: null }, limited: true, legacy: item };
124
+ }
103
125
  export const ADDRESS_HINT = /^https:\/\/[^\s/?#@]+\/?$/i;
104
126
  export const CODE_HINT = /^[A-Za-z0-9][A-Za-z0-9 -]{4,62}[A-Za-z0-9]$/;
105
127
  /** The part of a fingerprint people compare: its first 32 hex digits (128 bits) in 8 groups of 4. */
@@ -207,7 +229,7 @@ export function createStubClient({ now = () => Date.now(), agents = () => [] } =
207
229
  export function createHubWebClient({ fetchImpl = (...a) => fetch(...a), readTimeoutMs = 120_000 } = {}) {
208
230
  // The factory override is for owned transports/rehearsals; the page uses the finite default.
209
231
  const readBudget = Number.isInteger(readTimeoutMs) && readTimeoutMs > 0 && readTimeoutMs <= 300_000 ? readTimeoutMs : 120_000;
210
- let csrf = null, codeNotices = false, generation = 0;
232
+ let csrf = null, codeNotices = false, roomsLive = false, teamsLive = false, generation = 0;
211
233
  const ended = new Set(), pendingReads = new Map(), waits = new Set(), readControllers = new Set();
212
234
  let readTail = Promise.resolve();
213
235
  const retired = () => ({ ok: false, status: 401, code: "unauthenticated" });
@@ -277,20 +299,68 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a), readTime
277
299
  let json = null;
278
300
  try { json = await r.json(); } catch { json = null; }
279
301
  if (method === "GET" && signal?.aborted) return unreachable();
280
- if (r.status === 401 && mine === generation) { retireReads(); csrf = null; codeNotices = false; for (const fn of ended) { try { fn(); } catch { /* a listener's own failure */ } } }
302
+ if (r.status === 401 && mine === generation) { retireReads(); csrf = null; codeNotices = false; roomsLive = false; teamsLive = false; for (const fn of ended) { try { fn(); } catch { /* a listener's own failure */ } } }
281
303
  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,
282
304
  ...(method === "POST" && path === "/hub/v1/admin/enrolment-codes" && r.status === 429 && json?.code === "backpressure"
283
- && ["live-code-limit", "hourly-code-limit"].includes(json.reason) ? { reason: json.reason } : {}) };
305
+ && ["live-code-limit", "hourly-code-limit"].includes(json.reason) ? { reason: json.reason } : {}), ...roomRefusal(json) };
284
306
  return { ok: true, ...(json && typeof json === "object" ? json : {}) };
285
307
  }
286
308
  const id = (v) => encodeURIComponent(String(v));
309
+ // Track U2: a refused room write says what the person is told — 409 people-limit the room's would-be head count (the
310
+ // deduplicated union, the creator and current members included) and the limit; 503 group-unavailable which group.
311
+ const roomRefusal = (json) => json?.code === "people-limit" && Number.isSafeInteger(json.people)
312
+ ? { people: json.people, limit: Number.isSafeInteger(json.limit) ? json.limit : 100 }
313
+ : json?.code === "group-unavailable" && typeof json.group === "string" ? { group: json.group } : {};
314
+ // One stream per tab (#1580): every live subscription shares one EventSource. A Hub with rooms carries the notices on
315
+ // its rooms stream too (`notices` = the notice version); before that the notices have their own. Listeners are kept
316
+ // per event name; the stream closes with its last listener, and a refused (CLOSED) stream tells every subscriber once.
317
+ // One dispatcher per event name per source, added when the name first listens and kept while that source lives (with no
318
+ // listeners it reads an empty set), so a name that listens again while the stream stays open is heard once (Fable on #3848).
319
+ const stream = { source: null, url: "", listeners: new Map(), dispatchers: new Map(), closers: new Set() };
320
+ const attach = (name) => { if (stream.source && !stream.dispatchers.has(name)) { const fn = dispatch(name); stream.dispatchers.set(name, fn); stream.source.addEventListener(name, fn); } };
321
+ const dispatch = (name) => (event) => {
322
+ let data; try { data = JSON.parse(event.data); } catch { return; }
323
+ for (const fn of [...(stream.listeners.get(name) || [])]) { try { fn(data); } catch { /* a listener's own failure */ } }
324
+ };
325
+ function listen(url, handlers, onClosed) {
326
+ if (typeof EventSource === "undefined") return () => {};
327
+ if (stream.source && stream.url !== url) { stream.source.close(); stream.source = null; stream.dispatchers.clear(); } // the session changed what it may hear
328
+ const mine = [];
329
+ for (const [name, fn] of Object.entries(handlers)) {
330
+ if (typeof fn !== "function") continue;
331
+ if (!stream.listeners.has(name)) stream.listeners.set(name, new Set());
332
+ attach(name);
333
+ stream.listeners.get(name).add(fn); mine.push([name, fn]);
334
+ }
335
+ stream.closers.add(onClosed);
336
+ if (!stream.source) {
337
+ const source = new EventSource(url); stream.source = source; stream.url = url; stream.dispatchers.clear();
338
+ for (const name of stream.listeners.keys()) attach(name);
339
+ source.addEventListener("error", () => {
340
+ // A refused handshake is CLOSED, unlike a transient disconnect that EventSource itself reconnects.
341
+ if (stream.source !== source || source.readyState !== 2) return;
342
+ source.close(); stream.source = null; stream.listeners.clear(); stream.dispatchers.clear();
343
+ const closers = [...stream.closers]; stream.closers.clear();
344
+ for (const fn of closers) { try { fn(); } catch { /* a subscriber's own failure */ } }
345
+ });
346
+ }
347
+ let live = true;
348
+ return () => {
349
+ if (!live) return; live = false;
350
+ for (const [name, fn] of mine) { const set = stream.listeners.get(name); set?.delete(fn); if (set && !set.size) stream.listeners.delete(name); }
351
+ stream.closers.delete(onClosed);
352
+ if (!stream.listeners.size && stream.source) { stream.source.close(); stream.source = null; stream.dispatchers.clear(); }
353
+ };
354
+ }
355
+ const noticeVersion = (version) => version === 3 && codeNotices ? 3 : 2;
356
+ const streamUrl = (version) => roomsLive ? `/hub/v1/rooms/events?notices=${noticeVersion(version)}` : `/hub/v1/notices/events?v=${noticeVersion(version)}`;
287
357
  return {
288
358
  stub: false, web: true,
289
359
  /** Hear the session end (a 401 anywhere). @returns {() => void} */
290
360
  onSignedOut(fn) { ended.add(fn); return () => ended.delete(fn); },
291
- 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; },
292
- 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; },
293
- async signOut() { retireReads(); const r = await call("DELETE", "/hub/v1/session"); csrf = null; codeNotices = false; return r; },
361
+ 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; teamsLive = r.signedIn === true && r.features?.includes(TEAMS_FEATURE) === true; } return r; },
362
+ async signIn(login, password) { retireReads(); teamsLive = false; 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; teamsLive = r.features?.includes(TEAMS_FEATURE) === true; } return r; },
363
+ async signOut() { retireReads(); const r = await call("DELETE", "/hub/v1/session"); csrf = null; codeNotices = false; roomsLive = false; teamsLive = false; return r; },
294
364
  catalog() { return call("GET", "/hub/v1/exposures"); },
295
365
  sharingPauseV1: true,
296
366
  sharing(exposureId, revision, sharingEpoch, paused) { return call("POST", `/hub/v1/exposures/${id(exposureId)}/sharing`, { revision, sharingEpoch, paused }); },
@@ -329,6 +399,101 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a), readTime
329
399
  },
330
400
  read(roomId, after = 0) { return call("GET", `/hub/v1/rooms/${id(roomId)}/messages?after=${id(after)}`); },
331
401
  chooseButtons(roomId, input) { return call("POST", `/hub/v1/rooms/${id(roomId)}/buttons`, input); },
402
+ // Hub rooms (docs/design/hub-rooms-split.md, seams 1, 3 and 5). The Hub speaks them once its session lists
403
+ // ROOMS_FEATURE; before that it has today's rooms (one asker, one agent), which roomList() still answers in the same
404
+ // shape (kind "direct", the old item under `legacy`), and whose messages stay with hub-chat-store.js.
405
+ roomsV1: true,
406
+ /** The Hub answers the rooms calls (seam 1) — otherwise only roomList() is meaningful. */
407
+ roomsLive() { return roomsLive; },
408
+ teamsLive() { return teamsLive; },
409
+ /**
410
+ * → { ok, rooms: [{ id, kind: "direct" | "group", name, people, agents, online, unread, lastAt, lastText, lastAuthor }] }.
411
+ * `?v=2` (Ridge, #3858): the combined list; GET /hub/v1/rooms itself stays direct-only for older cached tabs, and a
412
+ * server without rooms ignores the parameter (its answer is then normalised here).
413
+ */
414
+ async roomList() {
415
+ const r = await call("GET", "/hub/v1/rooms?v=2");
416
+ if (!r.ok || roomsLive) return r;
417
+ return { ...r, rooms: (Array.isArray(r.rooms) ? r.rooms : []).map(legacyRoom).filter(Boolean) };
418
+ },
419
+ /** → { ok, room, me: { role }, members: [Member], settings: { allMention, historyForNew } } */
420
+ room(roomId) { return call("GET", `/hub/v1/rooms/${id(roomId)}`); },
421
+ /** A group room: { name, people: [personId], teams: [teamId], groups: [groupId], agents: [exposureId], assistant }. */
422
+ createRoom(input) { return call("POST", "/hub/v1/rooms", input); },
423
+ /** { name?, allMention?, historyForNew?, assistant?, archived? } */
424
+ updateRoom(roomId, patch) { return call("PATCH", `/hub/v1/rooms/${id(roomId)}`, patch); },
425
+ /** One member: { kind: "person" | "team" | "group" | "agent" | "assistant", id? } (the assistant has no id). */
426
+ addRoomMember(roomId, member) { return call("POST", `/hub/v1/rooms/${id(roomId)}/members`, member); },
427
+ removeRoomMember(roomId, memberId) { return call("DELETE", `/hub/v1/rooms/${id(roomId)}/members/${id(memberId)}`); },
428
+ /** A page of Message, newest last: the latest `limit`, or those before the message `before`. */
429
+ roomMessages(roomId, { before, limit } = {}) {
430
+ const q = new URLSearchParams();
431
+ if (before) q.set("before", String(before));
432
+ if (Number.isSafeInteger(limit) && limit > 0) q.set("limit", String(limit));
433
+ const query = q.toString();
434
+ return call("GET", `/hub/v1/rooms/${id(roomId)}/messages${query ? `?${query}` : ""}`);
435
+ },
436
+ /** { text, mentions: ["all" | "assistant" | exposureId], replyTo?, files?: [fileId], idempotencyKey } → the stored Message. */
437
+ sendRoomMessage(roomId, { text, mentions = [], replyTo, files, idempotencyKey }) {
438
+ return call("POST", `/hub/v1/rooms/${id(roomId)}/messages`, { text, mentions, idempotencyKey,
439
+ ...(replyTo ? { replyTo } : {}), ...(Array.isArray(files) && files.length ? { files } : {}) });
440
+ },
441
+ markRoomRead(roomId, upTo) { return call("POST", `/hub/v1/rooms/${id(roomId)}/read`, { upTo }); },
442
+ /**
443
+ * The one live stream of everything this person may see (seam 1): `handlers[name](data)` for each of ROOM_EVENTS,
444
+ * on the tab's one stream (which also carries the notices). A refused stream (CLOSED) calls onClosed once; a
445
+ * transient drop reconnects by itself. → unsubscribe.
446
+ */
447
+ subscribeRooms(handlers = {}, onClosed = () => {}) {
448
+ if (!roomsLive) return () => {};
449
+ const mine = {};
450
+ for (const name of ROOM_EVENTS) if (typeof handlers[name] === "function") mine[name] = (data) => { if (data && typeof data === "object") handlers[name](data); };
451
+ return listen(streamUrl(codeNotices ? 3 : 2), mine, onClosed);
452
+ },
453
+ // Seam 3: agents enter a room by their owner's consent.
454
+ inviteToRoom(roomId, input) { return call("POST", `/hub/v1/rooms/${id(roomId)}/invitations`, input); },
455
+ invitations() { return call("GET", "/hub/v1/invitations"); },
456
+ acceptInvitation(invitationId) { return call("POST", `/hub/v1/invitations/${id(invitationId)}/accept`, {}); },
457
+ declineInvitation(invitationId) { return call("POST", `/hub/v1/invitations/${id(invitationId)}/decline`, {}); },
458
+ // Seam 5: teams, who may open rooms, and the administrator's list of rooms (names and members, no content).
459
+ teams() { return call("GET", "/hub/v1/teams"); },
460
+ team(teamId) { return call("GET", `/hub/v1/teams/${id(teamId)}`); },
461
+ createTeam(input) { return call("POST", "/hub/v1/teams", input); },
462
+ updateTeam(teamId, patch) { return call("PATCH", `/hub/v1/teams/${id(teamId)}`, patch); },
463
+ deleteTeam(teamId) { return call("DELETE", `/hub/v1/teams/${id(teamId)}`); },
464
+ async teamSuggestions(kind, q, teamId, signal) {
465
+ const s = new URLSearchParams({ kind: String(kind), q: String(q ?? "") });
466
+ if (teamId != null) s.set("teamId", String(teamId));
467
+ const out = await call("GET", `/hub/v1/teams/candidates?${s}`, undefined, signal);
468
+ return signal?.aborted ? { ok: false, status: 0, code: "unreachable" } : out;
469
+ },
470
+ roomCreators() { return call("GET", "/hub/v1/admin/rooms/creators"); },
471
+ saveRoomCreators(input) { return call("PUT", "/hub/v1/admin/rooms/creators", input); },
472
+ adminRooms() { return call("GET", "/hub/v1/admin/rooms"); },
473
+ // Track U2 (dev-claude2): pickers, roles, invitations, leave, the agent's rooms, admin rooms.
474
+ // Leaving is removeRoomMember(roomId, <my id>) (409 last-manager); `me.assistant` comes with roomList()'s answer.
475
+ /** The new-room and add-member pickers → { ok, candidates: [{ kind: "person" | "team" | "group" | "agent", id, name, people?, owner?: { name }, mine? }] }. */
476
+ roomCandidates(q, kind, signal) {
477
+ const s = new URLSearchParams({ q: String(q ?? "") });
478
+ if (kind) s.set("kind", kind);
479
+ return call("GET", `/hub/v1/rooms/candidates?${s}`, undefined, signal);
480
+ },
481
+ /**
482
+ * A chosen AD group's label and head count → { ok, kind: "group", id, name, people } (its direct members now, nested
483
+ * groups not followed; creating the room or adding the group reads the list again). 503 group-unavailable when the
484
+ * directory cannot read the whole list.
485
+ */
486
+ roomGroup(groupId) { return call("GET", `/hub/v1/rooms/candidates/group/${id(groupId)}`); },
487
+ /** 設為房間管理 / 改為成員. */
488
+ setRoomMemberRole(roomId, memberId, role) { return call("PATCH", `/hub/v1/rooms/${id(roomId)}/members/${id(memberId)}`, { role }); },
489
+ /** A room manager withdraws a pending (or clears an expired) invitation; 重新邀請 is a new inviteToRoom(). */
490
+ cancelRoomInvitation(roomId, invitationId) { return call("DELETE", `/hub/v1/rooms/${id(roomId)}/invitations/${id(invitationId)}`); },
491
+ /** The rooms one of my shared agents is in → { ok, rooms: [{ id, name, people, memberId }] }; 退出這個房間 is removeRoomMember(id, memberId). */
492
+ agentRooms(exposureId) { return call("GET", `/hub/v1/exposures/${id(exposureId)}/rooms`); },
493
+ /** 管理 → 房間: 加入自己成為房間管理 (the room gets a system line). */
494
+ joinRoomAsAdmin(roomId) { return call("POST", `/hub/v1/admin/rooms/${id(roomId)}/join`, {}); },
495
+ /** 管理 → 房間: 封存. */
496
+ archiveRoomAsAdmin(roomId, archived = true) { return call("PATCH", `/hub/v1/admin/rooms/${id(roomId)}`, { archived }); },
332
497
  pairings() { return call("GET", "/hub/v1/pairings"); },
333
498
  quickPairingV1: true,
334
499
  createQuickPairing(label) { return call("POST", "/hub/v1/quick-pairing", { label }); },
@@ -349,14 +514,7 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a), readTime
349
514
  pairingNoticeSnapshotV1: typeof EventSource !== "undefined",
350
515
  acknowledgePairingNotice(noticeId) { return call("POST", `/hub/v1/notices/${id(noticeId)}/ack`); },
351
516
  subscribePairingNotices(fn, onClosed = () => {}, version = 2) {
352
- if (typeof EventSource === "undefined") return () => {};
353
- const events = new EventSource(`/hub/v1/notices/events?v=${version === 3 && codeNotices ? 3 : 2}`); let live = true;
354
- 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 */ } });
355
- events.addEventListener("error", () => {
356
- // A refused handshake is CLOSED, unlike a transient disconnect that EventSource itself reconnects.
357
- if (live && events.readyState === 2) { live = false; events.close(); onClosed(); }
358
- });
359
- return () => { live = false; events.close(); };
517
+ return listen(streamUrl(version), { notices: (value) => { if (value && Array.isArray(value.notices)) fn(value.notices); } }, onClosed);
360
518
  },
361
519
  confirmPairing(pairingId, fingerprint) { return call("POST", `/hub/v1/pairings/${id(pairingId)}/confirm`, { fingerprint }); },
362
520
  companyJoinSettings() { return call("GET", "/hub/v1/admin/company-join"); },
@@ -402,6 +560,12 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a), readTime
402
560
  fetchDirectoryCa(input, signal) { return call("POST", "/hub/v1/admin/hub/directory/ca/fetch", input, signal); },
403
561
  /** This client has the group permissions calls (a cached older client does not: the pages then hide them). */
404
562
  groupPolicyV1: true,
563
+ // Track A (Sentinel): the room assistant's admin page.
564
+ assistantAdminV1: true,
565
+ assistantSettings() { return call("GET", "/hub/v1/admin/assistant"); },
566
+ saveAssistantSettings(input) { return call("PUT", "/hub/v1/admin/assistant", input); },
567
+ assistantUsage() { return call("GET", "/hub/v1/admin/assistant/usage"); },
568
+ stopRoomAssistant(roomId) { return call("POST", `/hub/v1/admin/assistant/rooms/${id(roomId)}/stop`); },
405
569
  };
406
570
  }
407
571
 
@@ -6,7 +6,7 @@ import { GroupSearch } from "./hub-group-search.js";
6
6
  import { hubClient } from "./hub-client.js";
7
7
  register("hubGrantPicker", {
8
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.",
9
+ title: "Allow access to {0}", kind: "Allow", person: "A person", group: "An AD security group", team: "A team", teamPick: "Choose a team", teamHint: "The team's current members may ask. Removing someone from the team ends that permission. The grant's expiry keeps running.", findPerson: "Find a person", query: "Name or login", hint: "Type 2 to 64 characters.",
10
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
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
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.",
@@ -14,7 +14,7 @@ register("hubGrantPicker", {
14
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
15
  },
16
16
  "zh-TW": {
17
- title: "允許向 {0} 提問", kind: "允許對象", person: "個人", group: "AD 安全性群組", findPerson: "尋找同仁", query: "姓名或登入帳號", hint: "請輸入 2 到 64 個字。",
17
+ title: "允許向 {0} 提問", kind: "允許對象", person: "個人", group: "AD 安全性群組", team: "團隊", teamPick: "選擇團隊", teamHint: "依團隊目前的成員允許提問;成員離開團隊後就不再適用這份權限,授權的到期時間照常計算。", findPerson: "尋找同仁", query: "姓名或登入帳號", hint: "請輸入 2 到 64 個字。",
18
18
  searching: "搜尋中…", none: "找不到符合的同仁。請多輸入幾個姓名或帳號的字。", more: "還有更多同仁符合,請多輸入幾個字。", pick: "選擇 {0}", choose: "選擇", change: "重新選擇對象",
19
19
  failed: "目前無法搜尋目錄,請再試一次。", unsupported: "這個目錄不支援這項搜尋。", limited: "搜尋太多次了,請稍後再試。", retry: "重新搜尋",
20
20
  days: "允許多久", day: "{0} 天", expiry: "最長 90 天,到期自動失效;移除授權也會結束其聊天存取權。",
@@ -55,6 +55,13 @@ function PeopleSearch({ search, disabled, onPick }) {
55
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
56
  </div>`;
57
57
  }
58
+ function TeamPick({ client, disabled, onPick }) {
59
+ const [answer, setAnswer] = useState(null), [retry, setRetry] = useState(0);
60
+ useEffect(() => { let live = true; Promise.resolve().then(() => client.teams()).then(out => { if (live) setAnswer(out); }, () => { if (live) setAnswer({ ok: false }); }); return () => { live = false; }; }, [client, retry]);
61
+ if (!answer) return html`<p class="note" role="status">${g("searching")}</p>`;
62
+ if (!answer.ok) return html`<p class="err" role="status">${g("failed")}</p><button type="button" class="btn btn-sm" disabled=${disabled} onClick=${() => setRetry(n => n + 1)}>${g("retry")}</button>`;
63
+ return html`<label class="field"><span>${g("teamPick")}</span><select data-grant-team value="" disabled=${disabled} onChange=${e => { const row = answer.teams?.find(row => row.id === e.target.value); if (row) onPick(row); }}><option value="">${g("teamPick")}</option>${(answer.teams || []).map(row => html`<option value=${row.id}>${row.name}</option>`)}</select></label>`;
64
+ }
58
65
  export function HubGrantPicker({ x, client, act, onClose }) {
59
66
  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
67
  const life = useRef(0), writing = useRef(false), controllers = useRef(new Set());
@@ -75,7 +82,7 @@ export function HubGrantPicker({ x, client, act, onClose }) {
75
82
  const submit = async event => {
76
83
  event?.preventDefault?.(); if (writing.current || !selected || client !== hubClient()) return;
77
84
  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 }
85
+ const subject = kind === "team" ? { kind: "team", teamId: selected.id } : kind === "group" ? { kind: "group", group: { realm: selected.realm, objectId: selected.objectId }, dn: selected.dn }
79
86
  : { kind: "person", person: { ...selected.person } };
80
87
  const input = { exposureId: x.id, exposureRevision: x.revision, days, subject, ...(kind === "person" ? { login: selected.login } : {}) };
81
88
  try {
@@ -87,12 +94,14 @@ export function HubGrantPicker({ x, client, act, onClose }) {
87
94
  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
95
  <form class="form hub-grant" data-grant-picker onSubmit=${submit}>
89
96
  ${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>`
97
+ <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>${client.teamsLive?.() === true ? html`<option value="team">${g("team")}</option>` : null}</select></label>
98
+ ${selected ? html`<div class="s-row"><span class="hub-row-text"><strong>${selected.name || 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
99
  : kind === "person" ? html`<${PeopleSearch} search=${search} disabled=${busy} onPick=${setSelected} />`
100
+ : kind === "team" ? html`<${TeamPick} client=${client} disabled=${busy} onPick=${setSelected} />`
93
101
  : html`<${GroupSearch} client=${groupClient} id="hubGrantGroup" disabled=${busy} unknownHint=${g("failed")} onUnsupported=${() => setUnsupported(true)} onPick=${p => setSelected({ ...p, realm: x.owner?.realm || "" })} />`}
94
102
  ${unsupported ? html`<p class="err" role="status">${g("unsupported")}</p>` : null}
95
103
  ${kind === "group" ? html`<p class="note">${g("groupHint")}</p>` : null}
104
+ ${kind === "team" ? html`<p class="note">${g("teamHint")}</p>` : null}
96
105
  <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
106
  <p class="note">${g("expiry")}</p>
98
107
  </form>