@adhdev/daemon-core 0.9.82-rc.332 → 0.9.82-rc.333
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/index.js +127 -86
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +125 -84
- package/dist/index.mjs.map +1 -1
- package/dist/system/load-better-sqlite3.d.ts +21 -0
- package/package.json +2 -2
- package/src/mesh/mesh-runtime-store.ts +2 -5
- package/src/providers/native-history/hermes-cli-transcript.ts +2 -2
- package/src/providers/spec/native-history-executor.ts +2 -2
- package/src/system/load-better-sqlite3.ts +68 -0
package/dist/index.mjs
CHANGED
|
@@ -311,10 +311,10 @@ function readInjected(value) {
|
|
|
311
311
|
}
|
|
312
312
|
function getDaemonBuildInfo() {
|
|
313
313
|
if (cached) return cached;
|
|
314
|
-
const commit = readInjected(true ? "
|
|
315
|
-
const commitShort = readInjected(true ? "
|
|
316
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
317
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
314
|
+
const commit = readInjected(true ? "5d9635b2a6476691469ecfe32b26a17e13484b2b" : void 0) ?? "unknown";
|
|
315
|
+
const commitShort = readInjected(true ? "5d9635b2" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
316
|
+
const version = readInjected(true ? "0.9.82-rc.333" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
317
|
+
const builtAt = readInjected(true ? "2026-06-20T02:23:56.856Z" : void 0);
|
|
318
318
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
319
319
|
return cached;
|
|
320
320
|
}
|
|
@@ -582,10 +582,10 @@ async function getGitRepoStatus(workspace, options = {}) {
|
|
|
582
582
|
} catch (error) {
|
|
583
583
|
const gitError = error instanceof GitCommandError ? error : new GitCommandError("git_command_failed", "Failed to read Git status", { cause: error });
|
|
584
584
|
if (isTransientGitFailure(gitError)) {
|
|
585
|
-
const
|
|
586
|
-
if (
|
|
585
|
+
const cached3 = lastKnownGoodStatus.get(workspace);
|
|
586
|
+
if (cached3) {
|
|
587
587
|
return {
|
|
588
|
-
...
|
|
588
|
+
...cached3,
|
|
589
589
|
lastCheckedAt,
|
|
590
590
|
upstreamStatus: "unavailable",
|
|
591
591
|
error: gitError.stderr || gitError.message,
|
|
@@ -708,9 +708,9 @@ function resolveChangeImpactConfigForRepo(repoRoot, options) {
|
|
|
708
708
|
return { config: null, sourceKey: "no-repo-root" };
|
|
709
709
|
}
|
|
710
710
|
const loaded = loadChangeImpactConfig(repoRoot);
|
|
711
|
-
const
|
|
712
|
-
if (
|
|
713
|
-
return { config:
|
|
711
|
+
const cached3 = changeImpactConfigCache.get(repoRoot);
|
|
712
|
+
if (cached3 && cached3.sourceKey === loaded.sourceKey) {
|
|
713
|
+
return { config: cached3.config, sourceKey: loaded.sourceKey };
|
|
714
714
|
}
|
|
715
715
|
const config = loaded.sourceType === "repo_file" ? loaded.config ?? null : null;
|
|
716
716
|
changeImpactConfigCache.set(repoRoot, { sourceKey: loaded.sourceKey, config });
|
|
@@ -2536,6 +2536,46 @@ Follow these recovery rules:
|
|
|
2536
2536
|
}
|
|
2537
2537
|
});
|
|
2538
2538
|
|
|
2539
|
+
// src/system/load-better-sqlite3.ts
|
|
2540
|
+
import { createRequire } from "module";
|
|
2541
|
+
function loadBetterSqlite3() {
|
|
2542
|
+
if (cached2) return cached2;
|
|
2543
|
+
const errors = [];
|
|
2544
|
+
if (typeof __require === "function") {
|
|
2545
|
+
try {
|
|
2546
|
+
cached2 = __require("better-sqlite3");
|
|
2547
|
+
return cached2;
|
|
2548
|
+
} catch (e) {
|
|
2549
|
+
errors.push(e);
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
try {
|
|
2553
|
+
const metaUrl = typeof import.meta?.url === "string" ? import.meta.url : void 0;
|
|
2554
|
+
if (metaUrl) {
|
|
2555
|
+
cached2 = createRequire(metaUrl)("better-sqlite3");
|
|
2556
|
+
return cached2;
|
|
2557
|
+
}
|
|
2558
|
+
} catch (e) {
|
|
2559
|
+
errors.push(e);
|
|
2560
|
+
}
|
|
2561
|
+
try {
|
|
2562
|
+
cached2 = createRequire(`${process.cwd()}/__adhdev_better_sqlite3_loader__.js`)(
|
|
2563
|
+
"better-sqlite3"
|
|
2564
|
+
);
|
|
2565
|
+
return cached2;
|
|
2566
|
+
} catch (e) {
|
|
2567
|
+
errors.push(e);
|
|
2568
|
+
}
|
|
2569
|
+
const detail = errors.map((e) => e instanceof Error ? e.message : String(e)).join("; ");
|
|
2570
|
+
throw new Error(`Failed to load better-sqlite3: ${detail}`);
|
|
2571
|
+
}
|
|
2572
|
+
var cached2;
|
|
2573
|
+
var init_load_better_sqlite3 = __esm({
|
|
2574
|
+
"src/system/load-better-sqlite3.ts"() {
|
|
2575
|
+
"use strict";
|
|
2576
|
+
}
|
|
2577
|
+
});
|
|
2578
|
+
|
|
2539
2579
|
// src/mesh/mesh-ledger.ts
|
|
2540
2580
|
var mesh_ledger_exports = {};
|
|
2541
2581
|
__export(mesh_ledger_exports, {
|
|
@@ -2969,8 +3009,8 @@ function readLedgerFromStore(meshId) {
|
|
|
2969
3009
|
}
|
|
2970
3010
|
function getCachedRawEntries(meshId) {
|
|
2971
3011
|
const now = Date.now();
|
|
2972
|
-
const
|
|
2973
|
-
if (
|
|
3012
|
+
const cached3 = ledgerReadCache.get(meshId);
|
|
3013
|
+
if (cached3 && now - cached3.cachedAt < LEDGER_CACHE_TTL_MS) return cached3.entries;
|
|
2974
3014
|
let entries;
|
|
2975
3015
|
try {
|
|
2976
3016
|
entries = readLedgerFromStore(meshId);
|
|
@@ -3849,11 +3889,9 @@ var init_mesh_work_queue = __esm({
|
|
|
3849
3889
|
// src/mesh/mesh-runtime-store.ts
|
|
3850
3890
|
import { existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync6, renameSync as renameSync2, statSync as statSync4 } from "fs";
|
|
3851
3891
|
import { dirname as dirname2, join as join8 } from "path";
|
|
3852
|
-
import { createRequire } from "module";
|
|
3853
3892
|
function loadDatabaseCtor() {
|
|
3854
3893
|
if (DatabaseCtor) return DatabaseCtor;
|
|
3855
|
-
|
|
3856
|
-
DatabaseCtor = runtimeRequire("better-sqlite3");
|
|
3894
|
+
DatabaseCtor = loadBetterSqlite3();
|
|
3857
3895
|
return DatabaseCtor;
|
|
3858
3896
|
}
|
|
3859
3897
|
function safeMeshId(meshId) {
|
|
@@ -3884,6 +3922,7 @@ var DatabaseCtor, MeshRuntimeStore;
|
|
|
3884
3922
|
var init_mesh_runtime_store = __esm({
|
|
3885
3923
|
"src/mesh/mesh-runtime-store.ts"() {
|
|
3886
3924
|
"use strict";
|
|
3925
|
+
init_load_better_sqlite3();
|
|
3887
3926
|
init_mesh_ledger();
|
|
3888
3927
|
init_mesh_work_queue();
|
|
3889
3928
|
MeshRuntimeStore = class _MeshRuntimeStore {
|
|
@@ -9415,8 +9454,8 @@ function resolveCoordinatorDrainDaemonIds(components) {
|
|
|
9415
9454
|
}
|
|
9416
9455
|
function getCachedMeshByWorkspace(workspace) {
|
|
9417
9456
|
const now = Date.now();
|
|
9418
|
-
const
|
|
9419
|
-
if (
|
|
9457
|
+
const cached3 = meshByWorkspaceCache.get(workspace);
|
|
9458
|
+
if (cached3 && now - cached3.cachedAt < MESH_WORKSPACE_CACHE_TTL_MS) return cached3.mesh;
|
|
9420
9459
|
const mesh = getMeshByRepo(workspace);
|
|
9421
9460
|
meshByWorkspaceCache.set(workspace, { mesh, cachedAt: now });
|
|
9422
9461
|
return mesh;
|
|
@@ -15260,10 +15299,10 @@ ${lastSnapshot}`;
|
|
|
15260
15299
|
return this.accumulatedRawBuffer.replace(/\x1B\][^\x07]*(?:\x07|\x1B\\)/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
|
|
15261
15300
|
}
|
|
15262
15301
|
getFreshParsedStatusCache() {
|
|
15263
|
-
const
|
|
15302
|
+
const cached3 = this.parsedStatusCache;
|
|
15264
15303
|
const accumulatedRawBufferKey = this.getAccumulatedRawBufferCacheKey();
|
|
15265
|
-
if (
|
|
15266
|
-
return
|
|
15304
|
+
if (cached3 && cached3.responseBuffer === this.responseBuffer && cached3.currentTurnScope === this.engine.currentTurnScope && cached3.recentOutputBuffer === this.recentOutputBuffer && cached3.accumulatedBuffer === this.accumulatedBuffer && cached3.accumulatedRawBufferKey === accumulatedRawBufferKey && cached3.screenText === this.lastScreenText && cached3.currentStatus === this.engine.currentStatus && cached3.activeModal === this.engine.activeModal && cached3.cliName === this.cliName) {
|
|
15305
|
+
return cached3.result;
|
|
15267
15306
|
}
|
|
15268
15307
|
return null;
|
|
15269
15308
|
}
|
|
@@ -15725,10 +15764,10 @@ ${lastSnapshot}`;
|
|
|
15725
15764
|
getScriptParsedStatus() {
|
|
15726
15765
|
const screenText = this.readTerminalScreenText();
|
|
15727
15766
|
const parseScreenText = this.getParseScreenText(screenText);
|
|
15728
|
-
const
|
|
15767
|
+
const cached3 = this.parsedStatusCache;
|
|
15729
15768
|
const accumulatedRawBufferKey = this.getAccumulatedRawBufferCacheKey();
|
|
15730
|
-
if (!this.providerOwnsTranscript() &&
|
|
15731
|
-
return
|
|
15769
|
+
if (!this.providerOwnsTranscript() && cached3 && cached3.responseBuffer === this.responseBuffer && cached3.currentTurnScope === this.engine.currentTurnScope && cached3.recentOutputBuffer === this.recentOutputBuffer && cached3.accumulatedBuffer === this.accumulatedBuffer && cached3.accumulatedRawBufferKey === accumulatedRawBufferKey && cached3.screenText === parseScreenText && cached3.currentStatus === this.engine.currentStatus && cached3.activeModal === this.engine.activeModal && cached3.cliName === this.cliName) {
|
|
15770
|
+
return cached3.result;
|
|
15732
15771
|
}
|
|
15733
15772
|
const parsed = this.runParseSession();
|
|
15734
15773
|
if (!parsed || !Array.isArray(parsed.messages)) {
|
|
@@ -22129,11 +22168,11 @@ var savedHistoryRollupInFlight = /* @__PURE__ */ new Set();
|
|
|
22129
22168
|
var BOUNDED_TAIL_CACHE_MAX_ENTRIES = 64;
|
|
22130
22169
|
var boundedTailReadCache = /* @__PURE__ */ new Map();
|
|
22131
22170
|
function readBoundedTailCache(key, signature) {
|
|
22132
|
-
const
|
|
22133
|
-
if (!
|
|
22171
|
+
const cached3 = boundedTailReadCache.get(key);
|
|
22172
|
+
if (!cached3 || cached3.signature !== signature) return null;
|
|
22134
22173
|
boundedTailReadCache.delete(key);
|
|
22135
|
-
boundedTailReadCache.set(key,
|
|
22136
|
-
return
|
|
22174
|
+
boundedTailReadCache.set(key, cached3);
|
|
22175
|
+
return cached3.result;
|
|
22137
22176
|
}
|
|
22138
22177
|
function writeBoundedTailCache(key, signature, result) {
|
|
22139
22178
|
boundedTailReadCache.delete(key);
|
|
@@ -22617,9 +22656,9 @@ function computeSavedHistorySessionSummaries(agentType, dir, files, fileSignatur
|
|
|
22617
22656
|
for (const file of files.slice().sort()) {
|
|
22618
22657
|
const filePath = path14.join(dir, file);
|
|
22619
22658
|
const signature = fileSignatures.get(file) || `${file}:missing`;
|
|
22620
|
-
const
|
|
22659
|
+
const cached3 = savedHistoryFileSummaryCache.get(filePath);
|
|
22621
22660
|
const persisted = persistedEntries.get(file);
|
|
22622
|
-
const reusableEntry =
|
|
22661
|
+
const reusableEntry = cached3?.signature === signature ? cached3 : persisted?.signature === signature ? persisted : null;
|
|
22623
22662
|
const fileSummary = reusableEntry?.summary || computeSavedHistoryFileSummary(dir, file);
|
|
22624
22663
|
const nextEntry = reusableEntry || {
|
|
22625
22664
|
signature,
|
|
@@ -23115,16 +23154,16 @@ function readFileTailLines(filePath, needed) {
|
|
|
23115
23154
|
incrementalTailCache.delete(filePath);
|
|
23116
23155
|
return { lines: [], coversWholeFile: true };
|
|
23117
23156
|
}
|
|
23118
|
-
const
|
|
23119
|
-
if (
|
|
23120
|
-
if (
|
|
23157
|
+
const cached3 = incrementalTailCache.get(filePath);
|
|
23158
|
+
if (cached3) {
|
|
23159
|
+
if (cached3.size === size && cached3.mtimeMs === mtimeMs) {
|
|
23121
23160
|
incrementalTailCache.delete(filePath);
|
|
23122
|
-
incrementalTailCache.set(filePath,
|
|
23123
|
-
if (
|
|
23124
|
-
return { lines:
|
|
23161
|
+
incrementalTailCache.set(filePath, cached3);
|
|
23162
|
+
if (cached3.coversWholeFile || cached3.lines.length >= needed) {
|
|
23163
|
+
return { lines: cached3.lines, coversWholeFile: cached3.coversWholeFile };
|
|
23125
23164
|
}
|
|
23126
|
-
} else if (size >
|
|
23127
|
-
const incremental = tryIncrementalTailGrowth(filePath,
|
|
23165
|
+
} else if (size > cached3.size) {
|
|
23166
|
+
const incremental = tryIncrementalTailGrowth(filePath, cached3, size, mtimeMs, needed);
|
|
23128
23167
|
if (incremental) return { lines: incremental.lines, coversWholeFile: incremental.coversWholeFile };
|
|
23129
23168
|
}
|
|
23130
23169
|
incrementalTailCache.delete(filePath);
|
|
@@ -23150,22 +23189,22 @@ function readFileTailLines(filePath, needed) {
|
|
|
23150
23189
|
storeIncrementalTailCache(filePath, result.size, result.mtimeMs, result.lines, result.coversWholeFile);
|
|
23151
23190
|
return { lines: result.lines, coversWholeFile: result.coversWholeFile };
|
|
23152
23191
|
}
|
|
23153
|
-
function tryIncrementalTailGrowth(filePath,
|
|
23192
|
+
function tryIncrementalTailGrowth(filePath, cached3, size, mtimeMs, needed) {
|
|
23154
23193
|
const fd = fs6.openSync(filePath, "r");
|
|
23155
23194
|
try {
|
|
23156
|
-
if (
|
|
23195
|
+
if (cached3.size > 0) {
|
|
23157
23196
|
const boundary = Buffer.alloc(1);
|
|
23158
|
-
fs6.readSync(fd, boundary, 0, 1,
|
|
23197
|
+
fs6.readSync(fd, boundary, 0, 1, cached3.size - 1);
|
|
23159
23198
|
if (boundary[0] !== 10) return null;
|
|
23160
23199
|
}
|
|
23161
|
-
const appendedLength = size -
|
|
23200
|
+
const appendedLength = size - cached3.size;
|
|
23162
23201
|
const appended = Buffer.alloc(appendedLength);
|
|
23163
|
-
fs6.readSync(fd, appended, 0, appendedLength,
|
|
23202
|
+
fs6.readSync(fd, appended, 0, appendedLength, cached3.size);
|
|
23164
23203
|
const newLines = appended.toString("utf-8").split("\n");
|
|
23165
23204
|
if (newLines.length && newLines[newLines.length - 1] === "") newLines.pop();
|
|
23166
|
-
const merged =
|
|
23205
|
+
const merged = cached3.lines.concat(newLines);
|
|
23167
23206
|
const trimmed = merged.length > TAIL_LINES_RETAINED ? merged.slice(merged.length - TAIL_LINES_RETAINED) : merged;
|
|
23168
|
-
const coversWholeFile =
|
|
23207
|
+
const coversWholeFile = cached3.coversWholeFile && trimmed.length === merged.length;
|
|
23169
23208
|
storeIncrementalTailCache(filePath, size, mtimeMs, trimmed, coversWholeFile);
|
|
23170
23209
|
if (coversWholeFile || trimmed.length >= needed) {
|
|
23171
23210
|
return { lines: trimmed, coversWholeFile };
|
|
@@ -23230,8 +23269,8 @@ function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, ex
|
|
|
23230
23269
|
const fileSignatures = buildSavedHistoryFileSignatureMap(dir, files);
|
|
23231
23270
|
const cacheKey = `${sanitized}\0${historySessionId || ""}\0${offset}\0${limit}\0${excludeRecentCount}\0${historyBehavior?.collapseConsecutiveAssistantTurns ? "1" : "0"}`;
|
|
23232
23271
|
const signature = buildSavedHistoryCacheSignature(files, fileSignatures);
|
|
23233
|
-
const
|
|
23234
|
-
if (
|
|
23272
|
+
const cached3 = readBoundedTailCache(cacheKey, signature);
|
|
23273
|
+
if (cached3) return cached3;
|
|
23235
23274
|
const numericLimit = Math.max(1, Number(limit));
|
|
23236
23275
|
const numericOffset = Math.max(0, Number(offset));
|
|
23237
23276
|
const numericExclude = Math.max(0, Number(excludeRecentCount));
|
|
@@ -23274,23 +23313,23 @@ function listSavedHistorySessions(agentType, options = {}, historyBehavior) {
|
|
|
23274
23313
|
savedHistorySessionCache.delete(sanitized);
|
|
23275
23314
|
return { sessions: [], hasMore: false };
|
|
23276
23315
|
}
|
|
23277
|
-
const
|
|
23316
|
+
const cached3 = savedHistorySessionCache.get(sanitized);
|
|
23278
23317
|
const offset = Math.max(0, options.offset || 0);
|
|
23279
23318
|
const limit = Math.max(1, options.limit || 30);
|
|
23280
23319
|
const indexSignature = buildSavedHistoryIndexFileSignature(dir);
|
|
23281
23320
|
let cacheWasInvalidated = false;
|
|
23282
|
-
if (
|
|
23283
|
-
const cacheLooksPersisted =
|
|
23284
|
-
const cacheStillValid = cacheLooksPersisted ?
|
|
23321
|
+
if (cached3) {
|
|
23322
|
+
const cacheLooksPersisted = cached3.signature.startsWith("index:");
|
|
23323
|
+
const cacheStillValid = cacheLooksPersisted ? cached3.signature === indexSignature : (() => {
|
|
23285
23324
|
const files2 = listHistoryFiles(dir);
|
|
23286
23325
|
const fileSignatures2 = buildSavedHistoryFileSignatureMap(dir, files2);
|
|
23287
|
-
return
|
|
23326
|
+
return cached3.signature === buildSavedHistoryCacheSignature(files2, fileSignatures2);
|
|
23288
23327
|
})();
|
|
23289
23328
|
if (cacheStillValid) {
|
|
23290
|
-
const sliced2 =
|
|
23329
|
+
const sliced2 = cached3.summaries.slice(offset, offset + limit);
|
|
23291
23330
|
return {
|
|
23292
23331
|
sessions: sliced2,
|
|
23293
|
-
hasMore:
|
|
23332
|
+
hasMore: cached3.summaries.length > offset + limit
|
|
23294
23333
|
};
|
|
23295
23334
|
}
|
|
23296
23335
|
cacheWasInvalidated = true;
|
|
@@ -32235,6 +32274,7 @@ function collectStableSizes(when, sizes) {
|
|
|
32235
32274
|
|
|
32236
32275
|
// src/providers/spec/native-history-executor.ts
|
|
32237
32276
|
init_logger();
|
|
32277
|
+
init_load_better_sqlite3();
|
|
32238
32278
|
import * as fs13 from "fs";
|
|
32239
32279
|
import * as os17 from "os";
|
|
32240
32280
|
import * as path22 from "path";
|
|
@@ -32362,7 +32402,7 @@ function executeSqlite(src, input) {
|
|
|
32362
32402
|
if (!resolved || !fs13.existsSync(resolved)) return null;
|
|
32363
32403
|
let Database;
|
|
32364
32404
|
try {
|
|
32365
|
-
Database =
|
|
32405
|
+
Database = loadBetterSqlite3();
|
|
32366
32406
|
} catch {
|
|
32367
32407
|
return null;
|
|
32368
32408
|
}
|
|
@@ -39188,6 +39228,7 @@ function readSession3(sessionPath, sessionId, workspace) {
|
|
|
39188
39228
|
}
|
|
39189
39229
|
|
|
39190
39230
|
// src/providers/native-history/hermes-cli-transcript.ts
|
|
39231
|
+
init_load_better_sqlite3();
|
|
39191
39232
|
import * as fs20 from "fs";
|
|
39192
39233
|
import * as path30 from "path";
|
|
39193
39234
|
import * as os21 from "os";
|
|
@@ -39203,7 +39244,7 @@ function statMtimeMs4(p) {
|
|
|
39203
39244
|
function openDb() {
|
|
39204
39245
|
if (!fs20.existsSync(HERMES_STATE_DB)) return null;
|
|
39205
39246
|
try {
|
|
39206
|
-
const Database =
|
|
39247
|
+
const Database = loadBetterSqlite3();
|
|
39207
39248
|
return new Database(HERMES_STATE_DB, { readonly: true, fileMustExist: true });
|
|
39208
39249
|
} catch {
|
|
39209
39250
|
return null;
|
|
@@ -40578,8 +40619,8 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
40578
40619
|
return null;
|
|
40579
40620
|
}
|
|
40580
40621
|
registerProviderScriptRootSafely(path33.dirname(path33.dirname(providerDir)));
|
|
40581
|
-
const
|
|
40582
|
-
if (
|
|
40622
|
+
const cached3 = this.scriptsCache.get(dir);
|
|
40623
|
+
if (cached3) return cached3;
|
|
40583
40624
|
const scriptsJs = path33.join(dir, "scripts.js");
|
|
40584
40625
|
if (fs22.existsSync(scriptsJs)) {
|
|
40585
40626
|
try {
|
|
@@ -43658,13 +43699,13 @@ function sanitizeInlineMesh(inlineMesh) {
|
|
|
43658
43699
|
nodes
|
|
43659
43700
|
};
|
|
43660
43701
|
}
|
|
43661
|
-
function reconcileInlineMeshCache(
|
|
43662
|
-
if (!
|
|
43663
|
-
if (!incoming || typeof incoming !== "object" || Array.isArray(incoming)) return
|
|
43664
|
-
const cachedNodes = Array.isArray(
|
|
43702
|
+
function reconcileInlineMeshCache(cached3, incoming) {
|
|
43703
|
+
if (!cached3 || typeof cached3 !== "object" || Array.isArray(cached3)) return incoming;
|
|
43704
|
+
if (!incoming || typeof incoming !== "object" || Array.isArray(incoming)) return cached3;
|
|
43705
|
+
const cachedNodes = Array.isArray(cached3.nodes) ? cached3.nodes : [];
|
|
43665
43706
|
const incomingNodes = Array.isArray(incoming.nodes) ? incoming.nodes : [];
|
|
43666
|
-
if (!cachedNodes.length || !incomingNodes.length) return { ...
|
|
43667
|
-
const cachedUpdatedAt = Date.parse(readStringValue(
|
|
43707
|
+
if (!cachedNodes.length || !incomingNodes.length) return { ...cached3, ...incoming };
|
|
43708
|
+
const cachedUpdatedAt = Date.parse(readStringValue(cached3.updatedAt, cached3.updated_at) || "");
|
|
43668
43709
|
const incomingUpdatedAt = Date.parse(readStringValue(incoming.updatedAt, incoming.updated_at) || "");
|
|
43669
43710
|
const preserveCachedMembership = Number.isFinite(cachedUpdatedAt) && (!Number.isFinite(incomingUpdatedAt) || cachedUpdatedAt > incomingUpdatedAt);
|
|
43670
43711
|
const cachedById = /* @__PURE__ */ new Map();
|
|
@@ -43693,7 +43734,7 @@ function reconcileInlineMeshCache(cached2, incoming) {
|
|
|
43693
43734
|
}
|
|
43694
43735
|
}
|
|
43695
43736
|
return {
|
|
43696
|
-
...
|
|
43737
|
+
...cached3,
|
|
43697
43738
|
...incoming,
|
|
43698
43739
|
nodes
|
|
43699
43740
|
};
|
|
@@ -44026,9 +44067,9 @@ var MeshGitProbeCache = class {
|
|
|
44026
44067
|
*/
|
|
44027
44068
|
async probe(daemonId, workspace, probe) {
|
|
44028
44069
|
const key = this.key(daemonId, workspace);
|
|
44029
|
-
const
|
|
44030
|
-
if (
|
|
44031
|
-
return
|
|
44070
|
+
const cached3 = this.recent.get(key);
|
|
44071
|
+
if (cached3 && this.now() - cached3.at < this.reuseMs) {
|
|
44072
|
+
return cached3.value;
|
|
44032
44073
|
}
|
|
44033
44074
|
const existing = this.inflight.get(key);
|
|
44034
44075
|
if (existing) return existing;
|
|
@@ -45676,13 +45717,13 @@ var DaemonCommandRouter = class {
|
|
|
45676
45717
|
};
|
|
45677
45718
|
}
|
|
45678
45719
|
getCachedAggregateMeshStatus(meshId, mesh, options) {
|
|
45679
|
-
const
|
|
45680
|
-
if (!
|
|
45681
|
-
if (
|
|
45682
|
-
let snapshot = this.cloneJsonValue(
|
|
45720
|
+
const cached3 = this.aggregateMeshStatusCache.get(meshId);
|
|
45721
|
+
if (!cached3?.snapshot || cached3.snapshot.success !== true || !Array.isArray(cached3.snapshot.nodes)) return null;
|
|
45722
|
+
if (cached3.queueRevision !== getMeshQueueRevision(meshId)) return null;
|
|
45723
|
+
let snapshot = this.cloneJsonValue(cached3.snapshot);
|
|
45683
45724
|
snapshot = this.hydrateCachedAggregateMeshStatusFromInline(snapshot, mesh, options);
|
|
45684
45725
|
if (shouldRefreshStalePendingAggregate(snapshot, options)) return null;
|
|
45685
|
-
const ageMs = Math.max(0, Date.now() -
|
|
45726
|
+
const ageMs = Math.max(0, Date.now() - cached3.builtAt);
|
|
45686
45727
|
const sourceOfTruth = snapshot.sourceOfTruth && typeof snapshot.sourceOfTruth === "object" ? snapshot.sourceOfTruth : {};
|
|
45687
45728
|
snapshot.sourceOfTruth = {
|
|
45688
45729
|
...sourceOfTruth,
|
|
@@ -45693,7 +45734,7 @@ var DaemonCommandRouter = class {
|
|
|
45693
45734
|
source: "memory",
|
|
45694
45735
|
refreshReason: "memory_cache_hit",
|
|
45695
45736
|
ageMs,
|
|
45696
|
-
cachedAt: new Date(
|
|
45737
|
+
cachedAt: new Date(cached3.builtAt).toISOString(),
|
|
45697
45738
|
returnedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
45698
45739
|
}
|
|
45699
45740
|
};
|
|
@@ -45740,9 +45781,9 @@ var DaemonCommandRouter = class {
|
|
|
45740
45781
|
meshId,
|
|
45741
45782
|
sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(inlineMesh))
|
|
45742
45783
|
);
|
|
45743
|
-
const
|
|
45744
|
-
if (
|
|
45745
|
-
const merged = reconcileInlineMeshCache(
|
|
45784
|
+
const cached3 = this.inlineMeshCache.get(meshId);
|
|
45785
|
+
if (cached3) {
|
|
45786
|
+
const merged = reconcileInlineMeshCache(cached3, sanitizedInlineMesh);
|
|
45746
45787
|
this.inlineMeshCache.set(meshId, merged);
|
|
45747
45788
|
return merged;
|
|
45748
45789
|
}
|
|
@@ -45752,17 +45793,17 @@ var DaemonCommandRouter = class {
|
|
|
45752
45793
|
async getMeshForCommand(meshId, inlineMesh, options) {
|
|
45753
45794
|
const preferInline = options?.preferInline === true;
|
|
45754
45795
|
if (preferInline) {
|
|
45755
|
-
const
|
|
45756
|
-
if (
|
|
45796
|
+
const cached4 = this.getCachedInlineMesh(meshId);
|
|
45797
|
+
if (cached4) {
|
|
45757
45798
|
if (inlineMeshCarriesTransientNodeTruth(inlineMesh)) {
|
|
45758
45799
|
const merged = reconcileInlineMeshCache(
|
|
45759
|
-
|
|
45800
|
+
cached4,
|
|
45760
45801
|
this.applyInlineMeshNodeTombstones(meshId, inlineMesh)
|
|
45761
45802
|
);
|
|
45762
45803
|
this.inlineMeshCache.set(meshId, sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(merged)));
|
|
45763
45804
|
return { mesh: merged, inline: true, source: "inline_cache" };
|
|
45764
45805
|
}
|
|
45765
|
-
return { mesh:
|
|
45806
|
+
return { mesh: cached4, inline: true, source: "inline_cache" };
|
|
45766
45807
|
}
|
|
45767
45808
|
if (inlineMeshCarriesTransientNodeTruth(inlineMesh)) {
|
|
45768
45809
|
this.warmInlineMeshCache(meshId, inlineMesh);
|
|
@@ -45775,8 +45816,8 @@ var DaemonCommandRouter = class {
|
|
|
45775
45816
|
if (mesh) return { mesh, inline: false, source: "local_config" };
|
|
45776
45817
|
} catch {
|
|
45777
45818
|
}
|
|
45778
|
-
const
|
|
45779
|
-
if (
|
|
45819
|
+
const cached3 = this.getCachedInlineMesh(meshId);
|
|
45820
|
+
if (cached3) return { mesh: cached3, inline: true, source: "inline_cache" };
|
|
45780
45821
|
const warmedInline = this.warmInlineMeshCache(meshId, inlineMesh);
|
|
45781
45822
|
return warmedInline ? { mesh: warmedInline, inline: true, source: "inline_bootstrap" } : null;
|
|
45782
45823
|
}
|
|
@@ -47206,8 +47247,8 @@ ${hintLines.join("\n")}` : "",
|
|
|
47206
47247
|
const repoRootBaseRef = /* @__PURE__ */ new Map();
|
|
47207
47248
|
const submodulePathsByRepoRoot = /* @__PURE__ */ new Map();
|
|
47208
47249
|
const resolveBaseRef = async (repoRoot) => {
|
|
47209
|
-
const
|
|
47210
|
-
if (
|
|
47250
|
+
const cached3 = repoRootBaseRef.get(repoRoot);
|
|
47251
|
+
if (cached3) return cached3;
|
|
47211
47252
|
let baseBranch = "main";
|
|
47212
47253
|
try {
|
|
47213
47254
|
const { stdout } = await execFileAsync4("git", ["branch", "--show-current"], { cwd: repoRoot, encoding: "utf8" });
|