@marver-design/marver 0.27.2 → 0.29.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.
- package/CHANGELOG.md +160 -0
- package/README.md +6 -4
- package/dist/{anchor-check-gkxkPAIv.mjs → anchor-check-DhlpKl2K.mjs} +1 -1
- package/dist/{audio-Dw1lfMdb.mjs → audio-DX4POHAj.mjs} +39 -4
- package/dist/{boards-BqUqKNW8.mjs → boards-BeWtjGUM.mjs} +49 -4
- package/dist/boards-EH2onUXM.mjs +995 -0
- package/dist/{build-VgNg4rr8.mjs → build-CWbrb2bl.mjs} +9 -5
- package/dist/{capture-vadKjuCo.mjs → capture-DEtM4qm5.mjs} +259 -34
- package/dist/cli.mjs +40 -19
- package/dist/{comments-YEU1Zhv9.mjs → comments-XNhMmSSu.mjs} +4 -4
- package/dist/config-BezZTiov.mjs +182 -0
- package/dist/conn-BMiHS42T.mjs +222 -0
- package/dist/connectors-DekQvKt9.mjs +292 -0
- package/dist/{context-Ccjrhr1J.mjs → context-BUnFiyA3.mjs} +2 -2
- package/dist/{daemon-Dc9AH0M3.mjs → daemon-Sc_z8gT6.mjs} +2209 -205
- package/dist/{dev-ri6nAlRp.mjs → dev-DWBKQhxf.mjs} +31 -15
- package/dist/{init-W0nxR1OY.mjs → init-CYlFaRzG.mjs} +7 -2
- package/dist/jam-Cj5gBvwD.mjs +373 -0
- package/dist/{link-CdTgn94Y.mjs → link-BFFRgrMt.mjs} +3 -3
- package/dist/listener-DdLEM79A.mjs +80 -0
- package/dist/logo-CXY-1yrn.mjs +305 -0
- package/dist/{ls-BZ5TAtd5.mjs → ls-NqmePKOf.mjs} +1 -1
- package/dist/{manifest-aFyDmL8C.mjs → manifest-DPZ3WNg_.mjs} +1 -1
- package/dist/{marks-CnCCfAbD.mjs → marks-BnNANic9.mjs} +22 -3
- package/dist/{marks-BF9pNEgH.mjs → marks-DBp3h1Mc.mjs} +3 -6
- package/dist/{marver-id-gate-D-R0hSt_.mjs → marver-id-gate-vBLb_Icb.mjs} +1 -1
- package/dist/{perf-DkAUFT6W.mjs → perf-Denssrko.mjs} +45 -27
- package/dist/{perf-jam-BaH3Lg0m.mjs → perf-jam-CLkERSHo.mjs} +9 -2
- package/dist/permit-DDa6wqOs.mjs +187 -0
- package/dist/{plugin-B8UghYuF.mjs → plugin-DqoZB-D6.mjs} +849 -789
- package/dist/{poster-BNgafWMK.mjs → poster-CrsjqhY4.mjs} +1 -1
- package/dist/{profile-jIS6BcAs.mjs → profile-B1FKOM1e.mjs} +1 -1
- package/dist/{publish-bakes-38Nja78p.mjs → publish-bakes-DW-NDgU2.mjs} +3 -3
- package/dist/{queue-CAM_vNmX.mjs → queue-DeSQm24g.mjs} +189 -35
- package/dist/{recover-B8AiI29B.mjs → recover-GtJ9UDAB.mjs} +2 -2
- package/dist/{serve-Dp3nHstu.mjs → serve-DQv3Ti6X.mjs} +8 -4
- package/dist/{session-BAaJsK5c.mjs → session-VDJfXEEm.mjs} +1 -1
- package/dist/{share-Ce4tP7ji.mjs → share-Bu_kuOKL.mjs} +1 -1
- package/dist/{shot-CMQgMVZm.mjs → shot-DBWN8hPP.mjs} +1 -1
- package/dist/{shot-Ch24tiMO.mjs → shot-T04Ixrvq.mjs} +7 -6
- package/dist/sizes-wjXDev3b.mjs +139 -0
- package/dist/{slots-CFNnegCc.mjs → slots-Dn4Onb0V.mjs} +101 -3
- package/dist/speech-worker.mjs +23 -3
- package/dist/{sync-CQdGARJ9.mjs → sync-CMozOwZ0.mjs} +1 -1
- package/dist/transport-C5FnY9ni.mjs +203 -0
- package/dist/{work-Bxz-ObF3.mjs → work-BYWD_1Zf.mjs} +3 -3
- package/dist/{work-CNhFF9pU.mjs → work-DJxH7cCX.mjs} +1 -1
- package/docs/boards-and-folders.md +11 -0
- package/docs/jam-session.md +52 -18
- package/docs/live-jam.md +95 -10
- package/docs/performance.md +1 -1
- package/docs/publish.md +7 -0
- package/package.json +1 -1
- package/src/client/shell/Comments.tsx +5 -4
- package/src/client/shell/ContextMenu.tsx +5 -4
- package/src/client/shell/JamSurface.tsx +135 -29
- package/src/client/shell/Play.tsx +16 -4
- package/src/client/shell/api.ts +7 -3
- package/src/client/shell/app-bridge.ts +11 -3
- package/src/client/shell/comments-store.ts +14 -0
- package/src/client/shell/goto.ts +4 -3
- package/src/client/shell/icons.tsx +1 -0
- package/src/client/shell/jam-capture.ts +136 -37
- package/src/client/shell/jam-keys.ts +170 -18
- package/src/client/shell/jam-lane.tsx +14 -5
- package/src/client/shell/jam-lines.ts +76 -10
- package/src/client/shell/jam-panel.tsx +58 -4
- package/src/client/shell/jam-queue.ts +55 -8
- package/src/client/shell/jam-session.tsx +55 -6
- package/src/client/shell/jam-state.ts +19 -4
- package/src/client/shell/jam-surface-parts.tsx +6 -3
- package/src/client/shell/jam-ui.tsx +10 -1
- package/src/client/shell/jam-voice-wait.ts +21 -0
- package/src/client/shell/jam-voice.ts +14 -5
- package/src/client/shell/live-picture.ts +134 -0
- package/src/client/shell/open-item.ts +83 -0
- package/src/client/shell/open-resolve.ts +50 -0
- package/src/client/shell/store.ts +6 -2
- package/src/client/shell/styles.css +29 -11
- package/src/client/shell/tidy.ts +3 -2
- package/src/client/stage/main.tsx +30 -8
- package/src/shared/app-api.ts +173 -3
- package/src/shared/app-perf.ts +4 -2
- package/src/shared/approval.ts +20 -0
- package/src/shared/events.ts +1 -1
- package/templates/AGENTS-embedded.md +28 -1
- package/templates/AGENTS-studio.md +28 -1
- package/templates/instructions/boards.md +7 -1
- package/templates/instructions/jam.md +94 -0
- package/dist/boards-BHKP5yhI.mjs +0 -342
- package/dist/live-Cgzsicwi.mjs +0 -4
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
+
import { o as rendersDoc, r as layoutDocSource } from "./manifest-DPZ3WNg_.mjs";
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
//#region src/server/sizes.ts
|
|
6
|
+
/**
|
|
7
|
+
* Content-frame heights - `design/boards/_sizes.json`, committed.
|
|
8
|
+
*
|
|
9
|
+
* A content frame (a Doc: markdown, diagrams, images) is as tall as its content, which only a
|
|
10
|
+
* render can tell. Measured live, every load started from a guess (3/4 of the width) and grew
|
|
11
|
+
* frame by frame, and each growth re-flowed the rows below - the board swam for seconds. The
|
|
12
|
+
* height a frame measured at its own width is a fact about the FRAME at that width, not about a
|
|
13
|
+
* board (one doc sits on several boards) and not something to write into the frame's source: so
|
|
14
|
+
* it lives here, one line per `scene/frame@width`, written by the dev server when the shell
|
|
15
|
+
* reports a settled measurement, read before the first layout - dev, `marver build` and the
|
|
16
|
+
* published canvas alike. A stale entry is still the best first guess; the live measurement
|
|
17
|
+
* corrects it and the file follows. Underscore = infrastructure, never a board (board-tree.ts).
|
|
18
|
+
*/
|
|
19
|
+
var sizes_exports = /* @__PURE__ */ __exportAll({
|
|
20
|
+
SIZES_BATCH_MAX: () => 500,
|
|
21
|
+
SIZES_FILE: () => SIZES_FILE,
|
|
22
|
+
SIZE_KEY: () => SIZE_KEY,
|
|
23
|
+
SIZE_MAX: () => SIZE_MAX,
|
|
24
|
+
SIZE_MIN: () => 80,
|
|
25
|
+
autoWidthOf: () => autoWidthOf,
|
|
26
|
+
keptSizes: () => keptSizes,
|
|
27
|
+
measuringFrames: () => measuringFrames,
|
|
28
|
+
mergeSizes: () => mergeSizes,
|
|
29
|
+
readSizes: () => readSizes,
|
|
30
|
+
readSizesFile: () => readSizesFile,
|
|
31
|
+
rendersDoc: () => rendersDoc,
|
|
32
|
+
serializeSizes: () => serializeSizes,
|
|
33
|
+
sizesPath: () => sizesPath,
|
|
34
|
+
validEntry: () => validEntry
|
|
35
|
+
});
|
|
36
|
+
const SIZES_FILE = "_sizes.json";
|
|
37
|
+
/** `scene/frame@width` - the frame id grammar the focus route accepts, then the width it was measured at. */
|
|
38
|
+
const SIZE_KEY = /^([\w./-]{1,200})@(\d{2,4})$/;
|
|
39
|
+
const SIZE_MAX = 4e4;
|
|
40
|
+
const ABOUT = "Written by marver dev: the height each content frame measured at its width, so boards open at their final size. Commit it; never edit it by hand.";
|
|
41
|
+
const sizesPath = (root) => join(root, "design", "boards", SIZES_FILE);
|
|
42
|
+
/** A valid entry: a well-formed key whose frame is not a traversal, and a height in the shell's clamp. */
|
|
43
|
+
function validEntry(key, h) {
|
|
44
|
+
if (typeof key !== "string" || typeof h !== "number" || !Number.isInteger(h) || h < 80 || h > 4e4) return false;
|
|
45
|
+
const m = SIZE_KEY.exec(key);
|
|
46
|
+
return !!m && !m[1].split("/").some((p) => p === ".." || p === "." || p === "");
|
|
47
|
+
}
|
|
48
|
+
function readSizesFile(root) {
|
|
49
|
+
const file = sizesPath(root);
|
|
50
|
+
if (!existsSync(file)) return {
|
|
51
|
+
state: "absent",
|
|
52
|
+
heights: {}
|
|
53
|
+
};
|
|
54
|
+
try {
|
|
55
|
+
const raw = JSON.parse(readFileSync(file, "utf8"));
|
|
56
|
+
if (!raw || typeof raw !== "object" || !raw.heights || typeof raw.heights !== "object" || Array.isArray(raw.heights)) return {
|
|
57
|
+
state: "invalid",
|
|
58
|
+
heights: {}
|
|
59
|
+
};
|
|
60
|
+
const out = {};
|
|
61
|
+
for (const [k, v] of Object.entries(raw.heights)) if (validEntry(k, v)) out[k] = v;
|
|
62
|
+
return {
|
|
63
|
+
state: "ok",
|
|
64
|
+
heights: out
|
|
65
|
+
};
|
|
66
|
+
} catch {
|
|
67
|
+
return {
|
|
68
|
+
state: "invalid",
|
|
69
|
+
heights: {}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** Lenient read for the readers (the shell's first layout, the build): an absent or invalid file is
|
|
74
|
+
* no heights - every frame opens at its placeholder, as before. Never throws. */
|
|
75
|
+
const readSizes = (root) => readSizesFile(root).heights;
|
|
76
|
+
/** The file's text for a set of heights: sorted keys, one entry per line - a changed height is a
|
|
77
|
+
* one-line diff, and two branches that measured different frames merge without a conflict. */
|
|
78
|
+
function serializeSizes(heights) {
|
|
79
|
+
const sorted = {};
|
|
80
|
+
for (const k of Object.keys(heights).sort()) sorted[k] = heights[k];
|
|
81
|
+
return JSON.stringify({
|
|
82
|
+
about: ABOUT,
|
|
83
|
+
heights: sorted
|
|
84
|
+
}, null, 2) + "\n";
|
|
85
|
+
}
|
|
86
|
+
const keeps = (key, autoWidth) => {
|
|
87
|
+
const m = SIZE_KEY.exec(key);
|
|
88
|
+
return !!m && autoWidth(m[1]) === Number(m[2]);
|
|
89
|
+
};
|
|
90
|
+
/** Merge incoming heights into the current ones, keeping only what a board can use: a content frame
|
|
91
|
+
* that still exists, at the width it measures at on its own. Everything else is pruned - a deleted
|
|
92
|
+
* frame, a Doc that went from document to wide. Returns the next map and the keys taken. Pruning
|
|
93
|
+
* reads only the manifest: whether a frame still renders a Doc is asked on READ (keptSizes), so a
|
|
94
|
+
* source caught mid-write can hide an entry for one load, never delete it. */
|
|
95
|
+
function mergeSizes(current, incoming, autoWidth) {
|
|
96
|
+
const next = Object.fromEntries(Object.entries(current).filter(([k]) => keeps(k, autoWidth)));
|
|
97
|
+
const accepted = [];
|
|
98
|
+
for (const [k, v] of Object.entries(incoming)) {
|
|
99
|
+
if (!validEntry(k, v) || !keeps(k, autoWidth)) continue;
|
|
100
|
+
next[k] = v;
|
|
101
|
+
accepted.push(k);
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
next,
|
|
105
|
+
accepted
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** The entries a board can use - what the GET and the build hand the shell: a content frame at its
|
|
109
|
+
* own width that MEASURES (renders a Doc). A frame that went from a Doc to a bare Md keeps the size
|
|
110
|
+
* its board gives it, never an old measurement. */
|
|
111
|
+
const keptSizes = (heights, autoWidth, measuring) => Object.fromEntries(Object.entries(heights).filter(([k]) => keeps(k, autoWidth) && measuring.has(k.slice(0, k.lastIndexOf("@")))));
|
|
112
|
+
/** The auto width rule over a manifest's frames (the shell's defaultSize, store.ts). */
|
|
113
|
+
function autoWidthOf(frames, viewports) {
|
|
114
|
+
const byId = new Map(frames.map((f) => [f.id, f]));
|
|
115
|
+
return (id) => {
|
|
116
|
+
const f = byId.get(id);
|
|
117
|
+
if (!f?.contentWidth) return null;
|
|
118
|
+
return viewports[f.viewport ?? ""]?.width ?? f.contentWidth;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/** The content frames that measure: the frame renders a Doc, or a `_layout` it renders inside does
|
|
122
|
+
* (manifest.ts layoutDocSource - the same rule the manifest's width follows). A source that cannot
|
|
123
|
+
* be read, or reads empty (an editor mid-write), gets the benefit of the doubt - this only decides
|
|
124
|
+
* what a load is handed, never what the file keeps. */
|
|
125
|
+
function measuringFrames(root, frames) {
|
|
126
|
+
const out = /* @__PURE__ */ new Set();
|
|
127
|
+
const memo = /* @__PURE__ */ new Map();
|
|
128
|
+
for (const f of frames) {
|
|
129
|
+
if (!f.contentWidth || f.kind === "html" || !f.file || f.file.split("/").includes("..")) continue;
|
|
130
|
+
let src = "";
|
|
131
|
+
try {
|
|
132
|
+
src = readFileSync(join(root, f.file), "utf8");
|
|
133
|
+
} catch {}
|
|
134
|
+
if (!src.trim() || rendersDoc(src) || layoutDocSource(root, f.file, memo) !== null) out.add(f.id);
|
|
135
|
+
}
|
|
136
|
+
return out;
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
export { mergeSizes as a, serializeSizes as c, measuringFrames as i, sizesPath as l, autoWidthOf as n, readSizes as o, keptSizes as r, readSizesFile as s, SIZES_FILE as t, sizes_exports as u };
|
|
@@ -40,6 +40,92 @@ const runIdentity = (root, recoverWs) => {
|
|
|
40
40
|
ws: recoverWs ?? id
|
|
41
41
|
};
|
|
42
42
|
};
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/shared/app-api.ts
|
|
45
|
+
/** Reasons a page is busy (A2.14 #18). The first five are unsaved work; the last three are busy, not unsaved. */
|
|
46
|
+
const UNSAVED_WHY = [
|
|
47
|
+
"capture-recording",
|
|
48
|
+
"capture-unsent",
|
|
49
|
+
"board-unsaved",
|
|
50
|
+
"heights",
|
|
51
|
+
"typing"
|
|
52
|
+
];
|
|
53
|
+
const BUSY_ONLY_WHY = [
|
|
54
|
+
"jam-session",
|
|
55
|
+
"microphone",
|
|
56
|
+
"agent"
|
|
57
|
+
];
|
|
58
|
+
[...UNSAVED_WHY, ...BUSY_ONLY_WHY];
|
|
59
|
+
/** Bounds main checks again (A2.14 #19): unknown fields are stripped, a known one of the wrong type or past its bound refuses the message. */
|
|
60
|
+
const BOUNDS = {
|
|
61
|
+
version: 32,
|
|
62
|
+
versionChars: /^[0-9A-Za-z.+-]+$/,
|
|
63
|
+
board: 128,
|
|
64
|
+
page: /^[A-Za-z0-9_-]{8,64}$/,
|
|
65
|
+
doc: /^[A-Za-z0-9_-]{16,64}$/,
|
|
66
|
+
menuItems: 40,
|
|
67
|
+
menuId: /^[a-z][a-z0-9-]{0,31}$/,
|
|
68
|
+
label: 48,
|
|
69
|
+
hint: 8,
|
|
70
|
+
/** A3.8 #27: an epoch is an integer 0..epoch; a presentation viewport's sides are 0..viewport CSS px; `frames` 1..frames */
|
|
71
|
+
epoch: 2 ** 31 - 1,
|
|
72
|
+
viewport: 2e4,
|
|
73
|
+
frames: 8,
|
|
74
|
+
/** A4.6 #35, #37: a live picture's long side at most (main scales down to it; the server refuses past it), and
|
|
75
|
+
* main's deadline for one capture */
|
|
76
|
+
captureLong: 4096,
|
|
77
|
+
captureMs: 1500
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* What a slot file's `features` say a canvas offers the Mac app (src/server/slots.ts `FEATURES`; the app reads each
|
|
81
|
+
* registry entry's). A name is a version (A4.6 #2): a breaking change to its contract takes a new name (`live2`),
|
|
82
|
+
* never a new meaning for this one, and `bridge` and `inset` imply none of the others. An app ignores a name it does
|
|
83
|
+
* not know (A1.3), and asks nothing of a canvas that does not list one (A4.6 #3).
|
|
84
|
+
*/
|
|
85
|
+
const FEATURE = {
|
|
86
|
+
/** 0.27.1 (A2.9, A2.14 #15): the shell says hello, theme, menu and `mv:busy` with `unsaved` */
|
|
87
|
+
bridge: "bridge",
|
|
88
|
+
/** 0.27.2 (A3.8 #31): the shell takes the top inset under the strip and answers presentation requests */
|
|
89
|
+
inset: "inset",
|
|
90
|
+
/** 0.29.0 (A4.6 #5, #6, #11): the server answers `GET /__mv/app/live` (`LIVE_WIRE`) with `LiveEvent` v1 */
|
|
91
|
+
live: "live",
|
|
92
|
+
/** 0.29.0 (A4.6 #29, #30): the shell handles `mv:open` and answers `mv:opened` */
|
|
93
|
+
open: "open",
|
|
94
|
+
/** 0.29.0 (A4.6 #33-#37): the shell asks `mv:capture` for live pictures and the server takes `POST /api/jam/picture/live` */
|
|
95
|
+
capture: "capture"
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* The bounds both sides keep (A4.6 #11, #16): the server's selector and encoder write within them, and main checks
|
|
99
|
+
* every field again, stripping unknown ones and dropping an item of an unknown kind (not the event). `eventBytes`:
|
|
100
|
+
* the event as written (`event: live`, its `data:` line, the blank line) in UTF-8 bytes - the encoder drops the
|
|
101
|
+
* oldest whole items until it fits, and main drops a connection whose event is longer.
|
|
102
|
+
*/
|
|
103
|
+
const LIVE_BOUNDS = {
|
|
104
|
+
items: 100,
|
|
105
|
+
title: 140,
|
|
106
|
+
note: 140,
|
|
107
|
+
ref: 128,
|
|
108
|
+
cards: 8,
|
|
109
|
+
eventBytes: 65536,
|
|
110
|
+
id: /^(ask|review|failed|stalled):[0-9a-f]{20}$/
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* The live stream's wire (A4.6 #5, #6, #14). `GET <origin><path>` with `x-mv-ws`, a fresh `x-mv-nonce` and
|
|
114
|
+
* `x-mv-app` = `appProof(key, port)`; the 200 is `text/event-stream` carrying `x-mv-instance` and `x-mv-proof` =
|
|
115
|
+
* `liveProof(key, nonce, port)` (src/server/proof.ts). Each snapshot is `event: <event>`, one `data:` line of
|
|
116
|
+
* `LiveEvent` JSON, then a blank line; `<heartbeat>` is a comment line every `heartbeatMs`. No `Last-Event-ID`, no
|
|
117
|
+
* `retry:`. At most `clients` at once (one more ends the oldest); a client with more than `slowBytes` unsent is
|
|
118
|
+
* dropped and reconnects.
|
|
119
|
+
*/
|
|
120
|
+
const LIVE_WIRE = {
|
|
121
|
+
path: "/__mv/app/live",
|
|
122
|
+
type: "text/event-stream",
|
|
123
|
+
event: "live",
|
|
124
|
+
heartbeat: ": hb",
|
|
125
|
+
heartbeatMs: 3e4,
|
|
126
|
+
clients: 4,
|
|
127
|
+
slowBytes: 65536
|
|
128
|
+
};
|
|
43
129
|
const marverHome = () => process.env.MARVER_HOME || join(homedir(), ".marver");
|
|
44
130
|
/** The port before slot 1 - slot n listens on base + n (localhost:4805-4824). MARVER_SLOT_BASE moves
|
|
45
131
|
* the range for the test suite alone: the port check sees every program on this Mac, so a suite on
|
|
@@ -119,8 +205,20 @@ function asRecord(v) {
|
|
|
119
205
|
* reports. A canvas without it (0.27.0) gets the app's degraded guard, which asks first. `inset` (0.27.2, A3.8 #31):
|
|
120
206
|
* its shell takes the top inset under the app's transparent strip, keeps what it means to be read or clicked below
|
|
121
207
|
* it and its scroll edge, and answers the app's presentation requests - so app 0.2 may run it at the window's full
|
|
122
|
-
* height. A canvas without it stays below the strip.
|
|
123
|
-
|
|
208
|
+
* height. A canvas without it stays below the strip. The names are app-api.ts's `FEATURE`, read by the app too.
|
|
209
|
+
*
|
|
210
|
+
* A4 (0.29.0, A4.6 #2) adds `live`, `open` and `capture` - each a frozen contract, described at `FEATURE`. A name here
|
|
211
|
+
* is a promise the app acts on (it opens a stream, sends `mv:open`, answers `mv:capture`), so each A4 stream adds its
|
|
212
|
+
* own name here once its half works, never before: `live` (app-live.ts), `open` (the shell's open-item.ts) and
|
|
213
|
+
* `capture` (the shell asks for live pictures in play and the server takes `POST /api/jam/picture/live`:
|
|
214
|
+
* live-picture.ts, api.ts). */
|
|
215
|
+
const FEATURES = [
|
|
216
|
+
FEATURE.bridge,
|
|
217
|
+
FEATURE.inset,
|
|
218
|
+
FEATURE.live,
|
|
219
|
+
FEATURE.open,
|
|
220
|
+
FEATURE.capture
|
|
221
|
+
];
|
|
124
222
|
/** Take one candidate: the file, then - holding it - the port check. */
|
|
125
223
|
async function take(i, slot, port) {
|
|
126
224
|
const file = slot ? slotFileOf(slot) : portFileOf(port);
|
|
@@ -475,4 +573,4 @@ function formatRunning(list, now = Date.now()) {
|
|
|
475
573
|
return rows.map((r) => r.map((cell, c) => c === 0 ? cell.padStart(widths[c]) : cell.padEnd(widths[c])).join(" ").trimEnd());
|
|
476
574
|
}
|
|
477
575
|
//#endregion
|
|
478
|
-
export { notePrefer as a, ranDevBefore as c, recoverTarget as d, startedWhere as f,
|
|
576
|
+
export { runIdentity as _, notePrefer as a, ranDevBefore as c, recoverTarget as d, startedWhere as f, LIVE_WIRE as g, LIVE_BOUNDS as h, marverHome as i, readRunning as l, BOUNDS as m, formatRunning as n, originOf as o, stopPrefer as p, legacyEntry as r, place as s, forgetDevTraces as t, recoverEntries as u, workspaceId as v };
|
package/dist/speech-worker.mjs
CHANGED
|
@@ -121,6 +121,7 @@ var Segmenter = class {
|
|
|
121
121
|
while (!this.vad.isEmpty()) {
|
|
122
122
|
const raw = this.vad.front();
|
|
123
123
|
this.vad.pop();
|
|
124
|
+
if (!raw?.samples?.length) continue;
|
|
124
125
|
const seg = {
|
|
125
126
|
start: raw.start + this.skipped,
|
|
126
127
|
samples: raw.samples
|
|
@@ -237,7 +238,9 @@ function concat(a, b) {
|
|
|
237
238
|
//#endregion
|
|
238
239
|
//#region src/server/jam/speech-worker.ts
|
|
239
240
|
/**
|
|
240
|
-
* The speech worker (spec 27, Part 4): a
|
|
241
|
+
* The speech worker (spec 27, Part 4): a process of its own, so decoding never blocks the dev server - and a
|
|
242
|
+
* native crash in the engine (an ONNX error is a C++ exception no thread can catch) ends transcription, never
|
|
243
|
+
* the canvas (27 Oct: one took a whole canvas down mid-session). It also still runs as a worker thread. It
|
|
241
244
|
* loads `sherpa-onnx-node` (an optional dependency) and the checked model once, then runs one Segmenter
|
|
242
245
|
* per capture - Silero VAD for phrases, Parakeet v3 for words.
|
|
243
246
|
*
|
|
@@ -246,8 +249,20 @@ function concat(a, b) {
|
|
|
246
249
|
* out : { type: 'ready' } · { type: 'unavailable', reason } · { type: 'words', capture, words }
|
|
247
250
|
* { type: 'final', capture }
|
|
248
251
|
*/
|
|
249
|
-
const port = parentPort
|
|
250
|
-
|
|
252
|
+
const port = parentPort ?? {
|
|
253
|
+
postMessage: (m) => {
|
|
254
|
+
try {
|
|
255
|
+
process.send?.(m);
|
|
256
|
+
} catch {}
|
|
257
|
+
},
|
|
258
|
+
on: (ev, f) => {
|
|
259
|
+
process.on(ev, f);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
const paths = parentPort ? workerData.paths : JSON.parse(process.env.MARVER_SPEECH_PATHS ?? "{}");
|
|
263
|
+
if (!parentPort) process.on("disconnect", () => process.exit(0));
|
|
264
|
+
/** Shorter than this is no phrase at all: the recognizer is never handed it (an empty one crashed it, 27 Oct). */
|
|
265
|
+
const MIN_SAMPLES = RATE / 10;
|
|
251
266
|
let sherpa;
|
|
252
267
|
let recognizer;
|
|
253
268
|
const loadStart = performance.now();
|
|
@@ -295,6 +310,11 @@ const vadFor = () => new sherpa.Vad({
|
|
|
295
310
|
const turn = () => new Promise((r) => setImmediate(r));
|
|
296
311
|
const recognize = async (samples) => {
|
|
297
312
|
await turn();
|
|
313
|
+
if (samples.length < MIN_SAMPLES) return {
|
|
314
|
+
tokens: [],
|
|
315
|
+
timestamps: [],
|
|
316
|
+
ms: 0
|
|
317
|
+
};
|
|
298
318
|
const t0 = performance.now();
|
|
299
319
|
const s = recognizer.createStream();
|
|
300
320
|
s.acceptWaveform({
|
|
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
|
2
2
|
import { n as diffEvents } from "./events-CLH4ijKP.mjs";
|
|
3
3
|
import { a as readLog, i as listBoards, t as appendEvents } from "./comments-0BSbb04K.mjs";
|
|
4
4
|
import { t as CLI_TOKEN_CHARS } from "./auth-Dix8wrXV.mjs";
|
|
5
|
-
import { i as marverHome } from "./slots-
|
|
5
|
+
import { i as marverHome } from "./slots-Dn4Onb0V.mjs";
|
|
6
6
|
import { chmodSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, unlinkSync, writeSync } from "node:fs";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { createHash, randomBytes } from "node:crypto";
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { b as validConnId, c as jamDir, h as readConn, x as writeAtomic } from "./conn-BMiHS42T.mjs";
|
|
2
|
+
import { mkdirSync, readFileSync, readdirSync, rmSync, statSync, watch } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { createHmac, randomUUID, timingSafeEqual } from "node:crypto";
|
|
5
|
+
//#region src/server/jam/transport.ts
|
|
6
|
+
/**
|
|
7
|
+
* The session's commands travel through files, not a port (spec 29b, Part 6): Codex's and Cursor's
|
|
8
|
+
* sandboxes can block localhost, and a file in the repo reaches the daemon from any of them.
|
|
9
|
+
*
|
|
10
|
+
* The CLI writes design/.local/jam/req/<id>.json - the connection, the operation, its arguments, the
|
|
11
|
+
* time, and an HMAC-SHA256 over all of it made with the connection's key. The daemon checks the MAC,
|
|
12
|
+
* the age and that the id is new, does the operation, and answers design/.local/jam/res/<id>.json.
|
|
13
|
+
*/
|
|
14
|
+
const reqDir = (root) => join(jamDir(root), "req");
|
|
15
|
+
const resDir = (root) => join(jamDir(root), "res");
|
|
16
|
+
/** Requests and answers older than this are swept. */
|
|
17
|
+
const KEEP_MS = 6e5;
|
|
18
|
+
const REQ_ID = /^[0-9a-f-]{36}$/;
|
|
19
|
+
const OPS = [
|
|
20
|
+
"next",
|
|
21
|
+
"say",
|
|
22
|
+
"progress",
|
|
23
|
+
"done",
|
|
24
|
+
"release",
|
|
25
|
+
"status",
|
|
26
|
+
"mute",
|
|
27
|
+
"own"
|
|
28
|
+
];
|
|
29
|
+
/** JSON with its keys in order, at every depth: the bytes a MAC is made over. */
|
|
30
|
+
function canonical(v) {
|
|
31
|
+
if (Array.isArray(v)) return `[${v.map(canonical).join(",")}]`;
|
|
32
|
+
if (v && typeof v === "object") return `{${Object.keys(v).sort().filter((k) => v[k] !== void 0).map((k) => `${JSON.stringify(k)}:${canonical(v[k])}`).join(",")}}`;
|
|
33
|
+
return JSON.stringify(v);
|
|
34
|
+
}
|
|
35
|
+
const macOf = (key, body) => createHmac("sha256", Buffer.from(key, "hex")).update(canonical(body)).digest("hex");
|
|
36
|
+
/** Write a request and wait for its answer. Throws with a sentence a person can act on. */
|
|
37
|
+
async function request(root, conn, op, args, timeoutMs = 3e4) {
|
|
38
|
+
mkdirSync(reqDir(root), {
|
|
39
|
+
recursive: true,
|
|
40
|
+
mode: 448
|
|
41
|
+
});
|
|
42
|
+
mkdirSync(resDir(root), {
|
|
43
|
+
recursive: true,
|
|
44
|
+
mode: 448
|
|
45
|
+
});
|
|
46
|
+
const body = {
|
|
47
|
+
v: 1,
|
|
48
|
+
id: randomUUID(),
|
|
49
|
+
conn: conn.id,
|
|
50
|
+
op,
|
|
51
|
+
args,
|
|
52
|
+
ts: Date.now()
|
|
53
|
+
};
|
|
54
|
+
const req = {
|
|
55
|
+
...body,
|
|
56
|
+
mac: macOf(conn.key, body)
|
|
57
|
+
};
|
|
58
|
+
const res = join(resDir(root), `${req.id}.json`);
|
|
59
|
+
writeAtomic(join(reqDir(root), `${req.id}.json`), JSON.stringify(req));
|
|
60
|
+
return await new Promise((resolve, reject) => {
|
|
61
|
+
let done = false;
|
|
62
|
+
const finish = (fn) => {
|
|
63
|
+
if (done) return;
|
|
64
|
+
done = true;
|
|
65
|
+
clearInterval(poll);
|
|
66
|
+
clearTimeout(to);
|
|
67
|
+
clearTimeout(again);
|
|
68
|
+
try {
|
|
69
|
+
w?.close();
|
|
70
|
+
} catch {}
|
|
71
|
+
fn();
|
|
72
|
+
};
|
|
73
|
+
const look = () => {
|
|
74
|
+
let text;
|
|
75
|
+
try {
|
|
76
|
+
text = readFileSync(res, "utf8");
|
|
77
|
+
} catch {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
let out;
|
|
81
|
+
try {
|
|
82
|
+
out = JSON.parse(text);
|
|
83
|
+
} catch {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
rmSync(res, { force: true });
|
|
87
|
+
finish(() => resolve(out));
|
|
88
|
+
};
|
|
89
|
+
let w;
|
|
90
|
+
try {
|
|
91
|
+
w = watch(resDir(root), { persistent: false }, look);
|
|
92
|
+
} catch {}
|
|
93
|
+
const poll = setInterval(look, 200);
|
|
94
|
+
const again = setTimeout(() => {
|
|
95
|
+
if (!done && Date.now() - body.ts < 55e3) try {
|
|
96
|
+
writeAtomic(join(reqDir(root), `${req.id}.json`), JSON.stringify(req));
|
|
97
|
+
} catch {}
|
|
98
|
+
}, Math.min(timeoutMs / 2, 2e4));
|
|
99
|
+
const to = setTimeout(() => finish(() => {
|
|
100
|
+
rmSync(join(reqDir(root), `${req.id}.json`), { force: true });
|
|
101
|
+
reject(/* @__PURE__ */ new Error("the canvas did not answer - is `marver dev` running in this repo?"));
|
|
102
|
+
}), timeoutMs);
|
|
103
|
+
look();
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/** Check one request file: a known, live connection, a MAC made with its key, recent, never seen. */
|
|
107
|
+
function verify(root, raw, seen, now = Date.now()) {
|
|
108
|
+
const r = raw;
|
|
109
|
+
const id = typeof r?.id === "string" && REQ_ID.test(r.id) ? r.id : void 0;
|
|
110
|
+
if (!r || r.v !== 1 || !id || !validConnId(r.conn) || !OPS.includes(r.op) || !r.args || typeof r.args !== "object" || typeof r.ts !== "number" || typeof r.mac !== "string") return {
|
|
111
|
+
ok: false,
|
|
112
|
+
id,
|
|
113
|
+
error: "not a Jam request"
|
|
114
|
+
};
|
|
115
|
+
const conn = readConn(root, r.conn);
|
|
116
|
+
if (!conn) return {
|
|
117
|
+
ok: false,
|
|
118
|
+
id,
|
|
119
|
+
error: "this session is not connected to the canvas"
|
|
120
|
+
};
|
|
121
|
+
const want = Buffer.from(macOf(conn.key, {
|
|
122
|
+
v: 1,
|
|
123
|
+
id,
|
|
124
|
+
conn: r.conn,
|
|
125
|
+
op: r.op,
|
|
126
|
+
args: r.args,
|
|
127
|
+
ts: r.ts
|
|
128
|
+
}), "hex");
|
|
129
|
+
const got = Buffer.from(/^[0-9a-f]{64}$/.test(r.mac) ? r.mac : "", "hex");
|
|
130
|
+
if (got.length !== want.length || !timingSafeEqual(got, want)) return {
|
|
131
|
+
ok: false,
|
|
132
|
+
id,
|
|
133
|
+
error: "the request is not signed by this session"
|
|
134
|
+
};
|
|
135
|
+
if (Math.abs(now - r.ts) > 6e4) return {
|
|
136
|
+
ok: false,
|
|
137
|
+
id,
|
|
138
|
+
error: "the request is too old - run the command again"
|
|
139
|
+
};
|
|
140
|
+
if (seen.has(id)) return {
|
|
141
|
+
ok: false,
|
|
142
|
+
id,
|
|
143
|
+
error: "this request was already answered"
|
|
144
|
+
};
|
|
145
|
+
seen.add(id);
|
|
146
|
+
return {
|
|
147
|
+
ok: true,
|
|
148
|
+
req: r,
|
|
149
|
+
conn
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function answer(root, id, body) {
|
|
153
|
+
if (!REQ_ID.test(id)) return;
|
|
154
|
+
mkdirSync(resDir(root), {
|
|
155
|
+
recursive: true,
|
|
156
|
+
mode: 448
|
|
157
|
+
});
|
|
158
|
+
writeAtomic(join(resDir(root), `${id}.json`), JSON.stringify(body));
|
|
159
|
+
}
|
|
160
|
+
/** The requests waiting now, oldest first - each read and removed (a request is taken once). */
|
|
161
|
+
function takeRequests(root) {
|
|
162
|
+
let names;
|
|
163
|
+
try {
|
|
164
|
+
names = readdirSync(reqDir(root)).filter((n) => n.endsWith(".json"));
|
|
165
|
+
} catch {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
const out = [];
|
|
169
|
+
for (const n of names) {
|
|
170
|
+
const file = join(reqDir(root), n);
|
|
171
|
+
let raw = null;
|
|
172
|
+
let t = 0;
|
|
173
|
+
try {
|
|
174
|
+
t = statSync(file).mtimeMs;
|
|
175
|
+
raw = JSON.parse(readFileSync(file, "utf8"));
|
|
176
|
+
} catch {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
rmSync(file, { force: true });
|
|
180
|
+
out.push({
|
|
181
|
+
file,
|
|
182
|
+
raw,
|
|
183
|
+
t
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
return out.sort((a, b) => a.t - b.t);
|
|
187
|
+
}
|
|
188
|
+
/** Requests and answers nobody came back for. */
|
|
189
|
+
function sweep(root, now = Date.now()) {
|
|
190
|
+
for (const dir of [reqDir(root), resDir(root)]) {
|
|
191
|
+
let names;
|
|
192
|
+
try {
|
|
193
|
+
names = readdirSync(dir);
|
|
194
|
+
} catch {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
for (const n of names) try {
|
|
198
|
+
if (now - statSync(join(dir, n)).mtimeMs > KEEP_MS) rmSync(join(dir, n), { force: true });
|
|
199
|
+
} catch {}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
//#endregion
|
|
203
|
+
export { answer, reqDir, request, sweep, takeRequests, verify };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as NAME } from "./cli.mjs";
|
|
2
|
-
import { i as readDevInfo, n as WORK_TTL_MAX, t as WORK_TTL_DEFAULT } from "./work-
|
|
3
|
-
import { unreachable } from "./link-
|
|
2
|
+
import { i as readDevInfo, n as WORK_TTL_MAX, t as WORK_TTL_DEFAULT } from "./work-DJxH7cCX.mjs";
|
|
3
|
+
import { unreachable } from "./link-BFFRgrMt.mjs";
|
|
4
4
|
//#region src/cli/work.ts
|
|
5
5
|
/**
|
|
6
6
|
* `marver work` - the coding agent's hand on the canvas working state.
|
|
@@ -68,7 +68,7 @@ async function workCommand(root, action, frames, opts) {
|
|
|
68
68
|
});
|
|
69
69
|
console.log(active.length ? `still working: ${active.join(", ")}` : "nothing working - all clear");
|
|
70
70
|
const done = before.filter((f) => !active.includes(f));
|
|
71
|
-
const { links, hints } = done.length ? await (await import("./link-
|
|
71
|
+
const { links, hints } = done.length ? await (await import("./link-BFFRgrMt.mjs")).handBack(root, done) : {
|
|
72
72
|
links: [],
|
|
73
73
|
hints: []
|
|
74
74
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { c as listBoardFiles } from "./boards-EH2onUXM.mjs";
|
|
3
3
|
import { r as pidRuns } from "./exclusive-B1RtpeeP.mjs";
|
|
4
4
|
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|
|
@@ -99,6 +99,17 @@ new when you do; everything already there the first time counts as seen. They li
|
|
|
99
99
|
`design/.local/`, on this machine only, and a published canvas shows none. `npx marver marks` prints
|
|
100
100
|
them - for you, or for your agent at the start of a session.
|
|
101
101
|
|
|
102
|
+
**In the Mac app** (0.3, with Marver 0.29), each canvas's tab sums this up, even while it is hidden: an
|
|
103
|
+
orange count of what needs you - Marver's questions, captures to review, runs that failed or stalled -
|
|
104
|
+
else a blue count of new frames, else a shimmer while an agent works, and a teal dot while a Jam session
|
|
105
|
+
runs. Turn notices on and a canvas you are not looking at sends one when something new needs you, and the
|
|
106
|
+
Dock counts them all. Clicking a notice opens what it names where you can see it, on its board: a question
|
|
107
|
+
in its thread on the frame (Play left and hidden pins shown for it), or in a panel with a field to answer
|
|
108
|
+
when no frame on the board holds it; a review in its review; a failed run with Retry in view, a stalled
|
|
109
|
+
one with its three choices (a stalled capture's or Jam session's on its tile in the lane, on the board you are on). On a
|
|
110
|
+
board locked to play, Play stays and the thread opens over it; a resolved thread opens read-only. It moves
|
|
111
|
+
nothing while you are capturing or have typed words not yet sent.
|
|
112
|
+
|
|
102
113
|
## Edits land calmly
|
|
103
114
|
|
|
104
115
|
When a file changes, the canvas reloads only the frames that read it, a few at a time, the ones on
|