chat-recall 0.6.7 → 0.6.9
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 +966 -909
- package/dist/cli.js.map +1 -1
- package/dist/mcp-relay.js +1 -1
- package/dist/mcp.js +1043 -775
- package/dist/scan-worker.js +325 -25
- package/dist/scan-worker.js.map +1 -1
- package/dist/sync-client.d.ts +13 -0
- package/dist/sync-client.d.ts.map +1 -1
- package/dist/sync-client.js +38 -4
- package/dist/sync-client.js.map +1 -1
- package/dist/watch.js +895 -856
- package/package.json +1 -1
package/dist/scan-worker.js
CHANGED
|
@@ -5435,6 +5435,10 @@ function applyDecisions(roots, includeExcluded) {
|
|
|
5435
5435
|
function applyExclusions(roots, includeExcluded) {
|
|
5436
5436
|
return applyDecisions(roots, includeExcluded);
|
|
5437
5437
|
}
|
|
5438
|
+
function geminiTmpDirs(opts = {}) {
|
|
5439
|
+
const overridden = !!(process.env.CHAT_RECALL_GEMINI_HOME || sources().geminiHome);
|
|
5440
|
+
return applyExclusions(siblingHomes(geminiHomeDir(), overridden, "tmp"), opts.includeExcluded);
|
|
5441
|
+
}
|
|
5438
5442
|
function codexSessionDirs(opts = {}) {
|
|
5439
5443
|
const overridden = !!(process.env.CHAT_RECALL_CODEX_HOME || sources().codexHome);
|
|
5440
5444
|
return applyExclusions(siblingHomes(codexHomeDir(), overridden, "sessions"), opts.includeExcluded);
|
|
@@ -5790,6 +5794,10 @@ function ensureBootstrapped() {
|
|
|
5790
5794
|
_bootstrapper();
|
|
5791
5795
|
}
|
|
5792
5796
|
}
|
|
5797
|
+
function listAvailableBackends() {
|
|
5798
|
+
ensureBootstrapped();
|
|
5799
|
+
return [...REGISTRY.values()].filter((b) => b.isAvailable());
|
|
5800
|
+
}
|
|
5793
5801
|
var REGISTRY, _bootstrapper, _bootstrapped;
|
|
5794
5802
|
var init_tool_backend = __esm({
|
|
5795
5803
|
"../engine/dist/core/tool-backend.js"() {
|
|
@@ -9151,6 +9159,28 @@ var init_backends = __esm({
|
|
|
9151
9159
|
}
|
|
9152
9160
|
});
|
|
9153
9161
|
|
|
9162
|
+
// ../engine/dist/core/session-multi-tool.js
|
|
9163
|
+
function extractTurnsAny(sessionId, opts = {}) {
|
|
9164
|
+
const backend = getBackendForId(sessionId);
|
|
9165
|
+
if (!backend)
|
|
9166
|
+
return { sessionId, found: false, turns: [], startMs: 0, endMs: 0 };
|
|
9167
|
+
return memoInSessionScope(`turns:${sessionId}:${opts.maxTurns ?? ""}:${opts.assistantMax ?? ""}`, () => backend.extractTurns(sessionId, opts));
|
|
9168
|
+
}
|
|
9169
|
+
function replaySessionAny(sessionId) {
|
|
9170
|
+
const backend = getBackendForId(sessionId);
|
|
9171
|
+
if (!backend)
|
|
9172
|
+
return { sessionId, found: false, projectPath: "", files: [], totalLinesAdded: 0, totalLinesRemoved: 0 };
|
|
9173
|
+
return memoInSessionScope(`replay:${sessionId}`, () => backend.replay(sessionId));
|
|
9174
|
+
}
|
|
9175
|
+
var init_session_multi_tool = __esm({
|
|
9176
|
+
"../engine/dist/core/session-multi-tool.js"() {
|
|
9177
|
+
"use strict";
|
|
9178
|
+
init_tool_backend();
|
|
9179
|
+
init_live_session_scan();
|
|
9180
|
+
init_backends();
|
|
9181
|
+
}
|
|
9182
|
+
});
|
|
9183
|
+
|
|
9154
9184
|
// ../engine/dist/core/session-outcome.js
|
|
9155
9185
|
function extractDecisionsFromTurn(turn) {
|
|
9156
9186
|
if (turn.kind !== "assistant_text" || !turn.text)
|
|
@@ -9247,7 +9277,7 @@ function computeOutcome(sessionId, opts = {}) {
|
|
|
9247
9277
|
};
|
|
9248
9278
|
if (!backend)
|
|
9249
9279
|
return notFound;
|
|
9250
|
-
const turnsRes =
|
|
9280
|
+
const turnsRes = extractTurnsAny(sessionId, { assistantMax: 2e3 });
|
|
9251
9281
|
if (!turnsRes.found)
|
|
9252
9282
|
return notFound;
|
|
9253
9283
|
const decisions = [];
|
|
@@ -9286,7 +9316,7 @@ function computeOutcome(sessionId, opts = {}) {
|
|
|
9286
9316
|
totalLinesAdded = fast.totalLinesAdded;
|
|
9287
9317
|
totalLinesRemoved = fast.totalLinesRemoved;
|
|
9288
9318
|
} else {
|
|
9289
|
-
const replay =
|
|
9319
|
+
const replay = replaySessionAny(sessionId);
|
|
9290
9320
|
filesChanged = replay.files.map((f) => f.file);
|
|
9291
9321
|
totalLinesAdded = replay.totalLinesAdded;
|
|
9292
9322
|
totalLinesRemoved = replay.totalLinesRemoved;
|
|
@@ -9325,6 +9355,7 @@ var init_session_outcome = __esm({
|
|
|
9325
9355
|
init_session_sentiment();
|
|
9326
9356
|
init_session_git();
|
|
9327
9357
|
init_tool_backend();
|
|
9358
|
+
init_session_multi_tool();
|
|
9328
9359
|
init_backends();
|
|
9329
9360
|
DECISION_PATTERNS = [
|
|
9330
9361
|
/\b(?:I'?ll|I will|I'?m going to|Going to|Let me|We'?ll|We will|We should|Let'?s|I'?m about to|I'?m going to)\b[^\n.!?]*[.!?]/i,
|
|
@@ -9517,6 +9548,7 @@ var UUID_RE, ClaudeBackend, claudeBackend;
|
|
|
9517
9548
|
var init_claude = __esm({
|
|
9518
9549
|
"../engine/dist/core/backends/claude.js"() {
|
|
9519
9550
|
"use strict";
|
|
9551
|
+
init_live_session_scan();
|
|
9520
9552
|
init_tool_paths();
|
|
9521
9553
|
init_live_session_scan();
|
|
9522
9554
|
init_session_outcome();
|
|
@@ -9779,6 +9811,9 @@ var init_claude = __esm({
|
|
|
9779
9811
|
* splits show up alongside the parent.
|
|
9780
9812
|
*/
|
|
9781
9813
|
readEvents(rawId) {
|
|
9814
|
+
return memoInSessionScope(`events:claude:${rawId}`, () => this.#readEventsUncached(rawId));
|
|
9815
|
+
}
|
|
9816
|
+
#readEventsUncached(rawId) {
|
|
9782
9817
|
const groups = resolveSessionContentGroups(rawId);
|
|
9783
9818
|
if (groups.length === 0)
|
|
9784
9819
|
return [];
|
|
@@ -10215,11 +10250,54 @@ var init_shadow = __esm({
|
|
|
10215
10250
|
});
|
|
10216
10251
|
|
|
10217
10252
|
// ../engine/dist/core/live-session-scan.js
|
|
10253
|
+
var live_session_scan_exports = {};
|
|
10254
|
+
__export(live_session_scan_exports, {
|
|
10255
|
+
MAX_EVENT_LINE_BYTES: () => MAX_EVENT_LINE_BYTES,
|
|
10256
|
+
detectTool: () => detectTool,
|
|
10257
|
+
findCodexSessionFile: () => findCodexSessionFile,
|
|
10258
|
+
findGeminiSessionFile: () => findGeminiSessionFile,
|
|
10259
|
+
findSessionFile: () => findSessionFile,
|
|
10260
|
+
findSessionFiles: () => findSessionFiles,
|
|
10261
|
+
invalidateGeminiSessionIndex: () => invalidateGeminiSessionIndex,
|
|
10262
|
+
invalidateSessionFileIndex: () => invalidateSessionFileIndex,
|
|
10263
|
+
liveScanModifiedFiles: () => liveScanModifiedFiles,
|
|
10264
|
+
liveScanRecentEdits: () => liveScanRecentEdits,
|
|
10265
|
+
liveScanSessionEdits: () => liveScanSessionEdits,
|
|
10266
|
+
memoInSessionScope: () => memoInSessionScope,
|
|
10267
|
+
readGeminiMessages: () => readGeminiMessages,
|
|
10268
|
+
readHeadSync: () => readHeadSync,
|
|
10269
|
+
readSessionGroupText: () => readSessionGroupText,
|
|
10270
|
+
resolveSessionContentGroups: () => resolveSessionContentGroups,
|
|
10271
|
+
resolveSessionContentPaths: () => resolveSessionContentPaths,
|
|
10272
|
+
withSessionReadCache: () => withSessionReadCache,
|
|
10273
|
+
withSessionScanScope: () => withSessionScanScope
|
|
10274
|
+
});
|
|
10218
10275
|
import { existsSync as existsSync13, readdirSync as readdirSync10, readFileSync as readFileSync9, statSync as statSync11, openSync as openSync6, readSync as readSync6, closeSync as closeSync6 } from "fs";
|
|
10219
10276
|
import { join as join13, basename as basename8 } from "path";
|
|
10277
|
+
import { createHash as createHash2 } from "crypto";
|
|
10278
|
+
function lazyGeminiProjectsJson() {
|
|
10279
|
+
return join13(geminiHomeDir(), "projects.json");
|
|
10280
|
+
}
|
|
10281
|
+
function detectTool(sessionId) {
|
|
10282
|
+
return getBackendForId(sessionId)?.id ?? "claude";
|
|
10283
|
+
}
|
|
10284
|
+
async function withSessionScanScope(fn) {
|
|
10285
|
+
scanScopeDepth++;
|
|
10286
|
+
try {
|
|
10287
|
+
return await fn();
|
|
10288
|
+
} finally {
|
|
10289
|
+
if (--scanScopeDepth === 0) {
|
|
10290
|
+
invalidateSessionFileIndex();
|
|
10291
|
+
invalidateGeminiSessionIndex();
|
|
10292
|
+
}
|
|
10293
|
+
}
|
|
10294
|
+
}
|
|
10220
10295
|
function findSessionFile(sessionId) {
|
|
10221
10296
|
return sessionFileIndex().get(sessionId)?.[0] ?? null;
|
|
10222
10297
|
}
|
|
10298
|
+
function invalidateSessionFileIndex() {
|
|
10299
|
+
indexCache = null;
|
|
10300
|
+
}
|
|
10223
10301
|
function sessionFileIndex() {
|
|
10224
10302
|
if (indexCache)
|
|
10225
10303
|
return indexCache;
|
|
@@ -10290,13 +10368,26 @@ function resolveSessionContentGroups(sessionId) {
|
|
|
10290
10368
|
}
|
|
10291
10369
|
function withSessionReadCache(fn) {
|
|
10292
10370
|
readScopeDepth++;
|
|
10371
|
+
if (readScopeDepth === 1)
|
|
10372
|
+
derivedScope = /* @__PURE__ */ new Map();
|
|
10293
10373
|
try {
|
|
10294
10374
|
return fn();
|
|
10295
10375
|
} finally {
|
|
10296
|
-
if (--readScopeDepth === 0)
|
|
10376
|
+
if (--readScopeDepth === 0) {
|
|
10297
10377
|
readScope = null;
|
|
10378
|
+
derivedScope = null;
|
|
10379
|
+
}
|
|
10298
10380
|
}
|
|
10299
10381
|
}
|
|
10382
|
+
function memoInSessionScope(key, compute) {
|
|
10383
|
+
if (!derivedScope)
|
|
10384
|
+
return compute();
|
|
10385
|
+
if (derivedScope.has(key))
|
|
10386
|
+
return derivedScope.get(key);
|
|
10387
|
+
const value = compute();
|
|
10388
|
+
derivedScope.set(key, value);
|
|
10389
|
+
return value;
|
|
10390
|
+
}
|
|
10300
10391
|
function readSessionGroupText(group) {
|
|
10301
10392
|
let key = "";
|
|
10302
10393
|
if (readScopeDepth > 0) {
|
|
@@ -10342,6 +10433,178 @@ function resolveSessionContentPaths(sessionFile) {
|
|
|
10342
10433
|
const subPaths = readdirSync10(subDir).filter((f) => f.endsWith(".jsonl")).sort().map((f) => join13(subDir, f));
|
|
10343
10434
|
return [sessionFile, ...subPaths];
|
|
10344
10435
|
}
|
|
10436
|
+
function liveScanSessionEdits(sessionId) {
|
|
10437
|
+
const backend = getBackendForId(sessionId);
|
|
10438
|
+
if (backend)
|
|
10439
|
+
return backend.liveScanEdits(sessionId);
|
|
10440
|
+
const tool = detectTool(sessionId);
|
|
10441
|
+
return { found: false, projectPath: "", projectDir: "", edits: [], fileMtime: 0, tool };
|
|
10442
|
+
}
|
|
10443
|
+
function loadGeminiProjectMap() {
|
|
10444
|
+
if (geminiProjectMapCache)
|
|
10445
|
+
return geminiProjectMapCache;
|
|
10446
|
+
const map = /* @__PURE__ */ new Map();
|
|
10447
|
+
const projectsPath = lazyGeminiProjectsJson();
|
|
10448
|
+
if (existsSync13(projectsPath)) {
|
|
10449
|
+
try {
|
|
10450
|
+
const data = JSON.parse(readFileSync9(projectsPath, "utf-8"));
|
|
10451
|
+
for (const path of Object.keys(data.projects || {})) {
|
|
10452
|
+
map.set(createHash2("sha256").update(path).digest("hex"), path);
|
|
10453
|
+
}
|
|
10454
|
+
} catch {
|
|
10455
|
+
}
|
|
10456
|
+
}
|
|
10457
|
+
geminiProjectMapCache = map;
|
|
10458
|
+
return map;
|
|
10459
|
+
}
|
|
10460
|
+
function findGeminiSessionFile(sessionIdOrFileBase) {
|
|
10461
|
+
const idx = geminiIndex();
|
|
10462
|
+
const exact = idx.byBase.get(sessionIdOrFileBase);
|
|
10463
|
+
if (exact)
|
|
10464
|
+
return exact;
|
|
10465
|
+
for (let len = Math.min(sessionIdOrFileBase.length, 64); len >= 4; len--) {
|
|
10466
|
+
const hit = idx.byTail.get(sessionIdOrFileBase.slice(0, len));
|
|
10467
|
+
if (hit)
|
|
10468
|
+
return hit;
|
|
10469
|
+
}
|
|
10470
|
+
return geminiInnerIdIndex(idx).get(sessionIdOrFileBase) ?? null;
|
|
10471
|
+
}
|
|
10472
|
+
function invalidateGeminiSessionIndex() {
|
|
10473
|
+
geminiCache = null;
|
|
10474
|
+
}
|
|
10475
|
+
function geminiIndex() {
|
|
10476
|
+
if (geminiCache)
|
|
10477
|
+
return geminiCache;
|
|
10478
|
+
const byBase = /* @__PURE__ */ new Map();
|
|
10479
|
+
const byTail = /* @__PURE__ */ new Map();
|
|
10480
|
+
const all = [];
|
|
10481
|
+
const projMap = loadGeminiProjectMap();
|
|
10482
|
+
const isGeminiChat = (f) => f.startsWith("session-") && (f.endsWith(".json") || f.endsWith(".jsonl"));
|
|
10483
|
+
for (const tmpRoot of geminiTmpDirs()) {
|
|
10484
|
+
if (!existsSync13(tmpRoot))
|
|
10485
|
+
continue;
|
|
10486
|
+
let projs;
|
|
10487
|
+
try {
|
|
10488
|
+
projs = readdirSync10(tmpRoot, { withFileTypes: true });
|
|
10489
|
+
} catch {
|
|
10490
|
+
continue;
|
|
10491
|
+
}
|
|
10492
|
+
for (const proj of projs) {
|
|
10493
|
+
if (!proj.isDirectory())
|
|
10494
|
+
continue;
|
|
10495
|
+
const chats = join13(tmpRoot, proj.name, "chats");
|
|
10496
|
+
if (!existsSync13(chats))
|
|
10497
|
+
continue;
|
|
10498
|
+
let files;
|
|
10499
|
+
try {
|
|
10500
|
+
files = readdirSync10(chats);
|
|
10501
|
+
} catch {
|
|
10502
|
+
continue;
|
|
10503
|
+
}
|
|
10504
|
+
for (const f of files) {
|
|
10505
|
+
if (!isGeminiChat(f))
|
|
10506
|
+
continue;
|
|
10507
|
+
const base = f.replace(/\.jsonl?$/, "");
|
|
10508
|
+
const located = {
|
|
10509
|
+
path: join13(chats, f),
|
|
10510
|
+
projectDir: proj.name,
|
|
10511
|
+
projectPath: projMap.get(proj.name) || "",
|
|
10512
|
+
format: f.endsWith(".jsonl") ? "jsonl" : "json"
|
|
10513
|
+
};
|
|
10514
|
+
all.push(located);
|
|
10515
|
+
if (!byBase.has(base))
|
|
10516
|
+
byBase.set(base, located);
|
|
10517
|
+
const tail = base.split("-").pop() || "";
|
|
10518
|
+
if (tail.length >= 4 && !byTail.has(tail))
|
|
10519
|
+
byTail.set(tail, located);
|
|
10520
|
+
}
|
|
10521
|
+
}
|
|
10522
|
+
}
|
|
10523
|
+
const built = { byBase, byTail, all, byInnerId: null };
|
|
10524
|
+
if (scanScopeDepth > 0)
|
|
10525
|
+
geminiCache = built;
|
|
10526
|
+
return built;
|
|
10527
|
+
}
|
|
10528
|
+
function geminiInnerIdIndex(idx) {
|
|
10529
|
+
if (idx.byInnerId)
|
|
10530
|
+
return idx.byInnerId;
|
|
10531
|
+
const byInnerId = /* @__PURE__ */ new Map();
|
|
10532
|
+
for (const located of idx.all) {
|
|
10533
|
+
try {
|
|
10534
|
+
const innerId = readGeminiSessionIdFromFile(located.path, located.format);
|
|
10535
|
+
if (innerId && !byInnerId.has(innerId))
|
|
10536
|
+
byInnerId.set(innerId, located);
|
|
10537
|
+
} catch {
|
|
10538
|
+
}
|
|
10539
|
+
}
|
|
10540
|
+
idx.byInnerId = byInnerId;
|
|
10541
|
+
return byInnerId;
|
|
10542
|
+
}
|
|
10543
|
+
function readHeadSync(path, bytes = 65536) {
|
|
10544
|
+
const fd = openSync6(path, "r");
|
|
10545
|
+
try {
|
|
10546
|
+
const buf = Buffer.alloc(bytes);
|
|
10547
|
+
const n = readSync6(fd, buf, 0, buf.length, 0);
|
|
10548
|
+
return buf.toString("utf-8", 0, n);
|
|
10549
|
+
} finally {
|
|
10550
|
+
closeSync6(fd);
|
|
10551
|
+
}
|
|
10552
|
+
}
|
|
10553
|
+
function readGeminiSessionIdFromFile(path, format) {
|
|
10554
|
+
if (format === "json") {
|
|
10555
|
+
try {
|
|
10556
|
+
return JSON.parse(readFileSync9(path, "utf-8"))?.sessionId ?? null;
|
|
10557
|
+
} catch {
|
|
10558
|
+
return null;
|
|
10559
|
+
}
|
|
10560
|
+
}
|
|
10561
|
+
try {
|
|
10562
|
+
const head = readHeadSync(path).split("\n", 1)[0] || "";
|
|
10563
|
+
return JSON.parse(head)?.sessionId ?? null;
|
|
10564
|
+
} catch {
|
|
10565
|
+
return null;
|
|
10566
|
+
}
|
|
10567
|
+
}
|
|
10568
|
+
function readGeminiMessages(path, format) {
|
|
10569
|
+
if (format === "json") {
|
|
10570
|
+
try {
|
|
10571
|
+
const json = JSON.parse(readFileSync9(path, "utf-8"));
|
|
10572
|
+
return Array.isArray(json.messages) ? json.messages : [];
|
|
10573
|
+
} catch {
|
|
10574
|
+
return [];
|
|
10575
|
+
}
|
|
10576
|
+
}
|
|
10577
|
+
const out = [];
|
|
10578
|
+
let raw;
|
|
10579
|
+
try {
|
|
10580
|
+
raw = readFileSync9(path, "utf-8");
|
|
10581
|
+
} catch {
|
|
10582
|
+
return out;
|
|
10583
|
+
}
|
|
10584
|
+
let isFirst = true;
|
|
10585
|
+
for (const line of raw.split("\n")) {
|
|
10586
|
+
if (!line.trim())
|
|
10587
|
+
continue;
|
|
10588
|
+
if (isFirst) {
|
|
10589
|
+
isFirst = false;
|
|
10590
|
+
continue;
|
|
10591
|
+
}
|
|
10592
|
+
if (line.length > MAX_EVENT_LINE_BYTES)
|
|
10593
|
+
continue;
|
|
10594
|
+
let obj;
|
|
10595
|
+
try {
|
|
10596
|
+
obj = JSON.parse(line);
|
|
10597
|
+
} catch {
|
|
10598
|
+
continue;
|
|
10599
|
+
}
|
|
10600
|
+
if (!obj || typeof obj !== "object")
|
|
10601
|
+
continue;
|
|
10602
|
+
if (!obj.type)
|
|
10603
|
+
continue;
|
|
10604
|
+
out.push(obj);
|
|
10605
|
+
}
|
|
10606
|
+
return out;
|
|
10607
|
+
}
|
|
10345
10608
|
function findCodexSessionFile(sessionId) {
|
|
10346
10609
|
for (const root of codexSessionDirs()) {
|
|
10347
10610
|
const found = findCodexSessionFileIn(root, sessionId);
|
|
@@ -10405,7 +10668,53 @@ function findCodexSessionFileIn(root, sessionId) {
|
|
|
10405
10668
|
}
|
|
10406
10669
|
return scanDir(root);
|
|
10407
10670
|
}
|
|
10408
|
-
|
|
10671
|
+
function liveScanModifiedFiles(sessionId) {
|
|
10672
|
+
const scan = liveScanSessionEdits(sessionId);
|
|
10673
|
+
const writeOps = /* @__PURE__ */ new Set(["edit", "write", "multi_edit", "notebook_edit"]);
|
|
10674
|
+
const files = /* @__PURE__ */ new Set();
|
|
10675
|
+
const reads = /* @__PURE__ */ new Set();
|
|
10676
|
+
for (const e of scan.edits) {
|
|
10677
|
+
if (writeOps.has(e.op))
|
|
10678
|
+
files.add(e.file);
|
|
10679
|
+
else if (e.op === "read")
|
|
10680
|
+
reads.add(e.file);
|
|
10681
|
+
}
|
|
10682
|
+
return {
|
|
10683
|
+
found: scan.found,
|
|
10684
|
+
files: [...files],
|
|
10685
|
+
reads: [...reads],
|
|
10686
|
+
edits: scan.edits,
|
|
10687
|
+
projectPath: scan.projectPath,
|
|
10688
|
+
tool: scan.tool
|
|
10689
|
+
};
|
|
10690
|
+
}
|
|
10691
|
+
function liveScanRecentEdits(opts) {
|
|
10692
|
+
const enabled = opts.tools ? new Set(opts.tools) : null;
|
|
10693
|
+
const needle = opts.pattern?.toLowerCase();
|
|
10694
|
+
const accept = (e) => {
|
|
10695
|
+
if (e.ts < opts.sinceMs)
|
|
10696
|
+
return false;
|
|
10697
|
+
if (needle && !e.file.toLowerCase().includes(needle))
|
|
10698
|
+
return false;
|
|
10699
|
+
return true;
|
|
10700
|
+
};
|
|
10701
|
+
const allEdits = [];
|
|
10702
|
+
for (const backend of listAvailableBackends()) {
|
|
10703
|
+
if (enabled && !enabled.has(backend.id))
|
|
10704
|
+
continue;
|
|
10705
|
+
const backendEdits = backend.collectRecentEdits({
|
|
10706
|
+
sinceMs: opts.sinceMs,
|
|
10707
|
+
projectFilter: opts.projectFilter,
|
|
10708
|
+
limitSessions: opts.limitSessions
|
|
10709
|
+
});
|
|
10710
|
+
for (const e of backendEdits)
|
|
10711
|
+
if (accept(e))
|
|
10712
|
+
allEdits.push(e);
|
|
10713
|
+
}
|
|
10714
|
+
allEdits.sort((a, b) => b.ts - a.ts);
|
|
10715
|
+
return allEdits;
|
|
10716
|
+
}
|
|
10717
|
+
var scanScopeDepth, indexCache, readScope, readScopeDepth, derivedScope, geminiProjectMapCache, geminiCache, MAX_EVENT_LINE_BYTES;
|
|
10409
10718
|
var init_live_session_scan = __esm({
|
|
10410
10719
|
"../engine/dist/core/live-session-scan.js"() {
|
|
10411
10720
|
"use strict";
|
|
@@ -10419,31 +10728,13 @@ var init_live_session_scan = __esm({
|
|
|
10419
10728
|
indexCache = null;
|
|
10420
10729
|
readScope = null;
|
|
10421
10730
|
readScopeDepth = 0;
|
|
10731
|
+
derivedScope = null;
|
|
10732
|
+
geminiProjectMapCache = null;
|
|
10733
|
+
geminiCache = null;
|
|
10422
10734
|
MAX_EVENT_LINE_BYTES = 8 * 1024 * 1024;
|
|
10423
10735
|
}
|
|
10424
10736
|
});
|
|
10425
10737
|
|
|
10426
|
-
// ../engine/dist/core/session-multi-tool.js
|
|
10427
|
-
function extractTurnsAny(sessionId, opts = {}) {
|
|
10428
|
-
const backend = getBackendForId(sessionId);
|
|
10429
|
-
if (!backend)
|
|
10430
|
-
return { sessionId, found: false, turns: [], startMs: 0, endMs: 0 };
|
|
10431
|
-
return backend.extractTurns(sessionId, opts);
|
|
10432
|
-
}
|
|
10433
|
-
function replaySessionAny(sessionId) {
|
|
10434
|
-
const backend = getBackendForId(sessionId);
|
|
10435
|
-
if (!backend)
|
|
10436
|
-
return { sessionId, found: false, projectPath: "", files: [], totalLinesAdded: 0, totalLinesRemoved: 0 };
|
|
10437
|
-
return backend.replay(sessionId);
|
|
10438
|
-
}
|
|
10439
|
-
var init_session_multi_tool = __esm({
|
|
10440
|
-
"../engine/dist/core/session-multi-tool.js"() {
|
|
10441
|
-
"use strict";
|
|
10442
|
-
init_tool_backend();
|
|
10443
|
-
init_backends();
|
|
10444
|
-
}
|
|
10445
|
-
});
|
|
10446
|
-
|
|
10447
10738
|
// src/redact-deep.ts
|
|
10448
10739
|
function redactDeep(v, count) {
|
|
10449
10740
|
if (typeof v === "string") return redactSecrets(v, { force: true, count });
|
|
@@ -10574,12 +10865,21 @@ function runTask(task) {
|
|
|
10574
10865
|
}
|
|
10575
10866
|
return { id: task.id, findings, redactions: count.redactions, rawB64, rawSize };
|
|
10576
10867
|
}
|
|
10868
|
+
var scanScopeOpen = false;
|
|
10869
|
+
async function holdScanScopeOpen() {
|
|
10870
|
+
if (scanScopeOpen) return;
|
|
10871
|
+
scanScopeOpen = true;
|
|
10872
|
+
const { withSessionScanScope: withSessionScanScope2 } = await Promise.resolve().then(() => (init_live_session_scan(), live_session_scan_exports));
|
|
10873
|
+
void withSessionScanScope2(() => new Promise(() => {
|
|
10874
|
+
}));
|
|
10875
|
+
}
|
|
10577
10876
|
async function runDerived(task) {
|
|
10578
10877
|
if (task.pack && task.packVersion !== installedPackVersion) {
|
|
10579
10878
|
installServerRulePack(task.pack);
|
|
10580
10879
|
installedPackVersion = task.packVersion;
|
|
10581
10880
|
}
|
|
10582
10881
|
const { collectDerivedRows: collectDerivedRows2 } = await Promise.resolve().then(() => (init_derived(), derived_exports));
|
|
10882
|
+
await holdScanScopeOpen();
|
|
10583
10883
|
const count = { redactions: 0 };
|
|
10584
10884
|
const rows = collectDerivedRows2(
|
|
10585
10885
|
{ prefixedId: task.prefixedId, toolId: task.toolId, mtime: task.mtime },
|
package/dist/scan-worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-worker.js","sourceRoot":"","sources":["../src/scan-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CA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7B,CAAC;QACD,OAAO;IACT,CAAC;IACD,IAAI,MAAkB,CAAC;IACvB,IAAI,CAAC;QACH,MAAM,GAAG,OAAO,CAAC,IAAgB,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,4EAA4E;QAC5E,kEAAkE;QAClE,MAAM,GAAG;YACP,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC;YACxC,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SACxD,CAAC;IACJ,CAAC;IACD,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC,CAAC,CAAC"}
|
package/dist/sync-client.d.ts
CHANGED
|
@@ -81,7 +81,20 @@ export interface TargetOutcome {
|
|
|
81
81
|
ok: boolean;
|
|
82
82
|
/** Why it failed, or why it was not attempted. Absent when ok. */
|
|
83
83
|
error?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Uploads this target ACCEPTED during the walk, whether or not the walk then
|
|
86
|
+
* failed.
|
|
87
|
+
*
|
|
88
|
+
* `ok` alone answers "did the whole walk finish", which is not the question a
|
|
89
|
+
* user asks. A walk that delivered 38 batches and then hit one fatal error
|
|
90
|
+
* was recorded as a plain failure, so `lastOkAt` never moved and doctor said
|
|
91
|
+
* "nothing has synced in 7h" about a machine whose rows were landing as it
|
|
92
|
+
* spoke. Data arriving and a walk completing are two different facts and the
|
|
93
|
+
* health file needs both.
|
|
94
|
+
*/
|
|
95
|
+
accepted?: number;
|
|
84
96
|
}
|
|
97
|
+
export declare function _acceptedUploads(url: string): number;
|
|
85
98
|
export declare function syncSessions(opts?: {
|
|
86
99
|
sinceMs?: number;
|
|
87
100
|
cleartextPaths?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-client.d.ts","sourceRoot":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;IACtE,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAO,GACjC,OAAO,CAAC,iBAAiB,GAAG,qBAAqB,GAAG,IAAI,CAAC,CAmX3D;AAeD;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,UAAU,EACf,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAO,GACnG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAA;CAAE,GAAG,IAAI,CAAC,CAkEnI;AAED;;;;;;GAMG;AACH;;;;;;;;GAQG;AACH;;;;yCAIyC;AACzC,MAAM,WAAW,QAAQ;IAAG,OAAO,EAAE,gBAAgB,GAAG,QAAQ,GAAG,WAAW,CAAA;CAAE;AAEhF,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,CAAC,IAAI,QAAQ,CAElE;AAED,wBAAsB,eAAe,CAAC,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAO,GAAG,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,CA4C/G"}
|
package/dist/sync-client.js
CHANGED
|
@@ -500,6 +500,15 @@ export function removeCredentials(serverUrl) {
|
|
|
500
500
|
/** Tokenize an absolute project path so the server can group by project
|
|
501
501
|
* without learning the developer's filesystem layout. */
|
|
502
502
|
const hashPath = (p) => (p ? 'p_' + createHash('sha256').update(p).digest('hex').slice(0, 12) : '');
|
|
503
|
+
/**
|
|
504
|
+
* Uploads accepted per target during the CURRENT walk.
|
|
505
|
+
*
|
|
506
|
+
* Module-level because the count is made deep inside the upload pool and read
|
|
507
|
+
* in the outer catch, where the thrown error is all that survives of a failed
|
|
508
|
+
* walk. Reset when a target's sync starts.
|
|
509
|
+
*/
|
|
510
|
+
const acceptedUploads = new Map();
|
|
511
|
+
export function _acceptedUploads(url) { return acceptedUploads.get(url) ?? 0; }
|
|
503
512
|
/** compute_cache kinds shipped to the server. Must stay in step with the
|
|
504
513
|
* kinds the server's conversation routes read (heavyCacheGet keys). */
|
|
505
514
|
const COMPUTE_KINDS = ['diff', 'outcome', 'commits', 'markers'];
|
|
@@ -555,10 +564,11 @@ export async function syncSessions(opts = {}) {
|
|
|
555
564
|
};
|
|
556
565
|
continue;
|
|
557
566
|
}
|
|
567
|
+
acceptedUploads.set(cred.serverUrl, 0);
|
|
558
568
|
try {
|
|
559
569
|
const r = await syncToTarget(cred, opts);
|
|
560
570
|
noteTargetSuccess(cred.serverUrl);
|
|
561
|
-
perTarget[cred.serverUrl] = { ok: true };
|
|
571
|
+
perTarget[cred.serverUrl] = { ok: true, accepted: acceptedUploads.get(cred.serverUrl) ?? 0 };
|
|
562
572
|
agg = agg ? {
|
|
563
573
|
uploaded: agg.uploaded + r.uploaded, skipped: agg.skipped + r.skipped, redactions: agg.redactions + r.redactions,
|
|
564
574
|
items: agg.items + r.items, links: agg.links + r.links, findings: agg.findings + r.findings,
|
|
@@ -569,7 +579,9 @@ export async function syncSessions(opts = {}) {
|
|
|
569
579
|
catch (e) {
|
|
570
580
|
const msg = e instanceof Error ? e.message : String(e);
|
|
571
581
|
errors.push(`${cred.serverUrl}: ${msg}`);
|
|
572
|
-
|
|
582
|
+
// What this target took before the walk died. Without it, a walk that
|
|
583
|
+
// delivered thousands of rows and then failed reads as "never synced".
|
|
584
|
+
perTarget[cred.serverUrl] = { ok: false, error: msg, accepted: acceptedUploads.get(cred.serverUrl) ?? 0 };
|
|
573
585
|
// Report the NEXT attempt in the same breath as the failure, so the log
|
|
574
586
|
// says what will happen rather than leaving the user to infer it.
|
|
575
587
|
const next = noteTargetFailure(cred.serverUrl, msg);
|
|
@@ -1069,7 +1081,22 @@ async function syncToTargetInScope(cred, opts = {}) {
|
|
|
1069
1081
|
// this politeness (you own the box) → higher cap, zero pacing. An explicit
|
|
1070
1082
|
// --throttle (opts.throttleMs>0) forces the old serial+sleep mode for a
|
|
1071
1083
|
// known-fragile server.
|
|
1072
|
-
|
|
1084
|
+
// BATCH SIZE IS A DEADLINE, NOT A MEMORY BUDGET.
|
|
1085
|
+
//
|
|
1086
|
+
// The server's work is proportional to what a batch contains, and a hosted
|
|
1087
|
+
// target sits behind a proxy that gives the origin a fixed window — Cloudflare
|
|
1088
|
+
// ends the request at 100s with a 524, whatever either end is doing. Measured
|
|
1089
|
+
// against the hosted service: a 4 MB batch took the origin ~125s. So every
|
|
1090
|
+
// full batch died, the client's own 90s ceiling fired first and called it a
|
|
1091
|
+
// failure, and the retry sent the SAME oversized payload into the same wall.
|
|
1092
|
+
// The server logged 200 at 125s, having done the work twice, for a batch the
|
|
1093
|
+
// client had already given up on.
|
|
1094
|
+
//
|
|
1095
|
+
// 1 MB lands near 30s against the same server, which leaves room for a slow
|
|
1096
|
+
// day without touching the proxy's limit. A local target has no proxy and is
|
|
1097
|
+
// your own box, so it keeps the larger batch.
|
|
1098
|
+
const MAX_BATCH_BYTES = Number(process.env.CHAT_RECALL_MAX_BATCH_BYTES)
|
|
1099
|
+
|| (isLocalHost(cred.serverUrl) ? 4 * 1024 * 1024 : 1024 * 1024);
|
|
1073
1100
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
1074
1101
|
const explicitThrottle = typeof opts.throttleMs === 'number' && opts.throttleMs > 0;
|
|
1075
1102
|
const throttleMs = explicitThrottle ? opts.throttleMs : 0;
|
|
@@ -1149,6 +1176,7 @@ async function syncToTargetInScope(cred, opts = {}) {
|
|
|
1149
1176
|
signal: ac.signal,
|
|
1150
1177
|
});
|
|
1151
1178
|
if (res.ok) {
|
|
1179
|
+
acceptedUploads.set(cred.serverUrl, (acceptedUploads.get(cred.serverUrl) ?? 0) + 1);
|
|
1152
1180
|
const body = await res.json().catch(() => ({}));
|
|
1153
1181
|
// The server owns the plan answer; the user's opt-out is checked
|
|
1154
1182
|
// separately and wins over it.
|
|
@@ -1224,7 +1252,13 @@ async function syncToTargetInScope(cred, opts = {}) {
|
|
|
1224
1252
|
// belongs — on the server that knows its own load.
|
|
1225
1253
|
const retryAfterS = Number(res.headers.get('retry-after'));
|
|
1226
1254
|
const waitMs = res.status === 429 && retryAfterS > 0 ? retryAfterS * 1000 : RETRY_DELAYS_MS[attempt];
|
|
1227
|
-
|
|
1255
|
+
// 524 is the proxy ending the request, not the server rejecting it: the
|
|
1256
|
+
// origin is still working and will finish. Retrying the same payload
|
|
1257
|
+
// cannot beat the same clock, so say what would.
|
|
1258
|
+
const why = res.status === 524
|
|
1259
|
+
? ` — the proxy cut the request at its time limit; the batch is too big for one request`
|
|
1260
|
+
: '';
|
|
1261
|
+
console.error(`[sync] HTTP ${res.status} from ${base}${why} — backing off ${Math.round(waitMs / 1000)}s (attempt ${attempt + 1})`);
|
|
1228
1262
|
await sleep(waitMs);
|
|
1229
1263
|
continue;
|
|
1230
1264
|
}
|