@songsid/agend 2.4.0-beta.3 → 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 (274) hide show
  1. package/dist/agent-endpoint.d.ts +1 -1
  2. package/dist/agent-endpoint.js +8 -2
  3. package/dist/agent-endpoint.js.map +1 -1
  4. package/dist/auth-api.d.ts +3 -0
  5. package/dist/auth-api.js +15 -1
  6. package/dist/auth-api.js.map +1 -1
  7. package/dist/backend/agy-model-switch.d.ts +22 -0
  8. package/dist/backend/agy-model-switch.js +62 -0
  9. package/dist/backend/agy-model-switch.js.map +1 -0
  10. package/dist/backend/antigravity.js +50 -1
  11. package/dist/backend/antigravity.js.map +1 -1
  12. package/dist/backend/cli-runtime-switch.d.ts +71 -0
  13. package/dist/backend/cli-runtime-switch.js +176 -0
  14. package/dist/backend/cli-runtime-switch.js.map +1 -0
  15. package/dist/backend/codex-model-switch.d.ts +41 -0
  16. package/dist/backend/codex-model-switch.js +170 -0
  17. package/dist/backend/codex-model-switch.js.map +1 -0
  18. package/dist/backend/grok-model-switch.d.ts +16 -0
  19. package/dist/backend/grok-model-switch.js +45 -0
  20. package/dist/backend/grok-model-switch.js.map +1 -0
  21. package/dist/backend/grok.js +1 -1
  22. package/dist/backend/grok.js.map +1 -1
  23. package/dist/backend/muse.d.ts +2 -0
  24. package/dist/backend/muse.js +7 -3
  25. package/dist/backend/muse.js.map +1 -1
  26. package/dist/build-provenance.json +1 -1
  27. package/dist/channel/mcp-server.js +10 -1
  28. package/dist/channel/mcp-server.js.map +1 -1
  29. package/dist/channel/mcp-tools.js +8 -0
  30. package/dist/channel/mcp-tools.js.map +1 -1
  31. package/dist/cli-audited.js +12 -12
  32. package/dist/cli-audited.js.map +1 -1
  33. package/dist/daemon.d.ts +47 -1
  34. package/dist/daemon.js +301 -20
  35. package/dist/daemon.js.map +1 -1
  36. package/dist/delivery-consumed-watch.js +3 -0
  37. package/dist/delivery-consumed-watch.js.map +1 -1
  38. package/dist/fleet-manager.d.ts +102 -0
  39. package/dist/fleet-manager.js +663 -25
  40. package/dist/fleet-manager.js.map +1 -1
  41. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +2 -0
  42. package/dist/general-knowledge/skills/fleet-health/SKILL.md +9 -1
  43. package/dist/general-knowledge/skills/hub/SKILL.md +154 -0
  44. package/dist/general-knowledge/skills/model-discovery/SKILL.md +4 -0
  45. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +7 -3
  46. package/dist/hub/admin-dashboard.d.ts +85 -0
  47. package/dist/hub/admin-dashboard.js +161 -0
  48. package/dist/hub/admin-dashboard.js.map +1 -0
  49. package/dist/hub/attachments/store.d.ts +2 -0
  50. package/dist/hub/attachments/store.js +6 -0
  51. package/dist/hub/attachments/store.js.map +1 -1
  52. package/dist/hub/client.d.ts +10 -0
  53. package/dist/hub/client.js +72 -10
  54. package/dist/hub/client.js.map +1 -1
  55. package/dist/hub/compose/member.d.ts +20 -0
  56. package/dist/hub/compose/member.js +212 -17
  57. package/dist/hub/compose/member.js.map +1 -1
  58. package/dist/hub/compose/server.d.ts +8 -0
  59. package/dist/hub/compose/server.js +13 -2
  60. package/dist/hub/compose/server.js.map +1 -1
  61. package/dist/hub/display-name.d.ts +10 -0
  62. package/dist/hub/display-name.js +35 -0
  63. package/dist/hub/display-name.js.map +1 -0
  64. package/dist/hub/execution/service.d.ts +1 -0
  65. package/dist/hub/execution/service.js +1 -1
  66. package/dist/hub/execution/service.js.map +1 -1
  67. package/dist/hub/fleet-info.d.ts +12 -0
  68. package/dist/hub/fleet-info.js +14 -0
  69. package/dist/hub/fleet-info.js.map +1 -0
  70. package/dist/hub/fleet-update-model.d.ts +100 -0
  71. package/dist/hub/fleet-update-model.js +15 -0
  72. package/dist/hub/fleet-update-model.js.map +1 -0
  73. package/dist/hub/fleet-updates.d.ts +46 -0
  74. package/dist/hub/fleet-updates.js +282 -0
  75. package/dist/hub/fleet-updates.js.map +1 -0
  76. package/dist/hub/fleet-versions.d.ts +28 -0
  77. package/dist/hub/fleet-versions.js +80 -0
  78. package/dist/hub/fleet-versions.js.map +1 -0
  79. package/dist/hub/http/compose.d.ts +2 -0
  80. package/dist/hub/http/compose.js +192 -16
  81. package/dist/hub/http/compose.js.map +1 -1
  82. package/dist/hub/http/deps.d.ts +1 -0
  83. package/dist/hub/http/schema.js +13 -1
  84. package/dist/hub/http/schema.js.map +1 -1
  85. package/dist/hub/member/display-name.d.ts +9 -0
  86. package/dist/hub/member/display-name.js +71 -0
  87. package/dist/hub/member/display-name.js.map +1 -0
  88. package/dist/hub/member/exposure-api.d.ts +4 -0
  89. package/dist/hub/member/exposure-api.js +8 -3
  90. package/dist/hub/member/exposure-api.js.map +1 -1
  91. package/dist/hub/member/exposures.d.ts +4 -0
  92. package/dist/hub/member/exposures.js +20 -0
  93. package/dist/hub/member/exposures.js.map +1 -1
  94. package/dist/hub/member/pairing-api.js +3 -2
  95. package/dist/hub/member/pairing-api.js.map +1 -1
  96. package/dist/hub/member/recommendations.d.ts +37 -0
  97. package/dist/hub/member/recommendations.js +129 -0
  98. package/dist/hub/member/recommendations.js.map +1 -0
  99. package/dist/hub/member/room-ask.d.ts +60 -1
  100. package/dist/hub/member/room-ask.js +250 -22
  101. package/dist/hub/member/room-ask.js.map +1 -1
  102. package/dist/hub/member/room-post-answers.d.ts +52 -0
  103. package/dist/hub/member/room-post-answers.js +152 -0
  104. package/dist/hub/member/room-post-answers.js.map +1 -0
  105. package/dist/hub/member/room-post-receipt.d.ts +21 -0
  106. package/dist/hub/member/room-post-receipt.js +49 -0
  107. package/dist/hub/member/room-post-receipt.js.map +1 -0
  108. package/dist/hub/member/room-post.d.ts +100 -0
  109. package/dist/hub/member/room-post.js +223 -0
  110. package/dist/hub/member/room-post.js.map +1 -0
  111. package/dist/hub/member/updates.d.ts +92 -0
  112. package/dist/hub/member/updates.js +316 -0
  113. package/dist/hub/member/updates.js.map +1 -0
  114. package/dist/hub/protocol.d.ts +658 -1
  115. package/dist/hub/protocol.js +90 -13
  116. package/dist/hub/protocol.js.map +1 -1
  117. package/dist/hub/published-version.d.ts +3 -0
  118. package/dist/hub/published-version.js +35 -0
  119. package/dist/hub/published-version.js.map +1 -0
  120. package/dist/hub/recommendation-model.d.ts +36 -0
  121. package/dist/hub/recommendation-model.js +9 -0
  122. package/dist/hub/recommendation-model.js.map +1 -0
  123. package/dist/hub/recommendations.d.ts +58 -0
  124. package/dist/hub/recommendations.js +211 -0
  125. package/dist/hub/recommendations.js.map +1 -0
  126. package/dist/hub/representative.d.ts +3 -0
  127. package/dist/hub/representative.js +1 -0
  128. package/dist/hub/representative.js.map +1 -1
  129. package/dist/hub/room-context-model.d.ts +43 -0
  130. package/dist/hub/room-context-model.js +12 -0
  131. package/dist/hub/room-context-model.js.map +1 -0
  132. package/dist/hub/rooms/agents.d.ts +41 -9
  133. package/dist/hub/rooms/agents.js +183 -21
  134. package/dist/hub/rooms/agents.js.map +1 -1
  135. package/dist/hub/rooms/assistant.d.ts +1 -6
  136. package/dist/hub/rooms/assistant.js +7 -2
  137. package/dist/hub/rooms/assistant.js.map +1 -1
  138. package/dist/hub/rooms/automation.d.ts +24 -0
  139. package/dist/hub/rooms/automation.js +66 -0
  140. package/dist/hub/rooms/automation.js.map +1 -0
  141. package/dist/hub/rooms/buttons.d.ts +85 -0
  142. package/dist/hub/rooms/buttons.js +62 -0
  143. package/dist/hub/rooms/buttons.js.map +1 -0
  144. package/dist/hub/rooms/context-cursor.d.ts +18 -0
  145. package/dist/hub/rooms/context-cursor.js +61 -0
  146. package/dist/hub/rooms/context-cursor.js.map +1 -0
  147. package/dist/hub/rooms/context.d.ts +1 -1
  148. package/dist/hub/rooms/context.js +4 -4
  149. package/dist/hub/rooms/context.js.map +1 -1
  150. package/dist/hub/rooms/mentions.d.ts +15 -0
  151. package/dist/hub/rooms/mentions.js +43 -0
  152. package/dist/hub/rooms/mentions.js.map +1 -0
  153. package/dist/hub/rooms/post-replies.d.ts +23 -0
  154. package/dist/hub/rooms/post-replies.js +114 -0
  155. package/dist/hub/rooms/post-replies.js.map +1 -0
  156. package/dist/hub/rooms/schema.d.ts +9 -0
  157. package/dist/hub/rooms/schema.js +43 -0
  158. package/dist/hub/rooms/schema.js.map +1 -1
  159. package/dist/hub/rooms/service.d.ts +136 -1
  160. package/dist/hub/rooms/service.js +727 -18
  161. package/dist/hub/rooms/service.js.map +1 -1
  162. package/dist/hub/rooms/types.d.ts +27 -3
  163. package/dist/hub/rooms.js +1 -1
  164. package/dist/hub/rooms.js.map +1 -1
  165. package/dist/hub/runtime.d.ts +1 -1
  166. package/dist/hub/runtime.js +12 -0
  167. package/dist/hub/runtime.js.map +1 -1
  168. package/dist/hub/server.d.ts +6 -1
  169. package/dist/hub/server.js +75 -5
  170. package/dist/hub/server.js.map +1 -1
  171. package/dist/hub/settings-directory-proof.js +22 -1
  172. package/dist/hub/settings-directory-proof.js.map +1 -1
  173. package/dist/hub/types.d.ts +133 -2
  174. package/dist/hub-contact-windows.d.ts +11 -0
  175. package/dist/hub-contact-windows.js +56 -0
  176. package/dist/hub-contact-windows.js.map +1 -0
  177. package/dist/hub-pairing-summary.d.ts +1 -1
  178. package/dist/hub-room-conversation.d.ts +14 -0
  179. package/dist/hub-room-conversation.js +60 -0
  180. package/dist/hub-room-conversation.js.map +1 -0
  181. package/dist/hub-update-notice.d.ts +12 -0
  182. package/dist/hub-update-notice.js +35 -0
  183. package/dist/hub-update-notice.js.map +1 -0
  184. package/dist/locale.js +56 -2
  185. package/dist/locale.js.map +1 -1
  186. package/dist/native-mcp.js +9 -6
  187. package/dist/native-mcp.js.map +1 -1
  188. package/dist/outbound-handlers.d.ts +14 -4
  189. package/dist/outbound-handlers.js +54 -1
  190. package/dist/outbound-handlers.js.map +1 -1
  191. package/dist/outbound-schemas.d.ts +12 -0
  192. package/dist/outbound-schemas.js +12 -0
  193. package/dist/outbound-schemas.js.map +1 -1
  194. package/dist/pane-port.d.ts +2 -0
  195. package/dist/queued-handoffs.d.ts +16 -4
  196. package/dist/queued-handoffs.js +18 -1
  197. package/dist/queued-handoffs.js.map +1 -1
  198. package/dist/runtime-cli-install.js +13 -10
  199. package/dist/runtime-cli-install.js.map +1 -1
  200. package/dist/settings-api.d.ts +1 -0
  201. package/dist/settings-api.js +87 -0
  202. package/dist/settings-api.js.map +1 -1
  203. package/dist/tmux-manager.d.ts +2 -0
  204. package/dist/tmux-manager.js +2 -0
  205. package/dist/tmux-manager.js.map +1 -1
  206. package/dist/tool-permissions.js +3 -0
  207. package/dist/tool-permissions.js.map +1 -1
  208. package/dist/ui/chat-msg-actions.js +3 -222
  209. package/dist/ui/hub-admin-overview.js +189 -0
  210. package/dist/ui/hub-client.js +36 -4
  211. package/dist/ui/hub-fleet-versions.js +393 -0
  212. package/dist/ui/hub-room-agent-strings.js +28 -0
  213. package/dist/ui/hub-room-composer.js +5 -3
  214. package/dist/ui/hub-room-members-strings.js +2 -2
  215. package/dist/ui/hub-room-members.js +3 -2
  216. package/dist/ui/hub-room-notify.js +161 -0
  217. package/dist/ui/hub-room-search.js +126 -0
  218. package/dist/ui/hub-room-strings.js +46 -0
  219. package/dist/ui/hub-room-thread.js +239 -34
  220. package/dist/ui/hub-room-unread.js +2 -1
  221. package/dist/ui/hub-strings.js +8 -0
  222. package/dist/ui/image-annotate.js +2 -283
  223. package/dist/ui/image-lightbox.js +2 -176
  224. package/dist/ui/image-zoom.js +2 -242
  225. package/dist/ui/notice-hub-update.js +94 -0
  226. package/dist/ui/panel-chat.js +35 -6
  227. package/dist/ui/panel-hub.js +133 -19
  228. package/dist/ui/panel-notices.js +3 -1
  229. package/dist/ui/panel-settings.js +1 -1
  230. package/dist/ui/settings-hub-updates.js +67 -0
  231. package/dist/ui/settings-hub.js +28 -3
  232. package/dist/ui/settings-registry.js +1 -0
  233. package/dist/ui/settings-update.js +11 -5
  234. package/dist/ui/settings-web-authority.js +1 -1
  235. package/dist/ui/shared/app-i18n.js +2 -0
  236. package/dist/ui/shared/app-nav.js +6 -2
  237. package/dist/ui/shared/app-prefs.js +2 -1
  238. package/dist/ui/shared/app-shell.js +11 -1
  239. package/dist/ui/shared/app-update.js +90 -8
  240. package/dist/ui/shared/app.css +20 -0
  241. package/dist/ui/shared/chat-msg-actions.js +225 -0
  242. package/dist/ui/shared/chat-thread.js +70 -5
  243. package/dist/ui/shared/chat-work-bar.css +25 -13
  244. package/dist/ui/shared/hub-chat.css +6 -1
  245. package/dist/ui/shared/hub-owner.css +104 -0
  246. package/dist/ui/shared/hub-rooms-u2.css +16 -0
  247. package/dist/ui/shared/hub.css +5 -0
  248. package/dist/ui/shared/image-annotate.js +306 -0
  249. package/dist/ui/shared/image-lightbox.js +183 -0
  250. package/dist/ui/shared/image-zoom.js +242 -0
  251. package/dist/ui/shared/instance-nav.js +36 -7
  252. package/dist/ui/shared/view-strings.js +6 -0
  253. package/dist/ui/shared/web-authorize.js +2 -2
  254. package/dist/update-dispatch.d.ts +8 -1
  255. package/dist/update-dispatch.js +16 -1
  256. package/dist/update-dispatch.js.map +1 -1
  257. package/dist/update-idle.d.ts +65 -0
  258. package/dist/update-idle.js +190 -0
  259. package/dist/update-idle.js.map +1 -0
  260. package/dist/update-launch.d.ts +1 -1
  261. package/dist/update-launch.js +9 -2
  262. package/dist/update-launch.js.map +1 -1
  263. package/dist/usage/profile-timeline.d.ts +2 -0
  264. package/dist/usage/profile-timeline.js +4 -0
  265. package/dist/usage/profile-timeline.js.map +1 -1
  266. package/dist/web-api.js +19 -2
  267. package/dist/web-api.js.map +1 -1
  268. package/dist/web-notices.d.ts +3 -0
  269. package/dist/web-notices.js +17 -2
  270. package/dist/web-notices.js.map +1 -1
  271. package/dist/web-prefs.js +1 -0
  272. package/dist/web-prefs.js.map +1 -1
  273. package/dist/web-update.d.ts +15 -1
  274. package/package.json +1 -1
