@adhdev/daemon-standalone 0.9.82-rc.331 → 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 +188 -89
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/index-BKSjQ-U-.js +113 -0
- package/public/index.html +1 -1
- package/vendor/mcp-server/index.js +10 -5
- package/vendor/mcp-server/index.js.map +1 -1
package/dist/index.js
CHANGED
|
@@ -30036,10 +30036,10 @@ var require_dist3 = __commonJS({
|
|
|
30036
30036
|
}
|
|
30037
30037
|
function getDaemonBuildInfo() {
|
|
30038
30038
|
if (cached2) return cached2;
|
|
30039
|
-
const commit = readInjected(true ? "
|
|
30040
|
-
const commitShort = readInjected(true ? "
|
|
30041
|
-
const version2 = readInjected(true ? "0.9.82-rc.
|
|
30042
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
30039
|
+
const commit = readInjected(true ? "5d9635b2a6476691469ecfe32b26a17e13484b2b" : void 0) ?? "unknown";
|
|
30040
|
+
const commitShort = readInjected(true ? "5d9635b2" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
30041
|
+
const version2 = readInjected(true ? "0.9.82-rc.333" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
30042
|
+
const builtAt = readInjected(true ? "2026-06-20T02:24:25.156Z" : void 0);
|
|
30043
30043
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
30044
30044
|
return cached2;
|
|
30045
30045
|
}
|
|
@@ -30307,10 +30307,10 @@ var require_dist3 = __commonJS({
|
|
|
30307
30307
|
} catch (error48) {
|
|
30308
30308
|
const gitError = error48 instanceof GitCommandError ? error48 : new GitCommandError("git_command_failed", "Failed to read Git status", { cause: error48 });
|
|
30309
30309
|
if (isTransientGitFailure(gitError)) {
|
|
30310
|
-
const
|
|
30311
|
-
if (
|
|
30310
|
+
const cached3 = lastKnownGoodStatus.get(workspace);
|
|
30311
|
+
if (cached3) {
|
|
30312
30312
|
return {
|
|
30313
|
-
...
|
|
30313
|
+
...cached3,
|
|
30314
30314
|
lastCheckedAt,
|
|
30315
30315
|
upstreamStatus: "unavailable",
|
|
30316
30316
|
error: gitError.stderr || gitError.message,
|
|
@@ -30433,9 +30433,9 @@ var require_dist3 = __commonJS({
|
|
|
30433
30433
|
return { config: null, sourceKey: "no-repo-root" };
|
|
30434
30434
|
}
|
|
30435
30435
|
const loaded = loadChangeImpactConfig(repoRoot);
|
|
30436
|
-
const
|
|
30437
|
-
if (
|
|
30438
|
-
return { config:
|
|
30436
|
+
const cached3 = changeImpactConfigCache.get(repoRoot);
|
|
30437
|
+
if (cached3 && cached3.sourceKey === loaded.sourceKey) {
|
|
30438
|
+
return { config: cached3.config, sourceKey: loaded.sourceKey };
|
|
30439
30439
|
}
|
|
30440
30440
|
const config2 = loaded.sourceType === "repo_file" ? loaded.config ?? null : null;
|
|
30441
30441
|
changeImpactConfigCache.set(repoRoot, { sourceKey: loaded.sourceKey, config: config2 });
|
|
@@ -32279,6 +32279,47 @@ Follow these recovery rules:
|
|
|
32279
32279
|
4. **Always record what happened**: After handling a failure, briefly note the outcome in your report to the user.`;
|
|
32280
32280
|
}
|
|
32281
32281
|
});
|
|
32282
|
+
function loadBetterSqlite3() {
|
|
32283
|
+
if (cached22) return cached22;
|
|
32284
|
+
const errors = [];
|
|
32285
|
+
if (typeof require === "function") {
|
|
32286
|
+
try {
|
|
32287
|
+
cached22 = require("better-sqlite3");
|
|
32288
|
+
return cached22;
|
|
32289
|
+
} catch (e) {
|
|
32290
|
+
errors.push(e);
|
|
32291
|
+
}
|
|
32292
|
+
}
|
|
32293
|
+
try {
|
|
32294
|
+
const metaUrl = typeof import_meta?.url === "string" ? import_meta.url : void 0;
|
|
32295
|
+
if (metaUrl) {
|
|
32296
|
+
cached22 = (0, import_module.createRequire)(metaUrl)("better-sqlite3");
|
|
32297
|
+
return cached22;
|
|
32298
|
+
}
|
|
32299
|
+
} catch (e) {
|
|
32300
|
+
errors.push(e);
|
|
32301
|
+
}
|
|
32302
|
+
try {
|
|
32303
|
+
cached22 = (0, import_module.createRequire)(`${process.cwd()}/__adhdev_better_sqlite3_loader__.js`)(
|
|
32304
|
+
"better-sqlite3"
|
|
32305
|
+
);
|
|
32306
|
+
return cached22;
|
|
32307
|
+
} catch (e) {
|
|
32308
|
+
errors.push(e);
|
|
32309
|
+
}
|
|
32310
|
+
const detail = errors.map((e) => e instanceof Error ? e.message : String(e)).join("; ");
|
|
32311
|
+
throw new Error(`Failed to load better-sqlite3: ${detail}`);
|
|
32312
|
+
}
|
|
32313
|
+
var import_module;
|
|
32314
|
+
var import_meta;
|
|
32315
|
+
var cached22;
|
|
32316
|
+
var init_load_better_sqlite3 = __esm2({
|
|
32317
|
+
"src/system/load-better-sqlite3.ts"() {
|
|
32318
|
+
"use strict";
|
|
32319
|
+
import_module = require("module");
|
|
32320
|
+
import_meta = {};
|
|
32321
|
+
}
|
|
32322
|
+
});
|
|
32282
32323
|
var mesh_ledger_exports = {};
|
|
32283
32324
|
__export2(mesh_ledger_exports, {
|
|
32284
32325
|
MAX_LEDGER_SLICE_LIMIT: () => MAX_LEDGER_SLICE_LIMIT,
|
|
@@ -32707,8 +32748,8 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
32707
32748
|
}
|
|
32708
32749
|
function getCachedRawEntries(meshId) {
|
|
32709
32750
|
const now = Date.now();
|
|
32710
|
-
const
|
|
32711
|
-
if (
|
|
32751
|
+
const cached3 = ledgerReadCache.get(meshId);
|
|
32752
|
+
if (cached3 && now - cached3.cachedAt < LEDGER_CACHE_TTL_MS) return cached3.entries;
|
|
32712
32753
|
let entries;
|
|
32713
32754
|
try {
|
|
32714
32755
|
entries = readLedgerFromStore(meshId);
|
|
@@ -33612,8 +33653,7 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
33612
33653
|
});
|
|
33613
33654
|
function loadDatabaseCtor() {
|
|
33614
33655
|
if (DatabaseCtor) return DatabaseCtor;
|
|
33615
|
-
|
|
33616
|
-
DatabaseCtor = runtimeRequire("better-sqlite3");
|
|
33656
|
+
DatabaseCtor = loadBetterSqlite3();
|
|
33617
33657
|
return DatabaseCtor;
|
|
33618
33658
|
}
|
|
33619
33659
|
function safeMeshId(meshId) {
|
|
@@ -33642,8 +33682,6 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
33642
33682
|
}
|
|
33643
33683
|
var import_fs5;
|
|
33644
33684
|
var import_path5;
|
|
33645
|
-
var import_module;
|
|
33646
|
-
var import_meta;
|
|
33647
33685
|
var DatabaseCtor;
|
|
33648
33686
|
var MeshRuntimeStore;
|
|
33649
33687
|
var init_mesh_runtime_store = __esm2({
|
|
@@ -33651,10 +33689,9 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
33651
33689
|
"use strict";
|
|
33652
33690
|
import_fs5 = require("fs");
|
|
33653
33691
|
import_path5 = require("path");
|
|
33654
|
-
|
|
33692
|
+
init_load_better_sqlite3();
|
|
33655
33693
|
init_mesh_ledger();
|
|
33656
33694
|
init_mesh_work_queue();
|
|
33657
|
-
import_meta = {};
|
|
33658
33695
|
MeshRuntimeStore = class _MeshRuntimeStore {
|
|
33659
33696
|
static instance;
|
|
33660
33697
|
db;
|
|
@@ -39194,8 +39231,8 @@ Next step: ${nextStep}`;
|
|
|
39194
39231
|
}
|
|
39195
39232
|
function getCachedMeshByWorkspace(workspace) {
|
|
39196
39233
|
const now = Date.now();
|
|
39197
|
-
const
|
|
39198
|
-
if (
|
|
39234
|
+
const cached3 = meshByWorkspaceCache.get(workspace);
|
|
39235
|
+
if (cached3 && now - cached3.cachedAt < MESH_WORKSPACE_CACHE_TTL_MS) return cached3.mesh;
|
|
39199
39236
|
const mesh = getMeshByRepo(workspace);
|
|
39200
39237
|
meshByWorkspaceCache.set(workspace, { mesh, cachedAt: now });
|
|
39201
39238
|
return mesh;
|
|
@@ -40445,6 +40482,21 @@ Next step: ${nextStep}`;
|
|
|
40445
40482
|
targetSessionId: readNonEmptyString2(payload.targetSessionId) || readNonEmptyString2(payload.sessionId) || readNonEmptyString2(payload.instanceId),
|
|
40446
40483
|
providerType: readNonEmptyString2(payload.providerType),
|
|
40447
40484
|
providerSessionId: readNonEmptyString2(payload.providerSessionId),
|
|
40485
|
+
// Carry the session identity fields the worker provider event emits so the
|
|
40486
|
+
// coordinator's mirror (updateMeshOwnedSession) gets a real workspace/title/
|
|
40487
|
+
// settings. Without these the remote-relay hop reconstructs metadataEvent with
|
|
40488
|
+
// an empty workspace, and the dashboard flaps to the generic
|
|
40489
|
+
// "Terminal (Mesh Node)" title (and degrades the provider label) between live
|
|
40490
|
+
// events and the periodic get_status_metadata snapshot. The local in-process
|
|
40491
|
+
// forward path (onMeshCoordinatorEventForwarded) already preserves these; this
|
|
40492
|
+
// mirrors them for the remote-only relay path.
|
|
40493
|
+
workspace: readNonEmptyString2(payload.workspace) || readNonEmptyString2(payload.workspaceName),
|
|
40494
|
+
workspaceName: readNonEmptyString2(payload.workspaceName) || readNonEmptyString2(payload.workspace),
|
|
40495
|
+
sessionTitle: readNonEmptyString2(payload.sessionTitle),
|
|
40496
|
+
sessionStatus: readNonEmptyString2(payload.sessionStatus),
|
|
40497
|
+
sessionChatStatus: readNonEmptyString2(payload.sessionChatStatus),
|
|
40498
|
+
providerName: readNonEmptyString2(payload.providerName),
|
|
40499
|
+
...payload.sessionSettings && typeof payload.sessionSettings === "object" && !Array.isArray(payload.sessionSettings) ? { sessionSettings: payload.sessionSettings } : {},
|
|
40448
40500
|
finalSummary: readNonEmptyString2(payload.finalSummary) || readNonEmptyString2(payload.summary),
|
|
40449
40501
|
jobId: readNonEmptyString2(payload.jobId),
|
|
40450
40502
|
interactionId: readNonEmptyString2(payload.interactionId),
|
|
@@ -41347,7 +41399,8 @@ Next step: ${nextStep}`;
|
|
|
41347
41399
|
const meshId = readNonEmptyString2(settings.meshCoordinatorFor);
|
|
41348
41400
|
if (!meshId) continue;
|
|
41349
41401
|
const status = readNonEmptyString2(state.status).toLowerCase();
|
|
41350
|
-
|
|
41402
|
+
const modalParked = status === "waiting_choice" || status === "waiting_approval";
|
|
41403
|
+
out.push({ meshId, instance: inst, idle: status === "idle", modalParked });
|
|
41351
41404
|
}
|
|
41352
41405
|
return out;
|
|
41353
41406
|
}
|
|
@@ -41436,9 +41489,16 @@ Next step: ${nextStep}`;
|
|
|
41436
41489
|
}
|
|
41437
41490
|
for (const [meshId, meshCoordinators] of byMesh) {
|
|
41438
41491
|
const idleCoordinators = meshCoordinators.filter((c) => c.idle);
|
|
41439
|
-
const generatingCoordinators = meshCoordinators.filter((c) => !c.idle);
|
|
41492
|
+
const generatingCoordinators = meshCoordinators.filter((c) => !c.idle && !c.modalParked);
|
|
41493
|
+
const modalParkedCoordinators = meshCoordinators.filter((c) => !c.idle && c.modalParked);
|
|
41440
41494
|
const targetCoordinators = idleCoordinators.length > 0 ? idleCoordinators : generatingCoordinators;
|
|
41441
41495
|
const forceOnly = idleCoordinators.length === 0;
|
|
41496
|
+
if (targetCoordinators.length === 0) {
|
|
41497
|
+
if (modalParkedCoordinators.length > 0) {
|
|
41498
|
+
LOG2.info("MeshReconcile", `Reconcile skip \u2192 modal-parked: holding pending event(s) for mesh ${meshId} (${modalParkedCoordinators.length} coordinator(s) awaiting a modal answer; events left queued)`);
|
|
41499
|
+
}
|
|
41500
|
+
continue;
|
|
41501
|
+
}
|
|
41442
41502
|
if (store) {
|
|
41443
41503
|
try {
|
|
41444
41504
|
if (store.pendingEventCount(meshId) === 0) continue;
|
|
@@ -45038,10 +45098,10 @@ ${lastSnapshot}`;
|
|
|
45038
45098
|
return this.accumulatedRawBuffer.replace(/\x1B\][^\x07]*(?:\x07|\x1B\\)/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
|
|
45039
45099
|
}
|
|
45040
45100
|
getFreshParsedStatusCache() {
|
|
45041
|
-
const
|
|
45101
|
+
const cached3 = this.parsedStatusCache;
|
|
45042
45102
|
const accumulatedRawBufferKey = this.getAccumulatedRawBufferCacheKey();
|
|
45043
|
-
if (
|
|
45044
|
-
return
|
|
45103
|
+
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) {
|
|
45104
|
+
return cached3.result;
|
|
45045
45105
|
}
|
|
45046
45106
|
return null;
|
|
45047
45107
|
}
|
|
@@ -45503,10 +45563,10 @@ ${lastSnapshot}`;
|
|
|
45503
45563
|
getScriptParsedStatus() {
|
|
45504
45564
|
const screenText = this.readTerminalScreenText();
|
|
45505
45565
|
const parseScreenText = this.getParseScreenText(screenText);
|
|
45506
|
-
const
|
|
45566
|
+
const cached3 = this.parsedStatusCache;
|
|
45507
45567
|
const accumulatedRawBufferKey = this.getAccumulatedRawBufferCacheKey();
|
|
45508
|
-
if (!this.providerOwnsTranscript() &&
|
|
45509
|
-
return
|
|
45568
|
+
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) {
|
|
45569
|
+
return cached3.result;
|
|
45510
45570
|
}
|
|
45511
45571
|
const parsed = this.runParseSession();
|
|
45512
45572
|
if (!parsed || !Array.isArray(parsed.messages)) {
|
|
@@ -45753,6 +45813,10 @@ ${lastSnapshot}`;
|
|
|
45753
45813
|
if (!this.ptyProcess) throw new Error(`${this.cliName} is not running`);
|
|
45754
45814
|
const content = String(text || "");
|
|
45755
45815
|
if (!content.trim()) return;
|
|
45816
|
+
if (this.engine.currentStatus === "waiting_approval" || this.engine.hasActionableApproval()) {
|
|
45817
|
+
LOG2.info("CLI", `[${this.cliType}] force-send held \u2014 session parked on approval modal (status=${this.engine.currentStatus})`);
|
|
45818
|
+
return;
|
|
45819
|
+
}
|
|
45756
45820
|
LOG2.info("CLI", `[${this.cliType}] force-sending prompt while status=${this.engine.currentStatus}`);
|
|
45757
45821
|
await this.writeToPty(content + this.sendKey);
|
|
45758
45822
|
this.onStatusChange?.();
|
|
@@ -52187,11 +52251,11 @@ ${cleanBody}`;
|
|
|
52187
52251
|
var BOUNDED_TAIL_CACHE_MAX_ENTRIES = 64;
|
|
52188
52252
|
var boundedTailReadCache = /* @__PURE__ */ new Map();
|
|
52189
52253
|
function readBoundedTailCache(key, signature) {
|
|
52190
|
-
const
|
|
52191
|
-
if (!
|
|
52254
|
+
const cached3 = boundedTailReadCache.get(key);
|
|
52255
|
+
if (!cached3 || cached3.signature !== signature) return null;
|
|
52192
52256
|
boundedTailReadCache.delete(key);
|
|
52193
|
-
boundedTailReadCache.set(key,
|
|
52194
|
-
return
|
|
52257
|
+
boundedTailReadCache.set(key, cached3);
|
|
52258
|
+
return cached3.result;
|
|
52195
52259
|
}
|
|
52196
52260
|
function writeBoundedTailCache(key, signature, result) {
|
|
52197
52261
|
boundedTailReadCache.delete(key);
|
|
@@ -52675,9 +52739,9 @@ ${cleanBody}`;
|
|
|
52675
52739
|
for (const file2 of files.slice().sort()) {
|
|
52676
52740
|
const filePath = path14.join(dir, file2);
|
|
52677
52741
|
const signature = fileSignatures.get(file2) || `${file2}:missing`;
|
|
52678
|
-
const
|
|
52742
|
+
const cached3 = savedHistoryFileSummaryCache.get(filePath);
|
|
52679
52743
|
const persisted = persistedEntries.get(file2);
|
|
52680
|
-
const reusableEntry =
|
|
52744
|
+
const reusableEntry = cached3?.signature === signature ? cached3 : persisted?.signature === signature ? persisted : null;
|
|
52681
52745
|
const fileSummary = reusableEntry?.summary || computeSavedHistoryFileSummary(dir, file2);
|
|
52682
52746
|
const nextEntry = reusableEntry || {
|
|
52683
52747
|
signature,
|
|
@@ -53173,16 +53237,16 @@ ${cleanBody}`;
|
|
|
53173
53237
|
incrementalTailCache.delete(filePath);
|
|
53174
53238
|
return { lines: [], coversWholeFile: true };
|
|
53175
53239
|
}
|
|
53176
|
-
const
|
|
53177
|
-
if (
|
|
53178
|
-
if (
|
|
53240
|
+
const cached3 = incrementalTailCache.get(filePath);
|
|
53241
|
+
if (cached3) {
|
|
53242
|
+
if (cached3.size === size && cached3.mtimeMs === mtimeMs) {
|
|
53179
53243
|
incrementalTailCache.delete(filePath);
|
|
53180
|
-
incrementalTailCache.set(filePath,
|
|
53181
|
-
if (
|
|
53182
|
-
return { lines:
|
|
53244
|
+
incrementalTailCache.set(filePath, cached3);
|
|
53245
|
+
if (cached3.coversWholeFile || cached3.lines.length >= needed) {
|
|
53246
|
+
return { lines: cached3.lines, coversWholeFile: cached3.coversWholeFile };
|
|
53183
53247
|
}
|
|
53184
|
-
} else if (size >
|
|
53185
|
-
const incremental = tryIncrementalTailGrowth(filePath,
|
|
53248
|
+
} else if (size > cached3.size) {
|
|
53249
|
+
const incremental = tryIncrementalTailGrowth(filePath, cached3, size, mtimeMs, needed);
|
|
53186
53250
|
if (incremental) return { lines: incremental.lines, coversWholeFile: incremental.coversWholeFile };
|
|
53187
53251
|
}
|
|
53188
53252
|
incrementalTailCache.delete(filePath);
|
|
@@ -53208,22 +53272,22 @@ ${cleanBody}`;
|
|
|
53208
53272
|
storeIncrementalTailCache(filePath, result.size, result.mtimeMs, result.lines, result.coversWholeFile);
|
|
53209
53273
|
return { lines: result.lines, coversWholeFile: result.coversWholeFile };
|
|
53210
53274
|
}
|
|
53211
|
-
function tryIncrementalTailGrowth(filePath,
|
|
53275
|
+
function tryIncrementalTailGrowth(filePath, cached3, size, mtimeMs, needed) {
|
|
53212
53276
|
const fd = fs6.openSync(filePath, "r");
|
|
53213
53277
|
try {
|
|
53214
|
-
if (
|
|
53278
|
+
if (cached3.size > 0) {
|
|
53215
53279
|
const boundary = Buffer.alloc(1);
|
|
53216
|
-
fs6.readSync(fd, boundary, 0, 1,
|
|
53280
|
+
fs6.readSync(fd, boundary, 0, 1, cached3.size - 1);
|
|
53217
53281
|
if (boundary[0] !== 10) return null;
|
|
53218
53282
|
}
|
|
53219
|
-
const appendedLength = size -
|
|
53283
|
+
const appendedLength = size - cached3.size;
|
|
53220
53284
|
const appended = Buffer.alloc(appendedLength);
|
|
53221
|
-
fs6.readSync(fd, appended, 0, appendedLength,
|
|
53285
|
+
fs6.readSync(fd, appended, 0, appendedLength, cached3.size);
|
|
53222
53286
|
const newLines = appended.toString("utf-8").split("\n");
|
|
53223
53287
|
if (newLines.length && newLines[newLines.length - 1] === "") newLines.pop();
|
|
53224
|
-
const merged =
|
|
53288
|
+
const merged = cached3.lines.concat(newLines);
|
|
53225
53289
|
const trimmed = merged.length > TAIL_LINES_RETAINED ? merged.slice(merged.length - TAIL_LINES_RETAINED) : merged;
|
|
53226
|
-
const coversWholeFile =
|
|
53290
|
+
const coversWholeFile = cached3.coversWholeFile && trimmed.length === merged.length;
|
|
53227
53291
|
storeIncrementalTailCache(filePath, size, mtimeMs, trimmed, coversWholeFile);
|
|
53228
53292
|
if (coversWholeFile || trimmed.length >= needed) {
|
|
53229
53293
|
return { lines: trimmed, coversWholeFile };
|
|
@@ -53288,8 +53352,8 @@ ${cleanBody}`;
|
|
|
53288
53352
|
const fileSignatures = buildSavedHistoryFileSignatureMap(dir, files);
|
|
53289
53353
|
const cacheKey = `${sanitized}\0${historySessionId || ""}\0${offset}\0${limit}\0${excludeRecentCount}\0${historyBehavior?.collapseConsecutiveAssistantTurns ? "1" : "0"}`;
|
|
53290
53354
|
const signature = buildSavedHistoryCacheSignature(files, fileSignatures);
|
|
53291
|
-
const
|
|
53292
|
-
if (
|
|
53355
|
+
const cached3 = readBoundedTailCache(cacheKey, signature);
|
|
53356
|
+
if (cached3) return cached3;
|
|
53293
53357
|
const numericLimit = Math.max(1, Number(limit));
|
|
53294
53358
|
const numericOffset = Math.max(0, Number(offset));
|
|
53295
53359
|
const numericExclude = Math.max(0, Number(excludeRecentCount));
|
|
@@ -53332,23 +53396,23 @@ ${cleanBody}`;
|
|
|
53332
53396
|
savedHistorySessionCache.delete(sanitized);
|
|
53333
53397
|
return { sessions: [], hasMore: false };
|
|
53334
53398
|
}
|
|
53335
|
-
const
|
|
53399
|
+
const cached3 = savedHistorySessionCache.get(sanitized);
|
|
53336
53400
|
const offset = Math.max(0, options.offset || 0);
|
|
53337
53401
|
const limit = Math.max(1, options.limit || 30);
|
|
53338
53402
|
const indexSignature = buildSavedHistoryIndexFileSignature(dir);
|
|
53339
53403
|
let cacheWasInvalidated = false;
|
|
53340
|
-
if (
|
|
53341
|
-
const cacheLooksPersisted =
|
|
53342
|
-
const cacheStillValid = cacheLooksPersisted ?
|
|
53404
|
+
if (cached3) {
|
|
53405
|
+
const cacheLooksPersisted = cached3.signature.startsWith("index:");
|
|
53406
|
+
const cacheStillValid = cacheLooksPersisted ? cached3.signature === indexSignature : (() => {
|
|
53343
53407
|
const files2 = listHistoryFiles(dir);
|
|
53344
53408
|
const fileSignatures2 = buildSavedHistoryFileSignatureMap(dir, files2);
|
|
53345
|
-
return
|
|
53409
|
+
return cached3.signature === buildSavedHistoryCacheSignature(files2, fileSignatures2);
|
|
53346
53410
|
})();
|
|
53347
53411
|
if (cacheStillValid) {
|
|
53348
|
-
const sliced2 =
|
|
53412
|
+
const sliced2 = cached3.summaries.slice(offset, offset + limit);
|
|
53349
53413
|
return {
|
|
53350
53414
|
sessions: sliced2,
|
|
53351
|
-
hasMore:
|
|
53415
|
+
hasMore: cached3.summaries.length > offset + limit
|
|
53352
53416
|
};
|
|
53353
53417
|
}
|
|
53354
53418
|
cacheWasInvalidated = true;
|
|
@@ -62208,6 +62272,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62208
62272
|
var os17 = __toESM2(require("os"));
|
|
62209
62273
|
var path222 = __toESM2(require("path"));
|
|
62210
62274
|
init_logger();
|
|
62275
|
+
init_load_better_sqlite3();
|
|
62211
62276
|
var UUID_RE = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
|
|
62212
62277
|
function executeNativeHistory(cfg, input) {
|
|
62213
62278
|
if (!cfg?.source) return null;
|
|
@@ -62332,7 +62397,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62332
62397
|
if (!resolved || !fs13.existsSync(resolved)) return null;
|
|
62333
62398
|
let Database;
|
|
62334
62399
|
try {
|
|
62335
|
-
Database =
|
|
62400
|
+
Database = loadBetterSqlite3();
|
|
62336
62401
|
} catch {
|
|
62337
62402
|
return null;
|
|
62338
62403
|
}
|
|
@@ -64484,6 +64549,35 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
64484
64549
|
this.settings = rest;
|
|
64485
64550
|
this.adapter.updateRuntimeSettings?.(this.settings);
|
|
64486
64551
|
}
|
|
64552
|
+
/**
|
|
64553
|
+
* The resolved modal-park status of this session, or null when it is not
|
|
64554
|
+
* parked on a modal awaiting a human answer. Mirrors the overlay logic in
|
|
64555
|
+
* getState(): an active AskUserQuestion interactive prompt resolves to
|
|
64556
|
+
* waiting_choice; otherwise the adapter's waiting_approval (tool consent)
|
|
64557
|
+
* counts — UNLESS auto-approve will dismiss it, in which case the session is
|
|
64558
|
+
* effectively generating and is NOT modal-parked. This is the single signal
|
|
64559
|
+
* the mesh force-inject guard consults, and the same status string the
|
|
64560
|
+
* reconcile loop reads off get_status_metadata. Lowercase literals only —
|
|
64561
|
+
* the SessionStatus enum is forked across modules and waiting_choice is
|
|
64562
|
+
* absent from some of them.
|
|
64563
|
+
*/
|
|
64564
|
+
resolveModalParkStatus() {
|
|
64565
|
+
if (this.activeInteractivePrompt) return "waiting_choice";
|
|
64566
|
+
let adapterStatus;
|
|
64567
|
+
try {
|
|
64568
|
+
adapterStatus = this.adapter.getStatus({ allowParse: false });
|
|
64569
|
+
} catch {
|
|
64570
|
+
return null;
|
|
64571
|
+
}
|
|
64572
|
+
if (adapterStatus.status === "waiting_approval" && !this.shouldAutoApprove()) {
|
|
64573
|
+
return "waiting_approval";
|
|
64574
|
+
}
|
|
64575
|
+
return null;
|
|
64576
|
+
}
|
|
64577
|
+
/** True when this session is parked on a modal awaiting a human answer. */
|
|
64578
|
+
isModalParked() {
|
|
64579
|
+
return this.resolveModalParkStatus() !== null;
|
|
64580
|
+
}
|
|
64487
64581
|
onEvent(event, data) {
|
|
64488
64582
|
if (event === "send_message") {
|
|
64489
64583
|
const input = normalizeInputEnvelope(data);
|
|
@@ -64491,6 +64585,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
64491
64585
|
const promptText = buildCliStructuredInputPrompt(input);
|
|
64492
64586
|
if (promptText) {
|
|
64493
64587
|
const force = data?.force === true;
|
|
64588
|
+
if (force && this.isModalParked()) {
|
|
64589
|
+
LOG2.info("CLI", `[${this.type}] force send_message held \u2014 coordinator parked on modal (${this.resolveModalParkStatus()})`);
|
|
64590
|
+
return;
|
|
64591
|
+
}
|
|
64494
64592
|
void this.adapter.sendMessage(promptText, force ? { force: true } : {}).catch((e) => {
|
|
64495
64593
|
LOG2.warn("CLI", `[${this.type}] send_message failed: ${e?.message || e}`);
|
|
64496
64594
|
});
|
|
@@ -69083,6 +69181,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69083
69181
|
var fs20 = __toESM2(require("fs"));
|
|
69084
69182
|
var path30 = __toESM2(require("path"));
|
|
69085
69183
|
var os21 = __toESM2(require("os"));
|
|
69184
|
+
init_load_better_sqlite3();
|
|
69086
69185
|
var HERMES_STATE_DB = path30.join(os21.homedir(), ".hermes", "state.db");
|
|
69087
69186
|
var HERMES_LEGACY_SESSIONS_DIR = path30.join(os21.homedir(), ".hermes", "sessions");
|
|
69088
69187
|
function statMtimeMs4(p) {
|
|
@@ -69095,7 +69194,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69095
69194
|
function openDb() {
|
|
69096
69195
|
if (!fs20.existsSync(HERMES_STATE_DB)) return null;
|
|
69097
69196
|
try {
|
|
69098
|
-
const Database =
|
|
69197
|
+
const Database = loadBetterSqlite3();
|
|
69099
69198
|
return new Database(HERMES_STATE_DB, { readonly: true, fileMustExist: true });
|
|
69100
69199
|
} catch {
|
|
69101
69200
|
return null;
|
|
@@ -70466,8 +70565,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
70466
70565
|
return null;
|
|
70467
70566
|
}
|
|
70468
70567
|
registerProviderScriptRootSafely(path332.dirname(path332.dirname(providerDir)));
|
|
70469
|
-
const
|
|
70470
|
-
if (
|
|
70568
|
+
const cached3 = this.scriptsCache.get(dir);
|
|
70569
|
+
if (cached3) return cached3;
|
|
70471
70570
|
const scriptsJs = path332.join(dir, "scripts.js");
|
|
70472
70571
|
if (fs222.existsSync(scriptsJs)) {
|
|
70473
70572
|
try {
|
|
@@ -73514,13 +73613,13 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
73514
73613
|
nodes
|
|
73515
73614
|
};
|
|
73516
73615
|
}
|
|
73517
|
-
function reconcileInlineMeshCache(
|
|
73518
|
-
if (!
|
|
73519
|
-
if (!incoming || typeof incoming !== "object" || Array.isArray(incoming)) return
|
|
73520
|
-
const cachedNodes = Array.isArray(
|
|
73616
|
+
function reconcileInlineMeshCache(cached3, incoming) {
|
|
73617
|
+
if (!cached3 || typeof cached3 !== "object" || Array.isArray(cached3)) return incoming;
|
|
73618
|
+
if (!incoming || typeof incoming !== "object" || Array.isArray(incoming)) return cached3;
|
|
73619
|
+
const cachedNodes = Array.isArray(cached3.nodes) ? cached3.nodes : [];
|
|
73521
73620
|
const incomingNodes = Array.isArray(incoming.nodes) ? incoming.nodes : [];
|
|
73522
|
-
if (!cachedNodes.length || !incomingNodes.length) return { ...
|
|
73523
|
-
const cachedUpdatedAt = Date.parse(readStringValue(
|
|
73621
|
+
if (!cachedNodes.length || !incomingNodes.length) return { ...cached3, ...incoming };
|
|
73622
|
+
const cachedUpdatedAt = Date.parse(readStringValue(cached3.updatedAt, cached3.updated_at) || "");
|
|
73524
73623
|
const incomingUpdatedAt = Date.parse(readStringValue(incoming.updatedAt, incoming.updated_at) || "");
|
|
73525
73624
|
const preserveCachedMembership = Number.isFinite(cachedUpdatedAt) && (!Number.isFinite(incomingUpdatedAt) || cachedUpdatedAt > incomingUpdatedAt);
|
|
73526
73625
|
const cachedById = /* @__PURE__ */ new Map();
|
|
@@ -73549,7 +73648,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
73549
73648
|
}
|
|
73550
73649
|
}
|
|
73551
73650
|
return {
|
|
73552
|
-
...
|
|
73651
|
+
...cached3,
|
|
73553
73652
|
...incoming,
|
|
73554
73653
|
nodes
|
|
73555
73654
|
};
|
|
@@ -73882,9 +73981,9 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
73882
73981
|
*/
|
|
73883
73982
|
async probe(daemonId, workspace, probe) {
|
|
73884
73983
|
const key = this.key(daemonId, workspace);
|
|
73885
|
-
const
|
|
73886
|
-
if (
|
|
73887
|
-
return
|
|
73984
|
+
const cached3 = this.recent.get(key);
|
|
73985
|
+
if (cached3 && this.now() - cached3.at < this.reuseMs) {
|
|
73986
|
+
return cached3.value;
|
|
73888
73987
|
}
|
|
73889
73988
|
const existing = this.inflight.get(key);
|
|
73890
73989
|
if (existing) return existing;
|
|
@@ -75532,13 +75631,13 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75532
75631
|
};
|
|
75533
75632
|
}
|
|
75534
75633
|
getCachedAggregateMeshStatus(meshId, mesh, options) {
|
|
75535
|
-
const
|
|
75536
|
-
if (!
|
|
75537
|
-
if (
|
|
75538
|
-
let snapshot = this.cloneJsonValue(
|
|
75634
|
+
const cached3 = this.aggregateMeshStatusCache.get(meshId);
|
|
75635
|
+
if (!cached3?.snapshot || cached3.snapshot.success !== true || !Array.isArray(cached3.snapshot.nodes)) return null;
|
|
75636
|
+
if (cached3.queueRevision !== getMeshQueueRevision(meshId)) return null;
|
|
75637
|
+
let snapshot = this.cloneJsonValue(cached3.snapshot);
|
|
75539
75638
|
snapshot = this.hydrateCachedAggregateMeshStatusFromInline(snapshot, mesh, options);
|
|
75540
75639
|
if (shouldRefreshStalePendingAggregate(snapshot, options)) return null;
|
|
75541
|
-
const ageMs = Math.max(0, Date.now() -
|
|
75640
|
+
const ageMs = Math.max(0, Date.now() - cached3.builtAt);
|
|
75542
75641
|
const sourceOfTruth = snapshot.sourceOfTruth && typeof snapshot.sourceOfTruth === "object" ? snapshot.sourceOfTruth : {};
|
|
75543
75642
|
snapshot.sourceOfTruth = {
|
|
75544
75643
|
...sourceOfTruth,
|
|
@@ -75549,7 +75648,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75549
75648
|
source: "memory",
|
|
75550
75649
|
refreshReason: "memory_cache_hit",
|
|
75551
75650
|
ageMs,
|
|
75552
|
-
cachedAt: new Date(
|
|
75651
|
+
cachedAt: new Date(cached3.builtAt).toISOString(),
|
|
75553
75652
|
returnedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
75554
75653
|
}
|
|
75555
75654
|
};
|
|
@@ -75596,9 +75695,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75596
75695
|
meshId,
|
|
75597
75696
|
sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(inlineMesh))
|
|
75598
75697
|
);
|
|
75599
|
-
const
|
|
75600
|
-
if (
|
|
75601
|
-
const merged = reconcileInlineMeshCache(
|
|
75698
|
+
const cached3 = this.inlineMeshCache.get(meshId);
|
|
75699
|
+
if (cached3) {
|
|
75700
|
+
const merged = reconcileInlineMeshCache(cached3, sanitizedInlineMesh);
|
|
75602
75701
|
this.inlineMeshCache.set(meshId, merged);
|
|
75603
75702
|
return merged;
|
|
75604
75703
|
}
|
|
@@ -75608,17 +75707,17 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75608
75707
|
async getMeshForCommand(meshId, inlineMesh, options) {
|
|
75609
75708
|
const preferInline = options?.preferInline === true;
|
|
75610
75709
|
if (preferInline) {
|
|
75611
|
-
const
|
|
75612
|
-
if (
|
|
75710
|
+
const cached4 = this.getCachedInlineMesh(meshId);
|
|
75711
|
+
if (cached4) {
|
|
75613
75712
|
if (inlineMeshCarriesTransientNodeTruth(inlineMesh)) {
|
|
75614
75713
|
const merged = reconcileInlineMeshCache(
|
|
75615
|
-
|
|
75714
|
+
cached4,
|
|
75616
75715
|
this.applyInlineMeshNodeTombstones(meshId, inlineMesh)
|
|
75617
75716
|
);
|
|
75618
75717
|
this.inlineMeshCache.set(meshId, sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(merged)));
|
|
75619
75718
|
return { mesh: merged, inline: true, source: "inline_cache" };
|
|
75620
75719
|
}
|
|
75621
|
-
return { mesh:
|
|
75720
|
+
return { mesh: cached4, inline: true, source: "inline_cache" };
|
|
75622
75721
|
}
|
|
75623
75722
|
if (inlineMeshCarriesTransientNodeTruth(inlineMesh)) {
|
|
75624
75723
|
this.warmInlineMeshCache(meshId, inlineMesh);
|
|
@@ -75631,8 +75730,8 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75631
75730
|
if (mesh) return { mesh, inline: false, source: "local_config" };
|
|
75632
75731
|
} catch {
|
|
75633
75732
|
}
|
|
75634
|
-
const
|
|
75635
|
-
if (
|
|
75733
|
+
const cached3 = this.getCachedInlineMesh(meshId);
|
|
75734
|
+
if (cached3) return { mesh: cached3, inline: true, source: "inline_cache" };
|
|
75636
75735
|
const warmedInline = this.warmInlineMeshCache(meshId, inlineMesh);
|
|
75637
75736
|
return warmedInline ? { mesh: warmedInline, inline: true, source: "inline_bootstrap" } : null;
|
|
75638
75737
|
}
|
|
@@ -77062,8 +77161,8 @@ ${hintLines.join("\n")}` : "",
|
|
|
77062
77161
|
const repoRootBaseRef = /* @__PURE__ */ new Map();
|
|
77063
77162
|
const submodulePathsByRepoRoot = /* @__PURE__ */ new Map();
|
|
77064
77163
|
const resolveBaseRef = async (repoRoot) => {
|
|
77065
|
-
const
|
|
77066
|
-
if (
|
|
77164
|
+
const cached3 = repoRootBaseRef.get(repoRoot);
|
|
77165
|
+
if (cached3) return cached3;
|
|
77067
77166
|
let baseBranch = "main";
|
|
77068
77167
|
try {
|
|
77069
77168
|
const { stdout } = await execFileAsync4("git", ["branch", "--show-current"], { cwd: repoRoot, encoding: "utf8" });
|