chat-recall 0.7.68 → 0.7.70

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
@@ -9172,6 +9172,25 @@ var init_session = __esm({
9172
9172
  function detach(s) {
9173
9173
  return JSON.parse(JSON.stringify(s));
9174
9174
  }
9175
+ function payloadLength(v) {
9176
+ if (v === void 0 || v === null)
9177
+ return 0;
9178
+ if (typeof v === "string")
9179
+ return v.length;
9180
+ try {
9181
+ return JSON.stringify(v)?.length ?? 0;
9182
+ } catch {
9183
+ return 0;
9184
+ }
9185
+ }
9186
+ function budgetedCut(capChars, budgetChars = SYNC_PAYLOAD_BUDGET, tightChars = SYNC_PAYLOAD_CAP_TIGHT) {
9187
+ let kept = 0;
9188
+ return (v) => {
9189
+ const out = capPayload(v, kept >= budgetChars ? Math.min(tightChars, capChars) : capChars);
9190
+ kept += payloadLength(out);
9191
+ return out;
9192
+ };
9193
+ }
9175
9194
  function capPayload(v, capChars = SYNC_PAYLOAD_CAP) {
9176
9195
  if (v === void 0)
9177
9196
  return void 0;
@@ -9196,10 +9215,12 @@ function capPayload(v, capChars = SYNC_PAYLOAD_CAP) {
9196
9215
  }
9197
9216
  return v;
9198
9217
  }
9199
- var SYNC_PAYLOAD_CAP;
9218
+ var SYNC_PAYLOAD_BUDGET, SYNC_PAYLOAD_CAP_TIGHT, SYNC_PAYLOAD_CAP;
9200
9219
  var init_trim = __esm({
9201
9220
  "../engine/dist/transcript/trim.js"() {
9202
9221
  "use strict";
9222
+ SYNC_PAYLOAD_BUDGET = 48 * 1024 * 1024;
9223
+ SYNC_PAYLOAD_CAP_TIGHT = 200;
9203
9224
  SYNC_PAYLOAD_CAP = 2e3;
9204
9225
  }
9205
9226
  });
@@ -9217,7 +9238,7 @@ async function parseClaudeTranscript(sessionPath, opts = {}) {
9217
9238
  return parseMessagesFromFile(sessionPath, opts);
9218
9239
  }
9219
9240
  function parseClaudeTranscriptText(text, opts = {}) {
9220
- const builder = new MessageBuilder(opts.payloadCap);
9241
+ const builder = new MessageBuilder(opts.payloadCap, opts.cut);
9221
9242
  let lineNumber = 0;
9222
9243
  for (const line of text.split("\n")) {
9223
9244
  lineNumber++;
@@ -9235,7 +9256,7 @@ function parseClaudeTranscriptText(text, opts = {}) {
9235
9256
  }
9236
9257
  async function parseMessagesFromFile(sessionPath, opts) {
9237
9258
  const file = await open(sessionPath);
9238
- const builder = new MessageBuilder(opts.payloadCap);
9259
+ const builder = new MessageBuilder(opts.payloadCap, opts.cut);
9239
9260
  try {
9240
9261
  let lineNumber = 0;
9241
9262
  for await (const line of file.readLines()) {
@@ -9340,8 +9361,8 @@ var init_claude2 = __esm({
9340
9361
  calls = /* @__PURE__ */ new Map();
9341
9362
  /** The last result of each tool_use id. */
9342
9363
  results = /* @__PURE__ */ new Map();
9343
- constructor(payloadCap) {
9344
- this.cap = payloadCap ? (v) => capPayload(v, payloadCap) : (v) => v;
9364
+ constructor(payloadCap, cut) {
9365
+ this.cap = cut ?? (payloadCap ? (v) => capPayload(v, payloadCap) : (v) => v);
9345
9366
  }
9346
9367
  add(line, obj2) {
9347
9368
  if (!obj2 || typeof obj2 !== "object")
@@ -9554,7 +9575,7 @@ function parseCodexTranscriptText(text, opts = {}) {
9554
9575
  return messages;
9555
9576
  }
9556
9577
  function codexLineHandler(messages, opts) {
9557
- const cap = opts.payloadCap ? (v) => capPayload(v, opts.payloadCap) : (v) => v;
9578
+ const cap = opts.cut ?? (opts.payloadCap ? (v) => capPayload(v, opts.payloadCap) : (v) => v);
9558
9579
  return (lineNum, line) => {
9559
9580
  if (!line.trim())
9560
9581
  return;
@@ -16341,6 +16362,9 @@ function walkSessionLimit(env = process.env) {
16341
16362
  if (!Number.isFinite(n) || !Number.isInteger(n) || n <= 0) return DEFAULT_WALK_MAX_SESSIONS;
16342
16363
  return n;
16343
16364
  }
16365
+ function hasAckedMtime(row) {
16366
+ return typeof row?.m === "number" && row.m > 0;
16367
+ }
16344
16368
  function orderRefsForWalk(refs, isAcked) {
16345
16369
  const fresh = [];
16346
16370
  const acked = [];
@@ -17085,7 +17109,7 @@ async function parseOpenCodeTranscript(sessionId, opts = {}) {
17085
17109
  WHERE p.session_id = ?
17086
17110
  ORDER BY p.time_created ASC
17087
17111
  `).iterate(realId, realId);
17088
- const cap = opts.payloadCap ? (v) => capPayload(v, opts.payloadCap) : (v) => v;
17112
+ const cap = opts.cut ?? (opts.payloadCap ? (v) => capPayload(v, opts.payloadCap) : (v) => v);
17089
17113
  let lastMsgData = "";
17090
17114
  let lastRole = "assistant";
17091
17115
  let lineNum = 0;
@@ -17132,9 +17156,12 @@ var init_opencode2 = __esm({
17132
17156
  var transcript_exports = {};
17133
17157
  __export(transcript_exports, {
17134
17158
  RAW_PARSE_MAX_BYTES: () => RAW_PARSE_MAX_BYTES,
17159
+ SYNC_PAYLOAD_BUDGET: () => SYNC_PAYLOAD_BUDGET,
17135
17160
  SYNC_PAYLOAD_CAP: () => SYNC_PAYLOAD_CAP,
17161
+ SYNC_PAYLOAD_CAP_TIGHT: () => SYNC_PAYLOAD_CAP_TIGHT,
17136
17162
  TRANSCRIPT_VERSION: () => TRANSCRIPT_VERSION,
17137
17163
  archiveRawSession: () => archiveRawSession,
17164
+ budgetedCut: () => budgetedCut,
17138
17165
  buildRawContainer: () => buildRawContainer,
17139
17166
  canonicalEventsToMessages: () => canonicalEventsToMessages,
17140
17167
  capPayload: () => capPayload,
@@ -17190,7 +17217,7 @@ async function parseTranscriptUncut(sessionId, opts) {
17190
17217
  return null;
17191
17218
  const primaryPath = mainGroup.paths[0];
17192
17219
  const merged = readSessionGroupText(mainGroup);
17193
- const cut = opts.payloadCap ? { payloadCap: opts.payloadCap } : {};
17220
+ const cut = opts.payloadCap ? { payloadCap: opts.payloadCap, cut: budgetedCut(opts.payloadCap, opts.payloadBudget) } : {};
17194
17221
  const [tail, allSubagents] = await Promise.all([
17195
17222
  Promise.resolve(parseClaudeTranscriptText(merged.text, cut)),
17196
17223
  parseClaudeSubagents(primaryPath, cut)
@@ -17213,7 +17240,7 @@ async function parseTranscriptUncut(sessionId, opts) {
17213
17240
  return { messages, subagents, mtime: merged.mtime || safeMtime(primaryPath), ...opts.payloadCap ? { payloadCap: opts.payloadCap } : {} };
17214
17241
  }
17215
17242
  if (tool === "opencode") {
17216
- const cut = opts.payloadCap ? { payloadCap: opts.payloadCap } : {};
17243
+ const cut = opts.payloadCap ? { payloadCap: opts.payloadCap, cut: budgetedCut(opts.payloadCap, opts.payloadBudget) } : {};
17217
17244
  const messages = await parseOpenCodeTranscript(sessionId, cut);
17218
17245
  if (messages.length === 0)
17219
17246
  return null;
@@ -17225,7 +17252,7 @@ async function parseTranscriptUncut(sessionId, opts) {
17225
17252
  const loc = getBackend("codex").findSession(sessionId);
17226
17253
  if (!loc)
17227
17254
  return null;
17228
- const cut = opts.payloadCap ? { payloadCap: opts.payloadCap } : {};
17255
+ const cut = opts.payloadCap ? { payloadCap: opts.payloadCap, cut: budgetedCut(opts.payloadCap, opts.payloadBudget) } : {};
17229
17256
  const [messages, subagents] = await Promise.all([
17230
17257
  parseCodexTranscript(loc.path, cut),
17231
17258
  parseCodexSubagents(loc.path, cut)
@@ -30356,6 +30383,7 @@ __export(sync_client_exports, {
30356
30383
  classifyError: () => classifyError,
30357
30384
  countsForBreaker: () => countsForBreaker,
30358
30385
  exportByteLength: () => exportByteLength,
30386
+ fetchTenantSecurityConfig: () => fetchTenantSecurityConfig,
30359
30387
  isJsonlTranscript: () => isJsonlTranscript,
30360
30388
  isStandingFailure: () => isStandingFailure,
30361
30389
  isSyncSkip: () => isSyncSkip,
@@ -31313,7 +31341,7 @@ async function syncToTargetInScope(cred, opts = {}) {
31313
31341
  };
31314
31342
  let scanMs = 0, scanned = 0;
31315
31343
  const walkMax = opts.limit ?? walkSessionLimit();
31316
- const ordered = walkMax > 0 ? orderRefsForWalk(refs, (id) => Boolean(ledger?.get(id))) : refs;
31344
+ const ordered = walkMax > 0 ? orderRefsForWalk(refs, (id) => hasAckedMtime(ledger?.get(id))) : refs;
31317
31345
  const slice = walkMax > 0 ? ordered.slice(0, walkMax) : ordered;
31318
31346
  const unackedCount = walkMax > 0 ? refs.reduce((n, r) => n + (ledger?.get(r.prefixedId) ? 0 : 1), 0) : refs.length;
31319
31347
  const trace = process.env.CHAT_RECALL_SYNC_TRACE === "1" ? (msg) => {
@@ -42225,6 +42253,7 @@ program.command("verify").description("Check that the server holds everything th
42225
42253
  for (const t of targets) {
42226
42254
  let report;
42227
42255
  try {
42256
+ await fetchTenantSecurityConfig(t);
42228
42257
  report = await verifyAgainstServer2(t.serverUrl, t.token, sinceMs, deps);
42229
42258
  } catch (e) {
42230
42259
  console.error(chalk2.red(`${t.serverUrl}: ${e instanceof Error ? e.message : e}`));