@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
@@ -0,0 +1,152 @@
1
+ // M-3092 (Hub rooms, track U): the Hub's conversation list, drawn as the Fleet chat draws its roster — the same row
2
+ // (`li.v-li > a.inst.v-inst`: avatar with its status dot, the name line and the second line), the same section head
3
+ // (`inst-head > side-label`, its count) and the same count badge (`nav-count`). docs/design/hub-rooms-ux.md §2:
4
+ // - two groups: 「房間」 (rooms: a square avatar with the name's first character, "3 人 · 12 個 Agent") and 「Agent」
5
+ // (chats with one agent: a round avatar with the agent's presence dot, its owner's name; 「Hub 助理」 last, "Hub 提供");
6
+ // - unread first, then by the last message; archived ones last in their group; an unread @ to me is marked;
7
+ // - a list from a Hub without rooms yet (`limited`: today's chats) shows no dot and no unread — that Hub has neither;
8
+ // - S-145: 「最愛」 first, as the Fleet sidebar's favourites (#1664): starred from the row's menu, in the order starred or
9
+ // moved (Edit), taken out of their own group; the same words, menu and marks (hub-room-favorites.js keeps them).
10
+ // Words: hub-room-strings.js (namespace hubRoom; #3850's flat keys).
11
+ import { html, useLayoutEffect, useRef } from "/assets/app-html.js";
12
+ import { t } from "/assets/app-i18n.js";
13
+ import { firstCharacter, MAX_FAVORITES } from "/assets/instance-nav.js";
14
+ import { Menu } from "/assets/ui-menu.js";
15
+ import { Icon } from "/assets/ui-icons.js";
16
+ import "./hub-room-strings.js";
17
+ import { presenceDot } from "./hub-room-presence.js";
18
+
19
+ const tr = (key, ...a) => t(`hubRoom.${key}`, ...a);
20
+ /** The Fleet sidebar's own words for favourites (view.*, with named values; agentRow.*): no Hub copy of them. */
21
+ const tv = (key, values = {}) => t(`view.${key}`).replace(/\{(\w+)\}/g, (m, k) => (k in values ? String(values[k]) : m));
22
+
23
+ /**
24
+ * Today's room (GET /hub/v1/rooms from a Hub without rooms) as a list row — for a client older than this page, whose
25
+ * rooms() answers today's items and has no roomList() (an open tab after an upgrade). The same mapping as
26
+ * hub-client.js legacyRoom() (tests/hub-room-list-3092.test.ts keeps the two equal).
27
+ */
28
+ export function listRoomOf(item) {
29
+ if (!item || typeof item !== "object" || typeof item.id !== "string") return null;
30
+ return { id: item.id, kind: "direct", name: String(item.exposureName || ""), people: 1, agents: 1, online: null, unread: 0,
31
+ lastAt: Number.isFinite(item.lastAt) ? item.lastAt : 0, lastText: "", lastAuthor: "",
32
+ agent: { exposureId: String(item.exposureId || ""), owner: { name: String(item.ownerName || "") }, presence: null }, limited: true, legacy: item };
33
+ }
34
+ /** The rooms list from whichever client this page has: roomList() when it can, else rooms() mapped by listRoomOf(). */
35
+ export function readRoomList(client) {
36
+ if (typeof client.roomList === "function") return client.roomList();
37
+ return client.rooms().then((r) => (r && r.ok ? { ...r, rooms: (Array.isArray(r.rooms) ? r.rooms : []).map(listRoomOf).filter(Boolean) } : r));
38
+ }
39
+
40
+ /** A room's counts, "3 人 · 12 個 Agent" / "1 person · 2 agents" — singular when one. */
41
+ export function countsLine(people, agents) {
42
+ const p = Math.max(0, Number(people) || 0), a = Math.max(0, Number(agents) || 0);
43
+ return `${p === 1 ? tr("peopleOne") : tr("peopleMany", String(p))} · ${a === 1 ? tr("agentsOne") : tr("agentsMany", String(a))}`;
44
+ }
45
+
46
+ const rank = (r) => (r.archived ? 2 : r.unread > 0 ? 0 : 1);
47
+ const order = (a, b) => rank(a) - rank(b) || (b.lastAt || 0) - (a.lastAt || 0) || String(a.name).localeCompare(String(b.name));
48
+
49
+ /**
50
+ * The list's groups (spec §2): the favourites (S-145: `favs`, ids in their order), rooms, then the chats with one agent
51
+ * (the Hub assistant's last). A favourite is in 「最愛」 only, not also in its own group. `q` filters by the name, an
52
+ * agent's owner and the last line. → [{ key: "favorites" | "rooms" | "agents", items }] (an empty group is left out).
53
+ */
54
+ export function groupRooms(rooms, q = "", favs = []) {
55
+ const needle = String(q || "").trim().toLowerCase();
56
+ const hit = (r) => !needle || [r.name, r.agent?.owner?.name, r.lastText].some((v) => String(v || "").toLowerCase().includes(needle));
57
+ const all = (Array.isArray(rooms) ? rooms : []).filter((r) => r && typeof r.id === "string");
58
+ const byId = new Map(all.map((r) => [r.id, r])), starred = new Set(Array.isArray(favs) ? favs : []);
59
+ const list = all.filter((r) => !starred.has(r.id) && hit(r));
60
+ const groups = [
61
+ { key: "favorites", items: [...starred].map((id) => byId.get(id)).filter((r) => r && hit(r)) },
62
+ { key: "rooms", items: list.filter((r) => r.kind === "group").sort(order) },
63
+ { key: "agents", items: list.filter((r) => r.kind !== "group").sort((a, b) => (a.assistant ? 1 : 0) - (b.assistant ? 1 : 0) || order(a, b)) },
64
+ ];
65
+ return groups.filter((g) => g.items.length);
66
+ }
67
+
68
+ /** One row's view: its avatar, two lines, its count and @ mark. */
69
+ export function rowView(r) {
70
+ const group = r.kind === "group", limited = r.limited === true;
71
+ // Today's chats keep what their row said: closed, or a question waiting (the Fleet's working dot), else its owner.
72
+ const closed = limited && r.legacy?.state === "closed", waiting = limited && !closed && r.legacy?.waiting === true;
73
+ const line2 = group ? countsLine(r.people, r.agents)
74
+ : closed ? t("hubChat.tagClosed") : waiting ? t("hubChat.waiting")
75
+ : r.assistant ? tr("providedByHub") : String(r.agent?.owner?.name || "");
76
+ return {
77
+ title: r.assistant ? tr("hubAssistant") : String(r.name || ""), line2,
78
+ avatar: { square: group, text: firstCharacter(r.assistant ? tr("hubAssistant") : String(r.name || "?")) || "?" },
79
+ // The Hub assistant's dot is its own state (spec §10: 待命, or 暫時無法回答 when it can't answer): `presence` on its row.
80
+ dot: group ? null : limited ? waiting ? "busy" : null : r.assistant ? presenceDot(r.presence || "idle")
81
+ // The shared mapping (hub-room-presence.js, #3853); a row whose agent has no presence yet shows no dot (not "offline").
82
+ : r.agent?.presence ? presenceDot(r.agent.presence) : null,
83
+ closed,
84
+ unread: limited ? 0 : Math.max(0, Number(r.unread) || 0), mentioned: !limited && r.mentioned === true, archived: r.archived === true || closed,
85
+ };
86
+ }
87
+
88
+ const listTime = (ms) => {
89
+ if (!ms) return "";
90
+ const d = new Date(ms), now = new Date();
91
+ return d.toDateString() === now.toDateString() ? d.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" }) : d.toLocaleDateString(undefined, { month: "numeric", day: "numeric" });
92
+ };
93
+
94
+ /**
95
+ * The groups as the Fleet roster draws them. `current`: the open room's id; `onGo(e, room)`: a row was chosen; `star`
96
+ * (useRoomStar): the favourites — each row's menu stars it, Edit moves the starred ones (none: no menu, no 「最愛」).
97
+ */
98
+ export function HubRoomRows({ rooms, q = "", current = null, href, onGo, star = null }) {
99
+ const favs = star ? star.ids : [];
100
+ const filtered = !!String(q || "").trim();
101
+ // #1664's focus rule: after a star or a move the row is drawn elsewhere — its menu button gets the focus back.
102
+ // (The phone's home list and the sidebar can both be in the page: the one on screen.)
103
+ const focusRow = useRef(null);
104
+ useLayoutEffect(() => {
105
+ if (!focusRow.current || typeof document === "undefined") return;
106
+ const id = focusRow.current;
107
+ focusRow.current = null;
108
+ const btn = [...document.querySelectorAll(".hub-rooms > [data-room] > .inst-row-menu > button")]
109
+ .find((el) => el.parentElement.parentElement.getAttribute("data-room") === id && el.offsetParent !== null);
110
+ btn?.focus();
111
+ });
112
+ const styledMenus = typeof getComputedStyle === "function" && typeof document !== "undefined"
113
+ && getComputedStyle(document.documentElement).getPropertyValue?.("--agent-menu-version")?.trim() === "1";
114
+ // The row's ⋯ is the Fleet's 28px row-menu button (`.inst-row-menu > .icon-btn`); `icon-btn-row` names it as its own kind
115
+ // beside the page's 36px icon buttons (the Hub UI gate: one height per button kind).
116
+ const row = (r, fav, i, count) => {
117
+ const v = rowView(r), on = current === r.id, starred = favs.includes(r.id), full = !starred && favs.length >= MAX_FAVORITES;
118
+ const items = star ? [
119
+ { key: "favorite", label: t(`agentRow.${starred ? "remove" : "add"}`), icon: "star", disabled: full, iconClass: starred ? "menu-starred" : undefined,
120
+ title: full ? tv("favFull", { max: MAX_FAVORITES }) : undefined, onSelect: () => { focusRow.current = r.id; star.toggle(r.id); } },
121
+ ...(fav && star.editing ? [
122
+ { key: "up", label: tv("favUp", { name: v.title }), icon: "up", disabled: filtered || i === 0,
123
+ title: filtered ? tv("favFiltered") : tv("favUp", { name: v.title }), onSelect: () => { if (!filtered) { focusRow.current = r.id; star.move(r.id, -1); } } },
124
+ { key: "down", label: tv("favDown", { name: v.title }), icon: "down", disabled: filtered || i === count - 1,
125
+ title: filtered ? tv("favFiltered") : tv("favDown", { name: v.title }), onSelect: () => { if (!filtered) { focusRow.current = r.id; star.move(r.id, 1); } } },
126
+ ] : []),
127
+ ] : [];
128
+ return html`<li key=${r.id} class="v-li two-line" data-room=${r.id}>
129
+ <a class=${`inst v-inst${on ? " active" : ""}${starred ? " inst-favorite" : ""}${v.archived ? " hub-room-archived" : ""}`} href=${href(r)} aria-current=${on ? "page" : undefined}
130
+ onClick=${(e) => onGo(e, r)}>
131
+ <span class=${`av${v.avatar.square ? " av-square" : ""}`}><span class="av-text" aria-hidden="true">${v.avatar.text}</span>${v.dot
132
+ ? html`<span class=${`av-dot dot ${v.dot}`} aria-hidden="true"></span>` : null}</span>
133
+ <span class="inst-text"><span class="inst-line"><span class="inst-name" title=${v.title}>${v.title}</span><span class="v-meta">${listTime(r.lastAt)}</span></span>
134
+ <span class="inst-line inst-line2"><span class="inst-alt" title=${v.line2 || undefined}>${v.archived ? `${tr("archived")} · ${v.line2}` : v.line2}</span>
135
+ ${v.mentioned ? html`<span class="hub-room-at" title=${tr("mentionedYou")}>@</span>` : null}
136
+ ${v.unread ? html`<span class="nav-count" title=${tr("unreadN", String(v.unread))}>${v.unread > 99 ? "99+" : v.unread}</span>` : null}</span></span>
137
+ </a>${items.length ? html`<${Menu} cls=${`inst-workspace inst-row-menu agent-menu${starred ? " is-favorite" : ""}`} fit=${true} topLayer=${true}
138
+ ownerKey=${r.id} label=${t("agentRow.actions", v.title)} items=${items} triggerClass="icon-btn icon-btn-row"
139
+ trigger=${styledMenus ? html`<span class="inst-menu-star" aria-hidden="true">${starred ? html`<${Icon} name="star" size=${14} />` : null}</span><span class="inst-menu-more" aria-hidden="true"><${Icon} name="more" size=${16} /></span>` : undefined} />` : null}</li>`;
140
+ };
141
+ return html`${groupRooms(rooms, q, favs).map((g) => g.key === "favorites"
142
+ // #1664: 最愛 — always open, its rows moved with ↑ ↓ in Edit, named in the page's language.
143
+ // Its head is drawn as its neighbours' (「房間」, 「Agent」), with the Fleet's star before the name and its Edit after the count.
144
+ ? html`<div key=${g.key} class=${`hub-room-group hub-room-favs${star?.editing ? " fav-editing" : ""}`} data-group="favorites" role="group" aria-label=${tv("favorites")}>
145
+ <div class="inst-head fav-head"><h2 class="side-label"><${Icon} name="star" size=${12} cls="fav-mark" />${tv("favorites")}</h2><span class="count">${g.items.length}</span>
146
+ ${g.items.length > 1 ? html`<button type="button" class="chip-btn fav-edit" aria-pressed=${star.editing ? "true" : "false"} onClick=${() => star.setEditing(!star.editing)}>
147
+ ${star.editing ? tv("favDone") : html`<${Icon} name="star" size=${12} />${tv("favEdit")}`}</button>` : null}</div>
148
+ <ul class="hub-rooms" role="list">${g.items.map((r, i) => row(r, true, i, g.items.length))}</ul></div>`
149
+ : html`<div key=${g.key} class="hub-room-group" data-group=${g.key}>
150
+ <div class="inst-head"><h2 class="side-label">${tr(g.key === "rooms" ? "roomsGroup" : "agentsGroup")}</h2><span class="count">${g.items.length}</span></div>
151
+ <ul class="hub-rooms" role="list">${g.items.map((r) => row(r, false, 0, 0))}</ul></div>`)}`;
152
+ }
@@ -0,0 +1,12 @@
1
+ // Hub rooms, the right-hand members panel (docs/design/hub-rooms-ux.md section 5): 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("hubRoomMembers", {
7
+ en: { fewer: "Show fewer", ownerOf: "Owner: {0}", removeFailed: "It was not removed. Try again.", agents: "Agents", ownerAgent: "{0}'s agent", ownerAgentLatin: "{0}'s agent",
8
+ noAgents: "No agents yet. A room manager can add or invite them in Room settings." },
9
+ "zh-TW": { fewer: "收合", ownerOf: "擁有者:{0}", removeFailed: "沒有移除,請再試一次。", agents: "Agent", ownerAgent: "{0}的 Agent", ownerAgentLatin: "{0} 的 Agent",
10
+ noAgents: "還沒有 Agent。房間管理可以在房間設定加入或邀請。" },
11
+ });
12
+ export const hm = (key, ...args) => t(`hubRoomMembers.${key}`, ...args);
@@ -0,0 +1,104 @@
1
+ // Hub rooms, the right-hand members panel (docs/design/hub-rooms-ux.md section 5): the people, the agents in presence
2
+ // order, the room assistant, who can see what, and (for a room manager) the way to Room settings. Clicking an agent
3
+ // opens a small card: @ it here, chat with it one-to-one (only when I may ask it), and, for a manager, remove it.
4
+ // The dots use the Fleet sidebar's colours (.dot ok / busy / warn / off), so a state reads the same in both.
5
+ // The shell owns the room's detail (and reads it again on member.changed); this panel applies presence.changed in place.
6
+ import { html, useEffect, useState } from "/assets/app-html.js";
7
+ import { hubClient } from "./hub-client.js";
8
+ import { hm } from "./hub-room-members-strings.js";
9
+ import { hroom } from "./hub-room-strings.js";
10
+ import { collapse, headerCounts, presenceDot, presenceView, sortAgents } from "./hub-room-presence.js";
11
+ import { hn, linkRoomsU2Css } from "./hub-room-new-strings.js";
12
+
13
+ linkRoomsU2Css();
14
+
15
+ const AGENTS_SHOWN = 8;
16
+
17
+ /**
18
+ * The dot class and words for one member, from the shared rooms presence mapping (hub-room-presence.js: reason codes,
19
+ * known notes in the viewer's language, the same online count as the list). Only two things are this panel's own: a
20
+ * person added before their first Hub sign-in (they see the room when they first sign in), and the assistant's idle
21
+ * row reading 「待命 · Hub 提供」.
22
+ */
23
+ export function memberStatus(m) {
24
+ if (m.kind === "person" && m.signedIn === false) return { dot: "off", text: hn("neverSignedIn") };
25
+ const v = presenceView(m);
26
+ const word = m.kind === "assistant" && v.word === "stIdle" ? hroom("assistantIdleHub") : hroom(v.word);
27
+ const note = v.noteKey ? hroom(v.noteKey) : v.noteText;
28
+ return { dot: presenceDot(v.dot), text: note ? `${word} · ${note}` : word };
29
+ }
30
+
31
+ /** 「林小華的 Agent」, but 「Alex 的 Agent」: a name ending in a Latin letter or digit takes a space before 的 (Lumen). */
32
+ export function ownerAgent(name) {
33
+ return hm(/[A-Za-z0-9]$/.test(name) ? "ownerAgentLatin" : "ownerAgent", name);
34
+ }
35
+
36
+ /**
37
+ * The panel, in the right rail of a group room. Props (one mount line in the shell):
38
+ * - client;
39
+ * - roomId;
40
+ * - detail: the shell's own GET /hub/v1/rooms/:id answer { room, me: { id?, role }, members, settings, invited }. The
41
+ * shell reads it again on member.changed, so it is not read here. Only presence.changed is applied here, in place,
42
+ * until the next detail;
43
+ * - onMention(member): puts 「@name 」 in the composer;
44
+ * - onOpenChat(member): opens the one-to-one, offered only for an agent whose member row says `canAsk`;
45
+ * - onSettings().
46
+ */
47
+ export function RoomMembersPanel({ client = hubClient(), roomId, detail, onMention, onOpenChat, onSettings } = {}) {
48
+ const [presence, setPresence] = useState({}), [open, setOpen] = useState(null), [expanded, setExpanded] = useState(false);
49
+ const [busy, setBusy] = useState(false), [failed, setFailed] = useState(false), [gone, setGone] = useState({});
50
+ useEffect(() => { setPresence({}); setGone({}); }, [detail]);
51
+ useEffect(() => client.subscribeRooms?.({
52
+ // The whole state each time: presence, its reason code and note. One the event omits is cleared (undefined), so a
53
+ // stale reason or note never outlives the presence it came with.
54
+ "presence.changed": (e) => { if (e?.roomId === roomId && typeof e.memberId === "string") setPresence(old => ({ ...old, [e.memberId]: { presence: e.presence, presenceReason: e.presenceReason, presenceNote: e.presenceNote } })); },
55
+ }) ?? (() => {}), [client, roomId]);
56
+ if (!detail || !Array.isArray(detail.members)) return html`<aside class="hub-room-members" aria-busy="true"></aside>`;
57
+ const data = { role: detail.me?.role === "manager" ? "manager" : "member",
58
+ members: detail.members.filter(m => m && !gone[m.id]).map(m => presence[m.id] ? { ...m, ...presence[m.id] } : m) };
59
+ const meId = detail.me?.id;
60
+ const manager = data.role === "manager";
61
+ // Me first, then who is online, then the offline and those who have never signed in (spec 8224c4675).
62
+ const personRank = (m) => m.id === meId ? 0 : m.presence === "online" ? 1 : 2;
63
+ const people = data.members.filter(m => m.kind === "person").sort((a, b) => personRank(a) - personRank(b));
64
+ const agents = sortAgents(data.members), heads = headerCounts(data.members);
65
+ const assistant = data.members.find(m => m.kind === "assistant");
66
+ const fold = collapse(agents, AGENTS_SHOWN), shown = expanded ? agents : fold.shown;
67
+ const remove = async (m) => {
68
+ setBusy(true); setFailed(false);
69
+ const r = await client.removeRoomMember(roomId, m.id);
70
+ setBusy(false);
71
+ if (r?.ok) { setOpen(null); setGone(old => ({ ...old, [m.id]: true })); } // the shell reads the room again on member.changed
72
+ else setFailed(true);
73
+ };
74
+ // An agent's second line names whose it is beside its state (「處理中 · 林小華的 Agent」), always shown, not only on hover.
75
+ const row = (m, extra = null) => {
76
+ const v = memberStatus(m), owner = (m.kind === "agent" || m.kind === "later") && m.owner?.name ? ownerAgent(m.owner.name) : "";
77
+ return html`<span class="hub-member-name">${m.name}${extra}</span><span class="hub-member-state"><span class=${`dot ${v.dot}`} aria-hidden="true"></span><span>${v.text}</span>${owner ? html`<span class="hub-member-owner">· ${owner}</span>` : null}</span>`;
78
+ };
79
+ return html`<aside class="hub-room-members">
80
+ <section><h4>${heads.member}</h4>
81
+ <ul>${people.map(m => html`<li class="hub-member" key=${m.id}>${row(m, html`${m.id === meId ? html` <span class="tag">${hroom("roleYou")}</span>` : null}${m.role === "manager" ? html` <span class="tag">${hroom("roleManager")}</span>` : null}`)}</li>`)}</ul>
82
+ </section>
83
+ ${agents.length ? null : html`<section class="hub-room-no-agents"><h4>${hm("agents")}</h4><p class="note">${hm("noAgents")}</p></section>`}
84
+ ${agents.length ? html`<section><h4>${heads.agent}</h4>
85
+ <ul>${shown.map(m => html`<li class="hub-member hub-member-agent" key=${m.id}>
86
+ <button type="button" class="hub-member-open" title=${m.owner?.name ? hm("ownerOf", m.owner.name) : ""} aria-expanded=${open === m.id} onClick=${() => { setFailed(false); setOpen(open === m.id ? null : m.id); }}>${row(m)}</button>
87
+ ${open === m.id ? html`<div class="hub-member-card" role="group" aria-label=${m.name}>
88
+ <strong>${m.name}</strong>${m.owner?.name ? html`<small class="note">${hm("ownerOf", m.owner.name)}</small>` : null}
89
+ <small class="note">${memberStatus(m).text}</small>
90
+ <div class="field-row">
91
+ <button type="button" class="btn" onClick=${() => { setOpen(null); onMention?.(m); }}>${hroom("mentionHere")}</button>
92
+ ${m.canAsk === true ? html`<button type="button" class="btn" onClick=${() => { setOpen(null); onOpenChat?.(m); }}>${hroom("chatOneToOne")}</button>` : null}
93
+ ${manager ? html`<button type="button" class="btn btn-danger" disabled=${busy} onClick=${() => remove(m)}>${hroom("removeFromRoom")}</button>` : null}
94
+ </div>
95
+ ${failed ? html`<p class="note" role="alert">${hm("removeFailed")}</p>` : null}
96
+ </div>` : null}
97
+ </li>`)}</ul>
98
+ ${fold.rest ? html`<button type="button" class="btn btn-link hub-members-more" onClick=${() => setExpanded(!expanded)}>${expanded ? hm("fewer") : hroom("moreN", fold.rest)}</button>` : null}
99
+ </section>` : null}
100
+ ${assistant ? html`<section><ul><li class="hub-member hub-member-assistant">${row({ ...assistant, name: hroom("roomAssistant") })}</li></ul></section>` : null}
101
+ <section class="hub-room-who"><h4>${hroom("whoSees")}</h4><p class="note">${hroom("whoSeesRoom")}</p></section>
102
+ ${manager ? html`<button type="button" class="btn btn-link hub-room-settings-link" onClick=${() => onSettings?.()}>${hroom("roomSettings")}</button>` : null}
103
+ </aside>`;
104
+ }
@@ -0,0 +1,46 @@
1
+ // Hub rooms, the New room dialog and its pickers (docs/design/hub-rooms-ux.md section 6; the pickers are reused by Room
2
+ // settings, section 7): only the words the shared room vocabulary (hub-room-strings.js, namespace hubRoom) does not have.
3
+ // A module of its own, so a tab holding an older dictionary still has every word (upgrade skew).
4
+ import { register, t } from "/assets/app-i18n.js";
5
+
6
+ register("hubRoomNew", {
7
+ en: {
8
+ agents: "Agents",
9
+ withCount: "{0} · {1} people",
10
+ withCountOne: "{0} · 1 person",
11
+ peopleLimit: "This room would have {0} people, over the limit of {1}. Choose a smaller AD group or team instead.",
12
+ groupUnavailable: "Can't read the members of “{0}” right now. Try again later.",
13
+ neverSignedIn: "Hasn't signed in to the Hub yet",
14
+ teamAgents: "Every member's agents in “{0}”",
15
+ remove: "Remove {0}",
16
+ noMatch: "Nothing matches.",
17
+ searchFailed: "Search did not work. Try again.",
18
+ createFailed: "The room was not created. Try again.",
19
+ nameTooLong: "A room name is at most 60 characters.",
20
+ },
21
+ "zh-TW": {
22
+ agents: "Agent",
23
+ withCount: "{0} · {1} 人",
24
+ withCountOne: "{0} · 1 人",
25
+ peopleLimit: "這個房間會有 {0} 人,超過上限 {1} 人。請改選較小的 AD 群組或團隊。",
26
+ groupUnavailable: "目前無法讀取「{0}」的成員,請稍後再試。",
27
+ neverSignedIn: "還沒登入過 Hub",
28
+ teamAgents: "「{0}」所有人的 Agent",
29
+ remove: "移除 {0}",
30
+ noMatch: "找不到符合的結果。",
31
+ searchFailed: "搜尋沒有成功,請再試一次。",
32
+ createFailed: "房間沒有建立,請再試一次。",
33
+ nameTooLong: "房間名稱最多 60 個字。",
34
+ },
35
+ });
36
+ export const hn = (key, ...args) => t(`hubRoomNew.${key}`, ...args);
37
+
38
+ /** The U2 screens' stylesheet, linked once (an older hub-chat.css or hub-owner.css lacks these rules). */
39
+ export function linkRoomsU2Css(doc = typeof document !== "undefined" ? document : null) {
40
+ try {
41
+ if (!doc || !doc.head || doc.querySelector('link[data-hub-rooms-u2-css="1"]')) return;
42
+ const link = doc.createElement("link");
43
+ link.setAttribute("rel", "stylesheet"); link.setAttribute("href", "/assets/hub-rooms-u2.css"); link.setAttribute("data-hub-rooms-u2-css", "1");
44
+ doc.head.appendChild(link);
45
+ } catch { /* the screens still work without it */ }
46
+ }
@@ -0,0 +1,135 @@
1
+ // Hub rooms, the New room dialog (docs/design/hub-rooms-ux.md section 6), opened from the list's 「+ 新房間」 row (shown
2
+ // only to people who may start rooms). Name (required, at most 60 characters), members (people, teams, AD groups; I am
3
+ // always in, as the manager), agents (mine join at once; someone else's are invited and join when their owner agrees;
4
+ // a team's every member's agents can be invited), and the room assistant when the Hub offers one. 建立 creates the
5
+ // room, sends the invitations, and opens the room; the room's first lines (created, invited) are the server's.
6
+ // RoomPicker is the search-and-tags field, reused by Room settings (section 7).
7
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
8
+ import { Dialog } from "/assets/ui-dialog.js";
9
+ import { hubClient } from "./hub-client.js";
10
+ import { hroom } from "./hub-room-strings.js";
11
+ import { hn, linkRoomsU2Css } from "./hub-room-new-strings.js";
12
+
13
+ linkRoomsU2Css();
14
+
15
+ const NAME_MAX = 60;
16
+ const SEARCH_DELAY_MS = 200;
17
+
18
+ /** One picked item's words: a person or agent by name, a team or AD group with its people, a team's agents. */
19
+ export function pickLabel(item) {
20
+ if (item.kind === "team-agents") return hn("teamAgents", item.name);
21
+ if ((item.kind === "team" || item.kind === "group") && Number.isFinite(item.people)) return item.people === 1 ? hn("withCountOne", item.name) : hn("withCount", item.name, item.people);
22
+ return item.name;
23
+ }
24
+ const keyOf = (item) => `${item.kind}:${item.id}`;
25
+
26
+ /**
27
+ * A search box over GET /hub/v1/rooms/candidates and the picked items as tags.
28
+ * - kinds: the candidate kinds searched, e.g. ["person", "team", "group"] or ["agent", "team"]. In an agent picker, a team
29
+ * result stands for "invite every member's agents" (kind "team-agents").
30
+ * - picked, onChange(next), exclude: keys ("kind:id") never offered, e.g. members already in the room.
31
+ * - note: a refusal the owner shows under the field (the 100-person limit, a group the directory could not read).
32
+ * A picked AD group is read first (client.roomGroup): its tag shows its head count, and a group the directory cannot
33
+ * read whole is not added — the other picks stay.
34
+ */
35
+ export function RoomPicker({ client, kinds, picked, onChange, placeholder, label, id, exclude = [], fixed = null, note = "" } = {}) {
36
+ const [q, setQ] = useState(""), [results, setResults] = useState(null), [failed, setFailed] = useState(false), [groupNote, setGroupNote] = useState("");
37
+ const asked = useRef(0), timer = useRef(null), latest = useRef(picked), live = useRef(true);
38
+ latest.current = picked;
39
+ const agents = kinds.includes("agent");
40
+ useEffect(() => { live.current = true; return () => { live.current = false; clearTimeout(timer.current); }; }, []);
41
+ const search = (text) => {
42
+ setQ(text); clearTimeout(timer.current);
43
+ const mine = ++asked.current;
44
+ if (!text.trim()) { setResults(null); setFailed(false); return; }
45
+ timer.current = setTimeout(async () => {
46
+ const answers = await Promise.all(kinds.map(kind => client.roomCandidates(text.trim(), kind)));
47
+ if (mine !== asked.current) return;
48
+ if (answers.some(r => !r?.ok)) { setFailed(true); setResults(null); return; }
49
+ setFailed(false);
50
+ setResults(answers.flatMap(r => Array.isArray(r.candidates) ? r.candidates : [])
51
+ .map(c => agents && c.kind === "team" ? { ...c, kind: "team-agents" } : c)
52
+ .filter(c => c && typeof c.id === "string" && typeof c.name === "string"));
53
+ }, SEARCH_DELAY_MS);
54
+ };
55
+ const taken = new Set([...exclude, ...picked.map(keyOf)]);
56
+ const offer = (results ?? []).filter(c => !taken.has(keyOf(c)));
57
+ const pick = async (item) => {
58
+ setQ(""); setResults(null); setGroupNote("");
59
+ if (item.kind !== "group" || typeof client.roomGroup !== "function") { onChange([...latest.current, item]); return; }
60
+ const r = await client.roomGroup(item.id);
61
+ if (!live.current || latest.current.some(x => keyOf(x) === keyOf(item))) return;
62
+ if (!r?.ok) { setGroupNote(hn("groupUnavailable", item.name)); return; }
63
+ onChange([...latest.current, { ...item, ...(typeof r.name === "string" && r.name ? { name: r.name } : {}), ...(Number.isSafeInteger(r.people) ? { people: r.people } : {}) }]);
64
+ };
65
+ return html`<div class="field hub-room-picker">
66
+ <label for=${id}><span>${label}</span></label>
67
+ <ul class="hub-room-tags">
68
+ ${fixed}
69
+ ${picked.map(item => html`<li class="tag" key=${keyOf(item)}>${pickLabel(item)}${agents && item.kind === "agent" && !item.mine || item.kind === "team-agents" ? html` · ${hroom("invitePending")}` : null}
70
+ <button type="button" class="chip-btn" aria-label=${hn("remove", pickLabel(item))} onClick=${() => onChange(picked.filter(x => keyOf(x) !== keyOf(item)))}>×</button></li>`)}
71
+ </ul>
72
+ <input id=${id} type="search" autocomplete="off" placeholder=${placeholder} value=${q} onInput=${(e) => search(e.target.value)} />
73
+ ${failed ? html`<p class="note" role="alert">${hn("searchFailed")}</p>` : null}
74
+ ${groupNote || note ? html`<p class="note hub-room-picker-note" role="alert">${groupNote || note}</p>` : null}
75
+ ${results && !failed ? offer.length ? html`<ul class="hub-room-results" role="listbox" aria-label=${label}>${offer.map(c => html`<li key=${keyOf(c)}>
76
+ <button type="button" role="option" class="hub-room-result" onClick=${() => { void pick(c); }}>${pickLabel(c)}${c.owner?.name && c.kind === "agent" ? html` <small class="note">${c.owner.name}</small>` : null}${c.kind === "agent" && !c.mine ? html` <small class="note">${hroom("invitePending")}</small>` : null}</button></li>`)}</ul>`
77
+ : html`<p class="note">${hn("noMatch")}</p>` : null}
78
+ </div>`;
79
+ }
80
+
81
+ /** Props: client, onClose(), onOpenRoom(roomId), assistant (whether the Hub offers the room assistant; read from the list when not given). */
82
+ export function NewRoomDialog({ client = hubClient(), onClose, onOpenRoom, assistant } = {}) {
83
+ const [name, setName] = useState(""), [people, setPeople] = useState([]), [agents, setAgents] = useState([]), [withAssistant, setWithAssistant] = useState(false);
84
+ const [offered, setOffered] = useState(assistant === true), [busy, setBusy] = useState(false), [error, setError] = useState(""), [peopleNote, setPeopleNote] = useState("");
85
+ const nameRef = useRef(null), sent = useRef(false);
86
+ useEffect(() => {
87
+ if (typeof assistant === "boolean") { setOffered(assistant); return; }
88
+ let live = true;
89
+ void client.roomList().then(r => { if (live) setOffered(r?.ok === true && r.me?.assistant === true); });
90
+ return () => { live = false; };
91
+ }, [client, assistant]);
92
+ const create = async () => {
93
+ if (sent.current) return;
94
+ const title = name.trim();
95
+ if (!title) { setError(hroom("nameRequired")); nameRef.current?.focus(); return; }
96
+ if ([...title].length > NAME_MAX) { setError(hn("nameTooLong")); nameRef.current?.focus(); return; }
97
+ sent.current = true; setBusy(true); setError(""); setPeopleNote("");
98
+ const ids = (kind, from = people) => from.filter(x => x.kind === kind).map(x => x.id);
99
+ const r = await client.createRoom({ name: title, people: ids("person"), teams: ids("team"), groups: ids("group"),
100
+ agents: agents.filter(x => x.kind === "agent" && x.mine).map(x => x.id), assistant: offered && withAssistant });
101
+ const roomId = r?.ok ? r.room?.id : null;
102
+ if (!roomId) {
103
+ sent.current = false; setBusy(false);
104
+ // Nothing was created. Too many people: say how many, keep every pick. A group the directory could not read:
105
+ // drop that group only.
106
+ const group = r?.status === 503 && r.code === "group-unavailable" ? people.find(x => x.kind === "group" && x.id === r.group) : null;
107
+ if (r?.status === 409 && r.code === "people-limit" && Number.isSafeInteger(r.people)) setPeopleNote(hn("peopleLimit", r.people, r.limit ?? 100));
108
+ else if (group) { setPeople(people.filter(x => x !== group)); setPeopleNote(hn("groupUnavailable", group.name)); }
109
+ else setError(hn("createFailed"));
110
+ return;
111
+ }
112
+ const others = agents.filter(x => x.kind === "agent" && !x.mine).map(x => x.id), teams = agents.filter(x => x.kind === "team-agents").map(x => x.id);
113
+ // The room exists now: invitations are best effort, and the room's own list shows what was sent.
114
+ if (others.length) await client.inviteToRoom(roomId, { agents: others });
115
+ for (const team of teams) await client.inviteToRoom(roomId, { team });
116
+ onOpenRoom?.(roomId); onClose?.();
117
+ };
118
+ const me = html`<li class="tag hub-room-me">${hroom("roleYou")} · ${hroom("roleManager")}</li>`;
119
+ return html`<${Dialog} title=${hroom("newRoomTitle")} onClose=${() => onClose?.()} busy=${busy} cls="hub-room-new"
120
+ actions=${html`<button type="button" class="btn" disabled=${busy} onClick=${() => onClose?.()}>${hroom("cancel")}</button>
121
+ <button type="button" class="btn btn-primary" disabled=${busy} onClick=${() => { void create(); }}>${hroom("create")}</button>`}>
122
+ <form class="form" onSubmit=${(e) => { e.preventDefault(); void create(); }}>
123
+ <label class="field"><span>${hroom("name")}</span>
124
+ <input id="hubRoomName" ref=${nameRef} maxlength=${NAME_MAX} autocomplete="off" placeholder=${hroom("namePlaceholder")} value=${name}
125
+ aria-invalid=${error === hroom("nameRequired") || error === hn("nameTooLong") ? "true" : "false"} onInput=${(e) => { setName(e.target.value); if (error) setError(""); }} /></label>
126
+ ${error ? html`<p class="note hub-room-new-error" role="alert">${error}</p>` : null}
127
+ <${RoomPicker} client=${client} id="hubRoomPeople" kinds=${["person", "team", "group"]} label=${hroom("members")} placeholder=${hroom("addPeople")}
128
+ picked=${people} onChange=${(next) => { setPeople(next); setPeopleNote(""); }} fixed=${me} note=${peopleNote} />
129
+ <${RoomPicker} client=${client} id="hubRoomAgents" kinds=${["agent", "team"]} label=${hn("agents")} placeholder=${hroom("addAgents")}
130
+ picked=${agents} onChange=${setAgents} />
131
+ ${offered ? html`<label class="check"><input id="hubRoomAssistant" class="s-ui-toggle" type="checkbox" role="switch" checked=${withAssistant}
132
+ onChange=${(e) => setWithAssistant(e.target.checked)} /><span>${hroom("addAssistant")}</span></label>` : null}
133
+ </form>
134
+ </${Dialog}>`;
135
+ }
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Hub rooms presence (docs/design/hub-rooms-ux.md §5): the status dot and word for a
3
+ * member, the agents sort order, the Members/Agents header counts, and the
4
+ * overflow split behind "… 其餘 N 個". Pure helpers, no DOM: words come from
5
+ * hub-room-strings.js (namespace hubRoom) in the viewer's language, so this
6
+ * module imports it for its registration side effect and reads through hroom.
7
+ */
8
+ import { hroom } from "./hub-room-strings.js";
9
+
10
+ /** Spec §5 rows, in list order: 處理中, 待命, 暫停, 離線, 上線時回答. */
11
+ const GROUP_ORDER = ["working", "idle", "paused", "offline", "later"];
12
+
13
+ /** Presence value → status dot (spec §5 colours: green idle counts as online). */
14
+ const DOT = { online: "online", idle: "online", working: "working", paused: "paused", offline: "offline", later: "offline" };
15
+
16
+ /** Presence value → hubRoom word key. */
17
+ const WORD = { online: "stOnline", idle: "stIdle", working: "stWorking", paused: "stPaused", offline: "stOffline", later: "stLater" };
18
+
19
+ /**
20
+ * Fixture/server presence-note display text → hubRoom reason key. The note arrives
21
+ * as display text (the fixture's contract), so the known ones map back to their
22
+ * keys here; anything else passes through unchanged (it is text, never a key).
23
+ * Once R2 serves presenceReason codes, those win over this legacy text path.
24
+ */
25
+ const NOTE_KEY = { "額度用完": "pauseQuota", "等待登入": "pauseSignIn", "等待核准": "pauseApproval", "需要更新 AgEnD": "needsUpdate" };
26
+
27
+ /**
28
+ * R2 presenceReason codes → display overrides (hub-rooms track R/C contract).
29
+ * A mapped reason wins over any legacy presenceNote text, but only when the
30
+ * member's presence matches: patches can merge a stale reason onto a newer
31
+ * presence that omits it, so a lingering reason must never override a fresh
32
+ * presence. An unmapped code is ignored so the presence mapping stands and
33
+ * no raw code ever reaches the UI.
34
+ * - quota/auth/approval/operator/capacity apply to paused only (yellow; only
35
+ * the first three have a reason word, there is no operator/capacity word
36
+ * in hubRoom yet).
37
+ * - update applies to offline only (grey with its own word).
38
+ * - idle: no-op, the presence already says idle (autowake sleep).
39
+ * - error/stuck/unknown: no mapping defined — the presence mapping stands.
40
+ * - stopped/crashed: grey dot (offline) + the "stopped" word, gated on
41
+ * presence "paused" as C only sends these paused (crashed is normalised
42
+ * to stopped server-side, so both map to stStopped here).
43
+ */
44
+ const REASON = {
45
+ quota: { when: ["paused"], dot: "paused", word: "stPaused", noteKey: "pauseQuota" },
46
+ auth: { when: ["paused"], dot: "paused", word: "stPaused", noteKey: "pauseSignIn" },
47
+ approval: { when: ["paused"], dot: "paused", word: "stPaused", noteKey: "pauseApproval" },
48
+ update: { when: ["offline"], dot: "offline", word: "needsUpdate" },
49
+ operator: { when: ["paused"], dot: "paused", word: "stPaused" },
50
+ capacity: { when: ["paused"], dot: "paused", word: "stPaused" },
51
+ stopped: { when: ["paused"], dot: "offline", word: "stStopped" },
52
+ crashed: { when: ["paused"], dot: "offline", word: "stStopped" },
53
+ };
54
+
55
+ const groupIndex = (presence) => { const i = GROUP_ORDER.indexOf(presence); return i < 0 ? GROUP_ORDER.length : i; };
56
+
57
+ /**
58
+ * One member's status: { dot, word, noteKey?, noteText? }. dot is the status
59
+ * colour; word is always a hubRoom key; noteKey is too when the member's
60
+ * presenceNote matches a known reason, while an unrecognised note goes to
61
+ * noteText and is shown verbatim — never passed through hroom, so an unknown
62
+ * reason can never render as a raw hubRoom.* key. An offline member whose note
63
+ * is 需要更新 AgEnD shows as offline with its own word; a paused room assistant
64
+ * shows 暫時無法回答.
65
+ */
66
+ export function presenceView(member) {
67
+ const presence = member?.presence;
68
+ if (member?.kind === "assistant") {
69
+ return presence === "paused"
70
+ ? { dot: "paused", word: "stAssistantDown" }
71
+ : { dot: DOT[presence] ?? "offline", word: WORD[presence] ?? "stOffline" };
72
+ }
73
+ const reason = REASON[member?.presenceReason];
74
+ if (reason && reason.when.includes(presence)) return { dot: reason.dot, word: reason.word, ...(reason.noteKey ? { noteKey: reason.noteKey } : {}) };
75
+ const noteKey = NOTE_KEY[member?.presenceNote];
76
+ if (presence === "offline" && noteKey === "needsUpdate") return { dot: "offline", word: "needsUpdate" };
77
+ const view = { dot: DOT[presence] ?? "offline", word: WORD[presence] ?? "stOffline" };
78
+ if (noteKey) view.noteKey = noteKey;
79
+ else if (member?.presenceNote) view.noteText = member.presenceNote;
80
+ return view;
81
+ }
82
+
83
+ /**
84
+ * The Fleet sidebar dot class for a presence value, or for a presence + reason
85
+ * pair (shared with the list rows). A reason the table knows wins when its
86
+ * `when` gate matches the presence — so a stopped agent reads grey, not yellow.
87
+ * Unknown or gated-out reasons fall back to the plain presence dot.
88
+ */
89
+ const DOT_CLASS = { online: "ok", idle: "ok", working: "busy", paused: "warn", offline: "off", later: "off" };
90
+ export function presenceDot(presence, reason) {
91
+ const r = typeof reason === "string" ? REASON[reason] : undefined;
92
+ const dot = (r && r.when.includes(presence) ? r.dot : undefined) ?? DOT[presence] ?? "offline";
93
+ return DOT_CLASS[dot] ?? "off";
94
+ }
95
+
96
+ /**
97
+ * The Agents list order (spec §5): working, then idle (待命), paused, offline,
98
+ * reply-later; stable by name within each group. Only kind "agent"/"later"
99
+ * members sort here — people have their own row and the room assistant has its.
100
+ */
101
+ export function sortAgents(members) {
102
+ return members
103
+ .filter((m) => m.kind === "agent" || m.kind === "later")
104
+ .map((m, i) => [m, i])
105
+ .sort(([a, ai], [b, bi]) => groupIndex(a.presence) - groupIndex(b.presence) || (a.name < b.name ? -1 : a.name > b.name ? 1 : ai - bi))
106
+ .map(([m]) => m);
107
+ }
108
+
109
+ /** "Agent · 12(線上 9)" and "成員 · 3(線上 2)" in the viewer's language. */
110
+ export function headerCounts(members) {
111
+ const agents = members.filter((m) => m.kind === "agent" || m.kind === "later");
112
+ const people = members.filter((m) => m.kind === "person");
113
+ const online = (list) => list.filter((m) => m.presence === "online" || m.presence === "idle" || m.presence === "working").length;
114
+ return {
115
+ agent: hroom("agentsHead", agents.length, online(agents)),
116
+ member: hroom("membersHead", people.length, online(people)),
117
+ };
118
+ }
119
+
120
+ /** The first `limit` rows shown, the rest folded behind "… 其餘 N 個". */
121
+ export function collapse(list, limit = 8) {
122
+ return { shown: list.slice(0, limit), rest: Math.max(0, list.length - limit) };
123
+ }
@@ -0,0 +1,26 @@
1
+ // Hub rooms, Room settings (docs/design/hub-rooms-ux.md section 7): 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
3
+ // still has every word (upgrade skew).
4
+ import { register, t } from "/assets/app-i18n.js";
5
+
6
+ register("hubRoomSettings", {
7
+ en: {
8
+ expiredRow: "{0} ({1}) · invitation expired", expiredRowNoOwner: "{0} · invitation expired",
9
+ pendingRowNoOwner: "{0} · invited, waiting for the owner",
10
+ inviteAgain: "Invite again",
11
+ rowMenu: "More for {0}",
12
+ save: "Save",
13
+ saveFailed: "That was not saved. Try again.",
14
+ assistantSwitch: "Room assistant",
15
+ },
16
+ "zh-TW": {
17
+ expiredRow: "{0}({1})· 邀請已過期", expiredRowNoOwner: "{0} · 邀請已過期",
18
+ pendingRowNoOwner: "{0} · 已邀請,等擁有者同意",
19
+ inviteAgain: "重新邀請",
20
+ rowMenu: "{0} 的更多動作",
21
+ save: "儲存",
22
+ saveFailed: "沒有儲存,請再試一次。",
23
+ assistantSwitch: "房間助理",
24
+ },
25
+ });
26
+ export const hs = (key, ...args) => t(`hubRoomSettings.${key}`, ...args);