chat-recall 0.7.51 → 0.7.54
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/cli.js +928 -630
- package/dist/cli.js.map +1 -1
- package/dist/ledger-reconcile.d.ts +50 -0
- package/dist/ledger-reconcile.d.ts.map +1 -0
- package/dist/ledger-reconcile.js +102 -0
- package/dist/ledger-reconcile.js.map +1 -0
- package/dist/mcp.js +10922 -10720
- package/dist/scan-worker.js +52 -3
- package/dist/session-source-probe.d.ts +8 -0
- package/dist/session-source-probe.d.ts.map +1 -0
- package/dist/session-source-probe.js +18 -0
- package/dist/session-source-probe.js.map +1 -0
- package/dist/sync-client.d.ts.map +1 -1
- package/dist/sync-client.js +27 -11
- package/dist/sync-client.js.map +1 -1
- package/dist/sync-ledger.d.ts +5 -0
- package/dist/sync-ledger.d.ts.map +1 -1
- package/dist/sync-ledger.js +22 -0
- package/dist/sync-ledger.js.map +1 -1
- package/dist/tombstone-rule.d.ts +47 -0
- package/dist/tombstone-rule.d.ts.map +1 -0
- package/dist/tombstone-rule.js +64 -0
- package/dist/tombstone-rule.js.map +1 -0
- package/dist/walk-budget.d.ts.map +1 -1
- package/dist/walk-budget.js +1 -1
- package/dist/walk-budget.js.map +1 -1
- package/dist/watch.js +11829 -11626
- package/package.json +1 -1
package/dist/scan-worker.js
CHANGED
|
@@ -11477,8 +11477,10 @@ var init_claude2 = __esm({
|
|
|
11477
11477
|
const cutoff = opts.sinceMs ?? 0;
|
|
11478
11478
|
const filter = opts.projectFilter?.toLowerCase();
|
|
11479
11479
|
const byId = /* @__PURE__ */ new Map();
|
|
11480
|
-
|
|
11481
|
-
|
|
11480
|
+
const roots = claudeProjectDirs();
|
|
11481
|
+
const fresh = cutoff > 0 ? this.sessionIdsChangedSince(roots, cutoff) : null;
|
|
11482
|
+
for (const root of roots) {
|
|
11483
|
+
this.collectSessionsFromRoot(root, filter, byId, opts.previews !== false, fresh);
|
|
11482
11484
|
}
|
|
11483
11485
|
const out = [...byId.values()].filter((r) => r.mtime >= cutoff);
|
|
11484
11486
|
out.sort((a, b) => b.mtime - a.mtime);
|
|
@@ -11494,7 +11496,48 @@ var init_claude2 = __esm({
|
|
|
11494
11496
|
* handled both refs under one ledger row with two different mtimes, and the
|
|
11495
11497
|
* row that shipped nothing stamped the other copy's mtime.
|
|
11496
11498
|
*/
|
|
11497
|
-
|
|
11499
|
+
/**
|
|
11500
|
+
* The ids of the sessions that have a transcript file with an mtime at or above
|
|
11501
|
+
* `cutoff`, in any home. One directory read per project and one stat per file,
|
|
11502
|
+
* with no file content read and no ref built. A session with a copy in two
|
|
11503
|
+
* homes is in the set when either copy is new, which is the rule the cutoff
|
|
11504
|
+
* of `listSessions` applies to the merged session.
|
|
11505
|
+
*/
|
|
11506
|
+
sessionIdsChangedSince(roots, cutoff) {
|
|
11507
|
+
const ids = /* @__PURE__ */ new Set();
|
|
11508
|
+
for (const root of roots) {
|
|
11509
|
+
if (!existsSync12(root))
|
|
11510
|
+
continue;
|
|
11511
|
+
let projects;
|
|
11512
|
+
try {
|
|
11513
|
+
projects = readdirSync9(root, { withFileTypes: true });
|
|
11514
|
+
} catch {
|
|
11515
|
+
continue;
|
|
11516
|
+
}
|
|
11517
|
+
for (const proj of projects) {
|
|
11518
|
+
if (!proj.isDirectory())
|
|
11519
|
+
continue;
|
|
11520
|
+
const projPath = join12(root, proj.name);
|
|
11521
|
+
let files;
|
|
11522
|
+
try {
|
|
11523
|
+
files = readdirSync9(projPath);
|
|
11524
|
+
} catch {
|
|
11525
|
+
continue;
|
|
11526
|
+
}
|
|
11527
|
+
for (const f of files) {
|
|
11528
|
+
if (!f.endsWith(".jsonl") || f === "sessions-index.json")
|
|
11529
|
+
continue;
|
|
11530
|
+
try {
|
|
11531
|
+
if (statSync11(join12(projPath, f)).mtimeMs >= cutoff)
|
|
11532
|
+
ids.add(basename7(f, ".jsonl"));
|
|
11533
|
+
} catch {
|
|
11534
|
+
}
|
|
11535
|
+
}
|
|
11536
|
+
}
|
|
11537
|
+
}
|
|
11538
|
+
return ids;
|
|
11539
|
+
}
|
|
11540
|
+
collectSessionsFromRoot(root, filter, byId, previews, fresh = null) {
|
|
11498
11541
|
const add = (ref) => {
|
|
11499
11542
|
const prior = byId.get(ref.rawId);
|
|
11500
11543
|
if (!prior) {
|
|
@@ -11522,6 +11565,10 @@ var init_claude2 = __esm({
|
|
|
11522
11565
|
const indexData = JSON.parse(readFileSync9(indexPath, "utf-8"));
|
|
11523
11566
|
const entries = indexData.entries || [];
|
|
11524
11567
|
for (const entry of entries) {
|
|
11568
|
+
if (fresh && !fresh.has(entry.sessionId)) {
|
|
11569
|
+
indexed.add(entry.sessionId);
|
|
11570
|
+
continue;
|
|
11571
|
+
}
|
|
11525
11572
|
if (!entry.fullPath || !existsSync12(entry.fullPath))
|
|
11526
11573
|
continue;
|
|
11527
11574
|
indexed.add(entry.sessionId);
|
|
@@ -11554,6 +11601,8 @@ var init_claude2 = __esm({
|
|
|
11554
11601
|
const sessionId = basename7(f, ".jsonl");
|
|
11555
11602
|
if (indexed.has(sessionId))
|
|
11556
11603
|
continue;
|
|
11604
|
+
if (fresh && !fresh.has(sessionId))
|
|
11605
|
+
continue;
|
|
11557
11606
|
const fullPath = join12(projPath, f);
|
|
11558
11607
|
let stat;
|
|
11559
11608
|
try {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SessionProbe } from './tombstone-rule.js';
|
|
2
|
+
/**
|
|
3
|
+
* Ask the backend that owns `id` whether the source of the session exists.
|
|
4
|
+
* A backend that is not available (its folder or database is not there) or that
|
|
5
|
+
* throws gives `unknown`, so a missing mount never reads as a deletion.
|
|
6
|
+
*/
|
|
7
|
+
export declare function probeSessionSource(id: string): SessionProbe;
|
|
8
|
+
//# sourceMappingURL=session-source-probe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-source-probe.d.ts","sourceRoot":"","sources":["../src/session-source-probe.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,CAQ3D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getBackendForId } from '@chat-recall/engine/core/tool-backend.js';
|
|
2
|
+
/**
|
|
3
|
+
* Ask the backend that owns `id` whether the source of the session exists.
|
|
4
|
+
* A backend that is not available (its folder or database is not there) or that
|
|
5
|
+
* throws gives `unknown`, so a missing mount never reads as a deletion.
|
|
6
|
+
*/
|
|
7
|
+
export function probeSessionSource(id) {
|
|
8
|
+
const backend = getBackendForId(id);
|
|
9
|
+
if (!backend || !backend.isAvailable())
|
|
10
|
+
return 'unknown';
|
|
11
|
+
try {
|
|
12
|
+
return backend.findSession(id) ? 'present' : 'missing';
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return 'unknown';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=session-source-probe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-source-probe.js","sourceRoot":"","sources":["../src/session-source-probe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAG3E;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAU;IAC3C,MAAM,OAAO,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;IACpC,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;QAAE,OAAO,SAAS,CAAC;IACzD,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-client.d.ts","sourceRoot":"","sources":["../src/sync-client.ts"],"names":[],"mappings":"AAoCA,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAQzF,OAAO,EAAoF,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"sync-client.d.ts","sourceRoot":"","sources":["../src/sync-client.ts"],"names":[],"mappings":"AAoCA,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAQzF,OAAO,EAAoF,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAerL,OAAO,EAA+B,KAAK,UAAU,EAAE,MAAM,0CAA0C,CAAC;AA2ExG,yDAAyD;AACzD,wBAAgB,YAAY,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAI7E;AAgBD,wEAAwE;AACxE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAGvD;AAED,MAAM,MAAM,YAAY,GACpB,cAAc,GAAG,mBAAmB,GAAG,kBAAkB,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAC1F,KAAK,GAAG,SAAS,GAAG,oBAAoB,GAAG,cAAc,GAAG,OAAO,CAAC;AAExE;;;;;;;;;GASG;AACH;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAE3D;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,YAAY,CAyBtE;AAOD,OAAO,EAA2D,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACnH,OAAO,4CAA4C,CAAC;AAMpD;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAAG,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,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AAC,UAAU,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAyFlJ;AAED;;;;;;GAMG;AACH;;;;;;;;GAQG;AACH;;;;yCAIyC;AACzC,MAAM,WAAW,QAAQ;IAAG,OAAO,EAAE,gBAAgB,GAAG,QAAQ,GAAG,WAAW,CAAA;CAAE;AAEhF,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,CAAC,IAAI,QAAQ,CAElE;AAED,wBAAsB,eAAe,CAAC,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAO,GAAG,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,CA4C/G"}
|
package/dist/sync-client.js
CHANGED
|
@@ -48,6 +48,9 @@ import { dropFuzzyFindings } from '@chat-recall/engine/core/secret-precision.js'
|
|
|
48
48
|
import { loadSettings, saveSettings, isProjectSyncable } from '@chat-recall/engine/core/settings.js';
|
|
49
49
|
import { getDataDir } from '@chat-recall/engine/core/paths.js';
|
|
50
50
|
import { walkSessionLimit, orderRefsForWalk, mayTombstone } from './walk-budget.js';
|
|
51
|
+
import { tombstoneMode, planTombstones, describeTombstonePlan } from './tombstone-rule.js';
|
|
52
|
+
import { probeSessionSource } from './session-source-probe.js';
|
|
53
|
+
import { reconcileLedgerIfDue } from './ledger-reconcile.js';
|
|
51
54
|
import { listAvailableBackends } from '@chat-recall/engine/core/tool-backend.js';
|
|
52
55
|
import { parseTranscript, trimTranscriptForSync, TRANSCRIPT_VERSION, gzipContainer, redactContainer, buildRawContainer, containerSrcHash, parseTranscriptFromContainer, updateShadow, shadowUncompressedBytes } from '@chat-recall/engine/transcript/index.js';
|
|
53
56
|
import { parseClaudeTranscriptText } from '@chat-recall/engine/transcript/claude.js';
|
|
@@ -1460,6 +1463,10 @@ async function syncToTargetInScope(cred, opts = {}) {
|
|
|
1460
1463
|
};
|
|
1461
1464
|
};
|
|
1462
1465
|
const base = cred.serverUrl.replace(/\/$/, '');
|
|
1466
|
+
// Clear the rows of sessions that the server lacks before the ledger is read,
|
|
1467
|
+
// so this walk sends them (bounded by the walk cap, newest first).
|
|
1468
|
+
if (opts.useLedger)
|
|
1469
|
+
await reconcileLedgerIfDue(base, cred.token);
|
|
1463
1470
|
const ledger = opts.useLedger ? getSyncedRows(base) : null;
|
|
1464
1471
|
const convBatch = makeBatcher('conversations', 25, false, (rows) => {
|
|
1465
1472
|
// Server acked this batch — record exactly these sessions at exactly
|
|
@@ -1605,7 +1612,13 @@ async function syncToTargetInScope(cred, opts = {}) {
|
|
|
1605
1612
|
};
|
|
1606
1613
|
let appendBatch = [];
|
|
1607
1614
|
let appendBatchBytes = 0;
|
|
1608
|
-
|
|
1615
|
+
// One request touches this many sessions at most. The server did work for each
|
|
1616
|
+
// session of a batch at the same time, and 36 appended sessions in one request
|
|
1617
|
+
// of 291 KB ended a pod on 2026-11-16 (issue #27).
|
|
1618
|
+
const APPEND_BATCH_SIZE = (() => {
|
|
1619
|
+
const n = Number(process.env.CHAT_RECALL_APPEND_BATCH_MAX);
|
|
1620
|
+
return Number.isInteger(n) && n > 0 ? n : 10;
|
|
1621
|
+
})();
|
|
1609
1622
|
// Chunks of a chunked session are up to SYNC_CHUNK_BYTES each, so the batch
|
|
1610
1623
|
// is bounded by bytes as well as by count.
|
|
1611
1624
|
const APPEND_BATCH_MAX_BYTES = SYNC_CHUNK_BYTES;
|
|
@@ -2353,18 +2366,21 @@ async function syncToTargetInScope(cred, opts = {}) {
|
|
|
2353
2366
|
// The server keeps a tombstone for good, so only a walk that listed and visited
|
|
2354
2367
|
// every local session may send them (see `mayTombstone`).
|
|
2355
2368
|
if (ledger && mayTombstone({ changedWalk, listed: refs.length, sliceSize: slice.length, paused: walkPaused })) {
|
|
2356
|
-
const
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
}
|
|
2362
|
-
if (
|
|
2363
|
-
|
|
2369
|
+
const mode = tombstoneMode();
|
|
2370
|
+
const plan = mode === 'off' ? { ids: [], refused: null } : planTombstones({
|
|
2371
|
+
ledgerIds: ledger.keys(),
|
|
2372
|
+
visited: localSessionIds,
|
|
2373
|
+
probe: probeSessionSource,
|
|
2374
|
+
});
|
|
2375
|
+
if (plan.ids.length > 0)
|
|
2376
|
+
console.error(describeTombstonePlan(plan, mode));
|
|
2377
|
+
if (mode === 'act' && plan.refused === null && plan.ids.length > 0) {
|
|
2378
|
+
const deletedAt = Date.now();
|
|
2379
|
+
await post({ tombstones: plan.ids.map((session_id) => ({ session_id, deleted_at: deletedAt })) });
|
|
2364
2380
|
// Remove tombstoned ids from the ledger so we don't keep shipping them.
|
|
2365
2381
|
const data = getLedgerData(base);
|
|
2366
|
-
for (const
|
|
2367
|
-
delete data[
|
|
2382
|
+
for (const id of plan.ids)
|
|
2383
|
+
delete data[id];
|
|
2368
2384
|
persistLedgerData(base, data);
|
|
2369
2385
|
}
|
|
2370
2386
|
}
|