chat-recall 0.7.59 → 0.7.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/dist/cli.js +326 -173
- package/dist/mcp.js +310 -159
- package/dist/scan-worker.js +8 -0
- package/dist/session-file-scan.d.ts +22 -0
- package/dist/session-file-scan.d.ts.map +1 -0
- package/dist/session-file-scan.js +108 -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 +41 -22
- package/dist/sync-client.js.map +1 -1
- package/dist/watch.js +322 -169
- package/package.json +1 -1
package/dist/watch.js
CHANGED
|
@@ -6303,6 +6303,42 @@ var init_session = __esm({
|
|
|
6303
6303
|
}
|
|
6304
6304
|
});
|
|
6305
6305
|
|
|
6306
|
+
// ../engine/dist/transcript/trim.js
|
|
6307
|
+
function detach(s) {
|
|
6308
|
+
return JSON.parse(JSON.stringify(s));
|
|
6309
|
+
}
|
|
6310
|
+
function capPayload(v, capChars = SYNC_PAYLOAD_CAP) {
|
|
6311
|
+
if (v === void 0)
|
|
6312
|
+
return void 0;
|
|
6313
|
+
if (typeof v === "string") {
|
|
6314
|
+
return v.length > capChars ? detach(v.slice(0, capChars)) + `\u2026 [+${v.length - capChars} chars]` : v;
|
|
6315
|
+
}
|
|
6316
|
+
let s = "";
|
|
6317
|
+
try {
|
|
6318
|
+
s = JSON.stringify(v) ?? "";
|
|
6319
|
+
} catch {
|
|
6320
|
+
return void 0;
|
|
6321
|
+
}
|
|
6322
|
+
if (s.length <= capChars * 4)
|
|
6323
|
+
return v;
|
|
6324
|
+
if (Array.isArray(v))
|
|
6325
|
+
return detach(s.slice(0, capChars)) + `\u2026 [+${s.length - capChars} chars]`;
|
|
6326
|
+
if (v && typeof v === "object") {
|
|
6327
|
+
const o = {};
|
|
6328
|
+
for (const [k, val] of Object.entries(v))
|
|
6329
|
+
o[k] = capPayload(val, capChars);
|
|
6330
|
+
return o;
|
|
6331
|
+
}
|
|
6332
|
+
return v;
|
|
6333
|
+
}
|
|
6334
|
+
var SYNC_PAYLOAD_CAP;
|
|
6335
|
+
var init_trim = __esm({
|
|
6336
|
+
"../engine/dist/transcript/trim.js"() {
|
|
6337
|
+
"use strict";
|
|
6338
|
+
SYNC_PAYLOAD_CAP = 2e3;
|
|
6339
|
+
}
|
|
6340
|
+
});
|
|
6341
|
+
|
|
6306
6342
|
// ../engine/dist/transcript/claude.js
|
|
6307
6343
|
import { open, readdir, readFile, stat } from "fs/promises";
|
|
6308
6344
|
import { dirname as dirname5, join as join8, basename as basename3 } from "path";
|
|
@@ -6312,127 +6348,50 @@ function stripBanners(text) {
|
|
|
6312
6348
|
out = out.replace(re, " ");
|
|
6313
6349
|
return out.replace(/[ \t]{2,}/g, " ").trim();
|
|
6314
6350
|
}
|
|
6315
|
-
async function parseClaudeTranscript(sessionPath) {
|
|
6316
|
-
return parseMessagesFromFile(sessionPath);
|
|
6351
|
+
async function parseClaudeTranscript(sessionPath, opts = {}) {
|
|
6352
|
+
return parseMessagesFromFile(sessionPath, opts);
|
|
6317
6353
|
}
|
|
6318
|
-
function parseClaudeTranscriptText(text) {
|
|
6319
|
-
const
|
|
6354
|
+
function parseClaudeTranscriptText(text, opts = {}) {
|
|
6355
|
+
const builder = new MessageBuilder(opts.payloadCap);
|
|
6320
6356
|
let lineNumber = 0;
|
|
6321
6357
|
for (const line of text.split("\n")) {
|
|
6322
6358
|
lineNumber++;
|
|
6323
6359
|
if (!line.trim())
|
|
6324
6360
|
continue;
|
|
6361
|
+
let obj;
|
|
6325
6362
|
try {
|
|
6326
|
-
|
|
6363
|
+
obj = JSON.parse(line);
|
|
6327
6364
|
} catch {
|
|
6365
|
+
continue;
|
|
6328
6366
|
}
|
|
6367
|
+
builder.add(lineNumber, obj);
|
|
6329
6368
|
}
|
|
6330
|
-
return
|
|
6369
|
+
return builder.messages;
|
|
6331
6370
|
}
|
|
6332
|
-
async function parseMessagesFromFile(sessionPath) {
|
|
6371
|
+
async function parseMessagesFromFile(sessionPath, opts) {
|
|
6333
6372
|
const file = await open(sessionPath);
|
|
6334
|
-
const
|
|
6373
|
+
const builder = new MessageBuilder(opts.payloadCap);
|
|
6335
6374
|
try {
|
|
6336
6375
|
let lineNumber = 0;
|
|
6337
6376
|
for await (const line of file.readLines()) {
|
|
6338
6377
|
lineNumber++;
|
|
6339
6378
|
if (!line.trim())
|
|
6340
6379
|
continue;
|
|
6380
|
+
let obj;
|
|
6341
6381
|
try {
|
|
6342
|
-
|
|
6382
|
+
obj = JSON.parse(line);
|
|
6343
6383
|
} catch {
|
|
6344
6384
|
log2.debug({ line: lineNumber, file: sessionPath }, "skipped malformed transcript line");
|
|
6385
|
+
continue;
|
|
6345
6386
|
}
|
|
6387
|
+
builder.add(lineNumber, obj);
|
|
6346
6388
|
}
|
|
6347
6389
|
} finally {
|
|
6348
6390
|
await file.close();
|
|
6349
6391
|
}
|
|
6350
|
-
return
|
|
6392
|
+
return builder.messages;
|
|
6351
6393
|
}
|
|
6352
|
-
function
|
|
6353
|
-
const toolResults = /* @__PURE__ */ new Map();
|
|
6354
|
-
for (const { obj } of raw) {
|
|
6355
|
-
if (obj?.type !== "user")
|
|
6356
|
-
continue;
|
|
6357
|
-
const content = obj.message?.content;
|
|
6358
|
-
if (!Array.isArray(content))
|
|
6359
|
-
continue;
|
|
6360
|
-
for (const block of content) {
|
|
6361
|
-
if (block?.type === "tool_result" && block.tool_use_id) {
|
|
6362
|
-
toolResults.set(block.tool_use_id, {
|
|
6363
|
-
content: block.content,
|
|
6364
|
-
isError: block.is_error === true
|
|
6365
|
-
});
|
|
6366
|
-
}
|
|
6367
|
-
}
|
|
6368
|
-
}
|
|
6369
|
-
const messages = [];
|
|
6370
|
-
for (const { line, obj } of raw) {
|
|
6371
|
-
if (!obj || typeof obj !== "object")
|
|
6372
|
-
continue;
|
|
6373
|
-
const timestamp = typeof obj.timestamp === "string" ? obj.timestamp : void 0;
|
|
6374
|
-
if (obj.type === "user") {
|
|
6375
|
-
const content = obj.message?.content;
|
|
6376
|
-
let text = "";
|
|
6377
|
-
if (typeof content === "string") {
|
|
6378
|
-
text = content;
|
|
6379
|
-
} else if (Array.isArray(content)) {
|
|
6380
|
-
text = content.filter((c) => c?.type === "text" && typeof c.text === "string").map((c) => c.text).join("\n");
|
|
6381
|
-
}
|
|
6382
|
-
if (!text.trim())
|
|
6383
|
-
continue;
|
|
6384
|
-
const cleaned = stripBanners(text);
|
|
6385
|
-
if (!cleaned)
|
|
6386
|
-
continue;
|
|
6387
|
-
const origin = userRecordOrigin(obj, cleaned);
|
|
6388
|
-
messages.push({ line, role: "user", content: cleaned, timestamp, ...origin === "human" ? {} : { origin } });
|
|
6389
|
-
} else if (obj.type === "attachment") {
|
|
6390
|
-
const queued = queuedCommandPrompt(obj);
|
|
6391
|
-
if (!queued)
|
|
6392
|
-
continue;
|
|
6393
|
-
const cleaned = stripBanners(queued.text);
|
|
6394
|
-
if (!cleaned)
|
|
6395
|
-
continue;
|
|
6396
|
-
messages.push({ line, role: "user", content: cleaned, timestamp, ...queued.origin === "human" ? {} : { origin: queued.origin } });
|
|
6397
|
-
} else if (obj.type === "assistant") {
|
|
6398
|
-
const blocks = Array.isArray(obj.message?.content) ? obj.message.content : [];
|
|
6399
|
-
const thinkingBlock = blocks.find((c) => c?.type === "thinking");
|
|
6400
|
-
const textBlock = blocks.find((c) => c?.type === "text");
|
|
6401
|
-
const toolUses = blocks.filter((c) => c?.type === "tool_use");
|
|
6402
|
-
const toolCalls = toolUses.map((toolUse) => {
|
|
6403
|
-
const result = toolUse.id ? toolResults.get(toolUse.id) : void 0;
|
|
6404
|
-
return {
|
|
6405
|
-
name: toolUse.name || "unknown",
|
|
6406
|
-
input: toolUse.input,
|
|
6407
|
-
result: result?.content,
|
|
6408
|
-
isError: result?.isError
|
|
6409
|
-
};
|
|
6410
|
-
});
|
|
6411
|
-
const hasThinking = thinkingBlock !== void 0;
|
|
6412
|
-
const text = textBlock?.text ?? "";
|
|
6413
|
-
const thinking = thinkingBlock?.thinking ?? (hasThinking ? "" : void 0);
|
|
6414
|
-
if (!text && !hasThinking && toolCalls.length === 0)
|
|
6415
|
-
continue;
|
|
6416
|
-
messages.push({
|
|
6417
|
-
line,
|
|
6418
|
-
role: "assistant",
|
|
6419
|
-
content: text,
|
|
6420
|
-
thinking,
|
|
6421
|
-
toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
6422
|
-
timestamp
|
|
6423
|
-
});
|
|
6424
|
-
} else if (obj.type === "summary" && typeof obj.summary === "string") {
|
|
6425
|
-
messages.push({ line, role: "summary", content: obj.summary });
|
|
6426
|
-
} else if (obj.type === "system" && obj.subtype === "away_summary") {
|
|
6427
|
-
const c = obj.content;
|
|
6428
|
-
const text = typeof c === "string" ? c : Array.isArray(c) ? c.filter((b) => b?.type === "text" && typeof b.text === "string").map((b) => b.text).join("\n") : "";
|
|
6429
|
-
if (text.trim())
|
|
6430
|
-
messages.push({ line, role: "summary", content: stripBanners(text), timestamp });
|
|
6431
|
-
}
|
|
6432
|
-
}
|
|
6433
|
-
return messages;
|
|
6434
|
-
}
|
|
6435
|
-
async function parseClaudeSubagents(sessionPath) {
|
|
6394
|
+
async function parseClaudeSubagents(sessionPath, opts = {}) {
|
|
6436
6395
|
const sessionId = basename3(sessionPath).replace(/\.jsonl$/i, "");
|
|
6437
6396
|
const subagentsDir = join8(dirname5(sessionPath), sessionId, "subagents");
|
|
6438
6397
|
let entries;
|
|
@@ -6459,7 +6418,7 @@ async function parseClaudeSubagents(sessionPath) {
|
|
|
6459
6418
|
}
|
|
6460
6419
|
let messages = [];
|
|
6461
6420
|
try {
|
|
6462
|
-
messages = await parseMessagesFromFile(filePath);
|
|
6421
|
+
messages = await parseMessagesFromFile(filePath, opts);
|
|
6463
6422
|
} catch (e) {
|
|
6464
6423
|
log2.error({ err: e, filePath }, "Failed to parse subagent");
|
|
6465
6424
|
}
|
|
@@ -6484,12 +6443,13 @@ async function parseClaudeSubagents(sessionPath) {
|
|
|
6484
6443
|
}));
|
|
6485
6444
|
return subagents.map((s, i) => ({ s, mtime: stats[i] })).sort((a, b) => a.mtime - b.mtime).map(({ s }) => s);
|
|
6486
6445
|
}
|
|
6487
|
-
var log2, INJECTED_BANNERS2;
|
|
6446
|
+
var log2, INJECTED_BANNERS2, MessageBuilder;
|
|
6488
6447
|
var init_claude = __esm({
|
|
6489
6448
|
"../engine/dist/transcript/claude.js"() {
|
|
6490
6449
|
"use strict";
|
|
6491
6450
|
init_logger();
|
|
6492
6451
|
init_claude_prompt_origin();
|
|
6452
|
+
init_trim();
|
|
6493
6453
|
log2 = createLogger("transcript-claude");
|
|
6494
6454
|
INJECTED_BANNERS2 = [
|
|
6495
6455
|
/MCP issues detected\. ?Run \/mcp list for status\.?/g,
|
|
@@ -6508,6 +6468,104 @@ var init_claude = __esm({
|
|
|
6508
6468
|
// eslint-disable-next-line no-control-regex
|
|
6509
6469
|
/\[[0-9;]*m/g
|
|
6510
6470
|
];
|
|
6471
|
+
MessageBuilder = class {
|
|
6472
|
+
messages = [];
|
|
6473
|
+
cap;
|
|
6474
|
+
/** The calls of each tool_use id. */
|
|
6475
|
+
calls = /* @__PURE__ */ new Map();
|
|
6476
|
+
/** The last result of each tool_use id. */
|
|
6477
|
+
results = /* @__PURE__ */ new Map();
|
|
6478
|
+
constructor(payloadCap) {
|
|
6479
|
+
this.cap = payloadCap ? (v) => capPayload(v, payloadCap) : (v) => v;
|
|
6480
|
+
}
|
|
6481
|
+
add(line, obj) {
|
|
6482
|
+
if (!obj || typeof obj !== "object")
|
|
6483
|
+
return;
|
|
6484
|
+
const timestamp = typeof obj.timestamp === "string" ? obj.timestamp : void 0;
|
|
6485
|
+
if (obj.type === "user") {
|
|
6486
|
+
const content = obj.message?.content;
|
|
6487
|
+
if (Array.isArray(content)) {
|
|
6488
|
+
for (const block of content) {
|
|
6489
|
+
if (block?.type === "tool_result" && block.tool_use_id) {
|
|
6490
|
+
this.addResult(block.tool_use_id, this.cap(block.content), block.is_error === true);
|
|
6491
|
+
}
|
|
6492
|
+
}
|
|
6493
|
+
}
|
|
6494
|
+
let text = "";
|
|
6495
|
+
if (typeof content === "string") {
|
|
6496
|
+
text = content;
|
|
6497
|
+
} else if (Array.isArray(content)) {
|
|
6498
|
+
text = content.filter((c) => c?.type === "text" && typeof c.text === "string").map((c) => c.text).join("\n");
|
|
6499
|
+
}
|
|
6500
|
+
if (!text.trim())
|
|
6501
|
+
return;
|
|
6502
|
+
const cleaned = stripBanners(text);
|
|
6503
|
+
if (!cleaned)
|
|
6504
|
+
return;
|
|
6505
|
+
const origin = userRecordOrigin(obj, cleaned);
|
|
6506
|
+
this.messages.push({ line, role: "user", content: cleaned, timestamp, ...origin === "human" ? {} : { origin } });
|
|
6507
|
+
} else if (obj.type === "attachment") {
|
|
6508
|
+
const queued = queuedCommandPrompt(obj);
|
|
6509
|
+
if (!queued)
|
|
6510
|
+
return;
|
|
6511
|
+
const cleaned = stripBanners(queued.text);
|
|
6512
|
+
if (!cleaned)
|
|
6513
|
+
return;
|
|
6514
|
+
this.messages.push({ line, role: "user", content: cleaned, timestamp, ...queued.origin === "human" ? {} : { origin: queued.origin } });
|
|
6515
|
+
} else if (obj.type === "assistant") {
|
|
6516
|
+
const blocks = Array.isArray(obj.message?.content) ? obj.message.content : [];
|
|
6517
|
+
const thinkingBlock = blocks.find((c) => c?.type === "thinking");
|
|
6518
|
+
const textBlock = blocks.find((c) => c?.type === "text");
|
|
6519
|
+
const toolUses = blocks.filter((c) => c?.type === "tool_use");
|
|
6520
|
+
const toolCalls = toolUses.map((toolUse) => {
|
|
6521
|
+
const known = toolUse.id ? this.results.get(toolUse.id) : void 0;
|
|
6522
|
+
const call2 = {
|
|
6523
|
+
name: toolUse.name || "unknown",
|
|
6524
|
+
input: this.cap(toolUse.input),
|
|
6525
|
+
result: known?.content,
|
|
6526
|
+
isError: known?.isError
|
|
6527
|
+
};
|
|
6528
|
+
if (toolUse.id) {
|
|
6529
|
+
const list = this.calls.get(toolUse.id);
|
|
6530
|
+
if (list)
|
|
6531
|
+
list.push(call2);
|
|
6532
|
+
else
|
|
6533
|
+
this.calls.set(toolUse.id, [call2]);
|
|
6534
|
+
}
|
|
6535
|
+
return call2;
|
|
6536
|
+
});
|
|
6537
|
+
const hasThinking = thinkingBlock !== void 0;
|
|
6538
|
+
const text = textBlock?.text ?? "";
|
|
6539
|
+
const thinking = thinkingBlock?.thinking != null ? this.cap(thinkingBlock.thinking) : hasThinking ? "" : void 0;
|
|
6540
|
+
if (!text && !hasThinking && toolCalls.length === 0)
|
|
6541
|
+
return;
|
|
6542
|
+
this.messages.push({
|
|
6543
|
+
line,
|
|
6544
|
+
role: "assistant",
|
|
6545
|
+
content: text,
|
|
6546
|
+
thinking,
|
|
6547
|
+
toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
6548
|
+
timestamp
|
|
6549
|
+
});
|
|
6550
|
+
} else if (obj.type === "summary" && typeof obj.summary === "string") {
|
|
6551
|
+
this.messages.push({ line, role: "summary", content: obj.summary });
|
|
6552
|
+
} else if (obj.type === "system" && obj.subtype === "away_summary") {
|
|
6553
|
+
const c = obj.content;
|
|
6554
|
+
const text = typeof c === "string" ? c : Array.isArray(c) ? c.filter((b) => b?.type === "text" && typeof b.text === "string").map((b) => b.text).join("\n") : "";
|
|
6555
|
+
if (text.trim())
|
|
6556
|
+
this.messages.push({ line, role: "summary", content: stripBanners(text), timestamp });
|
|
6557
|
+
}
|
|
6558
|
+
}
|
|
6559
|
+
addResult(id, content, isError) {
|
|
6560
|
+
this.results.set(id, { content, isError });
|
|
6561
|
+
const list = this.calls.get(id);
|
|
6562
|
+
if (list)
|
|
6563
|
+
for (const call2 of list) {
|
|
6564
|
+
call2.result = content;
|
|
6565
|
+
call2.isError = isError;
|
|
6566
|
+
}
|
|
6567
|
+
}
|
|
6568
|
+
};
|
|
6511
6569
|
}
|
|
6512
6570
|
});
|
|
6513
6571
|
|
|
@@ -16092,10 +16150,12 @@ var init_opencode2 = __esm({
|
|
|
16092
16150
|
var transcript_exports = {};
|
|
16093
16151
|
__export(transcript_exports, {
|
|
16094
16152
|
RAW_PARSE_MAX_BYTES: () => RAW_PARSE_MAX_BYTES,
|
|
16153
|
+
SYNC_PAYLOAD_CAP: () => SYNC_PAYLOAD_CAP,
|
|
16095
16154
|
TRANSCRIPT_VERSION: () => TRANSCRIPT_VERSION,
|
|
16096
16155
|
archiveRawSession: () => archiveRawSession,
|
|
16097
16156
|
buildRawContainer: () => buildRawContainer,
|
|
16098
16157
|
canonicalEventsToMessages: () => canonicalEventsToMessages,
|
|
16158
|
+
capPayload: () => capPayload,
|
|
16099
16159
|
containerSrcHash: () => containerSrcHash,
|
|
16100
16160
|
detectForkPredecessor: () => detectForkPredecessor,
|
|
16101
16161
|
gunzipContainer: () => gunzipContainer,
|
|
@@ -16130,7 +16190,14 @@ __export(transcript_exports, {
|
|
|
16130
16190
|
writeTranscriptEnvelope: () => writeTranscriptEnvelope
|
|
16131
16191
|
});
|
|
16132
16192
|
import { statSync as statSync20 } from "fs";
|
|
16133
|
-
async function parseTranscript(sessionId) {
|
|
16193
|
+
async function parseTranscript(sessionId, opts = {}) {
|
|
16194
|
+
const t = await parseTranscriptUncut(sessionId, opts);
|
|
16195
|
+
const cap = opts.payloadCap;
|
|
16196
|
+
if (!t || !cap || t.payloadCap === cap)
|
|
16197
|
+
return t;
|
|
16198
|
+
return { ...t, ...trimTranscriptForSync(t, cap), payloadCap: cap };
|
|
16199
|
+
}
|
|
16200
|
+
async function parseTranscriptUncut(sessionId, opts) {
|
|
16134
16201
|
const tool = detectTool(sessionId);
|
|
16135
16202
|
if (tool === "claude") {
|
|
16136
16203
|
const groups = resolveSessionContentGroups(sessionId);
|
|
@@ -16141,9 +16208,10 @@ async function parseTranscript(sessionId) {
|
|
|
16141
16208
|
return null;
|
|
16142
16209
|
const primaryPath = mainGroup.paths[0];
|
|
16143
16210
|
const merged = readSessionGroupText(mainGroup);
|
|
16211
|
+
const cut = opts.payloadCap ? { payloadCap: opts.payloadCap } : {};
|
|
16144
16212
|
const [tail, allSubagents] = await Promise.all([
|
|
16145
|
-
Promise.resolve(parseClaudeTranscriptText(merged.text)),
|
|
16146
|
-
parseClaudeSubagents(primaryPath)
|
|
16213
|
+
Promise.resolve(parseClaudeTranscriptText(merged.text, cut)),
|
|
16214
|
+
parseClaudeSubagents(primaryPath, cut)
|
|
16147
16215
|
]);
|
|
16148
16216
|
const compacts = allSubagents.filter((s) => s.kind === "compact");
|
|
16149
16217
|
const subagents = allSubagents.filter((s) => s.kind !== "compact");
|
|
@@ -16160,7 +16228,7 @@ async function parseTranscript(sessionId) {
|
|
|
16160
16228
|
}
|
|
16161
16229
|
messages = [...stitched, ...tail].map((m, i) => ({ ...m, line: i + 1 }));
|
|
16162
16230
|
}
|
|
16163
|
-
return { messages, subagents, mtime: merged.mtime || safeMtime(primaryPath) };
|
|
16231
|
+
return { messages, subagents, mtime: merged.mtime || safeMtime(primaryPath), ...opts.payloadCap ? { payloadCap: opts.payloadCap } : {} };
|
|
16164
16232
|
}
|
|
16165
16233
|
if (tool === "opencode") {
|
|
16166
16234
|
const messages = await parseOpenCodeTranscript(sessionId);
|
|
@@ -16202,31 +16270,8 @@ function safeMtime(path) {
|
|
|
16202
16270
|
return 0;
|
|
16203
16271
|
}
|
|
16204
16272
|
}
|
|
16205
|
-
function trimTranscriptForSync(t, capChars =
|
|
16206
|
-
const cap = (v) =>
|
|
16207
|
-
if (v === void 0)
|
|
16208
|
-
return void 0;
|
|
16209
|
-
if (typeof v === "string") {
|
|
16210
|
-
return v.length > capChars ? v.slice(0, capChars) + `\u2026 [+${v.length - capChars} chars]` : v;
|
|
16211
|
-
}
|
|
16212
|
-
let s = "";
|
|
16213
|
-
try {
|
|
16214
|
-
s = JSON.stringify(v) ?? "";
|
|
16215
|
-
} catch {
|
|
16216
|
-
return void 0;
|
|
16217
|
-
}
|
|
16218
|
-
if (s.length <= capChars * 4)
|
|
16219
|
-
return v;
|
|
16220
|
-
if (Array.isArray(v))
|
|
16221
|
-
return s.slice(0, capChars) + `\u2026 [+${s.length - capChars} chars]`;
|
|
16222
|
-
if (v && typeof v === "object") {
|
|
16223
|
-
const o = {};
|
|
16224
|
-
for (const [k, val] of Object.entries(v))
|
|
16225
|
-
o[k] = cap(val);
|
|
16226
|
-
return o;
|
|
16227
|
-
}
|
|
16228
|
-
return v;
|
|
16229
|
-
};
|
|
16273
|
+
function trimTranscriptForSync(t, capChars = SYNC_PAYLOAD_CAP) {
|
|
16274
|
+
const cap = (v) => capPayload(v, capChars);
|
|
16230
16275
|
const trimMsg = (m) => ({
|
|
16231
16276
|
...m,
|
|
16232
16277
|
thinking: m.thinking !== void 0 ? cap(m.thinking) : void 0,
|
|
@@ -16258,7 +16303,9 @@ var init_transcript = __esm({
|
|
|
16258
16303
|
init_opencode2();
|
|
16259
16304
|
init_codex();
|
|
16260
16305
|
init_from_events();
|
|
16306
|
+
init_trim();
|
|
16261
16307
|
init_types();
|
|
16308
|
+
init_trim();
|
|
16262
16309
|
init_raw();
|
|
16263
16310
|
init_shadow();
|
|
16264
16311
|
init_claude();
|
|
@@ -28694,8 +28741,100 @@ var init_telemetry = __esm({
|
|
|
28694
28741
|
}
|
|
28695
28742
|
});
|
|
28696
28743
|
|
|
28744
|
+
// src/session-file-scan.ts
|
|
28745
|
+
import { open as open3 } from "node:fs/promises";
|
|
28746
|
+
import { statSync as statSync39 } from "node:fs";
|
|
28747
|
+
function sessionGroupsBytes(groups) {
|
|
28748
|
+
let total = 0;
|
|
28749
|
+
for (const g of groups) {
|
|
28750
|
+
for (const p of g.paths) {
|
|
28751
|
+
try {
|
|
28752
|
+
total += statSync39(p).size;
|
|
28753
|
+
} catch {
|
|
28754
|
+
}
|
|
28755
|
+
}
|
|
28756
|
+
}
|
|
28757
|
+
return total;
|
|
28758
|
+
}
|
|
28759
|
+
async function* readLinePieces(path, pieceBytes = SCAN_PIECE_BYTES) {
|
|
28760
|
+
const fh = await open3(path, "r");
|
|
28761
|
+
try {
|
|
28762
|
+
const buf = Buffer.allocUnsafe(pieceBytes);
|
|
28763
|
+
let carry = Buffer.alloc(0);
|
|
28764
|
+
for (; ; ) {
|
|
28765
|
+
const { bytesRead } = await fh.read(buf, 0, pieceBytes, null);
|
|
28766
|
+
if (bytesRead === 0) break;
|
|
28767
|
+
const joined = carry.length ? Buffer.concat([carry, buf.subarray(0, bytesRead)]) : buf.subarray(0, bytesRead);
|
|
28768
|
+
const cut = joined.lastIndexOf(NEWLINE);
|
|
28769
|
+
if (cut < 0) {
|
|
28770
|
+
carry = Buffer.from(joined);
|
|
28771
|
+
continue;
|
|
28772
|
+
}
|
|
28773
|
+
const piece = joined.subarray(0, cut + 1);
|
|
28774
|
+
carry = Buffer.from(joined.subarray(cut + 1));
|
|
28775
|
+
yield { text: piece.toString("utf8"), newlines: countNewlines(piece) };
|
|
28776
|
+
}
|
|
28777
|
+
if (carry.length) yield { text: carry.toString("utf8"), newlines: 0 };
|
|
28778
|
+
} finally {
|
|
28779
|
+
await fh.close();
|
|
28780
|
+
}
|
|
28781
|
+
}
|
|
28782
|
+
function countNewlines(b) {
|
|
28783
|
+
let n = 0;
|
|
28784
|
+
for (let i = b.indexOf(NEWLINE); i >= 0; i = b.indexOf(NEWLINE, i + 1)) n++;
|
|
28785
|
+
return n;
|
|
28786
|
+
}
|
|
28787
|
+
async function scanSessionGroupsChunked(sessionId, groups, tenantRules, pieceBytes = SCAN_PIECE_BYTES) {
|
|
28788
|
+
const findings = [];
|
|
28789
|
+
let lineBase = 0;
|
|
28790
|
+
const scan = (text) => {
|
|
28791
|
+
try {
|
|
28792
|
+
for (const x of scanTextForFindings(text)) {
|
|
28793
|
+
findings.push({ session_id: sessionId, detector: "builtin", rule: x.rule, line: x.line + lineBase, preview: x.preview });
|
|
28794
|
+
}
|
|
28795
|
+
} catch {
|
|
28796
|
+
}
|
|
28797
|
+
if (tenantRules && tenantRules.length > 0) {
|
|
28798
|
+
try {
|
|
28799
|
+
for (const x of scanTenantRules(text, tenantRules)) {
|
|
28800
|
+
findings.push({ session_id: sessionId, detector: x.detector, rule: x.rule, line: x.line + lineBase, preview: x.preview });
|
|
28801
|
+
}
|
|
28802
|
+
} catch {
|
|
28803
|
+
}
|
|
28804
|
+
}
|
|
28805
|
+
};
|
|
28806
|
+
for (const group of groups) {
|
|
28807
|
+
if (group.paths.length === 1) {
|
|
28808
|
+
let any = false;
|
|
28809
|
+
for await (const piece of readLinePieces(group.paths[0], pieceBytes)) {
|
|
28810
|
+
any = true;
|
|
28811
|
+
scan(piece.text);
|
|
28812
|
+
lineBase += piece.newlines;
|
|
28813
|
+
}
|
|
28814
|
+
if (any) lineBase += 1;
|
|
28815
|
+
} else {
|
|
28816
|
+
const { text } = readSessionGroupText(group);
|
|
28817
|
+
if (!text) continue;
|
|
28818
|
+
scan(text);
|
|
28819
|
+
lineBase += (text.match(/\n/g)?.length ?? 0) + 1;
|
|
28820
|
+
}
|
|
28821
|
+
}
|
|
28822
|
+
return findings;
|
|
28823
|
+
}
|
|
28824
|
+
var SCAN_PIECE_BYTES, NEWLINE;
|
|
28825
|
+
var init_session_file_scan = __esm({
|
|
28826
|
+
"src/session-file-scan.ts"() {
|
|
28827
|
+
"use strict";
|
|
28828
|
+
init_secret_redactor();
|
|
28829
|
+
init_secret_scanner();
|
|
28830
|
+
init_live_session_scan();
|
|
28831
|
+
SCAN_PIECE_BYTES = 8 * 1024 * 1024;
|
|
28832
|
+
NEWLINE = 10;
|
|
28833
|
+
}
|
|
28834
|
+
});
|
|
28835
|
+
|
|
28697
28836
|
// src/raw-archive-parts.ts
|
|
28698
|
-
import { createReadStream as createReadStream4, createWriteStream, openSync as openSync10, readSync as readSync9, closeSync as closeSync10, rmSync as rmSync5, statSync as
|
|
28837
|
+
import { createReadStream as createReadStream4, createWriteStream, openSync as openSync10, readSync as readSync9, closeSync as closeSync10, rmSync as rmSync5, statSync as statSync40 } from "node:fs";
|
|
28699
28838
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
28700
28839
|
import { join as join46 } from "node:path";
|
|
28701
28840
|
import { randomBytes } from "node:crypto";
|
|
@@ -28763,7 +28902,7 @@ async function writeArchiveFile(source, meta, redact, dir = tmpdir2()) {
|
|
|
28763
28902
|
rmSync5(path, { force: true });
|
|
28764
28903
|
throw err;
|
|
28765
28904
|
}
|
|
28766
|
-
return { path, gzSize:
|
|
28905
|
+
return { path, gzSize: statSync40(path).size, size };
|
|
28767
28906
|
}
|
|
28768
28907
|
async function putPart(url, body) {
|
|
28769
28908
|
let last;
|
|
@@ -29066,7 +29205,7 @@ __export(auto_update_exports, {
|
|
|
29066
29205
|
import { execSync as execSync2, execFileSync as execFileSync3 } from "node:child_process";
|
|
29067
29206
|
import { readFileSync as readFileSync41, existsSync as existsSync43 } from "node:fs";
|
|
29068
29207
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
29069
|
-
import { writeFileSync as writeFileSync10, mkdtempSync as mkdtempSync3, rmSync as rmSync6, readdirSync as readdirSync31, statSync as
|
|
29208
|
+
import { writeFileSync as writeFileSync10, mkdtempSync as mkdtempSync3, rmSync as rmSync6, readdirSync as readdirSync31, statSync as statSync41, mkdirSync as mkdirSync10 } from "node:fs";
|
|
29070
29209
|
import { join as join47, dirname as dirname18, sep as sep2, posix as pathPosix, win32 as pathWin32 } from "node:path";
|
|
29071
29210
|
import { tmpdir as tmpdir3, homedir as homedir16 } from "node:os";
|
|
29072
29211
|
import { createHash as createHash9 } from "node:crypto";
|
|
@@ -29119,7 +29258,7 @@ function sweepStaleStaging(root = tmpdir3(), now = Date.now()) {
|
|
|
29119
29258
|
if (!MKDTEMP_SUFFIX.test(name)) continue;
|
|
29120
29259
|
const dir = join47(root, name);
|
|
29121
29260
|
try {
|
|
29122
|
-
const st =
|
|
29261
|
+
const st = statSync41(dir);
|
|
29123
29262
|
if (!st.isDirectory() || now - st.mtimeMs < COLD_MS) continue;
|
|
29124
29263
|
const inside = readdirSync31(dir);
|
|
29125
29264
|
if (inside.length > 1 || inside.length === 1 && inside[0] !== "chat-recall.tgz") continue;
|
|
@@ -29363,7 +29502,7 @@ var init_auto_update = __esm({
|
|
|
29363
29502
|
|
|
29364
29503
|
// src/sync-client.ts
|
|
29365
29504
|
import { join as join48, dirname as dirname19, basename as basename22 } from "node:path";
|
|
29366
|
-
import { readFileSync as readFileSync42, writeFileSync as writeFileSync11, mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync4, rmSync as rmSync7, chmodSync as chmodSync4, unlinkSync as unlinkSync2, readdirSync as readdirSync32, statSync as
|
|
29505
|
+
import { readFileSync as readFileSync42, writeFileSync as writeFileSync11, mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync4, rmSync as rmSync7, chmodSync as chmodSync4, unlinkSync as unlinkSync2, readdirSync as readdirSync32, statSync as statSync42 } from "node:fs";
|
|
29367
29506
|
import { tmpdir as tmpdir4, hostname as hostname2 } from "node:os";
|
|
29368
29507
|
import { createHash as createHash10 } from "node:crypto";
|
|
29369
29508
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
@@ -29778,7 +29917,7 @@ function reapStaleScanDirs(dir = tmpdir4(), maxAgeMs = 6 * 36e5, now = Date.now(
|
|
|
29778
29917
|
if (!name.startsWith("cr-batchscan-")) continue;
|
|
29779
29918
|
const p = join48(dir, name);
|
|
29780
29919
|
try {
|
|
29781
|
-
if (now -
|
|
29920
|
+
if (now - statSync42(p).mtimeMs < maxAgeMs) continue;
|
|
29782
29921
|
rmSync7(p, { recursive: true, force: true });
|
|
29783
29922
|
reaped++;
|
|
29784
29923
|
} catch {
|
|
@@ -30677,6 +30816,10 @@ function sessionFileBytes(ref) {
|
|
|
30677
30816
|
if (!backend?.isAppendOnly?.()) return 0;
|
|
30678
30817
|
return backend.fileSize?.(ref.prefixedId) ?? 0;
|
|
30679
30818
|
}
|
|
30819
|
+
function syncTranscript(t) {
|
|
30820
|
+
const cut = t.payloadCap ? { messages: t.messages, subagents: t.subagents } : trimTranscriptForSync(t);
|
|
30821
|
+
return { messages: cut.messages, subagents: cut.subagents.map((s) => ({ ...s, filePath: "" })) };
|
|
30822
|
+
}
|
|
30680
30823
|
function sessionBuildBytes(ref) {
|
|
30681
30824
|
const main = sessionFileBytes(ref);
|
|
30682
30825
|
if (main === 0) return 0;
|
|
@@ -30713,11 +30856,14 @@ async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
30713
30856
|
} else {
|
|
30714
30857
|
try {
|
|
30715
30858
|
const backend = getBackendForId(ref.prefixedId) ?? getBackend("claude");
|
|
30716
|
-
const
|
|
30859
|
+
const streamGroups = ref.toolId === "claude" ? resolveSessionContentGroups(ref.rawId) : [];
|
|
30860
|
+
const streamedBytes = sessionGroupsBytes(streamGroups);
|
|
30861
|
+
const streamed = streamedBytes > FULL_BUILD_MAX_BYTES;
|
|
30862
|
+
const exp = streamed ? null : backend.exportRawSession(ref.prefixedId);
|
|
30717
30863
|
let built;
|
|
30718
|
-
const exportBytes = exportByteLength(exp);
|
|
30864
|
+
const exportBytes = streamed ? streamedBytes : exportByteLength(exp);
|
|
30719
30865
|
const overCeiling = exportBytes > FULL_BUILD_MAX_BYTES;
|
|
30720
|
-
if (exp && overCeiling) {
|
|
30866
|
+
if ((exp || streamed) && overCeiling) {
|
|
30721
30867
|
console.error(`[sync] ${ref.prefixedId} export is ${(exportBytes / 1048576).toFixed(0)}MB (over the ${(FULL_BUILD_MAX_BYTES / 1048576).toFixed(0)}MB ceiling) \u2014 parsing it in place, no container copy, no shadow merge, no raw archive`);
|
|
30722
30868
|
record({
|
|
30723
30869
|
kind: "oversized_session",
|
|
@@ -30728,25 +30874,29 @@ async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
30728
30874
|
includeRaw = false;
|
|
30729
30875
|
includeMeta = false;
|
|
30730
30876
|
exportOverCeiling = true;
|
|
30731
|
-
|
|
30732
|
-
|
|
30733
|
-
|
|
30734
|
-
|
|
30735
|
-
|
|
30736
|
-
|
|
30737
|
-
|
|
30738
|
-
}
|
|
30739
|
-
} catch {
|
|
30740
|
-
}
|
|
30741
|
-
if (opts.tenantRules && opts.tenantRules.length > 0) {
|
|
30877
|
+
if (streamed) {
|
|
30878
|
+
overCeilingFindings = await scanSessionGroupsChunked(ref.prefixedId, streamGroups, opts.tenantRules);
|
|
30879
|
+
} else if (exp) {
|
|
30880
|
+
overCeilingFindings = [];
|
|
30881
|
+
let lineBase = 0;
|
|
30882
|
+
for (const f of exp.files) {
|
|
30883
|
+
const text = f.bytes.toString("utf8");
|
|
30742
30884
|
try {
|
|
30743
|
-
for (const x of
|
|
30744
|
-
overCeilingFindings.push({ session_id: ref.prefixedId, detector:
|
|
30885
|
+
for (const x of scanTextForFindings(text)) {
|
|
30886
|
+
overCeilingFindings.push({ session_id: ref.prefixedId, detector: "builtin", rule: x.rule, line: x.line + lineBase, preview: x.preview });
|
|
30745
30887
|
}
|
|
30746
30888
|
} catch {
|
|
30747
30889
|
}
|
|
30890
|
+
if (opts.tenantRules && opts.tenantRules.length > 0) {
|
|
30891
|
+
try {
|
|
30892
|
+
for (const x of scanTenantRules(text, opts.tenantRules)) {
|
|
30893
|
+
overCeilingFindings.push({ session_id: ref.prefixedId, detector: x.detector, rule: x.rule, line: x.line + lineBase, preview: x.preview });
|
|
30894
|
+
}
|
|
30895
|
+
} catch {
|
|
30896
|
+
}
|
|
30897
|
+
}
|
|
30898
|
+
lineBase += (text.match(/\n/g)?.length ?? 0) + 1;
|
|
30748
30899
|
}
|
|
30749
|
-
lineBase += (text.match(/\n/g)?.length ?? 0) + 1;
|
|
30750
30900
|
}
|
|
30751
30901
|
}
|
|
30752
30902
|
if (exp && !overCeiling) {
|
|
@@ -30786,7 +30936,7 @@ async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
30786
30936
|
}
|
|
30787
30937
|
if (!transcript) {
|
|
30788
30938
|
try {
|
|
30789
|
-
const t = await parseTranscript(ref.prefixedId);
|
|
30939
|
+
const t = await parseTranscript(ref.prefixedId, { payloadCap: SYNC_PAYLOAD_CAP });
|
|
30790
30940
|
if (t && (t.messages.length > 0 || t.subagents.length > 0)) transcript = t;
|
|
30791
30941
|
} catch {
|
|
30792
30942
|
}
|
|
@@ -30799,7 +30949,9 @@ async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
30799
30949
|
if (isInternalToolPrompt(firstUser?.content)) return null;
|
|
30800
30950
|
const count = { redactions: 0 };
|
|
30801
30951
|
const envelope = redactDeep(
|
|
30802
|
-
|
|
30952
|
+
// A transcript the parser already cut is not cut again: the cut is not idempotent.
|
|
30953
|
+
// The path of a subagent file on this machine does not leave it: the container parse gives ''.
|
|
30954
|
+
{ v: TRANSCRIPT_VERSION, ...syncTranscript(transcript) },
|
|
30803
30955
|
count
|
|
30804
30956
|
);
|
|
30805
30957
|
let projectPath = ref.projectPath;
|
|
@@ -31171,6 +31323,7 @@ var init_sync_client = __esm({
|
|
|
31171
31323
|
init_telemetry();
|
|
31172
31324
|
init_collector_health();
|
|
31173
31325
|
init_live_session_scan();
|
|
31326
|
+
init_session_file_scan();
|
|
31174
31327
|
init_raw_archive_parts();
|
|
31175
31328
|
init_backends();
|
|
31176
31329
|
ownVersion = "0.0.0";
|
|
@@ -32008,7 +32161,7 @@ var init_code_task_status = __esm({
|
|
|
32008
32161
|
});
|
|
32009
32162
|
|
|
32010
32163
|
// src/project-tasks.ts
|
|
32011
|
-
import { existsSync as existsSync45, readFileSync as readFileSync45, writeFileSync as writeFileSync13, mkdirSync as mkdirSync13, statSync as
|
|
32164
|
+
import { existsSync as existsSync45, readFileSync as readFileSync45, writeFileSync as writeFileSync13, mkdirSync as mkdirSync13, statSync as statSync43 } from "node:fs";
|
|
32012
32165
|
import { join as join51, dirname as dirname21 } from "node:path";
|
|
32013
32166
|
import { homedir as homedir19 } from "node:os";
|
|
32014
32167
|
function isTeamTaskStatus(v) {
|
|
@@ -32021,7 +32174,7 @@ function isValidStatus(kind, v) {
|
|
|
32021
32174
|
return kind === "secret" ? isSecretTaskStatus(v) : kind === "team" ? isTeamTaskStatus(v) : isCodeTaskStatus(v);
|
|
32022
32175
|
}
|
|
32023
32176
|
function reconcile(kind, was, token, checked) {
|
|
32024
|
-
const
|
|
32177
|
+
const open4 = defaultWas(kind);
|
|
32025
32178
|
const done = kind === "secret" ? "rotated" : "done";
|
|
32026
32179
|
if (token && token !== was) return token;
|
|
32027
32180
|
if (kind === "team") {
|
|
@@ -32029,8 +32182,8 @@ function reconcile(kind, was, token, checked) {
|
|
|
32029
32182
|
if (!checked && was === "done") return "todo";
|
|
32030
32183
|
return token ?? was;
|
|
32031
32184
|
}
|
|
32032
|
-
if (checked && was ===
|
|
32033
|
-
if (!checked && was !==
|
|
32185
|
+
if (checked && was === open4) return done;
|
|
32186
|
+
if (!checked && was !== open4) return open4;
|
|
32034
32187
|
return token ?? was;
|
|
32035
32188
|
}
|
|
32036
32189
|
function parseAnchorLine(line) {
|
|
@@ -32097,7 +32250,7 @@ async function pushProjectTaskStatuses(base3, authHeaders, opts = {}) {
|
|
|
32097
32250
|
if (!existsSync45(file)) continue;
|
|
32098
32251
|
let mtime;
|
|
32099
32252
|
try {
|
|
32100
|
-
mtime =
|
|
32253
|
+
mtime = statSync43(file).mtimeMs;
|
|
32101
32254
|
} catch {
|
|
32102
32255
|
continue;
|
|
32103
32256
|
}
|
|
@@ -32151,11 +32304,11 @@ var init_project_tasks = __esm({
|
|
|
32151
32304
|
});
|
|
32152
32305
|
|
|
32153
32306
|
// ../engine/dist/core/which.js
|
|
32154
|
-
import { existsSync as existsSync46, statSync as
|
|
32307
|
+
import { existsSync as existsSync46, statSync as statSync44, accessSync, constants } from "node:fs";
|
|
32155
32308
|
import { join as join52, isAbsolute as isAbsolute3, delimiter as delimiter2, sep as sep3 } from "node:path";
|
|
32156
32309
|
function executable(p) {
|
|
32157
32310
|
try {
|
|
32158
|
-
if (!
|
|
32311
|
+
if (!statSync44(p).isFile())
|
|
32159
32312
|
return false;
|
|
32160
32313
|
} catch {
|
|
32161
32314
|
return false;
|
|
@@ -32218,11 +32371,11 @@ __export(toolkit_pull_exports, {
|
|
|
32218
32371
|
platformRefusal: () => platformRefusal,
|
|
32219
32372
|
portableCommand: () => portableCommand
|
|
32220
32373
|
});
|
|
32221
|
-
import { existsSync as existsSync47, mkdirSync as mkdirSync14, statSync as
|
|
32374
|
+
import { existsSync as existsSync47, mkdirSync as mkdirSync14, statSync as statSync45, writeFileSync as writeFileSync14 } from "node:fs";
|
|
32222
32375
|
import { dirname as dirname22, join as join53, basename as basename25, isAbsolute as isAbsolute4 } from "node:path";
|
|
32223
32376
|
function isExecutableFile(p) {
|
|
32224
32377
|
try {
|
|
32225
|
-
return
|
|
32378
|
+
return statSync45(p).isFile();
|
|
32226
32379
|
} catch {
|
|
32227
32380
|
return false;
|
|
32228
32381
|
}
|
|
@@ -32994,7 +33147,7 @@ var init_intent_drain = __esm({
|
|
|
32994
33147
|
});
|
|
32995
33148
|
|
|
32996
33149
|
// src/code-index-cursor.ts
|
|
32997
|
-
import { readFileSync as readFileSync47, writeFileSync as writeFileSync16, mkdirSync as mkdirSync16, statSync as
|
|
33150
|
+
import { readFileSync as readFileSync47, writeFileSync as writeFileSync16, mkdirSync as mkdirSync16, statSync as statSync46 } from "fs";
|
|
32998
33151
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
32999
33152
|
import { createHash as createHash12 } from "crypto";
|
|
33000
33153
|
import { join as join55, dirname as dirname24 } from "path";
|
|
@@ -33044,7 +33197,7 @@ function workspaceFingerprint(workspace, collectorVersion) {
|
|
|
33044
33197
|
const rel = entry.slice(3);
|
|
33045
33198
|
let stamp2 = "gone";
|
|
33046
33199
|
try {
|
|
33047
|
-
const s =
|
|
33200
|
+
const s = statSync46(join55(workspace, rel));
|
|
33048
33201
|
stamp2 = `${s.size}:${Math.floor(s.mtimeMs)}`;
|
|
33049
33202
|
} catch {
|
|
33050
33203
|
}
|
|
@@ -33276,10 +33429,10 @@ var init_self_restart = __esm({
|
|
|
33276
33429
|
});
|
|
33277
33430
|
|
|
33278
33431
|
// src/log-rotate.ts
|
|
33279
|
-
import { statSync as
|
|
33432
|
+
import { statSync as statSync47, copyFileSync as copyFileSync3, truncateSync } from "fs";
|
|
33280
33433
|
function rotateLogIfLarge(logPath, maxBytes = LOG_MAX_BYTES) {
|
|
33281
33434
|
try {
|
|
33282
|
-
const size =
|
|
33435
|
+
const size = statSync47(logPath).size;
|
|
33283
33436
|
if (size < maxBytes) return { rotated: false, sizeBefore: 0 };
|
|
33284
33437
|
copyFileSync3(logPath, `${logPath}.1`);
|
|
33285
33438
|
truncateSync(logPath, 0);
|
|
@@ -33350,7 +33503,7 @@ __export(shadow_prune_exports, {
|
|
|
33350
33503
|
DEFAULT_MAX_TOTAL_BYTES: () => DEFAULT_MAX_TOTAL_BYTES,
|
|
33351
33504
|
pruneShadow: () => pruneShadow
|
|
33352
33505
|
});
|
|
33353
|
-
import { readdirSync as readdirSync34, statSync as
|
|
33506
|
+
import { readdirSync as readdirSync34, statSync as statSync48, unlinkSync as unlinkSync3 } from "fs";
|
|
33354
33507
|
import { join as join56 } from "path";
|
|
33355
33508
|
function listShadows(isFullyAcked) {
|
|
33356
33509
|
const out = [];
|
|
@@ -33375,7 +33528,7 @@ function listShadows(isFullyAcked) {
|
|
|
33375
33528
|
const path = join56(dir, name);
|
|
33376
33529
|
let st;
|
|
33377
33530
|
try {
|
|
33378
|
-
st =
|
|
33531
|
+
st = statSync48(path);
|
|
33379
33532
|
} catch {
|
|
33380
33533
|
continue;
|
|
33381
33534
|
}
|
|
@@ -33490,7 +33643,7 @@ var init_code_intel = __esm({
|
|
|
33490
33643
|
});
|
|
33491
33644
|
|
|
33492
33645
|
// ../engine/dist/core/companions.js
|
|
33493
|
-
import { existsSync as existsSync50, mkdirSync as mkdirSync17, statSync as
|
|
33646
|
+
import { existsSync as existsSync50, mkdirSync as mkdirSync17, statSync as statSync49, chmodSync as chmodSync5, unlinkSync as unlinkSync4, renameSync as renameSync5, createWriteStream as createWriteStream2, readFileSync as readFileSync49, writeFileSync as writeFileSync17 } from "node:fs";
|
|
33494
33647
|
import { homedir as homedir20 } from "node:os";
|
|
33495
33648
|
import { join as join57 } from "node:path";
|
|
33496
33649
|
import { execSync as execSync3 } from "node:child_process";
|
|
@@ -33541,7 +33694,7 @@ function checkCodeindexStatus() {
|
|
|
33541
33694
|
status.installed = true;
|
|
33542
33695
|
status.path = foundPath;
|
|
33543
33696
|
try {
|
|
33544
|
-
status.size =
|
|
33697
|
+
status.size = statSync49(foundPath).size;
|
|
33545
33698
|
} catch {
|
|
33546
33699
|
}
|
|
33547
33700
|
try {
|
|
@@ -34982,7 +35135,7 @@ import chokidar from "chokidar";
|
|
|
34982
35135
|
import { dirname as dirname25, basename as basename27, join as join60, resolve as resolve2, sep as sep4 } from "path";
|
|
34983
35136
|
import { homedir as homedir22 } from "os";
|
|
34984
35137
|
import { spawn as spawn4 } from "node:child_process";
|
|
34985
|
-
import { existsSync as existsSync52, readFileSync as readFileSync52, statSync as
|
|
35138
|
+
import { existsSync as existsSync52, readFileSync as readFileSync52, statSync as statSync50 } from "fs";
|
|
34986
35139
|
async function shipToServer(trigger) {
|
|
34987
35140
|
if (syncInFlight) return;
|
|
34988
35141
|
syncInFlight = true;
|
|
@@ -35426,7 +35579,7 @@ var init_indexer = __esm({
|
|
|
35426
35579
|
sessionWatcher = watchWithFallback("sessions", CLAUDE_SESSION_ROOTS.map((root) => `${root}/**/*.jsonl`), {
|
|
35427
35580
|
ignored: (p, stats) => {
|
|
35428
35581
|
if (/agent-/.test(p) || /^\./.test(basename27(p))) return true;
|
|
35429
|
-
const st = stats ??
|
|
35582
|
+
const st = stats ?? statSync50(p, { throwIfNoEntry: false });
|
|
35430
35583
|
if (!st || st.isDirectory()) return false;
|
|
35431
35584
|
return st.mtimeMs < Date.now() - WATCH_WINDOW_MS;
|
|
35432
35585
|
},
|