@songsid/agend 2.4.0-beta.10 → 2.4.0-beta.11

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 (197) hide show
  1. package/dist/auth-api.js +1 -0
  2. package/dist/auth-api.js.map +1 -1
  3. package/dist/backend/claude-code.js +35 -9
  4. package/dist/backend/claude-code.js.map +1 -1
  5. package/dist/backend/codex-precaution.d.ts +7 -0
  6. package/dist/backend/codex-precaution.js +102 -0
  7. package/dist/backend/codex-precaution.js.map +1 -0
  8. package/dist/backend/codex.d.ts +1 -0
  9. package/dist/backend/codex.js +18 -0
  10. package/dist/backend/codex.js.map +1 -1
  11. package/dist/backend/grok.js +21 -6
  12. package/dist/backend/grok.js.map +1 -1
  13. package/dist/backend/types.d.ts +9 -1
  14. package/dist/backend/types.js.map +1 -1
  15. package/dist/build-provenance.json +1 -1
  16. package/dist/cli-audited.js +3 -3
  17. package/dist/cli-audited.js.map +1 -1
  18. package/dist/daemon.js +2 -2
  19. package/dist/daemon.js.map +1 -1
  20. package/dist/event-log.d.ts +12 -0
  21. package/dist/event-log.js +40 -0
  22. package/dist/event-log.js.map +1 -1
  23. package/dist/fleet-manager.d.ts +17 -1
  24. package/dist/fleet-manager.js +116 -3
  25. package/dist/fleet-manager.js.map +1 -1
  26. package/dist/general-knowledge/skills/hub/SKILL.md +13 -6
  27. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +10 -1
  28. package/dist/hub/admin-dashboard.js +3 -3
  29. package/dist/hub/admin-dashboard.js.map +1 -1
  30. package/dist/hub/agent-catalog-model.d.ts +276 -0
  31. package/dist/hub/agent-catalog-model.js +49 -0
  32. package/dist/hub/agent-catalog-model.js.map +1 -0
  33. package/dist/hub/agent-catalog.d.ts +137 -0
  34. package/dist/hub/agent-catalog.js +118 -0
  35. package/dist/hub/agent-catalog.js.map +1 -0
  36. package/dist/hub/agent-intro.d.ts +31 -0
  37. package/dist/hub/agent-intro.js +51 -0
  38. package/dist/hub/agent-intro.js.map +1 -0
  39. package/dist/hub/catalog.d.ts +4 -2
  40. package/dist/hub/catalog.js +19 -3
  41. package/dist/hub/catalog.js.map +1 -1
  42. package/dist/hub/client.d.ts +2 -0
  43. package/dist/hub/client.js +21 -1
  44. package/dist/hub/client.js.map +1 -1
  45. package/dist/hub/compose/member.d.ts +6 -0
  46. package/dist/hub/compose/member.js +68 -10
  47. package/dist/hub/compose/member.js.map +1 -1
  48. package/dist/hub/compose/server.d.ts +4 -0
  49. package/dist/hub/compose/server.js +2 -1
  50. package/dist/hub/compose/server.js.map +1 -1
  51. package/dist/hub/execution/service.d.ts +1 -1
  52. package/dist/hub/execution/service.js +1 -0
  53. package/dist/hub/execution/service.js.map +1 -1
  54. package/dist/hub/http/compose.d.ts +2 -0
  55. package/dist/hub/http/compose.js +98 -14
  56. package/dist/hub/http/compose.js.map +1 -1
  57. package/dist/hub/http/schema.js +9 -0
  58. package/dist/hub/http/schema.js.map +1 -1
  59. package/dist/hub/mcp/tools.js +2 -1
  60. package/dist/hub/mcp/tools.js.map +1 -1
  61. package/dist/hub/member/agent-catalog.d.ts +28 -0
  62. package/dist/hub/member/agent-catalog.js +80 -0
  63. package/dist/hub/member/agent-catalog.js.map +1 -0
  64. package/dist/hub/member/exposure-api.d.ts +3 -3
  65. package/dist/hub/member/exposure-api.js +4 -4
  66. package/dist/hub/member/exposure-api.js.map +1 -1
  67. package/dist/hub/member/exposures.d.ts +12 -4
  68. package/dist/hub/member/exposures.js +27 -13
  69. package/dist/hub/member/exposures.js.map +1 -1
  70. package/dist/hub/member/room-ask.d.ts +4 -1
  71. package/dist/hub/member/room-ask.js +6 -3
  72. package/dist/hub/member/room-ask.js.map +1 -1
  73. package/dist/hub/member/room-context-budget.d.ts +5 -0
  74. package/dist/hub/member/room-context-budget.js +34 -0
  75. package/dist/hub/member/room-context-budget.js.map +1 -0
  76. package/dist/hub/member/sharing-journal.d.ts +252 -0
  77. package/dist/hub/member/sharing-journal.js +212 -0
  78. package/dist/hub/member/sharing-journal.js.map +1 -0
  79. package/dist/hub/member/sharing-link.d.ts +25 -0
  80. package/dist/hub/member/sharing-link.js +68 -0
  81. package/dist/hub/member/sharing-link.js.map +1 -0
  82. package/dist/hub/member/sharing-result.d.ts +6 -0
  83. package/dist/hub/member/sharing-result.js +46 -0
  84. package/dist/hub/member/sharing-result.js.map +1 -0
  85. package/dist/hub/member/sharing.d.ts +37 -0
  86. package/dist/hub/member/sharing.js +181 -0
  87. package/dist/hub/member/sharing.js.map +1 -0
  88. package/dist/hub/personal/owner-host.d.ts +6 -0
  89. package/dist/hub/personal/owner-host.js +4 -2
  90. package/dist/hub/personal/owner-host.js.map +1 -1
  91. package/dist/hub/protocol.d.ts +226 -0
  92. package/dist/hub/protocol.js +3 -0
  93. package/dist/hub/protocol.js.map +1 -1
  94. package/dist/hub/rooms/agents.d.ts +1 -0
  95. package/dist/hub/rooms/agents.js +13 -2
  96. package/dist/hub/rooms/agents.js.map +1 -1
  97. package/dist/hub/rooms/direct-view.d.ts +5 -1
  98. package/dist/hub/rooms/direct-view.js +2 -2
  99. package/dist/hub/rooms/direct-view.js.map +1 -1
  100. package/dist/hub/rooms/service.d.ts +32 -0
  101. package/dist/hub/rooms/service.js +25 -11
  102. package/dist/hub/rooms/service.js.map +1 -1
  103. package/dist/hub/rooms/types.d.ts +2 -1
  104. package/dist/hub/rooms.d.ts +1 -0
  105. package/dist/hub/rooms.js +9 -4
  106. package/dist/hub/rooms.js.map +1 -1
  107. package/dist/hub/runtime.d.ts +1 -1
  108. package/dist/hub/server.js +23 -1
  109. package/dist/hub/server.js.map +1 -1
  110. package/dist/hub/sharing-previous-access.d.ts +22 -0
  111. package/dist/hub/sharing-previous-access.js +93 -0
  112. package/dist/hub/sharing-previous-access.js.map +1 -0
  113. package/dist/hub/sharing-requests.d.ts +171 -0
  114. package/dist/hub/sharing-requests.js +311 -0
  115. package/dist/hub/sharing-requests.js.map +1 -0
  116. package/dist/hub/sharing-retention.d.ts +47 -0
  117. package/dist/hub/sharing-retention.js +83 -0
  118. package/dist/hub/sharing-retention.js.map +1 -0
  119. package/dist/hub/sharing-withdrawal.d.ts +14 -0
  120. package/dist/hub/sharing-withdrawal.js +28 -0
  121. package/dist/hub/sharing-withdrawal.js.map +1 -0
  122. package/dist/hub/types.d.ts +6 -2
  123. package/dist/hub-page-sharing-settings.d.ts +6 -0
  124. package/dist/hub-page-sharing-settings.js +19 -0
  125. package/dist/hub-page-sharing-settings.js.map +1 -0
  126. package/dist/hub-sharing-notice.d.ts +43 -0
  127. package/dist/hub-sharing-notice.js +34 -0
  128. package/dist/hub-sharing-notice.js.map +1 -0
  129. package/dist/locale.js +58 -0
  130. package/dist/locale.js.map +1 -1
  131. package/dist/login-flows.js +1 -1
  132. package/dist/login-flows.js.map +1 -1
  133. package/dist/needs-you.js +1 -0
  134. package/dist/needs-you.js.map +1 -1
  135. package/dist/office-share-page.js +1 -1
  136. package/dist/office-share-page.js.map +1 -1
  137. package/dist/public-web-gateway.js +4 -2
  138. package/dist/public-web-gateway.js.map +1 -1
  139. package/dist/remote-card-answer.d.ts +1 -1
  140. package/dist/remote-card-answer.js +8 -1
  141. package/dist/remote-card-answer.js.map +1 -1
  142. package/dist/remote-card-prompt.js +1 -1
  143. package/dist/remote-card-prompt.js.map +1 -1
  144. package/dist/settings-api.d.ts +1 -0
  145. package/dist/settings-api.js +84 -10
  146. package/dist/settings-api.js.map +1 -1
  147. package/dist/settings-baseline.d.ts +3 -0
  148. package/dist/settings-baseline.js +2 -2
  149. package/dist/settings-baseline.js.map +1 -1
  150. package/dist/settings-change.js +1 -0
  151. package/dist/settings-change.js.map +1 -1
  152. package/dist/settings-effect.d.ts +3 -0
  153. package/dist/settings-effect.js +16 -1
  154. package/dist/settings-effect.js.map +1 -1
  155. package/dist/ui/fleet-office-card.js +8 -4
  156. package/dist/ui/fleet-office-pack.d.ts +1 -0
  157. package/dist/ui/fleet-office-pack.js +6 -2
  158. package/dist/ui/fleet-office-play.js +84 -0
  159. package/dist/ui/fleet-office-store.js +23 -0
  160. package/dist/ui/fleet-office-zones.js +5 -1
  161. package/dist/ui/fleet-office.js +78 -8
  162. package/dist/ui/hub-agent-intro.js +26 -0
  163. package/dist/ui/hub-chat-strings.js +4 -4
  164. package/dist/ui/hub-client.js +12 -1
  165. package/dist/ui/hub-grant-picker.js +25 -11
  166. package/dist/ui/hub-group-strings.js +3 -3
  167. package/dist/ui/hub-my-agents-model.js +42 -0
  168. package/dist/ui/hub-my-agents-strings.js +18 -0
  169. package/dist/ui/hub-my-agents.js +141 -0
  170. package/dist/ui/hub-owner-strings.js +5 -5
  171. package/dist/ui/hub-personal-agent.js +5 -4
  172. package/dist/ui/hub-room-composer.js +27 -4
  173. package/dist/ui/hub-room-list.js +3 -2
  174. package/dist/ui/hub-room-members.js +3 -2
  175. package/dist/ui/hub-room-new.js +1 -1
  176. package/dist/ui/hub-room-strings.js +2 -2
  177. package/dist/ui/hub-room-thread.js +4 -2
  178. package/dist/ui/hub-strings.js +5 -5
  179. package/dist/ui/hub-welcome.js +6 -6
  180. package/dist/ui/notice-hub-sharing.js +81 -0
  181. package/dist/ui/panel-hub.js +16 -11
  182. package/dist/ui/panel-notices.js +2 -1
  183. package/dist/ui/settings-hub-connection.js +2 -2
  184. package/dist/ui/settings-hub-page-sharing.js +52 -0
  185. package/dist/ui/settings-hub.js +4 -2
  186. package/dist/ui/settings-registry.js +1 -0
  187. package/dist/ui/shared/app-shell.js +8 -2
  188. package/dist/ui/shared/app-store.js +6 -2
  189. package/dist/ui/shared/hub-chat.css +3 -0
  190. package/dist/ui/shared/hub-my-agents.css +35 -0
  191. package/dist/web-api.d.ts +4 -1
  192. package/dist/web-api.js +55 -1
  193. package/dist/web-api.js.map +1 -1
  194. package/dist/web-notices.d.ts +17 -0
  195. package/dist/web-notices.js +47 -6
  196. package/dist/web-notices.js.map +1 -1
  197. package/package.json +1 -1