@@ -0,0 +1,189 @@
1
+ // M-3162 (Lumen's approved mockup, docs/evidence/hub-admin-dashboard on docs/hub-ux-review-m2902; API M-3161,
2
+ // docs/design/hub-admin-dashboard-api.md): Administration → Overview — how the Hub is being used, in counts only.
3
+ // People, Questions (per day, answer time, not answered, the most-asked agents), Fleets and Rooms, for Today or 7 days in
4
+ // this browser's own time zone, read again every minute. Never what anyone asked or answered, never counted by person;
5
+ // the line under the range says so. No token or cost figures. A Hub nobody has joined yet shows one line and "Let
6
+ // colleagues join" instead of a page of zeros (the Fleets still show: a Fleet may be paired before anyone uses the Hub).
7
+ // A module of its own with its own words (upgrade skew: a tab holding an older dictionary still has every word).
8
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
9
+ import { register, t, lang } from "/assets/app-i18n.js";
10
+ import { ErrorState, Skeleton } from "/assets/ui-states.js";
11
+
12
+ register("hubOverview", {
13
+ en: {
14
+ today: "Today", week: "7 days", rangeLabel: "Period",
15
+ updated: "Updated {0} · refreshes every minute",
16
+ privacy: "Counts only. This page never shows what anyone asked or what an agent answered, and never counts by person.",
17
+ hPeople: "People", hAsk: "Questions", hFleet: "Fleets", hRoom: "Rooms",
18
+ pToday: "Active today", pTodaySub: "of {0} people who have joined", pWeek: "Active in 7 days", pWeekSub: "{0} have not signed in this week",
19
+ pWeekAll: "everyone who has joined", pJoin: "Joined this week", pJoinSub: "{0} in total", pNow: "Signed in now", pNowSub: "active in the last 5 minutes",
20
+ qPerDay: "Questions per day", qRange_today: "today", qRange_7d: "7 days", qHint: "Each agent asked counts once.", qToday: "Today",
21
+ aTime: "Answer time", aMed: "Typical (median)", aSlow: "Slowest 1 in 10", aWait: "Waiting now", aWaitOld: "Longest wait now",
22
+ notEnough: "Not enough answers yet", none: "—",
23
+ fTitle: "Not answered", fRate: "{0}% of questions", fOff: "The agent's Fleet was offline", fTime: "No answer in time",
24
+ fPerm: "Permission ended first", fBusy: "Agent stopped or refused", fUnknown: "Other or unknown",
25
+ topTitle: "Most-asked agents", topAgent: "Agent", topAsk: "Questions", topMed: "Typical answer", topFail: "Not answered",
26
+ topNone: "No agent has been asked anything in this period.", topShared: "{0} shared agents in all.",
27
+ flOn: "Connected now", flOnSub: "of {0} Fleets", flBehind: "Need an update", flBehindSub: "below the recommended v{0}",
28
+ flBehindNoRec: "no recommended version set", flOld: "Too old for rooms", flOldSub: "their agents cannot answer in rooms",
29
+ flUnk: "Version unknown", flUnkSub: "too old to report a version", flLink: "See Connected Fleets",
30
+ rmPosts: "Messages", rmP: "People", rmA: "Agents", rmH: "Room assistant", rmActive: "Active rooms", rmActiveSub: "of {0} rooms · {1} created this week",
31
+ rmAsk: "Agent questions in rooms", rmAskSub: "@mentions that asked an agent", rmAuto: "Agent-to-agent chains stopped", rmAutoSub: "hit the depth or rate limit",
32
+ rmNote: "Counts across all rooms. Room names and members are not listed here: an administrator is not a member of every room.",
33
+ emptyLine: "Nobody has joined yet. Let colleagues join to see activity here.", emptyButton: "Let colleagues join",
34
+ sec: "{0} s", min: "{0} min", hour: "{0} h",
35
+ },
36
+ "zh-TW": {
37
+ today: "今天", week: "7 天", rangeLabel: "期間",
38
+ updated: "更新於 {0} · 每分鐘更新一次",
39
+ privacy: "這裡只有數字。不會顯示任何人問了什麼、Agent 答了什麼,也不會按人統計。",
40
+ hPeople: "使用的人", hAsk: "提問", hFleet: "Fleet", hRoom: "房間",
41
+ pToday: "今天使用", pTodaySub: "已加入的 {0} 人當中", pWeek: "7 天內使用", pWeekSub: "有 {0} 人這週沒有登入",
42
+ pWeekAll: "已加入的人都有使用", pJoin: "這週加入", pJoinSub: "總共 {0} 人", pNow: "目前登入中", pNowSub: "最近 5 分鐘內有操作",
43
+ qPerDay: "每天的提問數", qRange_today: "今天", qRange_7d: "7 天", qHint: "每問一個 Agent 算一次。", qToday: "今天",
44
+ aTime: "回答時間", aMed: "一般(中位數)", aSlow: "最慢的十分之一", aWait: "正在等回答", aWaitOld: "目前等最久",
45
+ notEnough: "回答數還不夠", none: "—",
46
+ fTitle: "沒有得到回答", fRate: "占全部提問的 {0}%", fOff: "Agent 的 Fleet 沒有連接", fTime: "逾時沒有回答",
47
+ fPerm: "權限先到期", fBusy: "Agent 停止或拒絕", fUnknown: "其他或原因不明",
48
+ topTitle: "最常被問的 Agent", topAgent: "Agent", topAsk: "提問數", topMed: "一般回答時間", topFail: "沒有回答",
49
+ topNone: "這段期間還沒有人問過 Agent。", topShared: "總共分享了 {0} 個 Agent。",
50
+ flOn: "目前已連接", flOnSub: "共 {0} 個 Fleet", flBehind: "需要更新", flBehindSub: "低於建議版本 v{0}",
51
+ flBehindNoRec: "還沒有設定建議版本", flOld: "版本太舊,無法使用房間", flOldSub: "它們的 Agent 無法在房間裡回答",
52
+ flUnk: "版本不明", flUnkSub: "版本太舊,無法回報版本", flLink: "查看已連接的 Fleet",
53
+ rmPosts: "訊息數", rmP: "人", rmA: "Agent", rmH: "房間助理", rmActive: "有活動的房間", rmActiveSub: "共 {0} 個房間 · 這週新增 {1} 個",
54
+ rmAsk: "在房間裡問 Agent", rmAskSub: "用 @ 提及來問 Agent 的次數", rmAuto: "Agent 互問被停止", rmAutoSub: "達到層數或頻率上限",
55
+ rmNote: "所有房間的合計。這裡不列出房間名稱與成員:管理員不一定是每個房間的成員。",
56
+ emptyLine: "還沒有人加入。開放同仁加入之後,這裡會顯示使用情形。", emptyButton: "讓同仁加入",
57
+ sec: "{0} 秒", min: "{0} 分鐘", hour: "{0} 小時",
58
+ },
59
+ });
60
+ export const ho = (key, ...args) => t(`hubOverview.${key}`, ...args);
61
+
62
+ const RANGE_KEY = "agend_hub_overview_range";
63
+ const REFRESH_MS = 60_000;
64
+ const num = (n) => (typeof n === "number" && Number.isFinite(n) ? n.toLocaleString(lang() === "zh-TW" ? "zh-TW" : "en") : "0");
65
+ /** A duration in plain words: seconds under a minute, minutes (one decimal under ten) under an hour, hours beyond. */
66
+ export function durationText(ms) {
67
+ if (typeof ms !== "number" || !Number.isFinite(ms) || ms < 0) return null;
68
+ const s = ms / 1000;
69
+ if (s < 60) return ho("sec", String(Math.max(1, Math.round(s))));
70
+ const m = s / 60;
71
+ if (m < 60) return ho("min", m < 10 ? String(Math.round(m * 10) / 10) : String(Math.round(m)));
72
+ return ho("hour", String(Math.round((m / 60) * 10) / 10));
73
+ }
74
+ /** The day label under a bar: the last bar is Today; the others are their weekday, in this page's language. */
75
+ export function dayLabel(date, last) {
76
+ if (last) return ho("qToday");
77
+ const d = new Date(`${date}T12:00:00Z`);
78
+ if (Number.isNaN(d.getTime())) return date;
79
+ return new Intl.DateTimeFormat(lang() === "zh-TW" ? "zh-TW" : "en", { weekday: lang() === "zh-TW" ? "narrow" : "short", timeZone: "UTC" }).format(d);
80
+ }
81
+ const zone = () => { try { return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC"; } catch { return "UTC"; } };
82
+ const readRange = () => { try { return sessionStorage.getItem(RANGE_KEY) === "today" ? "today" : "7d"; } catch { return "7d"; } };
83
+
84
+ function Card({ title, big, sub, cls = "" }) {
85
+ return html`<div class=${`hub-ov-card${cls ? ` ${cls}` : ""}`}><div class="hub-ov-card-title">${title}</div>
86
+ <div class="hub-ov-big">${big}</div>${sub ? html`<div class="hub-ov-sub">${sub}</div>` : null}</div>`;
87
+ }
88
+ function Rows({ rows }) {
89
+ return html`<dl class="hub-ov-kv">${rows.map(([k, v]) => html`<div key=${k}><dt>${k}</dt><dd>${v}</dd></div>`)}</dl>`;
90
+ }
91
+
92
+ /**
93
+ * The Overview. `client.adminDashboard({ range, timeZone })` → the M-3161 response (or { ok: false, status }). `onOpen(view,
94
+ * anchor)` opens another Administration tab (Manage at a card: "join", "fleets"); `onGone()` when the route is not there.
95
+ */
96
+ export function HubAdminOverview({ client, onOpen = () => {}, onGone = () => {} }) {
97
+ const [range, setRange] = useState(readRange), [data, setData] = useState(null), [error, setError] = useState(false), [at, setAt] = useState(0);
98
+ const live = useRef(true), asked = useRef(0);
99
+ const load = async (r = range) => {
100
+ const mine = ++asked.current;
101
+ const res = await client.adminDashboard({ range: r, timeZone: zone() }).catch(() => null);
102
+ if (!live.current || mine !== asked.current) return;
103
+ if (res && res.ok !== false && res.people) { setData(res); setError(false); setAt(Date.now()); }
104
+ else if (res && res.status === 404) onGone(); // an older Hub after all: the page shows Manage instead
105
+ else setError(true);
106
+ };
107
+ useEffect(() => { live.current = true; void load(range); const id = setInterval(() => { void load(range); }, REFRESH_MS); return () => { live.current = false; clearInterval(id); }; }, [range]);
108
+ const pick = (r) => { if (r === range) return; try { sessionStorage.setItem(RANGE_KEY, r); } catch { /* private mode */ } setRange(r); };
109
+ const head = html`<div class="hub-ov-bar">
110
+ <div class="hub-ov-range" role="group" aria-label=${ho("rangeLabel")}>
111
+ ${["today", "7d"].map((r) => html`<button key=${r} type="button" class=${`hub-ov-range-item${range === r ? " is-current" : ""}`} aria-pressed=${range === r ? "true" : "false"} onClick=${() => pick(r)}>${ho(r === "today" ? "today" : "week")}</button>`)}
112
+ </div>
113
+ ${at ? html`<span class="note hub-ov-updated">${ho("updated", new Date(at).toLocaleTimeString(lang() === "zh-TW" ? "zh-TW" : "en", { hour: "2-digit", minute: "2-digit" }))}</span>` : null}
114
+ </div>
115
+ <p class="note hub-ov-privacy">${ho("privacy")}</p>`;
116
+ if (!data) return html`<div class="hub-ov">${head}${error ? html`<${ErrorState} onRetry=${() => load(range)} />` : html`<${Skeleton} variant="rows" lines=${6} />`}</div>`;
117
+ const { people, questions: q, topAgents = [], fleets: f, rooms: rm } = data;
118
+ const fleetsSection = html`<section class="hub-ov-section"><h3>${ho("hFleet")}</h3>
119
+ <div class="hub-ov-grid4">
120
+ <${Card} title=${ho("flOn")} big=${num(f.connected)} sub=${ho("flOnSub", num(f.total))} />
121
+ <${Card} title=${ho("flBehind")} big=${num(f.needsUpdate)} sub=${f.recommendedVersion ? ho("flBehindSub", f.recommendedVersion) : ho("flBehindNoRec")} cls=${f.needsUpdate ? "warn" : ""} />
122
+ <${Card} title=${ho("flOld")} big=${num(f.tooOldRooms)} sub=${ho("flOldSub")} cls=${f.tooOldRooms ? "warn" : ""} />
123
+ <${Card} title=${ho("flUnk")} big=${num(f.unknownVersion)} sub=${ho("flUnkSub")} cls=${f.unknownVersion ? "warn" : ""} />
124
+ </div>
125
+ <a class="hub-ov-link" href="/ui/hub/admin?view=manage#fleets" onClick=${(e) => { if (e.metaKey || e.ctrlKey) return; e.preventDefault(); onOpen("manage", "fleets"); }}>${ho("flLink")} ›</a></section>`;
126
+ // A Hub nobody has joined yet: one line and the way to change that, instead of a page of zeros (Lumen, M-3162).
127
+ if (!people.total) return html`<div class="hub-ov">${head}
128
+ <section class="hub-ov-empty card"><p>${ho("emptyLine")}</p><button type="button" class="btn btn-primary" onClick=${() => onOpen("manage", "join")}>${ho("emptyButton")}</button></section>
129
+ ${fleetsSection}</div>`;
130
+ const perDay = Array.isArray(q.perDay) ? q.perDay : [];
131
+ const peak = Math.max(1, ...perDay.map((d) => d.count || 0));
132
+ const reasons = q.notAnswered?.reasons || {};
133
+ const failRows = [["fOff", reasons.offline], ["fTime", reasons.timedOut], ["fPerm", reasons.permissionEnded], ["fBusy", reasons.stoppedOrRefused],
134
+ ...(reasons.unknown ? [["fUnknown", reasons.unknown]] : [])].map(([k, v]) => [ho(k), num(v || 0)]);
135
+ const topPeak = Math.max(1, ...topAgents.map((a) => a.questions || 0));
136
+ const by = rm.byAuthor || {}, posts = Math.max(1, (by.people || 0) + (by.agents || 0) + (by.assistant || 0));
137
+ const share = (n) => `${Math.round(((n || 0) / posts) * 1000) / 10}%`;
138
+ return html`<div class="hub-ov">${head}
139
+ <section class="hub-ov-section"><h3>${ho("hPeople")}</h3>
140
+ <div class="hub-ov-grid4">
141
+ <${Card} title=${ho("pToday")} big=${num(people.activeToday)} sub=${ho("pTodaySub", num(people.total))} />
142
+ <${Card} title=${ho("pWeek")} big=${num(people.active7d)} sub=${people.total > people.active7d ? ho("pWeekSub", num(people.total - people.active7d)) : ho("pWeekAll")} />
143
+ <${Card} title=${ho("pJoin")} big=${num(people.joined7d)} sub=${ho("pJoinSub", num(people.total))} />
144
+ <${Card} title=${ho("pNow")} big=${num(people.signedInNow)} sub=${ho("pNowSub")} />
145
+ </div></section>
146
+ <section class="hub-ov-section"><h3>${ho("hAsk")}</h3>
147
+ <div class="hub-ov-split">
148
+ <div class="hub-ov-card hub-ov-perday"><div class="hub-ov-card-title">${ho("qPerDay")}</div>
149
+ <div class="hub-ov-big">${num(q.asked)} <small>${ho(`qRange_${data.range === "today" ? "today" : "7d"}`)}</small></div>
150
+ <div class="hub-ov-bars" role="img" aria-label=${perDay.map((d, i) => `${dayLabel(d.date, i === perDay.length - 1)} ${d.count}`).join(", ")}>
151
+ ${perDay.map((d, i) => html`<div key=${d.date} class=${i === perDay.length - 1 ? "today" : ""}><b>${num(d.count)}</b>
152
+ <i ref=${(el) => el?.style?.setProperty("height", `${Math.round(((d.count || 0) / peak) * 100)}%`)}></i><span>${dayLabel(d.date, i === perDay.length - 1)}</span></div>`)}
153
+ </div>
154
+ <p class="note">${ho("qHint")}</p></div>
155
+ <div class="hub-ov-stack">
156
+ <div class="hub-ov-card"><div class="hub-ov-card-title">${ho("aTime")}</div>
157
+ <${Rows} rows=${[[ho("aMed"), durationText(q.answerTime?.medianMs) ?? ho("notEnough")], [ho("aSlow"), durationText(q.answerTime?.p90Ms) ?? ho("notEnough")]]} />
158
+ <${Rows} rows=${[[ho("aWait"), num(q.waiting)], [ho("aWaitOld"), durationText(q.longestWaitMs) ?? ho("none")]]} /></div>
159
+ <div class="hub-ov-card"><div class="hub-ov-card-title">${ho("fTitle")}</div>
160
+ <div class="hub-ov-big">${num(q.notAnswered?.total)}${q.asked ? html` <small>${ho("fRate", String(Math.round(((q.notAnswered?.total || 0) / q.asked) * 1000) / 10))}</small>` : null}</div>
161
+ <${Rows} rows=${failRows} /></div>
162
+ </div>
163
+ </div>
164
+ <div class="hub-ov-card hub-ov-top"><div class="hub-ov-card-title">${ho("topTitle")}</div>
165
+ ${topAgents.length ? html`<table><thead><tr><th class="rank"></th><th>${ho("topAgent")}</th><th class="n">${ho("topAsk")}</th><th class="n">${ho("topMed")}</th><th class="n">${ho("topFail")}</th></tr></thead>
166
+ <tbody>${topAgents.map((a, i) => html`<tr key=${a.id}><td class="rank">${i + 1}</td>
167
+ <td><div class="hub-ov-agent">${a.name}</div>${a.ownerName ? html`<div class="note">${a.ownerName}</div>` : null}<div class="hub-ov-meter"><i ref=${(el) => el?.style?.setProperty("width", `${Math.round(((a.questions || 0) / topPeak) * 100)}%`)}></i></div></td>
168
+ <td class="n">${num(a.questions)}</td><td class="n">${durationText(a.medianMs) ?? html`<span class="note">${ho("notEnough")}</span>`}</td>
169
+ <td class="n">${a.notAnswered ? html`<span class="tag warn">${num(a.notAnswered)}</span>` : "0"}</td></tr>`)}</tbody></table>`
170
+ : html`<p class="note">${ho("topNone")}</p>`}
171
+ <p class="note">${ho("topShared", num(data.sharedAgents))}</p></div>
172
+ </section>
173
+ ${fleetsSection}
174
+ <section class="hub-ov-section"><h3>${ho("hRoom")}</h3>
175
+ <div class="hub-ov-split">
176
+ <div class="hub-ov-card"><div class="hub-ov-card-title">${ho("rmPosts")}</div>
177
+ <div class="hub-ov-big">${num(rm.messages)} <small>${ho(`qRange_${data.range === "today" ? "today" : "7d"}`)}</small></div>
178
+ <div class="hub-ov-split-bar" role="img" aria-label=${`${ho("rmP")} ${by.people || 0}, ${ho("rmA")} ${by.agents || 0}, ${ho("rmH")} ${by.assistant || 0}`}>
179
+ <i class="p" ref=${(el) => el?.style?.setProperty("flex-basis", share(by.people))}></i><i class="a" ref=${(el) => el?.style?.setProperty("flex-basis", share(by.agents))}></i><i class="h" ref=${(el) => el?.style?.setProperty("flex-basis", share(by.assistant))}></i></div>
180
+ <dl class="hub-ov-kv hub-ov-legend"><div><dt><i class="p"></i>${ho("rmP")}</dt><dd>${num(by.people)}</dd></div><div><dt><i class="a"></i>${ho("rmA")}</dt><dd>${num(by.agents)}</dd></div><div><dt><i class="h"></i>${ho("rmH")}</dt><dd>${num(by.assistant)}</dd></div></dl>
181
+ <p class="note">${ho("rmNote")}</p></div>
182
+ <div class="hub-ov-stack">
183
+ <${Card} title=${ho("rmActive")} big=${num(rm.active)} sub=${ho("rmActiveSub", num(rm.total), num(rm.created7d))} />
184
+ <${Card} title=${ho("rmAsk")} big=${num(rm.agentQuestions)} sub=${ho("rmAskSub")} />
185
+ <${Card} title=${ho("rmAuto")} big=${num(rm.chainsStopped)} sub=${ho("rmAutoSub")} />
186
+ </div>
187
+ </div></section>
188
+ </div>`;
189
+ }
@@ -56,7 +56,7 @@ export function hubName(doc = typeof document !== "undefined" ? document : null)
56
56
  * marks a mapping from the older restricted mode that answers nothing until the owner shares the agent again.
57
57
  * @typedef {{ agent: string, display: string, exposureId: string | null, revision: number,
58
58
  * state: "published" | "withdrawn" | "frozen", policy: { dataView: string, tools: string[] } | null,
59
- * enforceable: boolean, reason?: string }} HubExposureView
59
+ * enforceable: boolean, reason?: string, contactLimit?: boolean, contactLimitNotice?: boolean }} HubExposureView
60
60
  */
