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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (373) hide show
  1. package/dist/agent-cli-instructions.md +8 -4
  2. package/dist/agent-whats-new.js +7 -7
  3. package/dist/agent-whats-new.js.map +1 -1
  4. package/dist/auth-api.js +7 -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/cross-instance-messaging/SKILL.md +5 -3
  41. package/dist/general-knowledge/skills/hub/SKILL.md +161 -4
  42. package/dist/general-knowledge/skills/multi-channel/SKILL.md +1 -1
  43. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +18 -7
  44. package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +1 -1
  45. package/dist/grok-delivery-proof.d.ts +24 -0
  46. package/dist/grok-delivery-proof.js +124 -0
  47. package/dist/grok-delivery-proof.js.map +1 -0
  48. package/dist/hub/assistant/admin-types.d.ts +43 -0
  49. package/dist/hub/assistant/admin-types.js +2 -0
  50. package/dist/hub/assistant/admin-types.js.map +1 -0
  51. package/dist/hub/assistant/claude-host.d.ts +17 -0
  52. package/dist/hub/assistant/claude-host.js +300 -0
  53. package/dist/hub/assistant/claude-host.js.map +1 -0
  54. package/dist/hub/assistant/context.d.ts +3 -0
  55. package/dist/hub/assistant/context.js +7 -0
  56. package/dist/hub/assistant/context.js.map +1 -0
  57. package/dist/hub/assistant/fleet-host.d.ts +19 -0
  58. package/dist/hub/assistant/fleet-host.js +28 -0
  59. package/dist/hub/assistant/fleet-host.js.map +1 -0
  60. package/dist/hub/assistant/runner.d.ts +64 -0
  61. package/dist/hub/assistant/runner.js +239 -0
  62. package/dist/hub/assistant/runner.js.map +1 -0
  63. package/dist/hub/assistant/service.d.ts +51 -0
  64. package/dist/hub/assistant/service.js +143 -0
  65. package/dist/hub/assistant/service.js.map +1 -0
  66. package/dist/hub/assistant/store.d.ts +3 -0
  67. package/dist/hub/assistant/store.js +65 -0
  68. package/dist/hub/assistant/store.js.map +1 -0
  69. package/dist/hub/assistant/types.d.ts +60 -0
  70. package/dist/hub/assistant/types.js +2 -0
  71. package/dist/hub/assistant/types.js.map +1 -0
  72. package/dist/hub/catalog.js +22 -3
  73. package/dist/hub/catalog.js.map +1 -1
  74. package/dist/hub/client.d.ts +10 -0
  75. package/dist/hub/client.js +48 -8
  76. package/dist/hub/client.js.map +1 -1
  77. package/dist/hub/compose/member.d.ts +8 -1
  78. package/dist/hub/compose/member.js +224 -58
  79. package/dist/hub/compose/member.js.map +1 -1
  80. package/dist/hub/compose/server.d.ts +11 -1
  81. package/dist/hub/compose/server.js +68 -11
  82. package/dist/hub/compose/server.js.map +1 -1
  83. package/dist/hub/directory/admission.d.ts +15 -0
  84. package/dist/hub/directory/admission.js +56 -0
  85. package/dist/hub/directory/admission.js.map +1 -0
  86. package/dist/hub/directory/directory.d.ts +1 -1
  87. package/dist/hub/directory/directory.js +63 -0
  88. package/dist/hub/directory/directory.js.map +1 -1
  89. package/dist/hub/directory/types.d.ts +13 -0
  90. package/dist/hub/directory/types.js.map +1 -1
  91. package/dist/hub/group-policy/admin-control.d.ts +1 -0
  92. package/dist/hub/group-policy/admin-control.js +4 -2
  93. package/dist/hub/group-policy/admin-control.js.map +1 -1
  94. package/dist/hub/group-policy/admin-facts.d.ts +1 -0
  95. package/dist/hub/group-policy/admin-facts.js +2 -1
  96. package/dist/hub/group-policy/admin-facts.js.map +1 -1
  97. package/dist/hub/group-policy/admin-read.d.ts +1 -0
  98. package/dist/hub/group-policy/admin-read.js +3 -2
  99. package/dist/hub/group-policy/admin-read.js.map +1 -1
  100. package/dist/hub/group-policy/errors.d.ts +9 -0
  101. package/dist/hub/group-policy/errors.js +13 -0
  102. package/dist/hub/group-policy/errors.js.map +1 -0
  103. package/dist/hub/group-policy/store.d.ts +3 -9
  104. package/dist/hub/group-policy/store.js +5 -29
  105. package/dist/hub/group-policy/store.js.map +1 -1
  106. package/dist/hub/http/compose.d.ts +1 -0
  107. package/dist/hub/http/compose.js +429 -14
  108. package/dist/hub/http/compose.js.map +1 -1
  109. package/dist/hub/http/core.d.ts +6 -5
  110. package/dist/hub/http/core.js +74 -48
  111. package/dist/hub/http/core.js.map +1 -1
  112. package/dist/hub/http/deps.d.ts +18 -0
  113. package/dist/hub/http/schema.js +8 -0
  114. package/dist/hub/http/schema.js.map +1 -1
  115. package/dist/hub/init/member-certificate.d.ts +1 -0
  116. package/dist/hub/init/member-certificate.js +39 -0
  117. package/dist/hub/init/member-certificate.js.map +1 -0
  118. package/dist/hub/init/plan-digest.js +1 -0
  119. package/dist/hub/init/plan-digest.js.map +1 -1
  120. package/dist/hub/invitations.d.ts +96 -0
  121. package/dist/hub/invitations.js +292 -0
  122. package/dist/hub/invitations.js.map +1 -0
  123. package/dist/hub/join/certificate-trust.d.ts +13 -0
  124. package/dist/hub/join/certificate-trust.js +41 -0
  125. package/dist/hub/join/certificate-trust.js.map +1 -0
  126. package/dist/hub/join/certificate.d.ts +11 -0
  127. package/dist/hub/join/certificate.js +67 -0
  128. package/dist/hub/join/certificate.js.map +1 -0
  129. package/dist/hub/join/client.d.ts +5 -0
  130. package/dist/hub/join/client.js +30 -3
  131. package/dist/hub/join/client.js.map +1 -1
  132. package/dist/hub/join/http.js +5 -3
  133. package/dist/hub/join/http.js.map +1 -1
  134. package/dist/hub/join/local.d.ts +32 -1
  135. package/dist/hub/join/local.js +116 -11
  136. package/dist/hub/join/local.js.map +1 -1
  137. package/dist/hub/join/service.d.ts +17 -0
  138. package/dist/hub/join/service.js +12 -0
  139. package/dist/hub/join/service.js.map +1 -1
  140. package/dist/hub/join/trust.d.ts +9 -0
  141. package/dist/hub/join/trust.js +35 -0
  142. package/dist/hub/join/trust.js.map +1 -1
  143. package/dist/hub/member/pairing-api.js +9 -1
  144. package/dist/hub/member/pairing-api.js.map +1 -1
  145. package/dist/hub/member/room-ask.d.ts +137 -0
  146. package/dist/hub/member/room-ask.js +358 -0
  147. package/dist/hub/member/room-ask.js.map +1 -0
  148. package/dist/hub/member-journal.d.ts +18 -1
  149. package/dist/hub/member-journal.js +76 -3
  150. package/dist/hub/member-journal.js.map +1 -1
  151. package/dist/hub/member-origin.d.ts +177 -0
  152. package/dist/hub/member-origin.js +314 -0
  153. package/dist/hub/member-origin.js.map +1 -0
  154. package/dist/hub/pairing-notices.d.ts +1 -0
  155. package/dist/hub/pairing-notices.js +2 -1
  156. package/dist/hub/pairing-notices.js.map +1 -1
  157. package/dist/hub/pairing.d.ts +8 -0
  158. package/dist/hub/pairing.js +32 -5
  159. package/dist/hub/pairing.js.map +1 -1
  160. package/dist/hub/protocol.d.ts +159 -0
  161. package/dist/hub/protocol.js +19 -1
  162. package/dist/hub/protocol.js.map +1 -1
  163. package/dist/hub/roles/clock.d.ts +18 -0
  164. package/dist/hub/roles/clock.js +58 -0
  165. package/dist/hub/roles/clock.js.map +1 -0
  166. package/dist/hub/roles/cutover-marker.d.ts +57 -0
  167. package/dist/hub/roles/cutover-marker.js +26 -0
  168. package/dist/hub/roles/cutover-marker.js.map +1 -0
  169. package/dist/hub/roles/cutover.js +3 -17
  170. package/dist/hub/roles/cutover.js.map +1 -1
  171. package/dist/hub/roles/read.d.ts +7 -3
  172. package/dist/hub/roles/read.js +9 -1
  173. package/dist/hub/roles/read.js.map +1 -1
  174. package/dist/hub/rooms/admin.d.ts +45 -0
  175. package/dist/hub/rooms/admin.js +105 -0
  176. package/dist/hub/rooms/admin.js.map +1 -0
  177. package/dist/hub/rooms/agents.d.ts +74 -0
  178. package/dist/hub/rooms/agents.js +333 -0
  179. package/dist/hub/rooms/agents.js.map +1 -0
  180. package/dist/hub/rooms/assistant.d.ts +44 -0
  181. package/dist/hub/rooms/assistant.js +179 -0
  182. package/dist/hub/rooms/assistant.js.map +1 -0
  183. package/dist/hub/rooms/context.d.ts +10 -0
  184. package/dist/hub/rooms/context.js +24 -0
  185. package/dist/hub/rooms/context.js.map +1 -0
  186. package/dist/hub/rooms/direct-view.d.ts +39 -0
  187. package/dist/hub/rooms/direct-view.js +38 -0
  188. package/dist/hub/rooms/direct-view.js.map +1 -0
  189. package/dist/hub/rooms/directory.d.ts +35 -0
  190. package/dist/hub/rooms/directory.js +98 -0
  191. package/dist/hub/rooms/directory.js.map +1 -0
  192. package/dist/hub/rooms/schema.d.ts +11 -0
  193. package/dist/hub/rooms/schema.js +73 -0
  194. package/dist/hub/rooms/schema.js.map +1 -0
  195. package/dist/hub/rooms/service.d.ts +449 -0
  196. package/dist/hub/rooms/service.js +581 -0
  197. package/dist/hub/rooms/service.js.map +1 -0
  198. package/dist/hub/rooms/types.d.ts +79 -0
  199. package/dist/hub/rooms/types.js +2 -0
  200. package/dist/hub/rooms/types.js.map +1 -0
  201. package/dist/hub/rooms.d.ts +7 -1
  202. package/dist/hub/rooms.js +30 -5
  203. package/dist/hub/rooms.js.map +1 -1
  204. package/dist/hub/runtime.d.ts +8 -0
  205. package/dist/hub/runtime.js +57 -3
  206. package/dist/hub/runtime.js.map +1 -1
  207. package/dist/hub/server.d.ts +25 -0
  208. package/dist/hub/server.js +63 -5
  209. package/dist/hub/server.js.map +1 -1
  210. package/dist/hub/sessions.js +1 -1
  211. package/dist/hub/sessions.js.map +1 -1
  212. package/dist/hub/settings-commit.d.ts +6 -1
  213. package/dist/hub/settings-commit.js +15 -0
  214. package/dist/hub/settings-commit.js.map +1 -1
  215. package/dist/hub/settings-directory-recovery.d.ts +5 -0
  216. package/dist/hub/settings-directory-recovery.js +11 -1
  217. package/dist/hub/settings-directory-recovery.js.map +1 -1
  218. package/dist/hub/settings-member-address-control.d.ts +84 -0
  219. package/dist/hub/settings-member-address-control.js +150 -0
  220. package/dist/hub/settings-member-address-control.js.map +1 -0
  221. package/dist/hub/settings-member-address-decision.d.ts +229 -0
  222. package/dist/hub/settings-member-address-decision.js +318 -0
  223. package/dist/hub/settings-member-address-decision.js.map +1 -0
  224. package/dist/hub/settings-member-address-http.d.ts +9 -0
  225. package/dist/hub/settings-member-address-http.js +78 -0
  226. package/dist/hub/settings-member-address-http.js.map +1 -0
  227. package/dist/hub/settings-member-address-network.d.ts +2 -0
  228. package/dist/hub/settings-member-address-network.js +22 -0
  229. package/dist/hub/settings-member-address-network.js.map +1 -0
  230. package/dist/hub/settings-member-address-notices.d.ts +22 -0
  231. package/dist/hub/settings-member-address-notices.js +21 -0
  232. package/dist/hub/settings-member-address-notices.js.map +1 -0
  233. package/dist/hub/settings-member-address-policy.d.ts +21 -0
  234. package/dist/hub/settings-member-address-policy.js +34 -0
  235. package/dist/hub/settings-member-address-policy.js.map +1 -0
  236. package/dist/hub/settings-member-address.d.ts +64 -0
  237. package/dist/hub/settings-member-address.js +239 -0
  238. package/dist/hub/settings-member-address.js.map +1 -0
  239. package/dist/hub/socket.d.ts +2 -0
  240. package/dist/hub/socket.js +2 -0
  241. package/dist/hub/socket.js.map +1 -1
  242. package/dist/hub/teams/types.d.ts +41 -0
  243. package/dist/hub/teams/types.js +2 -0
  244. package/dist/hub/teams/types.js.map +1 -0
  245. package/dist/hub/tls.d.ts +47 -0
  246. package/dist/hub/tls.js +23 -6
  247. package/dist/hub/tls.js.map +1 -1
  248. package/dist/hub/types.d.ts +51 -3
  249. package/dist/hub/validation.d.ts +1 -1
  250. package/dist/hub/validation.js +2 -2
  251. package/dist/hub/validation.js.map +1 -1
  252. package/dist/hub/web-origin.d.ts +20 -7
  253. package/dist/hub/web-origin.js +26 -15
  254. package/dist/hub/web-origin.js.map +1 -1
  255. package/dist/hub-pilot-trust-settings.d.ts +4 -0
  256. package/dist/hub-pilot-trust-settings.js +13 -0
  257. package/dist/hub-pilot-trust-settings.js.map +1 -0
  258. package/dist/human-delivery-receipts.d.ts +4 -2
  259. package/dist/human-delivery-receipts.js +20 -13
  260. package/dist/human-delivery-receipts.js.map +1 -1
  261. package/dist/inbound-presentation.d.ts +28 -0
  262. package/dist/inbound-presentation.js +48 -0
  263. package/dist/inbound-presentation.js.map +1 -0
  264. package/dist/instance-lifecycle.js +1 -0
  265. package/dist/instance-lifecycle.js.map +1 -1
  266. package/dist/instructions.d.ts +4 -2
  267. package/dist/instructions.js +7 -4
  268. package/dist/instructions.js.map +1 -1
  269. package/dist/locale.js +14 -0
  270. package/dist/locale.js.map +1 -1
  271. package/dist/log-service.d.ts +3 -0
  272. package/dist/log-service.js +39 -22
  273. package/dist/log-service.js.map +1 -1
  274. package/dist/log-steps.d.ts +56 -1
  275. package/dist/log-steps.js +318 -56
  276. package/dist/log-steps.js.map +1 -1
  277. package/dist/needs-you-hub.js +6 -2
  278. package/dist/needs-you-hub.js.map +1 -1
  279. package/dist/needs-you.d.ts +5 -1
  280. package/dist/needs-you.js +4 -8
  281. package/dist/needs-you.js.map +1 -1
  282. package/dist/office-share-page.js +1 -1
  283. package/dist/office-share-page.js.map +1 -1
  284. package/dist/outbound-handlers.d.ts +1 -0
  285. package/dist/outbound-handlers.js +6 -0
  286. package/dist/outbound-handlers.js.map +1 -1
  287. package/dist/outbound-schemas.d.ts +1 -0
  288. package/dist/outbound-schemas.js +1 -0
  289. package/dist/outbound-schemas.js.map +1 -1
  290. package/dist/queued-handoffs.d.ts +3 -1
  291. package/dist/queued-handoffs.js +1 -1
  292. package/dist/queued-handoffs.js.map +1 -1
  293. package/dist/runtime-transcript-source.d.ts +2 -0
  294. package/dist/runtime-transcript-source.js +23 -1
  295. package/dist/runtime-transcript-source.js.map +1 -1
  296. package/dist/settings-api.d.ts +1 -0
  297. package/dist/settings-api.js +15 -8
  298. package/dist/settings-api.js.map +1 -1
  299. package/dist/settings-baseline.d.ts +3 -0
  300. package/dist/settings-baseline.js +2 -2
  301. package/dist/settings-baseline.js.map +1 -1
  302. package/dist/settings-effect.d.ts +3 -0
  303. package/dist/settings-effect.js +12 -2
  304. package/dist/settings-effect.js.map +1 -1
  305. package/dist/topic-commands.js +2 -1
  306. package/dist/topic-commands.js.map +1 -1
  307. package/dist/transcript-jsonl.d.ts +24 -0
  308. package/dist/transcript-jsonl.js +72 -22
  309. package/dist/transcript-jsonl.js.map +1 -1
  310. package/dist/transcript-monitor.d.ts +5 -1
  311. package/dist/transcript-monitor.js +65 -3
  312. package/dist/transcript-monitor.js.map +1 -1
  313. package/dist/transcript-needles.d.ts +1 -1
  314. package/dist/transcript-needles.js +1 -1
  315. package/dist/transcript-records.d.ts +2 -1
  316. package/dist/transcript-records.js.map +1 -1
  317. package/dist/transcript-sources.d.ts +4 -0
  318. package/dist/transcript-sources.js +2 -0
  319. package/dist/transcript-sources.js.map +1 -1
  320. package/dist/ui/agent-details-settings.js +10 -1
  321. package/dist/ui/chat-activity.js +2 -2
  322. package/dist/ui/fleet-canvas.js +5 -2
  323. package/dist/ui/fleet-office-card.js +4 -2
  324. package/dist/ui/fleet-org.js +2 -0
  325. package/dist/ui/hub-admin-rooms-strings.js +28 -0
  326. package/dist/ui/hub-admin-rooms.js +77 -0
  327. package/dist/ui/hub-assistant-admin-strings.js +26 -0
  328. package/dist/ui/hub-assistant-admin.js +85 -0
  329. package/dist/ui/hub-client.js +170 -14
  330. package/dist/ui/hub-invitations-strings.js +30 -0
  331. package/dist/ui/hub-invitations.js +108 -0
  332. package/dist/ui/hub-join-one-strings.js +2 -0
  333. package/dist/ui/hub-pairing-form-strings.js +48 -0
  334. package/dist/ui/hub-pilot-trust-strings.js +27 -0
  335. package/dist/ui/hub-pilot-trust.js +41 -0
  336. package/dist/ui/hub-room-composer.js +113 -0
  337. package/dist/ui/hub-room-favorites.js +90 -0
  338. package/dist/ui/hub-room-list.js +152 -0
  339. package/dist/ui/hub-room-members-strings.js +12 -0
  340. package/dist/ui/hub-room-members.js +104 -0
  341. package/dist/ui/hub-room-new-strings.js +46 -0
  342. package/dist/ui/hub-room-new.js +135 -0
  343. package/dist/ui/hub-room-presence.js +123 -0
  344. package/dist/ui/hub-room-settings-strings.js +26 -0
  345. package/dist/ui/hub-room-settings.js +134 -0
  346. package/dist/ui/hub-room-strings.js +222 -0
  347. package/dist/ui/hub-room-thread.js +262 -0
  348. package/dist/ui/hub-room-unread.js +51 -0
  349. package/dist/ui/hub-room-working.js +29 -0
  350. package/dist/ui/log-row.js +14 -5
  351. package/dist/ui/panel-details.js +6 -1
  352. package/dist/ui/panel-hub.js +91 -49
  353. package/dist/ui/panel-needs.js +2 -0
  354. package/dist/ui/settings-hub-company-join.js +31 -11
  355. package/dist/ui/settings-hub-connection.js +9 -3
  356. package/dist/ui/settings-hub-member-address.js +205 -0
  357. package/dist/ui/settings-hub-section.js +2 -0
  358. package/dist/ui/settings-hub.js +10 -4
  359. package/dist/ui/shared/app-i18n.js +2 -2
  360. package/dist/ui/shared/app-needs.js +3 -0
  361. package/dist/ui/shared/app-shell.js +4 -1
  362. package/dist/ui/shared/app.css +5 -0
  363. package/dist/ui/shared/chat-render.js +10 -0
  364. package/dist/ui/shared/chat-thread.js +14 -5
  365. package/dist/ui/shared/hub-chat.css +17 -0
  366. package/dist/ui/shared/hub-rooms-u2.css +42 -0
  367. package/dist/ui/shared/model-observation.js +16 -0
  368. package/dist/ui/shared/stale-tab.css +6 -0
  369. package/dist/ui/shared/stale-tab.js +50 -0
  370. package/dist/web-api.d.ts +2 -0
  371. package/dist/web-api.js +6 -2
  372. package/dist/web-api.js.map +1 -1
  373. package/package.json +1 -1
