codesesh 0.18.0 → 0.19.0
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/README.md +4 -2
- package/dist/{chunk-HIYT2ZJL.js → chunk-G2BTNW3C.js} +1678 -217
- package/dist/chunk-G2BTNW3C.js.map +1 -0
- package/dist/{chunk-DHNP33L4.js → chunk-KD3DGWZY.js} +2 -2
- package/dist/{dist-DMGLFBW6.js → dist-ALXOBKV2.js} +14 -2
- package/dist/index.js +168 -43
- package/dist/index.js.map +1 -1
- package/dist/scan-refresh-worker.js +243 -24
- package/dist/scan-refresh-worker.js.map +1 -1
- package/dist/search-index-worker.js +2 -2
- package/dist/smart-tag-worker.js +2 -2
- package/dist/web/assets/{AgentIcon-DcUJM198.js → AgentIcon-CEj7HO1m.js} +1 -1
- package/dist/web/assets/BookmarkButton-DLEnIyeE.js +1 -0
- package/dist/web/assets/{Dashboard-wjTLT17d.js → Dashboard-DUG0IFcy.js} +2 -2
- package/dist/web/assets/DialogTitle-Dv6DQPIb.js +1 -0
- package/dist/web/assets/Projects-BMaZc6J5.js +1 -0
- package/dist/web/assets/SearchFilterBar-iP6pzlZo.js +1 -0
- package/dist/web/assets/SearchResultsPanel-RuiLPkbP.js +1 -0
- package/dist/web/assets/{SessionDetail-CgR7ipmi.js → SessionDetail-De1Wl3mu.js} +35 -35
- package/dist/web/assets/{index-DuB6tGoe.css → index-B-CV7pFu.css} +1 -1
- package/dist/web/assets/index-CQI8F_8X.js +1930 -0
- package/dist/web/assets/session-indexes-BuxBafvh.js +4 -0
- package/dist/web/index.html +7 -8
- package/package.json +1 -1
- package/dist/chunk-HIYT2ZJL.js.map +0 -1
- package/dist/web/assets/BookmarkButton-CJjTjyae.js +0 -1
- package/dist/web/assets/DialogTitle-Bz0eXTGu.js +0 -1
- package/dist/web/assets/Projects-DBxubQuM.js +0 -1
- package/dist/web/assets/SearchFilterBar-BG9ah_Po.js +0 -1
- package/dist/web/assets/SearchResultsPanel-Clmf2xKw.js +0 -1
- package/dist/web/assets/index-DR07vs5V.js +0 -1890
- package/dist/web/assets/preload-helper-CmKXJxR3.js +0 -1
- package/dist/web/assets/session-indexes-EHJdYE4j.js +0 -4
- /package/dist/{chunk-DHNP33L4.js.map → chunk-KD3DGWZY.js.map} +0 -0
- /package/dist/{dist-DMGLFBW6.js.map → dist-ALXOBKV2.js.map} +0 -0
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
restrictExistingPrivateFiles,
|
|
5
5
|
restrictPrivateFile,
|
|
6
6
|
setCoreDiagnostics
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-G2BTNW3C.js";
|
|
8
8
|
|
|
9
9
|
// src/logging.ts
|
|
10
10
|
import { appendFileSync, existsSync, readdirSync, renameSync, statSync, unlinkSync } from "fs";
|
|
@@ -174,4 +174,4 @@ export {
|
|
|
174
174
|
appLogger,
|
|
175
175
|
logSearchIndexSync
|
|
176
176
|
};
|
|
177
|
-
//# sourceMappingURL=chunk-
|
|
177
|
+
//# sourceMappingURL=chunk-KD3DGWZY.js.map
|
|
@@ -20,16 +20,20 @@ import {
|
|
|
20
20
|
ensureSessionTagsSync,
|
|
21
21
|
executeSessionSearch,
|
|
22
22
|
filterSessionSearchCandidates,
|
|
23
|
+
filterSessionTreeByActivityWindow,
|
|
24
|
+
getAgentFullSyncCursor,
|
|
23
25
|
getAgentInfoMap,
|
|
24
26
|
getAgentLastFullSyncAt,
|
|
25
27
|
getCachePath2,
|
|
26
28
|
getPricingGeneration,
|
|
27
29
|
getRegisteredAgents,
|
|
30
|
+
getRootSessions,
|
|
28
31
|
getSessionActivityTime,
|
|
29
32
|
getSmartTagSourceTimestamp,
|
|
30
33
|
hasPendingPricing,
|
|
31
34
|
importBookmarks,
|
|
32
35
|
isAgentCacheInitialized,
|
|
36
|
+
isChildSession,
|
|
33
37
|
isProjectIdentityKind,
|
|
34
38
|
listBookmarks,
|
|
35
39
|
listCachedProjectGroups,
|
|
@@ -38,6 +42,8 @@ import {
|
|
|
38
42
|
loadCachedSessions,
|
|
39
43
|
markAgentCacheInitialized,
|
|
40
44
|
markAgentFullSyncCompleted,
|
|
45
|
+
markAgentFullSyncProgress,
|
|
46
|
+
markAgentFullSyncStarted,
|
|
41
47
|
matchesProjectIdentity,
|
|
42
48
|
matchesProjectScope,
|
|
43
49
|
materializeSessionDetailResponse,
|
|
@@ -59,7 +65,7 @@ import {
|
|
|
59
65
|
syncSessionSearchIndexChanges,
|
|
60
66
|
upsertBookmark,
|
|
61
67
|
upsertSessionAlias
|
|
62
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-G2BTNW3C.js";
|
|
63
69
|
export {
|
|
64
70
|
BaseAgent,
|
|
65
71
|
StateStorageUnavailableError as BookmarkStorageUnavailableError,
|
|
@@ -82,16 +88,20 @@ export {
|
|
|
82
88
|
ensureSessionTagsSync,
|
|
83
89
|
executeSessionSearch,
|
|
84
90
|
filterSessionSearchCandidates,
|
|
91
|
+
filterSessionTreeByActivityWindow,
|
|
92
|
+
getAgentFullSyncCursor,
|
|
85
93
|
getAgentInfoMap,
|
|
86
94
|
getAgentLastFullSyncAt,
|
|
87
95
|
getCachePath2 as getCachePath,
|
|
88
96
|
getPricingGeneration,
|
|
89
97
|
getRegisteredAgents,
|
|
98
|
+
getRootSessions,
|
|
90
99
|
getSessionActivityTime,
|
|
91
100
|
getSmartTagSourceTimestamp,
|
|
92
101
|
hasPendingPricing,
|
|
93
102
|
importBookmarks,
|
|
94
103
|
isAgentCacheInitialized,
|
|
104
|
+
isChildSession,
|
|
95
105
|
isProjectIdentityKind,
|
|
96
106
|
listBookmarks,
|
|
97
107
|
listCachedProjectGroups,
|
|
@@ -100,6 +110,8 @@ export {
|
|
|
100
110
|
loadCachedSessions,
|
|
101
111
|
markAgentCacheInitialized,
|
|
102
112
|
markAgentFullSyncCompleted,
|
|
113
|
+
markAgentFullSyncProgress,
|
|
114
|
+
markAgentFullSyncStarted,
|
|
103
115
|
matchesProjectIdentity,
|
|
104
116
|
matchesProjectScope,
|
|
105
117
|
materializeSessionDetailResponse,
|
|
@@ -122,4 +134,4 @@ export {
|
|
|
122
134
|
upsertBookmark,
|
|
123
135
|
upsertSessionAlias
|
|
124
136
|
};
|
|
125
|
-
//# sourceMappingURL=dist-
|
|
137
|
+
//# sourceMappingURL=dist-ALXOBKV2.js.map
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
appLogger,
|
|
4
4
|
logSearchIndexSync
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-KD3DGWZY.js";
|
|
6
6
|
import {
|
|
7
7
|
FileSystemSessionSource,
|
|
8
8
|
SessionAliasValidationError,
|
|
@@ -20,7 +20,9 @@ import {
|
|
|
20
20
|
deleteSessionAlias,
|
|
21
21
|
executeSessionSearch,
|
|
22
22
|
filterSessionSearchCandidates,
|
|
23
|
+
filterSessionTreeByActivityWindow,
|
|
23
24
|
formatSessionReference,
|
|
25
|
+
getAgentFullSyncCursor,
|
|
24
26
|
getAgentInfoMap,
|
|
25
27
|
getAgentLastFullSyncAt,
|
|
26
28
|
getSessionActivityTime,
|
|
@@ -33,7 +35,10 @@ import {
|
|
|
33
35
|
listFileActivity,
|
|
34
36
|
listSessionAliases,
|
|
35
37
|
loadCachedSessions,
|
|
38
|
+
markAgentCacheInitialized,
|
|
36
39
|
markAgentFullSyncCompleted,
|
|
40
|
+
markAgentFullSyncProgress,
|
|
41
|
+
markAgentFullSyncStarted,
|
|
37
42
|
matchesProjectIdentity,
|
|
38
43
|
matchesProjectScope,
|
|
39
44
|
materializeSessionDetailResponse,
|
|
@@ -44,6 +49,8 @@ import {
|
|
|
44
49
|
perf,
|
|
45
50
|
publishPendingPricing,
|
|
46
51
|
refreshPricingCache,
|
|
52
|
+
saveCachedSessionChanges,
|
|
53
|
+
saveCachedSessions,
|
|
47
54
|
scanSessions,
|
|
48
55
|
sessionRoutePath,
|
|
49
56
|
sessionSignature,
|
|
@@ -51,7 +58,7 @@ import {
|
|
|
51
58
|
startOfCalendarDay,
|
|
52
59
|
upsertBookmark,
|
|
53
60
|
upsertSessionAlias
|
|
54
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-G2BTNW3C.js";
|
|
55
62
|
|
|
56
63
|
// src/index.ts
|
|
57
64
|
import { defineCommand, runMain } from "citty";
|
|
@@ -206,13 +213,7 @@ function parseSearchOptions(c, defaults, projectIdentity) {
|
|
|
206
213
|
};
|
|
207
214
|
}
|
|
208
215
|
function filterSessionsByActivityWindow(sessions, from, to) {
|
|
209
|
-
|
|
210
|
-
return sessions.filter((session) => {
|
|
211
|
-
const activity = getSessionActivityTime(session);
|
|
212
|
-
if (from != null && activity < from) return false;
|
|
213
|
-
if (to != null && activity > to) return false;
|
|
214
|
-
return true;
|
|
215
|
-
});
|
|
216
|
+
return filterSessionTreeByActivityWindow(sessions, from, to);
|
|
216
217
|
}
|
|
217
218
|
|
|
218
219
|
// src/api/session-aliases-view.ts
|
|
@@ -1684,6 +1685,17 @@ var ScanStatusModel = class {
|
|
|
1684
1685
|
backfill: { active: false, pendingAgents: [], completedAgents: [], failedAgents: [] }
|
|
1685
1686
|
};
|
|
1686
1687
|
snapshot() {
|
|
1688
|
+
const backfill = {
|
|
1689
|
+
...this.status.backfill,
|
|
1690
|
+
pendingAgents: [...this.status.backfill.pendingAgents],
|
|
1691
|
+
completedAgents: [...this.status.backfill.completedAgents],
|
|
1692
|
+
failedAgents: [...this.status.backfill.failedAgents]
|
|
1693
|
+
};
|
|
1694
|
+
if (this.status.backfill.progress) {
|
|
1695
|
+
backfill.progress = { ...this.status.backfill.progress };
|
|
1696
|
+
} else {
|
|
1697
|
+
delete backfill.progress;
|
|
1698
|
+
}
|
|
1687
1699
|
return {
|
|
1688
1700
|
type: "scan-status",
|
|
1689
1701
|
...this.status,
|
|
@@ -1696,12 +1708,7 @@ var ScanStatusModel = class {
|
|
|
1696
1708
|
{ ...status }
|
|
1697
1709
|
])
|
|
1698
1710
|
),
|
|
1699
|
-
backfill
|
|
1700
|
-
...this.status.backfill,
|
|
1701
|
-
pendingAgents: [...this.status.backfill.pendingAgents],
|
|
1702
|
-
completedAgents: [...this.status.backfill.completedAgents],
|
|
1703
|
-
failedAgents: [...this.status.backfill.failedAgents]
|
|
1704
|
-
}
|
|
1711
|
+
backfill
|
|
1705
1712
|
};
|
|
1706
1713
|
}
|
|
1707
1714
|
startBatch(agentNames, phase, sessionCounts) {
|
|
@@ -1771,26 +1778,34 @@ var ScanStatusModel = class {
|
|
|
1771
1778
|
}
|
|
1772
1779
|
updateAgent(agentName, progress) {
|
|
1773
1780
|
const status = this.status.agentStatuses[agentName];
|
|
1774
|
-
if (!status || status.status !== "
|
|
1781
|
+
if (!status || status.status === "pending" || status.status === "complete" || status.status === "indexing" && progress.phase !== "finalizing") {
|
|
1782
|
+
return null;
|
|
1783
|
+
}
|
|
1775
1784
|
const now = Date.now();
|
|
1785
|
+
const nextStatus = progress.phase === "finalizing" ? "finalizing" : "scanning";
|
|
1786
|
+
const agentStatuses = {
|
|
1787
|
+
...this.status.agentStatuses,
|
|
1788
|
+
[agentName]: {
|
|
1789
|
+
...status,
|
|
1790
|
+
status: nextStatus,
|
|
1791
|
+
total: progress.total ?? status.total,
|
|
1792
|
+
processed: progress.processed ?? status.processed,
|
|
1793
|
+
sessions: progress.sessions ?? status.sessions,
|
|
1794
|
+
updatedAt: now
|
|
1795
|
+
}
|
|
1796
|
+
};
|
|
1776
1797
|
return this.set({
|
|
1777
1798
|
...this.status,
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
[agentName]: {
|
|
1781
|
-
...status,
|
|
1782
|
-
total: progress.total ?? status.total,
|
|
1783
|
-
processed: progress.processed ?? status.processed,
|
|
1784
|
-
sessions: progress.sessions ?? status.sessions,
|
|
1785
|
-
updatedAt: now
|
|
1786
|
-
}
|
|
1787
|
-
},
|
|
1799
|
+
phase: this.activePhase(this.status.pendingAgents, this.status.scanningAgents, agentStatuses),
|
|
1800
|
+
agentStatuses,
|
|
1788
1801
|
updatedAt: now
|
|
1789
1802
|
});
|
|
1790
1803
|
}
|
|
1791
1804
|
indexAgent(agentName) {
|
|
1792
1805
|
const status = this.status.agentStatuses[agentName];
|
|
1793
|
-
if (!this.status.active || !status || status.status !== "scanning")
|
|
1806
|
+
if (!this.status.active || !status || status.status !== "scanning" && status.status !== "finalizing") {
|
|
1807
|
+
return null;
|
|
1808
|
+
}
|
|
1794
1809
|
const now = Date.now();
|
|
1795
1810
|
const agentStatuses = {
|
|
1796
1811
|
...this.status.agentStatuses,
|
|
@@ -1862,7 +1877,10 @@ var ScanStatusModel = class {
|
|
|
1862
1877
|
});
|
|
1863
1878
|
}
|
|
1864
1879
|
activePhase(pendingAgents, scanningAgents, agentStatuses) {
|
|
1865
|
-
if (pendingAgents.length === 0 && scanningAgents.length > 0 && scanningAgents.every((agentName) =>
|
|
1880
|
+
if (pendingAgents.length === 0 && scanningAgents.length > 0 && scanningAgents.every((agentName) => {
|
|
1881
|
+
const status = agentStatuses[agentName]?.status;
|
|
1882
|
+
return status === "finalizing" || status === "indexing";
|
|
1883
|
+
})) {
|
|
1866
1884
|
return "indexing";
|
|
1867
1885
|
}
|
|
1868
1886
|
return this.status.phase === "initializing" ? "initializing" : "scanning";
|
|
@@ -1878,6 +1896,7 @@ var REFRESH_DEBOUNCE_MS = 200;
|
|
|
1878
1896
|
var EMPTY_AGENT_REFRESH_DEBOUNCE_MS = 3e4;
|
|
1879
1897
|
var SEARCH_INDEX_BULK_PENDING_PATH_THRESHOLD = 100;
|
|
1880
1898
|
var BACKFILL_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
1899
|
+
var CACHE_TRUNCATION_COVERAGE = 0.5;
|
|
1881
1900
|
function buildPersistenceDiff(previousSessions, nextSessions, candidateChangedIds = []) {
|
|
1882
1901
|
const { changes, removedSessionIds } = computeSessionDiff(
|
|
1883
1902
|
previousSessions,
|
|
@@ -1901,6 +1920,8 @@ var AgentSyncEngine = class {
|
|
|
1901
1920
|
sessionIndex = new LiveSessionIndex();
|
|
1902
1921
|
backfillQueue = [];
|
|
1903
1922
|
currentBackfillAgent;
|
|
1923
|
+
currentBackfillProgress;
|
|
1924
|
+
cacheIntegrityCheckedAgents = /* @__PURE__ */ new Set();
|
|
1904
1925
|
completedBackfillAgents = [];
|
|
1905
1926
|
failedBackfillAgents = [];
|
|
1906
1927
|
sessionsChangedListeners = /* @__PURE__ */ new Set();
|
|
@@ -1980,6 +2001,8 @@ var AgentSyncEngine = class {
|
|
|
1980
2001
|
}
|
|
1981
2002
|
this.backfillQueue.length = 0;
|
|
1982
2003
|
this.currentBackfillAgent = void 0;
|
|
2004
|
+
this.currentBackfillProgress = void 0;
|
|
2005
|
+
this.cacheIntegrityCheckedAgents.clear();
|
|
1983
2006
|
const searchIndexSnapshot = this.searchIndexJobs.snapshot();
|
|
1984
2007
|
appLogger.info("search_index.shutdown.started", {
|
|
1985
2008
|
active_batch_id: searchIndexSnapshot.activeBatchId,
|
|
@@ -2012,6 +2035,16 @@ var AgentSyncEngine = class {
|
|
|
2012
2035
|
);
|
|
2013
2036
|
}
|
|
2014
2037
|
updateAgentScanProgress(agentName, progress) {
|
|
2038
|
+
if (this.currentBackfillAgent === agentName) {
|
|
2039
|
+
this.currentBackfillProgress = {
|
|
2040
|
+
phase: progress.phase,
|
|
2041
|
+
total: progress.total,
|
|
2042
|
+
processed: progress.processed,
|
|
2043
|
+
sessions: progress.sessions
|
|
2044
|
+
};
|
|
2045
|
+
this.publishBackfillStatus();
|
|
2046
|
+
return;
|
|
2047
|
+
}
|
|
2015
2048
|
this.publishStatus(this.scanStatus.updateAgent(agentName, progress));
|
|
2016
2049
|
}
|
|
2017
2050
|
beginAgentIndexing(agentName) {
|
|
@@ -2157,7 +2190,9 @@ var AgentSyncEngine = class {
|
|
|
2157
2190
|
async initializeAgent(agent, previousSessions) {
|
|
2158
2191
|
this.setScanPhase("initializing");
|
|
2159
2192
|
const scanStartedAt = performance.now();
|
|
2160
|
-
const result = await this.runWorker(agent, previousSessions, null, this.startupScanOptions()
|
|
2193
|
+
const result = await this.runWorker(agent, previousSessions, null, this.startupScanOptions(), {
|
|
2194
|
+
checkpoint: true
|
|
2195
|
+
});
|
|
2161
2196
|
agent.setSessionMetaMap(new Map(Object.entries(result.meta)));
|
|
2162
2197
|
const sessions = attachMissingProjectIdentities(result.sessions);
|
|
2163
2198
|
this.lastRefreshAtByAgent.set(agent.name, Date.now());
|
|
@@ -2202,7 +2237,7 @@ var AgentSyncEngine = class {
|
|
|
2202
2237
|
const preciseChangedIds = checkResult.changedIds ?? null;
|
|
2203
2238
|
const scanStartedAt = performance.now();
|
|
2204
2239
|
if (preciseChangedIds === null) {
|
|
2205
|
-
const result = await this.runWorker(agent, baseline, null, {});
|
|
2240
|
+
const result = await this.runWorker(agent, baseline, null, {}, { checkpoint: true });
|
|
2206
2241
|
agent.setSessionMetaMap(new Map(Object.entries(result.meta)));
|
|
2207
2242
|
const sessions2 = attachMissingProjectIdentities(result.sessions);
|
|
2208
2243
|
return this.refreshStrategyResult(sessions2, {
|
|
@@ -2223,7 +2258,7 @@ var AgentSyncEngine = class {
|
|
|
2223
2258
|
}
|
|
2224
2259
|
async scanAgentFully(agent, previousSessions) {
|
|
2225
2260
|
const scanStartedAt = performance.now();
|
|
2226
|
-
const result = await this.runWorker(agent, previousSessions, null, {});
|
|
2261
|
+
const result = await this.runWorker(agent, previousSessions, null, {}, { checkpoint: true });
|
|
2227
2262
|
agent.setSessionMetaMap(new Map(Object.entries(result.meta)));
|
|
2228
2263
|
const sessions = attachMissingProjectIdentities(result.sessions);
|
|
2229
2264
|
this.lastRefreshAtByAgent.set(agent.name, Date.now());
|
|
@@ -2250,8 +2285,63 @@ var AgentSyncEngine = class {
|
|
|
2250
2285
|
changedIds,
|
|
2251
2286
|
scanOptions,
|
|
2252
2287
|
sourceSync: workerOptions.sourceSync,
|
|
2288
|
+
backfill: workerOptions.backfill,
|
|
2289
|
+
backfillCursor: workerOptions.backfillCursor,
|
|
2290
|
+
checkpoint: workerOptions.checkpoint,
|
|
2253
2291
|
meta: workerOptions.meta ?? buildAgentCacheMeta(agent),
|
|
2254
|
-
onProgress: (progress) => this.updateAgentScanProgress(agent.name, progress)
|
|
2292
|
+
onProgress: (progress) => this.updateAgentScanProgress(agent.name, progress),
|
|
2293
|
+
onCheckpoint: (checkpoint) => this.handleWorkerCheckpoint(agent, checkpoint)
|
|
2294
|
+
});
|
|
2295
|
+
}
|
|
2296
|
+
handleWorkerCheckpoint(agent, checkpoint) {
|
|
2297
|
+
if (this.isShuttingDown) return;
|
|
2298
|
+
if (checkpoint.stage === "scanned") {
|
|
2299
|
+
let persisted2 = false;
|
|
2300
|
+
try {
|
|
2301
|
+
persisted2 = saveCachedSessions(agent.name, checkpoint.sessions, checkpoint.meta);
|
|
2302
|
+
if (persisted2) markAgentCacheInitialized(agent.name);
|
|
2303
|
+
} catch (error) {
|
|
2304
|
+
appLogger.error("scan.checkpoint.failed", {
|
|
2305
|
+
agent: agent.name,
|
|
2306
|
+
stage: checkpoint.stage,
|
|
2307
|
+
error
|
|
2308
|
+
});
|
|
2309
|
+
}
|
|
2310
|
+
agent.setSessionMetaMap(new Map(Object.entries(checkpoint.meta)));
|
|
2311
|
+
const event = this.sessionIndex.commitAgentSessions(agent.name, checkpoint.sessions);
|
|
2312
|
+
this.emitSessionsChanged({
|
|
2313
|
+
agentName: agent.name,
|
|
2314
|
+
sessions: this.sessionIndex.snapshot().byAgent[agent.name] ?? [],
|
|
2315
|
+
event
|
|
2316
|
+
});
|
|
2317
|
+
appLogger.info("scan.checkpoint.persisted", {
|
|
2318
|
+
agent: agent.name,
|
|
2319
|
+
stage: checkpoint.stage,
|
|
2320
|
+
sessions: checkpoint.sessions.length,
|
|
2321
|
+
persisted: persisted2
|
|
2322
|
+
});
|
|
2323
|
+
return;
|
|
2324
|
+
}
|
|
2325
|
+
let persisted = false;
|
|
2326
|
+
try {
|
|
2327
|
+
persisted = saveCachedSessionChanges(agent.name, checkpoint.changes, [], checkpoint.meta);
|
|
2328
|
+
} catch (error) {
|
|
2329
|
+
appLogger.error("scan.checkpoint.failed", {
|
|
2330
|
+
agent: agent.name,
|
|
2331
|
+
stage: checkpoint.stage,
|
|
2332
|
+
sessions: checkpoint.changes.length,
|
|
2333
|
+
error
|
|
2334
|
+
});
|
|
2335
|
+
}
|
|
2336
|
+
if (persisted && checkpoint.backfillCursor) {
|
|
2337
|
+
markAgentFullSyncProgress(agent.name, checkpoint.backfillCursor);
|
|
2338
|
+
}
|
|
2339
|
+
appLogger.debug("scan.checkpoint.persisted", {
|
|
2340
|
+
agent: agent.name,
|
|
2341
|
+
stage: checkpoint.stage,
|
|
2342
|
+
sessions: checkpoint.changes.length,
|
|
2343
|
+
backfill_cursor: checkpoint.backfillCursor,
|
|
2344
|
+
persisted
|
|
2255
2345
|
});
|
|
2256
2346
|
}
|
|
2257
2347
|
needsBackfill(agent) {
|
|
@@ -2259,7 +2349,23 @@ var AgentSyncEngine = class {
|
|
|
2259
2349
|
if (startupScanOptions.from == null && startupScanOptions.to == null) return false;
|
|
2260
2350
|
if (!agent.isAvailable()) return false;
|
|
2261
2351
|
const lastSyncAt = getAgentLastFullSyncAt(agent.name);
|
|
2262
|
-
|
|
2352
|
+
if (lastSyncAt == null || Date.now() - lastSyncAt > BACKFILL_INTERVAL_MS) return true;
|
|
2353
|
+
if (!(agent instanceof FileSystemSessionSource)) return false;
|
|
2354
|
+
if (this.cacheIntegrityCheckedAgents.has(agent.name)) return false;
|
|
2355
|
+
const cached = loadCachedSessions(agent.name);
|
|
2356
|
+
const sourceCount = agent.listSessionSources().length;
|
|
2357
|
+
const cachedCount = cached?.sessions.length ?? 0;
|
|
2358
|
+
this.cacheIntegrityCheckedAgents.add(agent.name);
|
|
2359
|
+
if (sourceCount > 0 && cachedCount / sourceCount < CACHE_TRUNCATION_COVERAGE) {
|
|
2360
|
+
appLogger.warn("scan.backfill.cache_truncated", {
|
|
2361
|
+
agent: agent.name,
|
|
2362
|
+
cached_sessions: cachedCount,
|
|
2363
|
+
source_files: sourceCount,
|
|
2364
|
+
last_sync_at: lastSyncAt
|
|
2365
|
+
});
|
|
2366
|
+
return true;
|
|
2367
|
+
}
|
|
2368
|
+
return false;
|
|
2263
2369
|
}
|
|
2264
2370
|
enqueueBackfill(agentName) {
|
|
2265
2371
|
if (this.isShuttingDown || this.currentBackfillAgent === agentName || this.backfillQueue.includes(agentName)) {
|
|
@@ -2274,10 +2380,12 @@ var AgentSyncEngine = class {
|
|
|
2274
2380
|
const agentName = this.backfillQueue.shift();
|
|
2275
2381
|
if (!agentName) return;
|
|
2276
2382
|
this.currentBackfillAgent = agentName;
|
|
2383
|
+
this.currentBackfillProgress = void 0;
|
|
2277
2384
|
this.publishBackfillStatus();
|
|
2278
2385
|
void this.runBackfill(agentName).then((result) => {
|
|
2279
2386
|
if (this.isShuttingDown) return;
|
|
2280
2387
|
this.currentBackfillAgent = void 0;
|
|
2388
|
+
this.currentBackfillProgress = void 0;
|
|
2281
2389
|
if (result === "committed") {
|
|
2282
2390
|
if (!this.completedBackfillAgents.includes(agentName)) {
|
|
2283
2391
|
this.completedBackfillAgents.push(agentName);
|
|
@@ -2287,6 +2395,7 @@ var AgentSyncEngine = class {
|
|
|
2287
2395
|
);
|
|
2288
2396
|
} else if (!this.failedBackfillAgents.includes(agentName)) {
|
|
2289
2397
|
this.failedBackfillAgents.push(agentName);
|
|
2398
|
+
this.cacheIntegrityCheckedAgents.delete(agentName);
|
|
2290
2399
|
}
|
|
2291
2400
|
this.publishBackfillStatus();
|
|
2292
2401
|
this.pumpBackfillQueue();
|
|
@@ -2303,8 +2412,10 @@ var AgentSyncEngine = class {
|
|
|
2303
2412
|
const cached = loadCachedSessions(agentName);
|
|
2304
2413
|
const baseline = cached?.sessions ?? snapshot.byAgent[agentName] ?? [];
|
|
2305
2414
|
const meta = cached?.meta ?? buildAgentCacheMeta(agent);
|
|
2415
|
+
const backfillCursor = getAgentFullSyncCursor(agentName);
|
|
2306
2416
|
if (cached) restoreAgentCacheMeta(agent, cached);
|
|
2307
2417
|
try {
|
|
2418
|
+
markAgentFullSyncStarted(agentName);
|
|
2308
2419
|
const result = await this.runWorker(
|
|
2309
2420
|
agent,
|
|
2310
2421
|
baseline,
|
|
@@ -2312,11 +2423,16 @@ var AgentSyncEngine = class {
|
|
|
2312
2423
|
{},
|
|
2313
2424
|
{
|
|
2314
2425
|
sourceSync: agent instanceof FileSystemSessionSource,
|
|
2315
|
-
|
|
2426
|
+
backfill: true,
|
|
2427
|
+
backfillCursor,
|
|
2428
|
+
meta,
|
|
2429
|
+
checkpoint: true
|
|
2316
2430
|
}
|
|
2317
2431
|
);
|
|
2318
2432
|
agent.setSessionMetaMap(new Map(Object.entries(result.meta)));
|
|
2319
2433
|
const fullSessions = attachMissingProjectIdentities(result.sessions);
|
|
2434
|
+
this.currentBackfillProgress = { phase: "indexing", sessions: fullSessions.length };
|
|
2435
|
+
this.publishBackfillStatus();
|
|
2320
2436
|
await this.commitSessionPublication({
|
|
2321
2437
|
context: "scan.backfill",
|
|
2322
2438
|
agentName,
|
|
@@ -2350,6 +2466,7 @@ var AgentSyncEngine = class {
|
|
|
2350
2466
|
active: this.currentBackfillAgent != null || this.backfillQueue.length > 0,
|
|
2351
2467
|
pendingAgents: [...this.backfillQueue],
|
|
2352
2468
|
currentAgent: this.currentBackfillAgent,
|
|
2469
|
+
progress: this.currentBackfillProgress,
|
|
2353
2470
|
completedAgents: [...this.completedBackfillAgents],
|
|
2354
2471
|
failedAgents: [...this.failedBackfillAgents]
|
|
2355
2472
|
};
|
|
@@ -2783,6 +2900,9 @@ var ThreadWorkerRunner = class {
|
|
|
2783
2900
|
previousSessions: payload.previousSessions,
|
|
2784
2901
|
changedIds: payload.changedIds,
|
|
2785
2902
|
sourceSync: payload.sourceSync,
|
|
2903
|
+
backfill: payload.backfill,
|
|
2904
|
+
backfillCursor: payload.backfillCursor,
|
|
2905
|
+
checkpoint: payload.checkpoint,
|
|
2786
2906
|
scanOptions: payload.scanOptions,
|
|
2787
2907
|
meta: payload.meta
|
|
2788
2908
|
};
|
|
@@ -2801,7 +2921,8 @@ var ThreadWorkerRunner = class {
|
|
|
2801
2921
|
resolve: resolve4,
|
|
2802
2922
|
reject,
|
|
2803
2923
|
payload,
|
|
2804
|
-
onProgress: payload.onProgress
|
|
2924
|
+
onProgress: payload.onProgress,
|
|
2925
|
+
onCheckpoint: payload.onCheckpoint
|
|
2805
2926
|
});
|
|
2806
2927
|
if (!isNewWorker) {
|
|
2807
2928
|
try {
|
|
@@ -2853,6 +2974,10 @@ var ThreadWorkerRunner = class {
|
|
|
2853
2974
|
pending.onProgress?.(message.progress);
|
|
2854
2975
|
return;
|
|
2855
2976
|
}
|
|
2977
|
+
if (message.type === "checkpoint") {
|
|
2978
|
+
pending.onCheckpoint?.(message.checkpoint);
|
|
2979
|
+
return;
|
|
2980
|
+
}
|
|
2856
2981
|
slot.pending.delete(message.requestId);
|
|
2857
2982
|
if (message.type === "error") {
|
|
2858
2983
|
pending.reject(new Error(message.error));
|
|
@@ -3068,14 +3193,14 @@ function printScanResults(agents) {
|
|
|
3068
3193
|
|
|
3069
3194
|
// src/session-index-output.ts
|
|
3070
3195
|
function buildSessionIndexOutput(snapshot, window = {}) {
|
|
3071
|
-
const sessions = snapshot.sessions.
|
|
3072
|
-
const activity = session.time_updated ?? session.time_created;
|
|
3073
|
-
if (window.from != null && activity < window.from) return false;
|
|
3074
|
-
if (window.to != null && activity > window.to) return false;
|
|
3075
|
-
return true;
|
|
3076
|
-
});
|
|
3196
|
+
const sessions = filterSessionTreeByActivityWindow(snapshot.sessions, window.from, window.to);
|
|
3077
3197
|
const agents = getAgentInfoMap(
|
|
3078
|
-
Object.fromEntries(
|
|
3198
|
+
Object.fromEntries(
|
|
3199
|
+
Object.entries(snapshot.byAgent).map(([name, list]) => [
|
|
3200
|
+
name,
|
|
3201
|
+
filterSessionTreeByActivityWindow(list, window.from, window.to).length
|
|
3202
|
+
])
|
|
3203
|
+
)
|
|
3079
3204
|
).map(({ name, displayName, count }) => ({
|
|
3080
3205
|
name,
|
|
3081
3206
|
displayName,
|
|
@@ -3293,7 +3418,7 @@ var main = defineCommand({
|
|
|
3293
3418
|
log_path: appLogger.getLogPath()
|
|
3294
3419
|
});
|
|
3295
3420
|
if (clearCache) {
|
|
3296
|
-
const { clearCache: clear } = await import("./dist-
|
|
3421
|
+
const { clearCache: clear } = await import("./dist-ALXOBKV2.js");
|
|
3297
3422
|
clear();
|
|
3298
3423
|
appLogger.info("cache.clear");
|
|
3299
3424
|
console.log("Cache cleared.");
|