61
61
  /**
62
62
  * Results (docs/design/hub-ui-client.md "Results"). A withdrawal or disconnect fences locally at once (even offline) but
@@ -151,7 +151,7 @@ export function createStubClient({ now = () => Date.now(), agents = () => [] } =
151
151
  const c = consent.get(a.name) || { state: "withdrawn", revision: 0 };
152
152
  const ok = enforceable.has(a.name);
153
153
  return { agent: a.name, display: a.display_name || a.name, exposureId: c.revision ? `stub-${a.name}` : null, revision: c.revision,
154
- state: c.state, policy: ok && c.state === "published" ? { dataView: c.dataView || "agent", tools: c.tools ? [...c.tools] : [] } : null, enforceable: ok, ...(ok ? {} : { reason: "restricted_execution_pending" }),
154
+ state: c.state, contactLimit: c.contactLimit !== false, policy: ok && c.state === "published" ? { dataView: c.dataView || "agent", tools: c.tools ? [...c.tools] : [] } : null, enforceable: ok, ...(ok ? {} : { reason: "restricted_execution_pending" }),
155
155
  // P1 representative agent: the one choice is the agent itself, with no Hub tools; no pending confirmation.
156
156
  choices: ok ? { dataViews: [{ id: "agent", label: a.display_name || a.name }], tools: [] } : { dataViews: [], tools: [] },
157
157
  pending: null };
@@ -198,7 +198,7 @@ export function createStubClient({ now = () => Date.now(), agents = () => [] } =
198
198
  }
199
199
  if (pairing.state !== "paired") return { ok: false, error: "not_paired" };
200
200
  if (!enforceable.has(agent)) return { ok: false, error: "not_enforceable" };
201
- consent.set(agent, { state: "published", revision: c.revision + 1, dataView: choice && choice.dataViewId, tools: choice && choice.tools });
201
+ consent.set(agent, { state: "published", revision: c.revision + 1, dataView: choice && choice.dataViewId, tools: choice && choice.tools, contactLimit: choice?.contactLimit !== false });
202
202
  return { ok: true, view: view(a) };
203
203
  },
204
204
  /** Hear pairing changes (slice 1: the member's local status projections). @returns {() => void} */