@@ -103,7 +103,9 @@
103
103
  // "byInstance": { "atlas": "fox" }, optional: an instance name → its character set
104
104
  // "props": { "task": STRIP, "send": STRIP, "report": STRIP, "broadcast": STRIP }, optional traffic items
105
105
  // "bubbles": { "en": { "working": ["On it."] }, "zh-TW": { … } } optional: short lines per state (≤ 12 a state,
106
- // ≤ 40 characters each), in place of the page's own
106
+ // ≤ 40 characters each), in place of the page's own; M-3293:
107
+ // also "pat" and "feed" (what a person says to a pat or a feed in
108
+ // the Office; none: the page's own words)
107
109
  // "bubblesByInstance": { "atlas": { "en": { "idle": ["Coffee?"] } } }
108
110
  // optional (#3681): an instance's own lines, as "bubbles" (names
109
111
  // checked like byInstance's, ≤ 500). A person's line for a state
@@ -177,6 +179,8 @@ export const LOGICAL = { w: 1280, h: 720 };
177
179
  /** The people's depth: furniture below it is drawn under them, the rest over them. */
178
180
  export const CHAR_DEPTH = 1000;
179
181
  export const PACK_STATES = ["needs", "crashed", "stuck", "working", "idle", "paused", "stopped", "missing"];
182
+ /** M-3293 (#4119): what a bubbles table may name — the states, and the Office's two reactions (a pat, a feed). */
183
+ export const BUBBLE_KEYS = [...PACK_STATES, "pat", "feed"];
180
184
  const POSES = ["working", "idle", "paused", "needs", "walk", "walkDown", "walkUp", "walkSide"], PROPS = ["task", "send", "report", "broadcast"];
181
185
  /** A character set's strips: its poses, and what its people send (#2562). */
182
186
  const SET_STRIPS = [...POSES, "prop"];
