chat-recall 0.7.72 → 0.7.74

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 CHANGED
@@ -9215,10 +9215,13 @@ function capPayload(v, capChars = SYNC_PAYLOAD_CAP) {
9215
9215
  }
9216
9216
  return v;
9217
9217
  }
9218
- var SYNC_PAYLOAD_BUDGET, SYNC_PAYLOAD_CAP_TIGHT, SYNC_PAYLOAD_CAP;
9218
+ var SYNC_TEXT_CAP, SYNC_TEXT_BUDGET, SYNC_TEXT_CAP_TIGHT, SYNC_PAYLOAD_BUDGET, SYNC_PAYLOAD_CAP_TIGHT, SYNC_PAYLOAD_CAP;
9219
9219
  var init_trim = __esm({
9220
9220
  "../engine/dist/transcript/trim.js"() {
9221
9221
  "use strict";
9222
+ SYNC_TEXT_CAP = 2e5;
9223
+ SYNC_TEXT_BUDGET = 96 * 1024 * 1024;
9224
+ SYNC_TEXT_CAP_TIGHT = 2e3;
9222
9225
  SYNC_PAYLOAD_BUDGET = 48 * 1024 * 1024;
9223
9226
  SYNC_PAYLOAD_CAP_TIGHT = 200;
9224
9227
  SYNC_PAYLOAD_CAP = 2e3;
@@ -9238,7 +9241,7 @@ async function parseClaudeTranscript(sessionPath, opts = {}) {
9238
9241
  return parseMessagesFromFile(sessionPath, opts);
9239
9242
  }
9240
9243
  function parseClaudeTranscriptText(text, opts = {}) {
9241
- const builder = new MessageBuilder(opts.payloadCap, opts.cut);
9244
+ const builder = new MessageBuilder(opts.payloadCap, opts.cut, opts.cutText);
9242
9245
  let lineNumber = 0;
9243
9246
  for (const line of text.split("\n")) {
9244
9247
  lineNumber++;
@@ -9256,7 +9259,7 @@ function parseClaudeTranscriptText(text, opts = {}) {
9256
9259
  }
9257
9260
  async function parseMessagesFromFile(sessionPath, opts) {
9258
9261
  const file = await open(sessionPath);
9259
- const builder = new MessageBuilder(opts.payloadCap, opts.cut);
9262
+ const builder = new MessageBuilder(opts.payloadCap, opts.cut, opts.cutText);
9260
9263
  try {
9261
9264
  let lineNumber = 0;
9262
9265
  for await (const line of file.readLines()) {
@@ -9361,8 +9364,10 @@ var init_claude2 = __esm({
9361
9364
  calls = /* @__PURE__ */ new Map();
9362
9365
  /** The last result of each tool_use id. */
9363
9366
  results = /* @__PURE__ */ new Map();
9364
- constructor(payloadCap, cut) {
9367
+ cutText;
9368
+ constructor(payloadCap, cut, cutText) {
9365
9369
  this.cap = cut ?? (payloadCap ? (v) => capPayload(v, payloadCap) : (v) => v);
9370
+ this.cutText = cutText ? (v) => cutText(v) : (v) => v;
9366
9371
  }
9367
9372
  add(line, obj2) {
9368
9373
  if (!obj2 || typeof obj2 !== "object")
@@ -9389,7 +9394,7 @@ var init_claude2 = __esm({
9389
9394
  if (!cleaned)
9390
9395
  return;
9391
9396
  const origin = userRecordOrigin(obj2, cleaned);
9392
- this.messages.push({ line, role: "user", content: cleaned, timestamp, ...origin === "human" ? {} : { origin } });
9397
+ this.messages.push({ line, role: "user", content: this.cutText(cleaned), timestamp, ...origin === "human" ? {} : { origin } });
9393
9398
  } else if (obj2.type === "attachment") {
9394
9399
  const queued = queuedCommandPrompt(obj2);
9395
9400
  if (!queued)
@@ -9397,7 +9402,7 @@ var init_claude2 = __esm({
9397
9402
  const cleaned = stripBanners2(queued.text);
9398
9403
  if (!cleaned)
9399
9404
  return;
9400
- this.messages.push({ line, role: "user", content: cleaned, timestamp, ...queued.origin === "human" ? {} : { origin: queued.origin } });
9405
+ this.messages.push({ line, role: "user", content: this.cutText(cleaned), timestamp, ...queued.origin === "human" ? {} : { origin: queued.origin } });
9401
9406
  } else if (obj2.type === "assistant") {
9402
9407
  const blocks = Array.isArray(obj2.message?.content) ? obj2.message.content : [];
9403
9408
  const thinkingBlock = blocks.find((c) => c?.type === "thinking");
@@ -9428,7 +9433,7 @@ var init_claude2 = __esm({
9428
9433
  this.messages.push({
9429
9434
  line,
9430
9435
  role: "assistant",
9431
- content: text,
9436
+ content: this.cutText(text),
9432
9437
  thinking,
9433
9438
  toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
9434
9439
  timestamp
@@ -9576,6 +9581,7 @@ function parseCodexTranscriptText(text, opts = {}) {
9576
9581
  }
9577
9582
  function codexLineHandler(messages, opts) {
9578
9583
  const cap = opts.cut ?? (opts.payloadCap ? (v) => capPayload(v, opts.payloadCap) : (v) => v);
9584
+ const cutText = (v) => opts.cutText ? opts.cutText(v) : v;
9579
9585
  return (lineNum, line) => {
9580
9586
  if (!line.trim())
9581
9587
  return;
@@ -9585,14 +9591,14 @@ function codexLineHandler(messages, opts) {
9585
9591
  const text = String(obj2.payload.message || "").trim();
9586
9592
  if (!text || isCodexInjectedWrapper(text))
9587
9593
  return;
9588
- messages.push({ line: lineNum, role: "user", content: text, timestamp: obj2.timestamp });
9594
+ messages.push({ line: lineNum, role: "user", content: cutText(text), timestamp: obj2.timestamp });
9589
9595
  } else if (obj2.type === "response_item" && obj2.payload?.type === "message") {
9590
9596
  if (obj2.payload.role !== "assistant")
9591
9597
  return;
9592
9598
  const text = flattenCodexContent(obj2.payload.content);
9593
9599
  if (!text.trim())
9594
9600
  return;
9595
- messages.push({ line: lineNum, role: "assistant", content: text, timestamp: obj2.timestamp });
9601
+ messages.push({ line: lineNum, role: "assistant", content: cutText(text), timestamp: obj2.timestamp });
9596
9602
  } else if (obj2.type === "response_item" && obj2.payload?.type === "reasoning") {
9597
9603
  const summary = Array.isArray(obj2.payload.summary) ? obj2.payload.summary.map((s) => s?.text || "").filter(Boolean).join("\n") : "";
9598
9604
  if (!summary.trim())
@@ -17131,7 +17137,7 @@ async function parseOpenCodeTranscript(sessionId, opts = {}) {
17131
17137
  const role = lastRole;
17132
17138
  if (partData.type === "text" && partData.text?.trim()) {
17133
17139
  lineNum++;
17134
- messages.push({ line: lineNum, role, content: partData.text });
17140
+ messages.push({ line: lineNum, role, content: opts.cutText ? opts.cutText(partData.text) : partData.text });
17135
17141
  } else if (partData.type === "tool" && partData.tool) {
17136
17142
  lineNum++;
17137
17143
  messages.push({
@@ -17167,6 +17173,9 @@ __export(transcript_exports, {
17167
17173
  SYNC_PAYLOAD_BUDGET: () => SYNC_PAYLOAD_BUDGET,
17168
17174
  SYNC_PAYLOAD_CAP: () => SYNC_PAYLOAD_CAP,
17169
17175
  SYNC_PAYLOAD_CAP_TIGHT: () => SYNC_PAYLOAD_CAP_TIGHT,
17176
+ SYNC_TEXT_BUDGET: () => SYNC_TEXT_BUDGET,
17177
+ SYNC_TEXT_CAP: () => SYNC_TEXT_CAP,
17178
+ SYNC_TEXT_CAP_TIGHT: () => SYNC_TEXT_CAP_TIGHT,
17170
17179
  TRANSCRIPT_VERSION: () => TRANSCRIPT_VERSION,
17171
17180
  archiveRawSession: () => archiveRawSession,
17172
17181
  budgetedCut: () => budgetedCut,
@@ -17225,7 +17234,7 @@ async function parseTranscriptUncut(sessionId, opts) {
17225
17234
  return null;
17226
17235
  const primaryPath = mainGroup.paths[0];
17227
17236
  const merged = readSessionGroupText(mainGroup);
17228
- const cut = opts.payloadCap ? { payloadCap: opts.payloadCap, cut: budgetedCut(opts.payloadCap, opts.payloadBudget) } : {};
17237
+ const cut = opts.payloadCap ? { payloadCap: opts.payloadCap, cut: budgetedCut(opts.payloadCap, opts.payloadBudget), cutText: budgetedCut(SYNC_TEXT_CAP, SYNC_TEXT_BUDGET, SYNC_TEXT_CAP_TIGHT) } : {};
17229
17238
  const [tail, allSubagents] = await Promise.all([
17230
17239
  Promise.resolve(parseClaudeTranscriptText(merged.text, cut)),
17231
17240
  parseClaudeSubagents(primaryPath, cut)
@@ -17248,7 +17257,7 @@ async function parseTranscriptUncut(sessionId, opts) {
17248
17257
  return { messages, subagents, mtime: merged.mtime || safeMtime(primaryPath), ...opts.payloadCap ? { payloadCap: opts.payloadCap } : {} };
17249
17258
  }
17250
17259
  if (tool === "opencode") {
17251
- const cut = opts.payloadCap ? { payloadCap: opts.payloadCap, cut: budgetedCut(opts.payloadCap, opts.payloadBudget) } : {};
17260
+ const cut = opts.payloadCap ? { payloadCap: opts.payloadCap, cut: budgetedCut(opts.payloadCap, opts.payloadBudget), cutText: budgetedCut(SYNC_TEXT_CAP, SYNC_TEXT_BUDGET, SYNC_TEXT_CAP_TIGHT) } : {};
17252
17261
  const messages = await parseOpenCodeTranscript(sessionId, cut);
17253
17262
  if (messages.length === 0)
17254
17263
  return null;
@@ -17260,7 +17269,7 @@ async function parseTranscriptUncut(sessionId, opts) {
17260
17269
  const loc = getBackend("codex").findSession(sessionId);
17261
17270
  if (!loc)
17262
17271
  return null;
17263
- const cut = opts.payloadCap ? { payloadCap: opts.payloadCap, cut: budgetedCut(opts.payloadCap, opts.payloadBudget) } : {};
17272
+ const cut = opts.payloadCap ? { payloadCap: opts.payloadCap, cut: budgetedCut(opts.payloadCap, opts.payloadBudget), cutText: budgetedCut(SYNC_TEXT_CAP, SYNC_TEXT_BUDGET, SYNC_TEXT_CAP_TIGHT) } : {};
17264
17273
  const [messages, subagents] = await Promise.all([
17265
17274
  parseCodexTranscript(loc.path, cut),
17266
17275
  parseCodexSubagents(loc.path, cut)
@@ -37074,6 +37083,7 @@ async function verifyAgainstServer(server, token, sinceMs, deps, now = Date.now(
37074
37083
  pending: [],
37075
37084
  stranded: []
37076
37085
  };
37086
+ const candidates2 = [];
37077
37087
  for (const s of deps.listSessions(sinceMs)) {
37078
37088
  const srv = serverSize.get(s.rawId);
37079
37089
  if (srv === void 0) {
@@ -37083,6 +37093,21 @@ async function verifyAgainstServer(server, token, sinceMs, deps, now = Date.now(
37083
37093
  const local = deps.localContainerSize(s.rawId);
37084
37094
  if (local === null) continue;
37085
37095
  report.checked++;
37096
+ const deficit = local - srv;
37097
+ if (deficit <= TOLERANCE_BYTES) {
37098
+ report.complete++;
37099
+ continue;
37100
+ }
37101
+ candidates2.push({ s, srv, local });
37102
+ }
37103
+ if (candidates2.length > 0 && deps.beforeRecheck) {
37104
+ await deps.beforeRecheck(server, token);
37105
+ for (const c of candidates2) {
37106
+ const again = deps.localContainerSize(c.s.rawId);
37107
+ if (again !== null) c.local = again;
37108
+ }
37109
+ }
37110
+ for (const { s, srv, local } of candidates2) {
37086
37111
  const deficit = local - srv;
37087
37112
  if (deficit <= TOLERANCE_BYTES) {
37088
37113
  report.complete++;
@@ -42248,6 +42273,12 @@ program.command("verify").description("Check that the server holds everything th
42248
42273
  return null;
42249
42274
  }
42250
42275
  },
42276
+ // The sync redacts with the rule pack of the server, so a session with a deficit is measured
42277
+ // again with it: with the compiled-in rules alone a session that the pack redacts looked 764
42278
+ // bytes larger than its archive on the server.
42279
+ beforeRecheck: async (server, token) => {
42280
+ await fetchTenantSecurityConfig({ serverUrl: server, token });
42281
+ },
42251
42282
  serverSizes: async (server, token) => {
42252
42283
  const headers = {};
42253
42284
  if (token) headers.authorization = `Bearer ${token}`;
@@ -42262,7 +42293,6 @@ program.command("verify").description("Check that the server holds everything th
42262
42293
  for (const t of targets) {
42263
42294
  let report;
42264
42295
  try {
42265
- await fetchTenantSecurityConfig(t);
42266
42296
  report = await verifyAgainstServer2(t.serverUrl, t.token, sinceMs, deps);
42267
42297
  } catch (e) {
42268
42298
  console.error(chalk2.red(`${t.serverUrl}: ${e instanceof Error ? e.message : e}`));