@@ -443,6 +443,15 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a), readTime
443
443
  return call("POST", `/hub/v1/rooms/${id(roomId)}/messages`, { text, mentions, idempotencyKey,
444
444
  ...(replyTo ? { replyTo } : {}), ...(Array.isArray(files) && files.length ? { files } : {}) });
445
445
  },
446
+ /** M-3127 C: messages with these words in the group rooms I am in → { hits, cursor? } (newest first). */
447
+ searchRoomMessages(q, { limit, cursor } = {}) {
448
+ const p = new URLSearchParams({ q: String(q || "") });
449
+ if (Number.isSafeInteger(limit) && limit > 0) p.set("limit", String(limit));
450
+ if (cursor) p.set("cursor", String(cursor));
451
+ return call("GET", `/hub/v1/rooms/search?${p.toString()}`);
452
+ },
453
+ /** M-3127: add (`on`) or take back my reaction `emoji` on a group-room message → { reactions }. */
454
+ reactRoomMessage(roomId, messageId, emoji, on) { return call("POST", `/hub/v1/rooms/${id(roomId)}/messages/${id(messageId)}/reactions`, { emoji: String(emoji), on: on === true }); },
446
455
  markRoomRead(roomId, upTo) { return call("POST", `/hub/v1/rooms/${id(roomId)}/read`, { upTo }); },
