@songsid/agend 2.4.0-beta.20 → 2.4.0-beta.22

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 (256) hide show
  1. package/dist/agent-cli-instructions.md +1 -1
  2. package/dist/backend/claude-carry.d.ts +11 -0
  3. package/dist/backend/claude-carry.js +88 -6
  4. package/dist/backend/claude-carry.js.map +1 -1
  5. package/dist/backend/claude-code.js +3 -0
  6. package/dist/backend/claude-code.js.map +1 -1
  7. package/dist/build-provenance.json +1 -1
  8. package/dist/cache-ledger.d.ts +23 -21
  9. package/dist/cache-ledger.js +70 -6
  10. package/dist/cache-ledger.js.map +1 -1
  11. package/dist/cache-prices.d.ts +8 -6
  12. package/dist/cache-prices.js +12 -5
  13. package/dist/cache-prices.js.map +1 -1
  14. package/dist/cache-service.d.ts +9 -5
  15. package/dist/cache-service.js +202 -50
  16. package/dist/cache-service.js.map +1 -1
  17. package/dist/channel/mcp-tools.js +6 -4
  18. package/dist/channel/mcp-tools.js.map +1 -1
  19. package/dist/cli-audited.js +2 -1
  20. package/dist/cli-audited.js.map +1 -1
  21. package/dist/cli.js +4 -1
  22. package/dist/cli.js.map +1 -1
  23. package/dist/contact-auth-policy.js +1 -1
  24. package/dist/contact-auth-policy.js.map +1 -1
  25. package/dist/contact-auth-service.js +8 -2
  26. package/dist/contact-auth-service.js.map +1 -1
  27. package/dist/contact-auth-store.d.ts +3 -0
  28. package/dist/contact-auth-store.js +34 -8
  29. package/dist/contact-auth-store.js.map +1 -1
  30. package/dist/contact-auth-types.d.ts +3 -2
  31. package/dist/contact-auth-types.js.map +1 -1
  32. package/dist/contact-change-proposals.d.ts +47 -0
  33. package/dist/contact-change-proposals.js +132 -0
  34. package/dist/contact-change-proposals.js.map +1 -0
  35. package/dist/daemon.d.ts +31 -0
  36. package/dist/daemon.js +149 -2
  37. package/dist/daemon.js.map +1 -1
  38. package/dist/delivery-outbox.d.ts +10 -0
  39. package/dist/delivery-outbox.js +21 -0
  40. package/dist/delivery-outbox.js.map +1 -1
  41. package/dist/fleet-manager.d.ts +65 -1
  42. package/dist/fleet-manager.js +338 -20
  43. package/dist/fleet-manager.js.map +1 -1
  44. package/dist/general-knowledge/skills/concepts/SKILL.md +2 -1
  45. package/dist/general-knowledge/skills/hub/SKILL.md +45 -5
  46. package/dist/general-knowledge/skills/task-board/SKILL.md +4 -0
  47. package/dist/general-knowledge/skills/web-appearance/SKILL.md +1 -1
  48. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +16 -6
  49. package/dist/hub/agent-pictures-model.d.ts +275 -0
  50. package/dist/hub/agent-pictures-model.js +103 -0
  51. package/dist/hub/agent-pictures-model.js.map +1 -0
  52. package/dist/hub/agent-pictures.d.ts +64 -0
  53. package/dist/hub/agent-pictures.js +255 -0
  54. package/dist/hub/agent-pictures.js.map +1 -0
  55. package/dist/hub/client.d.ts +4 -0
  56. package/dist/hub/client.js +23 -2
  57. package/dist/hub/client.js.map +1 -1
  58. package/dist/hub/compose/member.d.ts +14 -3
  59. package/dist/hub/compose/member.js +46 -10
  60. package/dist/hub/compose/member.js.map +1 -1
  61. package/dist/hub/compose/server.d.ts +6 -5
  62. package/dist/hub/compose/server.js +7 -3
  63. package/dist/hub/compose/server.js.map +1 -1
  64. package/dist/hub/direct-posts-model.d.ts +1 -0
  65. package/dist/hub/direct-posts-model.js +2 -0
  66. package/dist/hub/direct-posts-model.js.map +1 -0
  67. package/dist/hub/direct-posts.d.ts +36 -0
  68. package/dist/hub/direct-posts.js +145 -0
  69. package/dist/hub/direct-posts.js.map +1 -0
  70. package/dist/hub/http/compose.d.ts +5 -0
  71. package/dist/hub/http/compose.js +158 -20
  72. package/dist/hub/http/compose.js.map +1 -1
  73. package/dist/hub/http/core.d.ts +9 -1
  74. package/dist/hub/http/core.js +21 -1
  75. package/dist/hub/http/core.js.map +1 -1
  76. package/dist/hub/http/deps.d.ts +1 -0
  77. package/dist/hub/http/schema.js +7 -0
  78. package/dist/hub/http/schema.js.map +1 -1
  79. package/dist/hub/init/text.js +1 -1
  80. package/dist/hub/join/service.d.ts +2 -0
  81. package/dist/hub/join/service.js +7 -3
  82. package/dist/hub/join/service.js.map +1 -1
  83. package/dist/hub/member/agent-pictures.d.ts +76 -0
  84. package/dist/hub/member/agent-pictures.js +196 -0
  85. package/dist/hub/member/agent-pictures.js.map +1 -0
  86. package/dist/hub/member/direct-rooms.d.ts +9 -0
  87. package/dist/hub/member/direct-rooms.js +14 -0
  88. package/dist/hub/member/direct-rooms.js.map +1 -0
  89. package/dist/hub/member/room-ask.d.ts +22 -1
  90. package/dist/hub/member/room-ask.js +99 -5
  91. package/dist/hub/member/room-ask.js.map +1 -1
  92. package/dist/hub/member/room-asker-store.d.ts +48 -0
  93. package/dist/hub/member/room-asker-store.js +181 -0
  94. package/dist/hub/member/room-asker-store.js.map +1 -0
  95. package/dist/hub/member/room-post.d.ts +11 -10
  96. package/dist/hub/member/room-post.js +51 -7
  97. package/dist/hub/member/room-post.js.map +1 -1
  98. package/dist/hub/policy.d.ts +11 -2
  99. package/dist/hub/policy.js +60 -7
  100. package/dist/hub/policy.js.map +1 -1
  101. package/dist/hub/protocol.d.ts +254 -1
  102. package/dist/hub/protocol.js +20 -8
  103. package/dist/hub/protocol.js.map +1 -1
  104. package/dist/hub/representative.d.ts +38 -0
  105. package/dist/hub/representative.js +140 -12
  106. package/dist/hub/representative.js.map +1 -1
  107. package/dist/hub/room-asker-identity-model.d.ts +53 -0
  108. package/dist/hub/room-asker-identity-model.js +14 -0
  109. package/dist/hub/room-asker-identity-model.js.map +1 -0
  110. package/dist/hub/room-asker-identity.d.ts +22 -0
  111. package/dist/hub/room-asker-identity.js +43 -0
  112. package/dist/hub/room-asker-identity.js.map +1 -0
  113. package/dist/hub/rooms/agents.d.ts +2 -0
  114. package/dist/hub/rooms/agents.js +30 -3
  115. package/dist/hub/rooms/agents.js.map +1 -1
  116. package/dist/hub/rooms/asker-identity.d.ts +21 -0
  117. package/dist/hub/rooms/asker-identity.js +86 -0
  118. package/dist/hub/rooms/asker-identity.js.map +1 -0
  119. package/dist/hub/rooms/direct-view.d.ts +3 -2
  120. package/dist/hub/rooms/direct-view.js +23 -8
  121. package/dist/hub/rooms/direct-view.js.map +1 -1
  122. package/dist/hub/rooms/office.d.ts +27 -0
  123. package/dist/hub/rooms/office.js +12 -2
  124. package/dist/hub/rooms/office.js.map +1 -1
  125. package/dist/hub/rooms/service.d.ts +38 -1
  126. package/dist/hub/rooms/service.js +56 -3
  127. package/dist/hub/rooms/service.js.map +1 -1
  128. package/dist/hub/rooms/types.d.ts +5 -2
  129. package/dist/hub/rooms.d.ts +9 -0
  130. package/dist/hub/rooms.js +97 -26
  131. package/dist/hub/rooms.js.map +1 -1
  132. package/dist/hub/runtime.d.ts +1 -1
  133. package/dist/hub/server.js +24 -2
  134. package/dist/hub/server.js.map +1 -1
  135. package/dist/hub/session-directory-transition.d.ts +1 -0
  136. package/dist/hub/session-directory-transition.js +15 -9
  137. package/dist/hub/session-directory-transition.js.map +1 -1
  138. package/dist/hub/session-limits.d.ts +58 -0
  139. package/dist/hub/session-limits.js +121 -0
  140. package/dist/hub/session-limits.js.map +1 -0
  141. package/dist/hub/sessions.d.ts +1 -1
  142. package/dist/hub/sessions.js +13 -7
  143. package/dist/hub/sessions.js.map +1 -1
  144. package/dist/hub/settings-directory-decision.js +1 -1
  145. package/dist/hub/settings-directory-decision.js.map +1 -1
  146. package/dist/hub/types.d.ts +9 -2
  147. package/dist/hub-character-plan.d.ts +47 -0
  148. package/dist/hub-character-plan.js +70 -0
  149. package/dist/hub-character-plan.js.map +1 -0
  150. package/dist/hub-contact-windows.d.ts +13 -1
  151. package/dist/hub-contact-windows.js +35 -2
  152. package/dist/hub-contact-windows.js.map +1 -1
  153. package/dist/hub-picture-reduce.d.ts +34 -0
  154. package/dist/hub-picture-reduce.js +101 -0
  155. package/dist/hub-picture-reduce.js.map +1 -0
  156. package/dist/hub-picture-worker.d.ts +1 -0
  157. package/dist/hub-picture-worker.js +19 -0
  158. package/dist/hub-picture-worker.js.map +1 -0
  159. package/dist/hub-report-target.d.ts +6 -0
  160. package/dist/hub-report-target.js +6 -0
  161. package/dist/hub-report-target.js.map +1 -1
  162. package/dist/locale.js +357 -265
  163. package/dist/locale.js.map +1 -1
  164. package/dist/ls-rows.d.ts +2 -0
  165. package/dist/ls-rows.js.map +1 -1
  166. package/dist/needs-you.d.ts +6 -0
  167. package/dist/needs-you.js +3 -1
  168. package/dist/needs-you.js.map +1 -1
  169. package/dist/outbound-handlers.d.ts +8 -0
  170. package/dist/outbound-handlers.js +53 -6
  171. package/dist/outbound-handlers.js.map +1 -1
  172. package/dist/outbound-schemas.d.ts +2 -0
  173. package/dist/outbound-schemas.js +6 -4
  174. package/dist/outbound-schemas.js.map +1 -1
  175. package/dist/runtime-cli-install.js +4 -4
  176. package/dist/runtime-cli-install.js.map +1 -1
  177. package/dist/task-board-tool.d.ts +17 -0
  178. package/dist/task-board-tool.js +58 -6
  179. package/dist/task-board-tool.js.map +1 -1
  180. package/dist/tips.js +3 -3
  181. package/dist/tool-permissions.js +2 -2
  182. package/dist/tool-permissions.js.map +1 -1
  183. package/dist/ui/agent-export-strings.js +1 -1
  184. package/dist/ui/agent-page-strings.js +5 -5
  185. package/dist/ui/contact-auth-client.js +2 -2
  186. package/dist/ui/contact-tool-groups.js +1 -1
  187. package/dist/ui/fleet-cache.js +5 -5
  188. package/dist/ui/fleet-canvas.js +3 -2
  189. package/dist/ui/fleet-office-card.js +46 -7
  190. package/dist/ui/fleet-office-dialogue.d.ts +6 -3
  191. package/dist/ui/fleet-office-dialogue.js +13 -3
  192. package/dist/ui/fleet-office-layout.js +15 -15
  193. package/dist/ui/fleet-office-model.js +3 -2
  194. package/dist/ui/fleet-office-overview.js +1 -1
  195. package/dist/ui/fleet-office-pack.d.ts +17 -7
  196. package/dist/ui/fleet-office-pack.js +106 -38
  197. package/dist/ui/fleet-office-play.js +11 -4
  198. package/dist/ui/fleet-office-skin.js +41 -11
  199. package/dist/ui/fleet-office-store.js +10 -1
  200. package/dist/ui/fleet-office-talk.js +423 -0
  201. package/dist/ui/fleet-office-view.js +58 -17
  202. package/dist/ui/fleet-office-zones.js +20 -12
  203. package/dist/ui/fleet-office.js +250 -65
  204. package/dist/ui/fleet-org.js +3 -3
  205. package/dist/ui/fleet-task-common.js +3 -3
  206. package/dist/ui/fleet-task-sort.js +88 -0
  207. package/dist/ui/fleet-task-view.js +38 -9
  208. package/dist/ui/fleet-tasks.js +47 -15
  209. package/dist/ui/fleet-usage.js +6 -6
  210. package/dist/ui/hub-admin-overview.js +1 -1
  211. package/dist/ui/hub-chat-store.js +4 -3
  212. package/dist/ui/hub-chat-strings.js +3 -1
  213. package/dist/ui/hub-client.js +3 -0
  214. package/dist/ui/hub-my-agents-strings.js +2 -2
  215. package/dist/ui/hub-my-agents.js +3 -0
  216. package/dist/ui/hub-room-composer.js +24 -4
  217. package/dist/ui/hub-room-members.js +7 -3
  218. package/dist/ui/hub-room-office.js +71 -2
  219. package/dist/ui/hub-room-presence.js +14 -0
  220. package/dist/ui/hub-room-strings.js +18 -2
  221. package/dist/ui/hub-room-thread.js +82 -13
  222. package/dist/ui/hub-room-working.js +37 -0
  223. package/dist/ui/hub-session-limits.js +79 -0
  224. package/dist/ui/panel-fleet.js +5 -5
  225. package/dist/ui/panel-hub.js +41 -6
  226. package/dist/ui/panel-log.js +3 -3
  227. package/dist/ui/panel-needs.js +28 -2
  228. package/dist/ui/panel-runtimes.js +2 -2
  229. package/dist/ui/runtime-cli-install.js +1 -1
  230. package/dist/ui/runtime-update-status.js +1 -1
  231. package/dist/ui/settings-access-strings.js +1 -1
  232. package/dist/ui/settings-hub-setup-strings.js +1 -1
  233. package/dist/ui/settings-layout.js +2 -2
  234. package/dist/ui/settings-named-test.js +16 -16
  235. package/dist/ui/settings-public-session-strings.js +2 -2
  236. package/dist/ui/settings-revoke-strings.js +1 -1
  237. package/dist/ui/settings-shared-strings.js +2 -2
  238. package/dist/ui/settings-strings.js +40 -40
  239. package/dist/ui/shared/app-shell.js +1 -1
  240. package/dist/ui/shared/app.css +106 -6
  241. package/dist/ui/shared/chat-strings.js +9 -9
  242. package/dist/ui/shared/hub-owner.css +5 -0
  243. package/dist/ui/shared/hub-rooms-u2.css +3 -0
  244. package/dist/ui/shared/instance-nav.js +36 -2
  245. package/dist/ui/shared/office-dialogue.css +110 -0
  246. package/dist/ui/shared/task-board.css +103 -7
  247. package/dist/ui/shared/view-strings.js +27 -9
  248. package/dist/web-api.d.ts +5 -0
  249. package/dist/web-api.js +29 -0
  250. package/dist/web-api.js.map +1 -1
  251. package/dist/web-office-skins.d.ts +8 -2
  252. package/dist/web-office-skins.js +33 -14
  253. package/dist/web-office-skins.js.map +1 -1
  254. package/dist/web-office-store.js +5 -3
  255. package/dist/web-office-store.js.map +1 -1
  256. package/package.json +1 -1
