shadok-ai 0.19.27 → 0.19.28

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.
package/README.md CHANGED
@@ -345,13 +345,14 @@ Enter to skip; you can add it later from the web UI).
345
345
  conversation is a real agent that stays resident, and they all draw on **your**
346
346
  Claude subscription, so there is no cap and no queue by design. Go back to
347
347
  **Board group** and every such conversation is closed at once.
348
- - **Link to a message** — every message (yours and the agent's) has a 🔗 link
349
- button beside copy. It copies a URL like `…/#agent=<session>&msg=<id>`;
350
- whoever opens it — someone who already has access to this cockpit, after the
351
- usual sign-in — lands on that agent, scrolled to that message, highlighted.
352
- The link lives in the URL's `#` part, so it never reaches the server or a
353
- proxy log. A message older than the history shown (the last 100 turns), or an
354
- agent that was closed, says so instead of opening somewhere else.
348
+ - **Link to a message** — every message (yours and the agent's, and a **room**'s
349
+ too) has a 🔗 link button beside copy. It copies a URL like
350
+ `…/#agent=<session>&msg=<id>` for an agent, `…/#room=<room>&msg=<id>` for a
351
+ room; whoever opens it — someone who already has access to this cockpit, after
352
+ the usual sign-in — lands on that conversation, scrolled to that message,
353
+ highlighted. The link lives in the URL's `#` part, so it never reaches the
354
+ server or a proxy log. A message older than the history shown, or a
355
+ conversation that was closed, says so instead of opening somewhere else.
355
356
  - **Run the command an agent asks you to** — when an agent writes `! cmd` for
356
357
  you to run (typically because it cannot), a ▶ run button sits right on that
357
358
  command's code block, beside its copy button — so it runs where it was
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shadok-ai",
3
- "version": "0.19.27",
3
+ "version": "0.19.28",
4
4
  "main": "dist/session.js",
5
5
  "scripts": {
6
6
  "test": "node --import tsx --test --test-timeout=120000 test/*.ts context/*/test/*.test.mjs",
@@ -1,26 +1,41 @@
1
1
  /**
2
- * A link to ONE message of an agent's conversation, for someone who already has
3
- * access to this cockpit. Pure, so the browser and test/deep-link.test.ts share
4
- * it. Design: docs/superpowers/specs/2026-10-21-message-deep-link-design.md.
2
+ * A link to ONE message of a conversation — an agent's or a room's — for someone
3
+ * who already has access to this cockpit. Pure, so the browser and
4
+ * test/deep-link.test.ts share it. Design:
5
+ * docs/superpowers/specs/2026-10-21-message-deep-link-design.md.
5
6
  *
6
7
  * The state rides in the HASH, never the query: a fragment never reaches the
7
- * server, a proxy or its logs. The agent is named by its FULL session id — a
8
- * shortened one is not an id (invariant 36) — and the message by its transcript
9
- * uuid.
8
+ * server, a proxy or its logs. The conversation is named by its FULL id — an
9
+ * agent by its session uuid (a shortened one is not an id, invariant 36), a room
10
+ * by its `r_…` id — and the message by its uuid (a transcript uuid for an agent,
11
+ * the message's own uuid for a room).
10
12
  */
11
13
 
12
- // A session id and a transcript uuid are both UUIDs; anything else is refused
14
+ // A session id and a message uuid are both UUIDs; anything else is refused
13
15
  // rather than half-trusted, since the parsed values end up in a CSS selector.
14
16
  const ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
17
+ // A room id (ROOM_ID_RE in src/rooms.ts): `r_` + 16 hex, never UUID-shaped, so
18
+ // `agent=` and `room=` can never be confused for one another.
19
+ const ROOM = /^r_[0-9a-f]{16}$/i;
15
20
 
16
- /** `base` is origin + path (no hash); returns the shareable URL. */
21
+ /** `base` is origin + path (no hash); returns the shareable URL to an AGENT's
22
+ * message, or null. */
17
23
  export function buildMessageLink(base, sessionId, msgId) {
18
24
  if (!ID.test(String(sessionId ?? "")) || !ID.test(String(msgId ?? ""))) return null;
19
25
  const at = String(base ?? "").split("#")[0];
20
26
  return `${at}#agent=${sessionId.toLowerCase()}&msg=${msgId.toLowerCase()}`;
21
27
  }
22
28
 
23
- /** `location.hash` → `{ agent, msg }`, or null for anything else. Never throws. */
29
+ /** `base` is origin + path (no hash); returns the shareable URL to a ROOM's
30
+ * message, or null. */
31
+ export function buildRoomMessageLink(base, roomId, msgId) {
32
+ if (!ROOM.test(String(roomId ?? "")) || !ID.test(String(msgId ?? ""))) return null;
33
+ const at = String(base ?? "").split("#")[0];
34
+ return `${at}#room=${roomId.toLowerCase()}&msg=${msgId.toLowerCase()}`;
35
+ }
36
+
37
+ /** `location.hash` → `{ agent, msg }` or `{ room, msg }`, or null for anything
38
+ * else. Never throws. `agent=` wins if both are somehow present. */
24
39
  export function parseMessageLink(hash) {
25
40
  const raw = String(hash ?? "").replace(/^#/, "");
26
41
  if (!raw) return null;
@@ -31,9 +46,12 @@ export function parseMessageLink(hash) {
31
46
  return null;
32
47
  }
33
48
  const agent = params.get("agent") ?? "";
49
+ const room = params.get("room") ?? "";
34
50
  const msg = params.get("msg") ?? "";
35
- if (!ID.test(agent) || !ID.test(msg)) return null;
36
- return { agent: agent.toLowerCase(), msg: msg.toLowerCase() };
51
+ if (!ID.test(msg)) return null;
52
+ if (ID.test(agent)) return { agent: agent.toLowerCase(), msg: msg.toLowerCase() };
53
+ if (ROOM.test(room)) return { room: room.toLowerCase(), msg: msg.toLowerCase() };
54
+ return null;
37
55
  }
38
56
 
39
57
  /** Does a prompt the transcript recorded match the bubble the client echoed?
package/public/index.html CHANGED
@@ -4595,8 +4595,9 @@
4595
4595
  import { connectCardPlan, sameConnectTarget } from "/connect-card.js?v=__ASSET_V__";
4596
4596
  window.connectCardPlan = connectCardPlan;
4597
4597
  window.sameConnectTarget = sameConnectTarget;
4598
- import { buildMessageLink, parseMessageLink, samePrompt } from "/deep-link.js?v=__ASSET_V__";
4598
+ import { buildMessageLink, buildRoomMessageLink, parseMessageLink, samePrompt } from "/deep-link.js?v=__ASSET_V__";
4599
4599
  window.buildMessageLink = buildMessageLink;
4600
+ window.buildRoomMessageLink = buildRoomMessageLink;
4600
4601
  window.parseMessageLink = parseMessageLink;
4601
4602
  window.samePrompt = samePrompt;
4602
4603
  import { GROUP_ICONS, UNGROUPED, randomGroupIcon, resolveGroupView, groupMood, cleanGroupIcon, reconcileTabGroup, groupIsDirty, focusTarget, groupMoveRefusal } from "/group-nav.js?v=__ASSET_V__";
@@ -4805,6 +4806,7 @@
4805
4806
  // No module → no link button, and a link opened before it lands is read
4806
4807
  // again on `shadok-bridge-ready`.
4807
4808
  buildMessageLink: () => null,
4809
+ buildRoomMessageLink: () => null,
4808
4810
  parseMessageLink: () => null,
4809
4811
  samePrompt: () => false,
4810
4812
  // The rail must paint even before the module lands: a plain folder icon, the
@@ -8527,10 +8529,11 @@
8527
8529
  }
8528
8530
 
8529
8531
  /**
8530
- * Give a bubble its transcript ids and a "link" button. The link names the
8531
- * FIRST id; the lookup is by membership (`[data-msg-ids~=…]`), because live
8532
- * every text block is its own bubble while the replay merges them — so a link
8533
- * made on either side finds its message on the other.
8532
+ * Give a bubble its message ids and a "link" button. The link names the FIRST
8533
+ * id; the lookup is by membership (`[data-msg-ids~=…]`), because live every
8534
+ * text block is its own bubble while the replay merges them — so a link made on
8535
+ * either side finds its message on the other. Works for an agent (by session
8536
+ * id) and a room (by room id); a room message carries a single uuid.
8534
8537
  */
8535
8538
  function stampMsgIds(tab, turn, ids) {
8536
8539
  if (!turn || !Array.isArray(ids) || !ids.length || turn.dataset.msgIds) return;
@@ -8544,7 +8547,10 @@
8544
8547
  b.title = "Copy a link to this message (for someone with access to this cockpit)";
8545
8548
  b.addEventListener("click", async (e) => {
8546
8549
  e.stopPropagation();
8547
- const url = window.buildMessageLink(location.origin + location.pathname, tab.sessionId, ids[0]);
8550
+ const base = location.origin + location.pathname;
8551
+ const url = tab.roomId
8552
+ ? window.buildRoomMessageLink(base, tab.roomId, ids[0])
8553
+ : window.buildMessageLink(base, tab.sessionId, ids[0]);
8548
8554
  const ok = !!url && (await copyText(url));
8549
8555
  b.textContent = ok ? "✓ link copied" : "⚠ failed";
8550
8556
  b.classList.toggle("done", ok);
@@ -8602,10 +8608,12 @@
8602
8608
  const link = window.parseMessageLink(location.hash);
8603
8609
  if (!link) return;
8604
8610
  if (restoring) { deepLinkTimer = setTimeout(followDeepLink, 200); return; }
8605
- const tab = tabs.find((t) => t.sessionId === link.agent);
8611
+ const tab = link.room
8612
+ ? tabs.find((t) => t.roomId === link.room)
8613
+ : tabs.find((t) => t.sessionId === link.agent);
8606
8614
  if (!tab) {
8607
8615
  clearDeepLinkHash();
8608
- deepLinkNote("This link points to an agent that is not on this cockpit (closed, or another instance).");
8616
+ deepLinkNote("This link points to a conversation that is not on this cockpit (closed, or another instance).");
8609
8617
  return;
8610
8618
  }
8611
8619
  pendingDeepLink = { tab, msg: link.msg, until: Date.now() + 20000 };
@@ -8627,7 +8635,7 @@
8627
8635
  if (Date.now() > until) {
8628
8636
  pendingDeepLink = null;
8629
8637
  clearDeepLinkHash();
8630
- deepLinkNote("This message is older than the history shown for this agent.");
8638
+ deepLinkNote("This message is older than the history shown for this conversation.");
8631
8639
  return;
8632
8640
  }
8633
8641
  deepLinkTimer = setTimeout(followDeepLink, 300);
@@ -11491,7 +11499,9 @@
11491
11499
  const label = own ? "you" : echoAuthorLabel({ from: m.author, origin: m.origin });
11492
11500
  const b = addTurn(tab, "user", label, m.text, null, m.ts);
11493
11501
  markPromptSide(b, { from: m.account || m.author, origin: m.origin });
11494
- b.parentElement.dataset.roomMsg = m.id;
11502
+ // A room message's uuid is its own id (randomUUID, server-side): it doubles
11503
+ // as the deep-link anchor, like an agent bubble's transcript id.
11504
+ stampMsgIds(tab, b.parentElement, [m.id]);
11495
11505
  tab.lastRoomTs = Math.max(tab.lastRoomTs || 0, m.ts);
11496
11506
  return b;
11497
11507
  }