notesoup 0.52.6 → 0.52.7
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/dist/plugins/claude/src/helper.js +34 -7
- package/dist/plugins/claude/src/history.d.ts +7 -2
- package/dist/plugins/claude/src/history.js +53 -22
- package/dist/plugins/claude/src/text.d.ts +5 -0
- package/dist/plugins/claude/src/text.js +12 -0
- package/dist/src/history/history.js +12 -11
- package/dist/src/tools/history.d.ts +5 -3
- package/dist/src/tools/history.js +9 -11
- package/dist/test/claude-history.test.js +135 -3
- package/dist/test/history.integration.test.js +26 -1
- package/docs/claude-code-mod.md +6 -2
- package/docs/tool-results.md +2 -2
- package/package.json +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +96 -39
- package/plugins/claude/src/helper.ts +34 -9
- package/plugins/claude/src/history.ts +54 -22
- package/plugins/claude/src/text.ts +13 -0
- package/plugins/paseo/OVERVIEW.md +6 -2
- package/plugins/paseo/client/brain-empty-card.tsx +3 -1
- package/plugins/paseo/client/brain-empty-transformer.ts +7 -14
- package/plugins/paseo/client/notes-op-transformer.ts +10 -18
- package/plugins/paseo/client/tool-result.ts +31 -0
- package/plugins/paseo/test/brain-empty.test.ts +24 -1
- package/plugins/paseo/test/fixtures/claude-tool-calls.ts +86 -0
- package/plugins/paseo/test/notes-op.test.ts +39 -1
- package/src/history/history.ts +12 -10
- package/src/tools/history.ts +14 -13
package/docs/claude-code-mod.md
CHANGED
|
@@ -24,9 +24,13 @@ The notes tools also serve subagent calls, using the same session identity and s
|
|
|
24
24
|
|
|
25
25
|
The active head comes from the main loop's successful `session.append` result UUID, including attachments and notices. On startup/resume, before such an append, the public API supplies no authoritative selected leaf: history explicitly refuses instead of assuming the last file row or `last-prompt.leafUuid` is current. The append result means the engine kept a row, but its disk write may lag; a head missing on disk is a retryable refusal, not permission to switch branches. Session end clears the binding; a new classic start rebinds it.
|
|
26
26
|
|
|
27
|
-
Seqs are allocated over first-occurrence persisted append order, before active-branch filtering: one address per logical message/attachment/notice and additional addresses for each tool use/result. Repeated UUID records do not allocate again. List pages skip empty user/assistant envelopes even with explicit roles, so tool-only and thinking-only rows do not crowd out dialogue; direct reads preserve those addresses and explicitly say when no visible text was recorded. Results pair by `tool_use_id`; pending calls remain unfinished, and a paired result's seq redirects to its call. Only text blocks and recorded attachment renderings become visible text; thinking and raw, unrendered attachment payloads are never exposed. Record types other than user, assistant, system and attachment are ignored, including future metadata, without allocating addresses or exposing payloads. If the selected branch requires a skipped record as an ancestor,
|
|
27
|
+
Seqs are allocated over first-occurrence persisted append order, before active-branch filtering: one address per logical message/attachment/notice and additional addresses for each tool use/result. Repeated UUID records do not allocate again. List pages skip empty user/assistant envelopes even with explicit roles, so tool-only and thinking-only rows do not crowd out dialogue; direct reads preserve those addresses and explicitly say when no visible text was recorded. Results pair by `tool_use_id`; pending calls remain unfinished, and a paired result's seq redirects to its call. Only text blocks and recorded attachment renderings become visible text; thinking and raw, unrendered attachment payloads are never exposed. Record types other than user, assistant, system and attachment are ignored, including future metadata, without allocating addresses or exposing payloads. If the selected branch requires a skipped record as an ancestor, that UUID is an ancestry gap, not a visible metadata event. Invalid supported message/block schemas, conflicting duplicates, session/sidechain mismatches, cycles and malformed committed JSONL lines still refuse explicitly. An incomplete final unterminated write is tolerated. Valid forward parent references are resolved after reading the snapshot, without reallocating addresses.
|
|
28
28
|
|
|
29
|
-
The selected tree follows the latest native `parentUuid` links. Compact boundaries also join their `logicalParentUuid` and recorded preserved segments through original ancestry, retaining old events instead of presenting only retained inference context. Auxiliary preservation UUIDs that were never persisted are skipped. Windows use `claude:<sessionId>:<ordinal>`, matching the current boot: native compact boundaries advance the ordinal, and retained notesoup boot markers name that same ordinal rather than advancing it again. A fork preserves the copied boot's ordinal but uses its own session id for public window ids. Copied prompt-context boot blocks are rebuilt with a fresh notes snapshot and the current session identity; historical boot messages in the transcript remain unchanged. Preserved duplicate rows keep their original window; new children of their rewritten versions inherit the new window.
|
|
29
|
+
The selected tree follows the latest native `parentUuid` links. Compact boundaries also join their `logicalParentUuid` and recorded preserved segments through original ancestry, retaining old events instead of presenting only retained inference context. Auxiliary preservation UUIDs that were never persisted are skipped. Windows use `claude:<sessionId>:<ordinal>`, matching the current boot: native compact boundaries advance the ordinal, and retained notesoup boot markers name that same ordinal rather than advancing it again. A fork preserves the copied boot's ordinal but uses its own session id for public window ids. Copied prompt-context boot blocks are rebuilt with a fresh notes snapshot and the current session identity; historical boot messages in the transcript remain unchanged. Preserved duplicate rows keep their original window; new children of their rewritten versions inherit the new window.
|
|
30
|
+
|
|
31
|
+
A missing required ancestor stops only that traversal edge. Confirmed selected suffixes and explicitly linked compaction history remain queryable; append order never joins a disconnected prefix or selects a sibling. All three history tools prepend a bounded Claude-specific incomplete-history notice, including missing UUID evidence, even for empty selections or query errors. The same pure text wrapper is supplied to shared selection/read budget checks and final delivery, so the complete text including the notice fits 32 KiB without clipping event text or continuation footers afterward. The notice is outside event documents, search matches and read offsets; the shared query schemas are unchanged. Previously allocated seqs remain unchanged if the missing record later appears: its first occurrence takes the next append address, and a fresh projection removes the gap notice when ancestry is complete.
|
|
32
|
+
|
|
33
|
+
Without a path back to a root or retained boot, window ordinals are unknown. Those events use `claude:<sessionId>:unknown:<missingUuid>` as an explicitly unnumbered segment (possibly spanning native compactions), not an invented ordinal. A subsequent complete retained boot re-anchors its own and later window ordinals without filling the history gap. Incomplete projections list only evidenced windows/segments, not empty placeholders for unseen ordinals. Confirmed numbered windows are sorted by ordinal (including when forward references put newer-window rows on disk first). Unknown segments are listed separately after the numbered windows; that placement does not assert chronological order for them. Shared tool pairing scans stable append seq order before regrouping events for display, so it does not depend on window/segment presentation order. `@previous` requires the exact preceding numbered window to be evidenced when history is incomplete, rather than choosing an adjacent unknown segment. The helper's reset-facing `history_state` returns the head's independently resolved ordinal, never `windows.length - 1`; if it is unknown, it explicitly refuses rather than supplying a guessed number. Existing reset-hook refusal handling leaves its prior state intact.
|
|
30
34
|
|
|
31
35
|
## Validation
|
|
32
36
|
|
package/docs/tool-results.md
CHANGED
|
@@ -59,7 +59,7 @@ Pi's nested records contain child ID, name, optional arguments, status, timing a
|
|
|
59
59
|
|
|
60
60
|
## Bounds and continuation
|
|
61
61
|
|
|
62
|
-
One selection determines the structured result and its text. Both complete representations must fit the 32 KiB output budget, including metadata, cursor and rendered notice. A programmatic caller does not receive an unbounded hidden payload beside a truncated textual one.
|
|
62
|
+
One selection determines the structured result and its text. Both complete representations must fit the 32 KiB output budget, including metadata, cursor and rendered notice. A programmatic caller does not receive an unbounded hidden payload beside a truncated textual one. History operations accept an optional pure text wrapper from the host: selection and read-window checks measure that wrapper around the shared rendering, and the caller must apply the same wrapper at delivery. Host prose stays in its plugin; no final clipping or separate query is involved.
|
|
63
63
|
|
|
64
64
|
History pages carry `page_older` and `page_newer`, the exact params to merge into the next call; `from` picks which end of a bounded range `limit` counts from, `since`/`until` narrow that range by event `created_at`, and only a call without roles or a non-empty query folds tool/context runs. Omitted queries, empty strings and empty lists all disable search filtering; empty entries in a query list are ignored. Without a query, notes search returns scoped notes with empty `matches`, not every body line. Notes listings/search are snapshots with a `more` count and can be narrowed by `glob`; they are not falsely advertised as paginated. `history_windows` is a snapshot too: its `more` counts the windows the budget left out and there is no window cursor, because `history_list` rows also expose `window_id`. A read can stop anywhere in the event document, including inside serialized arguments; concatenate its verbatim text slices before parsing any arguments. There is no separately truncated arguments object.
|
|
65
65
|
|
|
@@ -73,6 +73,6 @@ A note read reports unrecognized frontmatter under `metadata.extra`; a value too
|
|
|
73
73
|
- The history adapter owns native decoding, seq allocation and branch visibility.
|
|
74
74
|
- Shared operations own the typed result, filtering, paging, character windows and refusal messages.
|
|
75
75
|
- Shared renderers derive text from that result.
|
|
76
|
-
- Pi/Claude adapters supply host identity, projections and transport packaging only.
|
|
76
|
+
- Pi/Claude adapters supply host identity, projections, optional pure text decoration and transport packaging only.
|
|
77
77
|
|
|
78
78
|
There is no second query implementation for codemode, no copy of session storage and no migration of user records.
|
package/package.json
CHANGED
|
@@ -8900,28 +8900,28 @@ function toolEvent(item, result) {
|
|
|
8900
8900
|
};
|
|
8901
8901
|
}
|
|
8902
8902
|
function projectHistory(rawWindows, highestSeq, branchSeqs) {
|
|
8903
|
-
const raw = rawWindows.flatMap((current) => current.items);
|
|
8903
|
+
const raw = rawWindows.flatMap((current) => current.items).sort((a, b) => a.seq - b.seq);
|
|
8904
8904
|
const resultsById = /* @__PURE__ */ new Map();
|
|
8905
8905
|
for (const item of raw) {
|
|
8906
8906
|
if (item.role === "tool" && item.toolCallId && !resultsById.has(item.toolCallId)) resultsById.set(item.toolCallId, item);
|
|
8907
8907
|
}
|
|
8908
8908
|
const pairedResults = /* @__PURE__ */ new Map();
|
|
8909
|
-
const
|
|
8909
|
+
for (const item of raw) {
|
|
8910
|
+
const result = item.role === "tool_call" && item.toolCallId ? resultsById.get(item.toolCallId) : void 0;
|
|
8911
|
+
if (result && result.seq > item.seq && !pairedResults.has(result.seq)) {
|
|
8912
|
+
pairedResults.set(result.seq, item.seq);
|
|
8913
|
+
}
|
|
8914
|
+
}
|
|
8910
8915
|
const windows = rawWindows.map((current) => ({
|
|
8911
8916
|
windowId: current.windowId,
|
|
8912
8917
|
...current.createdAt ? { createdAt: current.createdAt } : {},
|
|
8913
8918
|
items: current.items.flatMap((item) => {
|
|
8914
|
-
if (
|
|
8915
|
-
if (item.role === "tool_call") {
|
|
8919
|
+
if (pairedResults.has(item.seq)) return [];
|
|
8920
|
+
if (item.role === "tool_call" || item.role === "tool") {
|
|
8916
8921
|
const result = item.toolCallId ? resultsById.get(item.toolCallId) : void 0;
|
|
8917
|
-
const paired = result && result.seq
|
|
8918
|
-
if (paired) {
|
|
8919
|
-
consumed.add(paired.seq);
|
|
8920
|
-
pairedResults.set(paired.seq, item.seq);
|
|
8921
|
-
}
|
|
8922
|
+
const paired = result && pairedResults.get(result.seq) === item.seq ? result : void 0;
|
|
8922
8923
|
return [toolEvent(item, paired)];
|
|
8923
8924
|
}
|
|
8924
|
-
if (item.role === "tool") return [toolEvent(item)];
|
|
8925
8925
|
return [{ seq: item.seq, windowId: item.windowId, role: item.role === "system" || item.role === "developer" ? "context" : item.role, text: item.text, createdAt: item.createdAt }];
|
|
8926
8926
|
})
|
|
8927
8927
|
}));
|
|
@@ -9541,9 +9541,7 @@ function renderRead(data) {
|
|
|
9541
9541
|
const neighborhood = `neighborhood \u2192 \`history_list\`(${JSON.stringify({ ...afterSeq >= 1 ? { after_seq: afterSeq } : {}, before_seq: data.seq + 10 })})`;
|
|
9542
9542
|
return [header(data), ...tool ? [tool] : [], neighborhood, "", data.total_chars === 0 ? "No visible text recorded for this event." : renderTextWindow(data)].join("\n");
|
|
9543
9543
|
}
|
|
9544
|
-
|
|
9545
|
-
return fitsResult(success(page), (result) => renderOutcome(result, renderPage));
|
|
9546
|
-
}
|
|
9544
|
+
var plainText = (text) => text;
|
|
9547
9545
|
var MAX_REPORTED_WINDOWS = 5;
|
|
9548
9546
|
function knownWindowSuffix(known) {
|
|
9549
9547
|
return known.length === 0 ? "" : `; its windows: ${known.slice(0, MAX_REPORTED_WINDOWS).join(", ")}`;
|
|
@@ -9568,9 +9566,9 @@ var historyWindows = {
|
|
|
9568
9566
|
description: "List this session's context windows, oldest first, with seq ranges.",
|
|
9569
9567
|
parameters: historyWindowsParameters,
|
|
9570
9568
|
outputSchema: resultSchema(HistoryWindowsDataSchema),
|
|
9571
|
-
async execute(_params, projection, sessionId) {
|
|
9569
|
+
async execute(_params, projection, sessionId, wrapText = plainText) {
|
|
9572
9570
|
const data = { session_id: sessionId, windows: [], more: projection.windows.length };
|
|
9573
|
-
const fits = (candidate) => fitsResult(success(candidate), (result) => renderOutcome(result, renderWindows));
|
|
9571
|
+
const fits = (candidate) => fitsResult(success(candidate), (result) => wrapText(renderOutcome(result, renderWindows)));
|
|
9574
9572
|
for (const window of projection.windows) {
|
|
9575
9573
|
let first = null;
|
|
9576
9574
|
let last = null;
|
|
@@ -9610,13 +9608,14 @@ var historyList = {
|
|
|
9610
9608
|
description: "Browse or search this session's events, a page at a time. Read one in full with `history_read`.",
|
|
9611
9609
|
parameters: historyListParameters,
|
|
9612
9610
|
outputSchema: resultSchema(HistoryPageSchema),
|
|
9613
|
-
async execute(params, projection) {
|
|
9611
|
+
async execute(params, projection, wrapText = plainText) {
|
|
9614
9612
|
const resolved = resolveWindowId(projection, params.window_id);
|
|
9615
9613
|
if (!resolved.ok) return resolved.outcome;
|
|
9616
9614
|
const scoped = { ...params, window_id: resolved.window_id };
|
|
9617
9615
|
const badWindow = badWindowId(projection, scoped);
|
|
9618
9616
|
if (badWindow) return badWindow;
|
|
9619
|
-
|
|
9617
|
+
const fits = (page) => fitsResult(success(page), (result) => wrapText(renderOutcome(result, renderPage)));
|
|
9618
|
+
return selectPage(projection, scoped, fits, scoped.max_chars_per_item ?? HISTORY_PREVIEW_CHARS);
|
|
9620
9619
|
},
|
|
9621
9620
|
render: (result) => renderOutcome(result, renderPage)
|
|
9622
9621
|
};
|
|
@@ -9627,7 +9626,7 @@ var historyRead = {
|
|
|
9627
9626
|
description: "Read one event in full: tool arguments, output, and nested calls.",
|
|
9628
9627
|
parameters: historyReadParameters,
|
|
9629
9628
|
outputSchema: resultSchema(HistoryReadDataSchema),
|
|
9630
|
-
async execute(params, projection) {
|
|
9629
|
+
async execute(params, projection, wrapText = plainText) {
|
|
9631
9630
|
const item = allItems(projection).find((event) => event.seq === params.seq);
|
|
9632
9631
|
if (item === void 0 && params.seq > projection.highestSeq) {
|
|
9633
9632
|
return failure("unknown_seq", `There is no seq ${params.seq}; this session runs from seq 1 to ${projection.highestSeq}.`);
|
|
@@ -9660,7 +9659,7 @@ var historyRead = {
|
|
|
9660
9659
|
...nestedCallSummary(item),
|
|
9661
9660
|
...window
|
|
9662
9661
|
}),
|
|
9663
|
-
(result) => renderOutcome(result, renderRead)
|
|
9662
|
+
(result) => wrapText(renderOutcome(result, renderRead))
|
|
9664
9663
|
);
|
|
9665
9664
|
},
|
|
9666
9665
|
render: (result) => renderOutcome(result, renderRead)
|
|
@@ -9783,26 +9782,32 @@ function claudeHistoryFromJsonl(text, source) {
|
|
|
9783
9782
|
nextSeq += items.length;
|
|
9784
9783
|
nodes.set(uuid, { first: version, latest: version, items });
|
|
9785
9784
|
}
|
|
9786
|
-
|
|
9785
|
+
const missingAncestors = /* @__PURE__ */ new Set();
|
|
9786
|
+
function positionOf(version) {
|
|
9787
9787
|
const chain = [], calculating = /* @__PURE__ */ new Set();
|
|
9788
9788
|
let cursor = version;
|
|
9789
|
-
|
|
9789
|
+
let before = { ordinal: 0 };
|
|
9790
|
+
while (cursor.position === void 0) {
|
|
9790
9791
|
cursor.ancestor ??= cursor.ancestorUuid === void 0 ? void 0 : nodes.get(cursor.ancestorUuid)?.first;
|
|
9791
9792
|
if (calculating.has(cursor)) throw new Error("cyclic Claude transcript ancestry");
|
|
9792
|
-
if (cursor.ancestorUuid !== void 0 && cursor.ancestor === void 0) throw new Error(`missing Claude transcript ancestor: ${cursor.ancestorUuid}`);
|
|
9793
9793
|
calculating.add(cursor);
|
|
9794
9794
|
chain.push(cursor);
|
|
9795
|
+
if (cursor.ancestorUuid !== void 0 && cursor.ancestor === void 0) {
|
|
9796
|
+
missingAncestors.add(cursor.ancestorUuid);
|
|
9797
|
+
before = { unknownAncestor: cursor.ancestorUuid };
|
|
9798
|
+
break;
|
|
9799
|
+
}
|
|
9795
9800
|
if (cursor.ancestor === void 0) break;
|
|
9796
9801
|
cursor = cursor.ancestor;
|
|
9797
9802
|
}
|
|
9798
|
-
|
|
9799
|
-
for (const
|
|
9800
|
-
const retained =
|
|
9801
|
-
const marked = bootOrdinal(
|
|
9802
|
-
|
|
9803
|
-
before =
|
|
9803
|
+
before = cursor.position ?? before;
|
|
9804
|
+
for (const current2 of chain.reverse()) {
|
|
9805
|
+
const retained = current2.row.isCompactSummary === true || current2.ancestor !== void 0 && boundary(current2.ancestor.row);
|
|
9806
|
+
const marked = bootOrdinal(current2.row, retained);
|
|
9807
|
+
current2.position = marked !== void 0 ? { ordinal: "ordinal" in before ? Math.max(before.ordinal, marked) : marked } : "ordinal" in before ? { ordinal: before.ordinal + (boundary(current2.row) ? 1 : 0) } : before;
|
|
9808
|
+
before = current2.position;
|
|
9804
9809
|
}
|
|
9805
|
-
return version.
|
|
9810
|
+
return version.position;
|
|
9806
9811
|
}
|
|
9807
9812
|
if (!source.headUuid) throw new Error("Claude history has no confirmed active head yet; wait for a main-session append after startup/resume");
|
|
9808
9813
|
if (!nodes.has(source.headUuid)) throw new Error("Claude history active head is not persisted yet; retry after the transcript write");
|
|
@@ -9821,7 +9826,10 @@ function claudeHistoryFromJsonl(text, source) {
|
|
|
9821
9826
|
visiting.add(key);
|
|
9822
9827
|
stack.push({ ...step, exit: true });
|
|
9823
9828
|
const node = nodes.get(uuid);
|
|
9824
|
-
if (!node)
|
|
9829
|
+
if (!node) {
|
|
9830
|
+
missingAncestors.add(uuid);
|
|
9831
|
+
continue;
|
|
9832
|
+
}
|
|
9825
9833
|
selected.add(uuid);
|
|
9826
9834
|
const row = (historical ? node.first : node.latest).row;
|
|
9827
9835
|
const ancestor = parent(row);
|
|
@@ -9843,20 +9851,35 @@ function claudeHistoryFromJsonl(text, source) {
|
|
|
9843
9851
|
}
|
|
9844
9852
|
}
|
|
9845
9853
|
}
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
const
|
|
9854
|
+
const current = positionOf(nodes.get(source.headUuid).latest);
|
|
9855
|
+
const windowId = (position) => `claude:${source.sessionId}:${"ordinal" in position ? position.ordinal : `unknown:${position.unknownAncestor}`}`;
|
|
9856
|
+
const windowsById = /* @__PURE__ */ new Map();
|
|
9849
9857
|
const branchSeqs = /* @__PURE__ */ new Set();
|
|
9858
|
+
let maxOrdinal = "ordinal" in current ? current.ordinal : 0;
|
|
9850
9859
|
for (const [uuid, node] of nodes) {
|
|
9851
9860
|
if (!selected.has(uuid)) continue;
|
|
9852
|
-
const
|
|
9861
|
+
const position = positionOf(node.first);
|
|
9862
|
+
if ("ordinal" in position) maxOrdinal = Math.max(maxOrdinal, position.ordinal);
|
|
9863
|
+
const id = windowId(position);
|
|
9864
|
+
let window = windowsById.get(id);
|
|
9865
|
+
if (!window) {
|
|
9866
|
+
window = { windowId: id, ..."ordinal" in position ? { ordinal: position.ordinal } : {}, items: [] };
|
|
9867
|
+
windowsById.set(id, window);
|
|
9868
|
+
}
|
|
9853
9869
|
window.createdAt ??= node.items[0]?.createdAt;
|
|
9854
9870
|
for (const item of node.items) {
|
|
9855
9871
|
branchSeqs.add(item.seq);
|
|
9856
|
-
window.items.push({ ...item, windowId:
|
|
9872
|
+
window.items.push({ ...item, windowId: id });
|
|
9873
|
+
}
|
|
9874
|
+
}
|
|
9875
|
+
if (missingAncestors.size === 0) {
|
|
9876
|
+
for (let ordinal = 0; ordinal <= maxOrdinal; ordinal++) {
|
|
9877
|
+
const id = windowId({ ordinal });
|
|
9878
|
+
if (!windowsById.has(id)) windowsById.set(id, { windowId: id, ordinal, items: [] });
|
|
9857
9879
|
}
|
|
9858
9880
|
}
|
|
9859
|
-
|
|
9881
|
+
const windows = [...windowsById.values()].sort((a, b) => a.ordinal === void 0 ? b.ordinal === void 0 ? 0 : 1 : b.ordinal === void 0 ? -1 : a.ordinal - b.ordinal);
|
|
9882
|
+
return { ...projectHistory(windows, nextSeq - 1, branchSeqs), missingAncestors: [...missingAncestors], currentWindowOrdinal: "ordinal" in current ? current.ordinal : void 0 };
|
|
9860
9883
|
}
|
|
9861
9884
|
async function readClaudeHistory(source) {
|
|
9862
9885
|
if (!source || typeof source.transcriptPath !== "string" || !source.transcriptPath || typeof source.sessionId !== "string") throw new Error("Claude history transcript_path is unavailable");
|
|
@@ -10102,6 +10125,18 @@ var COUNTDOWN_LINE = "Brain emptied in 3\u2026 2\u2026";
|
|
|
10102
10125
|
// plugins/claude/src/text.ts
|
|
10103
10126
|
var CLAUDE_HISTORY_UNAVAILABLE_SENTENCE = "History isn't available in this Claude session: no main transcript_path was supplied. Keep essential state in notes; don't pretend those notes are the missing transcript.";
|
|
10104
10127
|
var CLAUDE_WARNING_PROMPT = warningNotice();
|
|
10128
|
+
var CLAUDE_HISTORY_UNKNOWN_WINDOW = "Claude history cannot determine the current window ordinal across a missing ancestor; restore the ancestry or use a retained notesoup boot to re-anchor it.";
|
|
10129
|
+
var CLAUDE_HISTORY_UNKNOWN_PREVIOUS = 'Cannot resolve "@previous": the immediately preceding window is not confirmed across the ancestry gap. Use an explicit window id from history_windows.';
|
|
10130
|
+
function claudeHistoryUnconfirmedSeq(seq) {
|
|
10131
|
+
return `Seq ${seq} is outside the confirmed selected history; it may be on another branch or beyond an unresolved ancestry gap.`;
|
|
10132
|
+
}
|
|
10133
|
+
function claudeHistoryGapNotice(missing) {
|
|
10134
|
+
if (missing.length === 0) return "";
|
|
10135
|
+
const evidence = missing.slice(0, 5).map((uuid) => JSON.stringify(uuid.length > 160 ? `${uuid.slice(0, 160)}\u2026` : uuid)).join(", ");
|
|
10136
|
+
return `Claude history is incomplete: missing ancestor UUID(s): ${evidence}${missing.length > 5 ? `; ${missing.length - 5} more` : ""}. Only confirmed selected ancestry is returned; disconnected prefixes and unrelated branches are excluded. Window IDs containing :unknown: have unconfirmed ordinal/ownership and may span native compactions; they are listed separately after numbered windows, not placed in a chronological order. A later retained boot can re-anchor window numbering, but cannot fill the history gap.
|
|
10137
|
+
|
|
10138
|
+
`;
|
|
10139
|
+
}
|
|
10105
10140
|
|
|
10106
10141
|
// src/budget/constants.ts
|
|
10107
10142
|
var WARNING_RUNWAY_TOKENS = 16384;
|
|
@@ -10249,7 +10284,6 @@ function boundOperation(operation) {
|
|
|
10249
10284
|
description: operation.description,
|
|
10250
10285
|
parameters: operation.parameters,
|
|
10251
10286
|
async call(params, ...context) {
|
|
10252
|
-
if (!Check2(operation.parameters, params)) throw new Error(`invalid ${operation.name} parameters: ${paramProblem(operation.parameters, params)}`);
|
|
10253
10287
|
const outcome = await operation.execute(params, ...context);
|
|
10254
10288
|
return { text: operation.render(outcome), ok: outcome.ok };
|
|
10255
10289
|
}
|
|
@@ -10285,17 +10319,40 @@ async function dispatch(request) {
|
|
|
10285
10319
|
if (value.op === "limits") return resolveClaudeLimits(value.facts);
|
|
10286
10320
|
if (value.op === "tool") {
|
|
10287
10321
|
if (typeof value.tool !== "string" || !Object.hasOwn(OPERATIONS, value.tool) && !Object.hasOwn(HISTORY_OPERATIONS, value.tool)) throw new Error("unknown tool");
|
|
10322
|
+
const operation = Object.hasOwn(OPERATIONS, value.tool) ? OPERATIONS[value.tool] : HISTORY_OPERATIONS[value.tool];
|
|
10323
|
+
if (!Check2(operation.parameters, value.params)) throw new Error(`invalid ${value.tool} parameters: ${paramProblem(operation.parameters, value.params)}`);
|
|
10288
10324
|
const id = identity(value.identity);
|
|
10289
10325
|
if (Object.hasOwn(HISTORY_OPERATIONS, value.tool)) {
|
|
10326
|
+
const tool = value.tool;
|
|
10290
10327
|
const projection = await readClaudeHistory(historySource(value.history, id.sessionId));
|
|
10291
|
-
|
|
10328
|
+
const notice = claudeHistoryGapNotice(projection.missingAncestors);
|
|
10329
|
+
const wrapText = (text) => notice + text;
|
|
10330
|
+
let params = value.params;
|
|
10331
|
+
if (projection.missingAncestors.length > 0) {
|
|
10332
|
+
if (params.window_id === "@previous") {
|
|
10333
|
+
const previous = projection.currentWindowOrdinal === void 0 ? void 0 : `claude:${id.sessionId}:${projection.currentWindowOrdinal - 1}`;
|
|
10334
|
+
if (!projection.windows.some((window) => window.windowId === previous)) {
|
|
10335
|
+
return { ok: false, text: wrapText(CLAUDE_HISTORY_UNKNOWN_PREVIOUS) };
|
|
10336
|
+
}
|
|
10337
|
+
params = { ...params, window_id: previous };
|
|
10338
|
+
}
|
|
10339
|
+
if (value.tool === "history_read") {
|
|
10340
|
+
const { seq } = params;
|
|
10341
|
+
if (seq <= projection.highestSeq && !projection.branchSeqs.has(seq)) {
|
|
10342
|
+
return { ok: false, text: wrapText(claudeHistoryUnconfirmedSeq(seq)) };
|
|
10343
|
+
}
|
|
10344
|
+
}
|
|
10345
|
+
}
|
|
10346
|
+
const result = tool === "history_windows" ? await HISTORY_OPERATIONS[tool].call(params, projection, id.sessionId, wrapText) : await HISTORY_OPERATIONS[tool].call(params, projection, wrapText);
|
|
10347
|
+
return { ...result, text: wrapText(result.text) };
|
|
10292
10348
|
}
|
|
10293
10349
|
return OPERATIONS[value.tool].call(value.params, id);
|
|
10294
10350
|
}
|
|
10295
10351
|
if (value.op === "history_state") {
|
|
10296
10352
|
const id = identity(value.identity);
|
|
10297
10353
|
const projection = await readClaudeHistory(historySource(value.history, id.sessionId));
|
|
10298
|
-
|
|
10354
|
+
if (projection.currentWindowOrdinal === void 0) throw new Error(CLAUDE_HISTORY_UNKNOWN_WINDOW);
|
|
10355
|
+
return { window: projection.currentWindowOrdinal };
|
|
10299
10356
|
}
|
|
10300
10357
|
if (value.op === "boot") {
|
|
10301
10358
|
const id = identity(value.identity);
|
|
@@ -3,14 +3,13 @@ import { pathToFileURL } from "node:url";
|
|
|
3
3
|
import type { Static, TSchema } from "typebox";
|
|
4
4
|
import { Check, Errors } from "typebox/value";
|
|
5
5
|
import { notesList, notesRead, notesSearch, notesUpdate, notesWrite } from "../../../src/tools/notes.js";
|
|
6
|
-
import { historyList, historyRead, historyWindows } from "../../../src/tools/history.js";
|
|
6
|
+
import { historyList, historyRead, historyWindows, type HistoryTextWrapper } from "../../../src/tools/history.js";
|
|
7
7
|
import { readClaudeHistory, type ClaudeHistorySource } from "./history.js";
|
|
8
|
-
import type { HistoryProjection } from "../../../src/history/history.js";
|
|
9
8
|
import { loadNotesSnapshot } from "../../../src/boot/snapshot.js";
|
|
10
9
|
import { renderBootBlock } from "../../../src/boot/render.js";
|
|
11
10
|
import type { BootToolNames } from "../../../src/boot/text.js";
|
|
12
11
|
import { selectContinuation } from "../../../src/budget/text.js";
|
|
13
|
-
import { CLAUDE_HISTORY_UNAVAILABLE_SENTENCE, CLAUDE_WARNING_PROMPT } from "./text.js";
|
|
12
|
+
import { claudeHistoryGapNotice, claudeHistoryUnconfirmedSeq, CLAUDE_HISTORY_UNKNOWN_PREVIOUS, CLAUDE_HISTORY_UNKNOWN_WINDOW, CLAUDE_HISTORY_UNAVAILABLE_SENTENCE, CLAUDE_WARNING_PROMPT } from "./text.js";
|
|
14
13
|
import { resolveClaudeLimits } from "./thresholds.js";
|
|
15
14
|
import { projectKey, snapshotNotesIdentity, type NotesIdentity } from "../../../src/notes/index.js";
|
|
16
15
|
import type { Operation } from "../../../src/tools/result.js";
|
|
@@ -41,7 +40,7 @@ function paramProblem(schema: TSchema, params: unknown): string {
|
|
|
41
40
|
return `${field ? `${field} ` : ""}${first.message}${extra}`;
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
/** Bind
|
|
43
|
+
/** Bind shared execution/rendering to a host context; dispatch validates parameters before calling. */
|
|
45
44
|
function boundOperation<TParams extends TSchema, TData, TContext extends readonly unknown[]>(
|
|
46
45
|
operation: Operation<TParams, TData, TContext>,
|
|
47
46
|
): BoundOperation<TContext> {
|
|
@@ -49,8 +48,6 @@ function boundOperation<TParams extends TSchema, TData, TContext extends readonl
|
|
|
49
48
|
description: operation.description,
|
|
50
49
|
parameters: operation.parameters,
|
|
51
50
|
async call(params, ...context) {
|
|
52
|
-
// Refuse before the operation can act: a rejected shape never reaches a write.
|
|
53
|
-
if (!Check(operation.parameters, params)) throw new Error(`invalid ${operation.name} parameters: ${paramProblem(operation.parameters, params)}`);
|
|
54
51
|
// The same business outcome and the same renderer as the Pi tool; only the envelope differs.
|
|
55
52
|
const outcome = await operation.execute(params as Static<TParams>, ...context);
|
|
56
53
|
return { text: operation.render(outcome), ok: outcome.ok };
|
|
@@ -66,7 +63,7 @@ const OPERATIONS: Record<string, BoundOperation<[NotesIdentity]>> = {
|
|
|
66
63
|
notes_search: boundOperation(notesSearch),
|
|
67
64
|
};
|
|
68
65
|
|
|
69
|
-
const HISTORY_OPERATIONS
|
|
66
|
+
const HISTORY_OPERATIONS = {
|
|
70
67
|
history_list: boundOperation(historyList),
|
|
71
68
|
history_read: boundOperation(historyRead),
|
|
72
69
|
history_windows: boundOperation(historyWindows),
|
|
@@ -95,17 +92,45 @@ export async function dispatch(request: unknown): Promise<unknown> {
|
|
|
95
92
|
if (value.op === "limits") return resolveClaudeLimits(value.facts);
|
|
96
93
|
if (value.op === "tool") {
|
|
97
94
|
if (typeof value.tool !== "string" || (!Object.hasOwn(OPERATIONS, value.tool) && !Object.hasOwn(HISTORY_OPERATIONS, value.tool))) throw new Error("unknown tool");
|
|
95
|
+
const operation = Object.hasOwn(OPERATIONS, value.tool) ? OPERATIONS[value.tool]! : HISTORY_OPERATIONS[value.tool as keyof typeof HISTORY_OPERATIONS];
|
|
96
|
+
// Refuse before any operation can act: a rejected shape never reaches a write.
|
|
97
|
+
if (!Check(operation.parameters, value.params)) throw new Error(`invalid ${value.tool} parameters: ${paramProblem(operation.parameters, value.params)}`);
|
|
98
98
|
const id = identity(value.identity as ClaudeIdentityInput);
|
|
99
99
|
if (Object.hasOwn(HISTORY_OPERATIONS, value.tool)) {
|
|
100
|
+
const tool = value.tool as keyof typeof HISTORY_OPERATIONS;
|
|
100
101
|
const projection = await readClaudeHistory(historySource(value.history, id.sessionId));
|
|
101
|
-
|
|
102
|
+
const notice = claudeHistoryGapNotice(projection.missingAncestors);
|
|
103
|
+
const wrapText: HistoryTextWrapper = (text) => notice + text;
|
|
104
|
+
let params = value.params;
|
|
105
|
+
if (projection.missingAncestors.length > 0) {
|
|
106
|
+
// An unknown segment is not evidence for the window before the current
|
|
107
|
+
// one. Resolve the exact ordinal, never array adjacency across a gap.
|
|
108
|
+
if ((params as { window_id?: string }).window_id === "@previous") {
|
|
109
|
+
const previous = projection.currentWindowOrdinal === undefined ? undefined : `claude:${id.sessionId}:${projection.currentWindowOrdinal - 1}`;
|
|
110
|
+
if (!projection.windows.some((window) => window.windowId === previous)) {
|
|
111
|
+
return { ok: false, text: wrapText(CLAUDE_HISTORY_UNKNOWN_PREVIOUS) };
|
|
112
|
+
}
|
|
113
|
+
params = { ...params as object, window_id: previous };
|
|
114
|
+
}
|
|
115
|
+
if (value.tool === "history_read") {
|
|
116
|
+
const { seq } = params as { seq: number };
|
|
117
|
+
if (seq <= projection.highestSeq && !projection.branchSeqs.has(seq)) {
|
|
118
|
+
return { ok: false, text: wrapText(claudeHistoryUnconfirmedSeq(seq)) };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const result = tool === "history_windows"
|
|
123
|
+
? await HISTORY_OPERATIONS[tool].call(params, projection, id.sessionId, wrapText)
|
|
124
|
+
: await HISTORY_OPERATIONS[tool].call(params, projection, wrapText);
|
|
125
|
+
return { ...result, text: wrapText(result.text) };
|
|
102
126
|
}
|
|
103
127
|
return OPERATIONS[value.tool]!.call(value.params, id);
|
|
104
128
|
}
|
|
105
129
|
if (value.op === "history_state") {
|
|
106
130
|
const id = identity(value.identity as ClaudeIdentityInput);
|
|
107
131
|
const projection = await readClaudeHistory(historySource(value.history, id.sessionId));
|
|
108
|
-
|
|
132
|
+
if (projection.currentWindowOrdinal === undefined) throw new Error(CLAUDE_HISTORY_UNKNOWN_WINDOW);
|
|
133
|
+
return { window: projection.currentWindowOrdinal };
|
|
109
134
|
}
|
|
110
135
|
if (value.op === "boot") {
|
|
111
136
|
const id = identity(value.identity as ClaudeIdentityInput);
|
|
@@ -4,9 +4,12 @@ import { isDeepStrictEqual } from "node:util";
|
|
|
4
4
|
import { contentText, projectHistory, type DecodedHistoryItem, type DecodedHistoryWindow, type HistoryProjection } from "../../../src/history/history.js";
|
|
5
5
|
|
|
6
6
|
type Row = Record<string, unknown>;
|
|
7
|
-
type
|
|
7
|
+
type WindowPosition = { ordinal: number } | { unknownAncestor: string };
|
|
8
|
+
type Version = { row: Row; ancestorUuid?: string; ancestor?: Version; position?: WindowPosition };
|
|
8
9
|
type Node = { first: Version; latest: Version; items: DecodedHistoryItem[] };
|
|
9
10
|
export type ClaudeHistorySource = { sessionId: string; transcriptPath: string; headUuid?: string };
|
|
11
|
+
/** Claude graph evidence stays in the adapter; shared queries only see addressed windows. */
|
|
12
|
+
export type ClaudeHistoryProjection = HistoryProjection & { missingAncestors: string[]; currentWindowOrdinal: number | undefined };
|
|
10
13
|
const MESSAGE_TYPES = new Set(["user", "assistant", "system", "attachment"]);
|
|
11
14
|
const NON_TEXT_BLOCKS = new Set(["thinking", "redacted_thinking", "image", "document", "audio", "video", "server_tool_use", "web_search_tool_result", "tool_reference"]);
|
|
12
15
|
function object(value: unknown): value is Row { return typeof value === "object" && value !== null && !Array.isArray(value); }
|
|
@@ -112,12 +115,12 @@ function bootOrdinal(row: Row, retained: boolean): number | undefined {
|
|
|
112
115
|
}
|
|
113
116
|
|
|
114
117
|
/** All addresses are allocated on the full first-occurrence log, before branch selection. */
|
|
115
|
-
export function claudeHistoryFromJsonl(text: string, source: Omit<ClaudeHistorySource, "transcriptPath">):
|
|
118
|
+
export function claudeHistoryFromJsonl(text: string, source: Omit<ClaudeHistorySource, "transcriptPath">): ClaudeHistoryProjection {
|
|
116
119
|
const nodes = new Map<string, Node>();
|
|
117
120
|
let nextSeq = 1;
|
|
118
121
|
for (const row of rowsOf(text)) {
|
|
119
|
-
// Ignore non-message records, including future metadata.
|
|
120
|
-
//
|
|
122
|
+
// Ignore non-message records, including future metadata. If selected ancestry
|
|
123
|
+
// reaches a skipped UUID, it becomes a gap, never permission to expose its payload.
|
|
121
124
|
if (!MESSAGE_TYPES.has(row.type as string)) continue;
|
|
122
125
|
const uuid = requiredString(row.uuid, "uuid");
|
|
123
126
|
parent(row);
|
|
@@ -141,29 +144,37 @@ export function claudeHistoryFromJsonl(text: string, source: Omit<ClaudeHistoryS
|
|
|
141
144
|
nextSeq += items.length;
|
|
142
145
|
nodes.set(uuid, { first: version, latest: version, items });
|
|
143
146
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
// Resolve long
|
|
147
|
+
const missingAncestors = new Set<string>();
|
|
148
|
+
function positionOf(version: Version): WindowPosition {
|
|
149
|
+
// Resolve long chains iteratively. A gap destroys ordinal evidence, not the
|
|
150
|
+
// confirmed suffix. Only a retained boot can re-anchor that suffix's ordinal.
|
|
147
151
|
const chain: Version[] = [], calculating = new Set<Version>();
|
|
148
152
|
let cursor = version;
|
|
149
|
-
|
|
150
|
-
|
|
153
|
+
let before: WindowPosition = { ordinal: 0 };
|
|
154
|
+
while (cursor.position === undefined) {
|
|
155
|
+
// Forward references use the parent's first eventual version, not a rewrite.
|
|
151
156
|
cursor.ancestor ??= cursor.ancestorUuid === undefined ? undefined : nodes.get(cursor.ancestorUuid)?.first;
|
|
152
157
|
if (calculating.has(cursor)) throw new Error("cyclic Claude transcript ancestry");
|
|
153
|
-
if (cursor.ancestorUuid !== undefined && cursor.ancestor === undefined) throw new Error(`missing Claude transcript ancestor: ${cursor.ancestorUuid}`);
|
|
154
158
|
calculating.add(cursor);
|
|
155
159
|
chain.push(cursor);
|
|
160
|
+
if (cursor.ancestorUuid !== undefined && cursor.ancestor === undefined) {
|
|
161
|
+
missingAncestors.add(cursor.ancestorUuid);
|
|
162
|
+
before = { unknownAncestor: cursor.ancestorUuid };
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
156
165
|
if (cursor.ancestor === undefined) break;
|
|
157
166
|
cursor = cursor.ancestor;
|
|
158
167
|
}
|
|
159
|
-
|
|
168
|
+
before = cursor.position ?? before;
|
|
160
169
|
for (const current of chain.reverse()) {
|
|
161
170
|
const retained = current.row.isCompactSummary === true || (current.ancestor !== undefined && boundary(current.ancestor.row));
|
|
162
171
|
const marked = bootOrdinal(current.row, retained);
|
|
163
|
-
current.
|
|
164
|
-
|
|
172
|
+
current.position = marked !== undefined
|
|
173
|
+
? { ordinal: "ordinal" in before ? Math.max(before.ordinal, marked) : marked }
|
|
174
|
+
: "ordinal" in before ? { ordinal: before.ordinal + (boundary(current.row) ? 1 : 0) } : before;
|
|
175
|
+
before = current.position;
|
|
165
176
|
}
|
|
166
|
-
return version.
|
|
177
|
+
return version.position!;
|
|
167
178
|
}
|
|
168
179
|
if (!source.headUuid) throw new Error("Claude history has no confirmed active head yet; wait for a main-session append after startup/resume");
|
|
169
180
|
if (!nodes.has(source.headUuid)) throw new Error("Claude history active head is not persisted yet; retry after the transcript write");
|
|
@@ -182,7 +193,7 @@ export function claudeHistoryFromJsonl(text: string, source: Omit<ClaudeHistoryS
|
|
|
182
193
|
visiting.add(key);
|
|
183
194
|
stack.push({ ...step, exit: true });
|
|
184
195
|
const node = nodes.get(uuid);
|
|
185
|
-
if (!node)
|
|
196
|
+
if (!node) { missingAncestors.add(uuid); continue; }
|
|
186
197
|
selected.add(uuid);
|
|
187
198
|
const row = (historical ? node.first : node.latest).row;
|
|
188
199
|
const ancestor = parent(row);
|
|
@@ -207,20 +218,41 @@ export function claudeHistoryFromJsonl(text: string, source: Omit<ClaudeHistoryS
|
|
|
207
218
|
}
|
|
208
219
|
}
|
|
209
220
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const
|
|
221
|
+
const current = positionOf(nodes.get(source.headUuid)!.latest);
|
|
222
|
+
const windowId = (position: WindowPosition) => `claude:${source.sessionId}:${"ordinal" in position ? position.ordinal : `unknown:${position.unknownAncestor}`}`;
|
|
223
|
+
const windowsById = new Map<string, DecodedHistoryWindow & { ordinal?: number }>();
|
|
213
224
|
const branchSeqs = new Set<number>();
|
|
225
|
+
let maxOrdinal = "ordinal" in current ? current.ordinal : 0;
|
|
214
226
|
for (const [uuid, node] of nodes) {
|
|
215
227
|
if (!selected.has(uuid)) continue;
|
|
216
|
-
const
|
|
228
|
+
const position = positionOf(node.first);
|
|
229
|
+
if ("ordinal" in position) maxOrdinal = Math.max(maxOrdinal, position.ordinal);
|
|
230
|
+
const id = windowId(position);
|
|
231
|
+
let window = windowsById.get(id);
|
|
232
|
+
if (!window) {
|
|
233
|
+
window = { windowId: id, ...("ordinal" in position ? { ordinal: position.ordinal } : {}), items: [] };
|
|
234
|
+
windowsById.set(id, window);
|
|
235
|
+
}
|
|
217
236
|
window.createdAt ??= node.items[0]?.createdAt;
|
|
218
|
-
for (const item of node.items) { branchSeqs.add(item.seq); window.items.push({ ...item, windowId:
|
|
237
|
+
for (const item of node.items) { branchSeqs.add(item.seq); window.items.push({ ...item, windowId: id }); }
|
|
238
|
+
}
|
|
239
|
+
// Preserve complete-history empty windows (including copied boot ordinals).
|
|
240
|
+
// With gaps, report only evidenced windows, never invent the missing ordinals.
|
|
241
|
+
if (missingAncestors.size === 0) {
|
|
242
|
+
for (let ordinal = 0; ordinal <= maxOrdinal; ordinal++) {
|
|
243
|
+
const id = windowId({ ordinal });
|
|
244
|
+
if (!windowsById.has(id)) windowsById.set(id, { windowId: id, ordinal, items: [] });
|
|
245
|
+
}
|
|
219
246
|
}
|
|
220
|
-
|
|
247
|
+
// Forward references can put a newer numbered window on disk first. Unknown
|
|
248
|
+
// segments are a separate, unordered group, not an inferred place in that timeline.
|
|
249
|
+
const windows = [...windowsById.values()].sort((a, b) => a.ordinal === undefined
|
|
250
|
+
? b.ordinal === undefined ? 0 : 1
|
|
251
|
+
: b.ordinal === undefined ? -1 : a.ordinal - b.ordinal);
|
|
252
|
+
return { ...projectHistory(windows, nextSeq - 1, branchSeqs), missingAncestors: [...missingAncestors], currentWindowOrdinal: "ordinal" in current ? current.ordinal : undefined };
|
|
221
253
|
}
|
|
222
254
|
|
|
223
|
-
export async function readClaudeHistory(source: ClaudeHistorySource): Promise<
|
|
255
|
+
export async function readClaudeHistory(source: ClaudeHistorySource): Promise<ClaudeHistoryProjection> {
|
|
224
256
|
if (!source || typeof source.transcriptPath !== "string" || !source.transcriptPath || typeof source.sessionId !== "string") throw new Error("Claude history transcript_path is unavailable");
|
|
225
257
|
return claudeHistoryFromJsonl(await readFile(source.transcriptPath, "utf8"), source);
|
|
226
258
|
}
|
|
@@ -5,3 +5,16 @@ export const CLAUDE_HISTORY_UNAVAILABLE_SENTENCE = "History isn't available in t
|
|
|
5
5
|
|
|
6
6
|
/** The same notice as Pi; empty_brain's result explains Claude's deferred reset. */
|
|
7
7
|
export const CLAUDE_WARNING_PROMPT = warningNotice();
|
|
8
|
+
|
|
9
|
+
export const CLAUDE_HISTORY_UNKNOWN_WINDOW = "Claude history cannot determine the current window ordinal across a missing ancestor; restore the ancestry or use a retained notesoup boot to re-anchor it.";
|
|
10
|
+
export const CLAUDE_HISTORY_UNKNOWN_PREVIOUS = 'Cannot resolve "@previous": the immediately preceding window is not confirmed across the ancestry gap. Use an explicit window id from history_windows.';
|
|
11
|
+
export function claudeHistoryUnconfirmedSeq(seq: number): string {
|
|
12
|
+
return `Seq ${seq} is outside the confirmed selected history; it may be on another branch or beyond an unresolved ancestry gap.`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Bounded host-only evidence, outside event documents/search offsets and shared schemas. */
|
|
16
|
+
export function claudeHistoryGapNotice(missing: readonly string[]): string {
|
|
17
|
+
if (missing.length === 0) return "";
|
|
18
|
+
const evidence = missing.slice(0, 5).map((uuid) => JSON.stringify(uuid.length > 160 ? `${uuid.slice(0, 160)}…` : uuid)).join(", ");
|
|
19
|
+
return `Claude history is incomplete: missing ancestor UUID(s): ${evidence}${missing.length > 5 ? `; ${missing.length - 5} more` : ""}. Only confirmed selected ancestry is returned; disconnected prefixes and unrelated branches are excluded. Window IDs containing :unknown: have unconfirmed ordinal/ownership and may span native compactions; they are listed separately after numbered windows, not placed in a chronological order. A later retained boot can re-anchor window numbering, but cannot fill the history gap.\n\n`;
|
|
20
|
+
}
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Displays notesoup last-word messages already present in Paseo’s timeline as expanded, selectable paper cards. Last-word and notes cards share a pale-paper palette, tape accent, small corners, and compact spacing; a crumple call turns its card grey and strikes the address. Requires Paseo 0.11.2 on the client and daemon.
|
|
4
4
|
|
|
5
|
-
This client-only plugin transforms existing timeline rows in place: last-word custom messages become sticky cards, and notes_read/notes_write/notes_update tool calls become paper cards with the address, state, and a content or diff preview. It does not read session files or append messages. Other timeline items are unchanged.
|
|
5
|
+
This client-only plugin transforms existing timeline rows in place: last-word custom messages become sticky cards, and notes_read/notes_write/notes_update tool calls become paper cards with the address, state, and a content or diff preview. It accepts the bare Pi tool names and Claude's exact `mcp__notesoup__` prefix; same-named tools from other MCP servers are unchanged. It does not read session files or append messages. Other timeline items are unchanged.
|
|
6
6
|
|
|
7
7
|
Notes cards start collapsed; update cards also show the sentence just added. The whole header row expands and collapses the body. Long content scrolls inside a bounded panel. Display limits are 4000 characters for reads and writes, and 8000 for diffs; expanding does not fetch more content.
|
|
8
8
|
|
|
9
|
-
Notes cards prefer
|
|
9
|
+
Notes cards prefer Pi's structured tool payload on live events. Pi replayed history carries only rendered text blocks; Claude carries rendered text under the adapter's `output` field. Both use the same text fallback parser, and write previews come from the call arguments. Failed calls also read the adapter's error content (string or text blocks) or transport message when no result is available.
|
|
10
|
+
|
|
11
|
+
`empty_brain` (including `mcp__notesoup__empty_brain`) becomes a divider for running, completed and failed calls. Pi's JSON rollover outcomes are preserved. Claude's plain acknowledgement only completes the tool call; it does not invent a Pi outcome or assert that the deferred reset has committed.
|
|
12
|
+
|
|
13
|
+
Automated tests check transformer payloads with source-derived adapter fixtures, not a live Paseo UI session.
|
|
10
14
|
|
|
11
15
|
Paseo 0.11.2 drops Pi boundary `entry_appended` events from its live timeline. This plugin cannot display messages that Paseo has not received; that adapter gap needs an upstream fix. Messages available through history can be rendered.
|
|
@@ -7,7 +7,9 @@ function label(data: BrainEmpty): string {
|
|
|
7
7
|
if (data.status === "running") return "✂ emptying brain …";
|
|
8
8
|
if (data.error !== undefined) return "✂ brain refused to empty";
|
|
9
9
|
if (data.outcome === "rollover_already_pending") return "✂ already emptying";
|
|
10
|
-
return "✂
|
|
10
|
+
if (data.outcome === "rollover_requested") return "✂ reset requested";
|
|
11
|
+
// A completed tool call (including Claude's acknowledgement) does not prove a reset committed.
|
|
12
|
+
return "✂ empty_brain completed";
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
/** Single-side dashed borders are unreliable on iOS, so the cut line is a row of dash segments. */
|