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/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 raw = [];
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
- raw.push({ line: lineNumber, obj: JSON.parse(line) });
6363
+ obj = JSON.parse(line);
6327
6364
  } catch {
6365
+ continue;
6328
6366
  }
6367
+ builder.add(lineNumber, obj);
6329
6368
  }
6330
- return messagesFromRawLines(raw);
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 raw = [];
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
- raw.push({ line: lineNumber, obj: JSON.parse(line) });
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 messagesFromRawLines(raw);
6351
- }
6352
- function messagesFromRawLines(raw) {
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;
6392
+ return builder.messages;
6434
6393
  }
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
 
@@ -10222,6 +10280,52 @@ var init_opencode = __esm({
10222
10280
  getCommits(id, files, startMs, endMs, bufferMinutes) {
10223
10281
  return getSessionCommits(this.toPrefixedId(id), files, startMs, endMs, bufferMinutes);
10224
10282
  }
10283
+ /** The bytes of the dump of a session, summed in SQLite: no row is read into the process. */
10284
+ rawSessionBytes(id) {
10285
+ const dbPath = this.dbPath();
10286
+ if (!existsSync11(dbPath))
10287
+ return 0;
10288
+ const realId = this.toRawId(id);
10289
+ const db = openOpencodeDbOrThrow(dbPath);
10290
+ try {
10291
+ const row = db.prepare(`
10292
+ SELECT COALESCE(SUM(LENGTH(CAST(p.data AS BLOB)) + LENGTH(CAST(m.data AS BLOB))), 0) AS bytes
10293
+ FROM part p JOIN (SELECT id, data FROM message WHERE session_id = ?) m ON p.message_id = m.id
10294
+ WHERE p.session_id = ?
10295
+ `).get(realId, realId);
10296
+ return Number(row?.bytes ?? 0);
10297
+ } catch {
10298
+ return 0;
10299
+ } finally {
10300
+ db.close();
10301
+ }
10302
+ }
10303
+ /** The lines of the dump, one row at a time. Every line ends with a newline. */
10304
+ *iterateRawSessionLines(id) {
10305
+ const dbPath = this.dbPath();
10306
+ if (!existsSync11(dbPath))
10307
+ return;
10308
+ const realId = this.toRawId(id);
10309
+ const db = openOpencodeDbOrThrow(dbPath);
10310
+ try {
10311
+ const session = db.prepare(`SELECT * FROM session WHERE id = ?`).get(realId);
10312
+ if (!session)
10313
+ return;
10314
+ yield `${JSON.stringify({ kind: "session", row: session })}
10315
+ `;
10316
+ const rows = db.prepare(`
10317
+ SELECT m.id AS message_id, m.data AS message_data, p.id AS part_id, p.data AS part_data, p.time_created
10318
+ FROM part p JOIN (SELECT id, data FROM message WHERE session_id = ?) m ON p.message_id = m.id
10319
+ WHERE p.session_id = ?
10320
+ ORDER BY p.time_created ASC, p.id ASC
10321
+ `);
10322
+ for (const r of rows.iterate(realId, realId))
10323
+ yield `${JSON.stringify({ kind: "part", row: r })}
10324
+ `;
10325
+ } finally {
10326
+ db.close();
10327
+ }
10328
+ }
10225
10329
  exportRawSession(id) {
10226
10330
  const dbPath = this.dbPath();
10227
10331
  if (!existsSync11(dbPath))
@@ -15991,7 +16095,7 @@ var init_types = __esm({
15991
16095
  });
15992
16096
 
15993
16097
  // ../engine/dist/transcript/opencode.js
15994
- async function parseOpenCodeSubagents(parentSessionId) {
16098
+ async function parseOpenCodeSubagents(parentSessionId, opts = {}) {
15995
16099
  const { existsSync: existsSync53 } = await import("fs");
15996
16100
  const { opencodeBackend: opencodeBackend2 } = await Promise.resolve().then(() => (init_opencode(), opencode_exports));
15997
16101
  const dbPath = opencodeBackend2.dbPath();
@@ -16011,7 +16115,7 @@ async function parseOpenCodeSubagents(parentSessionId) {
16011
16115
  const childId = `opencode_${c.id}`;
16012
16116
  let messages = [];
16013
16117
  try {
16014
- messages = await parseOpenCodeTranscript(childId);
16118
+ messages = await parseOpenCodeTranscript(childId, opts);
16015
16119
  } catch (e) {
16016
16120
  log5.error({ err: e, sessionId: c.id }, "Failed to parse OpenCode sub-session");
16017
16121
  }
@@ -16035,7 +16139,7 @@ async function parseOpenCodeSubagents(parentSessionId) {
16035
16139
  db.close();
16036
16140
  }
16037
16141
  }
16038
- async function parseOpenCodeTranscript(sessionId) {
16142
+ async function parseOpenCodeTranscript(sessionId, opts = {}) {
16039
16143
  const { existsSync: existsSync53 } = await import("fs");
16040
16144
  const { opencodeBackend: opencodeBackend2 } = await Promise.resolve().then(() => (init_opencode(), opencode_exports));
16041
16145
  const dbPath = opencodeBackend2.dbPath();
@@ -16051,13 +16155,19 @@ async function parseOpenCodeTranscript(sessionId) {
16051
16155
  JOIN (SELECT id, data FROM message WHERE session_id = ?) m ON p.message_id = m.id
16052
16156
  WHERE p.session_id = ?
16053
16157
  ORDER BY p.time_created ASC
16054
- `).all(realId, realId);
16158
+ `).iterate(realId, realId);
16159
+ const cap = opts.payloadCap ? (v) => capPayload(v, opts.payloadCap) : (v) => v;
16160
+ let lastMsgData = "";
16161
+ let lastRole = "assistant";
16055
16162
  let lineNum = 0;
16056
16163
  for (const part of parts) {
16057
16164
  try {
16058
16165
  const partData = JSON.parse(part.data);
16059
- const msgData = JSON.parse(part.msg_data);
16060
- const role = msgData.role === "user" ? "user" : "assistant";
16166
+ if (part.msg_data !== lastMsgData) {
16167
+ lastRole = JSON.parse(part.msg_data).role === "user" ? "user" : "assistant";
16168
+ lastMsgData = part.msg_data;
16169
+ }
16170
+ const role = lastRole;
16061
16171
  if (partData.type === "text" && partData.text?.trim()) {
16062
16172
  lineNum++;
16063
16173
  messages.push({ line: lineNum, role, content: partData.text });
@@ -16067,7 +16177,7 @@ async function parseOpenCodeTranscript(sessionId) {
16067
16177
  line: lineNum,
16068
16178
  role: "assistant",
16069
16179
  content: `Tool: ${partData.tool}`,
16070
- toolCalls: [{ name: partData.tool, input: partData.state || {} }]
16180
+ toolCalls: [{ name: partData.tool, input: cap(partData.state || {}) }]
16071
16181
  });
16072
16182
  }
16073
16183
  } catch {
@@ -16084,6 +16194,7 @@ var init_opencode2 = __esm({
16084
16194
  "use strict";
16085
16195
  init_opencode_v2();
16086
16196
  init_logger();
16197
+ init_trim();
16087
16198
  log5 = createLogger("transcript-opencode");
16088
16199
  }
16089
16200
  });
@@ -16092,10 +16203,12 @@ var init_opencode2 = __esm({
16092
16203
  var transcript_exports = {};
16093
16204
  __export(transcript_exports, {
16094
16205
  RAW_PARSE_MAX_BYTES: () => RAW_PARSE_MAX_BYTES,
16206
+ SYNC_PAYLOAD_CAP: () => SYNC_PAYLOAD_CAP,
16095
16207
  TRANSCRIPT_VERSION: () => TRANSCRIPT_VERSION,
16096
16208
  archiveRawSession: () => archiveRawSession,
16097
16209
  buildRawContainer: () => buildRawContainer,
16098
16210
  canonicalEventsToMessages: () => canonicalEventsToMessages,
16211
+ capPayload: () => capPayload,
16099
16212
  containerSrcHash: () => containerSrcHash,
16100
16213
  detectForkPredecessor: () => detectForkPredecessor,
16101
16214
  gunzipContainer: () => gunzipContainer,
@@ -16130,7 +16243,14 @@ __export(transcript_exports, {
16130
16243
  writeTranscriptEnvelope: () => writeTranscriptEnvelope
16131
16244
  });
16132
16245
  import { statSync as statSync20 } from "fs";
16133
- async function parseTranscript(sessionId) {
16246
+ async function parseTranscript(sessionId, opts = {}) {
16247
+ const t = await parseTranscriptUncut(sessionId, opts);
16248
+ const cap = opts.payloadCap;
16249
+ if (!t || !cap || t.payloadCap === cap)
16250
+ return t;
16251
+ return { ...t, ...trimTranscriptForSync(t, cap), payloadCap: cap };
16252
+ }
16253
+ async function parseTranscriptUncut(sessionId, opts) {
16134
16254
  const tool = detectTool(sessionId);
16135
16255
  if (tool === "claude") {
16136
16256
  const groups = resolveSessionContentGroups(sessionId);
@@ -16141,9 +16261,10 @@ async function parseTranscript(sessionId) {
16141
16261
  return null;
16142
16262
  const primaryPath = mainGroup.paths[0];
16143
16263
  const merged = readSessionGroupText(mainGroup);
16264
+ const cut = opts.payloadCap ? { payloadCap: opts.payloadCap } : {};
16144
16265
  const [tail, allSubagents] = await Promise.all([
16145
- Promise.resolve(parseClaudeTranscriptText(merged.text)),
16146
- parseClaudeSubagents(primaryPath)
16266
+ Promise.resolve(parseClaudeTranscriptText(merged.text, cut)),
16267
+ parseClaudeSubagents(primaryPath, cut)
16147
16268
  ]);
16148
16269
  const compacts = allSubagents.filter((s) => s.kind === "compact");
16149
16270
  const subagents = allSubagents.filter((s) => s.kind !== "compact");
@@ -16160,15 +16281,16 @@ async function parseTranscript(sessionId) {
16160
16281
  }
16161
16282
  messages = [...stitched, ...tail].map((m, i) => ({ ...m, line: i + 1 }));
16162
16283
  }
16163
- return { messages, subagents, mtime: merged.mtime || safeMtime(primaryPath) };
16284
+ return { messages, subagents, mtime: merged.mtime || safeMtime(primaryPath), ...opts.payloadCap ? { payloadCap: opts.payloadCap } : {} };
16164
16285
  }
16165
16286
  if (tool === "opencode") {
16166
- const messages = await parseOpenCodeTranscript(sessionId);
16287
+ const cut = opts.payloadCap ? { payloadCap: opts.payloadCap } : {};
16288
+ const messages = await parseOpenCodeTranscript(sessionId, cut);
16167
16289
  if (messages.length === 0)
16168
16290
  return null;
16169
- const subagents = await parseOpenCodeSubagents(sessionId);
16291
+ const subagents = await parseOpenCodeSubagents(sessionId, cut);
16170
16292
  const loc = getBackend("opencode").findSession(sessionId);
16171
- return { messages, subagents, mtime: loc?.mtime || 0 };
16293
+ return { messages, subagents, mtime: loc?.mtime || 0, ...opts.payloadCap ? { payloadCap: opts.payloadCap } : {} };
16172
16294
  }
16173
16295
  if (tool === "codex") {
16174
16296
  const loc = getBackend("codex").findSession(sessionId);
@@ -16202,31 +16324,8 @@ function safeMtime(path) {
16202
16324
  return 0;
16203
16325
  }
16204
16326
  }
16205
- function trimTranscriptForSync(t, capChars = 2e3) {
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
- };
16327
+ function trimTranscriptForSync(t, capChars = SYNC_PAYLOAD_CAP) {
16328
+ const cap = (v) => capPayload(v, capChars);
16230
16329
  const trimMsg = (m) => ({
16231
16330
  ...m,
16232
16331
  thinking: m.thinking !== void 0 ? cap(m.thinking) : void 0,
@@ -16258,7 +16357,9 @@ var init_transcript = __esm({
16258
16357
  init_opencode2();
16259
16358
  init_codex();
16260
16359
  init_from_events();
16360
+ init_trim();
16261
16361
  init_types();
16362
+ init_trim();
16262
16363
  init_raw();
16263
16364
  init_shadow();
16264
16365
  init_claude();
@@ -28694,8 +28795,134 @@ var init_telemetry = __esm({
28694
28795
  }
28695
28796
  });
28696
28797
 
28798
+ // src/session-file-scan.ts
28799
+ import { open as open3 } from "node:fs/promises";
28800
+ import { statSync as statSync39 } from "node:fs";
28801
+ function sessionGroupsBytes(groups) {
28802
+ let total = 0;
28803
+ for (const g of groups) {
28804
+ for (const p of g.paths) {
28805
+ try {
28806
+ total += statSync39(p).size;
28807
+ } catch {
28808
+ }
28809
+ }
28810
+ }
28811
+ return total;
28812
+ }
28813
+ async function* readLinePieces(path, pieceBytes = SCAN_PIECE_BYTES) {
28814
+ const fh = await open3(path, "r");
28815
+ try {
28816
+ const buf = Buffer.allocUnsafe(pieceBytes);
28817
+ let carry = Buffer.alloc(0);
28818
+ for (; ; ) {
28819
+ const { bytesRead } = await fh.read(buf, 0, pieceBytes, null);
28820
+ if (bytesRead === 0) break;
28821
+ const joined = carry.length ? Buffer.concat([carry, buf.subarray(0, bytesRead)]) : buf.subarray(0, bytesRead);
28822
+ const cut = joined.lastIndexOf(NEWLINE);
28823
+ if (cut < 0) {
28824
+ carry = Buffer.from(joined);
28825
+ continue;
28826
+ }
28827
+ const piece = joined.subarray(0, cut + 1);
28828
+ carry = Buffer.from(joined.subarray(cut + 1));
28829
+ yield { text: piece.toString("utf8"), newlines: countNewlines(piece) };
28830
+ }
28831
+ if (carry.length) yield { text: carry.toString("utf8"), newlines: 0 };
28832
+ } finally {
28833
+ await fh.close();
28834
+ }
28835
+ }
28836
+ function countNewlines(b) {
28837
+ let n = 0;
28838
+ for (let i = b.indexOf(NEWLINE); i >= 0; i = b.indexOf(NEWLINE, i + 1)) n++;
28839
+ return n;
28840
+ }
28841
+ async function scanSessionGroupsChunked(sessionId, groups, tenantRules, pieceBytes = SCAN_PIECE_BYTES) {
28842
+ const findings = [];
28843
+ let lineBase = 0;
28844
+ const scan = (text) => {
28845
+ try {
28846
+ for (const x of scanTextForFindings(text)) {
28847
+ findings.push({ session_id: sessionId, detector: "builtin", rule: x.rule, line: x.line + lineBase, preview: x.preview });
28848
+ }
28849
+ } catch {
28850
+ }
28851
+ if (tenantRules && tenantRules.length > 0) {
28852
+ try {
28853
+ for (const x of scanTenantRules(text, tenantRules)) {
28854
+ findings.push({ session_id: sessionId, detector: x.detector, rule: x.rule, line: x.line + lineBase, preview: x.preview });
28855
+ }
28856
+ } catch {
28857
+ }
28858
+ }
28859
+ };
28860
+ for (const group of groups) {
28861
+ if (group.paths.length === 1) {
28862
+ let any = false;
28863
+ for await (const piece of readLinePieces(group.paths[0], pieceBytes)) {
28864
+ any = true;
28865
+ scan(piece.text);
28866
+ lineBase += piece.newlines;
28867
+ }
28868
+ if (any) lineBase += 1;
28869
+ } else {
28870
+ const { text } = readSessionGroupText(group);
28871
+ if (!text) continue;
28872
+ scan(text);
28873
+ lineBase += (text.match(/\n/g)?.length ?? 0) + 1;
28874
+ }
28875
+ }
28876
+ return findings;
28877
+ }
28878
+ function scanLinesChunked(sessionId, lines, tenantRules, pieceBytes = SCAN_PIECE_BYTES) {
28879
+ const findings = [];
28880
+ let lineBase = 0;
28881
+ let piece = [];
28882
+ let bytes = 0;
28883
+ const flush2 = () => {
28884
+ if (piece.length === 0) return;
28885
+ const text = piece.join("");
28886
+ try {
28887
+ for (const x of scanTextForFindings(text)) {
28888
+ findings.push({ session_id: sessionId, detector: "builtin", rule: x.rule, line: x.line + lineBase, preview: x.preview });
28889
+ }
28890
+ } catch {
28891
+ }
28892
+ if (tenantRules && tenantRules.length > 0) {
28893
+ try {
28894
+ for (const x of scanTenantRules(text, tenantRules)) {
28895
+ findings.push({ session_id: sessionId, detector: x.detector, rule: x.rule, line: x.line + lineBase, preview: x.preview });
28896
+ }
28897
+ } catch {
28898
+ }
28899
+ }
28900
+ lineBase += piece.length;
28901
+ piece = [];
28902
+ bytes = 0;
28903
+ };
28904
+ for (const line of lines) {
28905
+ piece.push(line);
28906
+ bytes += line.length;
28907
+ if (bytes >= pieceBytes) flush2();
28908
+ }
28909
+ flush2();
28910
+ return findings;
28911
+ }
28912
+ var SCAN_PIECE_BYTES, NEWLINE;
28913
+ var init_session_file_scan = __esm({
28914
+ "src/session-file-scan.ts"() {
28915
+ "use strict";
28916
+ init_secret_redactor();
28917
+ init_secret_scanner();
28918
+ init_live_session_scan();
28919
+ SCAN_PIECE_BYTES = 1024 * 1024;
28920
+ NEWLINE = 10;
28921
+ }
28922
+ });
28923
+
28697
28924
  // 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 statSync39 } from "node:fs";
28925
+ import { createReadStream as createReadStream4, createWriteStream, openSync as openSync10, readSync as readSync9, closeSync as closeSync10, rmSync as rmSync5, statSync as statSync40 } from "node:fs";
28699
28926
  import { tmpdir as tmpdir2 } from "node:os";
28700
28927
  import { join as join46 } from "node:path";
28701
28928
  import { randomBytes } from "node:crypto";
@@ -28763,7 +28990,7 @@ async function writeArchiveFile(source, meta, redact, dir = tmpdir2()) {
28763
28990
  rmSync5(path, { force: true });
28764
28991
  throw err;
28765
28992
  }
28766
- return { path, gzSize: statSync39(path).size, size };
28993
+ return { path, gzSize: statSync40(path).size, size };
28767
28994
  }
28768
28995
  async function putPart(url, body) {
28769
28996
  let last;
@@ -29066,7 +29293,7 @@ __export(auto_update_exports, {
29066
29293
  import { execSync as execSync2, execFileSync as execFileSync3 } from "node:child_process";
29067
29294
  import { readFileSync as readFileSync41, existsSync as existsSync43 } from "node:fs";
29068
29295
  import { fileURLToPath as fileURLToPath2 } from "node:url";
29069
- import { writeFileSync as writeFileSync10, mkdtempSync as mkdtempSync3, rmSync as rmSync6, readdirSync as readdirSync31, statSync as statSync40, mkdirSync as mkdirSync10 } from "node:fs";
29296
+ import { writeFileSync as writeFileSync10, mkdtempSync as mkdtempSync3, rmSync as rmSync6, readdirSync as readdirSync31, statSync as statSync41, mkdirSync as mkdirSync10 } from "node:fs";
29070
29297
  import { join as join47, dirname as dirname18, sep as sep2, posix as pathPosix, win32 as pathWin32 } from "node:path";
29071
29298
  import { tmpdir as tmpdir3, homedir as homedir16 } from "node:os";
29072
29299
  import { createHash as createHash9 } from "node:crypto";
@@ -29119,7 +29346,7 @@ function sweepStaleStaging(root = tmpdir3(), now = Date.now()) {
29119
29346
  if (!MKDTEMP_SUFFIX.test(name)) continue;
29120
29347
  const dir = join47(root, name);
29121
29348
  try {
29122
- const st = statSync40(dir);
29349
+ const st = statSync41(dir);
29123
29350
  if (!st.isDirectory() || now - st.mtimeMs < COLD_MS) continue;
29124
29351
  const inside = readdirSync31(dir);
29125
29352
  if (inside.length > 1 || inside.length === 1 && inside[0] !== "chat-recall.tgz") continue;
@@ -29363,7 +29590,7 @@ var init_auto_update = __esm({
29363
29590
 
29364
29591
  // src/sync-client.ts
29365
29592
  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 statSync41 } from "node:fs";
29593
+ 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
29594
  import { tmpdir as tmpdir4, hostname as hostname2 } from "node:os";
29368
29595
  import { createHash as createHash10 } from "node:crypto";
29369
29596
  import { fileURLToPath as fileURLToPath3 } from "node:url";
@@ -29778,7 +30005,7 @@ function reapStaleScanDirs(dir = tmpdir4(), maxAgeMs = 6 * 36e5, now = Date.now(
29778
30005
  if (!name.startsWith("cr-batchscan-")) continue;
29779
30006
  const p = join48(dir, name);
29780
30007
  try {
29781
- if (now - statSync41(p).mtimeMs < maxAgeMs) continue;
30008
+ if (now - statSync42(p).mtimeMs < maxAgeMs) continue;
29782
30009
  rmSync7(p, { recursive: true, force: true });
29783
30010
  reaped++;
29784
30011
  } catch {
@@ -30677,6 +30904,10 @@ function sessionFileBytes(ref) {
30677
30904
  if (!backend?.isAppendOnly?.()) return 0;
30678
30905
  return backend.fileSize?.(ref.prefixedId) ?? 0;
30679
30906
  }
30907
+ function syncTranscript(t) {
30908
+ const cut = t.payloadCap ? { messages: t.messages, subagents: t.subagents } : trimTranscriptForSync(t);
30909
+ return { messages: cut.messages, subagents: cut.subagents.map((s) => ({ ...s, filePath: "" })) };
30910
+ }
30680
30911
  function sessionBuildBytes(ref) {
30681
30912
  const main = sessionFileBytes(ref);
30682
30913
  if (main === 0) return 0;
@@ -30713,11 +30944,15 @@ async function buildConversationSync(ref, mtime, opts = {}) {
30713
30944
  } else {
30714
30945
  try {
30715
30946
  const backend = getBackendForId(ref.prefixedId) ?? getBackend("claude");
30716
- const exp = backend.exportRawSession(ref.prefixedId);
30947
+ const streamGroups = ref.toolId === "claude" ? resolveSessionContentGroups(ref.rawId) : [];
30948
+ const streamsLines = ref.toolId !== "claude" && !!backend.rawSessionBytes && !!backend.iterateRawSessionLines;
30949
+ const streamedBytes = ref.toolId === "claude" ? sessionGroupsBytes(streamGroups) : streamsLines ? backend.rawSessionBytes(ref.prefixedId) : 0;
30950
+ const streamed = streamedBytes > FULL_BUILD_MAX_BYTES;
30951
+ const exp = streamed ? null : backend.exportRawSession(ref.prefixedId);
30717
30952
  let built;
30718
- const exportBytes = exportByteLength(exp);
30953
+ const exportBytes = streamed ? streamedBytes : exportByteLength(exp);
30719
30954
  const overCeiling = exportBytes > FULL_BUILD_MAX_BYTES;
30720
- if (exp && overCeiling) {
30955
+ if ((exp || streamed) && overCeiling) {
30721
30956
  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
30957
  record({
30723
30958
  kind: "oversized_session",
@@ -30728,25 +30963,29 @@ async function buildConversationSync(ref, mtime, opts = {}) {
30728
30963
  includeRaw = false;
30729
30964
  includeMeta = false;
30730
30965
  exportOverCeiling = true;
30731
- overCeilingFindings = [];
30732
- let lineBase = 0;
30733
- for (const f of exp.files) {
30734
- const text = f.bytes.toString("utf8");
30735
- try {
30736
- for (const x of scanTextForFindings(text)) {
30737
- overCeilingFindings.push({ session_id: ref.prefixedId, detector: "builtin", rule: x.rule, line: x.line + lineBase, preview: x.preview });
30738
- }
30739
- } catch {
30740
- }
30741
- if (opts.tenantRules && opts.tenantRules.length > 0) {
30966
+ if (streamed) {
30967
+ overCeilingFindings = ref.toolId === "claude" ? await scanSessionGroupsChunked(ref.prefixedId, streamGroups, opts.tenantRules) : scanLinesChunked(ref.prefixedId, backend.iterateRawSessionLines(ref.prefixedId), opts.tenantRules);
30968
+ } else if (exp) {
30969
+ overCeilingFindings = [];
30970
+ let lineBase = 0;
30971
+ for (const f of exp.files) {
30972
+ const text = f.bytes.toString("utf8");
30742
30973
  try {
30743
- for (const x of scanTenantRules(text, opts.tenantRules)) {
30744
- overCeilingFindings.push({ session_id: ref.prefixedId, detector: x.detector, rule: x.rule, line: x.line + lineBase, preview: x.preview });
30974
+ for (const x of scanTextForFindings(text)) {
30975
+ overCeilingFindings.push({ session_id: ref.prefixedId, detector: "builtin", rule: x.rule, line: x.line + lineBase, preview: x.preview });
30745
30976
  }
30746
30977
  } catch {
30747
30978
  }
30979
+ if (opts.tenantRules && opts.tenantRules.length > 0) {
30980
+ try {
30981
+ for (const x of scanTenantRules(text, opts.tenantRules)) {
30982
+ overCeilingFindings.push({ session_id: ref.prefixedId, detector: x.detector, rule: x.rule, line: x.line + lineBase, preview: x.preview });
30983
+ }
30984
+ } catch {
30985
+ }
30986
+ }
30987
+ lineBase += (text.match(/\n/g)?.length ?? 0) + 1;
30748
30988
  }
30749
- lineBase += (text.match(/\n/g)?.length ?? 0) + 1;
30750
30989
  }
30751
30990
  }
30752
30991
  if (exp && !overCeiling) {
@@ -30786,7 +31025,7 @@ async function buildConversationSync(ref, mtime, opts = {}) {
30786
31025
  }
30787
31026
  if (!transcript) {
30788
31027
  try {
30789
- const t = await parseTranscript(ref.prefixedId);
31028
+ const t = await parseTranscript(ref.prefixedId, { payloadCap: SYNC_PAYLOAD_CAP });
30790
31029
  if (t && (t.messages.length > 0 || t.subagents.length > 0)) transcript = t;
30791
31030
  } catch {
30792
31031
  }
@@ -30799,7 +31038,9 @@ async function buildConversationSync(ref, mtime, opts = {}) {
30799
31038
  if (isInternalToolPrompt(firstUser?.content)) return null;
30800
31039
  const count = { redactions: 0 };
30801
31040
  const envelope = redactDeep(
30802
- { v: TRANSCRIPT_VERSION, ...trimTranscriptForSync(transcript) },
31041
+ // A transcript the parser already cut is not cut again: the cut is not idempotent.
31042
+ // The path of a subagent file on this machine does not leave it: the container parse gives ''.
31043
+ { v: TRANSCRIPT_VERSION, ...syncTranscript(transcript) },
30803
31044
  count
30804
31045
  );
30805
31046
  let projectPath = ref.projectPath;
@@ -31171,6 +31412,7 @@ var init_sync_client = __esm({
31171
31412
  init_telemetry();
31172
31413
  init_collector_health();
31173
31414
  init_live_session_scan();
31415
+ init_session_file_scan();
31174
31416
  init_raw_archive_parts();
31175
31417
  init_backends();
31176
31418
  ownVersion = "0.0.0";
@@ -32008,7 +32250,7 @@ var init_code_task_status = __esm({
32008
32250
  });
32009
32251
 
32010
32252
  // src/project-tasks.ts
32011
- import { existsSync as existsSync45, readFileSync as readFileSync45, writeFileSync as writeFileSync13, mkdirSync as mkdirSync13, statSync as statSync42 } from "node:fs";
32253
+ import { existsSync as existsSync45, readFileSync as readFileSync45, writeFileSync as writeFileSync13, mkdirSync as mkdirSync13, statSync as statSync43 } from "node:fs";
32012
32254
  import { join as join51, dirname as dirname21 } from "node:path";
32013
32255
  import { homedir as homedir19 } from "node:os";
32014
32256
  function isTeamTaskStatus(v) {
@@ -32021,7 +32263,7 @@ function isValidStatus(kind, v) {
32021
32263
  return kind === "secret" ? isSecretTaskStatus(v) : kind === "team" ? isTeamTaskStatus(v) : isCodeTaskStatus(v);
32022
32264
  }
32023
32265
  function reconcile(kind, was, token, checked) {
32024
- const open3 = defaultWas(kind);
32266
+ const open4 = defaultWas(kind);
32025
32267
  const done = kind === "secret" ? "rotated" : "done";
32026
32268
  if (token && token !== was) return token;
32027
32269
  if (kind === "team") {
@@ -32029,8 +32271,8 @@ function reconcile(kind, was, token, checked) {
32029
32271
  if (!checked && was === "done") return "todo";
32030
32272
  return token ?? was;
32031
32273
  }
32032
- if (checked && was === open3) return done;
32033
- if (!checked && was !== open3) return open3;
32274
+ if (checked && was === open4) return done;
32275
+ if (!checked && was !== open4) return open4;
32034
32276
  return token ?? was;
32035
32277
  }
32036
32278
  function parseAnchorLine(line) {
@@ -32097,7 +32339,7 @@ async function pushProjectTaskStatuses(base3, authHeaders, opts = {}) {
32097
32339
  if (!existsSync45(file)) continue;
32098
32340
  let mtime;
32099
32341
  try {
32100
- mtime = statSync42(file).mtimeMs;
32342
+ mtime = statSync43(file).mtimeMs;
32101
32343
  } catch {
32102
32344
  continue;
32103
32345
  }
@@ -32151,11 +32393,11 @@ var init_project_tasks = __esm({
32151
32393
  });
32152
32394
 
32153
32395
  // ../engine/dist/core/which.js
32154
- import { existsSync as existsSync46, statSync as statSync43, accessSync, constants } from "node:fs";
32396
+ import { existsSync as existsSync46, statSync as statSync44, accessSync, constants } from "node:fs";
32155
32397
  import { join as join52, isAbsolute as isAbsolute3, delimiter as delimiter2, sep as sep3 } from "node:path";
32156
32398
  function executable(p) {
32157
32399
  try {
32158
- if (!statSync43(p).isFile())
32400
+ if (!statSync44(p).isFile())
32159
32401
  return false;
32160
32402
  } catch {
32161
32403
  return false;
@@ -32218,11 +32460,11 @@ __export(toolkit_pull_exports, {
32218
32460
  platformRefusal: () => platformRefusal,
32219
32461
  portableCommand: () => portableCommand
32220
32462
  });
32221
- import { existsSync as existsSync47, mkdirSync as mkdirSync14, statSync as statSync44, writeFileSync as writeFileSync14 } from "node:fs";
32463
+ import { existsSync as existsSync47, mkdirSync as mkdirSync14, statSync as statSync45, writeFileSync as writeFileSync14 } from "node:fs";
32222
32464
  import { dirname as dirname22, join as join53, basename as basename25, isAbsolute as isAbsolute4 } from "node:path";
32223
32465
  function isExecutableFile(p) {
32224
32466
  try {
32225
- return statSync44(p).isFile();
32467
+ return statSync45(p).isFile();
32226
32468
  } catch {
32227
32469
  return false;
32228
32470
  }
@@ -32994,7 +33236,7 @@ var init_intent_drain = __esm({
32994
33236
  });
32995
33237
 
32996
33238
  // src/code-index-cursor.ts
32997
- import { readFileSync as readFileSync47, writeFileSync as writeFileSync16, mkdirSync as mkdirSync16, statSync as statSync45 } from "fs";
33239
+ import { readFileSync as readFileSync47, writeFileSync as writeFileSync16, mkdirSync as mkdirSync16, statSync as statSync46 } from "fs";
32998
33240
  import { execFileSync as execFileSync4 } from "child_process";
32999
33241
  import { createHash as createHash12 } from "crypto";
33000
33242
  import { join as join55, dirname as dirname24 } from "path";
@@ -33044,7 +33286,7 @@ function workspaceFingerprint(workspace, collectorVersion) {
33044
33286
  const rel = entry.slice(3);
33045
33287
  let stamp2 = "gone";
33046
33288
  try {
33047
- const s = statSync45(join55(workspace, rel));
33289
+ const s = statSync46(join55(workspace, rel));
33048
33290
  stamp2 = `${s.size}:${Math.floor(s.mtimeMs)}`;
33049
33291
  } catch {
33050
33292
  }
@@ -33276,10 +33518,10 @@ var init_self_restart = __esm({
33276
33518
  });
33277
33519
 
33278
33520
  // src/log-rotate.ts
33279
- import { statSync as statSync46, copyFileSync as copyFileSync3, truncateSync } from "fs";
33521
+ import { statSync as statSync47, copyFileSync as copyFileSync3, truncateSync } from "fs";
33280
33522
  function rotateLogIfLarge(logPath, maxBytes = LOG_MAX_BYTES) {
33281
33523
  try {
33282
- const size = statSync46(logPath).size;
33524
+ const size = statSync47(logPath).size;
33283
33525
  if (size < maxBytes) return { rotated: false, sizeBefore: 0 };
33284
33526
  copyFileSync3(logPath, `${logPath}.1`);
33285
33527
  truncateSync(logPath, 0);
@@ -33350,7 +33592,7 @@ __export(shadow_prune_exports, {
33350
33592
  DEFAULT_MAX_TOTAL_BYTES: () => DEFAULT_MAX_TOTAL_BYTES,
33351
33593
  pruneShadow: () => pruneShadow
33352
33594
  });
33353
- import { readdirSync as readdirSync34, statSync as statSync47, unlinkSync as unlinkSync3 } from "fs";
33595
+ import { readdirSync as readdirSync34, statSync as statSync48, unlinkSync as unlinkSync3 } from "fs";
33354
33596
  import { join as join56 } from "path";
33355
33597
  function listShadows(isFullyAcked) {
33356
33598
  const out = [];
@@ -33375,7 +33617,7 @@ function listShadows(isFullyAcked) {
33375
33617
  const path = join56(dir, name);
33376
33618
  let st;
33377
33619
  try {
33378
- st = statSync47(path);
33620
+ st = statSync48(path);
33379
33621
  } catch {
33380
33622
  continue;
33381
33623
  }
@@ -33490,7 +33732,7 @@ var init_code_intel = __esm({
33490
33732
  });
33491
33733
 
33492
33734
  // ../engine/dist/core/companions.js
33493
- import { existsSync as existsSync50, mkdirSync as mkdirSync17, statSync as statSync48, chmodSync as chmodSync5, unlinkSync as unlinkSync4, renameSync as renameSync5, createWriteStream as createWriteStream2, readFileSync as readFileSync49, writeFileSync as writeFileSync17 } from "node:fs";
33735
+ 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
33736
  import { homedir as homedir20 } from "node:os";
33495
33737
  import { join as join57 } from "node:path";
33496
33738
  import { execSync as execSync3 } from "node:child_process";
@@ -33541,7 +33783,7 @@ function checkCodeindexStatus() {
33541
33783
  status.installed = true;
33542
33784
  status.path = foundPath;
33543
33785
  try {
33544
- status.size = statSync48(foundPath).size;
33786
+ status.size = statSync49(foundPath).size;
33545
33787
  } catch {
33546
33788
  }
33547
33789
  try {
@@ -34982,7 +35224,7 @@ import chokidar from "chokidar";
34982
35224
  import { dirname as dirname25, basename as basename27, join as join60, resolve as resolve2, sep as sep4 } from "path";
34983
35225
  import { homedir as homedir22 } from "os";
34984
35226
  import { spawn as spawn4 } from "node:child_process";
34985
- import { existsSync as existsSync52, readFileSync as readFileSync52, statSync as statSync49 } from "fs";
35227
+ import { existsSync as existsSync52, readFileSync as readFileSync52, statSync as statSync50 } from "fs";
34986
35228
  async function shipToServer(trigger) {
34987
35229
  if (syncInFlight) return;
34988
35230
  syncInFlight = true;
@@ -35426,7 +35668,7 @@ var init_indexer = __esm({
35426
35668
  sessionWatcher = watchWithFallback("sessions", CLAUDE_SESSION_ROOTS.map((root) => `${root}/**/*.jsonl`), {
35427
35669
  ignored: (p, stats) => {
35428
35670
  if (/agent-/.test(p) || /^\./.test(basename27(p))) return true;
35429
- const st = stats ?? statSync49(p, { throwIfNoEntry: false });
35671
+ const st = stats ?? statSync50(p, { throwIfNoEntry: false });
35430
35672
  if (!st || st.isDirectory()) return false;
35431
35673
  return st.mtimeMs < Date.now() - WATCH_WINDOW_MS;
35432
35674
  },