@marver-design/marver 0.25.1 → 0.26.0

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 (91) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/README.md +3 -1
  3. package/dist/{anchor-DVV732zR.mjs → anchor-5H1vnoLu.mjs} +6 -1
  4. package/dist/{anchor-check-DGZnYviN.mjs → anchor-check-Dg5xpNnU.mjs} +1 -1
  5. package/dist/audio-CmSRYFEs.mjs +429 -0
  6. package/dist/{auth-DdUKeVKt.mjs → auth-Dix8wrXV.mjs} +1 -1
  7. package/dist/{bake-BpxMZfij.mjs → bake-DtVlm0_F.mjs} +1 -1
  8. package/dist/{boards-Csxj2WJn.mjs → boards-DYG22tOe.mjs} +2 -2
  9. package/dist/{build-DKaGhoVN.mjs → build-C_gUgcdC.mjs} +16 -9
  10. package/dist/capture-CrqvU_jh.mjs +729 -0
  11. package/dist/cli.mjs +23 -17
  12. package/dist/{collab-gqNdScUE.mjs → collab-Dxg2trOK.mjs} +4 -3
  13. package/dist/{comments-Zoch254k.mjs → comments-0BSbb04K.mjs} +14 -3
  14. package/dist/{comments-pTLlhjh4.mjs → comments-BqXua-XL.mjs} +7 -7
  15. package/dist/{config-cKgZBRj0.mjs → config-Cf7EjAMf.mjs} +12 -1
  16. package/dist/{context-D2ugHqwO.mjs → context-HQ4Giw58.mjs} +1 -1
  17. package/dist/daemon-DZo6o3rU.mjs +2445 -0
  18. package/dist/{dev-Diqx1Rt8.mjs → dev-_Nlsc6v9.mjs} +189 -18
  19. package/dist/dev-lock-DWSpa6nj.mjs +179 -0
  20. package/dist/{events-DnK_AnrW.mjs → events-CLH4ijKP.mjs} +14 -4
  21. package/dist/{init-DO4DhUt_.mjs → init-D8DtrK_F.mjs} +2 -2
  22. package/dist/{ledger-BNXW14Xw.mjs → ledger-D54iROST.mjs} +17 -1
  23. package/dist/{link-C-qUIuKU.mjs → link-BNzLvdhI.mjs} +2 -2
  24. package/dist/live-Cgzsicwi.mjs +4 -0
  25. package/dist/{manifest-DnAte_fB.mjs → manifest-Nl3KSVOk.mjs} +1 -1
  26. package/dist/{marks-koRsbHfe.mjs → marks-CKgzucHZ.mjs} +2 -2
  27. package/dist/{marks-DFuintmJ.mjs → marks-NQi0wZJ4.mjs} +23 -5
  28. package/dist/{marver-id-gate-DGANtVyC.mjs → marver-id-gate-BjF6v4bT.mjs} +4 -4
  29. package/dist/{perf-QJIWtTw1.mjs → perf-D6VmmJ2q.mjs} +1 -1
  30. package/dist/{perf-CCisg-ny.mjs → perf-DPbLGhhO.mjs} +1 -1
  31. package/dist/{plugin-dTF5reck.mjs → plugin-CTD0rydA.mjs} +277 -37
  32. package/dist/{poster-D-zjYpgk.mjs → poster-ChjXGTS5.mjs} +1 -1
  33. package/dist/{profile-Do0nGkXO.mjs → profile-WU9qcbIo.mjs} +1 -1
  34. package/dist/{publish-bakes-C_9VZ-Mq.mjs → publish-bakes-CEP_2NRc.mjs} +3 -3
  35. package/dist/queue-BuiCKSX1.mjs +1319 -0
  36. package/dist/reserve-BURNQ2Y3.mjs +53 -0
  37. package/dist/{rolldown-runtime-D7D4PA-g.mjs → rolldown-runtime-8H4AJuhK.mjs} +1 -0
  38. package/dist/{serve-wv2QWdxB.mjs → serve-C8rVheYk.mjs} +12 -12
  39. package/dist/session-qZWKt_VA.mjs +191 -0
  40. package/dist/{share-ScamJcks.mjs → share--oFJ1bCI.mjs} +2 -2
  41. package/dist/{shot-jdO_B6Qw.mjs → shot-CNbHoZ6H.mjs} +1 -1
  42. package/dist/{shot-CUlmkqFX.mjs → shot-DqcxJibP.mjs} +4 -3
  43. package/dist/speech-models-DomiLQcY.mjs +299 -0
  44. package/dist/speech-worker.mjs +319 -0
  45. package/dist/{summary-CrW88e3q.mjs → summary-Y8MY1Wuc.mjs} +2 -2
  46. package/dist/{sync-C3035OnJ.mjs → sync-DKk-yT1V.mjs} +9 -8
  47. package/dist/{work-GE88wb_3.mjs → work-F5u-twpJ.mjs} +28 -5
  48. package/dist/{work-CpJn1gwY.mjs → work-VvX_JIgl.mjs} +2 -2
  49. package/docs/jam-session.md +177 -0
  50. package/docs/live-jam.md +21 -3
  51. package/package.json +7 -1
  52. package/src/client/frame-host/bridge.js +20 -2
  53. package/src/client/frame-host/inspect.d.ts +4 -0
  54. package/src/client/frame-host/inspect.js +88 -3
  55. package/src/client/frame-host/keys.d.ts +6 -0
  56. package/src/client/frame-host/keys.js +55 -0
  57. package/src/client/frame-host/trail.d.ts +7 -0
  58. package/src/client/frame-host/trail.js +204 -0
  59. package/src/client/shell/App.tsx +45 -5
  60. package/src/client/shell/Comments.tsx +20 -6
  61. package/src/client/shell/JamSurface.tsx +340 -0
  62. package/src/client/shell/Play.tsx +22 -3
  63. package/src/client/shell/Tip.tsx +8 -3
  64. package/src/client/shell/canvas/Canvas.tsx +12 -2
  65. package/src/client/shell/canvas/FrameNode.tsx +11 -2
  66. package/src/client/shell/comments-store.ts +23 -16
  67. package/src/client/shell/icons.tsx +15 -0
  68. package/src/client/shell/jam-capture.ts +939 -0
  69. package/src/client/shell/jam-keys.ts +329 -0
  70. package/src/client/shell/jam-lane.tsx +208 -0
  71. package/src/client/shell/jam-lines.ts +115 -0
  72. package/src/client/shell/jam-panel.tsx +506 -0
  73. package/src/client/shell/jam-queue.ts +126 -0
  74. package/src/client/shell/jam-session.tsx +389 -0
  75. package/src/client/shell/jam-state.ts +61 -0
  76. package/src/client/shell/jam-surface-parts.tsx +102 -0
  77. package/src/client/shell/jam-ui.tsx +104 -0
  78. package/src/client/shell/jam-voice.ts +479 -0
  79. package/src/client/shell/sound.ts +22 -0
  80. package/src/client/shell/stage-size.ts +11 -0
  81. package/src/client/shell/store.ts +34 -13
  82. package/src/client/shell/styles.css +544 -2
  83. package/src/client/stage/main.tsx +16 -2
  84. package/src/shared/capture-frames.ts +41 -0
  85. package/src/shared/events.ts +19 -4
  86. package/src/shared/speech.ts +16 -0
  87. package/templates/AGENTS-embedded.md +10 -2
  88. package/templates/AGENTS-studio.md +10 -2
  89. package/templates/instructions/iterate.md +8 -6
  90. package/templates/instructions/jam.md +129 -59
  91. package/dist/daemon-Cl8KXGW4.mjs +0 -1523