@@ -0,0 +1,108 @@
1
+ // Hub rooms, invitations on the owner's side (docs/design/hub-rooms-ux.md section 8; seam 3 in hub-rooms-split.md).
2
+ // A room manager invited one of my shared agents; I agree (it joins the room) or decline. Two places show the same list:
3
+ // the Invitations page (the shell's sidebar row 「邀請」 with its count opens it) and the top of My shared agents. The list
4
+ // follows the rooms stream's invitation.changed, so an answer given in another tab, or an invitation that lapsed after
5
+ // 7 days, leaves both places at once.
6
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
7
+ import { hubClient } from "./hub-client.js";
8
+ import { hi } from "./hub-invitations-strings.js";
9
+ import { hroom } from "./hub-room-strings.js";
10
+ import { linkRoomsU2Css } from "./hub-room-new-strings.js";
11
+
12
+ linkRoomsU2Css();
13
+
14
+ /** The pending invitations to my agents: { list (null while loading), error, reload, answer(id, accept) → Promise<boolean> }. */
15
+ export function useInvitations(client = hubClient()) {
16
+ const [list, setList] = useState(null), [error, setError] = useState(false);
17
+ const live = useRef(true), asked = useRef(0);
18
+ const reload = async () => {
19
+ const mine = ++asked.current;
20
+ const r = await client.invitations();
21
+ if (!live.current || mine !== asked.current) return;
22
+ if (r?.ok && Array.isArray(r.invitations)) { setList(r.invitations.filter(valid)); setError(false); }
23
+ else setError(true);
24
+ };
25
+ useEffect(() => {
26
+ live.current = true; void reload();
27
+ const off = client.subscribeRooms?.({ "invitation.changed": () => { void reload(); } }) ?? (() => {});
28
+ return () => { live.current = false; off(); };
29
+ }, [client]);
30
+ const answer = async (invitationId, accept) => {
31
+ const r = await (accept ? client.acceptInvitation(invitationId) : client.declineInvitation(invitationId));
32
+ if (!live.current) return r;
33
+ if (r?.ok) setList(old => old ? old.filter(x => x.id !== invitationId) : old);
34
+ else if (r?.status === 404) { setList(old => old ? old.filter(x => x.id !== invitationId) : old); void reload(); }
35
+ return r;
36
+ };
37
+ return { list, error, reload, answer };
38
+ }
39
+ const valid = (x) => x && typeof x.id === "string" && x.room && typeof x.room.name === "string" && x.agent && typeof x.agent.name === "string";
40
+
41
+ /**
42
+ * The invitations themselves, each with 同意 / 不要. Nothing when there are none (My shared agents shows no empty box).
43
+ * heading: the list's own 「邀請」 title — false where the page already says it (the invitations page's header).
44
+ */
45
+ export function InvitationsList({ client = hubClient(), heading = true } = {}) { // onOpenRoom: not used — the owner is not a member of the inviting room
46
+ const { list, error, reload, answer } = useInvitations(client);
47
+ const [busy, setBusy] = useState(null), [note, setNote] = useState(null), inflight = useRef(false);
48
+ if (error && !list) return html`<p class="note hub-invitations-error" role="alert">${hi("loadFailed")} <button type="button" class="btn btn-link" onClick=${() => { void reload(); }}>${hi("retry")}</button></p>`;
49
+ if (!list?.length) return note ? html`<p class="note" role="status">${note.text}</p>` : null;
50
+ const act = async (item, accept) => {
51
+ if (inflight.current) return; // one answer at a time, even before the disabled buttons are drawn
52
+ inflight.current = true; setBusy(item.id); setNote(null);
53
+ const r = await answer(item.id, accept);
54
+ inflight.current = false; setBusy(null);
55
+ if (!r?.ok) setNote({ id: item.id, text: r?.status === 404 ? hi("gone") : hi("failed") });
56
+ };
57
+ return html`<section class="hub-invitations" aria-label=${hi("invitations")}>
58
+ ${heading ? html`<h3>${hi("invitations")}</h3>` : null}
59
+ ${list.map(item => html`<article class="hub-invitation" key=${item.id}>
60
+ <p>${hroom("inviteLead", item.by?.name || "", item.agent.name, item.room.name)}</p>
61
+ <small class="note">${Number(item.room.people) === 1 ? hi("leadOne") : hroom("inviteHint", Number(item.room.people) || 0)}</small>
62
+ <small class="note">${hi("readsRecent")}</small>
63
+ ${note?.id === item.id ? html`<p class="note" role="alert">${note.text}</p>` : null}
64
+ <div class="field-row">
65
+ <button type="button" class="btn btn-primary" disabled=${busy !== null} onClick=${() => act(item, true)}>${hroom("agree")}</button>
66
+ <button type="button" class="btn" disabled=${busy !== null} onClick=${() => act(item, false)}>${hroom("decline")}</button>
67
+ </div>
68
+ </article>`)}
69
+ ${note && !list.some(x => x.id === note.id) ? html`<p class="note" role="status">${note.text}</p>` : null}
70
+ </section>`;
71
+ }
72
+
73
+ /**
74
+ * 「在這些房間裡」 on one of my shared agents' pages (section 8): the rooms it was let into, each with 退出這個房間.
75
+ * Nothing when it is in none. Follows member.changed / room.changed for those rooms, and invitation.changed (an accepted
76
+ * invitation adds a room). onRooms(count): after each read of the agent's rooms (0 included) and after a Leave, so the
77
+ * page can say 「在 N 個房間裡」 from this one read.
78
+ */
79
+ export function AgentRoomsSection({ client = hubClient(), exposureId, onRooms } = {}) {
80
+ const [rooms, setRooms] = useState(null), [busy, setBusy] = useState(null), [failed, setFailed] = useState(null);
81
+ const live = useRef(true), asked = useRef(0), told = useRef(onRooms);
82
+ told.current = onRooms;
83
+ useEffect(() => { if (rooms) told.current?.(rooms.length); }, [rooms]); // each read (a new list) and each Leave
84
+ const reload = async () => {
85
+ const mine = ++asked.current;
86
+ const r = await client.agentRooms(exposureId);
87
+ if (live.current && mine === asked.current && r?.ok && Array.isArray(r.rooms)) setRooms(r.rooms.filter(x => x && typeof x.id === "string"));
88
+ };
89
+ useEffect(() => {
90
+ live.current = true; void reload();
91
+ const again = () => { void reload(); };
92
+ const off = client.subscribeRooms?.({ "invitation.changed": again, "member.changed": again, "room.changed": again }) ?? (() => {});
93
+ return () => { live.current = false; off(); };
94
+ }, [client, exposureId]);
95
+ if (!rooms?.length) return null;
96
+ const leave = async (room) => {
97
+ setBusy(room.id); setFailed(null);
98
+ const r = await client.removeRoomMember(room.id, room.memberId || exposureId);
99
+ if (!live.current) return;
100
+ setBusy(null);
101
+ if (r?.ok) setRooms(old => old.filter(x => x.id !== room.id)); else setFailed(room.id);
102
+ };
103
+ return html`<section class="hub-agent-rooms"><h4>${hroom("inTheseRooms")}</h4>
104
+ <ul>${rooms.map(room => html`<li key=${room.id} data-room=${room.id}><span>${hi("roomPeople", room.name, Number(room.people) || 0)}</span>
105
+ <button type="button" class="btn btn-link" disabled=${busy !== null} onClick=${() => { void leave(room); }}>${hroom("leaveThisRoom")}</button>
106
+ ${failed === room.id ? html`<p class="note" role="alert">${hi("leaveFailed")}</p>` : null}</li>`)}</ul>
107
+ </section>`;
108
+ }
@@ -29,6 +29,7 @@ register("joinOne", {
29
29
  opened: "Opened the sign-in tab for {0}…", left: "{0} left", reopen: "Reopen tab", cancel: "Cancel",
30
30
  ownerLine: "Connected with {0}'s company account · This Fleet is called “{1}”",
31
31
  reconnect: "Reconnect", remove: "Remove this connection",
32
+ revokedHint: "The Hub ended this Fleet's connection, for example after it moved the address Fleets connect to. Reconnect signs in again with your company account; nothing else is needed.",
32
33
  removeAsk: "Remove the connection to “{0}”? Agents you share will stop answering.", removeYes: "Remove", removeNo: "Keep",
33
34
  removed: "The connection was removed.",
34
35
  },
@@ -55,6 +56,7 @@ register("joinOne", {
55
56
  opened: "已開啟 {0} 的登入分頁…", left: "剩 {0}", reopen: "重新開啟分頁", cancel: "取消",
56
57
  ownerLine: "以 {0} 的公司帳號連接 · 這台 Fleet 叫「{1}」",
57
58
  reconnect: "重新連接", remove: "移除這個連接",
59
+ revokedHint: "Hub 結束了這個 Fleet 的連接,例如它變更了 Fleet 連接位址之後。按「重新連接」以公司帳號再次登入即可,不需要其他步驟。",
58
60
  removeAsk: "要移除與「{0}」的連接嗎?你分享的 Agent 會停止回答。", removeYes: "移除", removeNo: "保留",
59
61
  removed: "已移除連接。",
60
62
  },
@@ -0,0 +1,48 @@
1
+ // #3840: the pairing-code form under "Other ways" (Settings → Hub). A pairing code is 12 hex characters (the server's
2
+ // own rule: lowercased, spaces and dashes removed, /^[a-f0-9]{12}$/ in src/hub/member/pairing-api.ts); it is checked here,
3
+ // on the page, before any confirmation is asked. A join code (XXXX-XXXX, for the Hub address box above) is recognised and
4
+ // pointed up. The form's address is the member address shown with the pairing code, not the Hub's page address. After a
5
+ // confirmed change fails, the handler's own reason is named. Its own module, so a page holding an older hub-strings
6
+ // dictionary still has every word (upgrade skew).
7
+ import { register, t } from "/assets/app-i18n.js";
8
+
9
+ register("hubPairingForm", {
10
+ en: {
11
+ addressHint: "The address shown with the pairing code (it ends in a port). It is not the address of the Hub's pages.",
12
+ joinCode: "This is a join code. In “Hub address” at the top of this card, type the address, a space, then this code.",
13
+ codeShape: "A pairing code is 12 characters, 0–9 and a–f (for example 1a2b3c4d5e6f).",
14
+ failed_code: "Confirmed, but it was not applied: that is not a valid pairing code. A pairing code is 12 characters, 0–9 and a–f.",
15
+ failed_address: "Confirmed, but it was not applied: that is not a Hub's member address.",
16
+ failed_unreachable: "Confirmed, but it was not applied: the Hub could not be reached at that address.",
17
+ failed_refused: "Confirmed, but it was not applied: the Hub refused this pairing code (used, expired or not issued for this Hub).",
18
+ failed_busy: "Confirmed, but it was not applied: the Hub is busy. Try again in a moment.",
19
+ },
20
+ "zh-TW": {
21
+ addressHint: "配對碼一起提供的位址(結尾有連接埠),不是 Hub 網頁的位址。",
22
+ joinCode: "這是加入碼。請在這張卡片最上方的「Hub 位址」輸入位址、空一格,再輸入這組碼。",
23
+ codeShape: "配對碼是 12 個字元,只有 0–9 與 a–f(例如 1a2b3c4d5e6f)。",
24
+ failed_code: "已確認,但沒有套用:這不是有效的配對碼。配對碼是 12 個字元,只有 0–9 與 a–f。",
25
+ failed_address: "已確認,但沒有套用:這不是 Hub 的成員位址。",
26
+ failed_unreachable: "已確認,但沒有套用:連不到這個位址上的 Hub。",
27
+ failed_refused: "已確認,但沒有套用:Hub 拒絕了這組配對碼(已使用、已過期,或不是這個 Hub 發的)。",
28
+ failed_busy: "已確認,但沒有套用:Hub 目前忙碌,請稍後再試。",
29
+ },
30
+ });
31
+ export const hpf = (key, ...args) => t(`hubPairingForm.${key}`, ...args);
32
+
33
+ const JOIN_CODE = /^[0-9A-HJKMNP-TV-Z]{4}-?[0-9A-HJKMNP-TV-Z]{4}$/i;
34
+ /** The pairing code as the server reads it: lowercased, spaces and dashes removed. */
35
+ export const pairingCodeNormal = (raw) => String(raw ?? "").trim().toLowerCase().replace(/[\s-]/g, "");
36
+ /** "ok" (12 hex), "join" (a join code, which belongs in the Hub address box), "shape" (anything else typed), or "" (empty). */
37
+ export function pairingCodeState(raw) {
38
+ const text = String(raw ?? "").trim();
39
+ if (!text) return "";
40
+ if (/^[a-f0-9]{12}$/.test(pairingCodeNormal(text))) return "ok";
41
+ return JOIN_CODE.test(text) ? "join" : "shape";
42
+ }
43
+ /** The specific words for a confirmed connect that failed, from the replay's own reason ("apply_rejected: <error>"), or null. */
44
+ export function pairingFailure(outcome) {
45
+ const m = /^apply_rejected: ([a-z_]+)$/.exec(String(outcome?.detail ?? ""));
46
+ const key = m && ["code", "address", "unreachable", "refused", "busy"].includes(m[1]) ? `failed_${m[1]}` : null;
47
+ return key ? hpf(key) : null;
48
+ }
@@ -0,0 +1,27 @@
1
+ import { register, t } from "/assets/app-i18n.js";
2
+ register("hubPilotTrust", {
3
+ en: {
4
+ title: "This Hub uses a self-signed test certificate",
5
+ body: "This computer can't confirm its identity by itself. If this is the Hub your team is piloting, you can trust it for now. If its certificate changes later, you'll be asked again.",
6
+ fingerprint: "Certificate fingerprint", full: "Show the full fingerprint", trust: "Trust this Hub and continue", cancel: "Cancel",
7
+ trusted: "You trusted this Hub's self-signed certificate (for testing).",
8
+ changed: "{0}'s certificate is different from the one you trusted, so nothing was connected. If your Hub administrator confirms it was replaced, you can trust it again.",
9
+ again: "Trust again and continue",
10
+ setting: "Allow trusting a Hub with a self-signed certificate (for testing)",
11
+ hint: "For pilots only. Turn it off once the Hub has a trusted certificate.",
12
+ disabled: "{0} uses a self-signed certificate, and this AgEnD doesn't allow trusting one. Ask the Hub administrator for a trusted certificate.",
13
+ failed: "The setting could not be saved. Try again.", retry: "Try again", pending: "Confirm this change in Needs you."
14
+ },
15
+ "zh-TW": {
16
+ title: "這個 Hub 用的是測試用的自簽憑證",
17
+ body: "這台電腦無法自動確認它的身分。如果這是你們團隊試行中的 Hub,可以先信任它;之後它的憑證若改變,會再問你一次。",
18
+ fingerprint: "憑證指紋", full: "顯示完整指紋", trust: "信任這個 Hub 並繼續", cancel: "取消",
19
+ trusted: "已信任這個 Hub 的自簽憑證(測試用)。",
20
+ changed: "{0} 的憑證和你上次信任的不同,所以沒有連接。如果 Hub 管理員確認換過憑證,可以重新信任。",
21
+ again: "重新信任並繼續",
22
+ setting: "允許信任自簽憑證的 Hub(測試用)", hint: "只在試行期間使用。Hub 換上受信任的憑證後請關閉。",
23
+ disabled: "{0} 用的是自簽憑證,這台 AgEnD 不允許信任它。請 Hub 管理員換上受信任的憑證。",
24
+ failed: "設定未能儲存,請再試一次。", retry: "再試一次", pending: "請到「需要你」確認這項變更。"
25
+ }
26
+ });
27
+ export const pt = (key, ...args) => t("hubPilotTrust." + key, ...args);
@@ -0,0 +1,41 @@
1
+ /** Optional probe data: old hosts keep their existing certificate message. */
2
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
3
+ import { api, confirmedWrite } from "./settings-confirm.js";
4
+ import { pt } from "./hub-pilot-trust-strings.js";
5
+ export const pilotTrustV1 = true;
6
+ export function pilotTrustCandidate(probe) {
7
+ const trust = probe?.ok === false && probe.reason === "certificate" && probe.selfSigned === true ? probe.trust : null;
8
+ return trust && /^[a-f0-9]{64}$/.test(trust.fingerprint) && (trust.previous === null || /^[a-f0-9]{64}$/.test(trust.previous)) ? trust : null;
9
+ }
10
+ export function PilotTrustPrompt({ trust, host, busy, onTrust, onCancel }) {
11
+ const [full, setFull] = useState(false), changed = trust.previous !== null;
12
+ const fingerprint = trust.fingerprint.match(/.{2}/g).join(":");
13
+ return html`<div class="form hub-pilot-trust" role="group" aria-labelledby="hubPilotTrustTitle">
14
+ <strong id="hubPilotTrustTitle">${pt("title")}</strong>
15
+ <p class="note">${pt(changed ? "changed" : "body", host)}</p>
16
+ <div class="field"><span>${pt("fingerprint")}</span><code>${(full ? fingerprint : fingerprint.slice(0, 23) + "…" + fingerprint.slice(-11)).split(":").map((part, i) => html`${i ? ":" : ""}<wbr />${part}`)}</code>
17
+ ${!full ? html`<button type="button" class="btn btn-ghost btn-sm" onClick=${() => setFull(true)}>${pt("full")}</button>` : null}</div>
18
+ <div class="field-row"><button type="button" class="btn btn-primary" disabled=${busy} onClick=${onTrust}>${pt(changed ? "again" : "trust")}</button>
19
+ <button type="button" class="btn" disabled=${busy} onClick=${onCancel}>${pt("cancel")}</button></div>
20
+ </div>`;
21
+ }
22
+ export function HubPilotTrustSettings({ onChanged }) {
23
+ const [enabled, setEnabled] = useState(null), [busy, setBusy] = useState(false), [error, setError] = useState(false), [pending, setPending] = useState(false), live = useRef(true);
24
+ const path = "/api/settings/hub/pilot-trust";
25
+ const read = async () => { const r = await api(path); if (live.current && r.ok && typeof r.body?.enabled === "boolean") setEnabled(r.body.enabled); };
26
+ useEffect(() => { live.current = true; read().catch(() => {}); return () => { live.current = false; }; }, []);
27
+ const change = async value => {
28
+ if (busy) return; setBusy(true); setError(false); setPending(false);
29
+ try {
30
+ const r = await confirmedWrite(path, { method: "PUT", body: { enabled: value }, label: pt("setting"), onPending: () => { if (live.current) setPending(true); } });
31
+ if (!live.current) return;
32
+ if (!r.ok) { setError(true); return; }
33
+ await read(); if (live.current) { setPending(false); onChanged?.(); }
34
+ } catch { if (live.current) setError(true); }
35
+ finally { if (live.current) setBusy(false); }
36
+ };
37
+ if (enabled === null) return null;
38
+ return html`<div class="form hub-pilot-trust-setting"><label class="check"><input type="checkbox" role="switch" checked=${enabled} disabled=${busy} onChange=${e => change(e.target.checked)} /><span>${pt("setting")}</span></label>
39
+ <p class="note">${pt("hint")}</p>${pending ? html`<p class="note" role="status">${pt("pending")}</p>` : null}
40
+ ${error ? html`<p class="note" role="alert">${pt("failed")}</p>` : null}</div>`;
41
+ }
@@ -0,0 +1,113 @@
1
+ // M-3092 PR 2 (Hub rooms, track U): a room's composer — the Fleet chat's own ComposerInput, its palette (`cmd-palette`)
2
+ // and its reply bar (`reply-bar`), with what a room adds (docs/design/hub-rooms-ux.md §4):
3
+ // - typing `@` opens a menu: 「@所有 Agent」 (when this room lets me), 「@房間助理」 (when the room has one), each agent
4
+ // (its owner and status dot; filtered by name or owner), then the people (an @ to a person only reminds them);
5
+ // - with @所有 Agent in the text, a line above says how many answer now and how many after they come back;
6
+ // - under the box, always: messages with no @agent are seen only by the people in the room;
7
+ // - `/` is plain text here (no slash commands); a refusal is worded where the Fleet chat words "Not sent: …".
8
+ import { html, useState, useRef } from "/assets/app-html.js";
9
+ import { ComposerInput, touchScreen } from "/assets/chat-composer.js";
10
+ import { t } from "/assets/app-i18n.js";
11
+ import { Icon } from "/assets/ui-icons.js";
12
+ import { hroom } from "./hub-room-strings.js";
13
+ import { presenceDot } from "./hub-room-presence.js";
14
+
15
+ const ONLINE = new Set(["online", "idle", "working"]);
16
+ const agentsOf = (detail) => (detail?.members || []).filter((m) => m.kind === "agent" || m.kind === "later");
17
+
18
+ /** The @ token being typed at `caret` (from an `@` after a space or the start to the caret), or null. */
19
+ export function mentionAt(value, caret) {
20
+ const before = String(value || "").slice(0, caret), at = before.lastIndexOf("@");
21
+ if (at < 0 || (at > 0 && !/\s/.test(before[at - 1]))) return null;
22
+ const q = before.slice(at + 1);
23
+ return /[\s]/.test(q) ? null : { start: at, query: q };
24
+ }
25
+
26
+ /** The @ menu (spec §4), in its order; `query` filters agents and people by name or owner. */
27
+ export function mentionOptions(detail, query = "") {
28
+ const q = String(query || "").toLowerCase(), hit = (...v) => !q || v.some((x) => String(x || "").toLowerCase().includes(q));
29
+ const agents = agentsOf(detail), manager = detail?.me?.role === "manager", out = [];
30
+ if ((detail?.settings?.allMention !== false || manager) && agents.length && hit(hroom("mentionAll")))
31
+ out.push({ kind: "all", key: "all", label: hroom("mentionAll"), hint: hroom("mentionAllHint", String(agents.length)) });
32
+ if ((detail?.members || []).some((m) => m.kind === "assistant") && hit(hroom("mentionAssistant")))
33
+ out.push({ kind: "assistant", key: "assistant", label: hroom("mentionAssistant"), hint: hroom("mentionAssistantHint") });
34
+ for (const a of agents) if (hit(a.name, a.owner?.name)) out.push({ kind: "agent", key: a.id, label: `@${a.name}`, hint: a.owner?.name || "", dot: presenceDot(a.presence, a.presenceReason) });
35
+ for (const p of (detail?.members || []).filter((m) => m.kind === "person" && m.id !== detail?.me?.id)) if (hit(p.name)) out.push({ kind: "person", key: p.id, label: `@${p.name}`, hint: "" });
36
+ return out;
37
+ }
38
+
39
+ /** The mentions a text names (spec seam 1: "all", "assistant" or an agent's exposure id), read from the text as sent. */
40
+ export function mentionsIn(text, detail) {
41
+ const s = String(text || ""), out = [];
42
+ if (s.includes(hroom("mentionAll"))) out.push("all");
43
+ if (s.includes(hroom("mentionAssistant"))) out.push("assistant");
44
+ for (const a of agentsOf(detail)) if (new RegExp(`@${a.name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\w-])`).test(s)) out.push(a.id);
45
+ return [...new Set(out)];
46
+ }
47
+
48
+ /** Above the box when @所有 Agent is in it: how many answer now, how many after they come back (spec §4). */
49
+ export function allBar(detail) {
50
+ const agents = agentsOf(detail), online = agents.filter((a) => ONLINE.has(a.presence)).length;
51
+ return hroom("allBar", String(agents.length), String(online), String(agents.length - online));
52
+ }
53
+
54
+ const REFUSALS = { "all-mention-off": "errAllMention", "not-member": "errNotMember", archived: "errArchived" };
55
+ /** A refusal in words (spec §4); the network's own failure as the Fleet chat says it. */
56
+ export function refusalText(r) {
57
+ if (!r || r.ok) return "";
58
+ if (REFUSALS[r.code]) return hroom(REFUSALS[r.code]);
59
+ return hroom("notSentBecause", hroom("sendNoConnection"));
60
+ }
61
+
62
+ /**
63
+ * The composer. `store`: the room's (send); `detail`: the room GET; `reply`/`onReply`: the message being answered (the
64
+ * thread's Reply); `closed`: archived or no longer a member (the box says why, nothing is sent).
65
+ */
66
+ export function RoomComposer({ store, detail, reply = null, onReply = () => {}, closed = false, inputRef, insertRef }) {
67
+ const [value, setValue] = useState(""), [msg, setMsg] = useState(null), [busy, setBusy] = useState(false), [pick, setPick] = useState(0);
68
+ const own = useRef(null), input = inputRef || own;
69
+ const [caret, setCaret] = useState(0);
70
+ const at = mentionAt(value, caret), options = at ? mentionOptions(detail, at.query) : [];
71
+ const palette = at && options.length ? options : null, chosen = palette ? palette[Math.min(pick, palette.length - 1)] : null;
72
+ const room = detail?.room || {}, group = room.kind === "group";
73
+ // 「在這裡 @ 它」 from the members panel: the mention goes into the box, after what is there.
74
+ if (insertRef) insertRef.current = (text) => { setValue((v) => `${v && !/\s$/.test(v) ? `${v} ` : v}${text} `); setTimeout(() => input.current?.focus(), 0); };
75
+ const complete = (o) => {
76
+ const next = `${value.slice(0, at.start)}${o.label} ${value.slice(caret)}`;
77
+ setValue(next); setPick(0);
78
+ setTimeout(() => { const el = input.current; if (el) { const n = at.start + o.label.length + 1; el.focus(); try { el.setSelectionRange(n, n); } catch { /* not a text field */ } setCaret(n); } }, 0);
79
+ };
80
+ const send = async () => {
81
+ const text = value.trim(); if (!text || busy || closed) return;
82
+ setBusy(true); setMsg(null);
83
+ const r = await store.send(text, { mentions: mentionsIn(text, detail), ...(reply ? { replyTo: reply.roomMessage } : {}) });
84
+ setBusy(false);
85
+ if (r.ok) { setValue(""); onReply(null); } else setMsg({ text: refusalText(r), retry: !REFUSALS[r.code] });
86
+ };
87
+ const onKeyDown = (e) => {
88
+ if (palette && (e.key === "ArrowDown" || e.key === "ArrowUp")) { e.preventDefault(); setPick((i) => (i + (e.key === "ArrowDown" ? 1 : palette.length - 1)) % palette.length); return; }
89
+ if (palette && (e.key === "Enter" || e.key === "Tab") && !e.isComposing) { e.preventDefault(); complete(chosen); return; }
90
+ if (palette && e.key === "Escape") { e.preventDefault(); setCaret(-1); return; }
91
+ // Enter sends, Shift+Enter is a new line — the Fleet chat's own rule (and a phone's).
92
+ if (globalThis.AgendChatRender?.composerKey(e, { touch: touchScreen() }) === "send") { e.preventDefault(); void send(); }
93
+ };
94
+ const track = (v) => { setValue(v); setMsg(null); setCaret(input.current ? input.current.selectionStart ?? v.length : v.length); };
95
+ const paletteId = `hubMention-${room.id || "room"}`, optId = (o) => `${paletteId}-${o.key}`;
96
+ if (closed) return html`<div class="composer-box"><p class="note" role="status">${hroom(detail?.room?.archived ? "errArchived" : "errNotMember")}</p></div>`;
97
+ return html`<div class="composer-box hub-room-composer">
98
+ ${palette ? html`<ul data-trust="palette" class="cmd-palette" id=${paletteId} role="listbox" aria-label=${hroom("mentionAll")}>
99
+ ${palette.map((o) => html`<li key=${o.key} id=${optId(o)} role="option" aria-selected=${o === chosen ? "true" : "false"} class=${o === chosen ? "on" : ""}
100
+ onMouseDown=${(e) => { e.preventDefault(); complete(o); }}>
101
+ <span class="cmd-name">${o.dot ? html`<span class=${`dot ${o.dot}`} aria-hidden="true"></span> ` : null}${o.label}</span><span class="cmd-desc">${o.hint}</span></li>`)}
102
+ </ul>` : null}
103
+ ${group && value.includes(hroom("mentionAll")) ? html`<p class="note hub-room-allbar" role="status">${allBar(detail)}</p>` : null}
104
+ ${reply ? html`<div class="reply-bar" data-trust="composer" role="status"><span class="reply-text">${reply.sender ? `${reply.sender} · ` : ""}${String(reply.text || "").slice(0, 80)}</span>
105
+ <button type="button" class="icon-btn reply-cancel" title=${hroom("cancel")} aria-label=${hroom("cancel")} onClick=${() => { onReply(null); input.current?.focus(); }}><${Icon} name="close" size=${14} /></button></div>` : null}
106
+ <${ComposerInput} inputRef=${input} value=${value} placeholder=${room.assistant ? hroom("composerAssistant") : group ? hroom("composer", room.name || "") : hroom("composerDirect", room.name || "")} onValue=${track} onKeyDown=${onKeyDown}
107
+ controls=${palette ? paletteId : undefined} expanded=${!!palette} activeDescendant=${chosen ? optId(chosen) : undefined}
108
+ stop=${{ hidden: true, disabled: true, title: t("chat.stopReply"), label: t("chat.stopReply"), onClick: () => {} }}
109
+ send=${{ hidden: false, disabled: !value.trim() || busy, label: t("chat.send"), onClick: () => { void send(); } }} />
110
+ ${msg ? html`<p class="err" role="alert">${msg.text}${msg.retry ? html` <button type="button" class="btn btn-sm" onClick=${send}>${hroom("retrySend")}</button>` : null}</p>` : null}
111
+ ${group ? html`<p class="note hub-room-hint">${hroom("composerHint")}</p>` : null}
112
+ </div>`;
113
+ }
@@ -0,0 +1,90 @@
1
+ // M-3092 S-145 (docs/design/hub-rooms-ux.md §2: 「釘選、收藏的行為與 Fleet 側欄相同」): the Hub list's favourites — the
2
+ // Fleet sidebar's (#1664) rules on the Hub's conversations: star a room or a chat from its row menu, the starred ones sit in
3
+ // 「最愛」 above 「房間」 and 「Agent」 in the order they were starred (or moved in Edit), at most MAX_FAVORITES, and one that
4
+ // is gone from the list (left, removed) is dropped on the next change, never shown.
5
+ //
6
+ // Where they are kept: a per-person seam (`favoritesSource`). The Hub has no per-person preference store yet, so today's
7
+ // source is this browser's storage, one key per Hub sign-in (the Hub's own origin; `login` keeps two people on one browser
8
+ // apart); another tab follows through the storage event. A Hub-side store replaces the source, not this module's rules.
9
+ import { useEffect, useState } from "/assets/app-html.js";
10
+ import { createStore, useStore } from "/assets/app-store.js";
11
+ import { MAX_FAVORITES } from "/assets/instance-nav.js";
12
+
13
+ export { MAX_FAVORITES };
14
+ const KEY_PREFIX = "agend_hub_favorites.";
15
+
16
+ /** The ids as kept: unique strings, in order, at most MAX_FAVORITES (anything else in storage is ignored). */
17
+ export function cleanIds(value) {
18
+ return Array.isArray(value) ? [...new Set(value.filter((x) => typeof x === "string" && x))].slice(0, MAX_FAVORITES) : [];
19
+ }
20
+
21
+ /** This browser's storage, per sign-in. A full or blocked storage keeps the change for this page only. */
22
+ export const localFavoritesSource = {
23
+ read(login) {
24
+ try { return cleanIds(JSON.parse(globalThis.localStorage?.getItem(KEY_PREFIX + login) || "[]")); } catch { return []; }
25
+ },
26
+ write(login, ids) {
27
+ try { globalThis.localStorage?.setItem(KEY_PREFIX + login, JSON.stringify(ids)); } catch { /* this page only */ }
28
+ },
29
+ /** Another tab changed this sign-in's favourites: `onChange()`. Returns the unsubscribe. */
30
+ watch(login, onChange) {
31
+ if (typeof addEventListener !== "function") return () => {};
32
+ const on = (e) => { if (e && e.key === KEY_PREFIX + login) onChange(); };
33
+ addEventListener("storage", on);
34
+ return () => removeEventListener("storage", on);
35
+ },
36
+ };
37
+
38
+ let source = localFavoritesSource;
39
+ /** Tests (and a later Hub-side store) swap where favourites are kept. */
40
+ export function setFavoritesSource(next) { source = next || localFavoritesSource; }
41
+
42
+ /** { login, ids }: whose favourites are loaded, and their ids in order. */
43
+ export const favoritesStore = createStore({ login: null, ids: [] });
44
+ let unwatch = () => {};
45
+ /** Load `login`'s favourites (a sign-in, or a different person on this page); the same login again is a no-op. */
46
+ export function loadFavorites(login) {
47
+ const who = typeof login === "string" && login ? login : null;
48
+ if (favoritesStore.get().login === who) return;
49
+ unwatch();
50
+ unwatch = who ? source.watch(who, () => favoritesStore.set({ ids: source.read(who) })) : () => {};
51
+ favoritesStore.set({ login: who, ids: who ? source.read(who) : [] });
52
+ }
53
+
54
+ /** The favourites that are in the list now (`known`: the ids listed) — what is shown, and the base of every change. */
55
+ export function liveFavorites(known, ids = favoritesStore.get().ids) { return ids.filter((id) => known.has(id)); }
56
+ function save(ids) {
57
+ const { login } = favoritesStore.get();
58
+ favoritesStore.set({ ids });
59
+ if (login) source.write(login, ids);
60
+ }
61
+ /** Star or unstar `id`. False: not done (the list is full, or `id` isn't listed). */
62
+ export function toggleFavorite(id, known) {
63
+ const cur = liveFavorites(known);
64
+ if (cur.includes(id)) { save(cur.filter((x) => x !== id)); return true; }
65
+ if (cur.length >= MAX_FAVORITES || !known.has(id)) return false;
66
+ save([...cur, id]);
67
+ return true;
68
+ }
69
+ /** Move a favourite one place up (-1) or down (+1). */
70
+ export function moveFavorite(id, delta, known) {
71
+ const cur = liveFavorites(known);
72
+ const from = cur.indexOf(id), to = from + delta;
73
+ if (from < 0 || to < 0 || to >= cur.length) return;
74
+ cur.splice(to, 0, cur.splice(from, 1)[0]);
75
+ save(cur);
76
+ }
77
+
78
+ /**
79
+ * The list's starring, for HubRoomRows: { ids, editing, setEditing, toggle(id), move(id, delta) } for `login` over the
80
+ * `rooms` listed now (null until someone is signed in).
81
+ */
82
+ export function useRoomStar(rooms, login) {
83
+ const fav = useStore(favoritesStore);
84
+ const [editing, setEditing] = useState(false);
85
+ useEffect(() => { loadFavorites(login); }, [login]);
86
+ if (!login || fav.login !== login) return null;
87
+ const known = new Set((Array.isArray(rooms) ? rooms : []).map((r) => r && r.id).filter(Boolean));
88
+ return { ids: liveFavorites(known, fav.ids), editing, setEditing,
89
+ toggle: (id) => toggleFavorite(id, known), move: (id, delta) => moveFavorite(id, delta, known) };
90
+ }
@@ -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);