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

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 (56) hide show
  1. package/dist/agent-cli-instructions.md +1 -0
  2. package/dist/agent-whats-new.js +6 -0
  3. package/dist/agent-whats-new.js.map +1 -1
  4. package/dist/build-provenance.json +1 -1
  5. package/dist/channel/mcp-tools.js +2 -1
  6. package/dist/channel/mcp-tools.js.map +1 -1
  7. package/dist/dashboard-permissions.d.ts +14 -0
  8. package/dist/dashboard-permissions.js +17 -1
  9. package/dist/dashboard-permissions.js.map +1 -1
  10. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +5 -2
  11. package/dist/hub/compose/server.d.ts +1 -0
  12. package/dist/hub/compose/server.js +3 -1
  13. package/dist/hub/compose/server.js.map +1 -1
  14. package/dist/hub/http/compose.js +8 -1
  15. package/dist/hub/http/compose.js.map +1 -1
  16. package/dist/hub/http/core.js +5 -2
  17. package/dist/hub/http/core.js.map +1 -1
  18. package/dist/hub/http/deps.d.ts +2 -0
  19. package/dist/hub/http/schema.js +2 -1
  20. package/dist/hub/http/schema.js.map +1 -1
  21. package/dist/hub/rooms/office.d.ts +32 -0
  22. package/dist/hub/rooms/office.js +25 -0
  23. package/dist/hub/rooms/office.js.map +1 -1
  24. package/dist/hub/rooms/service.d.ts +44 -0
  25. package/dist/hub/rooms/service.js +44 -9
  26. package/dist/hub/rooms/service.js.map +1 -1
  27. package/dist/hub/rooms/types.d.ts +4 -0
  28. package/dist/instructions.js +2 -2
  29. package/dist/instructions.js.map +1 -1
  30. package/dist/ui/chat-task-refs.js +6 -4
  31. package/dist/ui/fleet-office-card.js +17 -8
  32. package/dist/ui/fleet-office-play.js +9 -0
  33. package/dist/ui/fleet-office-skin.js +111 -8
  34. package/dist/ui/fleet-office-zones.js +44 -9
  35. package/dist/ui/fleet-office.js +218 -67
  36. package/dist/ui/hub-my-agents-strings.js +2 -2
  37. package/dist/ui/hub-my-agents.js +8 -3
  38. package/dist/ui/hub-room-members.js +51 -4
  39. package/dist/ui/hub-room-office.js +16 -5
  40. package/dist/ui/hub-room-presence.js +5 -2
  41. package/dist/ui/hub-room-settings.js +45 -1
  42. package/dist/ui/hub-room-source.js +4 -2
  43. package/dist/ui/hub-room-strings.js +17 -4
  44. package/dist/ui/hub-room-thread.js +26 -6
  45. package/dist/ui/hub-strings.js +4 -4
  46. package/dist/ui/panel-chat.js +1 -1
  47. package/dist/ui/panel-hub.js +42 -5
  48. package/dist/ui/shared/app.css +44 -1
  49. package/dist/ui/shared/chat-render.js +4 -4
  50. package/dist/ui/shared/chat-thread.js +2 -2
  51. package/dist/ui/shared/hub-my-agents.css +6 -0
  52. package/dist/ui/shared/hub-rooms-u2.css +17 -0
  53. package/dist/web-api.d.ts +1 -0
  54. package/dist/web-api.js +1 -1
  55. package/dist/web-api.js.map +1 -1
  56. package/package.json +1 -1
