chat-recall 0.7.59 → 0.7.61
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 +425 -183
- package/dist/mcp.js +409 -169
- package/dist/scan-worker.js +54 -0
- package/dist/session-file-scan.d.ts +31 -0
- package/dist/session-file-scan.d.ts.map +1 -0
- package/dist/session-file-scan.js +149 -0
- package/dist/session-file-scan.js.map +1 -0
- package/dist/sync-client.d.ts +0 -7
- package/dist/sync-client.d.ts.map +1 -1
- package/dist/sync-client.js +46 -22
- package/dist/sync-client.js.map +1 -1
- package/dist/watch.js +421 -179
- package/package.json +1 -1
package/dist/scan-worker.js
CHANGED
|
@@ -5352,6 +5352,13 @@ var init_claude_prompt_origin = __esm({
|
|
|
5352
5352
|
}
|
|
5353
5353
|
});
|
|
5354
5354
|
|
|
5355
|
+
// ../engine/dist/transcript/trim.js
|
|
5356
|
+
var init_trim = __esm({
|
|
5357
|
+
"../engine/dist/transcript/trim.js"() {
|
|
5358
|
+
"use strict";
|
|
5359
|
+
}
|
|
5360
|
+
});
|
|
5361
|
+
|
|
5355
5362
|
// ../engine/dist/transcript/claude.js
|
|
5356
5363
|
var log2;
|
|
5357
5364
|
var init_claude = __esm({
|
|
@@ -5359,6 +5366,7 @@ var init_claude = __esm({
|
|
|
5359
5366
|
"use strict";
|
|
5360
5367
|
init_logger();
|
|
5361
5368
|
init_claude_prompt_origin();
|
|
5369
|
+
init_trim();
|
|
5362
5370
|
log2 = createLogger("transcript-claude");
|
|
5363
5371
|
}
|
|
5364
5372
|
});
|
|
@@ -7140,6 +7148,52 @@ var init_opencode = __esm({
|
|
|
7140
7148
|
getCommits(id, files, startMs, endMs, bufferMinutes) {
|
|
7141
7149
|
return getSessionCommits(this.toPrefixedId(id), files, startMs, endMs, bufferMinutes);
|
|
7142
7150
|
}
|
|
7151
|
+
/** The bytes of the dump of a session, summed in SQLite: no row is read into the process. */
|
|
7152
|
+
rawSessionBytes(id) {
|
|
7153
|
+
const dbPath = this.dbPath();
|
|
7154
|
+
if (!existsSync5(dbPath))
|
|
7155
|
+
return 0;
|
|
7156
|
+
const realId = this.toRawId(id);
|
|
7157
|
+
const db = openOpencodeDbOrThrow(dbPath);
|
|
7158
|
+
try {
|
|
7159
|
+
const row = db.prepare(`
|
|
7160
|
+
SELECT COALESCE(SUM(LENGTH(CAST(p.data AS BLOB)) + LENGTH(CAST(m.data AS BLOB))), 0) AS bytes
|
|
7161
|
+
FROM part p JOIN (SELECT id, data FROM message WHERE session_id = ?) m ON p.message_id = m.id
|
|
7162
|
+
WHERE p.session_id = ?
|
|
7163
|
+
`).get(realId, realId);
|
|
7164
|
+
return Number(row?.bytes ?? 0);
|
|
7165
|
+
} catch {
|
|
7166
|
+
return 0;
|
|
7167
|
+
} finally {
|
|
7168
|
+
db.close();
|
|
7169
|
+
}
|
|
7170
|
+
}
|
|
7171
|
+
/** The lines of the dump, one row at a time. Every line ends with a newline. */
|
|
7172
|
+
*iterateRawSessionLines(id) {
|
|
7173
|
+
const dbPath = this.dbPath();
|
|
7174
|
+
if (!existsSync5(dbPath))
|
|
7175
|
+
return;
|
|
7176
|
+
const realId = this.toRawId(id);
|
|
7177
|
+
const db = openOpencodeDbOrThrow(dbPath);
|
|
7178
|
+
try {
|
|
7179
|
+
const session = db.prepare(`SELECT * FROM session WHERE id = ?`).get(realId);
|
|
7180
|
+
if (!session)
|
|
7181
|
+
return;
|
|
7182
|
+
yield `${JSON.stringify({ kind: "session", row: session })}
|
|
7183
|
+
`;
|
|
7184
|
+
const rows = db.prepare(`
|
|
7185
|
+
SELECT m.id AS message_id, m.data AS message_data, p.id AS part_id, p.data AS part_data, p.time_created
|
|
7186
|
+
FROM part p JOIN (SELECT id, data FROM message WHERE session_id = ?) m ON p.message_id = m.id
|
|
7187
|
+
WHERE p.session_id = ?
|
|
7188
|
+
ORDER BY p.time_created ASC, p.id ASC
|
|
7189
|
+
`);
|
|
7190
|
+
for (const r of rows.iterate(realId, realId))
|
|
7191
|
+
yield `${JSON.stringify({ kind: "part", row: r })}
|
|
7192
|
+
`;
|
|
7193
|
+
} finally {
|
|
7194
|
+
db.close();
|
|
7195
|
+
}
|
|
7196
|
+
}
|
|
7143
7197
|
exportRawSession(id) {
|
|
7144
7198
|
const dbPath = this.dbPath();
|
|
7145
7199
|
if (!existsSync5(dbPath))
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type SessionContentGroup } from '@chat-recall/engine/core/live-session-scan.js';
|
|
2
|
+
export interface SessionFileFinding {
|
|
3
|
+
session_id: string;
|
|
4
|
+
detector: string;
|
|
5
|
+
rule: string;
|
|
6
|
+
line: number;
|
|
7
|
+
preview: string;
|
|
8
|
+
}
|
|
9
|
+
/** Bytes of a piece. A line longer than a piece makes its own larger piece. */
|
|
10
|
+
export declare const SCAN_PIECE_BYTES: number;
|
|
11
|
+
/** Bytes the files of the groups occupy on disk: the most an export of them holds. */
|
|
12
|
+
export declare function sessionGroupsBytes(groups: SessionContentGroup[]): number;
|
|
13
|
+
/** The pieces of one file. Each piece but the last ends with a newline. */
|
|
14
|
+
export declare function readLinePieces(path: string, pieceBytes?: number): AsyncGenerator<{
|
|
15
|
+
text: string;
|
|
16
|
+
newlines: number;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function scanSessionGroupsChunked(sessionId: string, groups: SessionContentGroup[], tenantRules?: Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
regex: string;
|
|
21
|
+
}>, pieceBytes?: number): Promise<SessionFileFinding[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Secret findings for a capture a backend gives as lines (a database dump), one
|
|
24
|
+
* piece of lines at a time. Every line ends with a newline, so the line numbers
|
|
25
|
+
* are the positions of the lines in the capture.
|
|
26
|
+
*/
|
|
27
|
+
export declare function scanLinesChunked(sessionId: string, lines: Iterable<string>, tenantRules?: Array<{
|
|
28
|
+
name: string;
|
|
29
|
+
regex: string;
|
|
30
|
+
}>, pieceBytes?: number): SessionFileFinding[];
|
|
31
|
+
//# sourceMappingURL=session-file-scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-file-scan.d.ts","sourceRoot":"","sources":["../src/session-file-scan.ts"],"names":[],"mappings":"AAcA,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AAE/G,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,QAAc,CAAC;AAI5C,sFAAsF;AACtF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAQxE;AAED,2EAA2E;AAC3E,wBAAuB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,SAAmB,GAAG,cAAc,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAmBrI;AAQD,wBAAsB,wBAAwB,CAC5C,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,mBAAmB,EAAE,EAC7B,WAAW,CAAC,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,EACpD,UAAU,SAAmB,GAC5B,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAqC/B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EACvB,WAAW,CAAC,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,EACpD,UAAU,SAAmB,GAC5B,kBAAkB,EAAE,CA+BtB"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secret findings for the files of one session, read from disk a piece at a
|
|
3
|
+
* time.
|
|
4
|
+
*
|
|
5
|
+
* A session whose files add up to more than the build ceiling is never held in
|
|
6
|
+
* memory as one export. This reads each file in pieces that end at a line end,
|
|
7
|
+
* scans each piece, and gives the findings the line numbers the scan of the
|
|
8
|
+
* joined container gives: the files follow each other, main file first, and the
|
|
9
|
+
* container puts one newline between two files.
|
|
10
|
+
*/
|
|
11
|
+
import { open } from 'node:fs/promises';
|
|
12
|
+
import { statSync } from 'node:fs';
|
|
13
|
+
import { scanTextForFindings } from '@chat-recall/engine/core/secret-redactor.js';
|
|
14
|
+
import { scanTenantRules } from '@chat-recall/engine/core/secret-scanner.js';
|
|
15
|
+
import { readSessionGroupText } from '@chat-recall/engine/core/live-session-scan.js';
|
|
16
|
+
/** Bytes of a piece. A line longer than a piece makes its own larger piece. */
|
|
17
|
+
export const SCAN_PIECE_BYTES = 1024 * 1024;
|
|
18
|
+
const NEWLINE = 0x0a;
|
|
19
|
+
/** Bytes the files of the groups occupy on disk: the most an export of them holds. */
|
|
20
|
+
export function sessionGroupsBytes(groups) {
|
|
21
|
+
let total = 0;
|
|
22
|
+
for (const g of groups) {
|
|
23
|
+
for (const p of g.paths) {
|
|
24
|
+
try {
|
|
25
|
+
total += statSync(p).size;
|
|
26
|
+
}
|
|
27
|
+
catch { /* a file that went away adds nothing */ }
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return total;
|
|
31
|
+
}
|
|
32
|
+
/** The pieces of one file. Each piece but the last ends with a newline. */
|
|
33
|
+
export async function* readLinePieces(path, pieceBytes = SCAN_PIECE_BYTES) {
|
|
34
|
+
const fh = await open(path, 'r');
|
|
35
|
+
try {
|
|
36
|
+
const buf = Buffer.allocUnsafe(pieceBytes);
|
|
37
|
+
let carry = Buffer.alloc(0);
|
|
38
|
+
for (;;) {
|
|
39
|
+
const { bytesRead } = await fh.read(buf, 0, pieceBytes, null);
|
|
40
|
+
if (bytesRead === 0)
|
|
41
|
+
break;
|
|
42
|
+
const joined = carry.length ? Buffer.concat([carry, buf.subarray(0, bytesRead)]) : buf.subarray(0, bytesRead);
|
|
43
|
+
const cut = joined.lastIndexOf(NEWLINE);
|
|
44
|
+
if (cut < 0) {
|
|
45
|
+
carry = Buffer.from(joined);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const piece = joined.subarray(0, cut + 1);
|
|
49
|
+
carry = Buffer.from(joined.subarray(cut + 1));
|
|
50
|
+
yield { text: piece.toString('utf8'), newlines: countNewlines(piece) };
|
|
51
|
+
}
|
|
52
|
+
if (carry.length)
|
|
53
|
+
yield { text: carry.toString('utf8'), newlines: 0 };
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
await fh.close();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function countNewlines(b) {
|
|
60
|
+
let n = 0;
|
|
61
|
+
for (let i = b.indexOf(NEWLINE); i >= 0; i = b.indexOf(NEWLINE, i + 1))
|
|
62
|
+
n++;
|
|
63
|
+
return n;
|
|
64
|
+
}
|
|
65
|
+
export async function scanSessionGroupsChunked(sessionId, groups, tenantRules, pieceBytes = SCAN_PIECE_BYTES) {
|
|
66
|
+
const findings = [];
|
|
67
|
+
let lineBase = 0;
|
|
68
|
+
const scan = (text) => {
|
|
69
|
+
try {
|
|
70
|
+
for (const x of scanTextForFindings(text)) {
|
|
71
|
+
findings.push({ session_id: sessionId, detector: 'builtin', rule: x.rule, line: x.line + lineBase, preview: x.preview });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch { /* best-effort */ }
|
|
75
|
+
if (tenantRules && tenantRules.length > 0) {
|
|
76
|
+
try {
|
|
77
|
+
for (const x of scanTenantRules(text, tenantRules)) {
|
|
78
|
+
findings.push({ session_id: sessionId, detector: x.detector, rule: x.rule, line: x.line + lineBase, preview: x.preview });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch { /* best-effort */ }
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
for (const group of groups) {
|
|
85
|
+
if (group.paths.length === 1) {
|
|
86
|
+
let any = false;
|
|
87
|
+
for await (const piece of readLinePieces(group.paths[0], pieceBytes)) {
|
|
88
|
+
any = true;
|
|
89
|
+
scan(piece.text);
|
|
90
|
+
lineBase += piece.newlines;
|
|
91
|
+
}
|
|
92
|
+
// The container puts one newline after a file, so the next file starts one line below the last line of this one.
|
|
93
|
+
// An empty file is not in the container.
|
|
94
|
+
if (any)
|
|
95
|
+
lineBase += 1;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
// One file with copies in several homes: the copies are merged as text, as the export does.
|
|
99
|
+
const { text } = readSessionGroupText(group);
|
|
100
|
+
if (!text)
|
|
101
|
+
continue;
|
|
102
|
+
scan(text);
|
|
103
|
+
lineBase += (text.match(/\n/g)?.length ?? 0) + 1;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return findings;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Secret findings for a capture a backend gives as lines (a database dump), one
|
|
110
|
+
* piece of lines at a time. Every line ends with a newline, so the line numbers
|
|
111
|
+
* are the positions of the lines in the capture.
|
|
112
|
+
*/
|
|
113
|
+
export function scanLinesChunked(sessionId, lines, tenantRules, pieceBytes = SCAN_PIECE_BYTES) {
|
|
114
|
+
const findings = [];
|
|
115
|
+
let lineBase = 0;
|
|
116
|
+
let piece = [];
|
|
117
|
+
let bytes = 0;
|
|
118
|
+
const flush = () => {
|
|
119
|
+
if (piece.length === 0)
|
|
120
|
+
return;
|
|
121
|
+
const text = piece.join('');
|
|
122
|
+
try {
|
|
123
|
+
for (const x of scanTextForFindings(text)) {
|
|
124
|
+
findings.push({ session_id: sessionId, detector: 'builtin', rule: x.rule, line: x.line + lineBase, preview: x.preview });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch { /* best-effort */ }
|
|
128
|
+
if (tenantRules && tenantRules.length > 0) {
|
|
129
|
+
try {
|
|
130
|
+
for (const x of scanTenantRules(text, tenantRules)) {
|
|
131
|
+
findings.push({ session_id: sessionId, detector: x.detector, rule: x.rule, line: x.line + lineBase, preview: x.preview });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch { /* best-effort */ }
|
|
135
|
+
}
|
|
136
|
+
lineBase += piece.length;
|
|
137
|
+
piece = [];
|
|
138
|
+
bytes = 0;
|
|
139
|
+
};
|
|
140
|
+
for (const line of lines) {
|
|
141
|
+
piece.push(line);
|
|
142
|
+
bytes += line.length;
|
|
143
|
+
if (bytes >= pieceBytes)
|
|
144
|
+
flush();
|
|
145
|
+
}
|
|
146
|
+
flush();
|
|
147
|
+
return findings;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=session-file-scan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-file-scan.js","sourceRoot":"","sources":["../src/session-file-scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAA4B,MAAM,+CAA+C,CAAC;AAU/G,+EAA+E;AAC/E,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,MAAM,OAAO,GAAG,IAAI,CAAC;AAErB,sFAAsF;AACtF,MAAM,UAAU,kBAAkB,CAAC,MAA6B;IAC9D,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;YAC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AAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC5H,CAAC;YACH,CAAC;YAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC;QAC/B,CAAC;QACD,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC;QACzB,KAAK,GAAG,EAAE,CAAC;QACX,KAAK,GAAG,CAAC,CAAC;IACZ,CAAC,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC;QACrB,IAAI,KAAK,IAAI,UAAU;YAAE,KAAK,EAAE,CAAC;IACnC,CAAC;IACD,KAAK,EAAE,CAAC;IACR,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/sync-client.d.ts
CHANGED
|
@@ -335,13 +335,6 @@ export declare const TOOLKIT_INVENTORY_TYPES: ReadonlySet<string>;
|
|
|
335
335
|
export declare const BATCH_SCAN_MAX_BYTES: number;
|
|
336
336
|
/** Bytes an append-only session occupies on disk (0 for non-AO backends). */
|
|
337
337
|
export declare function sessionFileBytes(ref: SessionRef): number;
|
|
338
|
-
/**
|
|
339
|
-
* Bytes a FULL build of an append-only session loads (0 for non-AO backends):
|
|
340
|
-
* the larger of the main transcript and the shadow container, which also holds
|
|
341
|
-
* the subagent transcripts and any history an upstream rewrite dropped. The
|
|
342
|
-
* main file alone under-counts: a 19 MB transcript built from a 42 MB shadow
|
|
343
|
-
* and peaked at 840 MB RSS.
|
|
344
|
-
*/
|
|
345
338
|
export declare function sessionBuildBytes(ref: SessionRef): number;
|
|
346
339
|
export declare function buildConversationSync(ref: SessionRef, mtime: number, opts?: {
|
|
347
340
|
mapPath?: (p: string) => string;
|
|
@@ -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;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;
|
|
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,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,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
|
@@ -52,7 +52,7 @@ import { tombstoneMode, planTombstones, describeTombstonePlan } from './tombston
|
|
|
52
52
|
import { probeSessionSource } from './session-source-probe.js';
|
|
53
53
|
import { reconcileLedgerIfDue } from './ledger-reconcile.js';
|
|
54
54
|
import { listAvailableBackends } from '@chat-recall/engine/core/tool-backend.js';
|
|
55
|
-
import { parseTranscript, trimTranscriptForSync, TRANSCRIPT_VERSION, gzipContainer, redactContainer, buildRawContainer, containerSrcHash, parseTranscriptFromContainer, updateShadow, shadowUncompressedBytes } from '@chat-recall/engine/transcript/index.js';
|
|
55
|
+
import { parseTranscript, trimTranscriptForSync, SYNC_PAYLOAD_CAP, TRANSCRIPT_VERSION, gzipContainer, redactContainer, buildRawContainer, containerSrcHash, parseTranscriptFromContainer, updateShadow, shadowUncompressedBytes } from '@chat-recall/engine/transcript/index.js';
|
|
56
56
|
import { parseClaudeTranscriptText } from '@chat-recall/engine/transcript/claude.js';
|
|
57
57
|
import { parseCodexTranscriptText } from '@chat-recall/engine/transcript/codex.js';
|
|
58
58
|
import { canonicalEventsToMessages } from '@chat-recall/engine/transcript/index.js';
|
|
@@ -214,6 +214,7 @@ let walkProgressForUpload = null;
|
|
|
214
214
|
let lastServerPackSpec = null;
|
|
215
215
|
import { reportWalkProgress, readCollectorHealth, updateCollectorHealth } from '@chat-recall/engine/core/collector-health.js';
|
|
216
216
|
import { withSessionScanScope, resolveSessionContentGroups } from '@chat-recall/engine/core/live-session-scan.js';
|
|
217
|
+
import { scanSessionGroupsChunked, scanLinesChunked, sessionGroupsBytes } from './session-file-scan.js';
|
|
217
218
|
import { writeArchiveFile, uploadArchiveFile } from './raw-archive-parts.js';
|
|
218
219
|
import '@chat-recall/engine/core/backends/index.js'; // register the tool backends
|
|
219
220
|
// Lives under the data dir so CHAT_RECALL_DATA_DIR isolates credentials the
|
|
@@ -2541,6 +2542,11 @@ export function sessionFileBytes(ref) {
|
|
|
2541
2542
|
* main file alone under-counts: a 19 MB transcript built from a 42 MB shadow
|
|
2542
2543
|
* and peaked at 840 MB RSS.
|
|
2543
2544
|
*/
|
|
2545
|
+
function syncTranscript(t) {
|
|
2546
|
+
// A transcript the parser already cut is not cut again: the cut is not idempotent.
|
|
2547
|
+
const cut = t.payloadCap ? { messages: t.messages, subagents: t.subagents } : trimTranscriptForSync(t);
|
|
2548
|
+
return { messages: cut.messages, subagents: cut.subagents.map((s) => ({ ...s, filePath: '' })) };
|
|
2549
|
+
}
|
|
2544
2550
|
export function sessionBuildBytes(ref) {
|
|
2545
2551
|
const main = sessionFileBytes(ref);
|
|
2546
2552
|
if (main === 0)
|
|
@@ -2607,7 +2613,15 @@ export async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
2607
2613
|
// shrink, and every viewer tab keeps its full history.
|
|
2608
2614
|
try {
|
|
2609
2615
|
const backend = getBackendForId(ref.prefixedId) ?? getBackend('claude');
|
|
2610
|
-
|
|
2616
|
+
// A Claude session is sized from its files on disk, before anything is read: the files of an
|
|
2617
|
+
// export over the ceiling are never held in memory together, so the export is not made.
|
|
2618
|
+
const streamGroups = ref.toolId === 'claude' ? resolveSessionContentGroups(ref.rawId) : [];
|
|
2619
|
+
const streamsLines = ref.toolId !== 'claude' && !!backend.rawSessionBytes && !!backend.iterateRawSessionLines;
|
|
2620
|
+
const streamedBytes = ref.toolId === 'claude'
|
|
2621
|
+
? sessionGroupsBytes(streamGroups)
|
|
2622
|
+
: (streamsLines ? backend.rawSessionBytes(ref.prefixedId) : 0);
|
|
2623
|
+
const streamed = streamedBytes > FULL_BUILD_MAX_BYTES;
|
|
2624
|
+
const exp = streamed ? null : backend.exportRawSession(ref.prefixedId);
|
|
2611
2625
|
// Content-identity gate: hash the raw export (mtime-independent) BEFORE the
|
|
2612
2626
|
// shadow merge / parse / redact / KG / git-replay. If it equals what this
|
|
2613
2627
|
// target last FULL-synced, nothing downstream can differ — bail now. This
|
|
@@ -2628,9 +2642,9 @@ export async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
2628
2642
|
// The ceiling check after the build therefore cannot protect the build.
|
|
2629
2643
|
// An export over the ceiling gets no container copy and no shadow merge;
|
|
2630
2644
|
// the live parse below reads it once instead.
|
|
2631
|
-
const exportBytes = exportByteLength(exp);
|
|
2645
|
+
const exportBytes = streamed ? streamedBytes : exportByteLength(exp);
|
|
2632
2646
|
const overCeiling = exportBytes > FULL_BUILD_MAX_BYTES;
|
|
2633
|
-
if (exp && overCeiling) {
|
|
2647
|
+
if ((exp || streamed) && overCeiling) {
|
|
2634
2648
|
console.error(`[sync] ${ref.prefixedId} export is ${(exportBytes / 1048576).toFixed(0)}MB `
|
|
2635
2649
|
+ `(over the ${(FULL_BUILD_MAX_BYTES / 1048576).toFixed(0)}MB ceiling) — parsing it in place, `
|
|
2636
2650
|
+ 'no container copy, no shadow merge, no raw archive');
|
|
@@ -2643,30 +2657,37 @@ export async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
2643
2657
|
includeRaw = false;
|
|
2644
2658
|
includeMeta = false;
|
|
2645
2659
|
exportOverCeiling = true;
|
|
2646
|
-
// The secret scan reads
|
|
2660
|
+
// The secret scan reads the files in pieces that end at a line end. The container, the joined text
|
|
2647
2661
|
// and the copy for the scan worker below are what a 44 MB export grew to 838 MB with
|
|
2648
2662
|
// (2026-11-16): the guard above said "no container copy", and then the code after the
|
|
2649
2663
|
// parse exported the session again and built one.
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
if (opts.tenantRules && opts.tenantRules.length > 0) {
|
|
2664
|
+
if (streamed) {
|
|
2665
|
+
overCeilingFindings = ref.toolId === 'claude'
|
|
2666
|
+
? await scanSessionGroupsChunked(ref.prefixedId, streamGroups, opts.tenantRules)
|
|
2667
|
+
: scanLinesChunked(ref.prefixedId, backend.iterateRawSessionLines(ref.prefixedId), opts.tenantRules);
|
|
2668
|
+
}
|
|
2669
|
+
else if (exp) {
|
|
2670
|
+
overCeilingFindings = [];
|
|
2671
|
+
let lineBase = 0;
|
|
2672
|
+
for (const f of exp.files) {
|
|
2673
|
+
const text = f.bytes.toString('utf8');
|
|
2661
2674
|
try {
|
|
2662
|
-
for (const x of
|
|
2663
|
-
overCeilingFindings.push({ session_id: ref.prefixedId, detector:
|
|
2675
|
+
for (const x of scanTextForFindings(text)) {
|
|
2676
|
+
overCeilingFindings.push({ session_id: ref.prefixedId, detector: 'builtin', rule: x.rule, line: x.line + lineBase, preview: x.preview });
|
|
2664
2677
|
}
|
|
2665
2678
|
}
|
|
2666
2679
|
catch { /* best-effort */ }
|
|
2680
|
+
if (opts.tenantRules && opts.tenantRules.length > 0) {
|
|
2681
|
+
try {
|
|
2682
|
+
for (const x of scanTenantRules(text, opts.tenantRules)) {
|
|
2683
|
+
overCeilingFindings.push({ session_id: ref.prefixedId, detector: x.detector, rule: x.rule, line: x.line + lineBase, preview: x.preview });
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
catch { /* best-effort */ }
|
|
2687
|
+
}
|
|
2688
|
+
// The container joins the files with a newline, so the next file starts one line after this one ends.
|
|
2689
|
+
lineBase += (text.match(/\n/g)?.length ?? 0) + 1;
|
|
2667
2690
|
}
|
|
2668
|
-
// The container joins the files with a newline, so the next file starts one line after this one ends.
|
|
2669
|
-
lineBase += (text.match(/\n/g)?.length ?? 0) + 1;
|
|
2670
2691
|
}
|
|
2671
2692
|
}
|
|
2672
2693
|
if (exp && !overCeiling) {
|
|
@@ -2736,7 +2757,7 @@ export async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
2736
2757
|
catch { /* shadow/export failed — fall back to the live parse below */ }
|
|
2737
2758
|
if (!transcript) {
|
|
2738
2759
|
try {
|
|
2739
|
-
const t = await parseTranscript(ref.prefixedId);
|
|
2760
|
+
const t = await parseTranscript(ref.prefixedId, { payloadCap: SYNC_PAYLOAD_CAP });
|
|
2740
2761
|
if (t && (t.messages.length > 0 || t.subagents.length > 0))
|
|
2741
2762
|
transcript = t;
|
|
2742
2763
|
}
|
|
@@ -2759,7 +2780,10 @@ export async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
2759
2780
|
// Trim payload bodies (tool inputs/results, thinking — raw replay never
|
|
2760
2781
|
// ships), then redact every string. Counts are preserved exactly.
|
|
2761
2782
|
const count = { redactions: 0 };
|
|
2762
|
-
const envelope = redactDeep(
|
|
2783
|
+
const envelope = redactDeep(
|
|
2784
|
+
// A transcript the parser already cut is not cut again: the cut is not idempotent.
|
|
2785
|
+
// The path of a subagent file on this machine does not leave it: the container parse gives ''.
|
|
2786
|
+
{ v: TRANSCRIPT_VERSION, ...syncTranscript(transcript) }, count);
|
|
2763
2787
|
// Live telemetry: parse the raw session file with THE metadata parser
|
|
2764
2788
|
// (tokens/cost/models/tools/duration/branch/files). Replaces the former
|
|
2765
2789
|
// local-store `extra_json` read. The metadata parser is Claude-JSONL shaped;
|