@@ -10,7 +10,7 @@ import { lang } from "/assets/app-i18n.js";
10
10
  import { hubClient } from "./hub-client.js";
11
11
  import { hm } from "./hub-room-members-strings.js";
12
12
  import { hroom } from "./hub-room-strings.js";
13
- import { collapse, headerCounts, presenceDot, presenceView, sortAgents } from "./hub-room-presence.js";
13
+ import { agentPictureSrc, collapse, headerCounts, presenceDot, presenceView, sortAgents } from "./hub-room-presence.js";
14
14
  import { hn, linkRoomsU2Css } from "./hub-room-new-strings.js";
15
15
  import { roomSource, RoomSourceMark } from "./hub-room-source.js";
16
16
  import { firstCharacter } from "/assets/instance-nav.js";
@@ -91,7 +91,11 @@ export function agentAvatar(m) {
91
91
  * slot M-3256's source badge had: every agent row's badge was the same logo, so the avatar now says "an agent" (people's
92
92
  * rows have none) and the source is said by the row's title, its accessible name and the agent's card (the design check).
93
93
  */
94
- function AgentAvatar({ m }) {
94
+ function AgentAvatar({ m, roomId = null }) {
95
+ // R2b: the disc its owner's sidebar shows, filling the circle as there (instance-nav.js .av img); one that fails to load
96
+ // gives the R2a avatar back.
97
+ const src = agentPictureSrc(roomId, m?.id, "disc", m?.look?.disc), [broken, setBroken] = useState(null);
98
+ if (src && broken !== src) return html`<span class="hub-agent-av pic" aria-hidden="true"><img src=${src} alt="" loading="lazy" decoding="async" onError=${() => setBroken(src)} /></span>`;
95
99
  const a = agentAvatar(m);
96
100
  // The colour goes in through the CSSOM (no style attribute: the dashboard's CSP, web-csp-1300).
97
101
  const paint = (el) => { if (!el?.style) return; if (a.color) { el.style.setProperty("--av", a.color); el.style.setProperty("--av-ink", a.ink); } else { el.style.removeProperty("--av"); el.style.removeProperty("--av-ink"); } };
@@ -159,7 +163,7 @@ export function RoomMembersPanel({ client = hubClient(), roomId, detail, onMenti
159
163
  // R2a: an agent's avatar takes the source mark's slot (the source in the row's title, accessible name and card). The
160
164
  // room assistant has the sidebar's 「Hub 助理」 disc (its first character, "H"), so the column lines up.
161
165
  const agentRow = m.kind === "agent" || m.kind === "later";
162
- const mark = agentRow ? html`<${AgentAvatar} m=${m} />` : m.kind === "assistant" ? html`<${AgentAvatar} m=${{ name: hroom("hubAssistant") }} />` : html`<${RoomSourceMark} source=${roomSource(m)} decorative=${true} />`;
166
+ const mark = agentRow ? html`<${AgentAvatar} m=${m} roomId=${roomId} />` : m.kind === "assistant" ? html`<${AgentAvatar} m=${{ name: hroom("hubAssistant") }} />` : html`<${RoomSourceMark} source=${roomSource(m)} decorative=${true} />`;
163
167
  return html`<span class="hub-member-name">${mark}${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>${!compact&&(m.intro||m.kind==="assistant")?html`<small class="note">${m.kind==="assistant"?hi("assistant"):m.intro}</small>`:null}`;
164
168
  };
165
169
  const person = (m) => html`<li class="hub-member" key=${m.id}>${row(m, html`${m.id === meId ? html` <span class="tag">${hroom("roleYou")}</span>` : null}${m.role === "manager" ? html` <span class="tag">${hroom("roleManager")}</span>` : null}`)}</li>`;
@@ -9,7 +9,7 @@ import { lang } from "/assets/app-i18n.js";
9
9
  import { createLease } from "/assets/app-ctx.js";
10
10
  import { Skeleton, ErrorState } from "/assets/ui-states.js";
11
11
  import { hroom } from "./hub-room-strings.js";
12
- import { presenceView } from "./hub-room-presence.js";
12
+ import { agentCharacterSrc, agentPictureSrc, presenceView } from "./hub-room-presence.js";
13
13
 
14
14
  /** How often a shown office is read again (the share page's POLL_MS). */
15
15
  export const ROOM_OFFICE_POLL_MS = 5000;
@@ -33,6 +33,73 @@ const safeKey = (name) => (RESERVED(name) ? `\u2060${name}` : name);
33
33
  const clip = (text, n) => { const c = [...text]; return c.length > n ? `${c.slice(0, n - 1).join("")}…` : text; };
34
34
  const STORAGE_PREFIX = "agend_hub_room_office:";
35
35
 
36
+ /**
37
+ * M-3533 R2c: an agent's own character in a room office is fitted into the built-in figure's box (fleet-office-skin.js
38
+ * charBox: 48 × 66), kept in proportion, never larger — one scale for everyone in the room (Lumen's choice, B, over the
39
+ * pack's own scale: at 64 × 96 a robot stood twice a figure's height and crossed its area's edge and name). Its feet stay
40
+ * on the seat, as a figure's. Drawn unsmoothed, as the Fleet office draws every strip.
41
+ */
42
+ export const CHARACTER_FIT = { w: 48, h: 66 };
43
+ /**
44
+ * An agent's character as the drawing takes it (a checked pack's strips, fleet-office-pack.js), its pictures at `src(pose,
45
+ * hash)`, each fitted into CHARACTER_FIT; null when it has none or a strip is not a well-formed one.
46
+ */
47
+ export function characterSet(character, src) {
48
+ if (!character || typeof character !== "object") return null;
49
+ const out = {};
50
+ for (const [pose, st] of Object.entries(character)) {
51
+ const url = st && src(pose, st.sha256);
52
+ const nums = st && ["frames", "w", "h", "fps", "ax", "ay", "dw", "dh"].every((k) => typeof st[k] === "number" && Number.isFinite(st[k]));
53
+ if (!url || !nums || !(st.frames >= 1 && st.dw > 0 && st.dh > 0)) return null;
54
+ const k = Math.min(1, CHARACTER_FIT.w / st.dw, CHARACTER_FIT.h / st.dh);
55
+ out[pose] = { src: url, frames: st.frames, w: st.w, h: st.h, fps: st.fps, ax: st.ax, ay: st.ay, dw: st.dw * k, dh: st.dh * k,
56
+ ...(Array.isArray(st.durations) ? { durations: st.durations } : {}), ...(st.once === true ? { once: true } : {}), ...(typeof st.loopFrom === "number" ? { loopFrom: st.loopFrom } : {}) };
57
+ }
58
+ return Object.keys(out).length ? out : null;
59
+ }
60
+ /** A picture loaded for the drawing (an Image once it has loaded; null if it fails). */
61
+ const loadImage = (url) => new Promise((resolve) => {
62
+ if (typeof Image !== "function") { resolve(null); return; }
63
+ const im = new Image();
64
+ im.onload = () => resolve(im); im.onerror = () => resolve(null);
65
+ im.src = url;
66
+ });
67
+
68
+ /**
69
+ * M-3533 R2c: the room's agents' own characters, each drawn only once all its pictures have loaded (an agent is drawn wholly
70
+ * with its set or wholly as the figure). `instances` the drawing's (named), `load` an image loader (tests).
71
+ */
72
+ export function useCharacters(roomId, instances, load = loadImage) {
73
+ const [images, setImages] = useState(() => new Map());
74
+ const wanted = useMemo(() => {
75
+ const sets = new Map();
76
+ for (const i of Array.isArray(instances) ? instances : []) {
77
+ const set = i && i.member ? characterSet(i.character, (pose, hash) => agentCharacterSrc(roomId, i.member, pose, hash)) : null;
78
+ if (set) sets.set(i.name, set);
79
+ }
80
+ return sets;
81
+ }, [roomId, instances]);
82
+ const urls = useMemo(() => [...new Set([...wanted.values()].flatMap((set) => Object.values(set).map((st) => st.src)))].sort(), [wanted]);
83
+ useEffect(() => {
84
+ let live = true;
85
+ const missing = urls.filter((u) => !images.has(u));
86
+ for (const u of missing) load(u).then((im) => { if (live) setImages((m) => new Map(m).set(u, im)); });
87
+ return () => { live = false; };
88
+ }, [urls.join("\n")]);
89
+ // Each read of the room makes new objects: the drawing gets a new skin only when the characters themselves change.
90
+ const sig = JSON.stringify([...wanted]);
91
+ return useMemo(() => {
92
+ const sets = Object.create(null), ready = new Map();
93
+ for (const [name, set] of wanted) {
94
+ const strips = Object.values(set);
95
+ if (!strips.every((st) => images.get(st.src))) continue;
96
+ sets[name] = set;
97
+ for (const st of strips) ready.set(st.src, images.get(st.src));
98
+ }
99
+ return Object.keys(sets).length ? { sets, images: ready } : null;
100
+ }, [sig, images]);
101
+ }
102
+
36
103
  /** The Office drawing, loaded once on first use (the Hub serves it; a fleet page has it already). */
37
104
  let drawing = null;
38
105
  export const loadDrawing = () => (drawing ??= Promise.all([import("./fleet-office.js"), import("./fleet-org.js")])
@@ -175,6 +242,7 @@ export function RoomOffice({ client, roomId, members, onMention = null, onOpenCh
175
242
  }, [lease, attempt]);
176
243
  const shown = useMemo(() => (d ? named(d, members) : null), [d, members]);
177
244
  holder.d = shown;
245
+ const characters = useCharacters(roomId, shown?.instances);
178
246
  const view = useMemo(() => (kit && shown ? kit.buildOrgView(shown.org, officeApp(shown)) : null), [kit, shown]);
179
247
  const memberOf = (name) => {
180
248
  const id = shown?.instances.find((i) => i.name === name)?.member;
@@ -197,6 +265,7 @@ export function RoomOffice({ client, roomId, members, onMention = null, onOpenCh
197
265
  // The card's row beside "Find in office" and "@ it" is narrow: a short label; the whole words its title and name.
198
266
  ...(onOpenChat && m.canAsk === true ? [{ label: hroom("chatOneToOneShort"), title: hroom("chatOneToOne"), run: () => onOpenChat(m) }] : [])];
199
267
  return acts.length > 1 ? acts : acts[0] || null; } : null}
200
- foldBar=${true} more=${more} onMore=${onMore} officesKey=${`${shown.offices?.offices?.[0]?.skin ?? ""}\n${shown.offices?.offices?.[0]?.members?.join("\n") ?? ""}`} />
268
+ cardPhoto=${(name) => { const i = shown.instances.find((x) => x.name === name); return i?.member ? agentPictureSrc(roomId, i.member, "portrait", i.picture?.portrait) : null; }}
269
+ foldBar=${true} more=${more} onMore=${onMore} characters=${characters} officesKey=${`${shown.offices?.offices?.[0]?.skin ?? ""}\n${shown.offices?.offices?.[0]?.members?.join("\n") ?? ""}`} />
201
270
  </div>`;
202
271
  }
@@ -124,3 +124,17 @@ export function headerCounts(members) {
124
124
  export function collapse(list, limit = 8) {
125
125
  return { shown: list.slice(0, limit), rest: Math.max(0, list.length - limit) };
126
126
  }
127
+
128
+ /**
129
+ * M-3533 R2b: an agent's picture in this room — for the room's members only; `?v=` is the hash the room shows, so a new
130
+ * picture is a new address. null when there is none (or the room or agent is unknown).
131
+ */
132
+ export function agentPictureSrc(roomId, exposureId, slot, hash) {
133
+ return roomId && exposureId && typeof hash === "string" && /^[a-f0-9]{64}$/.test(hash)
134
+ ? `/hub/v1/rooms/${encodeURIComponent(roomId)}/agents/${encodeURIComponent(exposureId)}/picture/${slot}?v=${hash}` : null;
135
+ }
136
+ /** M-3533 R2c: one pose of an agent's own character in this room (its strip's picture), as agentPictureSrc; null when none. */
137
+ export function agentCharacterSrc(roomId, exposureId, pose, hash) {
138
+ return roomId && exposureId && typeof pose === "string" && /^[A-Za-z]{1,16}$/.test(pose) && typeof hash === "string" && /^[a-f0-9]{64}$/.test(hash)
139
+ ? `/hub/v1/rooms/${encodeURIComponent(roomId)}/agents/${encodeURIComponent(exposureId)}/character/${pose}?v=${hash}` : null;
140
+ }
@@ -40,8 +40,13 @@ register("hubRoom", {
40
40
  searchResults: "Results", searchRooms: "Rooms and chats", searchBadgeRoom: "Room", searchBadgeChat: "Chat", searchCount: "{0} results",
41
41
  searchOlder: "Search older messages", searchKeys: "↑↓ move · Enter open · Esc close", jumpMissing: "That message is no longer in this room.",
42
42
  filterPh: "Filter: name or owner", filterClear: "Clear the filter",
43
- laterAnswer: "{0} ({1}) · answers after they come online", noAnswer: "No answer", noAnswerUnanswered:"No answer: The agent finished without answering here", noAnswerStopped: "No answer: {0} stopped sharing this agent.",
43
+ laterAnswer: "{0} ({1}) · answers after they come online", noAnswer: "No answer", noAnswerReshare: "This agent is unavailable right now. Its owner needs to share it again.", noAnswerUnanswered:"No answer: The agent finished without answering here", noAnswerStopped: "No answer: {0} stopped sharing this agent.",
44
44
  workingOne: "{0} is working on it", workingMany: "{0} agents are working",
45
+ waitBehindOne: "Waiting: {0} is answering another question first", waitBehindMany: "Waiting: {0} has {1} questions to answer first",
46
+ waitBusy: "Waiting: {0} is busy with other work", waitPaused: "Waiting: {0} is paused; it gets your question when it resumes",
47
+ waitOffline: "Waiting: {0} is offline; it gets your question when it's back", waitStart: "Sent to {0}; waiting for it to start", elapsedTitle: "Time since it started",
48
+ handedUnknown: "Handed to {0}; waiting for its answer",
49
+ workPaused: "Paused: {0} continues with your question when it resumes", workOffline: "Offline: {0} continues with your question when it's back",
45
50
  // §4 composer
46
51
  composer: "Speak in “{0}”; @ an agent to have it answer",
47
52
  composerShort: "Message, or @ an agent to ask", // Lumen (spec §4): a phone's width
@@ -55,6 +60,9 @@ register("hubRoom", {
55
60
  errAssistant: "The room assistant cannot answer right now.",
56
61
  notSentBecause: "Not sent: {0}",
57
62
  sendNoConnection: "it did not reach AgEnD — check the connection", retrySend: "Retry send",
63
+ sendSignedOut: "you are signed out — sign in again, then send it", sendSession: "this page's sign-in changed — reload the page, then send it",
64
+ sendBusy: "the Hub is busy just now — try again in a moment", sendUnavailable: "the Hub can't take it just now — try again",
65
+ sendDenied: "you can't ask this agent any more", sendInvalid: "the Hub didn't accept this message", sendRefused: "the Hub refused it ({0})",
58
66
  // §5 members rail
59
67
  membersHead: "Members · {0} (online {1})", roleYou: "You", roleManager: "Manager",
60
68
  agentsHead: "Agents · {0} (online {1})", moreN: "… {0} more",
@@ -189,8 +197,13 @@ register("hubRoom", {
189
197
  searchResults: "結果", searchRooms: "房間與聊天", searchBadgeRoom: "房間", searchBadgeChat: "聊天", searchCount: "{0} 筆結果",
190
198
  searchOlder: "搜尋更早的訊息", searchKeys: "↑↓ 移動 · Enter 開啟 · Esc 關閉", jumpMissing: "這則訊息已不在這個房間裡。",
191
199
  filterPh: "篩選:名稱或擁有者", filterClear: "清除篩選",
192
- laterAnswer: "{0}({1})· 上線後回答", noAnswer: "沒有回答", noAnswerUnanswered:"沒有回答:Agent 已結束處理,但沒有在這裡回答。", noAnswerStopped: "沒有回答:{0} 已停止分享這個 Agent。",
200
+ laterAnswer: "{0}({1})· 上線後回答", noAnswer: "沒有回答", noAnswerReshare: "這個 Agent 暫時無法回答,擁有者需要重新分享。", noAnswerUnanswered:"沒有回答:Agent 已結束處理,但沒有在這裡回答。", noAnswerStopped: "沒有回答:{0} 已停止分享這個 Agent。",
193
201
  workingOne: "{0} 正在處理", workingMany: "{0} 個 Agent 正在處理",
202
+ waitBehindOne: "等待中:{0} 正在先回答另一個問題", waitBehindMany: "等待中:{0} 前面還有 {1} 個問題",
203
+ waitBusy: "等待中:{0} 正在處理其他工作", waitPaused: "等待中:{0} 已暫停,恢復後會收到你的問題",
204
+ waitOffline: "等待中:{0} 離線中,上線後會收到你的問題", waitStart: "已送給 {0},等它開始處理", elapsedTitle: "開始處理後經過的時間",
205
+ handedUnknown: "已交給 {0},等它回答",
206
+ workPaused: "已暫停:{0} 恢復後會繼續處理你的問題", workOffline: "離線:{0} 上線後會繼續處理你的問題",
194
207
  composer: "在「{0}」說話;@ 一個 Agent 請它回答",
195
208
  composerShort: "說話,或 @ Agent 請它回答",
196
209
  mentionAllHint: "{0} 個都會回答", mentionAssistant: "@房間助理",
@@ -203,6 +216,9 @@ register("hubRoom", {
203
216
  errAssistant: "房間助理暫時無法回答。",
204
217
  notSentBecause: "沒有送出:{0}",
205
218
  sendNoConnection: "沒有送到 AgEnD,請檢查網路連線", retrySend: "重試傳送",
219
+ sendSignedOut: "你已登出,請重新登入後再傳送", sendSession: "這個頁面的登入狀態已變更,請重新整理頁面後再傳送",
220
+ sendBusy: "Hub 目前忙碌,請稍候再試", sendUnavailable: "Hub 暫時無法接收,請再試一次",
221
+ sendDenied: "你已經不能再問這個 Agent", sendInvalid: "Hub 不接受這則訊息", sendRefused: "Hub 拒絕了這則訊息({0})",
206
222
  membersHead: "成員 · {0}(線上 {1})", roleYou: "你", roleManager: "管理",
207
223
  agentsHead: "Agent · {0}(線上 {1})", moreN: "… 其餘 {0} 個",
208
224
  whoSees: "誰看得到",
@@ -31,16 +31,22 @@ import { notifyStore, notifySupport, setNotify } from "/assets/app-needs.js";
31
31
  import { HubNotifyToggle } from "./hub-room-notify.js";
32
32
  import { createHubButtonActions } from "./hub-button-actions.js";
33
33
  import { linkRoomsU2Css } from "./hub-room-new-strings.js";
34
- import { workingLine } from "./hub-room-working.js";
34
+ import { directStatus, workingLine } from "./hub-room-working.js";
35
35
  import { roomSource, mountSourceAuthor } from "./hub-room-source.js";
36
36
  import { countsLine } from "./hub-room-list.js";
37
37
  import { DropOverlay, MAX_FILES, PendingFiles, hf, hubFileAttachment, pageCarriesFiles, putBackText, roomTakesFiles, uploadChosen, useFileDrop } from "./hub-attachments.js";
38
38
  import { LightboxHost, openLightbox } from "/assets/image-lightbox.js";
39
39
  import { ROOM_PINS_MAX, RoomPinsButton, RoomPinsDialog } from "./hub-room-pins.js";
40
40
  import { RoomOffice } from "./hub-room-office.js";
41
+ // M-3591: an HTML page in a room opens in the side panel, as in a one-to-one chat (panel-hub.js HubRoomView).
42
+ import { PreviewPanel, closePanel, panelStore } from "/assets/preview-panel.js";
43
+ import { msgKey } from "/assets/chat-thread.js";
44
+ import { bindRoomFeedback, bootHubPreview, downloadHtml, draftWithLine, panelOpenFor, roomPanelKey, setHubPreviewOptIn } from "./hub-preview.js";
41
45
  // M-3125 PR3: the one quote target an annotated room picture has (here, so a page with an older dictionary has the words).
42
46
  register("hubRoomAnnotate", { en: { quote: "Quote in this room" }, "zh-TW": { quote: "引用到這個房間" } });
43
47
 
48
+ register("hubDirectPosts",{en:{mute:"Mute this agent’s own messages",muted:"{0}’s own messages are off.",mutedNotice:"{0}’s own messages are off; your questions still get answers.",unmuted:"This agent can send you messages again.",failed:"Could not change this preference. Please try again."},"zh-TW":{mute:"關閉這個 Agent 主動發來的訊息",muted:"已關閉 {0} 主動發來的訊息。",mutedNotice:"已關閉 {0} 主動發來的訊息;你問的問題仍會回答。",unmuted:"這個 Agent 現在可以再次主動發來訊息。",failed:"無法變更這項設定,請再試一次。"}});
49
+
44
50
  linkRoomsU2Css(); // M-3127: the reaction chips and picker are drawn from hub-rooms-u2.css (a room opened before any U2 panel)
45
51
  /**
46
52
  * M-3311 (3): the Fleet chat's 「全寬」 for a Hub conversation — this device's choice (as the Fleet keeps its own), its own key:
@@ -110,7 +116,7 @@ export function systemText(m) {
110
116
  * child counts as failed.
111
117
  */
112
118
  const count = (v) => (Number.isSafeInteger(v) && v > 0 ? v : 0);
113
- const REASON = { "finished-without-answer":"reasonUnanswered",expired: "reasonExpired", unavailable: "reasonUnavailable", interrupted: "reasonInterrupted", retired: "reasonRetired", unknown: "reasonUnknown" };
119
+ const REASON = { "share-needs-reshare":"noAnswerReshare", "finished-without-answer":"reasonUnanswered",expired: "reasonExpired", unavailable: "reasonUnavailable", interrupted: "reasonInterrupted", retired: "reasonRetired", unknown: "reasonUnknown" };
114
120
  export function askReason(code) { return REASON[code] ? hroom(REASON[code]) : ""; }
115
121
  export function askState(ask) {
116
122
  if (!ask || !Number.isSafeInteger(ask.total) || ask.total < 1) return null;
@@ -205,7 +211,9 @@ export function toThreadMessages(messages, { meId, ids, direct = false, expanded
205
211
  ...(!direct && Array.isArray(m.reactions) && m.reactions.length ? { reactionBar: reactionBar(m.reactions, { meId, names }) } : {}),
206
212
  ...(!direct && kind !== "person" && m.buttons ? { buttons: roomButtons(m.buttons, meId) } : {}),
207
213
  ...(quotedId ? { replyTo: { boot: BOOT, id: num(quotedId), sender: quoted ? authorLine(quoted.author, quoted.author?.id === meId, direct) : "", text: quoted ? String(quoted.text || "").slice(0, 120) : "" } } : {}),
208
- ...(m.stage === "not-answered" ? { text: m.reasonCode === "owner-stopped-sharing" ? hroom("noAnswerStopped", author.owner?.name || "") : m.reasonCode==="finished-without-answer"?hroom("noAnswerUnanswered"):hroom("noAnswer") } : {}) });
214
+ ...(m.stage === "not-answered" && !(kind === "person" && m.reasonCode === "share-needs-reshare") ? { text: m.reasonCode === "share-needs-reshare" ? hroom("noAnswerReshare") : m.reasonCode === "owner-stopped-sharing" ? hroom("noAnswerStopped", author.owner?.name || "") : m.reasonCode==="finished-without-answer"?hroom("noAnswerUnanswered"):hroom("noAnswer") } : {}) });
215
+ if (kind === "person" && m.stage === "not-answered" && m.reasonCode === "share-needs-reshare")
216
+ out.push({ boot: BOOT, id: num(`unavailable:${m.id}`), role: "status", sender: "", text: hroom("noAnswerReshare"), bare: true, wrap: true });
209
217
  if (foldAfter) out.push({ boot: BOOT, id: num(`expand:${foldAfter.arg}`), role: "status", sender: "", text: "", bare: true, fold: true, action: foldAfter });
210
218
  // Spec §10: once an @所有 Agent has answers, under the last one shown, 「請房間助理整理」 (it sends 「@房間助理 整理上面的回答」).
211
219
  if (summarise && lastShown && byId.get(m.answerTo)?.mentions?.includes("all"))
@@ -213,7 +221,7 @@ export function toThreadMessages(messages, { meId, ids, direct = false, expanded
213
221
  const line = state?.line, why = !line && mine ? askReason(state?.reason) : "";
214
222
  // Its status, not an event: under it, without a time of its own.
215
223
  if (line) out.push({ boot: BOOT, id: id + 1, role: "status", sender: "", text: line, progressOf: m.id, bare: true });
216
- else if (why) out.push({ boot: BOOT, id: id + 1, role: "status", sender: "", text: why, progressOf: m.id, bare: true });
224
+ else if (why) out.push({ boot: BOOT, id: id + 1, role: "status", sender: "", text: why, progressOf: m.id, bare: true, wrap: state?.reason === "share-needs-reshare" });
217
225
  if (mine && m.warning === "assistant-unavailable") out.push({ boot: BOOT, id: id + 1, role: "status", sender: "", ts: iso(m.at), text: hroom("errAssistant"), bare: true });
218
226
  }
219
227
  return out;
@@ -351,6 +359,8 @@ export function createRoomStore(roomId, { client, meId = "", pinsOn = false } =
351
359
  expand(messageId) { if (typeof messageId === "string" && !expanded.has(messageId)) { expanded.add(messageId); changed(); } },
352
360
  /** Who is working on an answer in this room now (its answer row has no text yet): their names, in arrival order. */
353
361
  working() { return this.workers().map((w) => w.name); },
362
+ /** M-3596: the answer rows still without text (a 1:1 room's open question: working or queued), for its status line. */
363
+ pendingAnswers() { return st.messages.filter((m) => m.answerTo && !m.text && (m.stage === "working" || m.stage === "queued")); },
354
364
  /** The same, as members ({ kind, name }) — what workingLine() words (the room assistant by its own name). */
355
365
  workers() { return st.messages.filter((m) => m.answerTo && !m.text && m.stage === "working" && m.author?.name).map((m) => ({ kind: m.author.kind === "assistant" ? "assistant" : "agent", name: String(m.author.name) })); },
356
366
  /**
@@ -420,8 +430,28 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
420
430
  useEffect(() => { alive.current = true; return () => { alive.current = false; }; }, []);
421
431
  useEffect(() => { setFiles([]); setFileMsg(""); }, [roomId]);
422
432
  const wide = useRailWide();
423
- const input = useRef(null), threadRef = useRef(null), insert = useRef(null);
433
+ const input = useRef(null), threadRef = useRef(null), insert = useRef(null), editDraft = useRef(null);
424
434
  const Panel = useMembersPanel();
435
+ // M-3591: the room's side panel for its HTML pages — the one-to-one chat's (panel-hub.js HubRoomView): the previews set
436
+ // up for this page, the panel's "Reply about this page" / Point at it lines into this room's box. Leaving the room
437
+ // closes it (PreviewPanel closes on unmount; the page is keyed by the room).
438
+ const split = useRef(null), panelKey = roomPanelKey(roomId);
439
+ const [panelOpen, setPanelOpen] = useState(() => panelOpenFor(panelKey));
440
+ useEffect(() => { bootHubPreview(); }, []);
441
+ useEffect(() => {
442
+ setPanelOpen(panelOpenFor(panelKey));
443
+ const off = panelStore.subscribe(() => setPanelOpen(panelOpenFor(panelKey)));
444
+ const release = bindRoomFeedback({
445
+ findMsg: (key) => store.messages().find((x) => msgKey(x) === key) || null,
446
+ addLine: (line) => editDraft.current?.((d) => draftWithLine(d, line)),
447
+ focus: () => {
448
+ const el = input.current; if (!el) return;
449
+ el.focus();
450
+ setTimeout(() => { try { const n = el.value.length; el.setSelectionRange(n, n); } catch { /* not a text field */ } }, 0);
451
+ },
452
+ });
453
+ return () => { off(); release(); };
454
+ }, [store]);
425
455
  // dev-claude2's room settings (hub-room-settings.js), opened from the header or the members panel.
426
456
  const [settings, setSettings] = useState(null);
427
457
  const openSettings = () => { import("./hub-room-settings.js").then((m) => { if (typeof m.RoomSettings === "function") setSettings(() => m.RoomSettings); }, () => {}); };
@@ -573,7 +603,15 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
573
603
  // M-3311 (3): the header's menu — a group room's Room settings and Leave, and on a desk the Fleet chat's 「全寬」 for any room.
574
604
  const [fullWidth, setFullWidth] = useState(hubChatWide);
575
605
  const textSize = useStore(textSizeStore), notify = useStore(notifyStore), narrow = useNarrowScreen();
606
+ const [muteBusy,setMuteBusy]=useState(false);
607
+ async function toggleDirectMute(){
608
+ if(muteBusy)return;setMuteBusy(true);
609
+ try{const muted=!room.directMessagesMuted,r=await client.updateRoom(roomId,{directMessagesMuted:muted});
610
+ if(r.ok){await store.refresh();toast(t(`hubDirectPosts.${muted?"muted":"unmuted"}`,title));}else toast(t("hubDirectPosts.failed"),false);
611
+ }finally{setMuteBusy(false);}
612
+ }
576
613
  const menuItems = [
614
+ !group&&room.kind==="direct"&&room.state==="active"&&typeof room.directMessagesMuted==="boolean"?{key:"directMute",checkbox:true,checked:room.directMessagesMuted,disabled:muteBusy,label:t("hubDirectPosts.mute"),onSelect:()=>{void toggleDirectMute();}}:null,
577
615
  // M-3533 R1: a phone has no tab row — Office is the first item of ⋯ (in the office, its back returns to the chat).
578
616
  narrow && officeOn && !inOffice ? { key: "office", label: hroom("tabOffice"), icon: "org", onSelect: () => onView("office") } : null,
579
617
  // In the office a phone's options (hide paused, bedtime, dialogue, key, fit, fill) are one sheet, not rows over the scene.
@@ -591,17 +629,25 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
591
629
  ].filter(Boolean);
592
630
  const line2 = narrow && inOffice ? hroom("tabOffice") : group ? `${countsLine(room.people, room.agents)}${hasAssistant ? ` · ${hroom("roomAssistant")}` : ""}`
593
631
  : room.assistant ? hroom("providedByHub") : room.agent?.answerOnly ? hp("answerOnlyAsker") : String(room.agent?.owner?.name || "");
594
- const showRail = wide && rail && Panel && group && detail;
632
+ // M-3591: the panel takes the members rail's place while it shows a page (the members button brings the rail back).
633
+ const showRail = wide && rail && Panel && group && detail && !(panelOpen && !inOffice);
595
634
  // The Fleet chat's working bar (Lumen): 「Notes 正在處理」, or 「2 個 Agent 正在處理」 — the answer row only when it arrives.
596
635
  // Who: this room's answers being worked on; the words: workingLine() (#3857), the one place that says it.
597
636
  const working = workingLine({ members: store.workers().map((w) => ({ ...w, presence: "working" })) });
637
+ // M-3596: a 1:1 room says what its own question is doing — the Fleet chat's bar: working (with the time since the agent got
638
+ // it), or waiting and why (behind another question, busy, paused, offline, or just sent). The asker's own questions only.
639
+ const statusOf = (now) => room.kind === "direct" && typeof store.pendingAnswers === "function"
640
+ ? directStatus(store.pendingAnswers(), { name: room.agent?.name || room.name, presence: room.agent?.presence, reported: room.agent?.reported === true }, now) : null;
641
+ const status = statusOf(Date.now());
598
642
  // M-3565: a message's agent name → its card in the members panel: the panel opened (a phone's sheet), the card open.
599
643
  const [focus, setFocus] = useState(null), wideNow = useRef(wide);
600
644
  wideNow.current = wide; // read when pressed: the thread keeps the sender hook from its first render
601
645
  const focusMember = (id) => {
602
646
  const m = (store.detail()?.members || []).find((x) => x && x.kind === "agent" && x.id === id);
603
647
  if (!m) return false;
604
- if (wideNow.current) setRail(true); else setSheet(true);
648
+ // M-3591 (#4407 review): on a desk the rail is where a shown page's panel is — close the page first, as the members
649
+ // button does (read when pressed: the thread keeps this hook from its first render).
650
+ if (wideNow.current) { if (panelOpenFor(panelKey)) closePanel(); setRail(true); } else setSheet(true);
605
651
  setFocus({ id, n: Date.now() });
606
652
  return true;
607
653
  };
@@ -616,7 +662,7 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
616
662
  onMention=${(m) => { setSheet(false); insertMention(m); }}
617
663
  onOpenChat=${chatWith} focus=${focus}
618
664
  onSettings=${() => { setSheet(false); openSettings(); }} />` : null;
619
- return html`<div class=${`hub-chat hub-room-page${showRail ? " with-rail" : ""}`} data-room=${roomId} data-width=${fullWidth ? "full" : undefined}>
665
+ return html`<div class=${`hub-chat hub-room-page${showRail ? " with-rail" : ""}`} data-room=${roomId} data-width=${fullWidth ? "full" : undefined} ref=${split}>
620
666
  <${LightboxHost} />
621
667
  ${pinsOpen ? html`<${RoomPinsDialog} pins=${store.pins()} onClose=${() => setPinsOpen(false)} onJump=${(p) => void showPin(p)} onUnpin=${(p) => void togglePin(p.messageId)} />` : null}
622
668
  <section class="hub-chat-main" ref=${mainRef}>
@@ -634,8 +680,8 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
634
680
  return html`<a key=${v} class=${`seg-item${on ? " active" : ""}`} href=${officeHref(v)} aria-current=${on ? "page" : undefined} data-label=${label}
635
681
  onClick=${(e) => { if (e.metaKey || e.ctrlKey || e.shiftKey || e.button > 0) return; e.preventDefault(); onView(v); }}>${label}</a>`; })}</nav>` : null}
636
682
  <span class="hub-head-tools"><${RoomPinsButton} count=${pinCount} onOpen=${() => setPinsOpen(true)} /><${TextSizeButton} /><${HubNotifyToggle} /></span>
637
- ${group && Panel ? html`<button type="button" class="icon-btn hub-room-rail-toggle" aria-pressed=${(wide ? rail : sheet) ? "true" : "false"} title=${hroom("members")} aria-label=${hroom("members")}
638
- onClick=${() => (wide ? setRail(!rail) : setSheet(true))}><${Icon} name="team" size=${18} /></button>` : null}
683
+ ${group && Panel ? html`<button type="button" class="icon-btn hub-room-rail-toggle" aria-pressed=${(wide ? showRail : sheet) ? "true" : "false"} title=${hroom("members")} aria-label=${hroom("members")}
684
+ onClick=${() => { if (!wide) { setSheet(true); return; } if (panelOpen && !inOffice) { closePanel(); setRail(true); return; } setRail(!rail); }}><${Icon} name="team" size=${18} /></button>` : null}
639
685
  ${menuItems.length ? html`<${Menu} cls="hub-room-menu" label=${hroom("menu")} fit=${true} ownerKey=${roomId} items=${menuItems} />` : null}
640
686
  </header>
641
687
  ${inOffice ? html`<${RoomOffice} key=${roomId} client=${client} roomId=${roomId} members=${detail?.members || []}
@@ -644,21 +690,44 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
644
690
  onEdit=${detail?.me?.role === "manager" && client.roomPurposeV1 === true ? openSettings : undefined} />` : null}
645
691
  ${leaveError ? html`<p class="err hub-room-leave-err" role="alert">${leaveError}</p>` : null}
646
692
  ${room.closureReason === "owner-stopped-sharing" ? html`<p class="note" role="status">${hroom("noAnswerStopped", room.ownerName || room.agent?.owner?.name || "")}</p>` : null}
647
- ${inOffice ? null : html`<${Thread} store=${store} name=${title} panelKey=${`hub-room:${roomId}`} threadRef=${threadRef} extra=${extra}
693
+ ${inOffice ? null : html`<${Thread} store=${store} name=${title} panelKey=${panelKey} threadRef=${threadRef} extra=${extra}
648
694
  emptyView=${room.assistant ? html`<div class="hub-assistant-empty"><${Empty} icon="bot" title=${hroom("hubAssistant")} hint=${hroom("hubAssistantEmpty")} /></div>`
649
695
  : group ? html`<p class="note">${hroom("composerHint")}</p>` : null} />`}
650
696
  ${/* M-3117: under the thread, the Fleet chat's dock — its column, its padding, the working line and the box in it.
651
697
  M-3533 R1: the office shows none (design §2.1: no message box under it; to ask, back to Chat). It stays mounted, hidden,
652
698
  so a draft and the mentions picked into it are still there when Chat comes back. */ ""}
653
699
  ${html`<div class="dock hub-dock" data-trust="composer" hidden=${inOffice}><div class="dock-col">
654
- ${working ? html`<${WorkBarView} kind="working" label=${working.text} elapsed="" elapsedTitle="" />` : null}
655
- <${RoomComposer} store=${sendStore} detail=${detail} reply=${reply} onReply=${setReply} closed=${store.closed()} inputRef=${input} insertRef=${insert}
700
+ ${room.kind === "direct" ? (status ? html`<${DirectStatusBar} statusOf=${statusOf} />` : null)
701
+ : working ? html`<${WorkBarView} kind="working" label=${working.text} elapsed="" elapsedTitle="" />` : null}
702
+ ${room.kind==="direct"&&room.directMessagesMuted?html`<p class="note" role="status">${t("hubDirectPosts.mutedNotice",title)}</p>`:null}
703
+ <${RoomComposer} store=${sendStore} detail=${detail} reply=${reply} onReply=${setReply} closed=${store.closed()} inputRef=${input} insertRef=${insert} editRef=${editDraft}
656
704
  attach=${attach} pending=${pending} canSendEmpty=${files.some((f) => f.state === "ready")} />
657
705
  </div></div>`}
658
706
  </section>
707
+ ${/* M-3591: the office has no thread, so no page panel beside it (leaving for the office closes it). */ ""}
708
+ ${inOffice ? null : html`<${PreviewPanel} name=${panelKey} split=${split} msgs=${() => store.messages()} subscribe=${(fn) => store.subscribe(() => fn(panelKey, "msgs"))}
709
+ keyOf=${msgKey} reveal=${(k) => threadRef.current && threadRef.current.reveal(k)} download=${downloadHtml} allow=${(commit) => setHubPreviewOptIn(true, commit)} />`}
659
710
  ${showRail ? html`<${RailFrame} trust="hub-context" label=${hroom("members")} title=${hroom("members")} closeLabel=${hroom("cancel")} onClose=${() => setRail(false)}>${panel}</${RailFrame}>` : null}
660
711
  ${!wide && sheet && panel && group ? html`<${Dialog} title=${hroom("members")} label=${hroom("members")} onClose=${() => setSheet(false)}><div class="hub-rail-sheet">${panel}</div></${Dialog}>` : null}
661
712
  ${settings && detail ? html`<${settings} client=${client} roomId=${roomId} detail=${detail} assistant=${hasAssistant}
662
713
  onClose=${() => setSettings(null)} onChanged=${() => { void store.refresh(); }} />` : null}
663
714
  </div>`;
664
715
  }
716
+
717
+ /** M-3596: a 1:1 room's status line — the Fleet chat's work bar (working, its elapsed time ticking; or waiting, and why). */
718
+ function DirectStatusBar({ statusOf }) {
719
+ // Worked out again on every tick (its elapsed time; a hand-off the agent never took turns back to waiting after the grace).
720
+ const [, tick] = useState(0);
721
+ const status = statusOf(Date.now());
722
+ const kind = status ? status.kind : null;
723
+ useEffect(() => {
724
+ if (kind !== "working") return undefined;
725
+ const h = setInterval(() => tick((n) => n + 1), 1000);
726
+ return () => clearInterval(h);
727
+ }, [kind]);
728
+ if (!status) return null;
729
+ if (status.kind !== "working") return html`<${WorkBarView} kind="awaiting" label=${status.text} note="" noteTitle="" />`;
730
+ const R = globalThis.AgendChatRender;
731
+ const elapsed = R && typeof status.since === "number" ? R.formatElapsed(Math.max(0, Date.now() - status.since)) : "";
732
+ return html`<${WorkBarView} kind="working" label=${status.text} elapsed=${elapsed} elapsedTitle=${hroom("elapsedTitle")} />`;
733
+ }
@@ -27,3 +27,40 @@ export function assistantFootnote(message) {
27
27
  if (author && author.kind === "assistant" && message.answerTo) return hroom("basedOnRecent");
28
28
  return "";
29
29
  }
30
+
31
+ /** M-3596: how long after a hand-off (the Hub's begin lease) an agent may still report idle before the question reads as
32
+ * not started (a hand-off held before any input never reaches the agent). */
33
+ export const HANDOFF_GRACE_MS = 60_000;
34
+
35
+ /**
36
+ * M-3596: a 1:1 room's status line, as the Fleet chat's work bar says it — from the open question's answer row (no text
37
+ * yet: working once the agent was handed it, else queued with how many came first) and the agent's presence (`reported`:
38
+ * its state came from its fleet; an older one never says). A paused or offline agent wins over working; a hand-off the
39
+ * agent still reports idle after HANDOFF_GRACE_MS never reached it (held before input) and reads as not started. With no
40
+ * reported state at all the Hub knows only that a hand-off was tried (a hold before input never reaches it): it says so,
41
+ * never "working" (Prism #4400). Words from hroom, never copied. → { kind: "working", text, since } | { kind: "awaiting", text } | null (nothing open).
42
+ */
43
+ export function directStatus(messages, agent, now = Date.now()) {
44
+ const rows = Array.isArray(messages) ? messages.filter((m) => m && m.answerTo && !m.text && m.author && m.author.kind === "agent"
45
+ && (m.stage === "working" || m.stage === "queued")) : [];
46
+ const name = String((agent && agent.name) || (rows[0] && rows[0].author.name) || "");
47
+ const presence = agent && agent.presence, reported = !!(agent && agent.reported);
48
+ const working = rows.find((m) => m.stage === "working");
49
+ if (working) {
50
+ if (presence === "paused") return { kind: "awaiting", text: hroom("workPaused", name) };
51
+ if (presence === "offline" || presence === "later") return { kind: "awaiting", text: hroom("workOffline", name) };
52
+ // No state from its fleet: a hand-off was tried, nothing more is known (it may have been held before input).
53
+ if (!reported) return { kind: "awaiting", text: hroom("handedUnknown", name) };
54
+ const since = typeof working.startedAt === "number" ? working.startedAt : working.at;
55
+ if (!(presence === "idle" && now - since > HANDOFF_GRACE_MS)) return { kind: "working", text: hroom("workingOne", name), since };
56
+ return { kind: "awaiting", text: hroom("waitStart", name) };
57
+ }
58
+ const queued = rows.find((m) => m.stage === "queued");
59
+ if (!queued) return null;
60
+ const ahead = typeof queued.ahead === "number" ? queued.ahead : 0;
61
+ const text = presence === "paused" ? hroom("waitPaused", name)
62
+ : presence === "offline" || presence === "later" ? hroom("waitOffline", name)
63
+ : ahead > 1 ? hroom("waitBehindMany", name, ahead) : ahead === 1 ? hroom("waitBehindOne", name)
64
+ : presence === "working" ? hroom("waitBusy", name) : hroom("waitStart", name);
65
+ return { kind: "awaiting", text };
66
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * M-3592: Administration → Sign-in — how long a Hub sign-in lasts, the administrator's (GET/PUT
3
+ * /hub/v1/admin/session-limits). Two lengths from a list within the server's bounds; the server checks them again.
4
+ */
5
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
6
+ import { register, t } from "/assets/app-i18n.js";
7
+
8
+ register("hubSessionLimits", {
9
+ en: {
10
+ title: "Sign-in", absolute: "Sign people out after", idle: "Or after this long without using the Hub",
11
+ note: "A longer sign-in time applies to new sign-ins; a shorter one also signs out anyone already signed in longer than it. The without-use limit applies to everyone at once.",
12
+ activity: "An open Hub page counts as using it: people are signed out for not using it only when no Hub page is open.",
13
+ save: "Save", saving: "Saving…", saved: "Saved.", failed: "Couldn’t save. Try again.", conflict: "Someone else changed this. The current setting is shown; try again.",
14
+ denied: "Only an administrator can change this.", tooLong: "The time without use can’t be longer than the sign-in itself.",
15
+ dflt: "{0} (default)", min: "{0} minutes", hour: "1 hour", hours: "{0} hours", day: "1 day", days: "{0} days",
16
+ },
17
+ "zh-TW": {
18
+ title: "登入時間", absolute: "登入多久後要重新登入", idle: "或多久沒使用 Hub 就登出",
19
+ note: "「登入多久後要重新登入」改長只套用於之後的登入;改短時,已登入超過這個時間的人也會被登出。「多久沒使用 Hub 就登出」會立即套用到所有人。",
20
+ activity: "開著 Hub 頁面就算在使用:只有沒開任何 Hub 頁面時,才會因為沒使用而登出。",
21
+ save: "儲存", saving: "儲存中…", saved: "已儲存。", failed: "無法儲存,請再試一次。", conflict: "這項設定已被其他人修改,已顯示目前的設定,請再試一次。",
22
+ denied: "只有管理員可以修改這項設定。", tooLong: "沒使用的時間不能比登入時間還長。",
23
+ dflt: "{0}(預設)", min: "{0} 分鐘", hour: "1 小時", hours: "{0} 小時", day: "1 天", days: "{0} 天",
24
+ },
25
+ });
26
+ const ts = (key, ...a) => t(`hubSessionLimits.${key}`, ...a);
27
+ /** The lengths offered (minutes), all within the server's bounds. */
28
+ export const ABSOLUTE_CHOICES = Object.freeze([60, 120, 240, 480, 720, 1440, 4320, 10080]);
29
+ export const IDLE_CHOICES = Object.freeze([15, 30, 60, 120, 240, 480, 1440]);
30
+ /** A length in minutes as words: "15 minutes", "8 hours", "7 days". */
31
+ export function minutesText(m) {
32
+ if (m % 1440 === 0) return m === 1440 ? ts("day") : ts("days", m / 1440);
33
+ if (m % 60 === 0) return m === 60 ? ts("hour") : ts("hours", m / 60);
34
+ return ts("min", m);
35
+ }
36
+ const refusal = (r) => r?.status === 409 || r?.code === "revision-conflict" ? ts("conflict")
37
+ : r?.code === "idle-longer-than-absolute" ? ts("tooLong") : r?.status === 401 || r?.status === 403 ? ts("denied") : ts("failed");
38
+
39
+ /** The card; nothing while the setting cannot be read (an older Hub, or not an administrator). */
40
+ export function HubSessionLimitsCard({ client }) {
41
+ const [state, setState] = useState(null), [absolute, setAbsolute] = useState(480), [idle, setIdle] = useState(60);
42
+ const [busy, setBusy] = useState(false), [msg, setMsg] = useState(null);
43
+ const epoch = useRef(0);
44
+ const load = async () => {
45
+ const r = typeof client?.sessionLimits === "function" ? await client.sessionLimits() : { ok: false };
46
+ if (!r || r.ok === false || !Number.isInteger(r.absoluteMinutes)) { setState({ missing: true }); return; }
47
+ setState(r); setAbsolute(r.absoluteMinutes); setIdle(r.idleMinutes);
48
+ };
49
+ useEffect(() => { void load(); return () => { epoch.current++; }; }, []);
50
+ if (!state || state.missing) return null;
51
+ const b = state.bounds || { absolute: { default: 480 }, idle: { default: 60 } };
52
+ // A saved length not in the list (set through the API) is offered as it is.
53
+ const choices = (list, current) => (list.includes(current) ? list : [...list, current].sort((x, y) => x - y));
54
+ const option = (m, def, disabled = false) => html`<option key=${m} value=${String(m)} disabled=${disabled}>${m === def ? ts("dflt", minutesText(m)) : minutesText(m)}</option>`;
55
+ const changed = absolute !== state.absoluteMinutes || idle !== state.idleMinutes;
56
+ const save = async () => {
57
+ if (busy) return;
58
+ if (idle > absolute) { setMsg({ ok: false, text: ts("tooLong") }); return; }
59
+ setBusy(true); setMsg(null); const mine = ++epoch.current;
60
+ let r; try { r = await client.saveSessionLimits({ absoluteMinutes: absolute, idleMinutes: idle, ifRevision: state.revision }); } catch { r = { ok: false }; }
61
+ if (mine !== epoch.current) return;
62
+ setBusy(false);
63
+ if (r && r.ok !== false && Number.isInteger(r.absoluteMinutes)) { setState(r); setAbsolute(r.absoluteMinutes); setIdle(r.idleMinutes); setMsg({ ok: true, text: ts("saved") }); return; }
64
+ setMsg({ ok: false, text: refusal(r) });
65
+ if (r?.status === 409 || r?.code === "revision-conflict") await load();
66
+ };
67
+ return html`<section class="card hub-session-limits" id="hub-admin-sign-in"><h3>${ts("title")}</h3>
68
+ <label class="field"><span>${ts("absolute")}</span>
69
+ <select class="hub-session-absolute" value=${String(absolute)} disabled=${busy} onChange=${(e) => { setAbsolute(Number(e.target.value)); setMsg(null); }}>
70
+ ${choices(ABSOLUTE_CHOICES, state.absoluteMinutes).map((m) => option(m, b.absolute.default))}</select></label>
71
+ <label class="field"><span>${ts("idle")}</span>
72
+ <select class="hub-session-idle" value=${String(idle)} disabled=${busy} onChange=${(e) => { setIdle(Number(e.target.value)); setMsg(null); }}>
73
+ ${choices(IDLE_CHOICES, state.idleMinutes).map((m) => option(m, b.idle.default, m > absolute))}</select></label>
74
+ <p class="note">${ts("note")}</p>
75
+ <p class="note">${ts("activity")}</p>
76
+ ${msg ? html`<p class=${msg.ok ? "note" : "err"} role=${msg.ok ? "status" : "alert"}>${msg.text}</p>` : null}
77
+ <button type="button" class="btn hub-session-save" disabled=${busy || !changed} onClick=${save}>${ts(busy ? "saving" : "save")}</button>
78
+ </section>`;
79
+ }
@@ -77,9 +77,9 @@ register("fleet", {
77
77
  hostMemory_top: "最大:{0}", hostMemory_ownerFleet: "fleet 本身", hostMemory_ownerTmux: "tmux", hostMemory_ownerOther: "不屬於任何 Agent",
78
78
  title: "Fleet", tasks: "任務", schedules: "排程", teams: "團隊", org: "組織圖", cache: "快取", usage: "用量", "host-health": "主機狀態",
79
79
  docs: "文件", docsNewTab: "文件(在新分頁開啟)",
80
- newSchedule: "新增排程", newTeam: "新增 team",
80
+ newSchedule: "新增排程", newTeam: "新增團隊",
81
81
  noSchedules: "還沒有排程", noSchedulesHint: "用 cron 自動執行例行工作。",
82
- noTeams: "還沒有 team", noTeamsHint: "把 Agent 分組一起工作。", countSchedules: "{0} 個排程", countTeams: "{0} 個 team", countSchedule: "1 個排程", countTeam: "1 個 team",
82
+ noTeams: "還沒有團隊", noTeamsHint: "把 Agent 分組一起工作。", countSchedules: "{0} 個排程", countTeams: "{0} 個團隊", countSchedule: "1 個排程", countTeam: "1 個團隊",
83
83
  delete: "刪除", on: "開", off: "關", cancel: "取消", create: "建立", creating: "建立中…", save: "儲存變更",
84
84
  taskDesc: "說明", cron: "Cron 表示式", message: "訊息", target: "目標 Agent", label: "標籤", teamName: "Team 名稱", members: "成員",
85
85
  schedOnce: "一次 · {0}", schedNext: "下次 {0}", schedRetrying: "重試中", schedDisabled: "已停用", schedSilent: "靜默", schedTz: "時區:{0}",
@@ -89,9 +89,9 @@ register("fleet", {
89
89
  cronEveryMinute: "每分鐘", cronEveryMinutes: "每 {0} 分鐘", cronEveryHours: "每 {0} 小時", cronDaily: "每天 {0}",
90
90
  cronWeekdays: "每週一到五 {0}", cronDays: "每週{0} {1}", cronMonthly: "每月 {0} 日 {1}", dayNames: "日,一,二,三,四,五,六", dayJoin: "、",
91
91
  scheduleFieldsRequired: "必須填寫 Cron、訊息與目標 Agent", teamFieldsRequired: "必須填寫名稱並選擇至少一名成員",
92
- deleteSchedule: "確定刪除此排程嗎?", deleteTeam: "確定刪除 team「{0}」嗎?", scheduleCreated: "排程已建立", scheduleDeleted: "排程已刪除",
93
- teamCreated: "Team 已建立", teamDeleted: "Team 已刪除", teamUpdated: "Team 已更新", edit: "編輯", editTeam: "編輯 team",
94
- teamNoRename: "不支援重新命名:請建立新的 team,再刪除這個。",
92
+ deleteSchedule: "確定刪除此排程嗎?", deleteTeam: "確定刪除團隊「{0}」嗎?", scheduleCreated: "排程已建立", scheduleDeleted: "排程已刪除",
93
+ teamCreated: "Team 已建立", teamDeleted: "Team 已刪除", teamUpdated: "Team 已更新", edit: "編輯", editTeam: "編輯團隊",
94
+ teamNoRename: "不支援重新命名:請建立新的團隊,再刪除這個。",
95
95
  backend: "Backend",
96
96
  newInstance: "新增 Agent", directory: "目錄", directoryHint: "可留空——留空會自動建立工作區", topic: "名稱", topicHint: "預設取自目錄名稱",
97
97
  topicRequired: "目錄留空時必須填寫名稱", description: "說明", descriptionHint: "這個 Agent 做什麼", model: "模型", modelHint: "例如 sonnet、opus、gpt-5",