@@ -53,8 +53,10 @@ export const insertTaskRef = (text, at, caret, code) => insertAtTrigger(text, at
53
53
  /**
54
54
  * `fetchImpl(url)` → a Response (or null: no board for this page). Keeps, per card number, the view the server gave
55
55
  * ({ code, title, status, assignee, kind }) — or null for a number that is no card (asked once; asked again only after the
56
- * board changed, which `refresh()` is told of). The messages that name a number come in `ensure(msgs)`; only a person's own
57
- * words count (`role: "user"`): an agent's "M-3" is its prose, not a reference.
56
+ * board changed, which `refresh()` is told of). The messages that name a number come in `ensure(msgs)`: a person's own words
57
+ * (`role: "user"`) and an agent's reply (`role: "agent"`) — an agent writes `#M-3` to point at a card, as a person does. Any
58
+ * other message (a status line, the timeline) is not asked about. Whether a card may be shown is the server's answer
59
+ * (GET /ui/tasks/refs leaves a hidden instance's card out over the public link), the same for either writer.
58
60
  */
59
61
  export function createTaskRefIndex(fetchImpl) {
60
62
  const known = new Map(); // code → view | null
@@ -97,11 +99,11 @@ export function createTaskRefIndex(fetchImpl) {
97
99
  return {
98
100
  /** The card a number is, or null (not asked yet, not a card, or the board cannot be read here). */
99
101
  get: (code) => known.get(code) || null,
100
- /** Ask for the numbers in these messages (a person's own words) that have not been asked about yet. */
102
+ /** Ask for the numbers in these messages (a person's words or an agent's reply) that have not been asked about yet. */
101
103
  ensure(msgs) {
102
104
  const want = [];
103
105
  for (const x of msgs || []) {
104
- if (!x || x.role !== "user" || typeof x.text !== "string" || x.text.length < 3) continue;
106
+ if (!x || (x.role !== "user" && x.role !== "agent") || typeof x.text !== "string" || x.text.length < 3) continue;
105
107
  for (const c of taskRefCodes(x.text)) if (!asked.has(c) && !want.includes(c)) want.push(c);
106
108
  }
107
109
  if (want.length) ask(want);
@@ -28,7 +28,7 @@ import { nineSlice } from "./fleet-office-dialogue.js";
28
28
  register("ocard", {
29
29
  en: {
30
30
  card: "{0}'s card", level: "Lv {0}", work: "{0} work tokens", estimated: "estimated", toNext: "{0} to Lv {1}", office: "Office", model: "Model", backend: "Backend",
31
- today: "Today", todayN: "{0} work tokens · {1} requests", firstSeen: "First seen", day: "Day {0}", now: "Now", nowLabel: "Now:", find: "Find in office", chat: "Chat", pat: "Pat", feed: "Feed", tell: "Tell {0} (with their next message)", tellNote: "Off: only you see it. On: a line like “[Office] <your name> patted your head ×3” rides the next message they get anyway — it never wakes them.",
31
+ today: "Today", todayN: "{0} work tokens · {1} requests", firstSeen: "First seen", day: "Day {0}", now: "Now", nowLabel: "Now: ", find: "Find in office", chat: "Chat", pat: "Pat", feed: "Feed", tell: "Tell {0} (with their next message)", tellNote: "Off: only you see it. On: a line like “[Office] <your name> patted your head ×3” rides the next message they get anyway — it never wakes them.",
32
32
  chatWindow: "Open {0}’s chat in a new window",
33
33
  close: "Close", xp: "Progress to Lv {0}",
34
34
  },
@@ -53,9 +53,10 @@ export function dayOf(first, nowMs = Date.now()) {
53
53
  * What the card says (pure, for the component and the tests): `node` the org chart's node; `lv` levelsOk's answer (or
54
54
  * null); `levels` the style's pack `levels` (or null); `share` a share link's page; `state` the state's words; `now`
55
55
  * the tooltip's activity line; `where` the office (and area) in words. M-3533: `rows` ({ key, label, value }[]) the
56
- * card's rows instead of the office's own (a Hub room's office: the agent's owner and introduction).
56
+ * card's rows instead of the office's own (a Hub room's office: the agent's owner and introduction); `display` the card's
57
+ * name instead of the person's (a room's: the agent's own name, where the scene's label adds its owner).
57
58
  */
58
- export function cardModel({ node, lv, levels, share = false, state, now, where, rows: given = null }) {
59
+ export function cardModel({ node, lv, levels, share = false, state, now, where, rows: given = null, display = "" }) {
59
60
  const it = node.i || {};
60
61
  const names = node.i ? namesOf(node.i) : { primary: node.name, secondary: "" };
61
62
  const fx = fixedOf(node.name, levels);
@@ -76,7 +77,7 @@ export function cardModel({ node, lv, levels, share = false, state, now, where,
76
77
  if (detail && e.firstSeen) rowItems.push({ key: "firstSeen", label: tc("firstSeen"), value: tc("day", dayOf(e.firstSeen)) });
77
78
  const rows = rowItems.map((r) => [r.label, r.value]);
78
79
  return {
79
- name: names.primary, instance: given ? "" : node.name, state, title,
80
+ name: display || names.primary, instance: given ? "" : node.name, state, title,
80
81
  stateLine: title ? `${state} · ${title}` : state,
81
82
  badge: on && fx && fx.hideLevel ? { mark: true, tier: 0 } : e ? { text: badgeText(e.level), tier: tierOf(e.level) } : null,
82
83
  level: showLevel ? { line1: detail ? `${tc("level", e.level)} · ${tc("work", tokens(e.workTokens))}` : tc("level", e.level), estimated: detail && e.estimated,
@@ -330,6 +331,9 @@ function drawPortraitAvatar(cv, im, W) {
330
331
  * ({ label, title, run }) the card's own main action, from the page (a Hub room's office: "@ it", to ask it in the chat).
331
332
  */
332
333
  export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onClose, onReact = null, tell = null, packCard = null, picture = null, portrait = null, packScale = 2, action = null }) {
334
+ // `action`: one, or a list (M-3565: a Hub room's "@ it" and "Chat with it one-to-one"); the first is the primary button.
335
+ const actions = Array.isArray(action) ? action.filter(Boolean) : action ? [action] : [];
336
+ const actionButtons = actions.map((a, i) => html`<button key=${i} type="button" class=${`btn btn-sm ${i === 0 ? "btn-primary " : ""}oo-card-action`} title=${a.title || undefined} aria-label=${a.title || undefined} onClick=${a.run}>${a.label}</button>`);
333
337
  const box = useRef(null), canvas = useRef(null), bgCanvas = useRef(null), swipe = useRef(null);
334
338
  const [picRev, setPicRev] = useState(0);
335
339
  const spec = useMemo(() => resolveCardSpec(packCard), [packCard]);
@@ -387,6 +391,11 @@ export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onC
387
391
  }, [spec, picture, packScale, picRev, sheet]);
388
392
 
389
393
  useEffect(() => { place && place(box.current); });
394
+ // Closed (unmounted): the page hears it, as it heard the card open — a scene drawn around the card (the tags it covered,
395
+ // #4379 review) is drawn again without it, reduced motion included.
396
+ const placeNow = useRef(place);
397
+ placeNow.current = place;
398
+ useEffect(() => () => { if (placeNow.current) placeNow.current(null); }, []);
390
399
  // A bottom sheet closes on a swipe down (60 px or more).
391
400
  const down = (e) => { if (sheet) swipe.current = e.clientY; };
392
401
  const up = (e) => { if (sheet && swipe.current !== null && e.clientY - swipe.current > 60) onClose(); swipe.current = null; };
@@ -413,7 +422,7 @@ export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onC
413
422
  ${m.level.pct !== null ? html`<progress class="oo-card-bar" max="100" value=${Math.round(m.level.pct * 100)} aria-label=${tc("xp", m.level.next)}></progress>` : null}
414
423
  </div>` : null}
415
424
  <dl class="oo-card-rows">${(m.rowItems || m.rows.map(([label, value]) => ({ key: "", label, value }))).map((r) => html`<div data-row=${r.key || undefined}><dt>${r.label}</dt><dd>${r.value}</dd></div>`)}</dl>
416
- ${m.now ? html`<div class="oo-card-now"><span class="muted">${tc("nowLabel")}</span> ${m.now}</div>` : null}
425
+ ${m.now ? html`<div class="oo-card-now"><span class="muted">${tc("nowLabel")}</span>${m.now}</div>` : null}
417
426
  ${tell ? html`<label class="check oo-card-tell" title=${tc("tellNote")}><input type="checkbox" checked=${tell.on} onChange=${(e) => tell.set(e.target.checked)} />
418
427
  <span>${tc("tell", m.name)}</span></label>` : null}
419
428
  <div class="oo-card-actions">
@@ -421,7 +430,7 @@ export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onC
421
430
  <button type="button" class="btn btn-sm btn-ghost oo-card-feed" onClick=${() => onReact("feed")}>${tc("feed")}</button>` : null}
422
431
  ${onFind ? html`<button type="button" class="btn btn-sm btn-ghost oo-card-find" onClick=${onFind}>${tc("find")}</button>` : null}
423
432
  ${onChat ? html`<button type="button" class="btn btn-sm btn-primary oo-card-chat" title=${tc("chatWindow", m.name)} aria-label=${tc("chatWindow", m.name)} onClick=${onChat}>${tc("chat")}</button>` : null}
424
- ${action ? html`<button type="button" class="btn btn-sm btn-primary oo-card-action" title=${action.title || undefined} aria-label=${action.title || undefined} onClick=${action.run}>${action.label}</button>` : null}
433
+ ${actionButtons}
425
434
  </div>
426
435
  </div>`;
427
436
  }
@@ -466,7 +475,7 @@ export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onC
466
475
  }
467
476
  if (sec === "now") {
468
477
  if (!m.now || hide.has("now")) return null;
469
- return html`<div key="now" class="oo-card-now"><span class="muted">${tc("nowLabel")}</span> ${m.now}</div>`;
478
+ return html`<div key="now" class="oo-card-now"><span class="muted">${tc("nowLabel")}</span>${m.now}</div>`;
470
479
  }
471
480
  if (sec === "tell") {
472
481
  if (!tell) return null;
@@ -479,7 +488,7 @@ export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onC
479
488
  <button type="button" class="btn btn-sm btn-ghost oo-card-feed" onClick=${() => onReact("feed")}>${tc("feed")}</button>` : null}
480
489
  ${onFind ? html`<button type="button" class="btn btn-sm btn-ghost oo-card-find" onClick=${onFind}>${tc("find")}</button>` : null}
481
490
  ${onChat ? html`<button type="button" class="btn btn-sm btn-primary oo-card-chat" title=${tc("chatWindow", m.name)} aria-label=${tc("chatWindow", m.name)} onClick=${onChat}>${tc("chat")}</button>` : null}
482
- ${action ? html`<button type="button" class="btn btn-sm btn-primary oo-card-action" title=${action.title || undefined} aria-label=${action.title || undefined} onClick=${action.run}>${action.label}</button>` : null}
491
+ ${actionButtons}
483
492
  </div>`;
484
493
  }
485
494
  return null;
@@ -38,6 +38,15 @@ export function playAllowed({ on, still, zones, overview, layout, shared }) {
38
38
  return !!on && !still && !!zones && !overview && !layout && !shared;
39
39
  }
40
40
 
41
+ /**
42
+ * M-3547: whether reduced motion is the only thing keeping play off here — the viewer's toggle on and a single zones
43
+ * office of their own dashboard, but the device asks for reduced motion. The Office then says so where a person looks
44
+ * for it (their card, and beside the greyed tick box); anywhere play is off for another reason, nothing is said.
45
+ */
46
+ export function playOffForMotion({ on, still, zones, overview, layout, shared }) {
47
+ return !!still && playAllowed({ on, still: false, zones, overview, layout, shared });
48
+ }
49
+
41
50
  /**
42
51
  * The pick-up of one pointer: `down(id, type, x, y, t, name)` on a person (`name`; none: nothing to pick up) — a mouse
43
52
  * is "maybe" until it moves SLOP, a touch "press" until LONG_MS (`tick(t)`) or a move past SLOP first ("pan": the view's
@@ -30,6 +30,8 @@
30
30
  // the people, furniture and items in the air, below the crowd counts, name tags and bubbles
31
31
  // @property {(ctx, x, y, look, env, compact?) => void} [drawTag] zones: a name tag under feet at (x, y) (compact: #2860)
32
32
  // @property {(ctx, area, n, env) => void} [drawCrowd] zones: an area's "+n" (who found no spot in it)
33
+ // @property {(ctx, area, env) => {x,y,w,h}} [areaTitleBox] zones (M-3539): where an area's name is written; name tags keep clear of it
34
+ // @property {(ctx, area, env) => void} [drawAreaTitle] zones (M-3539): the name written again over the people standing on it
33
35
  // @property {(ctx, desk, look, ms, env) => void} drawCharacter the occupant in its pose at time `ms` (0: still); in
34
36
  // zones `desk` is the character's box at its current position (its feet at desk.seat); walking, `look.heading` is
35
37
  // the current step's { dx, dy }
@@ -83,14 +85,47 @@ const px = (ctx, x, y, w, h, c) => { ctx.fillStyle = c; ctx.fillRect(Math.round(
83
85
  const art = (ctx, d, c, r, w, h, color, dy = 0) => px(ctx, d.x + CX - 5 * P + c * P, d.y + TOP + dy + r * P, w * P, h * P, color);
84
86
 
85
87
  /** Text shortened to `max` px with an ellipsis (canvas measures; a grapheme cluster is not split). */
86
- export function fitText(ctx, s, max) {
88
+ export function fitText(ctx, s, max, fit = null) {
87
89
  const str = String(s);
88
90
  if (!ctx.measureText || ctx.measureText(str).width <= max) return str;
91
+ const kept = fit && ownedTail(str, fit.owner) ? fitOwned(ctx, str, fit.owner, max) : null;
92
+ if (kept) return kept;
93
+ // A shorter word for the same one, when the whole label does not fit (the room assistant's "Assistant").
94
+ if (fit && typeof fit.short === "string" && fit.short && ctx.measureText(fit.short).width <= max) return fit.short;
89
95
  const chars = Array.from(str);
90
96
  while (chars.length && ctx.measureText(`${chars.join("")}…`).width > max) chars.pop();
91
97
  return `${chars.join("")}…`;
92
98
  }
93
99
 
100
+ /**
101
+ * A Hub room's agent told apart by its owner (hub-room-office.js named: `fit.owner` = [open, owner, close], the label's end).
102
+ * Too long for its tag, the owner part stays and the name is cut — the owner is what tells two agents of one name apart
103
+ * (#4379 review). Still too long: the owner's first word, then its first character. Never wider than `max`.
104
+ */
105
+ const ownedTail = (str, tail) => Array.isArray(tail) && tail.length === 3 && tail.every((t) => typeof t === "string") && !!tail[1].trim()
106
+ && str.length > tail.join("").length && str.endsWith(tail.join(""));
107
+ function fitOwned(ctx, str, [open, owner, close], max) {
108
+ const base = str.slice(0, str.length - `${open}${owner}${close}`.length);
109
+ const w = (t) => ctx.measureText(t).width, name = Array.from(base);
110
+ const parts = [owner.trim(), owner.trim().split(/\s+/)[0], Array.from(owner.trim())[0]].filter((v, i, a) => v && a.indexOf(v) === i);
111
+ const cut = (tail, least) => {
112
+ const c = [...name];
113
+ while (c.length > least && w(`${c.join("")}…${tail}`) > max) c.pop();
114
+ return c.length >= least && w(`${c.join("")}…${tail}`) <= max ? `${c.join("")}…${tail}` : null;
115
+ };
116
+ const [full, first = full, initial = first] = parts, tail = (p) => `${open}${p}${close}`;
117
+ // The owner is what tells them apart: the whole owner with the name cut comes before the owner's first word (two
118
+ // owners may share it: "Alex A", "Alex B"), the first word before its initial, which comes only when nothing else fits.
119
+ const tries = [() => (w(`${base}${tail(full)}`) <= max ? `${base}${tail(full)}` : null), () => cut(tail(full), 2),
120
+ () => (w(`${base}${tail(first)}`) <= max ? `${base}${tail(first)}` : null), () => cut(tail(first), 2), () => cut(tail(first), 1),
121
+ () => { const o = Array.from(first); // the whole name, the owner's word cut
122
+ for (let n = o.length - 1; n >= 3; n--) { const t = `${base}${tail(`${o.slice(0, n).join("")}…`)}`; if (w(t) <= max) return t; }
123
+ return null; },
124
+ () => (w(`${base}${tail(initial)}`) <= max ? `${base}${tail(initial)}` : null), () => cut(tail(initial), 2), () => cut(tail(initial), 1)];
125
+ for (const t of tries) { const r = t(); if (r) return r; }
126
+ return null;
127
+ }
128
+
94
129
  // ── The built-in pixel skin ──
95
130
 
96
131
  function drawFloor(ctx, L, env) {
@@ -341,11 +376,11 @@ const TAG_FONT = "600 10px system-ui, sans-serif";
341
376
  const COMPACT = { font: "500 9px system-ui, sans-serif", textW: 48, pad: 6, top: 2, h: 11 };
342
377
  const NORMAL = { font: TAG_FONT, textW: TAG_TEXT_W, pad: 10, top: 3, h: 14 };
343
378
  /** The box a name tag under feet at (x, y) takes (what drawTag draws; bubbles keep clear of it, #2513). */
344
- export function tagBox(ctx, x, y, label, compact = false) {
379
+ export function tagBox(ctx, x, y, label, compact = false, fit = null) {
345
380
  const k = compact ? COMPACT : NORMAL;
346
381
  ctx.save();
347
382
  ctx.font = k.font;
348
- const t = fitText(ctx, label, k.textW), w = Math.ceil((ctx.measureText ? ctx.measureText(t).width : t.length * 6) + k.pad);
383
+ const t = fitText(ctx, label, k.textW, fit), w = Math.ceil((ctx.measureText ? ctx.measureText(t).width : t.length * 6) + k.pad);
349
384
  ctx.restore();
350
385
  return { x: Math.round(x - w / 2), y: y + k.top, w, h: k.h, text: t };
351
386
  }
@@ -400,7 +435,7 @@ const BADGE_FONT = "700 8px system-ui, sans-serif";
400
435
  /** Zones: a name tag under someone's feet at (x, y); `compact` (#2860): the smaller one a crowded area keeps on. */
401
436
  function drawTag(ctx, x, y, look, env, compact = false) {
402
437
  const { pal } = env;
403
- const b = tagBox(ctx, x, y, look.label, compact);
438
+ const b = tagBox(ctx, x, y, look.label, compact, look.fit);
404
439
  ctx.save();
405
440
  if (look.dim) ctx.globalAlpha = 0.35;
406
441
  ctx.font = compact ? COMPACT.font : TAG_FONT;
@@ -497,11 +532,44 @@ function drawBackground(ctx, L, env) {
497
532
  for (let y = r.y; y < r.y + r.h; y += T) for (let x = r.x + (((y - r.y) / T) % 2) * T; x < r.x + r.w; x += 2 * T) px(ctx, x, y, Math.min(T, r.x + r.w - x), Math.min(T, r.y + r.h - y), c2);
498
533
  ctx.save();
499
534
  ctx.strokeStyle = pal.border; ctx.lineWidth = 2; ctx.strokeRect(r.x + 1, r.y + 1, r.w - 2, r.h - 2);
500
- ctx.fillStyle = pal.text; ctx.font = "600 16px system-ui, sans-serif"; ctx.textBaseline = "top"; ctx.textAlign = "left";
501
- ctx.fillText(fitText(ctx, env.labels.areas[a.name] || a.name, r.w - 60), r.x + 12, r.y + 10);
502
535
  ctx.restore();
536
+ writeAreaTitle(ctx, a, env);
503
537
  }
504
538
  }
539
+ /** The studio's area name font: written at the top left of its area, under the people (drawBackground). */
540
+ const AREA_TITLE_FONT = "600 16px system-ui, sans-serif";
541
+ /**
542
+ * M-3539: the box an area's name takes, in logical units: { x, y, w, h, text } — what drawBackground writes, the space
543
+ * the name tags keep clear of, and where drawAreaTitle writes it again over the people when one stands on it.
544
+ */
545
+ export function areaTitleBox(ctx, area, env) {
546
+ const r = area.rect;
547
+ ctx.save();
548
+ ctx.font = AREA_TITLE_FONT;
549
+ const text = fitText(ctx, env.labels.areas[area.name] || area.name, r.w - 60);
550
+ const w = Math.ceil(ctx.measureText ? ctx.measureText(text).width : text.length * 9);
551
+ ctx.restore();
552
+ return { x: r.x + 12, y: r.y + 10, w, h: 18, text };
553
+ }
554
+ function writeAreaTitle(ctx, area, env) {
555
+ const b = areaTitleBox(ctx, area, env);
556
+ ctx.save();
557
+ ctx.fillStyle = env.pal.text; ctx.font = AREA_TITLE_FONT; ctx.textBaseline = "top"; ctx.textAlign = "left";
558
+ ctx.fillText(b.text, b.x, b.y);
559
+ ctx.restore();
560
+ }
561
+ /**
562
+ * M-3539: an area's name written again over the people, on a plate of the page's surface (a person standing at the top
563
+ * of a crowded area covered 休息區): called by the scene only for a name a figure stands on.
564
+ */
565
+ function drawAreaTitle(ctx, area, env) {
566
+ const b = areaTitleBox(ctx, area, env);
567
+ ctx.save();
568
+ ctx.globalAlpha = 0.9;
569
+ ctx.fillStyle = env.pal.surface; ctx.fillRect(b.x - 4, b.y - 2, b.w + 8, b.h + 2);
570
+ ctx.restore();
571
+ writeAreaTitle(ctx, area, env);
572
+ }
505
573
  function drawFurniture(ctx, f, active, ms, env) {
506
574
  const x = f.x, y = f.y;
507
575
  switch (f.shape) {
@@ -549,7 +617,39 @@ function drawFurniture(ctx, f, active, ms, env) {
549
617
  /** @type {OfficeSkin} */
550
618
  /** #2540: the studio's matte is its hall floor (the scene's edge), so the panel around the scene reads as more of it. */
551
619
  const studioMatte = (env) => (ZONE_FLOOR[env.mode] || ZONE_FLOOR.dark).hall;
552
- export const studioSkin = { ...pixelSkin, id: "studio", pack: STUDIO_PACK, drawBackground, drawFurniture, matte: studioMatte };
620
+ export const studioSkin = { ...pixelSkin, id: "studio", pack: STUDIO_PACK, drawBackground, drawFurniture, areaTitleBox, drawAreaTitle, matte: studioMatte };
621
+
622
+ // ── M-3533 R1b: the studio for a large Hub room — the same canvas, desks and spacing; a big room runs out of seats to
623
+ // rest in, not desks (most agents are idle most of the time), so its lounge is as large as the work area beside it, a
624
+ // 6×5 grid a full name tag apart (TAG_TEXT_W + its padding: 94), and help and nap a strip below both. Drawn
625
+ // procedurally like the studio; the lounge keeps no furniture of its own, so nothing sits against its seats. ──
626
+ const STUDIO_LARGE_AREAS = {
627
+ desks: { name: "desks", rect: { x: 24, y: 64, w: 632, h: 448 }, seats: grid([104, 248, 392, 536], [190, 320, 450]) },
628
+ lounge: { name: "lounge", rect: { x: 696, y: 64, w: 560, h: 448 }, seats: grid([739, 833, 927, 1021, 1115, 1209], [146, 232, 318, 404, 490]) },
629
+ alert: { name: "alert", rect: { x: 24, y: 532, w: 632, h: 172 }, seats: grid([96, 216, 336, 456, 576], [606, 680]).slice(0, 9) },
630
+ nap: { name: "nap", rect: { x: 696, y: 532, w: 560, h: 172 }, seats: grid([800, 976, 1152], [606, 680]) },
631
+ };
632
+ const STUDIO_LARGE_FURNITURE = [
633
+ { id: "board", shape: "board", x: 340, y: 100, depth: 5 },
634
+ { id: "rack-work", shape: "rack", tone: "ok", x: 610, y: 160, depth: 6, activeWhen: ["working"] },
635
+ ...STUDIO_LARGE_AREAS.desks.seats.map((s, i) => ({ id: `desk-${i}`, shape: "desk", x: s.x, y: s.y, depth: 1100 })),
636
+ { id: "rack-alert", shape: "rack", tone: "danger", x: 630, y: 620, depth: 900, activeWhen: ["needs", "stuck", "crashed"] },
637
+ ...STUDIO_LARGE_AREAS.nap.seats.map((s, i) => ({ id: `bag-${i}`, shape: "beanbag", x: s.x, y: s.y + 4, depth: 990 })),
638
+ ].sort((a, b) => a.depth - b.depth);
639
+ export const STUDIO_LARGE_PACK = {
640
+ ...STUDIO_PACK, id: "studio-large", areas: STUDIO_LARGE_AREAS, furniture: STUDIO_LARGE_FURNITURE, ...studioGraph(STUDIO_LARGE_AREAS),
641
+ };
642
+ export const studioLargeSkin = { ...studioSkin, id: "studio-large", pack: STUDIO_LARGE_PACK };
643
+ /**
644
+ * A built-in style's seats, from its layout (never typed): `total` every seat, `rest` the seats of the area its idle
645
+ * people go to (its pack's stateZones.idle) — what a large room runs out of. null for a style that has no areas.
646
+ */
647
+ export function styleSeats(id) {
648
+ const pack = SKINS.get(id)?.pack;
649
+ if (!pack || !pack.areas) return null;
650
+ const areas = Object.values(pack.areas), idle = pack.stateZones?.idle;
651
+ return { total: areas.reduce((n, a) => n + a.seats.length, 0), rest: (pack.areas[idle]?.seats || []).length };
652
+ }
553
653
 
554
654
  // ── Skin packs ──
555
655
 
@@ -846,8 +946,11 @@ const PICTURES = new Map([COZY_PACK, GUILD_PACK, SCHOOL_PACK].map((pack) => [pac
846
946
  export const PICTURE_SKINS = [...PICTURES.keys()];
847
947
 
848
948
  /** The skins built into this page; an uploaded pack is loaded by loadPackSkin. */
849
- export const SKINS = new Map([["pixel", pixelSkin], ["studio", studioSkin], ...[...PICTURES].map(([id, p]) => [id, p.bare])]);
949
+ export const SKINS = new Map([["pixel", pixelSkin], ["studio", studioSkin], ["studio-large", studioLargeSkin], ...[...PICTURES].map(([id, p]) => [id, p.bare])]);
950
+ /** The styles the Fleet's own office offers (M-3533: "studio-large" is a Hub room's, drawable here, not offered there). */
850
951
  export const BUILT_IN_SKINS = ["pixel", "studio", ...PICTURE_SKINS];
952
+ /** M-3533 R1b: the styles a Hub room's office offers, largest first (the zones styles: no desks-per-team layout). */
953
+ export const ROOM_STYLES = ["studio-large", "studio", ...PICTURE_SKINS];
851
954
  /**
852
955
  * #2631/#2947: a picture-backed built-in's picture, loaded once; the skin drawn from it then takes the bare one's place
853
956
  * in SKINS (skinFor). The skin, or null while it cannot load (the bare one stays; tried again next time); null for an id
@@ -11,6 +11,14 @@ export function zoneOf(pack, state) {
11
11
  const z = pack.stateZones || {};
12
12
  return own(z, state) || own(z, "default") || Object.keys(pack.areas)[0];
13
13
  }
14
+ /**
15
+ * M-3539: the areas the idle never stroll or visit to — where a pack sends the people calling for you (needs, crashed,
16
+ * stuck; by zoneOf, its fallbacks included): someone standing there reads as "needs you". Never the area the idle live in.
17
+ */
18
+ export function callingAreas(pack) {
19
+ const idle = zoneOf(pack, "idle"); // as the layout sends them: own, else default, else the first area
20
+ return [...new Set(["needs", "crashed", "stuck"].map((st) => zoneOf(pack, st)).filter((a) => a && a !== idle && own(pack.areas, a)))];
21
+ }
14
22
 
15
23
  /**
16
24
  * How far apart overflow spots are, and how far they stay from the area's seats (logical units); TITLE: the band at
@@ -148,7 +156,7 @@ export function zonesLayout(pack, nodes, prev = new Map(), { night = false, seat
148
156
  });
149
157
  return { mode: "zones", rooms: [{ key: "\u0000zones", name: null, lobby: false, x: 0, y: 0, w: LOGICAL.w, h: LOGICAL.h, desks }], areas: pack.areas,
150
158
  waypoints: pack.waypoints || [], edges: pack.edges || [], straight: pack.straight === true, door: pack.door, mailDrop: pack.mailDrop || null,
151
- idleVisits: pack.idleVisits || [], width: LOGICAL.w, height: LOGICAL.h, seats, crowd, over }; // #3685: idleVisits for walkTargets
159
+ idleVisits: pack.idleVisits || [], idleAvoid: callingAreas(pack), width: LOGICAL.w, height: LOGICAL.h, seats, crowd, over }; // #3685: idleVisits for walkTargets; M-3539: idleAvoid
152
160
  }
153
161
 
154
162
  // ── Walking ──
@@ -191,6 +199,11 @@ export const isNight = (d = new Date()) => { const h = d.getHours(); return NIGH
191
199
  * one no seat of the office is on (taken or free), picked anew each time — then walk back. Pure: the page asks every TICK ms and walks the change.
192
200
  */
193
201
  export const WANDER = { PERIOD: 40000, AWAY: 8000, REACH: 220, TICK: 1000 };
202
+ /** M-3539: two people stand on each other when their feet are closer than a figure is wide (48) and tall (66), less a little. */
203
+ const STACK = { dx: 44, dy: 60 };
204
+ const stacks = (a, b) => Math.abs(a.x - b.x) < STACK.dx && Math.abs(a.y - b.y) < STACK.dy;
205
+ /** M-3539: the room a name tag takes under the feet (its top 3, its height 14, a margin). */
206
+ const STROLL_TAG = 18;
194
207
  /** Whether `p` is inside `rect` (edges included). */
195
208
  const inRect = (r, p) => p.x >= r.x && p.x <= r.x + r.w && p.y >= r.y && p.y <= r.y + r.h;
196
209
  /** Whether the segment p–q passes through the inside of `rect` (its edges not counted: areas may share one). */
@@ -240,6 +253,11 @@ export function routeStaysInArea(from, to, graph, home, returnTo = from) {
240
253
  const strictIn = (r, p) => p.x > r.x && p.x < r.x + r.w && p.y > r.y && p.y < r.y + r.h;
241
254
  return legs.every((pts) => pts.every((p, i) => !others.some((r) => strictIn(r, p) || (i > 0 && crosses(r, pts[i - 1], p)))));
242
255
  }
256
+ /** M-3539: `points` outside the graph's `idleAvoid` areas (callingAreas): no idle stroll ends in the help desk. */
257
+ function awayFromCalling(points, graph) {
258
+ const areas = graph.areas || {}, off = (graph.idleAvoid || []).map((a) => own(areas, a)?.rect).filter(Boolean);
259
+ return off.length ? points.filter((w) => !off.some((r) => inRect(r, w))) : points;
260
+ }
243
261
  /**
244
262
  * Where `name`, seated at `seat`, should be at `t` (ms) while idle: a spot near the seat, or the seat. `area` (M-3286:
245
263
  * the office keeps idle people in their own area): the id of the area they are seated in — only spots inside it, and
@@ -249,6 +267,7 @@ export function wanderTarget(name, seat, graph, t, seats = [], area = null) {
249
267
  let near = (graph.waypoints || []).filter((w) => Math.hypot(w.x - seat.x, w.y - seat.y) <= WANDER.REACH
250
268
  && !seats.some((s) => Math.hypot(w.x - s.x, w.y - s.y) < 4));
251
269
  if (area !== null && near.length) near = withinArea(near, seat, graph, area);
270
+ near = awayFromCalling(near, graph);
252
271
  if (!near.length) return seat;
253
272
  const h = nameHash(name), k = t + (h % WANDER.PERIOD), turn = Math.floor(k / WANDER.PERIOD);
254
273
  if (k - turn * WANDER.PERIOD >= WANDER.AWAY) return seat;
@@ -297,7 +316,8 @@ const spotsOf = (area) => (area.seats && area.seats.length ? area.seats : [{ x:
297
316
  * `from`; none: always null (strolls as before). Pure: which seat is free is walkTargets' to say.
298
317
  */
299
318
  export function visitAt(name, home, graph, t, from = null) {
300
- const areas = graph.areas || {}, opts = (graph.idleVisits || []).filter((v) => v.area !== from && own(areas, v.area));
319
+ const avoid = graph.idleAvoid || [];
320
+ const areas = graph.areas || {}, opts = (graph.idleVisits || []).filter((v) => v.area !== from && own(areas, v.area) && !avoid.includes(v.area));
301
321
  if (!opts.length) return null;
302
322
  const sum = opts.reduce((n, v) => n + v.weight, 0), P = WANDER.PERIOD, phase = nameHash(name) % P;
303
323
  const turn = Math.floor((t + phase) / P), first = Math.floor(turn / VISIT.EPOCH) * VISIT.EPOCH, edge = (first + VISIT.EPOCH) * P;
@@ -342,10 +362,23 @@ export function walkTargets(desks, graph, t, wander = true, furniture = [], nigh
342
362
  // M-3286: `ownArea` (the office's "Idle people stay in their own area"): a stroll stays in the area the person (or
343
363
  // NPC: the area its spot is in; none: as before) is in, and nobody goes on a visit.
344
364
  const areaAt = (p) => Object.keys(graph.areas || {}).find((k) => graph.areas[k].rect && inRect(graph.areas[k].rect, p)) ?? null;
345
- const stroll = (name, home, area = null) => {
365
+ // M-3539: a stroll ends inside an area (the hall between areas is narrower than a name tag), where its figure stands
366
+ // clear of everyone else's (a seat in use, a visitor's, another stroll's end) and its name tag stays inside the
367
+ // area; else the person stays seated this turn. An aisle
368
+ // point is under a row's seats, so in a full room a stroll stood on the person seated there and its tag spilled
369
+ // past the area's edge.
370
+ const ends = [];
371
+ const clear = (name, p) => {
372
+ if (desks.some((d) => d.node.name !== name && stacks(d.seat, p)) || ends.some((q) => stacks(q, p)) || [...away.values()].some((q) => stacks(q, p))) return false;
373
+ // Inside an area, with room for the tag under the feet: the hall between areas is narrower than a name tag.
374
+ const rects = Object.values(graph.areas || {}).filter((a) => a.rect), homeArea = rects.find((a) => inRect(a.rect, p));
375
+ if (!rects.length) return true; // a layout with no areas: anywhere, as before
376
+ return !!homeArea && p.y + STROLL_TAG <= homeArea.rect.y + homeArea.rect.h;
377
+ };
378
+ const stroll = (name, home, area = null, person = true) => {
346
379
  const p = wanderTarget(name, home, graph, t, seats, ownArea ? area ?? areaAt(home) : null), k = `${p.x},${p.y}`;
347
- if (p === home || used.has(k)) return home;
348
- used.add(k);
380
+ if (p === home || used.has(k) || (person && !clear(name, p))) return home;
381
+ used.add(k); ends.push(p);
349
382
  return p;
350
383
  };
351
384
  const idle = (d) => wander && d.node.state === "idle" && !d.night;
@@ -383,7 +416,7 @@ export function walkTargets(desks, graph, t, wander = true, furniture = [], nigh
383
416
  }
384
417
  if (memo) { memo.claims = claims; memo.idle = new Set(desks.filter(idle).map((d) => d.node.name)); }
385
418
  const out = new Map(desks.map((d) => [d.node.name, !idle(d) ? d.seat : away.get(d.node.name) || stroll(d.node.name, d.seat, d.area ?? null)]));
386
- if (wander) for (const f of furniture) if (f.walk && !(night && f.night)) out.set(npcKey(f), stroll(npcKey(f), { x: f.x, y: f.y }));
419
+ if (wander) for (const f of furniture) if (f.walk && !(night && f.night)) out.set(npcKey(f), stroll(npcKey(f), { x: f.x, y: f.y }, null, false)); // an NPC's stroll: as before (#2596)
387
420
  return out;
388
421
  }
389
422
 
@@ -488,9 +521,10 @@ export function createMail({ max = MAIL.MAX } = {}) {
488
521
  }
489
522
 
490
523
  /**
491
- * Where each character is. `sync(targets, now, graph, still)`: targets name → { x, y }; someone new is already there;
524
+ * Where each character is. `sync(targets, now, graph, still, fresh)`: targets name → { x, y }; someone new is already there;
492
525
  * someone whose target moved walks from where they are now along the graph (routeVia; each diagonal leg an L when the
493
- * graph is `straight`, #2634) — or is there at once when `still` (reduced motion); someone gone is forgotten. `at(name, now)` → { x, y, walking } and, while walking, `heading`: the
526
+ * graph is `straight`, #2634) — or is there at once when `still` (reduced motion); with `fresh` (M-3539: a new office or
527
+ * style) everyone is at their target at once, a walk under way stopped even when it was going there; someone gone is forgotten. `at(name, now)` → { x, y, walking } and, while walking, `heading`: the
494
528
  * current step's { dx, dy }, which picks a pack's walkDown / walkUp / walkSide strip; `moving(now)`.
495
529
  */
496
530
  export function createWalkers() {
@@ -503,10 +537,11 @@ export function createWalkers() {
503
537
  return { x: p.x, y: p.y, walking: true, heading: headingAt(w.pts, Math.max(0, t)) };
504
538
  };
505
539
  return {
506
- sync(targets, now, graph, still = false) {
540
+ sync(targets, now, graph, still = false, fresh = false) {
507
541
  for (const name of [...by.keys()]) if (!targets.has(name)) by.delete(name);
508
542
  for (const [name, to] of targets) {
509
543
  const w = by.get(name);
544
+ if (fresh) { by.set(name, { pts: null, to }); continue; }
510
545
  if (!w || still) { if (!w || w.to.x !== to.x || w.to.y !== to.y) by.set(name, { pts: null, to }); continue; }
511
546
  if (w.to.x === to.x && w.to.y === to.y) continue;
512
547
  const here = posAt(w, now), via = routeVia(graph, { x: here.x, y: here.y }, { x: to.x, y: to.y });