447
456
  /**
448
457
  * The one live stream of everything this person may see (seam 1): `handlers[name](data)` for each of ROOM_EVENTS,
@@ -548,6 +557,18 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a), readTime
548
557
  return call("POST", "/hub/v1/admin/group-policy/resources/resume", { resource, expectedPolicyRevision, expectedLifecycleRevision });
549
558
  },
550
559
  welcome() { return call("GET", "/hub/v1/me/welcome"); },
560
+ // M-3137 / M-3136 (versions spec §2.3): the signed-in person's own active Fleets with their version state (the banner).
561
+ myFleets() { return call("GET", "/hub/v1/me/fleets"); },
562
+ // M-3162 / M-3161: Administration → Overview's counts for Today or 7 days, in the viewer's time zone (counts only).
563
+ adminDashboard({ range = "7d", timeZone = "UTC" } = {}) { return call("GET", `/hub/v1/admin/dashboard?range=${encodeURIComponent(range)}&timeZone=${encodeURIComponent(timeZone)}`); },
564
+ // M-3141 / M-3138 (versions spec §3.1): the Hub's recommended AgEnD version — read, preview (nothing saved), save.
565
+ recommendedVersion() { return call("GET", "/hub/v1/admin/recommended-version"); },
566
+ previewRecommendedVersion(input) { return call("POST", "/hub/v1/admin/recommended-version/preview", input); },
567
+ saveRecommendedVersion(input) { return call("PUT", "/hub/v1/admin/recommended-version", input); },
568
+ // M-3145 / M-3144 (versions spec §4.2, §4.5): update the Fleets that allow it — one or many ids, the target always
569
+ // the saved recommendation (ifRevision guards it) — and cancel a waiting request.
570
+ updateFleets(input) { return call("POST", "/hub/v1/admin/fleet-updates", input); },
571
+ cancelFleetUpdate(requestId) { return call("POST", `/hub/v1/admin/fleet-updates/${encodeURIComponent(requestId)}/cancel`, {}); },
551
572
  // M-2682: Administration → This Hub — what it is, and its rename (two steps: the server binds the second to the first).
552
573
  thisHub() { return call("GET", "/hub/v1/admin/hub"); },
553
574
  prepareHubName(name) { return call("POST", "/hub/v1/admin/hub/name/prepare", { name }); },
@@ -650,7 +671,18 @@ export function createMemberClient({ confirm, pollMs = 5000, doc = typeof docume
650
671
  async cancel() { const r = await confirm.api("/api/hub/member/pairing/cancel", { method: "POST", body: "{}" }); return r.ok && r.body && r.body.pairing ? r.body.pairing : pairingNow(); },
651
672
  /** The local status, every pollMs while visible (one request at a time; none while hidden); stops with the last listener. */