package/CHANGELOG.md CHANGED
@@ -2,6 +2,68 @@
2
2
 
3
3
  Notable changes to `@marver-design/marver`. Format follows [Keep a Changelog](https://keepachangelog.com); versions follow semver.
4
4
 
5
+ ## 0.26.0 - 2026-10-20
6
+
7
+ ### Added
8
+
9
+ - **Captures: talk through the canvas.** Press `S`, point at things, click through the
10
+ prototype and say what is wrong, then `E`. A capture records your words, every click, pick
11
+ and note, the screens and devices you went through, and pictures of the frames you touched -
12
+ at the size you were looking at them - and your agent works from that one record. Its
13
+ read-back lets you fix a word, add a note after the fact, and decide: `⏎` add to queue,
14
+ `K` keep, `R` resume (it ended too soon), `Esc` drop
15
+ ([Jam sessions and captures](docs/jam-session.md)).
16
+ - **A lane, and review with before and after.** Captures line up along the bottom of the canvas
17
+ in the order you made them - queued, working, ready to review. A soft chime says one is ready;
18
+ `V` opens it: the agent's reply beside each frame it changed, `B` flips before and after, a
19
+ frame it made is marked New, and a Capture tab shows what you recorded. `⏎` looks good, `⇧⏎`
20
+ sends it back with what is still wrong. When you asked for something new beside a frame, the
21
+ capture's thread moves onto the new frame.
22
+ - **Sessions.** `J` runs a whole review as one session: it starts recording at once, keeps the
23
+ canvas lit with a clock while you work, and listens between captures. `J` again wraps up - you
24
+ say how to take it in, and your agent writes the record to `context/sessions/`: what was
25
+ asked, what was done, what is left, the decisions heard.
26
+ - **Words, on this Mac.** What you say becomes words with NVIDIA's Parakeet v3, run locally:
27
+ Marver asks before the one 488 MB download, and the audio never leaves your machine or touches
28
+ the disk. Where the speech engine cannot install, captures keep typed notes.
29
+ - **Captures name themselves.** With Claude Code, each capture gets a few-word name as soon as its
30
+ words are in, from Claude Haiku through your own login - a draft's words go to Anthropic for
31
+ this. A name you give wins; `jam: { names: false }` turns it off.
32
+ - **Every element knows its source.** In `marver dev`, design elements carry `data-mv-loc` - the
33
+ file and line they were written at - so your agent goes straight to the code you pointed at
34
+ (`jam: { loc: false }` turns it off; never in a published build).
35
+
36
+ ### Changed
37
+
38
+ - **Only a tag starts work** ([#5](https://github.com/TNEP4/marver/issues/5)). A plain reply in a
39
+ thread - even one answering Marver - is conversation and starts nothing; `npx marver marks`
40
+ lists it under "answered by you" for your chat agent. Each tag is a card answered in its own
41
+ thread, with the thread as it stood when you sent it.
42
+ - **One job per frame.** Your agent still works on up to `jam.concurrency` jobs at once, but never
43
+ two on the same frame, and a job's results are posted before anything new starts. A job edits
44
+ only the frames it was given; one that needs a shared file (a kit, a layout) comes back to run
45
+ alone.
46
+ - **One canvas per folder** ([#19](https://github.com/TNEP4/marver/issues/19)). A second `marver dev`
47
+ in the same folder stops with "a canvas already runs here" and its link, instead of taking over
48
+ the first one's record.
49
+
50
+ ### Fixed
51
+
52
+ - **Marver's notes and replies stay on your machine when you publish.** The docs always said so, and
53
+ `marver comments sync` never pushed them, but `marver build` copied each board's whole comment log
54
+ into the published canvas. Now a build ships only people's threads: a note Marver pinned, its
55
+ replies in your threads, and every capture's thread stay local.
56
+ - **An agent in a sandbox still looks at its work.** Codex runs with the network blocked, so
57
+ `marver shot` could not reach the canvas and it replied that it could not check the render; the
58
+ instructions now send it to the request file, which works in every sandbox.
59
+
60
+ ### Upgrading
61
+
62
+ `npm install @marver-design/marver@latest`, then `npx marver init` to refresh the agent
63
+ instructions. On its first boot `marver dev` upgrades the jam journal and says what changed; a
64
+ job that was running under 0.25 shows as failed with Retry. Replies you made before the upgrade
65
+ are listed by `npx marver marks` as "earlier, maybe handled".
66
+
5
67
  ## 0.25.1 - 2026-10-17
6
68
 
7
69
  ### Fixed
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  Screens, prototypes, specs, and now slide decks - all real code, all on one canvas, all shareable with people who sign in as themselves.
10
10
 
11
- [marver.design](https://marver.design) · [Boards and folders](docs/boards-and-folders.md) · [Context](docs/context.md) · [Slides](docs/slides.md) · [Sticky notes](docs/sticky-notes.md) · [Live Jam](docs/live-jam.md) · [Deploying a canvas](docs/publish.md) · [Sharing](docs/sharing.md) · [Changelog](CHANGELOG.md) · [Contributing](CONTRIBUTING.md) · [Issues](https://github.com/TNEP4/marver/issues)
11
+ [marver.design](https://marver.design) · [Boards and folders](docs/boards-and-folders.md) · [Context](docs/context.md) · [Slides](docs/slides.md) · [Sticky notes](docs/sticky-notes.md) · [Live Jam](docs/live-jam.md) · [Jam sessions](docs/jam-session.md) · [Deploying a canvas](docs/publish.md) · [Sharing](docs/sharing.md) · [Changelog](CHANGELOG.md) · [Contributing](CONTRIBUTING.md) · [Issues](https://github.com/TNEP4/marver/issues)
12
12
 
13
13
  ## Quickstart
14
14
 
@@ -95,6 +95,8 @@ Tag `@marver` in a comment and your own coding agent picks it up - reads the thr
95
95
 
96
96
  The trust boundary is hard: only comments written on the owner's machine trigger (a device-bound ledger - a drive-by comment on a published canvas cannot start work), the agent runs locked down (each CLI with its shell removed or OS-sandboxed - the per-agent table is in the guide), and every reply carries provenance: which agent ran it, as which dev user, on which model when the agent names one. Marver ships no AI; the agent that acts is the one you already run. The [Live Jam guide](docs/live-jam.md) has the config block, every agent's jail, and what to check when a mention does nothing.
97
97
 
98
+ **Captures and sessions.** Or skip the typing: press `S`, point at things, click through the prototype and say what is wrong, then `E`. A capture records your words (transcribed on your machine - the audio never leaves it), every click, pick and note, and pictures of the frames you touched at the size you saw them, and your agent works from that. Captures line up in a lane along the bottom - queued, working, ready to review - and each comes back with before and after pictures: `⏎` looks good, `⇧⏎` more work. `J` runs a whole review as a session and ends with a written record of it in `context/sessions/`. The [Jam sessions guide](docs/jam-session.md) has the keys and the settings.
99
+
98
100
  ## Working state
99
101
 
100
102
  The same glow, driven from the terminal. When your agent takes a request, it creates the frame files first, pins them on a board, and runs `npx marver work start <scene/frame ...>` - you see the work land on the canvas in seconds, watch it shimmer while subagents build in parallel, and see it settle on `work done`. Marks self-expire, so a crashed agent never leaves a frame glowing. Its reply ends with the canvas link `work done` prints - the board, opened on the frames it changed - and where it needs your eyes it pins a note on the frame as Marver (`npx marver comments new`), so you are pinged on the thing itself. And `npx marver shot --scene <scene>` (or `<scene/frame ...>`, `--all`; `[--scale 4]`) renders frames headless to PNGs - a whole scene in one browser, several frames at a time - so the agent can look at what it built before it says it is done - the same picture you get from the canvas's copy-as-image.
@@ -1,4 +1,9 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
1
2
  //#region src/shared/anchor.ts
3
+ var anchor_exports = /* @__PURE__ */ __exportAll({
4
+ readTarget: () => readTarget,
5
+ uncheckedAnchor: () => uncheckedAnchor
6
+ });
2
7
  /** Read a target from untrusted input - CLI flags, a Live Jam block: exactly one of `on` / `at`, an
3
8
  * optional whole `nth` from 1. A string is the reason it is not one. */
4
9
  function readTarget(raw) {
@@ -30,4 +35,4 @@ function uncheckedAnchor(t) {
30
35
  } };
31
36
  }
32
37
  //#endregion
33
- export { readTarget, uncheckedAnchor };
38
+ export { readTarget as n, uncheckedAnchor as r, anchor_exports as t };
@@ -1,4 +1,4 @@
1
- import { MOUNTED, frameUrl, manifestFrame, planShot, withBrowser } from "./shot-CUlmkqFX.mjs";
1
+ import { MOUNTED, frameUrl, manifestFrame, planShot, withBrowser } from "./shot-DqcxJibP.mjs";
2
2
  //#region src/server/anchor-check.ts
3
3
  /**
4
4
  * The anchor check (spec 26, Part 6): `comments new --on|--at`, `comments move` and a Live Jam re-pin
@@ -0,0 +1,429 @@
1
+ import { modelPaths, modelsReady } from "./speech-models-DomiLQcY.mjs";
2
+ import { createRequire } from "node:module";
3
+ import { Worker } from "node:worker_threads";
4
+ import { randomBytes } from "node:crypto";
5
+ import { WebSocketServer } from "ws";
6
+ const TICKET_MS = 3e4;
7
+ /** A segment on the socket: a capture's audio or a session's talk, numbered (`<owner>~<n>`). */
8
+ const ID = /^(cap|ses)-\d{10,16}-[a-z0-9]{4,12}~[a-z0-9]{1,24}$/;
9
+ const tickets = /* @__PURE__ */ new Map();
10
+ /** A single-use ticket for the audio socket, good for 30 s. */
11
+ function issueTicket(now = Date.now()) {
12
+ for (const [t, exp] of tickets) if (exp <= now) tickets.delete(t);
13
+ const t = randomBytes(24).toString("hex");
14
+ tickets.set(t, now + TICKET_MS);
15
+ return t;
16
+ }
17
+ /** Take a ticket: true once, while it lives. */
18
+ function takeTicket(t, now = Date.now()) {
19
+ if (!t) return false;
20
+ const exp = tickets.get(t);
21
+ tickets.delete(t);
22
+ return exp !== void 0 && exp > now;
23
+ }
24
+ const cookie = (req, name) => new RegExp(`(?:^|;\\s*)${name}=([\\w-]+)`).exec(String(req.headers.cookie ?? ""))?.[1];
25
+ /** May this upgrade open the audio socket? The ticket (taken now), the owner's cookie, and an Origin that
26
+ * is exactly this canvas (its host:port equals the request's Host). */
27
+ function upgradeAllowed(req, now = Date.now()) {
28
+ const ticket = new URL(req.url ?? "", "http://x").searchParams.get("ticket");
29
+ const origin = req.headers.origin;
30
+ let sameOrigin = false;
31
+ try {
32
+ sameOrigin = !!origin && new URL(String(origin)).host === String(req.headers.host ?? "");
33
+ } catch {
34
+ sameOrigin = false;
35
+ }
36
+ return takeTicket(ticket, now) && sameOrigin && !!cookie(req, "mv_c");
37
+ }
38
+ /** The running dev server's speech service, for the API routes. */
39
+ const speechLive = {};
40
+ /** The model holds about a gigabyte while loaded: with no capture for this long, the worker lets it go
41
+ * (the next capture loads it again in under a second). */
42
+ const IDLE_MS = 6e5;
43
+ function createSpeech(opts = {}) {
44
+ const ready_ = opts.modelsReady ?? modelsReady;
45
+ /** talk segments: their start on the page clock (ms), so their words get the time they were said */
46
+ const talkT0 = /* @__PURE__ */ new Map();
47
+ let worker = null;
48
+ let ready = null;
49
+ let unavailable;
50
+ let live = null;
51
+ let lastUse = Date.now();
52
+ const owners = /* @__PURE__ */ new Map();
53
+ /** talk segments open on a socket: how to end each one from here */
54
+ const talk = /* @__PURE__ */ new Map();
55
+ const idle = setInterval(() => {
56
+ if (worker && owners.size === 0 && Date.now() - lastUse > (opts.idleMs ?? IDLE_MS)) {
57
+ const w = worker;
58
+ worker = null;
59
+ ready = null;
60
+ w.terminate();
61
+ }
62
+ }, Math.min(6e4, opts.idleMs ?? IDLE_MS));
63
+ idle.unref();
64
+ const engineMissing = () => {
65
+ if (opts.engineMissing) return opts.engineMissing();
66
+ try {
67
+ createRequire(import.meta.url).resolve("sherpa-onnx-node");
68
+ return;
69
+ } catch {
70
+ return "the speech engine (sherpa-onnx-node) is not installed - typed notes only";
71
+ }
72
+ };
73
+ const tell = (ws, m) => {
74
+ if (ws && ws.readyState === ws.OPEN) ws.send(JSON.stringify(m));
75
+ };
76
+ /** The worker, started once (and again after it went): resolves to it once the model is loaded, or to
77
+ * null - the engine missing or failing, the model not there - and says why in `unavailable`. */
78
+ const start = () => {
79
+ if (ready) return ready;
80
+ const p = (async () => {
81
+ const missing = engineMissing();
82
+ if (missing) {
83
+ unavailable = missing;
84
+ return null;
85
+ }
86
+ if (!await ready_()) return null;
87
+ const url = opts.workerUrl ?? new URL(import.meta.url.endsWith(".ts") ? "./speech-worker.ts" : "./speech-worker.mjs", import.meta.url);
88
+ const w = new Worker(url, { workerData: { paths: modelPaths() } });
89
+ w.unref();
90
+ return new Promise((resolve) => {
91
+ let settled = false;
92
+ const settle = (v) => {
93
+ if (!settled) {
94
+ settled = true;
95
+ resolve(v);
96
+ }
97
+ };
98
+ w.on("message", (m) => {
99
+ if (m?.type === "ready") {
100
+ if (worker && worker !== w) {
101
+ w.terminate();
102
+ settle(worker);
103
+ return;
104
+ }
105
+ worker = w;
106
+ settle(w);
107
+ } else if (m?.type === "unavailable") {
108
+ unavailable = `the speech engine could not start: ${m.reason} - typed notes only`;
109
+ w.terminate();
110
+ settle(null);
111
+ } else if (m?.type === "words" || m?.type === "final") {
112
+ const o = owners.get(m.capture);
113
+ if (!o || o.w !== w) return;
114
+ if (m.type === "final") {
115
+ owners.delete(m.capture);
116
+ o.done?.();
117
+ o.onFinal?.(m.incomplete !== true);
118
+ }
119
+ const t0 = talkT0.get(m.capture);
120
+ if (m.type === "words" && t0 !== void 0 && Array.isArray(m.words)) try {
121
+ opts.onTalk?.({
122
+ session: m.capture.split("~")[0],
123
+ words: m.words.map((x) => ({
124
+ ...x,
125
+ at: t0 + x.at / 16e3 * 1e3
126
+ }))
127
+ });
128
+ } catch {}
129
+ if (m.type === "final") talkT0.delete(m.capture);
130
+ tell(o.ws, m);
131
+ }
132
+ });
133
+ let down = false;
134
+ const gone = (why) => {
135
+ if (down) return;
136
+ down = true;
137
+ if (worker === w) {
138
+ worker = null;
139
+ ready = null;
140
+ }
141
+ if (!settled) {
142
+ unavailable = `the speech engine stopped: ${why} - typed notes only`;
143
+ settle(null);
144
+ return;
145
+ }
146
+ for (const [id, o] of [...owners]) if (o.w === w) {
147
+ owners.delete(id);
148
+ o.done?.();
149
+ o.onFinal?.(false);
150
+ tell(o.ws, {
151
+ type: "final",
152
+ capture: id,
153
+ incomplete: true
154
+ });
155
+ }
156
+ };
157
+ w.on("error", (err) => gone(err.message));
158
+ w.on("exit", (code) => gone(`exit ${code}`));
159
+ });
160
+ })();
161
+ ready = p;
162
+ p.then((w) => {
163
+ if (!w && ready === p) ready = null;
164
+ });
165
+ return p;
166
+ };
167
+ /** Busy: a segment open on the live connection, or its last words not back - or the connection just opened
168
+ * (its page is still starting its microphone: a few seconds before its first segment). */
169
+ let liveSince = 0;
170
+ const busyNow = () => {
171
+ const ws = live;
172
+ if (!ws || ws.readyState !== ws.OPEN) return false;
173
+ return [...owners.values()].some((o) => o.ws === ws) || Date.now() - liveSince < 5e3;
174
+ };
175
+ const onSocket = (ws) => {
176
+ if (live && live !== ws) try {
177
+ live.close(4e3, "another audio connection took over");
178
+ } catch {}
179
+ live = ws;
180
+ liveSince = Date.now();
181
+ let closed = false;
182
+ const caps = /* @__PURE__ */ new Map();
183
+ const then = (c, f, otherwise) => {
184
+ c.gate = c.gate.then((w) => {
185
+ if (w && worker === w && (!closed || c.keep)) f(w);
186
+ else otherwise?.();
187
+ return w;
188
+ });
189
+ };
190
+ ws.on("message", (data, isBinary) => {
191
+ lastUse = Date.now();
192
+ if (isBinary) {
193
+ const buf = Buffer.isBuffer(data) ? data : Buffer.concat(data);
194
+ const n = buf.length ? buf[0] : 0;
195
+ if (buf.length < 1 + n + 6 || (buf.length - 1 - n - 4) % 2) return;
196
+ const id = buf.toString("utf8", 1, 1 + n);
197
+ const c = caps.get(id);
198
+ if (!c || c.ended || c.dropped) return;
199
+ const offset = buf.readUInt32LE(1 + n);
200
+ const pcm = new Int16Array(buf.buffer.slice(buf.byteOffset + 1 + n + 4, buf.byteOffset + buf.length));
201
+ c.sent = Math.max(c.sent, offset + pcm.length);
202
+ then(c, (w) => {
203
+ if (!c.dropped) w.postMessage({
204
+ type: "audio",
205
+ capture: id,
206
+ offset,
207
+ pcm
208
+ }, [pcm.buffer]);
209
+ });
210
+ return;
211
+ }
212
+ let m;
213
+ try {
214
+ m = JSON.parse(String(data));
215
+ } catch {
216
+ return;
217
+ }
218
+ if (typeof m?.capture !== "string" || !ID.test(m.capture)) return;
219
+ const id = m.capture;
220
+ if (m.type === "begin") {
221
+ const prev = caps.get(id);
222
+ if (prev && !prev.ended && !prev.dropped && owners.has(id)) return;
223
+ if (prev) prev.dropped = true;
224
+ const own = { ws };
225
+ owners.set(id, own);
226
+ if (id.startsWith("ses-") && Number.isFinite(m.t0)) talkT0.set(id, Number(m.t0));
227
+ const c = {
228
+ gate: Promise.resolve(null),
229
+ ended: false,
230
+ dropped: false,
231
+ sent: 0
232
+ };
233
+ own.done = () => {
234
+ if (caps.get(id) === c) caps.delete(id);
235
+ talkT0.delete(id);
236
+ talk.delete(id);
237
+ };
238
+ if (id.startsWith("ses-")) {
239
+ let finished;
240
+ const final = new Promise((r) => {
241
+ finished = r;
242
+ });
243
+ let over = false;
244
+ own.onFinal = (whole) => {
245
+ if (over) return;
246
+ over = true;
247
+ if (!whole && c.sent > 0) try {
248
+ opts.onTalk?.({
249
+ session: id.split("~")[0],
250
+ words: [{
251
+ w: "[words lost]",
252
+ at: Date.now(),
253
+ lost: true
254
+ }]
255
+ });
256
+ } catch {}
257
+ finished();
258
+ };
259
+ const lose = () => {
260
+ if (owners.get(id) === own) owners.delete(id);
261
+ own.done?.();
262
+ own.onFinal?.(false);
263
+ };
264
+ talk.set(id, () => {
265
+ if (!c.ended && !c.dropped) {
266
+ c.ended = true;
267
+ then(c, (w) => w.postMessage({
268
+ type: "end",
269
+ capture: id,
270
+ lastSample: c.sent
271
+ }), () => lose());
272
+ }
273
+ if (c.dropped) finished();
274
+ return Promise.race([final.then(() => true), new Promise((r) => setTimeout(() => r(false), opts.talkWaitMs ?? 1e4))]);
275
+ });
276
+ }
277
+ c.gate = start().then((w) => {
278
+ if (!w) {
279
+ owners.delete(id);
280
+ own.done?.();
281
+ own.onFinal?.(false);
282
+ tell(ws, {
283
+ type: "unavailable",
284
+ capture: id,
285
+ reason: unavailable ?? "the speech model is not ready - typed notes only"
286
+ });
287
+ return null;
288
+ }
289
+ if (closed && !c.keep || c.dropped || worker !== w) return null;
290
+ own.w = w;
291
+ w.postMessage({
292
+ type: "begin",
293
+ capture: id
294
+ });
295
+ return w;
296
+ });
297
+ caps.set(id, c);
298
+ } else if (m.type === "end") {
299
+ const c = caps.get(id);
300
+ if (!c || c.ended || c.dropped) {
301
+ tell(ws, {
302
+ type: "final",
303
+ capture: id,
304
+ incomplete: true
305
+ });
306
+ return;
307
+ }
308
+ c.ended = true;
309
+ const lastSample = Number(m.lastSample);
310
+ then(c, (w) => w.postMessage({
311
+ type: "end",
312
+ capture: id,
313
+ lastSample: Number.isFinite(lastSample) ? lastSample : 0
314
+ }), () => {
315
+ const o = owners.get(id);
316
+ o?.done?.();
317
+ o?.onFinal?.(false);
318
+ owners.delete(id);
319
+ tell(ws, {
320
+ type: "final",
321
+ capture: id,
322
+ incomplete: true
323
+ });
324
+ });
325
+ } else if (m.type === "drop") {
326
+ const c = caps.get(id);
327
+ if (!c || c.dropped) return;
328
+ c.dropped = true;
329
+ owners.get(id)?.done?.();
330
+ owners.get(id)?.onFinal?.(true);
331
+ owners.delete(id);
332
+ then(c, (w) => w.postMessage({
333
+ type: "drop",
334
+ capture: id
335
+ }));
336
+ }
337
+ });
338
+ ws.on("close", () => {
339
+ closed = true;
340
+ if (live === ws) live = null;
341
+ for (const [id, c] of caps) {
342
+ if (id.startsWith("ses-") && !c.dropped) {
343
+ c.keep = true;
344
+ if (!c.ended) {
345
+ c.ended = true;
346
+ then(c, (w) => w.postMessage({
347
+ type: "end",
348
+ capture: id,
349
+ lastSample: c.sent
350
+ }), () => {
351
+ const o = owners.get(id);
352
+ owners.delete(id);
353
+ o?.done?.();
354
+ o?.onFinal?.(false);
355
+ });
356
+ }
357
+ continue;
358
+ }
359
+ talkT0.delete(id);
360
+ if (owners.get(id)?.ws === ws) owners.delete(id);
361
+ c.dropped = true;
362
+ worker?.postMessage({
363
+ type: "drop",
364
+ capture: id
365
+ });
366
+ }
367
+ });
368
+ };
369
+ const wss = new WebSocketServer({
370
+ noServer: true,
371
+ maxPayload: 1 << 20
372
+ });
373
+ return {
374
+ retry() {
375
+ if (engineMissing() || worker || ready) return;
376
+ unavailable = void 0;
377
+ },
378
+ async state() {
379
+ const missing = engineMissing();
380
+ if (missing) return {
381
+ state: "unavailable",
382
+ reason: missing
383
+ };
384
+ if (unavailable) return {
385
+ state: "unavailable",
386
+ reason: unavailable
387
+ };
388
+ if (!await ready_()) return { state: "needs-model" };
389
+ if (worker) return { state: "ready" };
390
+ start();
391
+ return unavailable ? {
392
+ state: "unavailable",
393
+ reason: unavailable
394
+ } : { state: "loading" };
395
+ },
396
+ busy() {
397
+ return busyNow();
398
+ },
399
+ async finishTalk(session) {
400
+ return (await Promise.all([...talk].filter(([id]) => id.startsWith(`${session}~`)).map(([, end]) => end()))).every(Boolean);
401
+ },
402
+ attach(server) {
403
+ server.on("upgrade", (req, socket, head) => {
404
+ if (!(req.url ?? "").startsWith("/__mv/api/jam/audio")) return;
405
+ if (!upgradeAllowed(req)) {
406
+ socket.write("HTTP/1.1 403 Forbidden\r\nConnection: close\r\n\r\n");
407
+ socket.destroy();
408
+ return;
409
+ }
410
+ if (new URL(req.url ?? "", "http://x").searchParams.get("reclaim") === "1" && busyNow()) {
411
+ socket.write("HTTP/1.1 409 Conflict\r\nConnection: close\r\n\r\n");
412
+ socket.destroy();
413
+ return;
414
+ }
415
+ wss.handleUpgrade(req, socket, head, (ws) => onSocket(ws));
416
+ });
417
+ },
418
+ stop() {
419
+ clearInterval(idle);
420
+ try {
421
+ live?.close();
422
+ } catch {}
423
+ worker?.terminate();
424
+ wss.close();
425
+ }
426
+ };
427
+ }
428
+ //#endregion
429
+ export { createSpeech, issueTicket, speechLive };
@@ -1,4 +1,4 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
2
  import { closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, statSync, unlinkSync, writeSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
  import { createHash, createHmac, randomBytes, scryptSync, timingSafeEqual } from "node:crypto";
@@ -1,4 +1,4 @@
1
- import { AREA, SURFACE, pool, shotConcurrency, withBrowser } from "./shot-CUlmkqFX.mjs";
1
+ import { AREA, SURFACE, pool, shotConcurrency, withBrowser } from "./shot-DqcxJibP.mjs";
2
2
  import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, utimesSync, writeFileSync } from "node:fs";
3
3
  import { join, sep } from "node:path";
4
4
  import { createHash } from "node:crypto";
@@ -1,8 +1,8 @@
1
1
  import { r as NAME } from "./cli.mjs";
2
2
  import { a as checkRealDirs, d as readMembership, f as readRegistry, i as checkBoardsDir, n as addFolders, r as boardFields, s as listBoardFiles, u as pinFrames } from "./boards-CGg6piKF.mjs";
3
3
  import { T as readCapability, a as buildTree, b as FOLDER_MODULES, c as folderMap, f as isBoardName, k as resolveType, o as flatten, u as humanize, v as BOARD_TYPES, w as knownType } from "./board-tree-DRioF94d.mjs";
4
- import { _ as STATUS_LABEL, d as annotateBoards, h as PHASE_LABEL, s as scanFrames } from "./manifest-DnAte_fB.mjs";
5
- import { resolveTargets } from "./link-C-qUIuKU.mjs";
4
+ import { _ as STATUS_LABEL, d as annotateBoards, h as PHASE_LABEL, s as scanFrames } from "./manifest-Nl3KSVOk.mjs";
5
+ import { resolveTargets } from "./link-BNzLvdhI.mjs";
6
6
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
7
7
  import { join } from "node:path";
8
8
  //#region src/cli/boards.ts
@@ -1,10 +1,10 @@
1
1
  import { a as ROUTE, r as NAME } from "./cli.mjs";
2
2
  import { f as readRegistry, i as checkBoardsDir, o as isRegularFile, r as boardFields, s as listBoardFiles } from "./boards-CGg6piKF.mjs";
3
3
  import { C as PROPOSED_PUBLISH, a as buildTree, f as isBoardName, l as framesOn, o as flatten, t as ALL_SCENES } from "./board-tree-DRioF94d.mjs";
4
- import { g as PUBLISHABLE, s as scanFrames, v as publishableStatus } from "./manifest-DnAte_fB.mjs";
5
- import { a as readLog, r as legacyExposure, t as appendEvents } from "./comments-Zoch254k.mjs";
6
- import { n as loadConfig, r as detectHost } from "./config-cKgZBRj0.mjs";
7
- import { a as autoWidthOf, c as readSizes, n as tailwind3Css, o as keptSizes, r as tailwind4Plugin, s as measuringFrames, t as marverPlugin } from "./plugin-dTF5reck.mjs";
4
+ import { g as PUBLISHABLE, s as scanFrames, v as publishableStatus } from "./manifest-Nl3KSVOk.mjs";
5
+ import { a as readLog, o as shareable, r as legacyExposure, t as appendEvents } from "./comments-0BSbb04K.mjs";
6
+ import { n as loadConfig, r as detectHost } from "./config-Cf7EjAMf.mjs";
7
+ import { a as autoWidthOf, c as readSizes, n as tailwind3Css, o as keptSizes, r as tailwind4Plugin, s as measuringFrames, t as marverPlugin } from "./plugin-CTD0rydA.mjs";
8
8
  import { cpSync, existsSync, mkdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
9
9
  import { basename, dirname, join, sep } from "node:path";
10
10
  import { fileURLToPath } from "node:url";
@@ -744,7 +744,12 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
744
744
  page("frame-host", "frame", `${ROUTE.slice(1)}/frame/index.html`);
745
745
  page("stage", "stage", `${ROUTE.slice(1)}/stage/index.html`);
746
746
  cpSync(join(clientDir, "shell", "favicon"), join(outDir, ROUTE.slice(1), "favicon"), { recursive: true });
747
- for (const f of ["bridge.js", "inspect.js"]) cpSync(join(clientDir, "frame-host", f), join(outDir, "assets", f));
747
+ for (const f of [
748
+ "bridge.js",
749
+ "inspect.js",
750
+ "keys.js",
751
+ "trail.js"
752
+ ]) cpSync(join(clientDir, "frame-host", f), join(outDir, "assets", f));
748
753
  const frameCss = cssFor("frame").map((f) => `<link rel="stylesheet" href="/${f}" />`).join("\n");
749
754
  for (const f of frames.filter((x) => x.kind === "html")) {
750
755
  const src = readFileSync(join(root, f.file), "utf8");
@@ -780,7 +785,7 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
780
785
  const realAssets = existsSync(assetsDir) ? realpathSync(assetsDir) : null;
781
786
  for (const r of refs) {
782
787
  if (!isLocalAssetRef(r) || !r.endsWith(".poster.png") || existsSync(join(assetsDir, r))) continue;
783
- const { ensurePoster } = await import("./poster-D-zjYpgk.mjs");
788
+ const { ensurePoster } = await import("./poster-ChjXGTS5.mjs");
784
789
  const g = await ensurePoster(assetsDir, r.slice(0, -11));
785
790
  if (!g.ok) throw new Error(`design/assets/${r}: ${g.error}`);
786
791
  console.log(` poster: rendered design/assets/${r} (${g.width}×${g.height})`);
@@ -807,13 +812,15 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
807
812
  for (const n of publishedNames) {
808
813
  const f = join(commentsDir, `${n}.jsonl`);
809
814
  if (!existsSync(f)) continue;
815
+ const events = shareable(readLog(commentsDir, n));
816
+ if (!events.length) continue;
810
817
  mkdirSync(seedOut, { recursive: true });
811
- cpSync(f, join(seedOut, `${n}.jsonl`));
818
+ appendEvents(seedOut, n, events);
812
819
  seeded++;
813
820
  }
814
821
  const old = readLog(commentsDir, ALL_SCENES);
815
822
  const exposed = legacyExposure(old, rights, shows);
816
- const kept = old.filter((e) => exposed(e).length);
823
+ const kept = shareable(old).filter((e) => exposed(e).length);
817
824
  if (kept.length) {
818
825
  appendEvents(seedOut, ALL_SCENES, kept);
819
826
  seeded++;
@@ -855,7 +862,7 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
855
862
  }));
856
863
  let textureLine = " textures: skipped (--no-textures)";
857
864
  if (textures && bakeGen) {
858
- const { bakePublished } = await import("./publish-bakes-C_9VZ-Mq.mjs");
865
+ const { bakePublished } = await import("./publish-bakes-CEP_2NRc.mjs");
859
866
  const pubFrameFile = new Map(pubFrames.map((f) => [f.id, f]));
860
867
  const r = await bakePublished({
861
868
  root,