@songsid/agend 2.4.0-beta.2 → 2.4.0-beta.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 (294) hide show
  1. package/dist/agent-cli.js +1 -1
  2. package/dist/agent-endpoint.d.ts +1 -1
  3. package/dist/agent-endpoint.js +8 -2
  4. package/dist/agent-endpoint.js.map +1 -1
  5. package/dist/agent-token-header.d.ts +1 -1
  6. package/dist/agent-token-header.js +1 -1
  7. package/dist/auth-api.d.ts +3 -0
  8. package/dist/auth-api.js +15 -1
  9. package/dist/auth-api.js.map +1 -1
  10. package/dist/backend/agy-model-switch.d.ts +22 -0
  11. package/dist/backend/agy-model-switch.js +62 -0
  12. package/dist/backend/agy-model-switch.js.map +1 -0
  13. package/dist/backend/antigravity.js +60 -3
  14. package/dist/backend/antigravity.js.map +1 -1
  15. package/dist/backend/cli-runtime-switch.d.ts +71 -0
  16. package/dist/backend/cli-runtime-switch.js +176 -0
  17. package/dist/backend/cli-runtime-switch.js.map +1 -0
  18. package/dist/backend/codex-model-switch.d.ts +41 -0
  19. package/dist/backend/codex-model-switch.js +170 -0
  20. package/dist/backend/codex-model-switch.js.map +1 -0
  21. package/dist/backend/credential-profile.js +1 -1
  22. package/dist/backend/credential-profile.js.map +1 -1
  23. package/dist/backend/grok-model-switch.d.ts +16 -0
  24. package/dist/backend/grok-model-switch.js +45 -0
  25. package/dist/backend/grok-model-switch.js.map +1 -0
  26. package/dist/backend/grok.js +1 -1
  27. package/dist/backend/grok.js.map +1 -1
  28. package/dist/backend/muse.d.ts +2 -0
  29. package/dist/backend/muse.js +7 -3
  30. package/dist/backend/muse.js.map +1 -1
  31. package/dist/build-provenance.json +1 -1
  32. package/dist/channel/mcp-server.js +10 -1
  33. package/dist/channel/mcp-server.js.map +1 -1
  34. package/dist/channel/mcp-tools.js +8 -0
  35. package/dist/channel/mcp-tools.js.map +1 -1
  36. package/dist/classic-channel-manager.d.ts +1 -1
  37. package/dist/classic-channel-manager.js +1 -1
  38. package/dist/cli-audited.js +12 -12
  39. package/dist/cli-audited.js.map +1 -1
  40. package/dist/daemon.d.ts +48 -2
  41. package/dist/daemon.js +302 -21
  42. package/dist/daemon.js.map +1 -1
  43. package/dist/delivery-consumed-watch.js +3 -0
  44. package/dist/delivery-consumed-watch.js.map +1 -1
  45. package/dist/event-log.d.ts +1 -1
  46. package/dist/event-log.js +1 -1
  47. package/dist/fleet-manager.d.ts +104 -2
  48. package/dist/fleet-manager.js +665 -27
  49. package/dist/fleet-manager.js.map +1 -1
  50. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +10 -0
  51. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +2 -0
  52. package/dist/general-knowledge/skills/fleet-health/SKILL.md +18 -0
  53. package/dist/general-knowledge/skills/hub/SKILL.md +154 -0
  54. package/dist/general-knowledge/skills/model-discovery/SKILL.md +4 -0
  55. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +17 -3
  56. package/dist/hub/admin-dashboard.d.ts +85 -0
  57. package/dist/hub/admin-dashboard.js +161 -0
  58. package/dist/hub/admin-dashboard.js.map +1 -0
  59. package/dist/hub/attachments/store.d.ts +2 -0
  60. package/dist/hub/attachments/store.js +6 -0
  61. package/dist/hub/attachments/store.js.map +1 -1
  62. package/dist/hub/client.d.ts +10 -0
  63. package/dist/hub/client.js +72 -10
  64. package/dist/hub/client.js.map +1 -1
  65. package/dist/hub/compose/member.d.ts +20 -0
  66. package/dist/hub/compose/member.js +212 -17
  67. package/dist/hub/compose/member.js.map +1 -1
  68. package/dist/hub/compose/server.d.ts +8 -0
  69. package/dist/hub/compose/server.js +13 -2
  70. package/dist/hub/compose/server.js.map +1 -1
  71. package/dist/hub/display-name.d.ts +10 -0
  72. package/dist/hub/display-name.js +35 -0
  73. package/dist/hub/display-name.js.map +1 -0
  74. package/dist/hub/execution/service.d.ts +1 -0
  75. package/dist/hub/execution/service.js +1 -1
  76. package/dist/hub/execution/service.js.map +1 -1
  77. package/dist/hub/fleet-info.d.ts +12 -0
  78. package/dist/hub/fleet-info.js +14 -0
  79. package/dist/hub/fleet-info.js.map +1 -0
  80. package/dist/hub/fleet-update-model.d.ts +100 -0
  81. package/dist/hub/fleet-update-model.js +15 -0
  82. package/dist/hub/fleet-update-model.js.map +1 -0
  83. package/dist/hub/fleet-updates.d.ts +46 -0
  84. package/dist/hub/fleet-updates.js +282 -0
  85. package/dist/hub/fleet-updates.js.map +1 -0
  86. package/dist/hub/fleet-versions.d.ts +28 -0
  87. package/dist/hub/fleet-versions.js +80 -0
  88. package/dist/hub/fleet-versions.js.map +1 -0
  89. package/dist/hub/http/compose.d.ts +2 -0
  90. package/dist/hub/http/compose.js +192 -16
  91. package/dist/hub/http/compose.js.map +1 -1
  92. package/dist/hub/http/deps.d.ts +1 -0
  93. package/dist/hub/http/schema.js +13 -1
  94. package/dist/hub/http/schema.js.map +1 -1
  95. package/dist/hub/member/display-name.d.ts +9 -0
  96. package/dist/hub/member/display-name.js +71 -0
  97. package/dist/hub/member/display-name.js.map +1 -0
  98. package/dist/hub/member/exposure-api.d.ts +4 -0
  99. package/dist/hub/member/exposure-api.js +8 -3
  100. package/dist/hub/member/exposure-api.js.map +1 -1
  101. package/dist/hub/member/exposures.d.ts +4 -0
  102. package/dist/hub/member/exposures.js +20 -0
  103. package/dist/hub/member/exposures.js.map +1 -1
  104. package/dist/hub/member/pairing-api.js +3 -2
  105. package/dist/hub/member/pairing-api.js.map +1 -1
  106. package/dist/hub/member/recommendations.d.ts +37 -0
  107. package/dist/hub/member/recommendations.js +129 -0
  108. package/dist/hub/member/recommendations.js.map +1 -0
  109. package/dist/hub/member/room-ask.d.ts +60 -1
  110. package/dist/hub/member/room-ask.js +254 -24
  111. package/dist/hub/member/room-ask.js.map +1 -1
  112. package/dist/hub/member/room-post-answers.d.ts +52 -0
  113. package/dist/hub/member/room-post-answers.js +152 -0
  114. package/dist/hub/member/room-post-answers.js.map +1 -0
  115. package/dist/hub/member/room-post-receipt.d.ts +21 -0
  116. package/dist/hub/member/room-post-receipt.js +49 -0
  117. package/dist/hub/member/room-post-receipt.js.map +1 -0
  118. package/dist/hub/member/room-post.d.ts +100 -0
  119. package/dist/hub/member/room-post.js +223 -0
  120. package/dist/hub/member/room-post.js.map +1 -0
  121. package/dist/hub/member/updates.d.ts +92 -0
  122. package/dist/hub/member/updates.js +316 -0
  123. package/dist/hub/member/updates.js.map +1 -0
  124. package/dist/hub/protocol.d.ts +658 -1
  125. package/dist/hub/protocol.js +90 -13
  126. package/dist/hub/protocol.js.map +1 -1
  127. package/dist/hub/published-version.d.ts +3 -0
  128. package/dist/hub/published-version.js +35 -0
  129. package/dist/hub/published-version.js.map +1 -0
  130. package/dist/hub/recommendation-model.d.ts +36 -0
  131. package/dist/hub/recommendation-model.js +9 -0
  132. package/dist/hub/recommendation-model.js.map +1 -0
  133. package/dist/hub/recommendations.d.ts +58 -0
  134. package/dist/hub/recommendations.js +211 -0
  135. package/dist/hub/recommendations.js.map +1 -0
  136. package/dist/hub/representative.d.ts +3 -0
  137. package/dist/hub/representative.js +2 -1
  138. package/dist/hub/representative.js.map +1 -1
  139. package/dist/hub/room-context-model.d.ts +43 -0
  140. package/dist/hub/room-context-model.js +12 -0
  141. package/dist/hub/room-context-model.js.map +1 -0
  142. package/dist/hub/rooms/agents.d.ts +41 -9
  143. package/dist/hub/rooms/agents.js +183 -21
  144. package/dist/hub/rooms/agents.js.map +1 -1
  145. package/dist/hub/rooms/assistant.d.ts +1 -6
  146. package/dist/hub/rooms/assistant.js +7 -2
  147. package/dist/hub/rooms/assistant.js.map +1 -1
  148. package/dist/hub/rooms/automation.d.ts +24 -0
  149. package/dist/hub/rooms/automation.js +66 -0
  150. package/dist/hub/rooms/automation.js.map +1 -0
  151. package/dist/hub/rooms/buttons.d.ts +85 -0
  152. package/dist/hub/rooms/buttons.js +62 -0
  153. package/dist/hub/rooms/buttons.js.map +1 -0
  154. package/dist/hub/rooms/context-cursor.d.ts +18 -0
  155. package/dist/hub/rooms/context-cursor.js +61 -0
  156. package/dist/hub/rooms/context-cursor.js.map +1 -0
  157. package/dist/hub/rooms/context.d.ts +1 -1
  158. package/dist/hub/rooms/context.js +4 -4
  159. package/dist/hub/rooms/context.js.map +1 -1
  160. package/dist/hub/rooms/mentions.d.ts +15 -0
  161. package/dist/hub/rooms/mentions.js +43 -0
  162. package/dist/hub/rooms/mentions.js.map +1 -0
  163. package/dist/hub/rooms/post-replies.d.ts +23 -0
  164. package/dist/hub/rooms/post-replies.js +114 -0
  165. package/dist/hub/rooms/post-replies.js.map +1 -0
  166. package/dist/hub/rooms/schema.d.ts +9 -0
  167. package/dist/hub/rooms/schema.js +43 -0
  168. package/dist/hub/rooms/schema.js.map +1 -1
  169. package/dist/hub/rooms/service.d.ts +136 -1
  170. package/dist/hub/rooms/service.js +727 -18
  171. package/dist/hub/rooms/service.js.map +1 -1
  172. package/dist/hub/rooms/types.d.ts +27 -3
  173. package/dist/hub/rooms.js +1 -1
  174. package/dist/hub/rooms.js.map +1 -1
  175. package/dist/hub/runtime.d.ts +1 -1
  176. package/dist/hub/runtime.js +12 -0
  177. package/dist/hub/runtime.js.map +1 -1
  178. package/dist/hub/server.d.ts +6 -1
  179. package/dist/hub/server.js +75 -5
  180. package/dist/hub/server.js.map +1 -1
  181. package/dist/hub/settings-directory-proof.js +22 -1
  182. package/dist/hub/settings-directory-proof.js.map +1 -1
  183. package/dist/hub/types.d.ts +133 -2
  184. package/dist/hub-contact-windows.d.ts +11 -0
  185. package/dist/hub-contact-windows.js +56 -0
  186. package/dist/hub-contact-windows.js.map +1 -0
  187. package/dist/hub-pairing-summary.d.ts +1 -1
  188. package/dist/hub-room-conversation.d.ts +14 -0
  189. package/dist/hub-room-conversation.js +60 -0
  190. package/dist/hub-room-conversation.js.map +1 -0
  191. package/dist/hub-update-notice.d.ts +12 -0
  192. package/dist/hub-update-notice.js +35 -0
  193. package/dist/hub-update-notice.js.map +1 -0
  194. package/dist/locale.js +58 -2
  195. package/dist/locale.js.map +1 -1
  196. package/dist/native-mcp.js +9 -6
  197. package/dist/native-mcp.js.map +1 -1
  198. package/dist/outbound-handlers.d.ts +14 -4
  199. package/dist/outbound-handlers.js +54 -1
  200. package/dist/outbound-handlers.js.map +1 -1
  201. package/dist/outbound-schemas.d.ts +12 -0
  202. package/dist/outbound-schemas.js +12 -0
  203. package/dist/outbound-schemas.js.map +1 -1
  204. package/dist/pane-port.d.ts +2 -0
  205. package/dist/queued-handoffs.d.ts +16 -4
  206. package/dist/queued-handoffs.js +18 -1
  207. package/dist/queued-handoffs.js.map +1 -1
  208. package/dist/runtime-cli-install.js +13 -10
  209. package/dist/runtime-cli-install.js.map +1 -1
  210. package/dist/settings-api.d.ts +1 -0
  211. package/dist/settings-api.js +87 -0
  212. package/dist/settings-api.js.map +1 -1
  213. package/dist/tmux-manager.d.ts +2 -0
  214. package/dist/tmux-manager.js +2 -0
  215. package/dist/tmux-manager.js.map +1 -1
  216. package/dist/tool-permissions.js +3 -0
  217. package/dist/tool-permissions.js.map +1 -1
  218. package/dist/ui/chat-msg-actions.js +3 -222
  219. package/dist/ui/hub-admin-overview.js +189 -0
  220. package/dist/ui/hub-client.js +36 -4
  221. package/dist/ui/hub-fleet-versions.js +393 -0
  222. package/dist/ui/hub-room-agent-strings.js +28 -0
  223. package/dist/ui/hub-room-composer.js +16 -8
  224. package/dist/ui/hub-room-members-strings.js +2 -2
  225. package/dist/ui/hub-room-members.js +3 -2
  226. package/dist/ui/hub-room-notify.js +161 -0
  227. package/dist/ui/hub-room-search.js +126 -0
  228. package/dist/ui/hub-room-strings.js +47 -1
  229. package/dist/ui/hub-room-thread.js +243 -35
  230. package/dist/ui/hub-room-unread.js +2 -1
  231. package/dist/ui/hub-strings.js +8 -0
  232. package/dist/ui/image-annotate.js +2 -283
  233. package/dist/ui/image-lightbox.js +2 -176
  234. package/dist/ui/image-zoom.js +2 -242
  235. package/dist/ui/notice-hub-update.js +94 -0
  236. package/dist/ui/panel-chat.js +121 -12
  237. package/dist/ui/panel-hub.js +133 -19
  238. package/dist/ui/panel-notices.js +3 -1
  239. package/dist/ui/panel-settings.js +1 -1
  240. package/dist/ui/settings-hub-updates.js +67 -0
  241. package/dist/ui/settings-hub.js +28 -3
  242. package/dist/ui/settings-registry.js +1 -0
  243. package/dist/ui/settings-update.js +11 -5
  244. package/dist/ui/settings-web-authority.js +1 -1
  245. package/dist/ui/shared/app-i18n.js +2 -0
  246. package/dist/ui/shared/app-nav.js +6 -2
  247. package/dist/ui/shared/app-prefs.js +2 -1
  248. package/dist/ui/shared/app-shell.js +29 -4
  249. package/dist/ui/shared/app-update.js +90 -8
  250. package/dist/ui/shared/app.css +33 -0
  251. package/dist/ui/shared/chat-composer.js +6 -3
  252. package/dist/ui/shared/chat-msg-actions.js +225 -0
  253. package/dist/ui/shared/chat-thread.js +70 -5
  254. package/dist/ui/shared/chat-work-bar.css +48 -0
  255. package/dist/ui/shared/hub-chat.css +16 -2
  256. package/dist/ui/shared/hub-owner.css +104 -0
  257. package/dist/ui/shared/hub-rooms-u2.css +16 -0
  258. package/dist/ui/shared/hub.css +5 -0
  259. package/dist/ui/shared/image-annotate.js +306 -0
  260. package/dist/ui/shared/image-lightbox.js +183 -0
  261. package/dist/ui/shared/image-zoom.js +242 -0
  262. package/dist/ui/shared/instance-nav.js +36 -7
  263. package/dist/ui/shared/model-picker.css +4 -3
  264. package/dist/ui/shared/view-strings.js +8 -0
  265. package/dist/ui/shared/web-authorize.js +2 -2
  266. package/dist/update-dispatch.d.ts +8 -1
  267. package/dist/update-dispatch.js +16 -1
  268. package/dist/update-dispatch.js.map +1 -1
  269. package/dist/update-idle.d.ts +65 -0
  270. package/dist/update-idle.js +190 -0
  271. package/dist/update-idle.js.map +1 -0
  272. package/dist/update-launch.d.ts +1 -1
  273. package/dist/update-launch.js +9 -2
  274. package/dist/update-launch.js.map +1 -1
  275. package/dist/usage/i18n-keys.d.ts +1 -1
  276. package/dist/usage/i18n-keys.js +1 -1
  277. package/dist/usage/i18n-keys.js.map +1 -1
  278. package/dist/usage/profile-timeline.d.ts +2 -0
  279. package/dist/usage/profile-timeline.js +4 -0
  280. package/dist/usage/profile-timeline.js.map +1 -1
  281. package/dist/usage/providers.js +4 -4
  282. package/dist/usage/providers.js.map +1 -1
  283. package/dist/usage/quota-history.d.ts +1 -1
  284. package/dist/view-api.js +1 -1
  285. package/dist/view-api.js.map +1 -1
  286. package/dist/web-api.js +19 -2
  287. package/dist/web-api.js.map +1 -1
  288. package/dist/web-notices.d.ts +3 -0
  289. package/dist/web-notices.js +17 -2
  290. package/dist/web-notices.js.map +1 -1
  291. package/dist/web-prefs.js +1 -0
  292. package/dist/web-prefs.js.map +1 -1
  293. package/dist/web-update.d.ts +15 -1
  294. package/package.json +1 -1