652
673
  subscribe(fn) { listeners.add(fn); if (!timer) timer = timers.setTimeout(tick, pollMs); return () => { listeners.delete(fn); if (!listeners.size && timer) { timers.clearTimeout(timer); timer = null; } }; },
674
+ // M-3145 (versions spec §4.1; API M-3144, Ridge): the owner's switch for updates started by this Hub's administrator.
675
+ // An older host (404) answers ok: false, and the switch is not drawn.
676
+ async hubUpdateConsent() { const r = await confirm.api("/api/settings/hub/update-consent"); return r.ok && r.body && typeof r.body === "object" ? { ok: true, ...r.body } : { ok: false, status: r.status }; },
677
+ async setHubUpdateConsent(on) {
678
+ const r = await confirm.api("/api/settings/hub/update-consent", { method: "PUT", body: JSON.stringify({ on: on === true }) });
679
+ return r.ok && r.body && typeof r.body === "object" ? { ok: true, ...r.body } : { ok: false, status: r.status };
680
+ },
653
681
  async exposures() { const rows = await listed(); return rows || []; },
682
+ async acknowledgeContactLimitNotice() {
683
+ const r = await confirm.api("/api/hub/member/contact-limit-notice", { method: "POST", body: "{}" });
684
+ return r.ok && r.body?.ok === true;
685
+ },
654
686
  async setExposed(agent, on, expectedRevision, choice = null) {
655
687
  const rows = await listed();
656
688
  if (rows === null) return { ok: false, error: "unavailable" };
@@ -663,7 +695,7 @@ export function createMemberClient({ confirm, pollMs = 5000, doc = typeof docume
663
695
  }
664
696
  if (!choice || typeof choice.dataViewId !== "string" || !Array.isArray(choice.tools)) return { ok: false, error: "not_enforceable" };
665
697
  const r = await confirm.api("/api/hub/member/exposures", { method: "POST", headers: { "Idempotency-Key": confirm.newKey("hub") },
666
- body: JSON.stringify({ agent, dataViewId: choice.dataViewId, tools: choice.tools, expectedRevision }) });
698
+ body: JSON.stringify({ agent, dataViewId: choice.dataViewId, tools: choice.tools, expectedRevision, ...(choice.contactLimit !== undefined ? { contactLimit: choice.contactLimit } : {}) }) });
667
699
  if (confirm.isPendingResponse(r)) {
668
700
  const p = r.body.pending_change;
669
701
  return { ok: true, pending: { id: p.id, expiresAt: p.expires_at }, view: { ...row, pending: { expiresAt: p.expires_at } }, settled: confirm.track(p, "hub") };