@@ -298,7 +302,7 @@ function bubblesOf(v, at) {
298
302
  out[lang] = {};
299
303
  for (const [s, lines] of Object.entries(table)) {
300
304
  const here = `${at}.${lang}.${s}`;
301
- if (!PACK_STATES.includes(s)) throw new Refused(here, "a state");
305
+ if (!BUBBLE_KEYS.includes(s)) throw new Refused(here, "a state, pat or feed");
302
306
  out[lang][s] = list(lines, LIMIT.lines, here).map((l, i) => {
303
307
  if (typeof l !== "string" || !l.trim() || [...l].length > LIMIT.line || /[\u0000-\u001f\u007f]/.test(l)) throw new Refused(`${here}[${i}]`, `1–${LIMIT.line} characters`);
304
308
  return l.trim();
@@ -0,0 +1,84 @@
1
+ // M-3293 (#4119, the light version): play in the Office — pick a person up and drop them anywhere (they walk back to their
2
+ // seat along the usual route), and pat or feed them (a few hearts rising over the head and a speech bubble). The
3
+ // viewer's own: never stored on the host, never in a share link, never sent to an agent (no request at all), no
4
+ // tokens. Pure — fleet-office.js wires it to the pointer, the walkers and the scene.
5
+ //
6
+ // Who may play: a single zones office on the dashboard itself (not All offices, not a share link's page, not while Edit
7
+ // layout is open), with the viewer's "Drag and pat" on (per device, on by default) — and never with reduced motion.
8
+
9
+ /**
10
+ * LONG_MS: a touch held this long without moving picks a person up (a finger that moves first pans, as before); SLOP:
11
+ * a mouse picks up once it moves this far (CSS px) — a press that never moves is a click (their card). REACT_MS: a
12
+ * pat's or a feed's hearts and words last this long; HEARTS of them, rising RISE units.
13
+ */
14
+ export const PLAY = { LONG_MS: 450, SLOP: 6, REACT_MS: 1800, HEARTS: 3, RISE: 26 };
15
+ export const PLAY_KINDS = ["pat", "feed"];
16
+
17
+ /** Whether the viewer may play here: their toggle on, motion allowed, a single zones office of their own dashboard. */
18
+ export function playAllowed({ on, still, zones, overview, layout, shared }) {
19
+ return !!on && !still && !!zones && !overview && !layout && !shared;
20
+ }
21
+
22
+ /**
23
+ * The pick-up of one pointer: `down(id, type, x, y, t, name)` on a person (`name`; none: nothing to pick up) — a mouse
24
+ * is "maybe" until it moves SLOP, a touch "press" until LONG_MS (`tick(t)`) or a move past SLOP first ("pan": the view's
25
+ * own drag). Once "held", `move` carries them (`x`, `y` in the view's units; `px` the pointer's travel in CSS px decides
26
+ * the slop). `up(id)` → { name, at } when they were held (dropped there), else null (a click, or a pan).
27
+ */
28
+ export function createHold({ longMs = PLAY.LONG_MS, slop = PLAY.SLOP } = {}) {
29
+ let s = null;
30
+ return {
31
+ down(id, type, x, y, t, name, cx = 0, cy = 0) {
32
+ s = name ? { id, type, cx, cy, t0: t, name, state: type === "touch" ? "press" : "maybe", at: { x, y } } : null;
33
+ return s ? s.state : null;
34
+ },
35
+ move(id, x, y, t, cx = 0, cy = 0) {
36
+ if (!s || s.id !== id) return null;
37
+ const far = Math.hypot(cx - s.cx, cy - s.cy) > slop;
38
+ if (s.state === "maybe" && far) s.state = "held";
39
+ else if (s.state === "press") { if (t - s.t0 >= longMs) s.state = "held"; else if (far) s.state = "pan"; }
40
+ if (s.state === "held") s.at = { x, y };
41
+ return s.state;
42
+ },
43
+ tick(t) { if (s && s.state === "press" && t - s.t0 >= longMs) s.state = "held"; return s ? s.state : null; },
44
+ up(id) {
45
+ if (!s || s.id !== id) return null;
46
+ const r = s.state === "held" ? { name: s.name, at: { ...s.at } } : null;
47
+ s = null;
48
+ return r;
49
+ },
50
+ cancel() { s = null; },
51
+ held() { return s && s.state === "held" ? { name: s.name, at: { ...s.at } } : null; },
52
+ state() { return s ? s.state : null; },
53
+ };
54
+ }
55
+
56
+ const WORDS = {
57
+ en: { pat: "♪ Thanks!", feed: "Yum!" },
58
+ "zh-TW": { pat: "♪ 謝謝!", feed: "好吃!" },
59
+ };
60
+ /** What a person says to a pat or a feed, in the page's language (English otherwise). */
61
+ export const reactWords = (kind, lang) => (WORDS[lang] || WORDS.en)[kind] || "";
62
+
63
+ /**
64
+ * A reaction `r` ({ kind, t0 }) at `t`: its hearts — HEARTS of them over the head (dx, dy from the head, alpha), each
65
+ * a little after the one before, rising and fading — and its words; null once it is over (or not started).
66
+ */
67
+ export function reactionAt(r, t, lang = "en") {
68
+ if (!r || !PLAY_KINDS.includes(r.kind)) return null;
69
+ const f = (t - r.t0) / PLAY.REACT_MS;
70
+ if (f < 0 || f >= 1) return null;
71
+ const hearts = [];
72
+ for (let i = 0; i < PLAY.HEARTS; i++) {
73
+ const g = Math.min(1, Math.max(0, (f - i * 0.12) / (1 - (PLAY.HEARTS - 1) * 0.12)));
74
+ if (g <= 0) continue;
75
+ hearts.push({ dx: (i - (PLAY.HEARTS - 1) / 2) * 9, dy: -10 - g * PLAY.RISE, alpha: 1 - g });
76
+ }
77
+ return { f, hearts, say: reactWords(r.kind, lang) };
78
+ }
79
+
80
+ /** Reactions still showing at `t` (a Map name → { kind, t0 }), the rest dropped; whether any is left. */
81
+ export function pruneReactions(map, t) {
82
+ for (const [n, r] of [...map]) if (t - r.t0 >= PLAY.REACT_MS || t < r.t0) map.delete(n);
83
+ return map.size > 0;
84
+ }
@@ -22,6 +22,11 @@ import { levelsOk } from "./fleet-office-levels.js";
22
22
  import { checkLevels } from "./fleet-office-pack.js";
23
23
 
24
24
  const CHOICE_KEY = "agend_org_office", FILTER_KEY = "agend_org_office_filter", SKIN_KEY = "agend_org_office_skin", ASLEEP_KEY = "agend_org_office_hide_asleep", NIGHT_KEY = "agend_org_office_night";
25
+ /** M-3293: "Drag and pat" here (default: on; reduced motion turns it off whatever this says). */
26
+ const PLAY_KEY = "agend_org_office_play";
27
+ /** M-3293: the agents told about their pats and feeds, from this device (a list of names; default: none). */
28
+ const TELL_KEY = "agend_org_office_tell";
29
+ const TELL_MAX = 200;
25
30
  /** #2554: "0" when All offices leaves the lobby tile out (default: shown). */
26
31
  const LOBBY_KEY = "agend_org_office_lobby";
27
32
  /** #2946: whether the key to the items in the air is open here (default: folded). */
@@ -214,6 +219,24 @@ export function createOfficeStore({ fetch: get = globalThis.fetch, storage } = {
214
219
  /** #2568: whether the idle go to bed at night (00:00–06:00 on this device's clock) here (default: off). */
215
220
  nightOn: () => read(NIGHT_KEY) === "1",
216
221
  saveNightOn: (v) => write(NIGHT_KEY, v ? "1" : "0"),
222
+ /** M-3293: whether a person can be picked up, patted and fed here (default: on). */
223
+ playOn: () => read(PLAY_KEY) !== "0",
224
+ savePlayOn: (v) => write(PLAY_KEY, v ? "1" : "0"),
225
+ /** M-3293: whether `name` is told (with its next real message) about this device's pats and feeds (default: no). */
226
+ tellOn: (name) => { try { const l = JSON.parse(read(TELL_KEY) || "[]"); return Array.isArray(l) && l.includes(name); } catch { return false; } },
227
+ saveTell: (name, v) => {
228
+ let l = [];
229
+ try { const x = JSON.parse(read(TELL_KEY) || "[]"); if (Array.isArray(x)) l = x.filter((n) => typeof n === "string" && n !== name); } catch { /* none */ }
230
+ write(TELL_KEY, JSON.stringify((v ? [...l, name] : l).slice(-TELL_MAX)));
231
+ },
232
+ /** M-3293: tell `instance` about a pat or a feed (only when tellOn says so: the caller asks). { ok, queued } or { ok: false }. */
233
+ async tell(instance, kind) {
234
+ try {
235
+ const r = await get("/ui/office-tell", { method: "POST", headers, body: JSON.stringify({ instance, kind }) });
236
+ const d = await r.json().catch(() => ({}));
237
+ return r.ok ? { ok: true, queued: d.queued === true } : { ok: false, status: r.status };
238
+ } catch { return { ok: false, status: 0 }; }
239
+ },
217
240
  /** #2554: whether All offices shows the lobby tile (the instances in no stored office) here (default: shown). */
218
241
  lobbyTile: () => read(LOBBY_KEY) !== "0",
219
242
  /** #2946: whether the key to the items carried between desks is open here (default: folded). */
@@ -491,6 +491,9 @@ export function createWalkers() {
491
491
  }
492
492
  },
493
493
  at(name, now) { const w = by.get(name); return w ? posAt(w, now) : null; },
494
+ /** M-3293: `name` set down at `at` (picked up and carried, or just dropped): standing there, no walk; the next sync
495
+ * walks them from there to their target along the graph, as any walk. */
496
+ place(name, at) { by.set(name, { pts: null, to: { x: at.x, y: at.y } }); },
494
497
  moving(now) { for (const w of by.values()) if (posAt(w, now).walking) return true; return false; },
495
498
  };
496
499
  }
@@ -568,11 +571,12 @@ const QUIET_IN_CROWD = new Set(["idle", "paused", "stopped", "starting", "queued
568
571
  /**
569
572
  * The bubbles a frame may show (#2513): in an area over capacity (`over`), none for idle or asleep people and at most
570
573
  * CROWD_BUBBLES, the highest ranked first (bubbleRank); elsewhere all of them. `items`: { area, state, shown, key, … }.
574
+ * M-3293: one with `keep` (the words to a pat or a feed: an answer to what the viewer just did) is always kept.
571
575
  */
572
576
  export function thinBubbles(items, over) {
573
577
  const byArea = new Map(), out = [];
574
578
  for (const it of items) {
575
- if (!over || !over.has(it.area)) { out.push(it); continue; }
579
+ if (!over || !over.has(it.area) || it.keep) { out.push(it); continue; }
576
580
  if (QUIET_IN_CROWD.has(it.state)) continue;
577
581
  if (!byArea.has(it.area)) byArea.set(it.area, []);
578
582
  byArea.get(it.area).push(it);
@@ -75,6 +75,7 @@ import { CALLING, activeFurniture, bubbleAt, hiddenBy, bubbleRank, NIGHT, WANDER
75
75
  import { actsOk, createOfficeStore } from "./fleet-office-store.js";
76
76
  import { badgeOf, fixedOf, mergeLevels } from "./fleet-office-levels.js";
77
77
  import { OfficeCard, cardModel } from "./fleet-office-card.js";
78
+ import { PLAY, createHold, playAllowed, pruneReactions, reactionAt } from "./fleet-office-play.js";
78
79
  import { POLL_MS } from "./fleet-traffic.js";
79
80
  import { OfficeEditor, officeForSave } from "./fleet-office-editor.js";
80
81
  import { LayoutEditor, handlesOf } from "./fleet-office-layout.js";
@@ -99,7 +100,7 @@ register("orgo", {
99
100
  b_working: "On it.|Typing…|Almost there|In the zone|One more test", b_idle: "Tea time|Ready when you are|Stretching|Anything for me?",
100
101
  b_paused: "Zzz…|Back later", b_stopped: "Off duty|Zzz…", b_needs: "Need you!|A question for you|Over here!",
101
102
  b_crashed: "Ouch, crashed|Help!", b_stuck: "Hmm, stuck?|Still thinking…",
102
- hideAsleep: "Hide paused and stopped", nightOn: "Bedtime 0–6: the idle sleep", layoutIgnored: "Its saved layout does not fit this style: drawn as the style's own.",
103
+ hideAsleep: "Hide paused and stopped", nightOn: "Bedtime 0–6: the idle sleep", playOn: "Drag and pat", playStill: "Off while reduced motion is on", layoutIgnored: "Its saved layout does not fit this style: drawn as the style's own.",
103
104
  styleForAll: "The whole fleet's style, for everyone: every device and share link", styleHere: "The whole fleet's style in this browser",
104
105
  styleFailed: "The style was not saved for everyone ({0}).", styleBusy: "Too many changes. Try again in a minute.",
105
106
  fit: "Fit the office", overview: "Overview: click to move there", fullscreen: "Fullscreen", exitFullscreen: "Exit fullscreen",
@@ -128,7 +129,7 @@ register("orgo", {
128
129
  b_working: "處理中|打字中…|快好了|專心中|再測一次", b_idle: "喝茶中|隨時可以開工|伸個懶腰|有事找我嗎?",
129
130
  b_paused: "Zzz…|晚點回來", b_stopped: "下班了|Zzz…", b_needs: "需要你!|有個問題|在這裡!",
130
131
  b_crashed: "糟糕,當掉了|救命!", b_stuck: "嗯,卡住了?|還在想…",
131
- hideAsleep: "隱藏暫停與停止的成員", nightOn: "0–6 點就寢:閒著的人去睡", layoutIgnored: "它儲存的配置不適用這個風格:以風格本身的配置顯示。",
132
+ hideAsleep: "隱藏暫停與停止的成員", nightOn: "0–6 點就寢:閒著的人去睡", playOn: "拖曳與摸頭", playStill: "開啟「減少動態效果」時關閉", layoutIgnored: "它儲存的配置不適用這個風格:以風格本身的配置顯示。",
132
133
  styleForAll: "整個 fleet 的風格,所有人共用:每台裝置與分享連結都一樣", styleHere: "這個瀏覽器裡整個 fleet 的風格",
133
134
  styleFailed: "風格沒有替所有人儲存({0})。", styleBusy: "變更太頻繁,請一分鐘後再試。",
134
135
  fit: "顯示整個辦公室", overview: "總覽:點一下移到那裡", fullscreen: "全螢幕", exitFullscreen: "結束全螢幕",
@@ -587,6 +588,18 @@ export function drawPart(ctx, p, a, ox, oy, ms, still, hot, env, tagsOff = false
587
588
  }
588
589
  ctx.restore();
589
590
  }
591
+ // M-3293: a pat or a feed — a few hearts rising over the head (the palette's danger red, the text font: no new art)
592
+ // and their words in a bubble, while it lasts.
593
+ const t0 = now(), reacting = ms && p.reacts && p.reacts.size && pruneReactions(p.reacts, t0) ? p.reacts : null;
594
+ if (reacting) {
595
+ ctx.save();
596
+ ctx.fillStyle = env.pal.danger; ctx.font = "700 11px system-ui, sans-serif"; ctx.textAlign = "center"; ctx.textBaseline = "bottom";
597
+ for (const sp of speakers) {
598
+ const ra = reacting.has(sp.look.name) ? reactionAt(reacting.get(sp.look.name), t0, p.lang) : null;
599
+ if (ra) for (const h of ra.hearts) { ctx.globalAlpha = h.alpha; ctx.fillText("♥", sp.x + h.dx, sp.y + h.dy); }
600
+ }
601
+ ctx.restore();
602
+ }
590
603
  // Speech bubbles: a short line for the state, now and then (typed out; whole at once when still), placed so no two
591
604
  // overlap (placeBubbles; #2431).
592
605
  const bubbles = [];
@@ -594,9 +607,14 @@ export function drawPart(ctx, p, a, ox, oy, ms, still, hot, env, tagsOff = false
594
607
  if (sp.look.dim || sp.look.pose === "away") continue;
595
608
  const says = sp.look.night ? "paused" : sp.look.state; // asleep at night: its "Zzz…" lines
596
609
  // What an agent says itself (office_set, #2578): whole, kept over the area's thinning like a call.
597
- const act = p.acts && p.acts.get(sp.look.name), own = actLive(act, says, Date.now(), p.actSeen) && act.say ? act.say : null;
610
+ const act = p.acts && p.acts.get(sp.look.name), ra = reacting && reacting.has(sp.look.name) ? reactionAt(reacting.get(sp.look.name), t0, p.lang) : null;
611
+ // M-3293: a pat's or a feed's words first — the pack's own for it ("pat" / "feed" in its bubbles: theirs, their
612
+ // set's, the pack's), one picked by when it happened, else the page's.
613
+ const packSays = ra ? linesFor(reacting.get(sp.look.name).kind, p.lang, sk.pack, null, sp.look.name) : [];
614
+ const raSays = ra ? (packSays.length ? packSays[Math.floor(reacting.get(sp.look.name).t0) % packSays.length] : ra.say) : null;
615
+ const own = raSays ? raSays : actLive(act, says, Date.now(), p.actSeen) && act.say ? act.say : null;
598
616
  const b = own ? { text: own, shown: [...own].length } : bubbleAt(sp.look.name, says, ms, linesFor(says, p.lang, sk.pack, p.lines, sp.look.name)); // #3681: theirs, their set's, the pack's
599
- if (b) bubbles.push({ key: sp.look.name, area: sp.area, state: sp.look.state, calling: CALLING.has(sp.look.state), rank: own ? 0 : bubbleRank(sp.look.state), shown: b.shown,
617
+ if (b) bubbles.push({ key: sp.look.name, area: sp.area, state: sp.look.state, calling: CALLING.has(sp.look.state), rank: own ? 0 : bubbleRank(sp.look.state), shown: b.shown, ...(raSays ? { keep: true } : {}),
600
618
  box: bubbleBox(ctx, sp.x, sp.y, b.text), tail: { x: sp.x, y: sp.y }, sp, b });
601
619
  }
602
620
  // A crowded area speaks less (thinBubbles: calls, then work, a few at most); no bubble covers a name tag. `defer`
@@ -604,7 +622,7 @@ export function drawPart(ctx, p, a, ox, oy, ms, still, hot, env, tagsOff = false
604
622
  const placed = placeBubbles(thinBubbles(bubbles, p.zones ? p.L.over : null), 22, tags);
605
623
  const say = () => { T(); for (const { sp, b, dy } of placed) sk.drawBubble(ctx, sp.x, sp.y, [...b.text].slice(0, b.shown).join(""), env, -dy); };
606
624
  if (defer) defer.push(say); else say();
607
- return walking || up.length > 0 || p.flights.size() > 0 || post.some((it) => it.t > 0) || rising.length > 0;
625
+ return walking || up.length > 0 || p.flights.size() > 0 || post.some((it) => it.t > 0) || rising.length > 0 || !!reacting;
608
626
  }
609
627
  /**
610
628
  * #2661: an NPC's name tag (a furniture item's label) — with the title a pack pins on it (`levels.fixed` by its id),
@@ -752,6 +770,9 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
752
770
  const [nightNow, setNightNow] = useState(() => isNight());
753
771
  useEffect(() => { if (!nightOn) return undefined; setNightNow(isNight()); const h = setInterval(() => setNightNow(isNight()), NIGHT.TICK); return () => clearInterval(h); }, [nightOn]);
754
772
  const night = nightOn && nightNow;
773
+ // M-3293: "Drag and pat" here (per device, on by default); in force only where playAllowed says (below).
774
+ const [playOn, setPlayOn] = useState(() => store.playOn());
775
+ const [, setTellRev] = useState(0); // M-3293: the card's Tell box redrawn when ticked
755
776
  const [lobbyOn, setLobbyOn] = useState(() => store.lobbyTile()); // #2554: All offices' lobby tile
756
777
  const [packs, setPacks] = useState([]); // the skin packs the host keeps: [{ id, name, sha }]
757
778
  const [packSkins, setPackSkins] = useState(() => new Map()); // id@sha → a loaded skin, or null (not a pack)
@@ -1101,6 +1122,13 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
1101
1122
  // M-3286: the office's "Idle people stay in their own area" (Edit offices): strolls stay in the area, no visits.
1102
1123
  const ownArea = !!custom && custom.stayInArea === true;
1103
1124
  const visitMemo = useMemo(() => ({ claims: new Map(), idle: null }), [skin]);
1125
+ // M-3293: play — never on a share link's page (no onOpen there, or its own `talk`), with reduced motion, in All
1126
+ // offices, the carousel or Edit layout. `hold`: the person picked up (carried where the pointer is, walked back from
1127
+ // where they are dropped); `reacts`: pats and feeds showing (name → { kind, t0 }). The viewer's own: no request.
1128
+ const shared = talk !== undefined || typeof onOpen !== "function";
1129
+ const play = playAllowed({ on: playOn, still, zones, overview, layout: !!layout, shared }) && !carouselPick;
1130
+ const hold = useMemo(() => createHold(), []), reacts = useRef(new Map()), walkNow = useRef(null), holdTimer = useRef(null);
1131
+ useEffect(() => { if (!play) { hold.cancel(); reacts.current.clear(); } }, [play]);
1104
1132
  useEffect(() => {
1105
1133
  if (!zones || overview) return undefined;
1106
1134
  const go = () => {
@@ -1108,11 +1136,14 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
1108
1136
  // An act's walk; not someone in bed for the night (#2568: bedtime wins, as for mail).
1109
1137
  for (const d of desksOf(L)) { const a = actsHere.get(d.node.name), at = !d.night && actLive(a, d.node.state, Date.now(), actSeen.current) ? actTarget(a, L, walkers, t) : null; if (at) to.set(d.node.name, at); }
1110
1138
  for (const [name, at] of mail.targets(L, t)) to.set(name, at);
1139
+ const held = hold.held(); // M-3293: carried: where the pointer is, no walk
1140
+ if (held) to.set(held.name, held.at);
1111
1141
  walkers.sync(to, t, L, still);
1112
1142
  // Reduced motion has no loop: drawn again here, or an act's walk (set after the scene was drawn) never shows.
1113
1143
  if (still) { if (scene.current && !globalThis.document?.hidden) draw(0); } else loop.current?.wake();
1114
1144
  };
1115
1145
  go();
1146
+ walkNow.current = go;
1116
1147
  if (still) return undefined;
1117
1148
  const h = setInterval(go, WANDER.TICK);
1118
1149
  return () => clearInterval(h);
@@ -1390,7 +1421,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
1390
1421
  const parts = tiles.map((tl, i) => ({ ...partOf(tl.L, tileLooks[i], tl.skin, tl.zones, tl.walkers, tl.flights), night, key: tl.key, prefix: tl.prefix, tile: arranged.tiles[i], ups: ups.current, levelsOn: !!(lv && lv.enabled), levels: wordsOf(tl.skin) }));
1391
1422
  scene.current = { ...base, overview: true, parts, lay: arranged };
1392
1423
  } else {
1393
- scene.current = { ...base, overview: false, part: { ...partOf(L, looks, skin, zones, walkers, flights), ghosts, night, mail, acts: actsHere, actSeen: actSeen.current, ups: ups.current, levelsOn: !!(lv && lv.enabled), levels: wordsOf(skin) } };
1424
+ scene.current = { ...base, overview: false, part: { ...partOf(L, looks, skin, zones, walkers, flights), ghosts, night, mail, acts: actsHere, actSeen: actSeen.current, ups: ups.current, levelsOn: !!(lv && lv.enabled), levels: wordsOf(skin), reacts: reacts.current } };
1394
1425
  }
1395
1426
  if (still) draw(0); else loop.current?.wake();
1396
1427
  }, [L, looks, skin, pal, size.w, size.h, ratio, matte, overview, tiles, tileLooks, arranged, ghosts, night, mail, actsHere, lv, wordsOf]);
@@ -1580,12 +1611,47 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
1580
1611
  pinch: (from, to) => { raw.current = Math.min(OK_MAX, Math.max(OK_MIN, raw.current * (to.dist / from.dist))); setView(pinchOffice(view0(), from, to, raw.current)); } });
1581
1612
  /** Where a drag pans: the canvas, and Edit layout's overlay off its handles (the controls, the bar and the list: never). */
1582
1613
  const onScene = (el) => !!el && (el === canvasRef.current || (typeof el.closest === "function" && !!el.closest(".ol-svg") && !el.closest(".ol-handle")));
1614
+ /** M-3293: someone picked up — their walker set down under the pointer, no card, no tooltip, the click after it swallowed. */
1615
+ const pickedUp = (pointerId) => {
1616
+ const h = hold.held();
1617
+ if (!h) return;
1618
+ // Captured only now: a press that stays a click must reach the canvas (its card), which a capture would take away.
1619
+ try { stageRef.current.setPointerCapture(pointerId); } catch { /* gone */ }
1620
+ walkers.place(h.name, h.at); drag.current.swallow = true;
1621
+ setTip(null); setCard(null); loop.current?.wake();
1622
+ };
1583
1623
  const onDown = (e) => {
1584
1624
  lastType.current = e.pointerType || "mouse";
1585
1625
  if (!onScene(e.target)) return;
1626
+ // M-3293: a press on a person may pick them up — a mouse once it moves (no pan then), a touch once held still
1627
+ // (LONG_MS; a finger that moves first pans, as before).
1628
+ if (play && e.isPrimary !== false && !(e.pointerType === "mouse" && e.button !== 0)) {
1629
+ const d = deskOf(e), w = pointOf(e);
1630
+ const st = d && d.node && d.node.i && w ? hold.down(e.pointerId, e.pointerType || "mouse", w.x, w.y, now(), d.node.name, e.clientX, e.clientY) : hold.down(e.pointerId, "mouse", 0, 0, 0, null);
1631
+ if (st === "maybe") return; // no pan: a click (their card), or a pick-up once it moves
1632
+ if (st === "press") { const id = e.pointerId; clearTimeout(holdTimer.current); holdTimer.current = setTimeout(() => { if (hold.tick(now()) === "held") pickedUp(id); }, PLAY.LONG_MS); }
1633
+ }
1586
1634
  g.down(e);
1587
1635
  if (drag.current.pts.size === 2) raw.current = view0().k; // a pinch starts from the zoom shown
1588
1636
  };
1637
+ /** M-3293: while a press may pick someone up it is theirs (no pan); once held it carries them; a finger that moved first pans. */
1638
+ const onStageMove = (e) => {
1639
+ if (hold.state()) {
1640
+ const w = pointOf(e), was = hold.state();
1641
+ const st = w ? hold.move(e.pointerId, w.x, w.y, now(), e.clientX, e.clientY) : hold.state();
1642
+ if (st === "held") { if (was !== "held") pickedUp(e.pointerId); else { const h = hold.held(); walkers.place(h.name, h.at); loop.current?.wake(); } return; }
1643
+ if (st === "maybe" || st === "press") return;
1644
+ if (st === "pan") { clearTimeout(holdTimer.current); hold.cancel(); }
1645
+ }
1646
+ g.move(e);
1647
+ };
1648
+ const onStageUp = (e) => {
1649
+ clearTimeout(holdTimer.current);
1650
+ const r = hold.up(e.pointerId);
1651
+ if (r) { walkers.place(r.name, r.at); drag.current.swallow = true; setTimeout(() => { if (!drag.current.pts.size) drag.current.swallow = false; }, 0); walkNow.current?.(); }
1652
+ g.up(e);
1653
+ };
1654
+ const onStageCancel = (e) => { clearTimeout(holdTimer.current); const r = hold.up(e.pointerId); if (r) walkNow.current?.(); g.up(e); };
1589
1655
  const onWheel = (e) => {
1590
1656
  if (!onScene(e.target) && !(typeof e.target?.closest === "function" && e.target.closest(".ol-handle, .oo-tile-label"))) return;
1591
1657
  e.preventDefault();
@@ -1816,6 +1882,8 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
1816
1882
  </select></label>
1817
1883
  <${People} nodes=${everyone} pinned=${f.pinned} onChange=${(pinned) => setF({ ...f, pinned })} />` : null}
1818
1884
  <label class="check oo-hide-asleep"><input type="checkbox" checked=${hideAsleep} onChange=${() => { const v = !hideAsleep; store.saveHideAsleep(v); setHideAsleep(v); setTip(null); }} /><span>${to("hideAsleep")}</span></label>
1885
+ ${zones && !overview && !shared ? html`<label class="check oo-play" title=${still ? to("playStill") : null}><input type="checkbox" checked=${playOn && !still} disabled=${still}
1886
+ onChange=${() => { const v = !playOn; store.savePlayOn(v); setPlayOn(v); }} /><span>${to("playOn")}</span></label>` : null}
1819
1887
  ${zones || overview ? html`<label class="check oo-night"><input type="checkbox" checked=${nightOn} onChange=${() => { const v = !nightOn; store.saveNightOn(v); setNightOn(v); }} /><span>${to("nightOn")}</span></label>` : null}
1820
1888
  <label class="check oo-dialogue" title=${to("dialogueTitle")}><input type="checkbox" checked=${dialogueOn} onChange=${toggleDialogue} /><span>${to("dialogue")}</span></label>
1821
1889
  ${overview ? html`<label class="check oo-lobby-tile" title=${lobbyAll.length ? undefined : to("lobbyEveryone")}><input type="checkbox" checked=${lobbyOn && lobbyAll.length > 0}
@@ -1856,7 +1924,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
1856
1924
  ${editing && !overview && !carouselPick ? html`<${OfficeEditor} offices=${stored} rev=${storedRev} view=${view} store=${store} packs=${packs}
1857
1925
  ask=${ask} current=${() => shown.current} onSaved=${adopt} onClose=${() => setEditing(false)} />` : null}
1858
1926
  ${overview || people.length || L.rooms.length ? null : html`<p class="note oo-empty">${to("nobody")} ${auto && (f.team || f.pinned.length) ? html`<button type="button" class="btn btn-sm" onClick=${() => setF({ team: "", pinned: [] })}>${to("everyone")}</button>` : null}</p>`}
1859
- <div class=${`oo-stage${layout ? " editing" : ""}`} ref=${stageRef} onPointerDown=${onDown} onPointerMove=${g.move} onPointerUp=${g.up} onPointerCancel=${g.up}
1927
+ <div class=${`oo-stage${layout ? " editing" : ""}`} ref=${stageRef} onPointerDown=${onDown} onPointerMove=${onStageMove} onPointerUp=${onStageUp} onPointerCancel=${onStageCancel}
1860
1928
  onWheel=${onWheel} onKeyDown=${onKeyDown} onFocusIn=${onFocusIn} onClickCapture=${g.clickCapture}>
1861
1929
  ${dialogueOn ? html`<div class="sr-only oo-dialogue-live" aria-live="polite">${dlgSay}</div>` : null}
1862
1930
  <canvas ref=${canvasRef} class=${`oo-canvas${(tipDesk && tipDesk.node.i) || dlgHot ? " hot" : ""}`} role="application" tabindex="0" aria-label=${to(carouselPick ? "labelCarousel" : overview ? "labelAll" : "label")}
@@ -1879,7 +1947,9 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
1879
1947
  state: stateWords(cardOf.node), now: caption(officePose(cardOf.node.state), cardOf.node.state),
1880
1948
  where: [cardOf.office || (custom ? custom.name : to("allOffice")), cardOf.area].filter(Boolean).join(" · ") })}
1881
1949
  avatar=${drawAvatar} sheet=${phone || size.w < SHEET_W} place=${(el) => { cardEl.current = el; placeCard(); }}
1882
- onChat=${onOpen ? () => { const n = cardOf.node.name; setCard(null); open(n); } : null} onFind=${findCard} onClose=${closeCard} />` : null}
1950
+ onChat=${onOpen ? () => { const n = cardOf.node.name; setCard(null); open(n); } : null} onFind=${findCard} onClose=${closeCard}
1951
+ onReact=${play ? (kind) => { const n = cardOf.node.name; reacts.current.set(n, { kind, t0: now() }); loop.current?.wake(); if (store.tellOn(n)) void store.tell(n, kind); } : null}
1952
+ tell=${play ? { on: store.tellOn(cardOf.node.name), set: (v) => { store.saveTell(cardOf.node.name, v); setTellRev((x) => x + 1); } } : null} />` : null}
1883
1953
  <ul class="oo-desks" aria-label=${to("desks")}>${people.map((d) => {
1884
1954
  const nt = nodeText(d.node), cap = caption(officePose(d.node.state), d.node.state), where = d.office ? ` · ${d.office}` : "";
1885
1955
  return html`<li key=${d.key}>${d.node.i
@@ -0,0 +1,26 @@
1
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
2
+ import { register, t } from "/assets/app-i18n.js";
3
+ register("hubIntro", {
4
+ en: {title:"Introduction",hint:"One line about what this agent handles. Colleagues can see it. Up to 50 characters.",placeholder:"I handle…",save:"Save introduction",failed:"Could not save the introduction. Try again.",saved:"Introduction saved.",owner:"Last changed by the owner",agent:"Last changed by the agent",default:"From the Fleet description",review:"Colleagues will see this line. Check it and save.",cut:"Your earlier description was longer; only the first 50 characters are shown here.",assistant:"Hub assistant. Answers from this room's chat."},
5
+ "zh-TW": {title:"自我介紹",hint:"用一句話說明這個 Agent 負責什麼,同仁會看到。最多 50 個字。",placeholder:"我負責…",save:"儲存自我介紹",failed:"無法儲存自我介紹,請再試一次。",saved:"自我介紹已儲存。",owner:"最後由擁有者修改",agent:"最後由 Agent 修改",default:"來自 Fleet 說明",review:"同仁會看到這一行,請確認後儲存。",cut:"你之前的說明比較長,這裡只顯示前 50 個字。",assistant:"Hub 提供的助理,根據這個房間的對話回答。"}
6
+ });
7
+ export const hi=(key,...args)=>t(`hubIntro.${key}`,...args);
8
+ const split=value=>[...new Intl.Segmenter(undefined,{granularity:"grapheme"}).segment(String(value??""))].map(v=>v.segment);
9
+ export const introCount=value=>split(value).length;
10
+ export const introPreview=value=>split(value).slice(0,50).join("");
11
+ export function AgentIntroEditor({exposure,client,onSaved=()=>{}}){
12
+ const [text,setText]=useState(exposure.intro??""),[busy,setBusy]=useState(false),[message,setMessage]=useState("");
13
+ const generation=useRef(0),pending=useRef(false);
14
+ useEffect(()=>{generation.current++;setText(exposure.intro??"");setMessage("");return()=>{generation.current++;};},[exposure.id,exposure.intro,exposure.introAt]);
15
+ const count=introCount(text);
16
+ const save=async event=>{event.preventDefault();if(pending.current||count>50)return;const mine=generation.current;pending.current=true;setBusy(true);setMessage("");let result;
17
+ try{result=await client.saveAgentIntro(exposure.id,exposure.revision,text);}catch{result={ok:false};}
18
+ pending.current=false;if(mine!==generation.current)return;setBusy(false);setMessage(hi(result?.ok?"saved":"failed"));if(result?.ok)onSaved(result);
19
+ };
20
+ return html`<section class="card hub-agent-intro"><h3>${hi("title")}</h3><form class="form" onSubmit=${save}>
21
+ <label class="field"><span>${hi("title")}</span><input value=${text} placeholder=${hi("placeholder")} disabled=${busy} onInput=${e=>setText(e.target.value)} aria-invalid=${count>50?"true":null} /><small class="note">${`${hi("hint")} ${count}/50`}</small></label>
22
+ ${exposure.introBy?html`<p class="note">${hi(exposure.introBy)}${exposure.introAt?html` · <time datetime=${new Date(exposure.introAt).toISOString()}>${new Date(exposure.introAt).toLocaleString()}</time>`:null}</p>`:null}
23
+ <div class="field-row"><button class="btn btn-sm btn-primary" disabled=${busy||count>50||text===(exposure.intro??"")}>${hi("save")}</button></div>
24
+ ${message?html`<p role="status">${message}</p>`:null}
25
+ </form></section>`;
26
+ }
@@ -8,7 +8,7 @@ register("hubChat", {
8
8
  navSearch: "Search", notices: "Notices", noticesTitle: "Notices", noNotices: "No security notices", noticesLead: "When a new fleet connects to this Hub, you're told here. If you don't recognize it, revoke it.", settings: "Settings", signedIn: "Signed in", signOut: "Sign out",
9
9
  // M-3190: the chat launcher (新對話, or 對話 with nothing to open)
10
10
  launchTitle: "Who do you want to talk to today?", launchOwner: "Owner: {0}", launchInRoom: "In #{0}", launchGo: "Chat →", launchFilter: "Filter agents",
11
- launchNone: "No agent has been shared with you directly yet", launchNoneHint: "Ask a colleague to share one with you in My shared agents, or go into a room on the left and work with its agents.",
11
+ launchNone: "No agent has been shared with you directly yet", launchNoneHint: "Ask a colleague to share one with you in My agents, or go into a room on the left and work with its agents.",
12
12
  launchNewRoom: "New room", launchShare: "Share my agent", launchNoMatch: "No agent matches.",
13
13
  chats: "Chats", newChat: "New chat", search: "Search chats", noChats: "No chats yet", noChatsHint: "Start one with New chat: it lists the agents someone allowed you to ask.",
14
14
  noMatch: "No chat matches.", waiting: "Waiting for an answer", represents: "Answers for {0}",
@@ -35,13 +35,13 @@ register("hubChat", {
35
35
  adminTitle: "Hub administrator", adminSees: "Can't see the content.",
36
36
  notHere: "Not here", notHereText: "{0}'s files and changes, its terminal (View) and its tool progress: only {1} sees them, in their own fleet.",
37
37
  oneToOne: "A chat has only you and this agent.",
38
- menu: "Menu", mine: "My shared agents", mineHint: "Who may ask them, until when", admin: "Administration", adminHint: "Connect fleets",
38
+ menu: "Menu", mine: "My agents", mineHint: "Who may ask them, until when", admin: "Administration", adminHint: "Connect fleets",
39
39
  back: "Chats",
40
40
  },
41
41
  "zh-TW": {
42
42
  navSearch: "搜尋", notices: "通知", noticesTitle: "通知", noNotices: "沒有安全通知", noticesLead: "有新的 Fleet 連接到這個 Hub 時,會在這裡通知你。如果你不認得它,請撤銷。", settings: "設定", signedIn: "已登入", signOut: "登出",
43
43
  launchTitle: "今天想找哪位 Agent?", launchOwner: "擁有者:{0}", launchInRoom: "位於 #{0}", launchGo: "對話 →", launchFilter: "篩選 Agent",
44
- launchNone: "還沒有人直接分享 Agent 給你", launchNoneHint: "請同事在「我分享的 Agent」授權給你,或直接進入左側的房間與 Agent 協作。",
44
+ launchNone: "還沒有人直接分享 Agent 給你", launchNoneHint: "請同事在「我的 Agent」授權給你,或直接進入左側的房間與 Agent 協作。",
45
45
  launchNewRoom: "開新房間", launchShare: "分享我的 Agent", launchNoMatch: "沒有符合的 Agent。",
46
46
  chats: "對話", newChat: "新對話", search: "搜尋對話", noChats: "還沒有對話", noChatsHint: "用「新對話」開始:會列出有人允許你提問的 Agent。",
47
47
  noMatch: "沒有符合的對話。", waiting: "等待回答", represents: "代表 {0} 回答",
@@ -68,7 +68,7 @@ register("hubChat", {
68
68
  adminTitle: "Hub 管理員", adminSees: "看不到內容。",
69
69
  notHere: "這裡沒有", notHereText: "{0} 的檔案與變更、終端機畫面(View)、工具進度:只有 {1} 在自己的 fleet 看得到。",
70
70
  oneToOne: "一個聊天室只有你和這個 Agent。",
71
- menu: "選單", mine: "我分享的 Agent", mineHint: "誰可以提問、到什麼時候", admin: "管理", adminHint: "連接 Fleet",
71
+ menu: "選單", mine: "我的 Agent", mineHint: "誰可以提問、到什麼時候", admin: "管理", adminHint: "連接 Fleet",
72
72
  back: "對話",
73
73
  },
74
74
  });
@@ -120,7 +120,7 @@ export function legacyRoom(item) {
120
120
  if (!item || typeof item !== "object" || typeof item.id !== "string") return null;
121
121
  return { id: item.id, kind: "direct", name: String(item.exposureName || ""), people: 1, agents: 1, online: null, unread: 0,
122
122
  lastAt: Number.isFinite(item.lastAt) ? item.lastAt : 0, lastText: "", lastAuthor: "",
123
- agent: { ...(item.answerOnly?{answerOnly:true}:{}), exposureId: String(item.exposureId || ""), owner: { name: String(item.ownerName || "") }, presence: null }, limited: true, legacy: item };
123
+ agent: { ...(typeof item.intro==="string"?{intro:item.intro}:{}), ...(item.answerOnly?{answerOnly:true}:{}), exposureId: String(item.exposureId || ""), owner: { name: String(item.ownerName || "") }, presence: null }, limited: true, legacy: item };
124
124
  }
125
125
  export const ADDRESS_HINT = /^https:\/\/[^\s/?#@]+\/?$/i;
126
126
  export const CODE_HINT = /^[A-Za-z0-9][A-Za-z0-9 -]{4,62}[A-Za-z0-9]$/;
@@ -378,6 +378,17 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a), readTime
378
378
  savePersonPrefs(sessionCsrf, favorites, onlyIfUnset = false) {
379
379
  return sessionCsrf && sessionCsrf === csrf ? call("PUT", "/hub/v1/me/prefs", { favorites, onlyIfUnset }) : Promise.resolve(retired());
380
380
  },
381
+ agentSharingV1: true,
382
+ ownAgents(scope) { return scope && scope === csrf ? call("GET", "/hub/v1/me/agents") : Promise.resolve(retired()); },
383
+ refreshOwnAgents(scope, fleetId) { return scope && scope === csrf ? call("POST", "/hub/v1/me/agents/refresh", { fleetId }) : Promise.resolve(retired()); },
384
+ requestAgentSharing(scope, input) { return scope && scope === csrf ? call("POST", "/hub/v1/me/agent-sharing", input) : Promise.resolve(retired()); },
385
+ agentSharingRequest(scope, requestId) { return scope && scope === csrf ? call("GET", `/hub/v1/me/agent-sharing/${id(requestId)}`) : Promise.resolve(retired()); },
386
+ previousAgentAccess(scope, exposureId) { return scope && scope === csrf ? call("GET", `/hub/v1/me/agents/${id(exposureId)}/previous-access`) : Promise.resolve(retired()); },
387
+ usePreviousAgentAccess(scope, exposureId, input) { return scope && scope === csrf ? call("POST", `/hub/v1/me/agents/${id(exposureId)}/previous-access`, input) : Promise.resolve(retired()); },
388
+ ownerGrant(scope, input) { return scope && scope === csrf ? call("POST", "/hub/v1/grants", input) : Promise.resolve(retired()); },
389
+ ownerSharing(scope, exposureId, revision, sharingEpoch, paused) { return scope && scope === csrf ? call("POST", `/hub/v1/exposures/${id(exposureId)}/sharing`, { revision, sharingEpoch, paused }) : Promise.resolve(retired()); },
390
+ agentIntrosV1: true,
391
+ saveAgentIntro: (exposureId, revision, text) => call("PUT", `/hub/v1/exposures/${id(exposureId)}/intro`, {revision,text}),
381
392
  catalog() { return call("GET", "/hub/v1/exposures"); },
382
393
  sharingPauseV1: true,
383
394
  sharing(exposureId, revision, sharingEpoch, paused) { return call("POST", `/hub/v1/exposures/${id(exposureId)}/sharing`, { revision, sharingEpoch, paused }); },
@@ -11,7 +11,7 @@ register("hubGrantPicker", {
11
11
  failed: "The directory could not be searched just now. Try again.", unsupported: "This directory does not support that search.", limited: "Too many searches. Try again shortly.", retry: "Search again",
12
12
  days: "Access lasts", day: "{0} days", expiry: "Choose up to 90 days. Access expires automatically; removing the grant also ends access to its chats.",
13
13
  groupHint: "Direct members are checked again for every action. Nested and primary groups are not included. Whoever manages this AD group can change who may ask. Each person has a private chat.",
14
- save: "Allow", cancel: "Cancel", refused: "The selected person or group changed or is no longer available. Search and choose again.", saveFailed: "Access could not be saved. Check the current agent and try again.",
14
+ saved: "Saved", save: "Allow", cancel: "Cancel", refused: "The selected person or group changed or is no longer available. Search and choose again.", saveFailed: "Access could not be saved. Check the current agent and try again.",
15
15
  },
16
16
  "zh-TW": {
17
17
  title: "允許向 {0} 提問", kind: "允許對象", person: "個人", group: "AD 安全性群組", team: "團隊", teamPick: "選擇團隊", teamHint: "依團隊目前的成員允許提問;成員離開團隊後就不再適用這份權限,授權的到期時間照常計算。", findPerson: "尋找同仁", query: "姓名或登入帳號", hint: "請輸入 2 到 64 個字。",
@@ -19,7 +19,7 @@ register("hubGrantPicker", {
19
19
  failed: "目前無法搜尋目錄,請再試一次。", unsupported: "這個目錄不支援這項搜尋。", limited: "搜尋太多次了,請稍後再試。", retry: "重新搜尋",
20
20
  days: "允許多久", day: "{0} 天", expiry: "最長 90 天,到期自動失效;移除授權也會結束其聊天存取權。",
21
21
  groupHint: "每次操作都會重新檢查直接成員,不含巢狀或主要群組。能管理這個 AD 群組的人,也能改變誰可以提問。每個人都有自己的私人對話。",
22
- save: "允許提問", cancel: "取消", refused: "選取的同仁或群組已變更或無法使用,請重新搜尋選擇。", saveFailed: "無法儲存授權,請確認目前的 Agent 後再試。",
22
+ saved: "已儲存", save: "允許提問", cancel: "取消", refused: "選取的同仁或群組已變更或無法使用,請重新搜尋選擇。", saveFailed: "無法儲存授權,請確認目前的 Agent 後再試。",
23
23
  },
24
24
  });
25
25
  const g = (key, ...args) => t(`hubGrantPicker.${key}`, ...args);
@@ -32,8 +32,10 @@ export function linkHubGrantPickerCss(doc = typeof document !== "undefined" ? do
32
32
  doc.head.appendChild(link);
33
33
  } catch { /* The form's existing controls still work if the stylesheet cannot be linked. */ }
34
34
  }
35
- export function HubGrantPicker({ x, client, act, onClose }) {
35
+ export function HubGrantPicker({ x, client, act, onClose, targets, grant, onResults, extra, legacy = false }) {
36
+ const [login, setLogin] = useState("");
36
37
  const [kind, setKind] = useState("person"), [selected, setSelected] = useState(null), [days, setDays] = useState(7), [busy, setBusy] = useState(false), [error, setError] = useState(null), [unsupported, setUnsupported] = useState(false);
38
+ const [targetResults, setTargetResults] = useState({});
37
39
  const life = useRef(0), writing = useRef(false), controllers = useRef(new Set());
38
40
  const search = useMemo(() => async (kind, q) => {
39
41
  const controller = new AbortController(); for (const old of controllers.current) old.abort(); controllers.current.add(controller);
@@ -49,22 +51,34 @@ export function HubGrantPicker({ x, client, act, onClose }) {
49
51
  }, [client, x.id, x.revision]);
50
52
  const change = () => { setSelected(null); setError(null); setUnsupported(false); };
51
53
  const submit = async event => {
52
- event?.preventDefault?.(); if (writing.current || !selected || client !== hubClient()) return;
54
+ event?.preventDefault?.(); if (writing.current || (legacy ? !login.trim() : !selected) || client !== hubClient()) return;
53
55
  writing.current = true; setBusy(true); setError(null); const mine = life.current;
54
- const subject = kind === "team" ? { kind: "team", teamId: selected.id } : kind === "group" ? { kind: "group", group: { realm: selected.realm, objectId: selected.objectId }, dn: selected.dn }
56
+ const subject = legacy ? null : kind === "team" ? { kind: "team", teamId: selected.id } : kind === "group" ? { kind: "group", group: { realm: selected.realm, objectId: selected.objectId }, dn: selected.dn }
55
57
  : { kind: "person", person: { ...selected.person } };
56
- const input = { exposureId: x.id, exposureRevision: x.revision, days, subject, ...(kind === "person" ? { login: selected.login } : {}) };
58
+ const input = { exposureId: x.id, exposureRevision: x.revision, days, ...(legacy ? { login: login.trim() } : { subject, ...(kind === "person" ? { login: selected.login } : {}) }) };
57
59
  try {
58
- const out = await act(() => client.grant(input), undefined, () => { if (mine === life.current) setError(g("refused")); });
59
- if (mine === life.current && client === hubClient()) { if (out?.ok) onClose(); else setError(g("refused")); }
60
+ if (targets && grant) {
61
+ const results = {}; let failed = false;
62
+ for (const target of targets) {
63
+ if (mine !== life.current || client !== hubClient()) return;
64
+ const out = await grant({ ...input, exposureId: target.id, exposureRevision: target.revision });
65
+ results[target.id] = out?.ok ? g("saved") : g("saveFailed"); failed ||= !out?.ok;
66
+ }
67
+ if (mine === life.current && client === hubClient()) { setTargetResults(results); onResults?.(results); if (!failed) onClose(); else setError(g("saveFailed")); }
68
+ } else {
69
+ const out = await act(() => client.grant(input), undefined, () => { if (mine === life.current) setError(g("refused")); });
70
+ if (mine === life.current && client === hubClient()) { if (out?.ok) onClose(); else setError(g("refused")); }
71
+ }
60
72
  } catch { if (mine === life.current) setError(g("saveFailed")); }
61
73
  finally { if (mine === life.current) { writing.current = false; setBusy(false); } }
62
74
  };
63
- return html`<${Dialog} title=${g("title", x.displayName)} onClose=${onClose} actions=${html`<button type="button" class="btn" onClick=${onClose}>${g("cancel")}</button><button type="button" class="btn btn-primary" disabled=${busy || !selected} onClick=${submit}>${g("save")}</button>`}>
75
+ return html`<${Dialog} title=${g("title", x.displayName)} onClose=${onClose} actions=${html`<button type="button" class="btn" onClick=${onClose}>${g("cancel")}</button><button type="button" class="btn btn-primary" disabled=${busy || (legacy ? !login.trim() : !selected)} onClick=${submit}>${g("save")}</button>`}>
64
76
  <form class="form hub-grant" data-grant-picker onSubmit=${submit}>
77
+ ${extra || null}
78
+ ${targets?.length > 1 ? html`<ul>${targets.map(target => html`<li>${target.displayName}${targetResults[target.id] ? ` · ${targetResults[target.id]}` : ""}</li>`)}</ul>` : null}
65
79
  ${error ? html`<p class="err" role="alert">${error}</p>` : null}
66
- <${SubjectPicker} client=${client} search=${search} kind=${kind} onKind=${next => { change(); setKind(next); }} selected=${selected} onClear=${change}
67
- disabled=${busy} id="hubGrant" label=${g("kind")} onUnsupported=${() => setUnsupported(true)} onPick=${(type, row) => setSelected(type === "group" ? { ...row, realm: x.owner?.realm || "" } : row)} />
80
+ ${legacy ? html`<label class="field"><span>${g("query")}</span><input data-grant-login autocomplete="off" spellcheck=${false} disabled=${busy} value=${login} onInput=${e => setLogin(e.target.value)} /></label>` : html`<${SubjectPicker} client=${client} search=${search} kind=${kind} onKind=${next => { change(); setKind(next); }} selected=${selected} onClear=${change}
81
+ disabled=${busy} id="hubGrant" label=${g("kind")} onUnsupported=${() => setUnsupported(true)} onPick=${(type, row) => setSelected(type === "group" ? { ...row, realm: x.owner?.realm || "" } : row)} />`}
68
82
  ${unsupported ? html`<p class="err" role="status">${g("unsupported")}</p>` : null}
69
83
  ${kind === "group" ? html`<p class="note">${g("groupHint")}</p>` : null}
70
84
  ${kind === "team" ? html`<p class="note">${g("teamHint")}</p>` : null}
@@ -51,9 +51,9 @@ register("hubGroups", {
51
51
  unknown: "The directory didn't answer, so this can't be checked right now.", retry: "Retry", ineligible: "Your directory account can't use this right now.",
52
52
  deniedPerson: "Your Hub administrator has excluded your account from this.", suspended: "Paused by your Hub administrator.",
53
53
  publishNot: "Sharing agents is not included in your access.",
54
- // M-3190: the chat launcher's frame and 我分享的 Agent → My fleets
54
+ // M-3190: the chat launcher's frame and 我的 Agent → My fleets
55
55
  readyBanner: "Your Hub is ready: create a pairing code to invite colleagues, or set up the room assistant →", readyGo: "Open Administration", readyDismiss: "Dismiss",
56
- footFleets: "{0} fleets connected ({1})", listSep: ", ", footManage: "Manage in My shared agents →", footNone: "Want to share agents from your own AgEnD?", footConnect: "Connect a fleet in My shared agents →",
56
+ footFleets: "{0} fleets connected ({1})", listSep: ", ", footManage: "Manage in My agents →", footNone: "Want to share agents from your own AgEnD?", footConnect: "Connect a fleet in My agents →",
57
57
  fleetsTitle: "My fleets", connectCount: "{0} of {1}", fleetMenu: "Fleet {0}", connectAnother: "+ Connect another fleet",
58
58
  copy: "Copy", copied: "Copied", copyFailed: "Copy failed. Select the address and copy it.",
59
59
  },
@@ -101,7 +101,7 @@ register("hubGroups", {
101
101
  deniedPerson: "Hub 管理員已將你的帳號排除在外。", suspended: "已被 Hub 管理員暫停。",
102
102
  publishNot: "你的存取權不包含分享 Agent。",
103
103
  readyBanner: "Hub 已就緒:產生配對碼邀請同事加入,或設定房間助理 →", readyGo: "前往「管理」", readyDismiss: "關閉",
104
- footFleets: "已連接 {0} 個 Fleet({1})", listSep: "、", footManage: "前往「我分享的 Agent」管理 →", footNone: "要用自己的 AgEnD 分享 Agent?", footConnect: "前往「我分享的 Agent」連接 Fleet →",
104
+ footFleets: "已連接 {0} 個 Fleet({1})", listSep: "、", footManage: "前往「我的 Agent」管理 →", footNone: "要用自己的 AgEnD 分享 Agent?", footConnect: "前往「我的 Agent」連接 Fleet →",
105
105
  fleetsTitle: "我的 Fleet", connectCount: "{0} / {1}", fleetMenu: "Fleet {0}", connectAnother: "+ 連接另一個 Fleet",
106
106
  copy: "複製", copied: "已複製", copyFailed: "複製失敗。請選取位址再複製。",
107
107
  },