@@ -0,0 +1,393 @@
1
+ // M-3137 (docs/design/hub-fleet-versions.md, phase 1 — see versions): what a Hub page says about Fleets' AgEnD versions.
2
+ // - Administration → Connected fleets (§2.2): the summary line above the list, the "Needs update" filter, and per row
3
+ // the AgEnD version, when it last connected and one state tag (a warn tag's sentence under it). The server
4
+ // (M-3136, GET /hub/v1/admin/overview) computes the state; this only words it.
5
+ // - The signed-in person's own Fleets (§2.3, GET /hub/v1/me/fleets): one banner when any is behind, closed for the session.
6
+ // The user's rule (no unread counts, no red dots): every state is a plain tag, never a badge.
7
+ // A module of its own with its own words, so a tab holding an older dictionary still has every word (upgrade skew); an
8
+ // overview without the version fields (an older Hub) draws exactly what it drew before.
9
+ import { html, useEffect, useState } from "/assets/app-html.js";
10
+ import { register, t, lang } from "/assets/app-i18n.js";
11
+ import { Icon } from "/assets/ui-icons.js";
12
+ import { confirmDialog } from "/assets/ui-confirm.js";
13
+
14
+ register("hubVersions", {
15
+ en: {
16
+ allCurrent: "All {0} Fleets are on the recommended version or newer.", allCurrentOne: "Your Fleet is on the recommended version or newer.",
17
+ someBehind: "{0} of {1} Fleets need an update.", someBehindOne: "{0} of {1} Fleets needs an update.", someBehindOnly: "The Fleet needs an update.",
18
+ // Phase 1 has no recommended version and no way to set one yet (M-3138 adds it, with "Set a recommended version…").
19
+ noRecommended: "{0} active Fleets.", noRecommendedOne: "{0} active Fleet.",
20
+ noRecommendedSet: "{0} active Fleets. Set a recommended version to see which ones are behind.", noRecommendedSetOne: "{0} active Fleet. Set a recommended version to see whether it is behind.",
21
+ recTitle: "Recommended AgEnD version", recHub: "Same as this Hub ({0})", recHubPlain: "Same as this Hub",
22
+ recSpecific: "A specific version", recVersion: "Version", recVersionPh: "e.g. 2.4.0", recNone: "No recommendation",
23
+ recLead: "Fleets below this version tell their owner and offer Update. Nothing is updated without the owner.",
24
+ recPreview: "{0} Fleets will be asked to update.", recPreviewOne: "{0} Fleet will be asked to update.", recPreviewNone: "No Fleet will be asked to update.",
25
+ recChecking: "Checking npm…", recSave: "Save", recSaving: "Saving…", recSaved: "Saved.",
26
+ errInvalid: "Enter a version number such as 2.4.0.", errNotFound: "Version {0} was not found on npm.",
27
+ errNpm: "Couldn't reach npm to check {0}. Try again.", errHubVersion: "This Hub's own version can't be read. Choose a specific version.",
28
+ errConflict: "Someone else changed this just now; their choice is shown. Check it and save again.", errFailed: "It wasn't saved. Try again.",
29
+ notified: "Owner notified · {0}", notNotified: "Not notified yet",
30
+ updateBtn: "Update", ownerUpdates: "Owner updates it", updateMany: "Update {0} Fleets that allow it", updateManyOne: "Update {0} Fleet that allows it",
31
+ askOne: "Update {0} to AgEnD v{1}? It starts when that Fleet's agents are idle. Its owner is told now and when it finishes.",
32
+ askMany: "Update {0} Fleets to AgEnD v{1}?", askOk: "Update",
33
+ replaceBtn: "Update to v{0} instead",
34
+ askReplace: "Update {0} to AgEnD v{1} instead of v{2}? The waiting request is cancelled first. It starts when that Fleet's agents are idle. Its owner is told now and when it finishes.", cancel: "Cancel", tryAgain: "Try again",
35
+ stSending: "Sending…", stConnect: "Waiting for the Fleet to connect", stWaiting: "Waiting for its agents to be idle · since {0}",
36
+ stUpdating: "Updating…", stDone: "Updated to v{0} · {1}", stRolledBack: "Update failed; back on v{0}",
37
+ stBusy: "Did not start: agents were busy for 24 hours", stOffline: "Did not start: the Fleet has not connected for 7 days.",
38
+ stCancelled: "The owner cancelled this update", cancelling: "Cancelling…", stGone: "Update failed and the Fleet has not come back. Contact {0}.",
39
+ startedMany: "Started for {0} Fleets.", startedManyOne: "Started for {0} Fleet.", startedSome: "Started for {0} Fleets; {1} could not start.", startedSomeOne: "Started for {0} Fleet; {1} could not start.",
40
+ rfOwnerOff: "The owner no longer allows updates from the Hub.", rfNotService: "This Fleet was started by hand, so it cannot be updated from here.",
41
+ rfNotFound: "That Fleet could not find v{0} on npm.", rfNpm: "That Fleet could not reach the update source. Nothing was changed.",
42
+ rfPermission: "That Fleet has no permission to install updates. Its owner must update it by hand.", rfCurrent: "Already on v{0}.",
43
+ rfOpen: "An update is already open for this Fleet.", rfUnsupported: "This Fleet's AgEnD is too old to be updated from the Hub.",
44
+ rfGone: "This Fleet is no longer connected to this Hub.", rfRunning: "That Fleet was already updating.",
45
+ rfNoRec: "Set a recommended version first.", rfRevision: "The recommended version changed just now. Check it and try again.",
46
+ rfFailed: "The update did not finish.",
47
+ filter: "Needs update",
48
+ colVersion: "AgEnD version", colLast: "Last connected",
49
+ unknown: "Unknown", now: "Now", never: "Never",
50
+ tagTooOld: "Too old for rooms", tagNeeds: "Needs update", tagUnknown: "Version unknown", tagCurrent: "Up to date",
51
+ whyTooOld: "This Fleet's agents cannot answer in rooms until it is updated.",
52
+ whyNeeds: "This Fleet runs {0}; the recommended version is {1}.",
53
+ whyNeedsNoRec: "This Fleet runs {0}, older than the recommended version.",
54
+ whyUnknown: "This Fleet is too old to report its version. Ask its owner to update it.",
55
+ bannerOne: "Your Fleet “{0}” runs an older AgEnD ({1}). Some features here will not work until you update it. Open your AgEnD dashboard and press Update.",
56
+ bannerOneUnknown: "Your Fleet “{0}” runs an older AgEnD. Some features here will not work until you update it. Open your AgEnD dashboard and press Update.",
57
+ bannerOneNoName: "One of your Fleets runs an older AgEnD. Some features here will not work until you update it. Open your AgEnD dashboard and press Update.",
58
+ bannerMany: "{0} of your Fleets run an older AgEnD. Some features here will not work until you update them. Open your AgEnD dashboard and press Update.",
59
+ close: "Close",
60
+ },
61
+ "zh-TW": {
62
+ allCurrent: "{0} 個 Fleet 都是建議版本或更新的版本。", allCurrentOne: "{0} 個 Fleet 都是建議版本或更新的版本。",
63
+ someBehind: "{1} 個 Fleet 當中有 {0} 個需要更新。", someBehindOnly: "{1} 個 Fleet 當中有 {0} 個需要更新。", someBehindOne: "{1} 個 Fleet 當中有 {0} 個需要更新。",
64
+ noRecommended: "{0} 個使用中的 Fleet。", noRecommendedOne: "{0} 個使用中的 Fleet。",
65
+ noRecommendedSet: "{0} 個使用中的 Fleet。設定建議版本後,就能看出哪些落後。", noRecommendedSetOne: "{0} 個使用中的 Fleet。設定建議版本後,就能看出哪些落後。",
66
+ recTitle: "建議的 AgEnD 版本", recHub: "與這個 Hub 相同({0})", recHubPlain: "與這個 Hub 相同",
67
+ recSpecific: "指定版本", recVersion: "版本", recVersionPh: "例如 2.4.0", recNone: "不建議版本",
68
+ recLead: "低於這個版本的 Fleet 會通知擁有者並提供更新按鈕。沒有擁有者的動作,不會更新任何東西。",
69
+ recPreview: "會有 {0} 個 Fleet 收到更新通知。", recPreviewOne: "會有 {0} 個 Fleet 收到更新通知。", recPreviewNone: "不會通知任何 Fleet。",
70
+ recChecking: "正在檢查 npm…", recSave: "儲存", recSaving: "儲存中…", recSaved: "已儲存。",
71
+ errInvalid: "請輸入版本號,例如 2.4.0。", errNotFound: "在 npm 上找不到 {0} 這個版本。",
72
+ errNpm: "無法連上 npm 檢查 {0},請再試一次。", errHubVersion: "讀不到這個 Hub 的版本,請改為指定版本。",
73
+ errConflict: "剛剛有人改了這個設定,已顯示最新的選擇。請確認後再儲存。", errFailed: "沒有儲存,請再試一次。",
74
+ notified: "已通知擁有者 · {0}", notNotified: "尚未通知",
75
+ updateBtn: "更新", ownerUpdates: "由擁有者自行更新", updateMany: "更新 {0} 個已允許的 Fleet", updateManyOne: "更新 {0} 個已允許的 Fleet",
76
+ askOne: "要把 {0} 更新到 AgEnD v{1} 嗎?會等那個 Fleet 的 Agent 都閒置才開始。現在和完成時都會通知擁有者。",
77
+ askMany: "要把 {0} 個 Fleet 更新到 AgEnD v{1} 嗎?", askOk: "更新",
78
+ replaceBtn: "改為更新到 v{0}",
79
+ askReplace: "要改把 {0} 更新到 AgEnD v{1}(取代 v{2})嗎?會先取消等待中的要求,再等那個 Fleet 的 Agent 都閒置才開始。現在和完成時都會通知擁有者。", cancel: "取消", tryAgain: "再試一次",
80
+ stSending: "傳送中…", stConnect: "等待 Fleet 連接", stWaiting: "等待 Agent 閒置 · {0} 起",
81
+ stUpdating: "更新中…", stDone: "已更新到 v{0} · {1}", stRolledBack: "更新失敗,已回到 v{0}",
82
+ stBusy: "沒有開始:Agent 連續 24 小時都在忙", stOffline: "沒有開始:這個 Fleet 已經 7 天沒有連接。",
83
+ stCancelled: "擁有者取消了這次更新", cancelling: "取消中…", stGone: "更新失敗,而且 Fleet 沒有重新連接。請聯絡 {0}。",
84
+ startedMany: "已為 {0} 個 Fleet 開始。", startedManyOne: "已為 {0} 個 Fleet 開始。", startedSome: "已為 {0} 個 Fleet 開始;{1} 個無法開始。", startedSomeOne: "已為 {0} 個 Fleet 開始;{1} 個無法開始。",
85
+ rfOwnerOff: "擁有者已不允許由 Hub 更新。", rfNotService: "這個 Fleet 是手動啟動的,無法從這裡更新。",
86
+ rfNotFound: "那個 Fleet 在 npm 上找不到 v{0}。", rfNpm: "那個 Fleet 連不上更新來源,沒有任何變更。",
87
+ rfPermission: "那個 Fleet 沒有安裝更新的權限,需要擁有者手動更新。", rfCurrent: "已經是 v{0}。",
88
+ rfOpen: "這個 Fleet 已經有一個進行中的更新。", rfUnsupported: "這個 Fleet 的 AgEnD 太舊,無法從 Hub 更新。",
89
+ rfGone: "這個 Fleet 已不再連接到這個 Hub。", rfRunning: "那個 Fleet 已經在更新。",
90
+ rfNoRec: "請先設定建議版本。", rfRevision: "建議版本剛剛改了,請確認後再試一次。",
91
+ rfFailed: "更新沒有完成。",
92
+ filter: "需要更新",
93
+ colVersion: "AgEnD 版本", colLast: "上次連接",
94
+ unknown: "不明", now: "目前已連接", never: "從未連接",
95
+ tagTooOld: "版本太舊,無法使用房間", tagNeeds: "需要更新", tagUnknown: "版本不明", tagCurrent: "已是建議版本",
96
+ whyTooOld: "這個 Fleet 的 Agent 要更新後才能在房間裡回答。",
97
+ whyNeeds: "這個 Fleet 是 {0},建議版本是 {1}。",
98
+ whyNeedsNoRec: "這個 Fleet 是 {0},比建議版本舊。",
99
+ whyUnknown: "這個 Fleet 版本太舊,無法回報版本。請通知擁有者更新。",
100
+ bannerOne: "你的 Fleet「{0}」是較舊的 AgEnD({1}),這裡的部分功能要更新後才能使用。請開啟你的 AgEnD 儀表板,按「更新」。",
101
+ bannerOneUnknown: "你的 Fleet「{0}」是較舊的 AgEnD,這裡的部分功能要更新後才能使用。請開啟你的 AgEnD 儀表板,按「更新」。",
102
+ bannerOneNoName: "你有一個 Fleet 是較舊的 AgEnD,這裡的部分功能要更新後才能使用。請開啟你的 AgEnD 儀表板,按「更新」。",
103
+ bannerMany: "你有 {0} 個 Fleet 是較舊的 AgEnD,這裡的部分功能要更新後才能使用。請開啟你的 AgEnD 儀表板,按「更新」。",
104
+ close: "關閉",
105
+ },
106
+ });
107
+ export const hv = (key, ...args) => t(`hubVersions.${key}`, ...args);
108
+ /** M-3170: a count of Fleets — a one-Fleet sentence (`<key>One`) for 1; zh-TW's is the same sentence as for any count. */
109
+ const hvn = (key, n, ...args) => hv(n === 1 ? `${key}One` : key, String(n), ...args);
110
+
111
+ // The server's states (M-3136), in its priority order.
112
+ const STATES = ["too-old-rooms", "needs-update", "unknown", "current"];
113
+ const TAG = { "too-old-rooms": "tagTooOld", "needs-update": "tagNeeds", unknown: "tagUnknown", current: "tagCurrent" };
114
+ /** True when the overview carries the version fields (an older Hub's rows do not: nothing new is drawn). */
115
+ export const hasVersions = (fleets) => Array.isArray(fleets) && fleets.some((f) => STATES.includes(f?.versionState));
116
+ /** A Fleet that needs its owner's Update (the filter's set, and the summary's count): every state but current. */
117
+ export const behind = (f) => STATES.includes(f?.versionState) && f.versionState !== "current";
118
+
119
+ /** The summary's counts, over the active rows (a revoked Fleet is not counted). */
120
+ export function versionCounts(fleets) {
121
+ const active = (fleets || []).filter((f) => f && f.status === "active");
122
+ return { total: active.length, needs: active.filter(behind).length };
123
+ }
124
+
125
+ /** The summary line above Connected fleets (§2.2). */
126
+ export function summaryText(fleets, recommended, canRecommend = false) {
127
+ const { total, needs } = versionCounts(fleets);
128
+ // M-3141: the clause comes back only where there is a control to set it (this Hub serves the setting).
129
+ if (!recommended) return hvn(canRecommend ? "noRecommendedSet" : "noRecommended", total);
130
+ // M-3177 (Fable): one Fleet in all is "The Fleet needs an update.", never "1 of 1 Fleets…".
131
+ if (needs > 0 && total === 1) return hv("someBehindOnly", String(needs), String(total));
132
+ return needs > 0 ? hvn("someBehind", needs, String(total)) : hvn("allCurrent", total);
133
+ }
134
+
135
+ /** "Now" (with the green dot), a relative time ("3 days ago" / 「3 天前」), or "Never". */
136
+ /** "5 minutes ago" / 「5 分鐘前」, in hours then days past those. */
137
+ function ago(at, now) {
138
+ const rtf = new Intl.RelativeTimeFormat(lang() === "zh-TW" ? "zh-TW" : "en", { numeric: "always" });
139
+ const s = Math.max(0, Math.round((now - at) / 1000));
140
+ if (s < 3600) return rtf.format(-Math.max(1, Math.round(s / 60)), "minute");
141
+ if (s < 86400) return rtf.format(-Math.round(s / 3600), "hour");
142
+ return rtf.format(-Math.round(s / 86400), "day");
143
+ }
144
+
145
+ export function lastConnectedText(f, now = Date.now()) {
146
+ if (f?.connected === true) return hv("now");
147
+ const at = Number(f?.lastConnectedAt);
148
+ if (!Number.isFinite(at) || at <= 0) return hv("never");
149
+ return ago(at, now);
150
+ }
151
+
152
+ /**
153
+ * §3.4: under a behind Fleet's tag once a recommendation is set — "Owner notified · {when}" (the Fleet acknowledged the
154
+ * offer for the current recommendation), else "Not notified yet" (too old to be told, or not online since). None for a
155
+ * Fleet that is current, or with no recommendation.
156
+ */
157
+ export function notifiedText(f, recommended, now = Date.now()) {
158
+ if (!recommended || !behind(f)) return "";
159
+ const at = Number(f?.recommendationNotifiedAt);
160
+ return Number.isFinite(at) && at > 0 ? hv("notified", ago(at, now)) : hv("notNotified");
161
+ }
162
+
163
+ /** One warn tag's sentence (shown under the row), or "" for Up to date. */
164
+ export function tagWhy(f, recommended) {
165
+ if (f?.versionState === "too-old-rooms") return hv("whyTooOld");
166
+ if (f?.versionState === "needs-update") return recommended ? hv("whyNeeds", f.version || hv("unknown"), recommended) : hv("whyNeedsNoRec", f.version || hv("unknown"));
167
+ if (f?.versionState === "unknown") return hv("whyUnknown");
168
+ return "";
169
+ }
170
+
171
+ /**
172
+ * A row's version facts: AgEnD version, last connected, its state tag and, for a warn tag, its sentence under them
173
+ * (shown, not hidden behind a hover: a tap target the size of a tag cannot be one on a phone).
174
+ */
175
+ export function FleetVersionCells({ fleet, recommended = null, now }) {
176
+ const state = STATES.includes(fleet?.versionState) ? fleet.versionState : null;
177
+ const why = tagWhy(fleet, recommended);
178
+ return html`<span class="hub-fleet-version">
179
+ ${state ? html`<span class=${`tag hub-fleet-tag${why ? " warn" : ""}`}>${hv(TAG[state])}</span>` : null}
180
+ <span class="hub-fleet-ver"><small class="note">${hv("colVersion")}</small> <span>${fleet?.version || hv("unknown")}</span></span>
181
+ <span class="hub-fleet-last"><small class="note">${hv("colLast")}</small> ${fleet?.connected === true ? html`<span class="dot ok" aria-hidden="true"></span> ` : null}<span>${lastConnectedText(fleet, now)}</span></span>
182
+ ${why ? html`<small class="note hub-fleet-why">${why}</small>` : null}
183
+ ${notifiedText(fleet, recommended, now) ? html`<small class="note hub-fleet-notified">${notifiedText(fleet, recommended, now)}</small>` : null}
184
+ </span>`;
185
+ }
186
+
187
+ /** The summary line and the "Needs update" filter (shown while any Fleet needs one). */
188
+ export function FleetVersionsSummary({ fleets, recommended = null, canRecommend = false, filtered = false, onFilter = () => {} }) {
189
+ const { needs } = versionCounts(fleets);
190
+ return html`<div class="hub-fleet-summary"><p class="note" role="status">${summaryText(fleets, recommended, canRecommend)}</p>
191
+ ${/* Pressed, it stays (Fable): the last Fleet that needed an update may be updated meanwhile, and the list must come back. */ ""}
192
+ ${needs > 0 || filtered ? html`<button type="button" class="btn btn-sm hub-fleet-filter" aria-pressed=${filtered ? "true" : "false"} onClick=${() => onFilter(!filtered)}>${hv("filter")}</button>` : null}</div>`;
193
+ }
194
+
195
+ const SEEN_KEY = "agend_hub_versions_banner_closed";
196
+ /** One sign-in's mark: a one-way digest of what tells it from the next (never the value itself in storage). */
197
+ function signInMark(v) {
198
+ let h = 0x811c9dc5;
199
+ for (const c of String(v)) { h ^= c.codePointAt(0); h = Math.imul(h, 0x01000193) >>> 0; }
200
+ return h.toString(36);
201
+ }
202
+ /**
203
+ * §2.3: a signed-in person whose own Fleet is behind is told once, here. Closed, it stays away for this sign-in
204
+ * (`signIn`: what tells one sign-in from the next — the session's CSRF token, new at every sign-in) and comes back on
205
+ * the next while still true.
206
+ */
207
+ export function OlderFleetBanner({ client, signIn = "" }) {
208
+ const [mine, setMine] = useState(null);
209
+ const mark = signInMark(signIn);
210
+ const seen = () => { try { return sessionStorage.getItem(SEEN_KEY) === mark; } catch { return false; } };
211
+ const [, redraw] = useState(0);
212
+ const closed = seen(); // read each time: a new sign-in has a new mark
213
+ useEffect(() => {
214
+ if (closed || typeof client?.myFleets !== "function") return undefined;
215
+ let live = true;
216
+ client.myFleets().then((r) => { if (live && r && r.ok !== false && Array.isArray(r.fleets)) setMine(r.fleets.filter(behind)); }, () => {});
217
+ return () => { live = false; };
218
+ }, [closed, mark]);
219
+ if (closed || !mine || !mine.length) return null;
220
+ const one = mine.length === 1 ? mine[0] : null;
221
+ const text = one ? (!one.label ? hv("bannerOneNoName") : one.version ? hv("bannerOne", one.label, one.version) : hv("bannerOneUnknown", one.label))
222
+ : hv("bannerMany", String(mine.length));
223
+ const close = () => { try { sessionStorage.setItem(SEEN_KEY, mark); } catch { /* this page only */ } setMine([]); redraw((n) => n + 1); };
224
+ return html`<div class="hub-banner warn hub-versions-banner" role="status"><span>${text}</span>
225
+ <button type="button" class="icon-btn" aria-label=${hv("close")} title=${hv("close")} onClick=${close}><${Icon} name="close" size=${14} /></button></div>`;
226
+ }
227
+
228
+ const REFUSAL = { "version-invalid": "errInvalid", "version-not-found": "errNotFound", "npm-unavailable": "errNpm", "hub-version-unknown": "errHubVersion", "revision-conflict": "errConflict" };
229
+ /** A refusal in this card's words; the version named is the one the person entered (the server echoes it validated). */
230
+ export function refusalText(r, version) {
231
+ const key = REFUSAL[r?.code] || "errFailed";
232
+ return hv(key, version || "");
233
+ }
234
+
235
+ /**
236
+ * M-3141 (versions spec §3.1): Administration's "Recommended AgEnD version" card, above Connected fleets. Three choices —
237
+ * Same as this Hub (the default once first saved; it follows the Hub), A specific version (checked on npm), No
238
+ * recommendation (the state before anyone set it). The effect is shown before it applies (the group-permissions
239
+ * preview's style): the server's preview of the draft, refreshed as it changes, then one Save (its revision guards a
240
+ * concurrent change). A Hub without the setting (older): nothing is drawn, and `onAvailable(false)` says so.
241
+ */
242
+ export function RecommendedVersionCard({ client, onSaved = () => {}, onAvailable = () => {} }) {
243
+ const [state, setState] = useState(null); // the saved setting (GET), or { missing: true }
244
+ const [mode, setMode] = useState("hub"), [version, setVersion] = useState("");
245
+ const [preview, setPreview] = useState(null); // { pending } | { ok, affected, recommendedVersion } | { error }
246
+ const [saving, setSaving] = useState(false), [msg, setMsg] = useState(null);
247
+ // Nothing is previewed (an npm check) only for opening the page: once the person changes the form, or presses Save.
248
+ const [touched, setTouched] = useState(false);
249
+ const load = async () => {
250
+ const r = typeof client?.recommendedVersion === "function" ? await client.recommendedVersion() : { ok: false };
251
+ if (!r || r.ok === false) { setState({ missing: true }); onAvailable(false); return null; }
252
+ setState(r); onAvailable(true);
253
+ // Unsaved (configured: false): the form starts on Same as this Hub (V1); saved: on what was saved.
254
+ setMode(r.configured ? r.mode : "hub"); setVersion(r.mode === "specific" && r.version ? r.version : "");
255
+ return r;
256
+ };
257
+ useEffect(() => { void load(); }, []);
258
+ const target = version.trim();
259
+ const changed = !!state && !state.missing && (!state.configured || mode !== state.mode || (mode === "specific" && target !== (state.version || "")));
260
+ // The server's preview of the draft (a stale answer, for an older draft, is dropped).
261
+ useEffect(() => {
262
+ if (!touched || !changed || (mode === "specific" && !target)) { setPreview(null); return undefined; }
263
+ let live = true;
264
+ setPreview({ pending: true });
265
+ const t = setTimeout(async () => {
266
+ const r = await client.previewRecommendedVersion({ mode, ...(mode === "specific" ? { version: target } : {}) });
267
+ if (!live) return;
268
+ setPreview(r && r.ok !== false ? { ok: true, affected: Number(r.affected) || 0, recommendedVersion: r.recommendedVersion ?? null } : { error: refusalText(r, target) });
269
+ }, mode === "specific" ? 500 : 0);
270
+ return () => { live = false; clearTimeout(t); };
271
+ }, [touched, changed, mode, target]);
272
+ if (!state || state.missing) return null;
273
+ const save = async () => {
274
+ if (saving) return;
275
+ if (!preview?.ok) { setTouched(true); return; } // first the effect (the preview), then Save applies it
276
+ setSaving(true); setMsg(null);
277
+ const r = await client.saveRecommendedVersion({ mode, ...(mode === "specific" ? { version: target } : {}), ifRevision: state.revision });
278
+ setSaving(false);
279
+ if (r && r.ok !== false) { setMsg({ ok: true, text: hv("recSaved") }); await load(); setPreview(null); setTouched(false); onSaved(); return; }
280
+ setMsg({ ok: false, text: refusalText(r, target) });
281
+ if (r?.code === "revision-conflict") { await load(); onSaved(); } // their choice is shown
282
+ };
283
+ const radio = (value, label, extra = null) => html`<label class="check hub-rec-choice"><input type="radio" name="hubRecMode" value=${value}
284
+ checked=${mode === value} onChange=${() => { setMode(value); setMsg(null); setTouched(true); }} /><span>${label}</span>${extra}</label>`;
285
+ return html`<section class="card hub-rec-card"><h3>${hv("recTitle")}</h3>
286
+ <div class="hub-rec-choices" role="radiogroup" aria-label=${hv("recTitle")}>
287
+ ${radio("hub", state.hubVersion ? hv("recHub", state.hubVersion) : hv("recHubPlain"))}
288
+ ${radio("specific", hv("recSpecific"), mode === "specific" ? html`<span class="field hub-rec-version"><span class="sr-only">${hv("recVersion")}</span>
289
+ <input id="hubRecVersion" type="text" inputmode="text" autocomplete="off" spellcheck=${false} placeholder=${hv("recVersionPh")} value=${version}
290
+ onInput=${(e) => { setVersion(e.target.value); setMsg(null); setTouched(true); }} /></span>` : null)}
291
+ ${radio("none", hv("recNone"))}
292
+ </div>
293
+ <p class="note">${hv("recLead")}</p>
294
+ ${changed && preview ? html`<p class=${preview.error ? "err" : "note hub-rec-preview"} role="status" aria-live="polite">${preview.pending ? hv("recChecking")
295
+ : preview.error ? preview.error : mode === "none" || preview.affected === 0 ? hv("recPreviewNone") : hvn("recPreview", preview.affected)}</p>` : null}
296
+ ${msg ? html`<p class=${msg.ok ? "note" : "err"} role=${msg.ok ? "status" : "alert"}>${msg.text}</p>` : null}
297
+ ${changed ? html`<div class="save-row"><button type="button" class="btn btn-primary" disabled=${saving || !!preview?.pending || !!preview?.error || (mode === "specific" && !target)} onClick=${save}>${saving ? hv("recSaving") : hv("recSave")}</button></div>` : null}
298
+ </section>`;
299
+ }
300
+
301
+ // ── M-3145 (versions spec §4.2, §4.5; API M-3144): updating Fleets whose owner allows it ─────────────────────────────
302
+
303
+ const RF = { "owner-disabled": "rfOwnerOff", "not-service": "rfNotService", "version-not-found": "rfNotFound", "npm-unavailable": "rfNpm",
304
+ "no-permission": "rfPermission", "already-current": "rfCurrent", "request-open": "rfOpen", unsupported: "rfUnsupported", revoked: "rfGone",
305
+ "not-found": "rfGone", "update-running": "rfRunning", "no-recommendation": "rfNoRec", "revision-conflict": "rfRevision" };
306
+ /** A refusal or a Fleet's reason in words ({0}: the version it names); anything else, generically. */
307
+ export function updateReasonText(code, version = "") { return hv(RF[code] || "rfFailed", version); }
308
+
309
+ /** True when the overview carries phase 3's fields (an older Hub: no buttons, no lines). */
310
+ export const hasUpdates = (fleets) => Array.isArray(fleets) && fleets.some((f) => f && "updatesAllowed" in f);
311
+ const OPEN = new Set(["queued", "waiting", "updating"]);
312
+ /** A Fleet the administrator may update now: active, behind, its owner allows it, nothing open for it. */
313
+ export const updatable = (f, recommended) => !!recommended && f?.status === "active" && behind(f) && f.updatesAllowed === true
314
+ && !(f.updateRequest && OPEN.has(f.updateRequest.state));
315
+
316
+ /**
317
+ * §5's replacement: a request not yet started (queued or waiting, no cancel pending) for another version than the saved
318
+ * recommendation can be replaced by one for the recommendation — the Hub cancels the old one first. Never while updating.
319
+ */
320
+ export const replaceable = (f, recommended) => !!recommended && f?.status === "active" && behind(f) && f.updatesAllowed === true
321
+ && !!f.updateRequest && (f.updateRequest.state === "queued" || f.updateRequest.state === "waiting")
322
+ && f.updateRequest.cancelRequested !== true && f.updateRequest.version !== recommended;
323
+
324
+ /** §4.5: the request's one status line (and its one action: Cancel while waiting, Try again after a failure). */
325
+ export function updateStatus(f, now = Date.now()) {
326
+ const r = f?.updateRequest;
327
+ if (!r) return null;
328
+ const owner = f.owner?.name || "";
329
+ switch (r.state) {
330
+ // Not yet accepted by the Fleet (held up to 7 days while it is offline): it can be withdrawn, as a waiting one can.
331
+ case "queued": return { text: f.connected === true ? hv("stSending") : hv("stConnect"), action: "cancel" };
332
+ case "waiting": return { text: hv("stWaiting", r.waitingSince ? ago(r.waitingSince, now) : ""), action: "cancel" };
333
+ case "updating": return { text: hv("stUpdating") };
334
+ case "done": return { text: hv("stDone", r.version || "", ago(r.updatedAt || now, now)) };
335
+ case "rolled-back": return { text: hv("stRolledBack", r.currentVersion || ""), action: "retry" };
336
+ case "expired": return { text: hv(r.reasonCode === "offline-7d" ? "stOffline" : "stBusy"), action: "retry" };
337
+ case "cancelled": return { text: hv("stCancelled") };
338
+ case "failed": return r.reasonCode === "rollback-failed" ? { text: hv("stGone", owner) } : { text: updateReasonText(r.reasonCode, r.version), action: "retry" };
339
+ case "refused": return { text: updateReasonText(r.reasonCode, r.reasonCode === "already-current" ? r.currentVersion : r.version), action: r.reasonCode === "already-current" ? null : "retry" };
340
+ default: return null;
341
+ }
342
+ }
343
+
344
+ const newKey = () => (globalThis.crypto?.randomUUID?.() || `${Date.now()}-${Math.random()}`);
345
+ /**
346
+ * Ask, then start: one or many Fleets, the target always the saved recommendation (its revision guards a change made
347
+ * meanwhile). Resolves { ok, text } for the page to say, or null when the administrator said no.
348
+ */
349
+ export async function startUpdates(client, fleets, recommended, revision, replacing = null) {
350
+ if (!fleets.length) return null;
351
+ const one = fleets.length === 1 ? fleets[0] : null, name = one ? one.label || one.owner?.name || "" : "";
352
+ const message = one && replacing ? hv("askReplace", name, recommended, replacing) : one ? hv("askOne", name, recommended) : hv("askMany", String(fleets.length), recommended);
353
+ const yes = await confirmDialog({ title: hv("askOk"), message, confirmLabel: hv("askOk") });
354
+ if (!yes) return null;
355
+ const r = await client.updateFleets({ fleetIds: fleets.map((f) => f.id), ifRevision: revision, idempotencyKey: newKey() });
356
+ if (!r || r.ok === false) return { ok: false, text: updateReasonText(r?.code, recommended) };
357
+ const started = Array.isArray(r.requests) ? r.requests.length : 0, refused = Array.isArray(r.refused) ? r.refused : [];
358
+ if (one) return refused.length ? { ok: false, text: updateReasonText(refused[0].code, recommended) } : { ok: true, text: "" };
359
+ return { ok: refused.length === 0, text: refused.length ? hvn("startedSome", started, String(refused.length)) : hvn("startedMany", started) };
360
+ }
361
+
362
+ /** A Connected fleets row's update part: its status line, else Update (the owner allows it) or "Owner updates it". */
363
+ export function FleetUpdateCell({ fleet, recommended = null, revision = 0, client, onChanged = () => {}, now }) {
364
+ const [busy, setBusy] = useState(false), [msg, setMsg] = useState(null);
365
+ if (!recommended || !behind(fleet) && !fleet?.updateRequest) return null;
366
+ const status = updateStatus(fleet, now);
367
+ const run = async (fn) => { if (busy) return; setBusy(true); setMsg(null); const r = await fn(); setBusy(false); if (r) { if (r.text) setMsg(r); onChanged(); } };
368
+ const start = () => run(() => startUpdates(client, [fleet], recommended, revision));
369
+ const replace = () => run(() => startUpdates(client, [fleet], recommended, revision, fleet.updateRequest.version));
370
+ const cancel = () => run(async () => { const r = await client.cancelFleetUpdate(fleet.updateRequest.id); return r && r.ok !== false ? { ok: true, text: "" } : { ok: false, text: updateReasonText(r?.code) }; });
371
+ return html`<span class="hub-fleet-update">
372
+ ${status ? html`<small class="note hub-fleet-update-status">${status.text}</small>
373
+ ${/* A cancel the Fleet has not confirmed yet (it may already have claimed the request): Cancelling…, once. */ ""}
374
+ ${status.action === "cancel" ? html`<button type="button" class="btn btn-sm" disabled=${busy || fleet.updateRequest?.cancelRequested === true} onClick=${cancel}>${fleet.updateRequest?.cancelRequested === true ? hv("cancelling") : hv("cancel")}</button>` : null}
375
+ ${replaceable(fleet, recommended) ? html`<button type="button" class="btn btn-sm hub-fleet-update-replace" disabled=${busy} onClick=${replace}>${hv("replaceBtn", recommended)}</button>` : null}
376
+ ${status.action === "retry" && updatable(fleet, recommended) ? html`<button type="button" class="btn btn-sm" disabled=${busy} onClick=${start}>${hv("tryAgain")}</button>` : null}`
377
+ : fleet.updatesAllowed === true ? html`<button type="button" class="btn btn-sm hub-fleet-update-btn" disabled=${busy} onClick=${start}>${hv("updateBtn")}</button>`
378
+ : html`<small class="note hub-fleet-owner-updates">${hv("ownerUpdates")}</small>`}
379
+ ${msg ? html`<small class=${msg.ok ? "note" : "err"} role=${msg.ok ? "status" : "alert"}>${msg.text}</small>` : null}
380
+ </span>`;
381
+ }
382
+
383
+ /** Above the list (§4.2): "Update {n} Fleets that allow it", while at least one qualifies. */
384
+ export function UpdateAllowedButton({ fleets, recommended = null, revision = 0, client, onChanged = () => {} }) {
385
+ const [busy, setBusy] = useState(false), [msg, setMsg] = useState(null);
386
+ const ready = (fleets || []).filter((f) => updatable(f, recommended));
387
+ if (!ready.length && !msg) return null;
388
+ const go = async () => { if (busy) return; setBusy(true); setMsg(null); const r = await startUpdates(client, ready, recommended, revision); setBusy(false); if (r) { setMsg(r.text ? r : null); onChanged(); } };
389
+ return html`<div class="hub-fleet-update-all">
390
+ ${ready.length ? html`<button type="button" class="btn btn-sm btn-primary" disabled=${busy} onClick=${go}>${hvn("updateMany", ready.length)}</button>` : null}
391
+ ${msg ? html`<p class=${msg.ok ? "note" : "err"} role=${msg.ok ? "status" : "alert"}>${msg.text}</p>` : null}
392
+ </div>`;
393
+ }
@@ -0,0 +1,28 @@
1
+ // M-3118: independent namespace so a cached room dictionary can still render new stop events.
2
+ import { register, t, lang } from "/assets/app-i18n.js";
3
+ register("hubRoomAgent", {
4
+ en: {
5
+ all: "Agents can't use @All agents. This message was not sent to other agents.",
6
+ ambiguous: 'More than one member is named "{0}", so this mention was not delivered.',
7
+ depth: "Agents have asked each other several times in a row, so this stops here. They can ask each other again after a person writes in the room.",
8
+ rate: "{0} is posting too often, so this mention was not delivered. It can try again after {1}.",
9
+ capacity: "The Hub is busy, so this mention was not delivered.",
10
+ via: "{0} via {1}",
11
+ },
12
+ "zh-TW": {
13
+ all: "Agent 不能使用 @所有 Agent,這則訊息沒有轉給其他 Agent。",
14
+ ambiguous: "房間裡有不只一位「{0}」,這個 @ 沒有送出。",
15
+ depth: "Agent 之間已經連續互相提問多次,先停在這裡。有人在房間發言後,Agent 才能再互相提問。",
16
+ rate: "{0} 發言太頻繁,這個 @ 沒有送出。{1} 後可以再試。",
17
+ capacity: "Hub 目前忙碌,這個 @ 沒有送出。",
18
+ via: "{0} 透過 {1}",
19
+ },
20
+ });
21
+ export const hra = (key, ...args) => t(`hubRoomAgent.${key}`, ...args);
22
+ export function agentStopText(system) {
23
+ if (!system || !["all", "ambiguous", "depth", "rate", "capacity"].includes(system.reason)) return null;
24
+ if (system.reason !== "rate") return hra(system.reason, String(system.name || ""));
25
+ if (!Number.isSafeInteger(system.retryAt) || system.retryAt < 0) return null;
26
+ const time = new Date(Math.ceil(system.retryAt / 60_000) * 60_000).toLocaleTimeString(lang(), { hour: "2-digit", minute: "2-digit" });
27
+ return hra("rate", String(system.name || ""), time);
28
+ }
@@ -71,8 +71,11 @@ export function refusalText(r) {
71
71
  /**
72
72
  * The composer. `store`: the room's (send); `detail`: the room GET; `reply`/`onReply`: the message being answered (the
73
73
  * thread's Reply); `closed`: archived or no longer a member (the box says why, nothing is sent).
74
+ * M-3125: `canSendEmpty` — Send works with an empty box (the caller has files ready).
75
+ * M-3117 (for M-3125's files): `attach` is ComposerInput's own ({ title, onFiles } — the Fleet's + left of the box), `pending`
76
+ * the files waiting, drawn first in the box (where the 1:1 chat puts its PendingFiles). Neither given: no Attach.
74
77
  */
75
- export function RoomComposer({ store, detail, reply = null, onReply = () => {}, closed = false, inputRef, insertRef }) {
78
+ export function RoomComposer({ store, detail, reply = null, onReply = () => {}, closed = false, inputRef, insertRef, attach = null, pending = null, canSendEmpty = false }) {
76
79
  const [value, setValue] = useState(""), [msg, setMsg] = useState(null), [busy, setBusy] = useState(false), [pick, setPick] = useState(0);
77
80
  const own = useRef(null), input = inputRef || own;
78
81
  const [caret, setCaret] = useState(0);
@@ -80,6 +83,8 @@ export function RoomComposer({ store, detail, reply = null, onReply = () => {},
80
83
  const palette = at && options.length ? options : null, chosen = palette ? palette[Math.min(pick, palette.length - 1)] : null;
81
84
  const room = detail?.room || {}, group = room.kind === "group";
82
85
  const short = useShortPlaceholder();
86
+ // M-3117: the Fleet chat's box takes the focus when its conversation opens (panel-chat.js Composer): a room's too.
87
+ useEffect(() => { if (!closed) input.current?.focus(); }, [room.id || "", closed]);
83
88
  // 「在這裡 @ 它」 from the members panel: the mention goes into the box, after what is there.
84
89
  if (insertRef) insertRef.current = (text) => { setValue((v) => `${v && !/\s$/.test(v) ? `${v} ` : v}${text} `); setTimeout(() => input.current?.focus(), 0); };
85
90
  const complete = (o) => {
@@ -88,7 +93,8 @@ export function RoomComposer({ store, detail, reply = null, onReply = () => {},
88
93
  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);
89
94
  };
90
95
  const send = async () => {
91
- const text = value.trim(); if (!text || busy || closed) return;
96
+ // M-3125: `canSendEmpty` — files are ready to go, so a post may be the files alone (the server takes it).
97
+ const text = value.trim(); if ((!text && !canSendEmpty) || busy || closed) return;
92
98
  setBusy(true); setMsg(null);
93
99
  const r = await store.send(text, { mentions: mentionsIn(text, detail), ...(reply ? { replyTo: reply.roomMessage } : {}) });
94
100
  setBusy(false);
@@ -103,8 +109,10 @@ export function RoomComposer({ store, detail, reply = null, onReply = () => {},
103
109
  };
104
110
  const track = (v) => { setValue(v); setMsg(null); setCaret(input.current ? input.current.selectionStart ?? v.length : v.length); };
105
111
  const paletteId = `hubMention-${room.id || "room"}`, optId = (o) => `${paletteId}-${o.key}`;
106
- if (closed) return html`<div class="composer-box"><p class="note" role="status">${hroom(detail?.room?.archived ? "errArchived" : "errNotMember")}</p></div>`;
112
+ // M-3117: as the Fleet chat's dock has it — the box, then a failed send, then the line under it (its .composer-row).
113
+ if (closed) return html`<p class="hub-banner warn" role="status">${hroom(detail?.room?.archived ? "errArchived" : "errNotMember")}</p>`;
107
114
  return html`<div class="composer-box hub-room-composer">
115
+ ${pending}
108
116
  ${palette ? html`<ul data-trust="palette" class="cmd-palette" id=${paletteId} role="listbox" aria-label=${hroom("mentionAll")}>
109
117
  ${palette.map((o) => html`<li key=${o.key} id=${optId(o)} role="option" aria-selected=${o === chosen ? "true" : "false"} class=${o === chosen ? "on" : ""}
110
118
  onMouseDown=${(e) => { e.preventDefault(); complete(o); }}>
@@ -113,11 +121,11 @@ export function RoomComposer({ store, detail, reply = null, onReply = () => {},
113
121
  ${group && value.includes(hroom("mentionAll")) ? html`<p class="note hub-room-allbar" role="status">${allBar(detail)}</p>` : null}
114
122
  ${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>
115
123
  <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}
116
- <${ComposerInput} inputRef=${input} value=${value} placeholder=${room.assistant ? hroom("composerAssistant") : group ? (short ? hroom("composerShort") : hroom("composer", room.name || "")) : hroom("composerDirect", room.name || "")} onValue=${track} onKeyDown=${onKeyDown}
124
+ <${ComposerInput} inputRef=${input} value=${value} attach=${attach} placeholder=${room.assistant ? hroom("composerAssistant") : group ? (short ? hroom("composerShort") : hroom("composer", room.name || "")) : hroom("composerDirect", room.name || "")} onValue=${track} onKeyDown=${onKeyDown}
117
125
  controls=${palette ? paletteId : undefined} expanded=${!!palette} activeDescendant=${chosen ? optId(chosen) : undefined}
118
126
  stop=${{ hidden: true, disabled: true, title: t("chat.stopReply"), label: t("chat.stopReply"), onClick: () => {} }}
119
- send=${{ hidden: false, disabled: !value.trim() || busy, label: t("chat.send"), onClick: () => { void send(); } }} />
120
- ${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}
121
- ${group ? html`<p class="note hub-room-hint">${hroom("composerHint")}</p>` : null}
122
- </div>`;
127
+ send=${{ hidden: false, disabled: (!value.trim() && !canSendEmpty) || busy, label: t("chat.send"), onClick: () => { void send(); } }} />
128
+ </div>
129
+ ${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}
130
+ ${group ? html`<div class="composer-row"><span class="hint hub-room-hint">${hroom("composerHint")}</span></div>` : null}`;
123
131
  }
@@ -4,9 +4,9 @@
4
4
  import { register, t } from "/assets/app-i18n.js";
5
5
 
6
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",
7
+ en: { askOwner: "ask {0}", fewer: "Show fewer", ownerOf: "Owner: {0}", removeFailed: "It was not removed. Try again.", agents: "Agents", ownerAgent: "{0}'s agent", ownerAgentLatin: "{0}'s agent",
8
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",
9
+ "zh-TW": { askOwner: "請通知 {0}", fewer: "收合", ownerOf: "擁有者:{0}", removeFailed: "沒有移除,請再試一次。", agents: "Agent", ownerAgent: "{0}的 Agent", ownerAgentLatin: "{0} 的 Agent",
10
10
  noAgents: "還沒有 Agent。房間管理可以在房間設定加入或邀請。" },
11
11
  });
12
12
  export const hm = (key, ...args) => t(`hubRoomMembers.${key}`, ...args);
@@ -25,7 +25,8 @@ export function memberStatus(m) {
25
25
  const v = presenceView(m);
26
26
  const word = m.kind === "assistant" && v.word === "stIdle" ? hroom("assistantIdleHub") : hroom(v.word);
27
27
  const note = v.noteKey ? hroom(v.noteKey) : v.noteText;
28
- return { dot: presenceDot(v.dot), text: note ? `${word} · ${note}` : word };
28
+ // M-3137 (versions spec §2.4): an agent whose Fleet needs an AgEnD update says whom to ask, not only whose it is.
29
+ return { dot: presenceDot(v.dot), text: note ? `${word} · ${note}` : word, ...(v.word === "needsUpdate" ? { update: true } : {}) };
29
30
  }
30
31
 
31
32
  /** 「林小華的 Agent」, but 「Alex 的 Agent」: a name ending in a Latin letter or digit takes a space before 的 (Lumen). */
@@ -73,7 +74,7 @@ export function RoomMembersPanel({ client = hubClient(), roomId, detail, onMenti
73
74
  };
74
75
  // An agent's second line names whose it is beside its state (「處理中 · 林小華的 Agent」), always shown, not only on hover.
75
76
  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
+ const v = memberStatus(m), owner = (m.kind === "agent" || m.kind === "later") && m.owner?.name ? (v.update ? hm("askOwner", m.owner.name) : ownerAgent(m.owner.name)) : "";
77
78
  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
  };
79
80
  return html`<aside class="hub-room-members">