@fractalsynapse/dsh-chapters 0.2.59 → 0.2.60
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/docs/project-state.md +4 -0
- package/lib/client.js +184 -0
- package/lib/client.js.map +1 -1
- package/lib/commands.js +55 -8
- package/lib/commands.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/docs/project-state.md
CHANGED
|
@@ -1426,6 +1426,10 @@ three models swapped live at runtime, autorun uncapped; durable-log watching nam
|
|
|
1426
1426
|
mechanism. Open: #491/#462 await the still-undelivered scheduled cycle (cron ~10h late, past
|
|
1427
1427
|
pattern — dispatch fallback decided for tomorrow if absent); #456 Tier B remains the campaign day.
|
|
1428
1428
|
|
|
1429
|
+
## 0.2.60 cut (2026-11-27): the command reply row — invisible-card era ends plugin-side, plus the #588 gate trilogy
|
|
1430
|
+
|
|
1431
|
+
**Shipped:** #590 (PR #591): the dock row rendering every /chapters-* reply (server-recorded settings row, human-driven pulls, self-suppression when the host card exists, in-flight as running) — the maintainer's downtime complaint, ended. #588 (PR #589): the regression gates — host fold drift guard both ways (mutation-proved), durable round-trip stage, FAQ. Development record kept honest: the follow-wire channel was MEASURED dead (27 records, 0 command events) before merge, the exec-slash and dispatch-race bugs found by breadcrumb-driven reload legs (fourteen iterations), and the e2e now grades the reply-visible CONTRACT rather than my assumption about the channel. The row on the maintainer's exact host version is graded by the post-install live pass — recorded as pending, not claimed.
|
|
1432
|
+
|
|
1429
1433
|
## 0.2.59 cut (2026-11-27): honest attribution of provider failures + armed loops ride out transient offer failures
|
|
1430
1434
|
|
|
1431
1435
|
**Shipped:** #583 (PR #584): the shared llm-fold (full-length finish capture, host words surface in the plane row), the honest empty sentence, and the 60s/3m/9m re-decide ladder with one loud OFFER STALLED — unarmed stays single-attempt. CI needed a third attempt (attempts 1-2: rotating single-leg environment failures — revival stall, then a prompt-bar timing race on a loaded runner); all six suspect legs proven green locally on the branch first (prompt-off x2, prompt-revival, prompt x3). The release verifier executes both #583 proofs against the published tarball and was rehearsed against 0.2.58 to prove it discriminates. Context: this release is the precondition the maintainer set for the SAIP resume — no loop restart with known errors in the process.
|
package/lib/client.js
CHANGED
|
@@ -1440,6 +1440,183 @@ window.__ModuleLoader__.load({
|
|
|
1440
1440
|
if (res.ok !== true) return "";
|
|
1441
1441
|
return res.value?.result?.text ?? "";
|
|
1442
1442
|
}
|
|
1443
|
+
function excerptOf(text) {
|
|
1444
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
1445
|
+
return flat.length > 200 ? `${flat.slice(0, 200)}…` : flat;
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Does the host already render this reply? The probe runs BEFORE the row mounts (once per new
|
|
1449
|
+
* exchange), so an excerpt found in the document is the host's card, not our own echo. Absent
|
|
1450
|
+
* document (tests, odd hosts) reads as "not shown" — fail-visible, never fail-silent.
|
|
1451
|
+
*/
|
|
1452
|
+
function hostCardShowsReply(excerpt, doc) {
|
|
1453
|
+
if (excerpt === "") return false;
|
|
1454
|
+
const text = doc?.body?.innerText;
|
|
1455
|
+
if (typeof text !== "string") return false;
|
|
1456
|
+
return text.includes(excerpt.slice(0, 80));
|
|
1457
|
+
}
|
|
1458
|
+
function parseReplyRow(raw) {
|
|
1459
|
+
if (raw.trim() === "") return null;
|
|
1460
|
+
try {
|
|
1461
|
+
const p = JSON.parse(raw);
|
|
1462
|
+
if (typeof p.line !== "string" || p.line === "") return null;
|
|
1463
|
+
return {
|
|
1464
|
+
line: p.line,
|
|
1465
|
+
kind: p.kind ?? "success",
|
|
1466
|
+
text: p.text ?? "",
|
|
1467
|
+
seq: Number.isFinite(Date.parse(p.at ?? "")) ? Date.parse(p.at ?? "") : 1
|
|
1468
|
+
};
|
|
1469
|
+
} catch {
|
|
1470
|
+
return null;
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
const composerTextOf = () => {
|
|
1474
|
+
try {
|
|
1475
|
+
const el = document.querySelector("[data-composer-input]");
|
|
1476
|
+
if (el === null) return "";
|
|
1477
|
+
return "value" in el ? String(el.value ?? "") : el.innerText ?? "";
|
|
1478
|
+
} catch {
|
|
1479
|
+
return "";
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1482
|
+
function subscribeReply(exec, onReply) {
|
|
1483
|
+
let closed = false;
|
|
1484
|
+
const pullOnce = async () => {
|
|
1485
|
+
try {
|
|
1486
|
+
const raw = await exec("/chapters-reply last");
|
|
1487
|
+
const parsed = parseReplyRow(raw);
|
|
1488
|
+
if (closed) return true;
|
|
1489
|
+
console.info(`[client:chapters] command reply pull: ${String(raw.length)} chars, parsed=${String(parsed !== null)}`);
|
|
1490
|
+
if (parsed === null) return false;
|
|
1491
|
+
onReply(parsed);
|
|
1492
|
+
return true;
|
|
1493
|
+
} catch {
|
|
1494
|
+
return false;
|
|
1495
|
+
}
|
|
1496
|
+
};
|
|
1497
|
+
const pull = async (retry = false) => {
|
|
1498
|
+
if (await pullOnce()) return;
|
|
1499
|
+
if (!retry) return;
|
|
1500
|
+
for (let i = 0; i < 4; i += 1) {
|
|
1501
|
+
await new Promise((res) => setTimeout(res, 500));
|
|
1502
|
+
if (closed || await pullOnce()) return;
|
|
1503
|
+
}
|
|
1504
|
+
};
|
|
1505
|
+
pull();
|
|
1506
|
+
const onVis = () => {
|
|
1507
|
+
try {
|
|
1508
|
+
if (document.visibilityState === "visible") pull();
|
|
1509
|
+
} catch {}
|
|
1510
|
+
};
|
|
1511
|
+
try {
|
|
1512
|
+
document.addEventListener("visibilitychange", onVis);
|
|
1513
|
+
} catch {}
|
|
1514
|
+
let prior = composerTextOf();
|
|
1515
|
+
let observer;
|
|
1516
|
+
let attachTimer;
|
|
1517
|
+
const onComposerMutate = () => {
|
|
1518
|
+
const now = composerTextOf();
|
|
1519
|
+
if (/^\s*\/chapters[-a-z]*/i.test(prior) && now.trim() === "") {
|
|
1520
|
+
console.info("[client:chapters] command reply submit detected");
|
|
1521
|
+
pull(true);
|
|
1522
|
+
}
|
|
1523
|
+
prior = now;
|
|
1524
|
+
};
|
|
1525
|
+
const attachComposer = () => {
|
|
1526
|
+
try {
|
|
1527
|
+
const el = document.querySelector("[data-composer-input]");
|
|
1528
|
+
if (el === null) return false;
|
|
1529
|
+
observer = new MutationObserver(onComposerMutate);
|
|
1530
|
+
observer.observe(el, {
|
|
1531
|
+
childList: true,
|
|
1532
|
+
subtree: true,
|
|
1533
|
+
characterData: true,
|
|
1534
|
+
attributes: true
|
|
1535
|
+
});
|
|
1536
|
+
console.info("[client:chapters] command reply composer observer attached");
|
|
1537
|
+
return true;
|
|
1538
|
+
} catch {
|
|
1539
|
+
return true;
|
|
1540
|
+
}
|
|
1541
|
+
};
|
|
1542
|
+
if (!attachComposer()) {
|
|
1543
|
+
let attempts = 0;
|
|
1544
|
+
const retry = () => {
|
|
1545
|
+
if (closed || attempts >= 8 || attachComposer()) return;
|
|
1546
|
+
attempts += 1;
|
|
1547
|
+
attachTimer = setTimeout(retry, 2e3);
|
|
1548
|
+
};
|
|
1549
|
+
attachTimer = setTimeout(retry, 2e3);
|
|
1550
|
+
}
|
|
1551
|
+
return () => {
|
|
1552
|
+
closed = true;
|
|
1553
|
+
if (attachTimer !== void 0) clearTimeout(attachTimer);
|
|
1554
|
+
try {
|
|
1555
|
+
document.removeEventListener("visibilitychange", onVis);
|
|
1556
|
+
} catch {}
|
|
1557
|
+
observer?.disconnect();
|
|
1558
|
+
};
|
|
1559
|
+
}
|
|
1560
|
+
function CommandReplyRow(props) {
|
|
1561
|
+
const [reply, setReply] = (0, react.useState)(null);
|
|
1562
|
+
const [expanded, setExpanded] = (0, react.useState)(false);
|
|
1563
|
+
const [dismissedSeq, setDismissedSeq] = (0, react.useState)(null);
|
|
1564
|
+
(0, react.useEffect)(() => {
|
|
1565
|
+
console.info("[client:chapters] command reply row mounted");
|
|
1566
|
+
return subscribeReply(props.exec, setReply);
|
|
1567
|
+
}, [props.exec]);
|
|
1568
|
+
const excerpt = reply === null || reply.kind === "running" ? "" : excerptOf(reply.text);
|
|
1569
|
+
const [suppressed, setSuppressed] = (0, react.useState)(false);
|
|
1570
|
+
(0, react.useEffect)(() => {
|
|
1571
|
+
setExpanded(false);
|
|
1572
|
+
const sup = reply !== null && excerpt !== "" && hostCardShowsReply(excerpt, document);
|
|
1573
|
+
if (reply !== null) console.info(`[client:chapters] command reply render decision: seq=${String(reply.seq)} suppressed=${String(sup)}`);
|
|
1574
|
+
setSuppressed(sup);
|
|
1575
|
+
}, [reply?.seq, excerpt]);
|
|
1576
|
+
if (reply === null || reply.seq === dismissedSeq) return null;
|
|
1577
|
+
if (suppressed) return null;
|
|
1578
|
+
const color = reply.kind === "error" ? "var(--color-danger, #d33)" : reply.kind === "running" ? "var(--color-warning, #b80)" : "var(--color-fg-dimmed, #888)";
|
|
1579
|
+
return (0, react.createElement)("div", {
|
|
1580
|
+
"data-chapters-reply": "true",
|
|
1581
|
+
style: {
|
|
1582
|
+
display: "flex",
|
|
1583
|
+
gap: 8,
|
|
1584
|
+
alignItems: "center",
|
|
1585
|
+
fontSize: 12,
|
|
1586
|
+
padding: "4px 10px",
|
|
1587
|
+
borderLeft: `3px solid ${color}`,
|
|
1588
|
+
opacity: .92
|
|
1589
|
+
},
|
|
1590
|
+
title: reply.kind === "running" ? `${reply.line} — running` : `${reply.line} — ${reply.kind}`,
|
|
1591
|
+
onClick: () => {
|
|
1592
|
+
if (excerpt !== "") setExpanded((e) => !e);
|
|
1593
|
+
}
|
|
1594
|
+
}, (0, react.createElement)("span", { style: {
|
|
1595
|
+
fontFamily: "monospace",
|
|
1596
|
+
color
|
|
1597
|
+
} }, reply.kind === "running" ? `> ${reply.line} …` : `> ${reply.line}`), excerpt === "" ? null : (0, react.createElement)("span", { style: {
|
|
1598
|
+
color: "var(--color-fg, #ccc)",
|
|
1599
|
+
overflow: "hidden",
|
|
1600
|
+
textOverflow: "ellipsis",
|
|
1601
|
+
whiteSpace: expanded ? "pre-wrap" : "nowrap",
|
|
1602
|
+
maxWidth: "60ch",
|
|
1603
|
+
flex: 1
|
|
1604
|
+
} }, expanded ? reply.text : excerpt), (0, react.createElement)("button", {
|
|
1605
|
+
type: "button",
|
|
1606
|
+
"aria-label": "Dismiss command reply",
|
|
1607
|
+
style: {
|
|
1608
|
+
marginLeft: "auto",
|
|
1609
|
+
border: "none",
|
|
1610
|
+
background: "none",
|
|
1611
|
+
color,
|
|
1612
|
+
cursor: "pointer"
|
|
1613
|
+
},
|
|
1614
|
+
onClick: (ev) => {
|
|
1615
|
+
ev.stopPropagation();
|
|
1616
|
+
setDismissedSeq(reply.seq);
|
|
1617
|
+
}
|
|
1618
|
+
}, "×"));
|
|
1619
|
+
}
|
|
1443
1620
|
// src/client/index.ts
|
|
1444
1621
|
/**
|
|
1445
1622
|
* dsh-chapters client entry: the per-message door buttons.
|
|
@@ -1615,6 +1792,13 @@ window.__ModuleLoader__.load({
|
|
|
1615
1792
|
order: 30,
|
|
1616
1793
|
inject: (sessionId) => ({ exec: (line) => runCommandText(remote, sessionId, line) })
|
|
1617
1794
|
}, PromptDock));
|
|
1795
|
+
const disposeReplyRow = slots.inject("conversation.input.dock", () => slots.register({
|
|
1796
|
+
name: "conversation.input.dock",
|
|
1797
|
+
id: "chapters-command-reply",
|
|
1798
|
+
order: 31,
|
|
1799
|
+
inject: (sessionId) => ({ exec: (line) => runCommandText(remote, sessionId, line) })
|
|
1800
|
+
}, CommandReplyRow));
|
|
1801
|
+
console.info(`[client:chapters] command reply row registered: ${typeof disposeReplyRow}`);
|
|
1618
1802
|
}
|
|
1619
1803
|
exports.apply = apply;
|
|
1620
1804
|
exports.inject = inject;
|