chat-recall 0.7.76 → 0.7.78

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
@@ -6718,6 +6718,10 @@ function applyDecisions(roots, includeExcluded) {
6718
6718
  function applyExclusions(roots, includeExcluded) {
6719
6719
  return applyDecisions(roots, includeExcluded);
6720
6720
  }
6721
+ function geminiTmpDirs(opts = {}) {
6722
+ const overridden = !!(process.env.CHAT_RECALL_GEMINI_HOME || sources().geminiHome);
6723
+ return applyExclusions(siblingHomes(geminiHomeDir(), overridden, "tmp"), opts.includeExcluded);
6724
+ }
6721
6725
  function codexSessionDirs(opts = {}) {
6722
6726
  const overridden = !!(process.env.CHAT_RECALL_CODEX_HOME || sources().codexHome);
6723
6727
  return applyExclusions(siblingHomes(codexHomeDir(), overridden, "sessions"), opts.includeExcluded);
@@ -14168,8 +14172,35 @@ var init_shadow = __esm({
14168
14172
  });
14169
14173
 
14170
14174
  // ../engine/dist/core/live-session-scan.js
14175
+ var live_session_scan_exports = {};
14176
+ __export(live_session_scan_exports, {
14177
+ INDEX_RECHECK_MS: () => INDEX_RECHECK_MS,
14178
+ MAX_EVENT_LINE_BYTES: () => MAX_EVENT_LINE_BYTES,
14179
+ detectTool: () => detectTool,
14180
+ findCodexSessionFile: () => findCodexSessionFile,
14181
+ findGeminiSessionFile: () => findGeminiSessionFile,
14182
+ findSessionFile: () => findSessionFile,
14183
+ findSessionFiles: () => findSessionFiles,
14184
+ invalidateGeminiSessionIndex: () => invalidateGeminiSessionIndex,
14185
+ invalidateSessionFileIndex: () => invalidateSessionFileIndex,
14186
+ liveScanModifiedFiles: () => liveScanModifiedFiles,
14187
+ liveScanRecentEdits: () => liveScanRecentEdits,
14188
+ liveScanSessionEdits: () => liveScanSessionEdits,
14189
+ memoInSessionScope: () => memoInSessionScope,
14190
+ readGeminiMessages: () => readGeminiMessages,
14191
+ readHeadSync: () => readHeadSync,
14192
+ readSessionGroupText: () => readSessionGroupText,
14193
+ resolveSessionContentGroups: () => resolveSessionContentGroups,
14194
+ resolveSessionContentPaths: () => resolveSessionContentPaths,
14195
+ withSessionReadCache: () => withSessionReadCache,
14196
+ withSessionScanScope: () => withSessionScanScope
14197
+ });
14171
14198
  import { existsSync as existsSync18, readdirSync as readdirSync13, readFileSync as readFileSync15, statSync as statSync16, openSync as openSync7, readSync as readSync7, closeSync as closeSync7 } from "fs";
14172
14199
  import { join as join21, basename as basename11 } from "path";
14200
+ import { createHash as createHash7 } from "crypto";
14201
+ function lazyGeminiProjectsJson() {
14202
+ return join21(geminiHomeDir(), "projects.json");
14203
+ }
14173
14204
  function detectTool(sessionId) {
14174
14205
  return getBackendForId(sessionId)?.id ?? "claude";
14175
14206
  }
@@ -14356,9 +14387,178 @@ function resolveSessionContentPaths(sessionFile) {
14356
14387
  const subPaths = readdirSync13(subDir).filter((f) => f.endsWith(".jsonl")).sort().map((f) => join21(subDir, f));
14357
14388
  return [sessionFile, ...subPaths];
14358
14389
  }
14390
+ function liveScanSessionEdits(sessionId) {
14391
+ const backend = getBackendForId(sessionId);
14392
+ if (backend)
14393
+ return backend.liveScanEdits(sessionId);
14394
+ const tool = detectTool(sessionId);
14395
+ return { found: false, projectPath: "", projectDir: "", edits: [], fileMtime: 0, tool };
14396
+ }
14397
+ function loadGeminiProjectMap() {
14398
+ if (geminiProjectMapCache)
14399
+ return geminiProjectMapCache;
14400
+ const map = /* @__PURE__ */ new Map();
14401
+ const projectsPath = lazyGeminiProjectsJson();
14402
+ if (existsSync18(projectsPath)) {
14403
+ try {
14404
+ const data = JSON.parse(readFileSync15(projectsPath, "utf-8"));
14405
+ for (const path of Object.keys(data.projects || {})) {
14406
+ map.set(createHash7("sha256").update(path).digest("hex"), path);
14407
+ }
14408
+ } catch {
14409
+ }
14410
+ }
14411
+ geminiProjectMapCache = map;
14412
+ return map;
14413
+ }
14414
+ function findGeminiSessionFile(sessionIdOrFileBase) {
14415
+ const idx = geminiIndex();
14416
+ const exact = idx.byBase.get(sessionIdOrFileBase);
14417
+ if (exact)
14418
+ return exact;
14419
+ for (let len = Math.min(sessionIdOrFileBase.length, 64); len >= 4; len--) {
14420
+ const hit = idx.byTail.get(sessionIdOrFileBase.slice(0, len));
14421
+ if (hit)
14422
+ return hit;
14423
+ }
14424
+ return geminiInnerIdIndex(idx).get(sessionIdOrFileBase) ?? null;
14425
+ }
14359
14426
  function invalidateGeminiSessionIndex() {
14360
14427
  geminiCache = null;
14361
14428
  }
14429
+ function geminiIndex() {
14430
+ if (geminiCache)
14431
+ return geminiCache;
14432
+ const byBase = /* @__PURE__ */ new Map();
14433
+ const byTail = /* @__PURE__ */ new Map();
14434
+ const all = [];
14435
+ const projMap = loadGeminiProjectMap();
14436
+ const isGeminiChat = (f) => f.startsWith("session-") && (f.endsWith(".json") || f.endsWith(".jsonl"));
14437
+ for (const tmpRoot of geminiTmpDirs()) {
14438
+ if (!existsSync18(tmpRoot))
14439
+ continue;
14440
+ let projs;
14441
+ try {
14442
+ projs = readdirSync13(tmpRoot, { withFileTypes: true });
14443
+ } catch {
14444
+ continue;
14445
+ }
14446
+ for (const proj of projs) {
14447
+ if (!proj.isDirectory())
14448
+ continue;
14449
+ const chats = join21(tmpRoot, proj.name, "chats");
14450
+ if (!existsSync18(chats))
14451
+ continue;
14452
+ let files;
14453
+ try {
14454
+ files = readdirSync13(chats);
14455
+ } catch {
14456
+ continue;
14457
+ }
14458
+ for (const f of files) {
14459
+ if (!isGeminiChat(f))
14460
+ continue;
14461
+ const base4 = f.replace(/\.jsonl?$/, "");
14462
+ const located = {
14463
+ path: join21(chats, f),
14464
+ projectDir: proj.name,
14465
+ projectPath: projMap.get(proj.name) || "",
14466
+ format: f.endsWith(".jsonl") ? "jsonl" : "json"
14467
+ };
14468
+ all.push(located);
14469
+ if (!byBase.has(base4))
14470
+ byBase.set(base4, located);
14471
+ const tail = base4.split("-").pop() || "";
14472
+ if (tail.length >= 4 && !byTail.has(tail))
14473
+ byTail.set(tail, located);
14474
+ }
14475
+ }
14476
+ }
14477
+ const built = { byBase, byTail, all, byInnerId: null };
14478
+ if (scanScopeDepth > 0)
14479
+ geminiCache = built;
14480
+ return built;
14481
+ }
14482
+ function geminiInnerIdIndex(idx) {
14483
+ if (idx.byInnerId)
14484
+ return idx.byInnerId;
14485
+ const byInnerId = /* @__PURE__ */ new Map();
14486
+ for (const located of idx.all) {
14487
+ try {
14488
+ const innerId = readGeminiSessionIdFromFile(located.path, located.format);
14489
+ if (innerId && !byInnerId.has(innerId))
14490
+ byInnerId.set(innerId, located);
14491
+ } catch {
14492
+ }
14493
+ }
14494
+ idx.byInnerId = byInnerId;
14495
+ return byInnerId;
14496
+ }
14497
+ function readHeadSync(path, bytes = 65536) {
14498
+ const fd = openSync7(path, "r");
14499
+ try {
14500
+ const buf = Buffer.alloc(bytes);
14501
+ const n = readSync7(fd, buf, 0, buf.length, 0);
14502
+ return buf.toString("utf-8", 0, n);
14503
+ } finally {
14504
+ closeSync7(fd);
14505
+ }
14506
+ }
14507
+ function readGeminiSessionIdFromFile(path, format) {
14508
+ if (format === "json") {
14509
+ try {
14510
+ return JSON.parse(readFileSync15(path, "utf-8"))?.sessionId ?? null;
14511
+ } catch {
14512
+ return null;
14513
+ }
14514
+ }
14515
+ try {
14516
+ const head = readHeadSync(path).split("\n", 1)[0] || "";
14517
+ return JSON.parse(head)?.sessionId ?? null;
14518
+ } catch {
14519
+ return null;
14520
+ }
14521
+ }
14522
+ function readGeminiMessages(path, format) {
14523
+ if (format === "json") {
14524
+ try {
14525
+ const json = JSON.parse(readFileSync15(path, "utf-8"));
14526
+ return Array.isArray(json.messages) ? json.messages : [];
14527
+ } catch {
14528
+ return [];
14529
+ }
14530
+ }
14531
+ const out = [];
14532
+ let raw;
14533
+ try {
14534
+ raw = readFileSync15(path, "utf-8");
14535
+ } catch {
14536
+ return out;
14537
+ }
14538
+ let isFirst = true;
14539
+ for (const line of raw.split("\n")) {
14540
+ if (!line.trim())
14541
+ continue;
14542
+ if (isFirst) {
14543
+ isFirst = false;
14544
+ continue;
14545
+ }
14546
+ if (line.length > MAX_EVENT_LINE_BYTES)
14547
+ continue;
14548
+ let obj2;
14549
+ try {
14550
+ obj2 = JSON.parse(line);
14551
+ } catch {
14552
+ continue;
14553
+ }
14554
+ if (!obj2 || typeof obj2 !== "object")
14555
+ continue;
14556
+ if (!obj2.type)
14557
+ continue;
14558
+ out.push(obj2);
14559
+ }
14560
+ return out;
14561
+ }
14362
14562
  function findCodexSessionFile(sessionId) {
14363
14563
  for (const root of codexSessionDirs()) {
14364
14564
  const found = findCodexSessionFileIn(root, sessionId);
@@ -14422,7 +14622,53 @@ function findCodexSessionFileIn(root, sessionId) {
14422
14622
  }
14423
14623
  return scanDir(root);
14424
14624
  }
14425
- var scanScopeDepth, indexCache, INDEX_RECHECK_MS, dirMtime, readScope, readScopeDepth, derivedScope, geminiCache, MAX_EVENT_LINE_BYTES;
14625
+ function liveScanModifiedFiles(sessionId) {
14626
+ const scan = liveScanSessionEdits(sessionId);
14627
+ const writeOps = /* @__PURE__ */ new Set(["edit", "write", "multi_edit", "notebook_edit"]);
14628
+ const files = /* @__PURE__ */ new Set();
14629
+ const reads = /* @__PURE__ */ new Set();
14630
+ for (const e of scan.edits) {
14631
+ if (writeOps.has(e.op))
14632
+ files.add(e.file);
14633
+ else if (e.op === "read")
14634
+ reads.add(e.file);
14635
+ }
14636
+ return {
14637
+ found: scan.found,
14638
+ files: [...files],
14639
+ reads: [...reads],
14640
+ edits: scan.edits,
14641
+ projectPath: scan.projectPath,
14642
+ tool: scan.tool
14643
+ };
14644
+ }
14645
+ function liveScanRecentEdits(opts) {
14646
+ const enabled = opts.tools ? new Set(opts.tools) : null;
14647
+ const needle = opts.pattern?.toLowerCase();
14648
+ const accept = (e) => {
14649
+ if (e.ts < opts.sinceMs)
14650
+ return false;
14651
+ if (needle && !e.file.toLowerCase().includes(needle))
14652
+ return false;
14653
+ return true;
14654
+ };
14655
+ const allEdits = [];
14656
+ for (const backend of listAvailableBackends()) {
14657
+ if (enabled && !enabled.has(backend.id))
14658
+ continue;
14659
+ const backendEdits = backend.collectRecentEdits({
14660
+ sinceMs: opts.sinceMs,
14661
+ projectFilter: opts.projectFilter,
14662
+ limitSessions: opts.limitSessions
14663
+ });
14664
+ for (const e of backendEdits)
14665
+ if (accept(e))
14666
+ allEdits.push(e);
14667
+ }
14668
+ allEdits.sort((a, b) => b.ts - a.ts);
14669
+ return allEdits;
14670
+ }
14671
+ var scanScopeDepth, indexCache, INDEX_RECHECK_MS, dirMtime, readScope, readScopeDepth, derivedScope, geminiProjectMapCache, geminiCache, MAX_EVENT_LINE_BYTES;
14426
14672
  var init_live_session_scan = __esm({
14427
14673
  "../engine/dist/core/live-session-scan.js"() {
14428
14674
  "use strict";
@@ -14445,6 +14691,7 @@ var init_live_session_scan = __esm({
14445
14691
  readScope = null;
14446
14692
  readScopeDepth = 0;
14447
14693
  derivedScope = null;
14694
+ geminiProjectMapCache = null;
14448
14695
  geminiCache = null;
14449
14696
  MAX_EVENT_LINE_BYTES = 8 * 1024 * 1024;
14450
14697
  }
@@ -14658,7 +14905,7 @@ var init_session_outcome = __esm({
14658
14905
 
14659
14906
  // ../engine/dist/core/backends/pi.js
14660
14907
  import { readdirSync as readdirSync14, readFileSync as readFileSync16, statSync as statSync17, openSync as openSync8, readSync as readSync8, closeSync as closeSync8 } from "fs";
14661
- import { createHash as createHash7 } from "crypto";
14908
+ import { createHash as createHash8 } from "crypto";
14662
14909
  import { basename as basename12, join as join22 } from "path";
14663
14910
  function parsePiFile(path) {
14664
14911
  let raw;
@@ -14778,7 +15025,7 @@ function piSessionKey(file) {
14778
15025
  return `${file.id}~${projectSuffix(file.projectPath || file.projectDir)}`;
14779
15026
  }
14780
15027
  function projectSuffix(projectDir) {
14781
- return createHash7("sha256").update(projectDir).digest("hex").slice(0, 8);
15028
+ return createHash8("sha256").update(projectDir).digest("hex").slice(0, 8);
14782
15029
  }
14783
15030
  function mtimeOf(path, fallback) {
14784
15031
  try {
@@ -15762,7 +16009,7 @@ __export(detector_install_exports, {
15762
16009
  resolveDetector: () => resolveDetector
15763
16010
  });
15764
16011
  import { spawnSync as spawnSync2 } from "child_process";
15765
- import { createHash as createHash8 } from "crypto";
16012
+ import { createHash as createHash9 } from "crypto";
15766
16013
  import { existsSync as existsSync20, mkdirSync as mkdirSync5, mkdtempSync, chmodSync as chmodSync3, renameSync as renameSync3, rmSync as rmSync2, writeFileSync as writeFileSync5, readFileSync as readFileSync18, statSync as statSync19, copyFileSync as copyFileSync2 } from "fs";
15767
16014
  import { join as join24 } from "path";
15768
16015
  function managedDetectorPath(name) {
@@ -15772,7 +16019,7 @@ function receiptPath(name) {
15772
16019
  return join24(getDetectorBinDir(), `${name}.receipt.json`);
15773
16020
  }
15774
16021
  function sha256File(path) {
15775
- return createHash8("sha256").update(readFileSync18(path)).digest("hex");
16022
+ return createHash9("sha256").update(readFileSync18(path)).digest("hex");
15776
16023
  }
15777
16024
  function readReceipt(name) {
15778
16025
  try {
@@ -15861,7 +16108,7 @@ async function installDetector(name, opts = {}) {
15861
16108
  if (!res.ok)
15862
16109
  throw new Error(`download failed: ${res.status} ${res.statusText} (${url})`);
15863
16110
  const bytes = Buffer.from(await res.arrayBuffer());
15864
- const got = createHash8("sha256").update(bytes).digest("hex");
16111
+ const got = createHash9("sha256").update(bytes).digest("hex");
15865
16112
  if (got !== asset.sha256) {
15866
16113
  throw new Error(`checksum mismatch for ${asset.file}: expected ${asset.sha256}, got ${got}. Refusing to install \u2014 the release bytes are not the ones this version was pinned to.`);
15867
16114
  }
@@ -18678,7 +18925,7 @@ ${task.description}`.slice(0, MAX_CHUNK_CHARS2);
18678
18925
  import { existsSync as existsSync25, readFileSync as readFileSync24, readdirSync as readdirSync19, statSync as statSync25 } from "fs";
18679
18926
  import { homedir as homedir9 } from "os";
18680
18927
  import { join as join30, basename as basename15, dirname as dirname16 } from "path";
18681
- import { createHash as createHash9 } from "crypto";
18928
+ import { createHash as createHash10 } from "crypto";
18682
18929
  function discoverProjectDirs(claudeDir) {
18683
18930
  const dirs = [];
18684
18931
  const seen = /* @__PURE__ */ new Set();
@@ -18740,7 +18987,7 @@ function discoverProjectDirs(claudeDir) {
18740
18987
  } catch {
18741
18988
  }
18742
18989
  }
18743
- void createHash9;
18990
+ void createHash10;
18744
18991
  return dirs;
18745
18992
  }
18746
18993
  var MAX_CHUNK_CHARS3, NOTE_FILES, ClaudeMdSource;
@@ -29401,16 +29648,16 @@ async function flush() {
29401
29648
  }
29402
29649
  function stableMark(value) {
29403
29650
  try {
29404
- const { createHash: createHash18 } = __require("node:crypto");
29405
- return createHash18("sha256").update(value).digest("hex").slice(0, 12);
29651
+ const { createHash: createHash19 } = __require("node:crypto");
29652
+ return createHash19("sha256").update(value).digest("hex").slice(0, 12);
29406
29653
  } catch {
29407
29654
  return "";
29408
29655
  }
29409
29656
  }
29410
29657
  function hashHost() {
29411
29658
  try {
29412
- const { createHash: createHash18 } = __require("node:crypto");
29413
- return createHash18("sha256").update(hostname()).digest("hex").slice(0, 12);
29659
+ const { createHash: createHash19 } = __require("node:crypto");
29660
+ return createHash19("sha256").update(hostname()).digest("hex").slice(0, 12);
29414
29661
  } catch {
29415
29662
  return "";
29416
29663
  }
@@ -30088,7 +30335,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
30088
30335
  import { writeFileSync as writeFileSync10, mkdtempSync as mkdtempSync3, rmSync as rmSync6, readdirSync as readdirSync31, statSync as statSync41, mkdirSync as mkdirSync10 } from "node:fs";
30089
30336
  import { join as join47, dirname as dirname19, sep as sep2, posix as pathPosix, win32 as pathWin32 } from "node:path";
30090
30337
  import { tmpdir as tmpdir3, homedir as homedir16 } from "node:os";
30091
- import { createHash as createHash10 } from "node:crypto";
30338
+ import { createHash as createHash11 } from "node:crypto";
30092
30339
  function compareVersions(a, b) {
30093
30340
  const pa = String(a).split("-")[0].split(".").map((n) => parseInt(n, 10) || 0);
30094
30341
  const pb = String(b).split("-")[0].split(".").map((n) => parseInt(n, 10) || 0);
@@ -30163,7 +30410,7 @@ async function executeAutoUpdate(plan, deps) {
30163
30410
  return { updated: false, reason: `download failed: ${e2 instanceof Error ? e2.message : e2}` };
30164
30411
  }
30165
30412
  }
30166
- const got = createHash10("sha256").update(buf).digest("hex");
30413
+ const got = createHash11("sha256").update(buf).digest("hex");
30167
30414
  if (got !== plan.sha256) return { updated: false, reason: `checksum mismatch (expected ${plan.sha256.slice(0, 12)}\u2026, got ${got.slice(0, 12)}\u2026) \u2014 NOT installing` };
30168
30415
  const dir = mkdtempSync3(join47(tmpdir3(), "cr-update-"));
30169
30416
  const discardStaging = () => {
@@ -30426,7 +30673,7 @@ __export(sync_client_exports, {
30426
30673
  import { join as join48, dirname as dirname20, basename as basename22 } from "node:path";
30427
30674
  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";
30428
30675
  import { tmpdir as tmpdir4, hostname as hostname2 } from "node:os";
30429
- import { createHash as createHash11 } from "node:crypto";
30676
+ import { createHash as createHash12 } from "node:crypto";
30430
30677
  import { fileURLToPath as fileURLToPath3 } from "node:url";
30431
30678
  import { gzipSync as gzipSync3 } from "zlib";
30432
30679
  function classedError(errorClass, message) {
@@ -31334,7 +31581,7 @@ async function syncToTargetInScope(cred, opts = {}) {
31334
31581
  const kgSeen = /* @__PURE__ */ new Set();
31335
31582
  const kgEntityType = /* @__PURE__ */ new Map();
31336
31583
  const kgEntityNames = /* @__PURE__ */ new Set();
31337
- const kgKey = (subject, predicate, object, validFrom) => createHash11("sha1").update(`${subject}|${predicate}|${object}|${validFrom}`).digest("hex").slice(0, 16);
31584
+ const kgKey = (subject, predicate, object, validFrom) => createHash12("sha1").update(`${subject}|${predicate}|${object}|${validFrom}`).digest("hex").slice(0, 16);
31338
31585
  const accumulateKg = async (triples, sourceSession) => {
31339
31586
  for (const t of triples) {
31340
31587
  const key2 = kgKey(t.subject, t.predicate, t.object, t.validFrom ?? "");
@@ -31713,7 +31960,7 @@ async function syncToTargetInScope(cred, opts = {}) {
31713
31960
  for (const [sourceType, ids] of inventory) {
31714
31961
  if (inventoryFailed.has(sourceType)) continue;
31715
31962
  const sorted = [...ids].sort();
31716
- const hash = createHash11("sha256").update(sorted.join("\n")).digest("hex").slice(0, 32);
31963
+ const hash = createHash12("sha256").update(sorted.join("\n")).digest("hex").slice(0, 32);
31717
31964
  if (sentHashes[sourceType] === hash) continue;
31718
31965
  entries.push({ source_type: sourceType, ids: sorted });
31719
31966
  hashes[sourceType] = hash;
@@ -32367,7 +32614,7 @@ var init_sync_client = __esm({
32367
32614
  EMPTY_SYNC_CONFIG = { excludeTools: [], excludeProjects: [], excludeSources: [], approveSources: [] };
32368
32615
  _fetchTenantSyncConfigForTests = fetchTenantSyncConfig;
32369
32616
  SYNC_RULES_REFUSAL = /* @__PURE__ */ Symbol.for("chat-recall.syncRulesRefusal");
32370
- hashPath = (p) => p ? "p_" + createHash11("sha256").update(p).digest("hex").slice(0, 12) : "";
32617
+ hashPath = (p) => p ? "p_" + createHash12("sha256").update(p).digest("hex").slice(0, 12) : "";
32371
32618
  acceptedUploads = /* @__PURE__ */ new Map();
32372
32619
  MAX_DERIVED_ROW_BYTES = 2 * 1024 * 1024;
32373
32620
  isLocalHost = isPrivateHost;
@@ -34107,7 +34354,7 @@ __export(device_auth_exports, {
34107
34354
  betterAuthDeviceLogin: () => betterAuthDeviceLogin,
34108
34355
  deviceLogin: () => deviceLogin
34109
34356
  });
34110
- import { createHash as createHash12, randomBytes as randomBytes2 } from "node:crypto";
34357
+ import { createHash as createHash13, randomBytes as randomBytes2 } from "node:crypto";
34111
34358
  async function readDeviceCode(res, where) {
34112
34359
  const text = await res.text().catch(() => "");
34113
34360
  let parsed;
@@ -34136,7 +34383,7 @@ async function deviceLogin(opts, onPrompt) {
34136
34383
  const clientId = opts.clientId || DEFAULT_CLIENT_ID;
34137
34384
  const scope = opts.scope || "openid email profile";
34138
34385
  const codeVerifier = b64url(randomBytes2(32));
34139
- const codeChallenge = b64url(createHash12("sha256").update(codeVerifier).digest());
34386
+ const codeChallenge = b64url(createHash13("sha256").update(codeVerifier).digest());
34140
34387
  const startRes = await fetch(`${issuer}/protocol/openid-connect/auth/device`, {
34141
34388
  method: "POST",
34142
34389
  headers: { "content-type": "application/x-www-form-urlencoded" },
@@ -34677,7 +34924,7 @@ import { existsSync as existsSync49, mkdirSync as mkdirSync15, statSync as statS
34677
34924
  import { homedir as homedir21 } from "node:os";
34678
34925
  import { join as join59 } from "node:path";
34679
34926
  import { execSync as execSync3 } from "node:child_process";
34680
- import { createHash as createHash13 } from "node:crypto";
34927
+ import { createHash as createHash14 } from "node:crypto";
34681
34928
  function expectedCodeindexSha256(artifact) {
34682
34929
  return CODEINDEX_SHA256[artifact.replace(/^codeindex-/, "").replace(/\.exe$/, "")] ?? null;
34683
34930
  }
@@ -34785,7 +35032,7 @@ async function installCodeindex(opts = {}) {
34785
35032
  if (!expected) {
34786
35033
  throw new Error(`No pinned checksum for ${status.artifactName} \u2014 refusing to install an unverified binary. Add its sha256 to CODEINDEX_SHA256 in companions.ts.`);
34787
35034
  }
34788
- const actual = createHash13("sha256").update(readFileSync47(tmpPath)).digest("hex");
35035
+ const actual = createHash14("sha256").update(readFileSync47(tmpPath)).digest("hex");
34789
35036
  if (actual !== expected) {
34790
35037
  throw new Error(`Checksum mismatch for ${status.artifactName}.
34791
35038
  expected ${expected}
@@ -34875,7 +35122,7 @@ __export(install_skills_exports, {
34875
35122
  uninstallSkills: () => uninstallSkills
34876
35123
  });
34877
35124
  import { readdirSync as readdirSync33, existsSync as existsSync50, mkdirSync as mkdirSync16, rmSync as rmSync8, cpSync, writeFileSync as writeFileSync18, readFileSync as readFileSync48, statSync as statSync45, realpathSync as realpathSync5 } from "fs";
34878
- import { createHash as createHash14 } from "crypto";
35125
+ import { createHash as createHash15 } from "crypto";
34879
35126
  import { join as join60, basename as basename23 } from "path";
34880
35127
  function skillsSourceDir() {
34881
35128
  return join60(import.meta.dirname, "..", "skills");
@@ -34889,7 +35136,7 @@ function version() {
34889
35136
  }
34890
35137
  function skillsFingerprint() {
34891
35138
  const src = skillsSourceDir();
34892
- const h = createHash14("sha256");
35139
+ const h = createHash15("sha256");
34893
35140
  for (const name of bundledSkillNames()) {
34894
35141
  for (const rel of filesUnder(join60(src, name)).sort()) {
34895
35142
  h.update(name + "/" + rel);
@@ -36705,7 +36952,7 @@ __export(repair_exports, {
36705
36952
  repairSession: () => repairSession,
36706
36953
  repairSessions: () => repairSessions
36707
36954
  });
36708
- import { createHash as createHash15 } from "node:crypto";
36955
+ import { createHash as createHash16 } from "node:crypto";
36709
36956
  function resolveEndpoints(only) {
36710
36957
  const settings2 = loadSettings();
36711
36958
  const creds = loadAllCredentials();
@@ -36920,7 +37167,7 @@ var init_repair = __esm({
36920
37167
  init_http();
36921
37168
  init_sync_client();
36922
37169
  init_sync_client();
36923
- hashPath2 = (p) => p ? "p_" + createHash15("sha256").update(p).digest("hex").slice(0, 12) : "";
37170
+ hashPath2 = (p) => p ? "p_" + createHash16("sha256").update(p).digest("hex").slice(0, 12) : "";
36924
37171
  }
36925
37172
  });
36926
37173
 
@@ -37123,7 +37370,8 @@ async function verifyAgainstServer(server, token, sinceMs, deps, now = Date.now(
37123
37370
  const row = ledger.get(s.prefixedId) ?? ledger.get(s.rawId);
37124
37371
  const cursor = row?.s ?? 0;
37125
37372
  const live = s.mtime >= now - LIVE_GRACE_MS;
37126
- const stranded = !live && !!row && cursor >= deps.fileSize(s.rawId);
37373
+ const awaitingSettle = !!row && fullCoveredOffset(row) < cursor && now - s.mtime < SETTLE_QUIET_MS;
37374
+ const stranded = !live && !awaitingSettle && !!row && cursor >= deps.fileSize(s.rawId);
37127
37375
  const finding = {
37128
37376
  sessionId: s.rawId,
37129
37377
  projectPath: s.projectPath || "",
@@ -37198,9 +37446,9 @@ var init_verify_repair = __esm({
37198
37446
  });
37199
37447
 
37200
37448
  // ../engine/dist/types/code-intel.js
37201
- import { createHash as createHash16 } from "crypto";
37449
+ import { createHash as createHash17 } from "crypto";
37202
37450
  function shortHash(s) {
37203
- return createHash16("sha256").update(s).digest("hex").slice(0, 16);
37451
+ return createHash17("sha256").update(s).digest("hex").slice(0, 16);
37204
37452
  }
37205
37453
  function snippetKey(snippet) {
37206
37454
  return (snippet ?? "").replace(/\s+/g, " ").trim().slice(0, 200);
@@ -38922,7 +39170,7 @@ __export(team_merge_exports, {
38922
39170
  });
38923
39171
  import { existsSync as existsSync58, mkdirSync as mkdirSync22, readFileSync as readFileSync55, rmSync as rmSync11, writeFileSync as writeFileSync24, statSync as statSync48 } from "fs";
38924
39172
  import { dirname as dirname30, join as join69 } from "path";
38925
- import { createHash as createHash17 } from "crypto";
39173
+ import { createHash as createHash18 } from "crypto";
38926
39174
  function installPathFor(art, tool) {
38927
39175
  switch (art.type) {
38928
39176
  case "skill":
@@ -39003,14 +39251,14 @@ async function mergePullResult(opts) {
39003
39251
  continue;
39004
39252
  }
39005
39253
  const body2 = Buffer.from(a.bodyB64, "base64");
39006
- const sha = createHash17("sha256").update(body2).digest("hex");
39254
+ const sha = createHash18("sha256").update(body2).digest("hex");
39007
39255
  for (const tool of targets) {
39008
39256
  const path = installPathFor(a, tool);
39009
39257
  if (!path)
39010
39258
  continue;
39011
39259
  try {
39012
39260
  const existing = readFileIfExists(path);
39013
- if (existing && createHash17("sha256").update(existing).digest("hex") === sha) {
39261
+ if (existing && createHash18("sha256").update(existing).digest("hex") === sha) {
39014
39262
  report.skipped.push({ artifactId: a.id, path, reason: "unchanged" });
39015
39263
  pending.push({ artifactId: a.id, tool, artifactType: a.type, artifactName: a.name, sha256: sha, installedAt: Date.now() });
39016
39264
  continue;
@@ -42232,6 +42480,7 @@ program.command("verify").description("Check that the server holds everything th
42232
42480
  const { redactSecrets: redactSecrets2, serverRulePackVersion: serverRulePackVersion2 } = await Promise.resolve().then(() => (init_secret_redactor(), secret_redactor_exports));
42233
42481
  const { fetchWithTimeout: fetchWithTimeout2 } = await Promise.resolve().then(() => (init_http(), http_exports));
42234
42482
  const { forceFullResync: forceFullResync2 } = await Promise.resolve().then(() => (init_verify_repair(), verify_repair_exports));
42483
+ const { withSessionScanScope: withSessionScanScope2 } = await Promise.resolve().then(() => (init_live_session_scan(), live_session_scan_exports));
42235
42484
  const targets = verifyTargets2();
42236
42485
  if (targets.length === 0) {
42237
42486
  console.error(chalk2.red("No server configured \u2014 run `chat-recall login` first."));
@@ -42308,7 +42557,7 @@ program.command("verify").description("Check that the server holds everything th
42308
42557
  for (const t of targets) {
42309
42558
  let report;
42310
42559
  try {
42311
- report = await verifyAgainstServer2(t.serverUrl, t.token, sinceMs, deps);
42560
+ report = await withSessionScanScope2(() => verifyAgainstServer2(t.serverUrl, t.token, sinceMs, deps));
42312
42561
  } catch (e) {
42313
42562
  console.error(chalk2.red(`${t.serverUrl}: ${e instanceof Error ? e.message : e}`));
42314
42563
  exitCode = 1;