@marver-design/marver 0.30.1 → 0.32.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 +70 -0
- package/README.md +12 -8
- package/dist/{anchor-check-Bv4o-R2T.mjs → anchor-check-DZtX13ly.mjs} +1 -1
- package/dist/{board-tree-BXR8dw4b.mjs → board-tree-DGj0HhEE.mjs} +6 -2
- package/dist/{boards-EH2onUXM.mjs → boards-Cim1GTKc.mjs} +32 -2
- package/dist/{boards-BeWtjGUM.mjs → boards-jHmEPLV7.mjs} +7 -7
- package/dist/{build-zWGXSzly.mjs → build-D2dHEWX-.mjs} +14 -17
- package/dist/{capture-DEtM4qm5.mjs → capture-HaS-1or8.mjs} +1 -1
- package/dist/cli.mjs +38 -20
- package/dist/{collab-BEAcXrBb.mjs → collab-D2NcrOB8.mjs} +53 -14
- package/dist/comment-actions-Bxf9Ld4g.mjs +351 -0
- package/dist/{comments-XNhMmSSu.mjs → comments-ocvsnt2j.mjs} +85 -10
- package/dist/config-B0YcFtqS.mjs +510 -0
- package/dist/{context-BUnFiyA3.mjs → context-Cj2TcC0H.mjs} +3 -3
- package/dist/{daemon-CChgWJNq.mjs → daemon-D6TrdgMi.mjs} +268 -28
- package/dist/deep-link-DYtuT740.mjs +163 -0
- package/dist/{dev-DOgIITpT.mjs → dev-DMQYbw-2.mjs} +23 -16
- package/dist/devices-uJZ2inMq.mjs +155 -0
- package/dist/{events-CLH4ijKP.mjs → events-Dieo1482.mjs} +49 -4
- package/dist/{init-CYlFaRzG.mjs → init-BgusplYn.mjs} +40 -10
- package/dist/{jam-Cj5gBvwD.mjs → jam-CkuLL8A8.mjs} +1 -1
- package/dist/{link-BFFRgrMt.mjs → link-aZq5cExV.mjs} +54 -7
- package/dist/{logo-CXY-1yrn.mjs → logo-C9s7-Cy9.mjs} +89 -66
- package/dist/{ls-NqmePKOf.mjs → ls-DGVIW-Io.mjs} +1 -1
- package/dist/{manifest-DPZ3WNg_.mjs → manifest-CK8Qh4Nq.mjs} +255 -13
- package/dist/{marks-BnNANic9.mjs → marks-C8oX8kbE.mjs} +3 -3
- package/dist/{marks-DBp3h1Mc.mjs → marks-Dt-5JXCp.mjs} +18 -5
- package/dist/{marver-id-gate-vBLb_Icb.mjs → marver-id-gate-BAeuMeaU.mjs} +11 -7
- package/dist/md-B9_13Q0R.mjs +105 -0
- package/dist/notes-CRAX4wgk.mjs +148 -0
- package/dist/own-C8Mq0Hnf.mjs +128 -0
- package/dist/pdf-Cf9GIoIM.mjs +2299 -0
- package/dist/pdf-HB0prF75.mjs +117 -0
- package/dist/{perf-6MOTHxay.mjs → perf-9ZEF5KLO.mjs} +5 -5
- package/dist/{perf-BCxAo0IS.mjs → perf-BA_NDarr.mjs} +2 -1
- package/dist/{plugin-CFWBcAba.mjs → plugin-DesQP9L5.mjs} +565 -107
- package/dist/{poster-DPPpQiva.mjs → poster-Bb6WraCA.mjs} +1 -1
- package/dist/{profile-B1FKOM1e.mjs → profile-cdmSer1k.mjs} +1 -1
- package/dist/{publish-bakes-_Zx8crP3.mjs → publish-bakes-EjMmukJB.mjs} +3 -3
- package/dist/{queue-DeSQm24g.mjs → queue-BLLfdlDw.mjs} +156 -11
- package/dist/{recover-mDUVsnPd.mjs → recover-B3dmatx4.mjs} +2 -2
- package/dist/{serve-DQv3Ti6X.mjs → serve-kcF6-H8V.mjs} +4 -4
- package/dist/{session-VDJfXEEm.mjs → session-DBF-nQvq.mjs} +29 -3
- package/dist/{share-Bu_kuOKL.mjs → share-CS2mg27O.mjs} +1 -1
- package/dist/{shot-d4h_hJi9.mjs → shot-Bjt2MQe3.mjs} +4 -4
- package/dist/{shot-DBWN8hPP.mjs → shot-BuUCG46-.mjs} +1 -1
- package/dist/show-DhmiUu01.mjs +101 -0
- package/dist/{sizes-wjXDev3b.mjs → sizes-BckcL4Zz.mjs} +1 -1
- package/dist/{slots-Dn4Onb0V.mjs → slots-BOcfIqxy.mjs} +15 -3
- package/dist/{summary-Y8MY1Wuc.mjs → summary-cPmRDGpX.mjs} +1 -1
- package/dist/{sync-CMozOwZ0.mjs → sync-BNWwh8OF.mjs} +205 -7
- package/dist/{work-DJxH7cCX.mjs → work-B4tydWnf.mjs} +38 -2
- package/dist/{work-BYWD_1Zf.mjs → work-CzIXp7n1.mjs} +3 -3
- package/docs/app.md +143 -6
- package/docs/boards-and-folders.md +41 -7
- package/docs/jam-session.md +5 -0
- package/docs/live-jam.md +9 -0
- package/docs/pdf.md +108 -0
- package/docs/publish.md +9 -9
- package/docs/sharing.md +11 -0
- package/docs/slides.md +11 -1
- package/package.json +3 -1
- package/src/client/content/index.tsx +4 -2
- package/src/client/frame-host/main.tsx +3 -0
- package/src/client/shell/App.tsx +71 -24
- package/src/client/shell/BoardList.tsx +16 -7
- package/src/client/shell/Comments.tsx +77 -16
- package/src/client/shell/Play.tsx +104 -27
- package/src/client/shell/Toolbar.tsx +4 -3
- package/src/client/shell/app-bridge.ts +40 -5
- package/src/client/shell/canvas/Canvas.tsx +30 -8
- package/src/client/shell/canvas/FrameNode.tsx +3 -1
- package/src/client/shell/canvas/ctl.ts +16 -0
- package/src/client/shell/commands.ts +20 -0
- package/src/client/shell/comments-store.ts +81 -2
- package/src/client/shell/devices.tsx +42 -0
- package/src/client/shell/goto.ts +56 -9
- package/src/client/shell/icons.tsx +11 -4
- package/src/client/shell/immersive.ts +123 -0
- package/src/client/shell/inset.ts +29 -3
- package/src/client/shell/jam-lines.ts +5 -3
- package/src/client/shell/jam-panel.tsx +17 -5
- package/src/client/shell/marks-ui.tsx +54 -0
- package/src/client/shell/notes.ts +21 -0
- package/src/client/shell/pdf-export.tsx +154 -0
- package/src/client/shell/pdf-notes.ts +20 -0
- package/src/client/shell/recorder-signals.ts +5 -2
- package/src/client/shell/show.ts +250 -0
- package/src/client/shell/store.ts +23 -38
- package/src/client/shell/styles.css +68 -6
- package/src/shared/app-api.ts +90 -4
- package/src/shared/auto-place.ts +32 -0
- package/src/shared/board-tree.ts +3 -0
- package/src/shared/board-types.ts +6 -2
- package/src/shared/deep-link.ts +212 -0
- package/src/shared/devices.ts +89 -0
- package/src/shared/events.ts +48 -5
- package/src/shared/export-plan.ts +98 -0
- package/src/shared/immersive.ts +13 -0
- package/src/shared/perf-records.ts +1 -1
- package/templates/AGENTS-embedded.md +76 -12
- package/templates/AGENTS-studio.md +76 -12
- package/templates/instructions/boards.md +6 -5
- package/templates/instructions/configure.md +32 -2
- package/templates/instructions/iterate.md +8 -0
- package/templates/instructions/jam.md +9 -0
- package/templates/instructions/publish.md +14 -4
- package/templates/instructions/review.md +4 -0
- package/templates/instructions/slides.md +67 -1
- package/templates/instructions/welcome.md +9 -5
- package/templates/playbooks/publish-canvas/PLAYBOOK.md +1 -1
- package/dist/config-BezZTiov.mjs +0 -182
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { l as toFrameId } from "./manifest-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { l as toFrameId } from "./manifest-CK8Qh4Nq.mjs";
|
|
2
|
+
import { o as workActivity } from "./work-B4tydWnf.mjs";
|
|
3
|
+
import { a as replay } from "./events-Dieo1482.mjs";
|
|
4
4
|
import { a as readLog, t as appendEvents } from "./comments-0BSbb04K.mjs";
|
|
5
|
-
import { n as localProfile } from "./profile-
|
|
5
|
+
import { n as localProfile } from "./profile-cdmSer1k.mjs";
|
|
6
6
|
import { i as onPath, t as AGENT_BIN } from "./agent-BsieQGTD.mjs";
|
|
7
7
|
import { r as uncheckedAnchor } from "./anchor-5H1vnoLu.mjs";
|
|
8
8
|
import { S as writeOffers, _ as readPrefs, f as patchConn, g as readOffers, h as readConn, l as listConns, m as pingLine, n as closeConn, o as eligible, p as pidAlive, r as connDir, t as alive } from "./conn-BMiHS42T.mjs";
|
|
9
9
|
import { hookBin } from "./connectors-DekQvKt9.mjs";
|
|
10
10
|
import { answer, reqDir, sweep, takeRequests, verify } from "./transport-C5FnY9ni.mjs";
|
|
11
11
|
import { i as record, t as has } from "./ledger-D54iROST.mjs";
|
|
12
|
-
import { C as refusedAsk, S as parseMembers, T as sharedWhy, _ as wordsUntil, a as checkRecord, b as packetPath, c as firstPoint, d as packetPictures, f as picturePath, g as wordsSince, h as storeCapture, m as requestWords, n as captureFrames, o as continues, p as readCapture, r as captureWords, t as CAPTURE_ID, u as madeOf, v as buildPacket, w as sanitize, x as parseAgentText, y as goalText } from "./capture-
|
|
13
|
-
import { a as recordFile, c as storeWrapup, i as readWrapup, n as buildWrapup, o as recordPathProblem, r as moreOf, t as SESSION_ID } from "./session-
|
|
14
|
-
import { act, addCapture, addWrapup, answeredSince, beginStep, captureComment, captureIntact, conflictStep, createQueue, ctxFor, endSession, endStep, fail, failCard, form, joinAlone, looksGood, moreWrapup,
|
|
15
|
-
import { d as logJam } from "./perf-
|
|
16
|
-
import { i as jamLive } from "./plugin-
|
|
12
|
+
import { C as refusedAsk, S as parseMembers, T as sharedWhy, _ as wordsUntil, a as checkRecord, b as packetPath, c as firstPoint, d as packetPictures, f as picturePath, g as wordsSince, h as storeCapture, m as requestWords, n as captureFrames, o as continues, p as readCapture, r as captureWords, t as CAPTURE_ID, u as madeOf, v as buildPacket, w as sanitize, x as parseAgentText, y as goalText } from "./capture-HaS-1or8.mjs";
|
|
13
|
+
import { a as recordFile, c as storeWrapup, i as readWrapup, l as wrapupWithoutDeleted, n as buildWrapup, o as recordPathProblem, r as moreOf, t as SESSION_ID } from "./session-DBF-nQvq.mjs";
|
|
14
|
+
import { act, addCapture, addWrapup, answeredSince, beginStep, captureComment, captureIntact, conflictStep, createQueue, ctxFor, deletedEvents, dropDeleted, endSession, endStep, fail, failCard, form, joinAlone, liveThreads, looksGood, moreWrapup, ownerOnly, payloadKey, pending, prune, r as releaseLock, redelivering, requeue, runsAlone, sameComment, settle, startSession, stillOwned, t as acquireLock, textOf, tombstonesOf, undelivered, withdrawnCaptures, wrapupIntact, wrapupOf } from "./queue-BLLfdlDw.mjs";
|
|
15
|
+
import { d as logJam } from "./perf-BA_NDarr.mjs";
|
|
16
|
+
import { i as jamLive } from "./plugin-DesQP9L5.mjs";
|
|
17
17
|
import { t as PROTECTED_GLOBS } from "./permit-DDa6wqOs.mjs";
|
|
18
18
|
import { jamReservations, restoreHolds } from "./reserve-BURNQ2Y3.mjs";
|
|
19
|
+
import { recordOwn } from "./own-C8Mq0Hnf.mjs";
|
|
19
20
|
import { closeSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, realpathSync, rmSync, statSync, watch, writeFileSync } from "node:fs";
|
|
20
21
|
import { basename, dirname, isAbsolute, join, relative, sep } from "node:path";
|
|
21
22
|
import { fileURLToPath } from "node:url";
|
|
@@ -1101,7 +1102,9 @@ const STALL_MS = 9e5;
|
|
|
1101
1102
|
* MARVER_SLOT_BASE set (test-build.ts; as perf-run.ts's MV_PERF_RUN_T): a real stall in seconds, so a browser case
|
|
1102
1103
|
* drives one through this daemon and the page's own actions. */
|
|
1103
1104
|
const stallMs = () => {
|
|
1104
|
-
return STALL_MS;
|
|
1105
|
+
if (!process.env.MARVER_SLOT_BASE) return STALL_MS;
|
|
1106
|
+
const v = Number(process.env.MV_JAM_STALL_MS);
|
|
1107
|
+
return Number.isFinite(v) && v > 0 ? v : STALL_MS;
|
|
1105
1108
|
};
|
|
1106
1109
|
/** How long a request's answer is kept for the same request sent again. */
|
|
1107
1110
|
const RECEIPT_MS = 6e5;
|
|
@@ -1232,7 +1235,14 @@ function createRuns(d) {
|
|
|
1232
1235
|
/** What a run is called in a ping: its card's name, else the owner's words (a capture's first words - its name comes later), clipped. */
|
|
1233
1236
|
const titleOf = (b) => {
|
|
1234
1237
|
const c = q.j.cards.find((x) => x.id === b.members[0]?.card);
|
|
1235
|
-
const
|
|
1238
|
+
const m0 = b.members[0];
|
|
1239
|
+
const g = m0 ? d.gone?.(m0.board) : void 0;
|
|
1240
|
+
const off = !!c && (c.kind === "capture" || !!c.capture) && !!m0 && !!d.withdrawn?.().has(c.kind === "capture" ? c.id : c.capture);
|
|
1241
|
+
const brief0 = off ? {
|
|
1242
|
+
...m0.brief,
|
|
1243
|
+
capture: void 0
|
|
1244
|
+
} : m0?.brief;
|
|
1245
|
+
const words = c?.name ?? (off ? void 0 : c?.autoName) ?? brief0?.asks?.find((a) => !g?.has(a.id))?.body ?? (brief0?.capture ? requestWords(brief0.capture, " ") || void 0 : void 0) ?? (c?.kind === "wrapup" ? "Session record" : "a request");
|
|
1236
1246
|
const t = sanitize(String(words), 400).replace(/@marver\b/gi, "").replace(/\s+/g, " ").trim() || "a request";
|
|
1237
1247
|
const cps = [...t];
|
|
1238
1248
|
return cps.length > 60 ? `${cps.slice(0, 59).join("")}…` : t;
|
|
@@ -1678,6 +1688,7 @@ function createRuns(d) {
|
|
|
1678
1688
|
at: Date.now(),
|
|
1679
1689
|
progress: Date.now()
|
|
1680
1690
|
};
|
|
1691
|
+
b.runAt = b.claim.at;
|
|
1681
1692
|
const handle = handleOf(b, gen);
|
|
1682
1693
|
const o = {
|
|
1683
1694
|
ok: true,
|
|
@@ -2266,6 +2277,13 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
2266
2277
|
const activeChildren = /* @__PURE__ */ new Set();
|
|
2267
2278
|
const running = /* @__PURE__ */ new Map();
|
|
2268
2279
|
const runningBatches = /* @__PURE__ */ new Map();
|
|
2280
|
+
/** spec 32 F2: background runs whose runner is set and that wait for a process slot (jam.concurrency): not at work yet */
|
|
2281
|
+
const slotWaiting = /* @__PURE__ */ new Set();
|
|
2282
|
+
/** spec 32 F2: batches set to run that have not begun yet - formed (their cards are `working` already), taking their
|
|
2283
|
+
* pictures before, recovered at boot, or choosing a runner. A session's claim begins one (`claim.at`); a background
|
|
2284
|
+
* one leaves for `slotWaiting` as its runner is set. Never at work meanwhile, and never read as an older batch with
|
|
2285
|
+
* no `runAt` (Codex's round-3 review: a new batch's preparation was counted, then its start jumped at execution) */
|
|
2286
|
+
const preparing = /* @__PURE__ */ new Set();
|
|
2269
2287
|
/** every run that starts, counted: a run knows whether another began while it ran */
|
|
2270
2288
|
let batchStarts = 0;
|
|
2271
2289
|
const runAgent = (ad, opts, goal, onSpawn, onEarly) => new Promise((resolve) => {
|
|
@@ -2441,6 +2459,11 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
2441
2459
|
} catch {
|
|
2442
2460
|
packet = null;
|
|
2443
2461
|
}
|
|
2462
|
+
if (packet) {
|
|
2463
|
+
const x = scrubDeleted(q.j, b, packet);
|
|
2464
|
+
if (x.changed) writeFileSync(join(root, packetPath(b.batchId)), JSON.stringify(packet, null, 1), { mode: 384 });
|
|
2465
|
+
if (!x.left) return `Everything this run asked for was deleted - nothing to do. Release it: \`npx marver jam release ${handle}${as ? ` --as ${as}` : ""}\`.`;
|
|
2466
|
+
}
|
|
2444
2467
|
if (packet && packet.frames.join("\n") !== b.frames.join("\n")) {
|
|
2445
2468
|
packet.frames = [...b.frames];
|
|
2446
2469
|
writeFileSync(join(root, packetPath(b.batchId)), JSON.stringify(packet, null, 1), { mode: 384 });
|
|
@@ -2452,6 +2475,8 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
2452
2475
|
}) : `The packet of this run is missing (${packetPath(b.batchId)}) - release it: \`npx marver jam release ${handle}${as ? ` --as ${as}` : ""}\`.`;
|
|
2453
2476
|
},
|
|
2454
2477
|
say: (b) => ensureEarly(b),
|
|
2478
|
+
gone: (board) => goneCached(board),
|
|
2479
|
+
withdrawn: () => withdrawnCaptures(q.j, commentsDir),
|
|
2455
2480
|
ready: () => ready,
|
|
2456
2481
|
jamOn: () => !!q.j.session,
|
|
2457
2482
|
canSpawn: (agent) => Object.hasOwn(AGENT_BIN, agent) && onPath(AGENT_BIN[agent]),
|
|
@@ -2494,6 +2519,115 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
2494
2519
|
frames: x.frames.filter((f) => b.frames.includes(f)),
|
|
2495
2520
|
title: runs.title(x)
|
|
2496
2521
|
}));
|
|
2522
|
+
/** Spec 31 C.5, at every hand-off: each message deleted since the claim is taken out of the run's briefs and its packet,
|
|
2523
|
+
* per message, history included; a tag's card with no request left is dropped, and the members left are numbered
|
|
2524
|
+
* from m1 again. Synchronous - the caller holds the queue lock (or is runs' goal, under it). `left`: the members left;
|
|
2525
|
+
* with none the caller ends the run (`ended`). The packet is changed in place; the caller writes it. */
|
|
2526
|
+
/** A board's deleted create and reply events, read now. */
|
|
2527
|
+
const goneOf = (board) => deletedEvents(readLog(commentsDir, board));
|
|
2528
|
+
/** the journal's captures whose own comment was deleted (by the card, never a field in a comment) */
|
|
2529
|
+
const capsNow = () => withdrawnCaptures(q.j, commentsDir);
|
|
2530
|
+
/** The words of a board's deleted More work replies, as a record keeps them (the tag gone) - for records sealed before 0.31 */
|
|
2531
|
+
const goneWords = (board) => {
|
|
2532
|
+
const log = readLog(commentsDir, board), g = deletedEvents(log);
|
|
2533
|
+
return new Set(log.filter((e) => e.id.startsWith("mw-") && g.has(e.id)).map((e) => (e.body ?? "").replace(/^@marver\s*/i, "").trim()));
|
|
2534
|
+
};
|
|
2535
|
+
/** ...and read again only when its log changed (titles are asked for on every view of the queue) */
|
|
2536
|
+
const goneSeen = /* @__PURE__ */ new Map();
|
|
2537
|
+
const goneCached = (board) => {
|
|
2538
|
+
let key = "";
|
|
2539
|
+
try {
|
|
2540
|
+
const st = statSync(join(commentsDir, `${board}.jsonl`));
|
|
2541
|
+
key = `${st.size}:${st.mtimeMs}`;
|
|
2542
|
+
} catch {
|
|
2543
|
+
return /* @__PURE__ */ new Set();
|
|
2544
|
+
}
|
|
2545
|
+
const hit = goneSeen.get(board);
|
|
2546
|
+
if (hit?.key === key) return hit.gone;
|
|
2547
|
+
const gone = goneOf(board);
|
|
2548
|
+
goneSeen.set(board, {
|
|
2549
|
+
key,
|
|
2550
|
+
gone
|
|
2551
|
+
});
|
|
2552
|
+
return gone;
|
|
2553
|
+
};
|
|
2554
|
+
function scrubDeleted(j, b, packet) {
|
|
2555
|
+
const gone = /* @__PURE__ */ new Map();
|
|
2556
|
+
const ts = tombstonesOf(j, commentsDir);
|
|
2557
|
+
const goneIn = (board) => {
|
|
2558
|
+
let g = gone.get(board);
|
|
2559
|
+
if (!g) gone.set(board, g = new Set(ts.gone(board)));
|
|
2560
|
+
return g;
|
|
2561
|
+
};
|
|
2562
|
+
const caps = ts.captures;
|
|
2563
|
+
let changed = false;
|
|
2564
|
+
for (const m of b.members) {
|
|
2565
|
+
const c = j.cards.find((x) => x.id === m.card);
|
|
2566
|
+
const g = goneIn(m.board);
|
|
2567
|
+
if (!c) continue;
|
|
2568
|
+
let lost = false;
|
|
2569
|
+
const brief = dropDeleted(m.brief, m.board, ts);
|
|
2570
|
+
if (brief !== m.brief) {
|
|
2571
|
+
m.brief = brief;
|
|
2572
|
+
c.brief = dropDeleted(c.brief, m.board, ts);
|
|
2573
|
+
changed = lost = true;
|
|
2574
|
+
}
|
|
2575
|
+
const pm = packet?.members.find((x) => x.card === m.card);
|
|
2576
|
+
if (pm && dropDeleted(pm.brief, m.board, ts) !== pm.brief) changed = lost = true;
|
|
2577
|
+
if (c.events.some((id) => g.has(id))) {
|
|
2578
|
+
c.events = c.events.filter((id) => !g.has(id));
|
|
2579
|
+
changed = lost = true;
|
|
2580
|
+
}
|
|
2581
|
+
const briefAsks = (m.brief ?? pm?.brief)?.asks.length ?? 0;
|
|
2582
|
+
const capGone = c.kind === "capture" && caps.has(c.id) && !c.events.length;
|
|
2583
|
+
if (c.state === "working" && (lost && c.kind === "comment" && (!c.events.length || !briefAsks) || capGone)) {
|
|
2584
|
+
c.state = "dropped";
|
|
2585
|
+
c.note = "deleted";
|
|
2586
|
+
c.rev += 1;
|
|
2587
|
+
c.at = Date.now();
|
|
2588
|
+
changed = true;
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
if (changed) {
|
|
2592
|
+
const survivors = b.members.filter((m) => j.cards.find((x) => x.id === m.card)?.state === "working");
|
|
2593
|
+
const ids = new Map(survivors.map((m, i) => [m.card, `m${i + 1}`]));
|
|
2594
|
+
b.members = survivors.map((m) => ({
|
|
2595
|
+
...m,
|
|
2596
|
+
id: ids.get(m.card)
|
|
2597
|
+
}));
|
|
2598
|
+
}
|
|
2599
|
+
if (packet) {
|
|
2600
|
+
const ids = new Map(b.members.map((m) => [m.card, m.id]));
|
|
2601
|
+
const next = packet.members.filter((x) => ids.has(x.card)).map((x) => {
|
|
2602
|
+
const brief = dropDeleted(x.brief, x.board, ts);
|
|
2603
|
+
return {
|
|
2604
|
+
...x,
|
|
2605
|
+
id: ids.get(x.card),
|
|
2606
|
+
brief: brief.wrapup ? {
|
|
2607
|
+
...brief,
|
|
2608
|
+
wrapup: {
|
|
2609
|
+
...brief.wrapup,
|
|
2610
|
+
content: wrapupWithoutDeleted(brief.wrapup.content, goneIn, goneWords, () => caps)
|
|
2611
|
+
}
|
|
2612
|
+
} : brief
|
|
2613
|
+
};
|
|
2614
|
+
});
|
|
2615
|
+
if (JSON.stringify(next) !== JSON.stringify(packet.members)) {
|
|
2616
|
+
packet.members = next;
|
|
2617
|
+
changed = true;
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
return {
|
|
2621
|
+
changed,
|
|
2622
|
+
left: b.members.length
|
|
2623
|
+
};
|
|
2624
|
+
}
|
|
2625
|
+
/** A run whose every request was deleted before its hand-off: done, nothing ran (under the lock). */
|
|
2626
|
+
const ended = (b) => {
|
|
2627
|
+
b.state = "done";
|
|
2628
|
+
b.at = Date.now();
|
|
2629
|
+
b.note = "its requests were deleted";
|
|
2630
|
+
};
|
|
2497
2631
|
/** A session's early line (`marver jam say`), journaled on the batch before it is posted: posted with the id it
|
|
2498
2632
|
* names, once - an id already in the log is not posted again (a restart between the two posts it then). */
|
|
2499
2633
|
const ensureEarly = (b) => {
|
|
@@ -2957,7 +3091,7 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
2957
3091
|
brief = {
|
|
2958
3092
|
...brief,
|
|
2959
3093
|
wrapup: {
|
|
2960
|
-
content: w.wrapup,
|
|
3094
|
+
content: wrapupWithoutDeleted(w.wrapup, goneOf, goneWords, capsNow),
|
|
2961
3095
|
hash: w.hash
|
|
2962
3096
|
}
|
|
2963
3097
|
};
|
|
@@ -3094,6 +3228,21 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
3094
3228
|
reanchors: []
|
|
3095
3229
|
};
|
|
3096
3230
|
try {
|
|
3231
|
+
if (!b.claim) {
|
|
3232
|
+
const r = await q.lock((j) => {
|
|
3233
|
+
const x = scrubDeleted(j, b, packet);
|
|
3234
|
+
if (!x.left) ended(b);
|
|
3235
|
+
if (x.changed || !x.left) q.persist();
|
|
3236
|
+
return x;
|
|
3237
|
+
});
|
|
3238
|
+
if (!r.left) {
|
|
3239
|
+
runs.delivered(b.batchId, false, "its requests were deleted");
|
|
3240
|
+
queueChanged();
|
|
3241
|
+
timeRun();
|
|
3242
|
+
return;
|
|
3243
|
+
}
|
|
3244
|
+
if (r.changed) writePacket();
|
|
3245
|
+
}
|
|
3097
3246
|
if (!b.power) {
|
|
3098
3247
|
const s0 = runs.settings();
|
|
3099
3248
|
await q.lock(() => {
|
|
@@ -3221,6 +3370,8 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
3221
3370
|
marver: marverCmd()
|
|
3222
3371
|
} : void 0;
|
|
3223
3372
|
await q.lock(() => {
|
|
3373
|
+
slotWaiting.add(b.batchId);
|
|
3374
|
+
preparing.delete(b.batchId);
|
|
3224
3375
|
b.runner = {
|
|
3225
3376
|
kind: ch.kind,
|
|
3226
3377
|
agent,
|
|
@@ -3234,12 +3385,28 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
3234
3385
|
queueChanged();
|
|
3235
3386
|
const permit = await takePermit();
|
|
3236
3387
|
try {
|
|
3388
|
+
await q.lock(() => {
|
|
3389
|
+
slotWaiting.delete(b.batchId);
|
|
3390
|
+
if (!stopped) {
|
|
3391
|
+
b.runAt = Date.now();
|
|
3392
|
+
q.persist();
|
|
3393
|
+
}
|
|
3394
|
+
});
|
|
3395
|
+
queueChanged();
|
|
3237
3396
|
while (!stopped && b.attempts < MAX_ATTEMPTS) {
|
|
3238
|
-
await q.lock(() => {
|
|
3397
|
+
if (!await q.lock((j) => {
|
|
3239
3398
|
b.attempts += 1;
|
|
3240
3399
|
b.leaseUntil = Date.now() + LEASE_MS;
|
|
3400
|
+
const x = scrubDeleted(j, b, packet);
|
|
3401
|
+
if (!x.left) ended(b);
|
|
3241
3402
|
q.persist();
|
|
3242
|
-
|
|
3403
|
+
return x.left;
|
|
3404
|
+
})) {
|
|
3405
|
+
runs.delivered(b.batchId, false, "its requests were deleted");
|
|
3406
|
+
queueChanged();
|
|
3407
|
+
timeRun();
|
|
3408
|
+
return;
|
|
3409
|
+
}
|
|
3243
3410
|
for (const m of packet.members) if (m.kind === "wrapup") {
|
|
3244
3411
|
const c = q.j.cards.find((x) => x.id === m.card);
|
|
3245
3412
|
const w = c && readWrapup(root, wrapupOf(c));
|
|
@@ -3247,7 +3414,7 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
3247
3414
|
m.brief = {
|
|
3248
3415
|
...m.brief,
|
|
3249
3416
|
wrapup: {
|
|
3250
|
-
content: w.wrapup,
|
|
3417
|
+
content: wrapupWithoutDeleted(w.wrapup, goneOf, goneWords, capsNow),
|
|
3251
3418
|
hash: w.hash
|
|
3252
3419
|
}
|
|
3253
3420
|
};
|
|
@@ -3299,6 +3466,7 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
3299
3466
|
if (run.ok) break;
|
|
3300
3467
|
}
|
|
3301
3468
|
} finally {
|
|
3469
|
+
slotWaiting.delete(b.batchId);
|
|
3302
3470
|
permit();
|
|
3303
3471
|
}
|
|
3304
3472
|
}
|
|
@@ -3423,6 +3591,7 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
3423
3591
|
}
|
|
3424
3592
|
if (!there) appendEvents(commentsDir, c.board, [p.event]);
|
|
3425
3593
|
record(root, c.board, p.event.id);
|
|
3594
|
+
if ((p.event.type === "create" || p.event.type === "reply") && !p.event.agent && p.event.commentId) recordOwn(root, c.board, [p.event.commentId]);
|
|
3426
3595
|
if (p.op === "confirm") record(root, c.board, payloadKey(c));
|
|
3427
3596
|
settled(endStep(j, c));
|
|
3428
3597
|
q.persist();
|
|
@@ -3707,7 +3876,10 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
3707
3876
|
});
|
|
3708
3877
|
prune(j);
|
|
3709
3878
|
if (moved() !== was) q.persist();
|
|
3710
|
-
for (const b of batches)
|
|
3879
|
+
for (const b of batches) {
|
|
3880
|
+
runningBatches.set(b.batchId, b);
|
|
3881
|
+
preparing.add(b.batchId);
|
|
3882
|
+
}
|
|
3711
3883
|
const now = performance.now();
|
|
3712
3884
|
for (const b of batches) batchWaits.set(b.batchId, new Map(b.members.flatMap((m) => {
|
|
3713
3885
|
const t = queuedSince.get(m.card);
|
|
@@ -3797,6 +3969,7 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
3797
3969
|
};
|
|
3798
3970
|
const launch = (b) => {
|
|
3799
3971
|
runningBatches.set(b.batchId, b);
|
|
3972
|
+
if (!b.results) preparing.add(b.batchId);
|
|
3800
3973
|
const p = (async () => {
|
|
3801
3974
|
try {
|
|
3802
3975
|
await runBatch(b);
|
|
@@ -3815,6 +3988,7 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
3815
3988
|
}
|
|
3816
3989
|
} finally {
|
|
3817
3990
|
if (!delivering.has(b.batchId)) runningBatches.delete(b.batchId);
|
|
3991
|
+
preparing.delete(b.batchId);
|
|
3818
3992
|
running.delete(b.batchId);
|
|
3819
3993
|
reserve();
|
|
3820
3994
|
try {
|
|
@@ -3857,8 +4031,15 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
3857
4031
|
return l;
|
|
3858
4032
|
};
|
|
3859
4033
|
const owned = (board, id) => ctx.owned.has(`${board}\t${id}`) && logOf(board).some((e) => e.id === id);
|
|
3860
|
-
const
|
|
3861
|
-
const
|
|
4034
|
+
const goneOf = /* @__PURE__ */ new Map();
|
|
4035
|
+
const ts = tombstonesOf(j, commentsDir);
|
|
4036
|
+
const gone = (board) => {
|
|
4037
|
+
let g = goneOf.get(board);
|
|
4038
|
+
if (!g) goneOf.set(board, g = deletedEvents(logOf(board)));
|
|
4039
|
+
return g;
|
|
4040
|
+
};
|
|
4041
|
+
const askOk = (board, a) => !gone(board).has(a.id) && stillOwned(ctx, board, logOf(board), a);
|
|
4042
|
+
const clean = (board, brief, comment) => !brief || !comment ? dropDeleted(brief, board, ts) : dropDeleted({
|
|
3862
4043
|
...brief,
|
|
3863
4044
|
asks: brief.asks.filter((a) => askOk(board, a)),
|
|
3864
4045
|
history: brief.history.map((m) => m.owner && !askOk(board, m) ? {
|
|
@@ -3872,7 +4053,7 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
3872
4053
|
...brief.follows,
|
|
3873
4054
|
asks: brief.follows.asks.filter((a) => askOk(board, a))
|
|
3874
4055
|
} } : {}
|
|
3875
|
-
};
|
|
4056
|
+
}, board, ts);
|
|
3876
4057
|
for (const m of b.members) {
|
|
3877
4058
|
const c = j.cards.find((x) => x.id === m.card);
|
|
3878
4059
|
if (!c) continue;
|
|
@@ -3888,11 +4069,11 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
3888
4069
|
const had = c.brief?.asks.length ?? 0;
|
|
3889
4070
|
c.brief = clean(c.board, c.brief, true);
|
|
3890
4071
|
m.brief = clean(m.board, m.brief, true);
|
|
3891
|
-
const events = c.events.filter((id) => owned(c.board, id));
|
|
4072
|
+
const events = c.events.filter((id) => owned(c.board, id) && !gone(c.board).has(id));
|
|
3892
4073
|
if (events.length !== c.events.length && (events.length || !comment)) c.events = events;
|
|
3893
4074
|
if (comment && (!events.length || had > 0 && !c.brief?.asks.length)) {
|
|
3894
4075
|
c.state = "dropped";
|
|
3895
|
-
c.note = "no longer authorized";
|
|
4076
|
+
c.note = c.events.some((id) => gone(c.board).has(id)) ? "deleted" : "no longer authorized";
|
|
3896
4077
|
c.rev += 1;
|
|
3897
4078
|
c.at = Date.now();
|
|
3898
4079
|
}
|
|
@@ -3938,13 +4119,17 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
3938
4119
|
q.persist();
|
|
3939
4120
|
return out;
|
|
3940
4121
|
});
|
|
3941
|
-
for (const { b } of leftover)
|
|
4122
|
+
for (const { b, results } of leftover) {
|
|
4123
|
+
runningBatches.set(b.batchId, b);
|
|
4124
|
+
if (!results) preparing.add(b.batchId);
|
|
4125
|
+
}
|
|
3942
4126
|
reserve();
|
|
3943
4127
|
for (const { b } of leftover.filter((x) => x.results)) {
|
|
3944
4128
|
await q.lock((j) => {
|
|
3945
4129
|
redelivering(j, b);
|
|
3946
4130
|
q.persist();
|
|
3947
4131
|
});
|
|
4132
|
+
const cardless = () => b.members.every((m) => !q.j.cards.some((c) => c.id === m.card));
|
|
3948
4133
|
for (let n = 1;; n++) {
|
|
3949
4134
|
const tDeliver = performance.now();
|
|
3950
4135
|
try {
|
|
@@ -3957,6 +4142,22 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
3957
4142
|
});
|
|
3958
4143
|
break;
|
|
3959
4144
|
} catch (err) {
|
|
4145
|
+
if (cardless()) {
|
|
4146
|
+
log(` jam: a recovered batch whose cards are gone could not be posted - ${err.message}; retired`);
|
|
4147
|
+
logJam(root, {
|
|
4148
|
+
kind: "run",
|
|
4149
|
+
batch: b.batchId,
|
|
4150
|
+
redelivered: true,
|
|
4151
|
+
failure: "delivery"
|
|
4152
|
+
});
|
|
4153
|
+
await q.lock(() => {
|
|
4154
|
+
b.state = "failed";
|
|
4155
|
+
b.at = Date.now();
|
|
4156
|
+
b.note = "its cards are gone";
|
|
4157
|
+
q.persist();
|
|
4158
|
+
});
|
|
4159
|
+
break;
|
|
4160
|
+
}
|
|
3960
4161
|
if (n >= 4 || stopped) {
|
|
3961
4162
|
log(` jam: could not post a recovered batch - ${err.message}; its cards fail, Retry posts them`);
|
|
3962
4163
|
logJam(root, {
|
|
@@ -4007,10 +4208,11 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
4007
4208
|
const moreAsks = (j, ctx, c) => {
|
|
4008
4209
|
if (!c.events.length) return [];
|
|
4009
4210
|
const log = readLog(commentsDir, c.board);
|
|
4211
|
+
const gone = deletedEvents(log);
|
|
4010
4212
|
const runs = [...c.ran ?? [], ...c.batch ? [c.batch] : []].map((id) => j.batches.find((b) => b.batchId === id)).filter((b) => !!b);
|
|
4011
4213
|
return c.events.filter((id) => id.startsWith("mw-")).flatMap((id) => {
|
|
4012
4214
|
const ev = log.find((e) => e.id === id);
|
|
4013
|
-
if (!ev || !ctx.owned.has(`${c.board}\t${id}`)) return [];
|
|
4215
|
+
if (!ev || gone.has(id) || !ctx.owned.has(`${c.board}\t${id}`)) return [];
|
|
4014
4216
|
const took = runs.flatMap((b) => {
|
|
4015
4217
|
const m = b.members.find((x) => x.card === c.id && x.brief?.asks.some((a) => a.id === id));
|
|
4016
4218
|
return m ? [{
|
|
@@ -4027,6 +4229,7 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
4027
4229
|
const failed = !answered && took.length > 0 && took.every(({ b }) => b.state === "done" || b.state === "failed");
|
|
4028
4230
|
return [{
|
|
4029
4231
|
ask,
|
|
4232
|
+
event: id,
|
|
4030
4233
|
...r && "body" in r ? { result: r.body } : failed ? { result: "(the run failed - not done)" } : {}
|
|
4031
4234
|
}];
|
|
4032
4235
|
});
|
|
@@ -4127,6 +4330,16 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
4127
4330
|
...c.session ? { session: c.session } : {},
|
|
4128
4331
|
...readWrapup(root, wrapupOf(c)) ? { file: readWrapup(root, wrapupOf(c)).wrapup.file } : {}
|
|
4129
4332
|
};
|
|
4333
|
+
if (withdrawnCaptures(q.j, commentsDir).has(c.id)) return {
|
|
4334
|
+
title: "Withdrawn capture",
|
|
4335
|
+
notes: 0,
|
|
4336
|
+
...c.name ? {
|
|
4337
|
+
named: true,
|
|
4338
|
+
name: c.name
|
|
4339
|
+
} : {},
|
|
4340
|
+
inRun: false,
|
|
4341
|
+
...c.session ? { session: c.session } : {}
|
|
4342
|
+
};
|
|
4130
4343
|
let t = titles.get(c.id);
|
|
4131
4344
|
if (!t) {
|
|
4132
4345
|
const rec = readCapture(root, c.id)?.record;
|
|
@@ -4203,8 +4416,20 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
4203
4416
|
...c.exclusive ? { exclusive: true } : {},
|
|
4204
4417
|
...c.kind !== "comment" ? captureView(c) : {},
|
|
4205
4418
|
...c.state === "working" ? (() => {
|
|
4206
|
-
const
|
|
4207
|
-
|
|
4419
|
+
const b = j.batches.find((x) => x.batchId === c.batch);
|
|
4420
|
+
const slot = !!b && slotWaiting.has(b.batchId);
|
|
4421
|
+
const unstarted = slot || !!b && preparing.has(b.batchId) && !b.claim;
|
|
4422
|
+
const r0 = runs.runnerOf(b);
|
|
4423
|
+
const r = r0 && slot ? {
|
|
4424
|
+
...r0,
|
|
4425
|
+
state: "waiting"
|
|
4426
|
+
} : r0;
|
|
4427
|
+
const startedAt = unstarted ? void 0 : b?.runAt ?? b?.claim?.at;
|
|
4428
|
+
return {
|
|
4429
|
+
...r ? { runner: r } : {},
|
|
4430
|
+
...typeof startedAt === "number" ? { startedAt } : {},
|
|
4431
|
+
...unstarted ? { unstarted: true } : {}
|
|
4432
|
+
};
|
|
4208
4433
|
})() : {}
|
|
4209
4434
|
};
|
|
4210
4435
|
}),
|
|
@@ -4232,6 +4457,7 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
4232
4457
|
return q.j;
|
|
4233
4458
|
},
|
|
4234
4459
|
view,
|
|
4460
|
+
busy: () => liveThreads(q.j, ctxFor(root)),
|
|
4235
4461
|
sealed: (id) => sourceIntact(id),
|
|
4236
4462
|
async session(op) {
|
|
4237
4463
|
if (!SESSION_ID.test(op.id)) return {
|
|
@@ -4536,10 +4762,22 @@ function startJam(root, cfg, log = () => {}, onChanged = () => {}, anchor, onQue
|
|
|
4536
4762
|
core.tick();
|
|
4537
4763
|
jamLive.poke = () => void core.poke();
|
|
4538
4764
|
jamLive.view = () => core.view();
|
|
4539
|
-
jamLive.
|
|
4540
|
-
jamLive.
|
|
4765
|
+
jamLive.busy = () => core.busy();
|
|
4766
|
+
jamLive.withdrawn = (id) => withdrawnCaptures(core.snapshot(), commentsDir).has(id);
|
|
4767
|
+
const asPage = (r) => {
|
|
4768
|
+
const id = r.card?.id;
|
|
4769
|
+
if (typeof id !== "string") return r;
|
|
4770
|
+
const { card: _c, ...rest } = r;
|
|
4771
|
+
const shown = core.view().cards.find((c) => c.id === id);
|
|
4772
|
+
return {
|
|
4773
|
+
...rest,
|
|
4774
|
+
...shown ? { card: shown } : {}
|
|
4775
|
+
};
|
|
4776
|
+
};
|
|
4777
|
+
jamLive.act = async (id, rev, action, body) => asPage(await core.act(id, rev, action, body));
|
|
4778
|
+
jamLive.capture = async (record) => asPage(await core.capture(record));
|
|
4541
4779
|
jamLive.sealed = (id) => core.sealed(id);
|
|
4542
|
-
jamLive.session = (op) => core.session(op);
|
|
4780
|
+
jamLive.session = async (op) => asPage(await core.session(op));
|
|
4543
4781
|
jamLive.record = (id) => core.record(id);
|
|
4544
4782
|
jamLive.canWrap = (id) => core.canWrap(id);
|
|
4545
4783
|
jamLive.captureOpen = (c, ses, on) => core.captureOpen(c, ses, on);
|
|
@@ -4563,6 +4801,8 @@ function startJam(root, cfg, log = () => {}, onChanged = () => {}, anchor, onQue
|
|
|
4563
4801
|
core.stop();
|
|
4564
4802
|
delete jamLive.poke;
|
|
4565
4803
|
delete jamLive.view;
|
|
4804
|
+
delete jamLive.busy;
|
|
4805
|
+
delete jamLive.withdrawn;
|
|
4566
4806
|
delete jamLive.act;
|
|
4567
4807
|
delete jamLive.capture;
|
|
4568
4808
|
jamReservations.frames.clear();
|