@marver-design/marver 0.25.1 → 0.26.1
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 +116 -0
- package/README.md +5 -3
- package/dist/{anchor-DVV732zR.mjs → anchor-5H1vnoLu.mjs} +6 -1
- package/dist/{anchor-check-DGZnYviN.mjs → anchor-check-l-ny3UzH.mjs} +1 -1
- package/dist/audio-Dw1lfMdb.mjs +443 -0
- package/dist/{auth-DdUKeVKt.mjs → auth-Dix8wrXV.mjs} +1 -1
- package/dist/{bake-BpxMZfij.mjs → bake-C-awKgLA.mjs} +1 -1
- package/dist/{boards-Csxj2WJn.mjs → boards-DYG22tOe.mjs} +2 -2
- package/dist/{build-DKaGhoVN.mjs → build-BDRiO_mP.mjs} +16 -9
- package/dist/capture-vadKjuCo.mjs +730 -0
- package/dist/cli.mjs +24 -18
- package/dist/{collab-gqNdScUE.mjs → collab-Dxg2trOK.mjs} +4 -3
- package/dist/{comments-Zoch254k.mjs → comments-0BSbb04K.mjs} +14 -3
- package/dist/{comments-pTLlhjh4.mjs → comments-BqXua-XL.mjs} +7 -7
- package/dist/{config-cKgZBRj0.mjs → config-Cf7EjAMf.mjs} +12 -1
- package/dist/{context-D2ugHqwO.mjs → context-HQ4Giw58.mjs} +1 -1
- package/dist/daemon-DL6Fwq6D.mjs +2569 -0
- package/dist/{dev-Diqx1Rt8.mjs → dev-Bw_qYWWq.mjs} +202 -18
- package/dist/dev-lock-DWSpa6nj.mjs +179 -0
- package/dist/{events-DnK_AnrW.mjs → events-CLH4ijKP.mjs} +14 -4
- package/dist/{init-DO4DhUt_.mjs → init-D8DtrK_F.mjs} +2 -2
- package/dist/{ledger-BNXW14Xw.mjs → ledger-D54iROST.mjs} +17 -1
- package/dist/{link-C-qUIuKU.mjs → link-BNzLvdhI.mjs} +2 -2
- package/dist/live-Cgzsicwi.mjs +4 -0
- package/dist/{manifest-DnAte_fB.mjs → manifest-Nl3KSVOk.mjs} +1 -1
- package/dist/{marks-koRsbHfe.mjs → marks-CKgzucHZ.mjs} +2 -2
- package/dist/{marks-DFuintmJ.mjs → marks-DyWMv_Z1.mjs} +23 -5
- package/dist/{marver-id-gate-DGANtVyC.mjs → marver-id-gate-BjF6v4bT.mjs} +4 -4
- package/dist/perf-C75MZ73h.mjs +167 -0
- package/dist/{perf-CCisg-ny.mjs → perf-DPbLGhhO.mjs} +1 -1
- package/dist/perf-jam-BU3TVrZu.mjs +239 -0
- package/dist/{plugin-dTF5reck.mjs → plugin-DkGmZs_r.mjs} +298 -38
- package/dist/{poster-D-zjYpgk.mjs → poster-BdtSKMDm.mjs} +2 -1
- package/dist/{profile-Do0nGkXO.mjs → profile-WU9qcbIo.mjs} +1 -1
- package/dist/{publish-bakes-C_9VZ-Mq.mjs → publish-bakes-9RzRToXV.mjs} +3 -3
- package/dist/queue-29ok5_eZ.mjs +1319 -0
- package/dist/reserve-BURNQ2Y3.mjs +53 -0
- package/dist/{rolldown-runtime-D7D4PA-g.mjs → rolldown-runtime-8H4AJuhK.mjs} +1 -0
- package/dist/{serve-wv2QWdxB.mjs → serve-C8rVheYk.mjs} +12 -12
- package/dist/session-BAaJsK5c.mjs +191 -0
- package/dist/{share-ScamJcks.mjs → share--oFJ1bCI.mjs} +2 -2
- package/dist/{shot-CUlmkqFX.mjs → shot-DQeR_Pfn.mjs} +339 -20
- package/dist/shot-XQV7HC9A.mjs +139 -0
- package/dist/speech-models-DomiLQcY.mjs +299 -0
- package/dist/speech-worker.mjs +354 -0
- package/dist/{summary-CrW88e3q.mjs → summary-Y8MY1Wuc.mjs} +2 -2
- package/dist/{sync-C3035OnJ.mjs → sync-DKk-yT1V.mjs} +9 -8
- package/dist/{work-GE88wb_3.mjs → work-F5u-twpJ.mjs} +28 -5
- package/dist/{work-CpJn1gwY.mjs → work-VvX_JIgl.mjs} +2 -2
- package/docs/jam-session.md +194 -0
- package/docs/live-jam.md +29 -3
- package/package.json +7 -1
- package/src/client/frame-host/bridge.js +20 -2
- package/src/client/frame-host/inspect.d.ts +4 -0
- package/src/client/frame-host/inspect.js +96 -6
- package/src/client/frame-host/keys.d.ts +6 -0
- package/src/client/frame-host/keys.js +59 -0
- package/src/client/frame-host/trail.d.ts +7 -0
- package/src/client/frame-host/trail.js +204 -0
- package/src/client/shell/App.tsx +52 -8
- package/src/client/shell/Comments.tsx +20 -6
- package/src/client/shell/JamSurface.tsx +346 -0
- package/src/client/shell/Play.tsx +32 -9
- package/src/client/shell/Tip.tsx +8 -3
- package/src/client/shell/Toolbar.tsx +5 -4
- package/src/client/shell/canvas/Canvas.tsx +12 -2
- package/src/client/shell/canvas/FrameNode.tsx +14 -4
- package/src/client/shell/comments-store.ts +23 -16
- package/src/client/shell/icons.tsx +17 -0
- package/src/client/shell/jam-capture.ts +1005 -0
- package/src/client/shell/jam-keys.ts +358 -0
- package/src/client/shell/jam-lane.tsx +249 -0
- package/src/client/shell/jam-lines.ts +115 -0
- package/src/client/shell/jam-panel.tsx +556 -0
- package/src/client/shell/jam-queue.ts +126 -0
- package/src/client/shell/jam-session.tsx +389 -0
- package/src/client/shell/jam-state.ts +103 -0
- package/src/client/shell/jam-surface-parts.tsx +106 -0
- package/src/client/shell/jam-ui.tsx +104 -0
- package/src/client/shell/jam-voice.ts +479 -0
- package/src/client/shell/sound.ts +22 -0
- package/src/client/shell/stage-size.ts +11 -0
- package/src/client/shell/store.ts +47 -17
- package/src/client/shell/styles.css +564 -2
- package/src/client/stage/main.tsx +18 -2
- package/src/shared/capture-frames.ts +41 -0
- package/src/shared/events.ts +19 -4
- package/src/shared/speech.ts +16 -0
- package/templates/AGENTS-embedded.md +10 -2
- package/templates/AGENTS-studio.md +10 -2
- package/templates/instructions/iterate.md +8 -6
- package/templates/instructions/jam.md +131 -59
- package/dist/daemon-Cl8KXGW4.mjs +0 -1523
- package/dist/perf-QJIWtTw1.mjs +0 -68
- package/dist/shot-jdO_B6Qw.mjs +0 -86
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
//#region src/server/jam/reserve.ts
|
|
4
|
+
/**
|
|
5
|
+
* One reservation table for every writer (spec 27, "One job per frame"). A jam batch reserves
|
|
6
|
+
* every frame its cards name; `marver work start` holds frames for a chat agent. A batch starts
|
|
7
|
+
* only when none of its frames is held, and `work start` on a frame a batch holds is refused - one
|
|
8
|
+
* table, both directions. An exclusive job (a shared file, a board-level comment) reserves the
|
|
9
|
+
* whole canvas: while it waits or runs, no new batch starts and no NEW hold is taken, but a hold
|
|
10
|
+
* that already exists may renew and end, so an agent mid-edit never loses it.
|
|
11
|
+
*
|
|
12
|
+
* The jam side lives in memory (the daemon re-forms it at boot from the journal); the CLI's holds
|
|
13
|
+
* are written to design/.local/work-holds.json with their expiry and restored at boot, before any
|
|
14
|
+
* batch is scheduled, so a hold taken before a restart still holds after it.
|
|
15
|
+
*/
|
|
16
|
+
/** One per process - the daemon writes it, the work route reads it. */
|
|
17
|
+
const jamReservations = {
|
|
18
|
+
frames: /* @__PURE__ */ new Map(),
|
|
19
|
+
exclusive: null
|
|
20
|
+
};
|
|
21
|
+
/** Why `work start` may not take `frame` now, or null. `holding`: the CLI already holds it (a
|
|
22
|
+
* renewal is always allowed). */
|
|
23
|
+
function refuseHold(frame, holding, r = jamReservations) {
|
|
24
|
+
if (holding) return null;
|
|
25
|
+
if (r.frames.has(frame)) return "Marver is working on this frame - try again when it is done";
|
|
26
|
+
if (r.exclusive) return "Marver is changing a shared file - try again when it is done";
|
|
27
|
+
if (r.settling) return "Marver is finishing a job - try again in a moment";
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const holdsFile = (root) => join(root, "design", ".local", "work-holds.json");
|
|
31
|
+
/** Write the CLI's unexpired holds (frame and expiry only). Best-effort and atomic. */
|
|
32
|
+
function saveHolds(root, activity) {
|
|
33
|
+
try {
|
|
34
|
+
mkdirSync(join(root, "design", ".local"), { recursive: true });
|
|
35
|
+
const tmp = `${holdsFile(root)}.tmp`;
|
|
36
|
+
writeFileSync(tmp, JSON.stringify(Object.fromEntries(activity.leases("cli"))), { mode: 384 });
|
|
37
|
+
renameSync(tmp, holdsFile(root));
|
|
38
|
+
} catch {}
|
|
39
|
+
}
|
|
40
|
+
/** Bring back the holds a previous server wrote - expired ones stay gone. */
|
|
41
|
+
function restoreHolds(root, activity) {
|
|
42
|
+
let n = 0;
|
|
43
|
+
try {
|
|
44
|
+
const v = JSON.parse(readFileSync(holdsFile(root), "utf8"));
|
|
45
|
+
for (const [frame, until] of Object.entries(v ?? {})) if (typeof until === "number" && until > Date.now()) {
|
|
46
|
+
activity.restore(frame, until, "cli");
|
|
47
|
+
n++;
|
|
48
|
+
}
|
|
49
|
+
} catch {}
|
|
50
|
+
return n;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { jamReservations, refuseHold, restoreHolds, saveHolds };
|
|
@@ -75,9 +75,9 @@ async function serve(root, portFlag) {
|
|
|
75
75
|
* accounts get in. Null when there is no roster to consult. */
|
|
76
76
|
let guestDoorOpen = null;
|
|
77
77
|
if (process.env.MARVER_DATA_DIR) {
|
|
78
|
-
const { collabHandler } = await import("./collab-
|
|
79
|
-
const { appendEvents, readLog } = await import("./comments-
|
|
80
|
-
const { dataDir } = await import("./comments-
|
|
78
|
+
const { collabHandler } = await import("./collab-Dxg2trOK.mjs");
|
|
79
|
+
const { appendEvents, readLog } = await import("./comments-0BSbb04K.mjs").then((n) => n.n);
|
|
80
|
+
const { dataDir } = await import("./comments-0BSbb04K.mjs").then((n) => n.n);
|
|
81
81
|
const dir = dataDir();
|
|
82
82
|
for (const seedDir of [join(root, "design", ".dist-seeds"), join(dist, "design", "comments")]) {
|
|
83
83
|
if (!existsSync(seedDir)) continue;
|
|
@@ -88,8 +88,8 @@ async function serve(root, portFlag) {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
collab = collabHandler(dir, dist);
|
|
91
|
-
const { loadStore, createInvite, normEmail, operatorUser, sessionUser } = await import("./auth-
|
|
92
|
-
const share = await import("./auth-
|
|
91
|
+
const { loadStore, createInvite, normEmail, operatorUser, sessionUser } = await import("./auth-Dix8wrXV.mjs").then((n) => n.r);
|
|
92
|
+
const share = await import("./auth-Dix8wrXV.mjs").then((n) => n.R);
|
|
93
93
|
const ceilings = share.ceilingsFromRights(meta.rights ?? {});
|
|
94
94
|
const admitted = (u) => !!u && share.entryAllowed(dir, u, ceilings);
|
|
95
95
|
guestDoorOpen = () => {
|
|
@@ -119,7 +119,7 @@ async function serve(root, portFlag) {
|
|
|
119
119
|
}
|
|
120
120
|
const cliToken = process.env.MARVER_CLI_TOKEN ?? "";
|
|
121
121
|
if (cliToken) {
|
|
122
|
-
const { cliTokenProblem } = await import("./auth-
|
|
122
|
+
const { cliTokenProblem } = await import("./auth-Dix8wrXV.mjs").then((n) => n.r);
|
|
123
123
|
if (!process.env.MARVER_DATA_DIR) {
|
|
124
124
|
console.error(`[${NAME}] MARVER_CLI_TOKEN needs MARVER_DATA_DIR - there are no accounts for it to act as otherwise.`);
|
|
125
125
|
process.exit(1);
|
|
@@ -147,10 +147,10 @@ async function serve(root, portFlag) {
|
|
|
147
147
|
console.error(`[${NAME}] MARVER_ID_ISSUER is set but MARVER_PUBLIC_ORIGIN is not.\n Every assertion is bound to this canvas's exact origin, and it cannot be\n inferred from request headers - a proxy can make any request look local.\n Set it to the origin people actually reach this canvas on:\n MARVER_PUBLIC_ORIGIN=https://canvas.example.com\n MARVER_PUBLIC_ORIGIN=http://localhost:${portFlag ?? (Number(process.env.PORT) || 4199)} (development)`);
|
|
148
148
|
process.exit(1);
|
|
149
149
|
}
|
|
150
|
-
const { marverIdHandler } = await import("./marver-id-gate-
|
|
151
|
-
const { dataDir } = await import("./comments-
|
|
150
|
+
const { marverIdHandler } = await import("./marver-id-gate-BjF6v4bT.mjs");
|
|
151
|
+
const { dataDir } = await import("./comments-0BSbb04K.mjs").then((n) => n.n);
|
|
152
152
|
const canvasName = humanName(meta.name);
|
|
153
|
-
const { ceilingsFromRights } = await import("./auth-
|
|
153
|
+
const { ceilingsFromRights } = await import("./auth-Dix8wrXV.mjs").then((n) => n.R);
|
|
154
154
|
idHandler = marverIdHandler(dataDir(), idIssuer, canvasName, meta.branding, ceilingsFromRights(meta.rights ?? {}));
|
|
155
155
|
}
|
|
156
156
|
if (idIssuer && process.env.MARVER_PASSWORD) console.log(` note: MARVER_ID_ISSUER and MARVER_PASSWORD are both set - the identity gate wins, the password is IGNORED`);
|
|
@@ -168,9 +168,9 @@ async function serve(root, portFlag) {
|
|
|
168
168
|
};
|
|
169
169
|
const gated = Boolean(verifier || idIssuer);
|
|
170
170
|
if (collab) {
|
|
171
|
-
const { ensureShare, reclampShare, ceilingsFromRights } = await import("./auth-
|
|
172
|
-
const { loadStore } = await import("./auth-
|
|
173
|
-
const { dataDir } = await import("./comments-
|
|
171
|
+
const { ensureShare, reclampShare, ceilingsFromRights } = await import("./auth-Dix8wrXV.mjs").then((n) => n.R);
|
|
172
|
+
const { loadStore } = await import("./auth-Dix8wrXV.mjs").then((n) => n.r);
|
|
173
|
+
const { dataDir } = await import("./comments-0BSbb04K.mjs").then((n) => n.n);
|
|
174
174
|
const dir = dataDir();
|
|
175
175
|
const ceilings = ceilingsFromRights(meta.rights ?? {});
|
|
176
176
|
const mode = idIssuer ? "private" : verifier ? "password" : "public";
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
+
import { f as readCapture } from "./capture-vadKjuCo.mjs";
|
|
3
|
+
import { appendFileSync, closeSync, existsSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, writeSync } from "node:fs";
|
|
4
|
+
import { dirname, join, relative, sep } from "node:path";
|
|
5
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
6
|
+
//#region src/server/jam/session.ts
|
|
7
|
+
/**
|
|
8
|
+
* The Jam session (spec 27, Part 5): `J` starts one, `J` again ends it with a wrap-up.
|
|
9
|
+
*
|
|
10
|
+
* While a session runs, the microphone is live and what is said BETWEEN captures - its talk - is kept in
|
|
11
|
+
* `design/.local/jam/sessions/<id>.jsonl` (local, never committed, sent to no agent unless you say so at
|
|
12
|
+
* the end). Every capture made in it carries the session.
|
|
13
|
+
*
|
|
14
|
+
* "Write the record" seals a wrap-up into `design/.local/jam/wrapups/<id>.json` - your instructions
|
|
15
|
+
* first, every confirmed capture of the session (its record, your edit, its card's state and reply), the
|
|
16
|
+
* kept ones (as kept), the verdicts, and the talk if you left that on - ledgered with its hash and checked
|
|
17
|
+
* again at claim, like a capture. Drafts and dropped captures are left out; tags are answered in their
|
|
18
|
+
* threads and are not in it. The agent writes the record to `context/sessions/<date>-<slug>.md` (or
|
|
19
|
+
* `design/sessions/` with no `context/`) and nothing else.
|
|
20
|
+
*/
|
|
21
|
+
var session_exports = /* @__PURE__ */ __exportAll({
|
|
22
|
+
SESSION_ID: () => SESSION_ID,
|
|
23
|
+
WRAPUP_ID: () => WRAPUP_ID,
|
|
24
|
+
appendTalk: () => appendTalk,
|
|
25
|
+
buildWrapup: () => buildWrapup,
|
|
26
|
+
moreOf: () => moreOf,
|
|
27
|
+
readTalk: () => readTalk,
|
|
28
|
+
readWrapup: () => readWrapup,
|
|
29
|
+
recordFile: () => recordFile,
|
|
30
|
+
recordPathProblem: () => recordPathProblem,
|
|
31
|
+
storeWrapup: () => storeWrapup,
|
|
32
|
+
talkMinutes: () => talkMinutes
|
|
33
|
+
});
|
|
34
|
+
const SESSION_ID = /^ses-\d{10,16}-[a-z0-9]{4,12}$/;
|
|
35
|
+
const WRAPUP_ID = /^wrap-\d{10,16}-[a-z0-9]{4,12}$/;
|
|
36
|
+
const jamDir = (root) => join(root, "design", ".local", "jam");
|
|
37
|
+
const sessionsDir = (root) => join(jamDir(root), "sessions");
|
|
38
|
+
const wrapupsDir = (root) => join(jamDir(root), "wrapups");
|
|
39
|
+
const hashOf = (s) => createHash("sha256").update(s).digest("hex");
|
|
40
|
+
/** Words said between captures: one line per phrase, appended to the session's transcript. */
|
|
41
|
+
function appendTalk(root, session, words) {
|
|
42
|
+
if (!SESSION_ID.test(session) || !words.length) return;
|
|
43
|
+
mkdirSync(sessionsDir(root), { recursive: true });
|
|
44
|
+
const line = {
|
|
45
|
+
at: words[0].at,
|
|
46
|
+
text: words.map((w) => w.w).join(" "),
|
|
47
|
+
words: words.map((w) => ({
|
|
48
|
+
w: w.w,
|
|
49
|
+
at: w.at
|
|
50
|
+
}))
|
|
51
|
+
};
|
|
52
|
+
appendFileSync(join(sessionsDir(root), `${session}.jsonl`), JSON.stringify(line) + "\n", { mode: 384 });
|
|
53
|
+
}
|
|
54
|
+
function readTalk(root, session) {
|
|
55
|
+
if (!SESSION_ID.test(session)) return [];
|
|
56
|
+
try {
|
|
57
|
+
return readFileSync(join(sessionsDir(root), `${session}.jsonl`), "utf8").split("\n").flatMap((l) => {
|
|
58
|
+
try {
|
|
59
|
+
const x = JSON.parse(l);
|
|
60
|
+
return typeof x?.text === "string" && Number.isFinite(x.at) ? [x] : [];
|
|
61
|
+
} catch {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
} catch {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** How long the talk runs, for the sheet ("26 min"): from its first line to its last. */
|
|
70
|
+
const talkMinutes = (talk) => talk.length ? Math.max(1, Math.round((talk[talk.length - 1].at - talk[0].at) / 6e4)) : 0;
|
|
71
|
+
/** The record's file: `context/sessions/<date>-<hhmm>-<session>.md`, or `design/sessions/` with no
|
|
72
|
+
* `context/` - the session's own id in it, so two sessions never write one file. */
|
|
73
|
+
function recordFile(root, since, session = "ses-0-session") {
|
|
74
|
+
const d = new Date(since);
|
|
75
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
76
|
+
const date = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
|
|
77
|
+
const tail = (/^ses-\d+-([a-z0-9]+)$/.exec(session)?.[1] ?? "session").slice(0, 12);
|
|
78
|
+
const name = `${date}-${pad(d.getHours())}${pad(d.getMinutes())}-session-${tail}.md`;
|
|
79
|
+
return existsSync(join(root, "context")) ? `context/sessions/${name}` : `design/sessions/${name}`;
|
|
80
|
+
}
|
|
81
|
+
/** Why a record path is not safe to write or read, or null: it must be a plain `.md` under
|
|
82
|
+
* `context/sessions/` or `design/sessions/`, and no part of it that exists - the folders or the file -
|
|
83
|
+
* may be a link (a link would send the agent's write, or the panel's read, somewhere else). */
|
|
84
|
+
function recordPathProblem(root, file) {
|
|
85
|
+
if (!/^(context|design)\/sessions\/[a-z0-9][a-z0-9-]*\.md$/.test(file)) return "not a session record path";
|
|
86
|
+
let rootReal;
|
|
87
|
+
try {
|
|
88
|
+
rootReal = realpathSync(root);
|
|
89
|
+
} catch {
|
|
90
|
+
return "the project folder is not there";
|
|
91
|
+
}
|
|
92
|
+
let at = root;
|
|
93
|
+
for (const part of file.split("/")) {
|
|
94
|
+
at = join(at, part);
|
|
95
|
+
let st;
|
|
96
|
+
try {
|
|
97
|
+
st = lstatSync(at);
|
|
98
|
+
} catch {
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
if (st.isSymbolicLink()) return `${relative(root, at)} is a link`;
|
|
102
|
+
}
|
|
103
|
+
let probe = join(root, file);
|
|
104
|
+
while (!existsSync(probe) && probe !== root) probe = dirname(probe);
|
|
105
|
+
try {
|
|
106
|
+
const real = realpathSync(probe);
|
|
107
|
+
if (real !== rootReal && !real.startsWith(rootReal + sep)) return "it leads outside the project";
|
|
108
|
+
} catch {
|
|
109
|
+
return "it cannot be checked";
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
/** What the wrap-up says of the session, at this moment ("as of"). */
|
|
114
|
+
function buildWrapup(j, root, o) {
|
|
115
|
+
const now = o.now ?? Date.now();
|
|
116
|
+
const caps = [];
|
|
117
|
+
for (const c of j.cards.filter((x) => x.kind === "capture" && x.session === o.session).sort((a, b) => a.made - b.made)) {
|
|
118
|
+
if (c.state === "draft" || c.state === "dropped" || c.state === "confirming") continue;
|
|
119
|
+
if (o.intact && !o.intact(c)) return { error: "a capture of the session changed after it was confirmed - capture it again, then write the record" };
|
|
120
|
+
const cap = readCapture(root, c.id);
|
|
121
|
+
if (!cap) return { error: "a capture of the session is gone - write the record again without it" };
|
|
122
|
+
const verdict = c.verdict;
|
|
123
|
+
caps.push({
|
|
124
|
+
id: c.id,
|
|
125
|
+
title: o.title?.(c) ?? c.name ?? c.id,
|
|
126
|
+
state: c.state,
|
|
127
|
+
...c.state === "kept" ? { kept: true } : {},
|
|
128
|
+
record: cap.record,
|
|
129
|
+
...c.payload?.edited !== void 0 ? { edited: c.payload.edited } : {},
|
|
130
|
+
...c.payload?.added?.length ? { added: c.payload.added } : {},
|
|
131
|
+
...o.reply?.(c) ? { reply: o.reply(c) } : {},
|
|
132
|
+
...verdict ? { verdict } : {},
|
|
133
|
+
...o.more?.(c).length ? { more: o.more(c) } : {}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
const talk = o.includeTalk ? readTalk(root, o.session) : void 0;
|
|
137
|
+
return {
|
|
138
|
+
format: "marver.jam.wrapup",
|
|
139
|
+
v: 1,
|
|
140
|
+
id: `wrap-${now}-${randomBytes(4).toString("hex").slice(0, 6)}`,
|
|
141
|
+
session: o.session,
|
|
142
|
+
since: o.since,
|
|
143
|
+
until: now,
|
|
144
|
+
instructions: o.instructions.slice(0, 2e4),
|
|
145
|
+
file: recordFile(root, o.since, o.session),
|
|
146
|
+
captures: caps,
|
|
147
|
+
tags: o.tags,
|
|
148
|
+
...talk ? { talk } : {}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/** More work on a record: the same content - its captures, talk and file - with your note, as a wrap-up of
|
|
152
|
+
* its own (sealed and ledgered like the first). */
|
|
153
|
+
function moreOf(prev, note, now = Date.now()) {
|
|
154
|
+
return {
|
|
155
|
+
...prev,
|
|
156
|
+
id: `wrap-${now}-${randomBytes(4).toString("hex").slice(0, 6)}`,
|
|
157
|
+
more: note.slice(0, 2e4)
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/** Seal a wrap-up once (a second store of the same id is refused). Returns its hash. */
|
|
161
|
+
function storeWrapup(root, w) {
|
|
162
|
+
mkdirSync(wrapupsDir(root), { recursive: true });
|
|
163
|
+
const file = join(wrapupsDir(root), `${w.id}.json`);
|
|
164
|
+
if (existsSync(file)) throw new Error("a wrap-up is already stored under this id");
|
|
165
|
+
const body = JSON.stringify(w);
|
|
166
|
+
const tmp = `${file}.${randomBytes(6).toString("hex")}.tmp`;
|
|
167
|
+
const fd = openSync(tmp, "w", 384);
|
|
168
|
+
try {
|
|
169
|
+
writeSync(fd, body);
|
|
170
|
+
fsyncSync(fd);
|
|
171
|
+
} finally {
|
|
172
|
+
closeSync(fd);
|
|
173
|
+
}
|
|
174
|
+
renameSync(tmp, file);
|
|
175
|
+
return hashOf(body);
|
|
176
|
+
}
|
|
177
|
+
/** A stored wrap-up and the hash of its bytes as they are now (changed after the seal: refused at claim). */
|
|
178
|
+
function readWrapup(root, id) {
|
|
179
|
+
if (!WRAPUP_ID.test(id)) return null;
|
|
180
|
+
try {
|
|
181
|
+
const body = readFileSync(join(wrapupsDir(root), `${id}.json`), "utf8");
|
|
182
|
+
return {
|
|
183
|
+
wrapup: JSON.parse(body),
|
|
184
|
+
hash: hashOf(body)
|
|
185
|
+
};
|
|
186
|
+
} catch {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
//#endregion
|
|
191
|
+
export { recordFile as a, storeWrapup as c, readWrapup as i, buildWrapup as n, recordPathProblem as o, moreOf as r, session_exports as s, SESSION_ID as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as NAME } from "./cli.mjs";
|
|
2
|
-
import { M as resolveAccess } from "./auth-
|
|
3
|
-
import { i as loadCollab } from "./sync-
|
|
2
|
+
import { M as resolveAccess } from "./auth-Dix8wrXV.mjs";
|
|
3
|
+
import { i as loadCollab } from "./sync-DKk-yT1V.mjs";
|
|
4
4
|
//#region src/cli/share.ts
|
|
5
5
|
/**
|
|
6
6
|
* `marver share <action>` - the roster from the terminal (01-sharing §9).
|