@adhdev/daemon-standalone 0.9.82-rc.332 → 0.9.82-rc.334
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 +729 -611
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/index-UtQU55ZC.js +113 -0
- package/public/index.html +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 ? "9e5ae5d2814077a6bf9e982b17066ca2051da97b" : void 0) ?? "unknown";
|
|
30040
|
+
const commitShort = readInjected(true ? "9e5ae5d2" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
30041
|
+
const version2 = readInjected(true ? "0.9.82-rc.334" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
30042
|
+
const builtAt = readInjected(true ? "2026-06-20T03:56:19.434Z" : 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);
|
|
@@ -32971,6 +33012,314 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
32971
33012
|
ledgerImportDone = /* @__PURE__ */ new Set();
|
|
32972
33013
|
}
|
|
32973
33014
|
});
|
|
33015
|
+
var fs32;
|
|
33016
|
+
var AsyncBatchWriter;
|
|
33017
|
+
var init_async_batch_writer = __esm2({
|
|
33018
|
+
"src/logging/async-batch-writer.ts"() {
|
|
33019
|
+
"use strict";
|
|
33020
|
+
fs32 = __toESM2(require("fs"));
|
|
33021
|
+
AsyncBatchWriter = class {
|
|
33022
|
+
// Maps filePath -> string buffer
|
|
33023
|
+
static buffers = /* @__PURE__ */ new Map();
|
|
33024
|
+
static writePromises = /* @__PURE__ */ new Map();
|
|
33025
|
+
static flushTimer = null;
|
|
33026
|
+
/**
|
|
33027
|
+
* Queues data to be written to a file asynchronously in a batch.
|
|
33028
|
+
*/
|
|
33029
|
+
static write(filePath, data) {
|
|
33030
|
+
let buf = this.buffers.get(filePath);
|
|
33031
|
+
if (!buf) {
|
|
33032
|
+
buf = [];
|
|
33033
|
+
this.buffers.set(filePath, buf);
|
|
33034
|
+
}
|
|
33035
|
+
buf.push(data);
|
|
33036
|
+
if (!this.flushTimer) {
|
|
33037
|
+
this.flushTimer = setTimeout(() => {
|
|
33038
|
+
this.flushTimer = null;
|
|
33039
|
+
this.flushAll();
|
|
33040
|
+
}, 50);
|
|
33041
|
+
}
|
|
33042
|
+
}
|
|
33043
|
+
static async flushAll() {
|
|
33044
|
+
const entries = Array.from(this.buffers.entries());
|
|
33045
|
+
this.buffers.clear();
|
|
33046
|
+
for (const [filePath, buffer] of entries) {
|
|
33047
|
+
const dataToWrite = buffer.join("");
|
|
33048
|
+
const doWrite = async () => {
|
|
33049
|
+
try {
|
|
33050
|
+
const prevPromise = this.writePromises.get(filePath);
|
|
33051
|
+
if (prevPromise) await prevPromise;
|
|
33052
|
+
await fs32.promises.appendFile(filePath, dataToWrite, { encoding: "utf-8", mode: 384 });
|
|
33053
|
+
} catch {
|
|
33054
|
+
}
|
|
33055
|
+
};
|
|
33056
|
+
const writePromise = doWrite();
|
|
33057
|
+
this.writePromises.set(filePath, writePromise);
|
|
33058
|
+
writePromise.finally(() => {
|
|
33059
|
+
if (this.writePromises.get(filePath) === writePromise) {
|
|
33060
|
+
this.writePromises.delete(filePath);
|
|
33061
|
+
}
|
|
33062
|
+
});
|
|
33063
|
+
}
|
|
33064
|
+
}
|
|
33065
|
+
};
|
|
33066
|
+
}
|
|
33067
|
+
});
|
|
33068
|
+
var logger_exports = {};
|
|
33069
|
+
__export2(logger_exports, {
|
|
33070
|
+
LOG: () => LOG2,
|
|
33071
|
+
LOG_DIR_PATH: () => LOG_DIR_PATH,
|
|
33072
|
+
LOG_PATH: () => LOG_PATH,
|
|
33073
|
+
daemonLog: () => daemonLog,
|
|
33074
|
+
getCurrentDaemonLogPath: () => getCurrentDaemonLogPath,
|
|
33075
|
+
getDaemonLogDir: () => getDaemonLogDir,
|
|
33076
|
+
getLogBufferSize: () => getLogBufferSize,
|
|
33077
|
+
getLogLevel: () => getLogLevel,
|
|
33078
|
+
getLogPath: () => getLogPath,
|
|
33079
|
+
getRecentLogs: () => getRecentLogs,
|
|
33080
|
+
installGlobalInterceptor: () => installGlobalInterceptor,
|
|
33081
|
+
setLogLevel: () => setLogLevel
|
|
33082
|
+
});
|
|
33083
|
+
function setLogLevel(level) {
|
|
33084
|
+
currentLevel = level;
|
|
33085
|
+
daemonLog("Logger", `Log level set to: ${level}`, "info");
|
|
33086
|
+
}
|
|
33087
|
+
function getLogLevel() {
|
|
33088
|
+
return currentLevel;
|
|
33089
|
+
}
|
|
33090
|
+
function getDateStr() {
|
|
33091
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
33092
|
+
}
|
|
33093
|
+
function getDaemonLogDir() {
|
|
33094
|
+
return LOG_DIR;
|
|
33095
|
+
}
|
|
33096
|
+
function getCurrentDaemonLogPath(date5 = /* @__PURE__ */ new Date()) {
|
|
33097
|
+
return path9.join(LOG_DIR, `daemon-${date5.toISOString().slice(0, 10)}.log`);
|
|
33098
|
+
}
|
|
33099
|
+
function checkDateRotation() {
|
|
33100
|
+
const today = getDateStr();
|
|
33101
|
+
if (today !== currentDate) {
|
|
33102
|
+
currentDate = today;
|
|
33103
|
+
currentLogFile = path9.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
33104
|
+
cleanOldLogs();
|
|
33105
|
+
}
|
|
33106
|
+
}
|
|
33107
|
+
function cleanOldLogs() {
|
|
33108
|
+
try {
|
|
33109
|
+
const files = fs4.readdirSync(LOG_DIR).filter((f) => f.startsWith("daemon-") && f.endsWith(".log"));
|
|
33110
|
+
const cutoff = /* @__PURE__ */ new Date();
|
|
33111
|
+
cutoff.setDate(cutoff.getDate() - MAX_LOG_DAYS);
|
|
33112
|
+
const cutoffStr = cutoff.toISOString().slice(0, 10);
|
|
33113
|
+
for (const file2 of files) {
|
|
33114
|
+
const dateMatch = file2.match(/daemon-(\d{4}-\d{2}-\d{2})/);
|
|
33115
|
+
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
33116
|
+
try {
|
|
33117
|
+
fs4.unlinkSync(path9.join(LOG_DIR, file2));
|
|
33118
|
+
} catch {
|
|
33119
|
+
}
|
|
33120
|
+
}
|
|
33121
|
+
}
|
|
33122
|
+
} catch {
|
|
33123
|
+
}
|
|
33124
|
+
}
|
|
33125
|
+
function rotateSizeIfNeeded() {
|
|
33126
|
+
try {
|
|
33127
|
+
const stat2 = fs4.statSync(currentLogFile);
|
|
33128
|
+
if (stat2.size > MAX_LOG_SIZE) {
|
|
33129
|
+
const backup = currentLogFile.replace(".log", ".1.log");
|
|
33130
|
+
try {
|
|
33131
|
+
fs4.unlinkSync(backup);
|
|
33132
|
+
} catch {
|
|
33133
|
+
}
|
|
33134
|
+
fs4.renameSync(currentLogFile, backup);
|
|
33135
|
+
}
|
|
33136
|
+
} catch {
|
|
33137
|
+
}
|
|
33138
|
+
}
|
|
33139
|
+
function writeToFile(line) {
|
|
33140
|
+
try {
|
|
33141
|
+
if (++writeCount % 1e3 === 0) {
|
|
33142
|
+
checkDateRotation();
|
|
33143
|
+
rotateSizeIfNeeded();
|
|
33144
|
+
}
|
|
33145
|
+
AsyncBatchWriter.write(currentLogFile, line + "\n");
|
|
33146
|
+
} catch {
|
|
33147
|
+
}
|
|
33148
|
+
}
|
|
33149
|
+
function getRecentLogs(count = 50, minLevel = "info") {
|
|
33150
|
+
const minNum = LEVEL_NUM[minLevel];
|
|
33151
|
+
const filtered = ringBuffer.filter((e) => LEVEL_NUM[e.level] >= minNum);
|
|
33152
|
+
return filtered.slice(-count);
|
|
33153
|
+
}
|
|
33154
|
+
function getLogBufferSize() {
|
|
33155
|
+
return ringBuffer.length;
|
|
33156
|
+
}
|
|
33157
|
+
function ts() {
|
|
33158
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
|
|
33159
|
+
}
|
|
33160
|
+
function fullTs() {
|
|
33161
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
33162
|
+
}
|
|
33163
|
+
function daemonLog(category, msg, level = "info") {
|
|
33164
|
+
const shouldOutput = LEVEL_NUM[level] >= LEVEL_NUM[currentLevel];
|
|
33165
|
+
const label = LEVEL_LABEL[level];
|
|
33166
|
+
const line = `[${ts()}] [${label}] [${category}] ${msg}`;
|
|
33167
|
+
if (!shouldOutput) return;
|
|
33168
|
+
writeToFile(line);
|
|
33169
|
+
ringBuffer.push({ ts: Date.now(), level, category, message: msg });
|
|
33170
|
+
if (ringBuffer.length > RING_BUFFER_SIZE) {
|
|
33171
|
+
ringBuffer.splice(0, ringBuffer.length - RING_BUFFER_SIZE);
|
|
33172
|
+
}
|
|
33173
|
+
origConsoleLog(line);
|
|
33174
|
+
}
|
|
33175
|
+
function installGlobalInterceptor() {
|
|
33176
|
+
if (interceptorInstalled) return;
|
|
33177
|
+
interceptorInstalled = true;
|
|
33178
|
+
const stripAnsi4 = (str) => str.replace(/\x1B\[[0-9;]*m/g, "");
|
|
33179
|
+
const isDaemonLogLine = (msg) => /\[(DBG|INF|WRN|ERR)\]/.test(msg);
|
|
33180
|
+
console.log = (...args) => {
|
|
33181
|
+
origConsoleLog(...args);
|
|
33182
|
+
try {
|
|
33183
|
+
const msg = args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ");
|
|
33184
|
+
const clean = stripAnsi4(msg);
|
|
33185
|
+
if (isDaemonLogLine(clean)) return;
|
|
33186
|
+
const line = clean.startsWith("[20") ? clean : `[${fullTs()}] ${clean}`;
|
|
33187
|
+
writeToFile(line);
|
|
33188
|
+
const catMatch = clean.match(/\[([^\]]+)\]/);
|
|
33189
|
+
ringBuffer.push({
|
|
33190
|
+
ts: Date.now(),
|
|
33191
|
+
level: "info",
|
|
33192
|
+
category: catMatch?.[1] || "System",
|
|
33193
|
+
message: clean
|
|
33194
|
+
});
|
|
33195
|
+
if (ringBuffer.length > RING_BUFFER_SIZE) {
|
|
33196
|
+
ringBuffer.splice(0, ringBuffer.length - RING_BUFFER_SIZE);
|
|
33197
|
+
}
|
|
33198
|
+
} catch {
|
|
33199
|
+
}
|
|
33200
|
+
};
|
|
33201
|
+
console.error = (...args) => {
|
|
33202
|
+
origConsoleError(...args);
|
|
33203
|
+
try {
|
|
33204
|
+
const msg = args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ");
|
|
33205
|
+
const clean = stripAnsi4(msg);
|
|
33206
|
+
if (isDaemonLogLine(clean)) return;
|
|
33207
|
+
const line = `[${fullTs()}] [ERROR] ${clean}`;
|
|
33208
|
+
writeToFile(line);
|
|
33209
|
+
ringBuffer.push({ ts: Date.now(), level: "error", category: "System", message: clean });
|
|
33210
|
+
if (ringBuffer.length > RING_BUFFER_SIZE) {
|
|
33211
|
+
ringBuffer.splice(0, ringBuffer.length - RING_BUFFER_SIZE);
|
|
33212
|
+
}
|
|
33213
|
+
} catch {
|
|
33214
|
+
}
|
|
33215
|
+
};
|
|
33216
|
+
console.warn = (...args) => {
|
|
33217
|
+
origConsoleWarn(...args);
|
|
33218
|
+
try {
|
|
33219
|
+
const msg = args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ");
|
|
33220
|
+
const clean = stripAnsi4(msg);
|
|
33221
|
+
if (isDaemonLogLine(clean)) return;
|
|
33222
|
+
const line = `[${fullTs()}] [WARN] ${clean}`;
|
|
33223
|
+
writeToFile(line);
|
|
33224
|
+
ringBuffer.push({ ts: Date.now(), level: "warn", category: "System", message: clean });
|
|
33225
|
+
if (ringBuffer.length > RING_BUFFER_SIZE) {
|
|
33226
|
+
ringBuffer.splice(0, ringBuffer.length - RING_BUFFER_SIZE);
|
|
33227
|
+
}
|
|
33228
|
+
} catch {
|
|
33229
|
+
}
|
|
33230
|
+
};
|
|
33231
|
+
writeToFile(`
|
|
33232
|
+
=== ADHDev Daemon started at ${fullTs()} ===`);
|
|
33233
|
+
writeToFile(`Log file: ${currentLogFile}`);
|
|
33234
|
+
writeToFile(`Log level: ${currentLevel}`);
|
|
33235
|
+
}
|
|
33236
|
+
function getLogPath() {
|
|
33237
|
+
return currentLogFile;
|
|
33238
|
+
}
|
|
33239
|
+
var fs4;
|
|
33240
|
+
var path9;
|
|
33241
|
+
var os32;
|
|
33242
|
+
var LEVEL_NUM;
|
|
33243
|
+
var LEVEL_LABEL;
|
|
33244
|
+
var currentLevel;
|
|
33245
|
+
var LOG_DIR;
|
|
33246
|
+
var MAX_LOG_SIZE;
|
|
33247
|
+
var MAX_LOG_DAYS;
|
|
33248
|
+
var currentDate;
|
|
33249
|
+
var currentLogFile;
|
|
33250
|
+
var writeCount;
|
|
33251
|
+
var RING_BUFFER_SIZE;
|
|
33252
|
+
var ringBuffer;
|
|
33253
|
+
var origConsoleLog;
|
|
33254
|
+
var origConsoleError;
|
|
33255
|
+
var origConsoleWarn;
|
|
33256
|
+
var LOG2;
|
|
33257
|
+
var interceptorInstalled;
|
|
33258
|
+
var LOG_PATH;
|
|
33259
|
+
var LOG_DIR_PATH;
|
|
33260
|
+
var init_logger = __esm2({
|
|
33261
|
+
"src/logging/logger.ts"() {
|
|
33262
|
+
"use strict";
|
|
33263
|
+
fs4 = __toESM2(require("fs"));
|
|
33264
|
+
path9 = __toESM2(require("path"));
|
|
33265
|
+
os32 = __toESM2(require("os"));
|
|
33266
|
+
init_async_batch_writer();
|
|
33267
|
+
LEVEL_NUM = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
33268
|
+
LEVEL_LABEL = { debug: "DBG", info: "INF", warn: "WRN", error: "ERR" };
|
|
33269
|
+
currentLevel = "info";
|
|
33270
|
+
LOG_DIR = process.platform === "win32" ? path9.join(process.env.LOCALAPPDATA || process.env.APPDATA || path9.join(os32.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path9.join(os32.homedir(), "Library", "Logs", "adhdev") : path9.join(os32.homedir(), ".local", "share", "adhdev", "logs");
|
|
33271
|
+
MAX_LOG_SIZE = 5 * 1024 * 1024;
|
|
33272
|
+
MAX_LOG_DAYS = 7;
|
|
33273
|
+
try {
|
|
33274
|
+
fs4.mkdirSync(LOG_DIR, { recursive: true });
|
|
33275
|
+
} catch {
|
|
33276
|
+
}
|
|
33277
|
+
currentDate = getDateStr();
|
|
33278
|
+
currentLogFile = path9.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
33279
|
+
cleanOldLogs();
|
|
33280
|
+
try {
|
|
33281
|
+
const oldLog = path9.join(LOG_DIR, "daemon.log");
|
|
33282
|
+
if (fs4.existsSync(oldLog)) {
|
|
33283
|
+
const stat2 = fs4.statSync(oldLog);
|
|
33284
|
+
const oldDate = stat2.mtime.toISOString().slice(0, 10);
|
|
33285
|
+
fs4.renameSync(oldLog, path9.join(LOG_DIR, `daemon-${oldDate}.log`));
|
|
33286
|
+
}
|
|
33287
|
+
const oldLogBackup = path9.join(LOG_DIR, "daemon.log.old");
|
|
33288
|
+
if (fs4.existsSync(oldLogBackup)) {
|
|
33289
|
+
fs4.unlinkSync(oldLogBackup);
|
|
33290
|
+
}
|
|
33291
|
+
} catch {
|
|
33292
|
+
}
|
|
33293
|
+
writeCount = 0;
|
|
33294
|
+
RING_BUFFER_SIZE = 200;
|
|
33295
|
+
ringBuffer = [];
|
|
33296
|
+
origConsoleLog = console.log.bind(console);
|
|
33297
|
+
origConsoleError = console.error.bind(console);
|
|
33298
|
+
origConsoleWarn = console.warn.bind(console);
|
|
33299
|
+
LOG2 = {
|
|
33300
|
+
debug: (category, msg) => daemonLog(category, msg, "debug"),
|
|
33301
|
+
info: (category, msg) => daemonLog(category, msg, "info"),
|
|
33302
|
+
warn: (category, msg) => daemonLog(category, msg, "warn"),
|
|
33303
|
+
error: (category, msg) => daemonLog(category, msg, "error"),
|
|
33304
|
+
/**
|
|
33305
|
+
* Create a scoped logger for a specific component.
|
|
33306
|
+
* Category is baked in so callers only pass the message.
|
|
33307
|
+
*/
|
|
33308
|
+
forComponent(category) {
|
|
33309
|
+
return {
|
|
33310
|
+
debug: (msg) => daemonLog(category, msg, "debug"),
|
|
33311
|
+
info: (msg) => daemonLog(category, msg, "info"),
|
|
33312
|
+
warn: (msg) => daemonLog(category, msg, "warn"),
|
|
33313
|
+
error: (msg) => daemonLog(category, msg, "error"),
|
|
33314
|
+
asLogFn: (level = "info") => (msg) => daemonLog(category, msg, level)
|
|
33315
|
+
};
|
|
33316
|
+
}
|
|
33317
|
+
};
|
|
33318
|
+
interceptorInstalled = false;
|
|
33319
|
+
LOG_PATH = path9.join(LOG_DIR, `daemon-${getDateStr()}.log`);
|
|
33320
|
+
LOG_DIR_PATH = LOG_DIR;
|
|
33321
|
+
}
|
|
33322
|
+
});
|
|
32974
33323
|
var mesh_work_queue_exports = {};
|
|
32975
33324
|
__export2(mesh_work_queue_exports, {
|
|
32976
33325
|
ACTIVE_MESH_QUEUE_STATUSES: () => ACTIVE_MESH_QUEUE_STATUSES,
|
|
@@ -33434,11 +33783,18 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
33434
33783
|
}
|
|
33435
33784
|
function updateSessionTaskStatus(meshId, sessionId, status, opts) {
|
|
33436
33785
|
return withQueueLock(meshId, () => {
|
|
33786
|
+
const store = MeshRuntimeStore.getInstance();
|
|
33437
33787
|
const occurredAtIso = opts?.occurredAt ? new Date(opts.occurredAt).toISOString() : void 0;
|
|
33438
|
-
const entry =
|
|
33439
|
-
if (!entry)
|
|
33788
|
+
const entry = store.findAssignedBySession(meshId, sessionId, occurredAtIso, opts?.taskId);
|
|
33789
|
+
if (!entry) {
|
|
33790
|
+
const assignedRows = store.getActiveAssignmentDetails(meshId).filter((r) => r.sessionId === sessionId);
|
|
33791
|
+
if (assignedRows.length > 0) {
|
|
33792
|
+
LOG2.warn("MeshQueue", `No assigned queue row matched completion for mesh ${meshId} session ${sessionId} (taskId=${opts?.taskId ?? "none"}, occurredAt=${occurredAtIso ?? "none"}); ${assignedRows.length} assigned row(s) exist: ${assignedRows.map((r) => r.id).join(",")}`);
|
|
33793
|
+
}
|
|
33794
|
+
return null;
|
|
33795
|
+
}
|
|
33440
33796
|
entry.status = status;
|
|
33441
|
-
|
|
33797
|
+
store.updateQueueEntry(entry);
|
|
33442
33798
|
if (DEPENDENCY_FAILURE_TERMINALS.has(status)) propagateDependencyFailure(meshId, entry.id);
|
|
33443
33799
|
return entry;
|
|
33444
33800
|
});
|
|
@@ -33556,6 +33912,7 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
33556
33912
|
init_repo_mesh_types();
|
|
33557
33913
|
init_mesh_runtime_store();
|
|
33558
33914
|
init_mesh_config();
|
|
33915
|
+
init_logger();
|
|
33559
33916
|
ACTIVE_MESH_QUEUE_STATUSES = ["pending", "assigned"];
|
|
33560
33917
|
HISTORICAL_MESH_QUEUE_STATUSES = ["completed", "failed", "cancelled"];
|
|
33561
33918
|
MESH_TASK_MODES = ["code_change", "validation", "live_debug_readonly", "launch_app", "convergence"];
|
|
@@ -33612,8 +33969,7 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
33612
33969
|
});
|
|
33613
33970
|
function loadDatabaseCtor() {
|
|
33614
33971
|
if (DatabaseCtor) return DatabaseCtor;
|
|
33615
|
-
|
|
33616
|
-
DatabaseCtor = runtimeRequire("better-sqlite3");
|
|
33972
|
+
DatabaseCtor = loadBetterSqlite3();
|
|
33617
33973
|
return DatabaseCtor;
|
|
33618
33974
|
}
|
|
33619
33975
|
function safeMeshId(meshId) {
|
|
@@ -33642,8 +33998,6 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
33642
33998
|
}
|
|
33643
33999
|
var import_fs5;
|
|
33644
34000
|
var import_path5;
|
|
33645
|
-
var import_module;
|
|
33646
|
-
var import_meta;
|
|
33647
34001
|
var DatabaseCtor;
|
|
33648
34002
|
var MeshRuntimeStore;
|
|
33649
34003
|
var init_mesh_runtime_store = __esm2({
|
|
@@ -33651,10 +34005,9 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
33651
34005
|
"use strict";
|
|
33652
34006
|
import_fs5 = require("fs");
|
|
33653
34007
|
import_path5 = require("path");
|
|
33654
|
-
|
|
34008
|
+
init_load_better_sqlite3();
|
|
33655
34009
|
init_mesh_ledger();
|
|
33656
34010
|
init_mesh_work_queue();
|
|
33657
|
-
import_meta = {};
|
|
33658
34011
|
MeshRuntimeStore = class _MeshRuntimeStore {
|
|
33659
34012
|
static instance;
|
|
33660
34013
|
db;
|
|
@@ -34219,12 +34572,51 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
34219
34572
|
return { id, nodeId: r.assigned_node_id ?? void 0, sessionId: r.assigned_session_id ?? void 0, message };
|
|
34220
34573
|
});
|
|
34221
34574
|
}
|
|
34222
|
-
|
|
34575
|
+
/**
|
|
34576
|
+
* Resolve the `assigned` queue row a completion event belongs to.
|
|
34577
|
+
*
|
|
34578
|
+
* Clock-skew safety (C2): a completion event's `occurredAtIso` carries the
|
|
34579
|
+
* REMOTE WORKER's clock, while `updated_at` carries the COORDINATOR's clock
|
|
34580
|
+
* (set at assignment and re-bumped on every mutation). For a remote node,
|
|
34581
|
+
* coordinator-clock > worker-clock skew used to make an `updated_at <= occurredAt`
|
|
34582
|
+
* filter return nothing, stranding the finished task as `assigned` forever.
|
|
34583
|
+
*
|
|
34584
|
+
* We therefore NEVER filter completion-matching on the mutable `updated_at`:
|
|
34585
|
+
* 1. If `taskId` is given, match the exact `assigned` row by id (no time filter).
|
|
34586
|
+
* 2. Otherwise a session holds at most one `assigned` task — match it without a
|
|
34587
|
+
* time filter. If several exist (shouldn't normally), disambiguate by the
|
|
34588
|
+
* IMMUTABLE `dispatchTimestamp`: latest `dispatchTimestamp <= occurredAt`,
|
|
34589
|
+
* and if skew makes ALL of them later than `occurredAt`, fall back to the
|
|
34590
|
+
* most-recent `dispatchTimestamp` rather than returning null.
|
|
34591
|
+
*/
|
|
34592
|
+
findAssignedBySession(meshId, sessionId, occurredAtIso, taskId) {
|
|
34223
34593
|
this.ensureLegacyQueueMigrated(meshId);
|
|
34224
|
-
|
|
34225
|
-
|
|
34226
|
-
|
|
34227
|
-
|
|
34594
|
+
if (taskId) {
|
|
34595
|
+
const row = this.db.prepare(
|
|
34596
|
+
`SELECT payload FROM mesh_queue WHERE mesh_id = ? AND assigned_session_id = ? AND status = 'assigned' AND id = ? LIMIT 1`
|
|
34597
|
+
).get(meshId, sessionId, taskId);
|
|
34598
|
+
if (row) return JSON.parse(row.payload);
|
|
34599
|
+
}
|
|
34600
|
+
const rows = this.db.prepare(
|
|
34601
|
+
`SELECT payload FROM mesh_queue WHERE mesh_id = ? AND assigned_session_id = ? AND status = 'assigned'`
|
|
34602
|
+
).all(meshId, sessionId);
|
|
34603
|
+
if (rows.length === 0) return null;
|
|
34604
|
+
const entries = rows.map((r) => {
|
|
34605
|
+
try {
|
|
34606
|
+
return JSON.parse(r.payload);
|
|
34607
|
+
} catch {
|
|
34608
|
+
return null;
|
|
34609
|
+
}
|
|
34610
|
+
}).filter((e) => e !== null);
|
|
34611
|
+
if (entries.length === 0) return null;
|
|
34612
|
+
if (entries.length === 1) return entries[0];
|
|
34613
|
+
const orderKey = (e) => e.dispatchTimestamp ?? e.updatedAt ?? "";
|
|
34614
|
+
const byDispatchDesc = [...entries].sort((a, b) => orderKey(b).localeCompare(orderKey(a)));
|
|
34615
|
+
if (occurredAtIso) {
|
|
34616
|
+
const atOrBefore = byDispatchDesc.find((e) => orderKey(e) <= occurredAtIso);
|
|
34617
|
+
if (atOrBefore) return atOrBefore;
|
|
34618
|
+
}
|
|
34619
|
+
return byDispatchDesc[0];
|
|
34228
34620
|
}
|
|
34229
34621
|
toRow(entry) {
|
|
34230
34622
|
return {
|
|
@@ -35475,314 +35867,6 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
35475
35867
|
MAX_CHANGED_FILES = 100;
|
|
35476
35868
|
}
|
|
35477
35869
|
});
|
|
35478
|
-
var fs32;
|
|
35479
|
-
var AsyncBatchWriter;
|
|
35480
|
-
var init_async_batch_writer = __esm2({
|
|
35481
|
-
"src/logging/async-batch-writer.ts"() {
|
|
35482
|
-
"use strict";
|
|
35483
|
-
fs32 = __toESM2(require("fs"));
|
|
35484
|
-
AsyncBatchWriter = class {
|
|
35485
|
-
// Maps filePath -> string buffer
|
|
35486
|
-
static buffers = /* @__PURE__ */ new Map();
|
|
35487
|
-
static writePromises = /* @__PURE__ */ new Map();
|
|
35488
|
-
static flushTimer = null;
|
|
35489
|
-
/**
|
|
35490
|
-
* Queues data to be written to a file asynchronously in a batch.
|
|
35491
|
-
*/
|
|
35492
|
-
static write(filePath, data) {
|
|
35493
|
-
let buf = this.buffers.get(filePath);
|
|
35494
|
-
if (!buf) {
|
|
35495
|
-
buf = [];
|
|
35496
|
-
this.buffers.set(filePath, buf);
|
|
35497
|
-
}
|
|
35498
|
-
buf.push(data);
|
|
35499
|
-
if (!this.flushTimer) {
|
|
35500
|
-
this.flushTimer = setTimeout(() => {
|
|
35501
|
-
this.flushTimer = null;
|
|
35502
|
-
this.flushAll();
|
|
35503
|
-
}, 50);
|
|
35504
|
-
}
|
|
35505
|
-
}
|
|
35506
|
-
static async flushAll() {
|
|
35507
|
-
const entries = Array.from(this.buffers.entries());
|
|
35508
|
-
this.buffers.clear();
|
|
35509
|
-
for (const [filePath, buffer] of entries) {
|
|
35510
|
-
const dataToWrite = buffer.join("");
|
|
35511
|
-
const doWrite = async () => {
|
|
35512
|
-
try {
|
|
35513
|
-
const prevPromise = this.writePromises.get(filePath);
|
|
35514
|
-
if (prevPromise) await prevPromise;
|
|
35515
|
-
await fs32.promises.appendFile(filePath, dataToWrite, { encoding: "utf-8", mode: 384 });
|
|
35516
|
-
} catch {
|
|
35517
|
-
}
|
|
35518
|
-
};
|
|
35519
|
-
const writePromise = doWrite();
|
|
35520
|
-
this.writePromises.set(filePath, writePromise);
|
|
35521
|
-
writePromise.finally(() => {
|
|
35522
|
-
if (this.writePromises.get(filePath) === writePromise) {
|
|
35523
|
-
this.writePromises.delete(filePath);
|
|
35524
|
-
}
|
|
35525
|
-
});
|
|
35526
|
-
}
|
|
35527
|
-
}
|
|
35528
|
-
};
|
|
35529
|
-
}
|
|
35530
|
-
});
|
|
35531
|
-
var logger_exports = {};
|
|
35532
|
-
__export2(logger_exports, {
|
|
35533
|
-
LOG: () => LOG2,
|
|
35534
|
-
LOG_DIR_PATH: () => LOG_DIR_PATH,
|
|
35535
|
-
LOG_PATH: () => LOG_PATH,
|
|
35536
|
-
daemonLog: () => daemonLog,
|
|
35537
|
-
getCurrentDaemonLogPath: () => getCurrentDaemonLogPath,
|
|
35538
|
-
getDaemonLogDir: () => getDaemonLogDir,
|
|
35539
|
-
getLogBufferSize: () => getLogBufferSize,
|
|
35540
|
-
getLogLevel: () => getLogLevel,
|
|
35541
|
-
getLogPath: () => getLogPath,
|
|
35542
|
-
getRecentLogs: () => getRecentLogs,
|
|
35543
|
-
installGlobalInterceptor: () => installGlobalInterceptor,
|
|
35544
|
-
setLogLevel: () => setLogLevel
|
|
35545
|
-
});
|
|
35546
|
-
function setLogLevel(level) {
|
|
35547
|
-
currentLevel = level;
|
|
35548
|
-
daemonLog("Logger", `Log level set to: ${level}`, "info");
|
|
35549
|
-
}
|
|
35550
|
-
function getLogLevel() {
|
|
35551
|
-
return currentLevel;
|
|
35552
|
-
}
|
|
35553
|
-
function getDateStr() {
|
|
35554
|
-
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
35555
|
-
}
|
|
35556
|
-
function getDaemonLogDir() {
|
|
35557
|
-
return LOG_DIR;
|
|
35558
|
-
}
|
|
35559
|
-
function getCurrentDaemonLogPath(date5 = /* @__PURE__ */ new Date()) {
|
|
35560
|
-
return path9.join(LOG_DIR, `daemon-${date5.toISOString().slice(0, 10)}.log`);
|
|
35561
|
-
}
|
|
35562
|
-
function checkDateRotation() {
|
|
35563
|
-
const today = getDateStr();
|
|
35564
|
-
if (today !== currentDate) {
|
|
35565
|
-
currentDate = today;
|
|
35566
|
-
currentLogFile = path9.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
35567
|
-
cleanOldLogs();
|
|
35568
|
-
}
|
|
35569
|
-
}
|
|
35570
|
-
function cleanOldLogs() {
|
|
35571
|
-
try {
|
|
35572
|
-
const files = fs4.readdirSync(LOG_DIR).filter((f) => f.startsWith("daemon-") && f.endsWith(".log"));
|
|
35573
|
-
const cutoff = /* @__PURE__ */ new Date();
|
|
35574
|
-
cutoff.setDate(cutoff.getDate() - MAX_LOG_DAYS);
|
|
35575
|
-
const cutoffStr = cutoff.toISOString().slice(0, 10);
|
|
35576
|
-
for (const file2 of files) {
|
|
35577
|
-
const dateMatch = file2.match(/daemon-(\d{4}-\d{2}-\d{2})/);
|
|
35578
|
-
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
35579
|
-
try {
|
|
35580
|
-
fs4.unlinkSync(path9.join(LOG_DIR, file2));
|
|
35581
|
-
} catch {
|
|
35582
|
-
}
|
|
35583
|
-
}
|
|
35584
|
-
}
|
|
35585
|
-
} catch {
|
|
35586
|
-
}
|
|
35587
|
-
}
|
|
35588
|
-
function rotateSizeIfNeeded() {
|
|
35589
|
-
try {
|
|
35590
|
-
const stat2 = fs4.statSync(currentLogFile);
|
|
35591
|
-
if (stat2.size > MAX_LOG_SIZE) {
|
|
35592
|
-
const backup = currentLogFile.replace(".log", ".1.log");
|
|
35593
|
-
try {
|
|
35594
|
-
fs4.unlinkSync(backup);
|
|
35595
|
-
} catch {
|
|
35596
|
-
}
|
|
35597
|
-
fs4.renameSync(currentLogFile, backup);
|
|
35598
|
-
}
|
|
35599
|
-
} catch {
|
|
35600
|
-
}
|
|
35601
|
-
}
|
|
35602
|
-
function writeToFile(line) {
|
|
35603
|
-
try {
|
|
35604
|
-
if (++writeCount % 1e3 === 0) {
|
|
35605
|
-
checkDateRotation();
|
|
35606
|
-
rotateSizeIfNeeded();
|
|
35607
|
-
}
|
|
35608
|
-
AsyncBatchWriter.write(currentLogFile, line + "\n");
|
|
35609
|
-
} catch {
|
|
35610
|
-
}
|
|
35611
|
-
}
|
|
35612
|
-
function getRecentLogs(count = 50, minLevel = "info") {
|
|
35613
|
-
const minNum = LEVEL_NUM[minLevel];
|
|
35614
|
-
const filtered = ringBuffer.filter((e) => LEVEL_NUM[e.level] >= minNum);
|
|
35615
|
-
return filtered.slice(-count);
|
|
35616
|
-
}
|
|
35617
|
-
function getLogBufferSize() {
|
|
35618
|
-
return ringBuffer.length;
|
|
35619
|
-
}
|
|
35620
|
-
function ts() {
|
|
35621
|
-
return (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
|
|
35622
|
-
}
|
|
35623
|
-
function fullTs() {
|
|
35624
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
35625
|
-
}
|
|
35626
|
-
function daemonLog(category, msg, level = "info") {
|
|
35627
|
-
const shouldOutput = LEVEL_NUM[level] >= LEVEL_NUM[currentLevel];
|
|
35628
|
-
const label = LEVEL_LABEL[level];
|
|
35629
|
-
const line = `[${ts()}] [${label}] [${category}] ${msg}`;
|
|
35630
|
-
if (!shouldOutput) return;
|
|
35631
|
-
writeToFile(line);
|
|
35632
|
-
ringBuffer.push({ ts: Date.now(), level, category, message: msg });
|
|
35633
|
-
if (ringBuffer.length > RING_BUFFER_SIZE) {
|
|
35634
|
-
ringBuffer.splice(0, ringBuffer.length - RING_BUFFER_SIZE);
|
|
35635
|
-
}
|
|
35636
|
-
origConsoleLog(line);
|
|
35637
|
-
}
|
|
35638
|
-
function installGlobalInterceptor() {
|
|
35639
|
-
if (interceptorInstalled) return;
|
|
35640
|
-
interceptorInstalled = true;
|
|
35641
|
-
const stripAnsi4 = (str) => str.replace(/\x1B\[[0-9;]*m/g, "");
|
|
35642
|
-
const isDaemonLogLine = (msg) => /\[(DBG|INF|WRN|ERR)\]/.test(msg);
|
|
35643
|
-
console.log = (...args) => {
|
|
35644
|
-
origConsoleLog(...args);
|
|
35645
|
-
try {
|
|
35646
|
-
const msg = args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ");
|
|
35647
|
-
const clean = stripAnsi4(msg);
|
|
35648
|
-
if (isDaemonLogLine(clean)) return;
|
|
35649
|
-
const line = clean.startsWith("[20") ? clean : `[${fullTs()}] ${clean}`;
|
|
35650
|
-
writeToFile(line);
|
|
35651
|
-
const catMatch = clean.match(/\[([^\]]+)\]/);
|
|
35652
|
-
ringBuffer.push({
|
|
35653
|
-
ts: Date.now(),
|
|
35654
|
-
level: "info",
|
|
35655
|
-
category: catMatch?.[1] || "System",
|
|
35656
|
-
message: clean
|
|
35657
|
-
});
|
|
35658
|
-
if (ringBuffer.length > RING_BUFFER_SIZE) {
|
|
35659
|
-
ringBuffer.splice(0, ringBuffer.length - RING_BUFFER_SIZE);
|
|
35660
|
-
}
|
|
35661
|
-
} catch {
|
|
35662
|
-
}
|
|
35663
|
-
};
|
|
35664
|
-
console.error = (...args) => {
|
|
35665
|
-
origConsoleError(...args);
|
|
35666
|
-
try {
|
|
35667
|
-
const msg = args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ");
|
|
35668
|
-
const clean = stripAnsi4(msg);
|
|
35669
|
-
if (isDaemonLogLine(clean)) return;
|
|
35670
|
-
const line = `[${fullTs()}] [ERROR] ${clean}`;
|
|
35671
|
-
writeToFile(line);
|
|
35672
|
-
ringBuffer.push({ ts: Date.now(), level: "error", category: "System", message: clean });
|
|
35673
|
-
if (ringBuffer.length > RING_BUFFER_SIZE) {
|
|
35674
|
-
ringBuffer.splice(0, ringBuffer.length - RING_BUFFER_SIZE);
|
|
35675
|
-
}
|
|
35676
|
-
} catch {
|
|
35677
|
-
}
|
|
35678
|
-
};
|
|
35679
|
-
console.warn = (...args) => {
|
|
35680
|
-
origConsoleWarn(...args);
|
|
35681
|
-
try {
|
|
35682
|
-
const msg = args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ");
|
|
35683
|
-
const clean = stripAnsi4(msg);
|
|
35684
|
-
if (isDaemonLogLine(clean)) return;
|
|
35685
|
-
const line = `[${fullTs()}] [WARN] ${clean}`;
|
|
35686
|
-
writeToFile(line);
|
|
35687
|
-
ringBuffer.push({ ts: Date.now(), level: "warn", category: "System", message: clean });
|
|
35688
|
-
if (ringBuffer.length > RING_BUFFER_SIZE) {
|
|
35689
|
-
ringBuffer.splice(0, ringBuffer.length - RING_BUFFER_SIZE);
|
|
35690
|
-
}
|
|
35691
|
-
} catch {
|
|
35692
|
-
}
|
|
35693
|
-
};
|
|
35694
|
-
writeToFile(`
|
|
35695
|
-
=== ADHDev Daemon started at ${fullTs()} ===`);
|
|
35696
|
-
writeToFile(`Log file: ${currentLogFile}`);
|
|
35697
|
-
writeToFile(`Log level: ${currentLevel}`);
|
|
35698
|
-
}
|
|
35699
|
-
function getLogPath() {
|
|
35700
|
-
return currentLogFile;
|
|
35701
|
-
}
|
|
35702
|
-
var fs4;
|
|
35703
|
-
var path9;
|
|
35704
|
-
var os32;
|
|
35705
|
-
var LEVEL_NUM;
|
|
35706
|
-
var LEVEL_LABEL;
|
|
35707
|
-
var currentLevel;
|
|
35708
|
-
var LOG_DIR;
|
|
35709
|
-
var MAX_LOG_SIZE;
|
|
35710
|
-
var MAX_LOG_DAYS;
|
|
35711
|
-
var currentDate;
|
|
35712
|
-
var currentLogFile;
|
|
35713
|
-
var writeCount;
|
|
35714
|
-
var RING_BUFFER_SIZE;
|
|
35715
|
-
var ringBuffer;
|
|
35716
|
-
var origConsoleLog;
|
|
35717
|
-
var origConsoleError;
|
|
35718
|
-
var origConsoleWarn;
|
|
35719
|
-
var LOG2;
|
|
35720
|
-
var interceptorInstalled;
|
|
35721
|
-
var LOG_PATH;
|
|
35722
|
-
var LOG_DIR_PATH;
|
|
35723
|
-
var init_logger = __esm2({
|
|
35724
|
-
"src/logging/logger.ts"() {
|
|
35725
|
-
"use strict";
|
|
35726
|
-
fs4 = __toESM2(require("fs"));
|
|
35727
|
-
path9 = __toESM2(require("path"));
|
|
35728
|
-
os32 = __toESM2(require("os"));
|
|
35729
|
-
init_async_batch_writer();
|
|
35730
|
-
LEVEL_NUM = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
35731
|
-
LEVEL_LABEL = { debug: "DBG", info: "INF", warn: "WRN", error: "ERR" };
|
|
35732
|
-
currentLevel = "info";
|
|
35733
|
-
LOG_DIR = process.platform === "win32" ? path9.join(process.env.LOCALAPPDATA || process.env.APPDATA || path9.join(os32.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path9.join(os32.homedir(), "Library", "Logs", "adhdev") : path9.join(os32.homedir(), ".local", "share", "adhdev", "logs");
|
|
35734
|
-
MAX_LOG_SIZE = 5 * 1024 * 1024;
|
|
35735
|
-
MAX_LOG_DAYS = 7;
|
|
35736
|
-
try {
|
|
35737
|
-
fs4.mkdirSync(LOG_DIR, { recursive: true });
|
|
35738
|
-
} catch {
|
|
35739
|
-
}
|
|
35740
|
-
currentDate = getDateStr();
|
|
35741
|
-
currentLogFile = path9.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
35742
|
-
cleanOldLogs();
|
|
35743
|
-
try {
|
|
35744
|
-
const oldLog = path9.join(LOG_DIR, "daemon.log");
|
|
35745
|
-
if (fs4.existsSync(oldLog)) {
|
|
35746
|
-
const stat2 = fs4.statSync(oldLog);
|
|
35747
|
-
const oldDate = stat2.mtime.toISOString().slice(0, 10);
|
|
35748
|
-
fs4.renameSync(oldLog, path9.join(LOG_DIR, `daemon-${oldDate}.log`));
|
|
35749
|
-
}
|
|
35750
|
-
const oldLogBackup = path9.join(LOG_DIR, "daemon.log.old");
|
|
35751
|
-
if (fs4.existsSync(oldLogBackup)) {
|
|
35752
|
-
fs4.unlinkSync(oldLogBackup);
|
|
35753
|
-
}
|
|
35754
|
-
} catch {
|
|
35755
|
-
}
|
|
35756
|
-
writeCount = 0;
|
|
35757
|
-
RING_BUFFER_SIZE = 200;
|
|
35758
|
-
ringBuffer = [];
|
|
35759
|
-
origConsoleLog = console.log.bind(console);
|
|
35760
|
-
origConsoleError = console.error.bind(console);
|
|
35761
|
-
origConsoleWarn = console.warn.bind(console);
|
|
35762
|
-
LOG2 = {
|
|
35763
|
-
debug: (category, msg) => daemonLog(category, msg, "debug"),
|
|
35764
|
-
info: (category, msg) => daemonLog(category, msg, "info"),
|
|
35765
|
-
warn: (category, msg) => daemonLog(category, msg, "warn"),
|
|
35766
|
-
error: (category, msg) => daemonLog(category, msg, "error"),
|
|
35767
|
-
/**
|
|
35768
|
-
* Create a scoped logger for a specific component.
|
|
35769
|
-
* Category is baked in so callers only pass the message.
|
|
35770
|
-
*/
|
|
35771
|
-
forComponent(category) {
|
|
35772
|
-
return {
|
|
35773
|
-
debug: (msg) => daemonLog(category, msg, "debug"),
|
|
35774
|
-
info: (msg) => daemonLog(category, msg, "info"),
|
|
35775
|
-
warn: (msg) => daemonLog(category, msg, "warn"),
|
|
35776
|
-
error: (msg) => daemonLog(category, msg, "error"),
|
|
35777
|
-
asLogFn: (level = "info") => (msg) => daemonLog(category, msg, level)
|
|
35778
|
-
};
|
|
35779
|
-
}
|
|
35780
|
-
};
|
|
35781
|
-
interceptorInstalled = false;
|
|
35782
|
-
LOG_PATH = path9.join(LOG_DIR, `daemon-${getDateStr()}.log`);
|
|
35783
|
-
LOG_DIR_PATH = LOG_DIR;
|
|
35784
|
-
}
|
|
35785
|
-
});
|
|
35786
35870
|
var mesh_coordinator_exports = {};
|
|
35787
35871
|
__export2(mesh_coordinator_exports, {
|
|
35788
35872
|
applyMeshCoordinatorSystemPromptInjection: () => applyMeshCoordinatorSystemPromptInjection,
|
|
@@ -36190,6 +36274,61 @@ ${rendered}`, "utf-8");
|
|
|
36190
36274
|
HERMES_MCP_CONFIG_PATH = "~/.hermes/config.yaml";
|
|
36191
36275
|
}
|
|
36192
36276
|
});
|
|
36277
|
+
function resolveWin32GlobalBin(trimmed) {
|
|
36278
|
+
if (path10.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\")) {
|
|
36279
|
+
return null;
|
|
36280
|
+
}
|
|
36281
|
+
const extraDirs = [];
|
|
36282
|
+
if (process.env.APPDATA) extraDirs.push(path10.join(process.env.APPDATA, "npm"));
|
|
36283
|
+
try {
|
|
36284
|
+
extraDirs.push(path10.dirname(process.execPath));
|
|
36285
|
+
} catch {
|
|
36286
|
+
}
|
|
36287
|
+
for (const dir of extraDirs) {
|
|
36288
|
+
if (!dir) continue;
|
|
36289
|
+
for (const ext of WIN_EXEC_EXT) {
|
|
36290
|
+
const full = path10.join(dir, trimmed + ext);
|
|
36291
|
+
if ((0, import_fs8.existsSync)(full)) return full;
|
|
36292
|
+
}
|
|
36293
|
+
}
|
|
36294
|
+
return null;
|
|
36295
|
+
}
|
|
36296
|
+
function resolveWin32Executable(command) {
|
|
36297
|
+
if (process.platform !== "win32") return command;
|
|
36298
|
+
const trimmed = (command || "").trim();
|
|
36299
|
+
if (!trimmed) return command;
|
|
36300
|
+
if (path10.isAbsolute(trimmed) && (0, import_fs8.existsSync)(trimmed)) return trimmed;
|
|
36301
|
+
try {
|
|
36302
|
+
const out = (0, import_child_process.execFileSync)("where", [trimmed], {
|
|
36303
|
+
encoding: "utf8",
|
|
36304
|
+
windowsHide: true
|
|
36305
|
+
}).trim();
|
|
36306
|
+
if (out) {
|
|
36307
|
+
const matches = out.split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
|
|
36308
|
+
const direct = matches.find((m) => DIRECT_EXEC_EXT.has(path10.extname(m).toLowerCase()));
|
|
36309
|
+
return direct || matches[0] || command;
|
|
36310
|
+
}
|
|
36311
|
+
} catch {
|
|
36312
|
+
}
|
|
36313
|
+
const globalBin = resolveWin32GlobalBin(trimmed);
|
|
36314
|
+
if (globalBin) return globalBin;
|
|
36315
|
+
return command;
|
|
36316
|
+
}
|
|
36317
|
+
var import_child_process;
|
|
36318
|
+
var import_fs8;
|
|
36319
|
+
var path10;
|
|
36320
|
+
var DIRECT_EXEC_EXT;
|
|
36321
|
+
var WIN_EXEC_EXT;
|
|
36322
|
+
var init_resolve_executable = __esm2({
|
|
36323
|
+
"src/cli-adapters/resolve-executable.ts"() {
|
|
36324
|
+
"use strict";
|
|
36325
|
+
import_child_process = require("child_process");
|
|
36326
|
+
import_fs8 = require("fs");
|
|
36327
|
+
path10 = __toESM2(require("path"));
|
|
36328
|
+
DIRECT_EXEC_EXT = /* @__PURE__ */ new Set([".exe", ".com"]);
|
|
36329
|
+
WIN_EXEC_EXT = [".exe", ".com", ".cmd", ".bat"];
|
|
36330
|
+
}
|
|
36331
|
+
});
|
|
36193
36332
|
async function fastForwardMeshNode(args) {
|
|
36194
36333
|
const workspace = typeof args.workspace === "string" ? args.workspace.trim() : "";
|
|
36195
36334
|
const nodeId = normalizeOptionalString(args.nodeId);
|
|
@@ -37706,9 +37845,9 @@ Next step: ${nextStep}`;
|
|
|
37706
37845
|
const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
37707
37846
|
const events = [];
|
|
37708
37847
|
for (const path422 of paths) {
|
|
37709
|
-
if (!(0,
|
|
37848
|
+
if (!(0, import_fs10.existsSync)(path422)) continue;
|
|
37710
37849
|
try {
|
|
37711
|
-
const raw = (0,
|
|
37850
|
+
const raw = (0, import_fs10.readFileSync)(path422, "utf-8");
|
|
37712
37851
|
const parsed = raw.split("\n").filter(Boolean).flatMap((line) => {
|
|
37713
37852
|
try {
|
|
37714
37853
|
return [JSON.parse(line)];
|
|
@@ -37783,11 +37922,11 @@ Next step: ${nextStep}`;
|
|
|
37783
37922
|
}
|
|
37784
37923
|
function trimPendingEventsIfNeeded(path422) {
|
|
37785
37924
|
try {
|
|
37786
|
-
if (!(0,
|
|
37787
|
-
if ((0,
|
|
37788
|
-
const lines = (0,
|
|
37925
|
+
if (!(0, import_fs10.existsSync)(path422)) return;
|
|
37926
|
+
if ((0, import_fs10.statSync)(path422).size <= MAX_PENDING_EVENTS_BYTES) return;
|
|
37927
|
+
const lines = (0, import_fs10.readFileSync)(path422, "utf-8").split("\n").filter(Boolean);
|
|
37789
37928
|
if (lines.length <= MAX_PENDING_EVENTS_KEEP) return;
|
|
37790
|
-
(0,
|
|
37929
|
+
(0, import_fs10.writeFileSync)(path422, lines.slice(-MAX_PENDING_EVENTS_KEEP).join("\n") + "\n", "utf-8");
|
|
37791
37930
|
} catch {
|
|
37792
37931
|
}
|
|
37793
37932
|
}
|
|
@@ -37816,7 +37955,7 @@ Next step: ${nextStep}`;
|
|
|
37816
37955
|
}
|
|
37817
37956
|
const path422 = getPendingEventsPath(event.meshId, event.targetCoordinatorDaemonId);
|
|
37818
37957
|
trimPendingEventsIfNeeded(path422);
|
|
37819
|
-
(0,
|
|
37958
|
+
(0, import_fs10.appendFileSync)(path422, JSON.stringify(event) + "\n", "utf-8");
|
|
37820
37959
|
return true;
|
|
37821
37960
|
} catch (e) {
|
|
37822
37961
|
LOG2.warn("MeshEvents", `Failed to persist pending coordinator event: ${e?.message || e}`);
|
|
@@ -37826,20 +37965,20 @@ Next step: ${nextStep}`;
|
|
|
37826
37965
|
function atomicDrainFile(path422) {
|
|
37827
37966
|
const tmpPath = `${path422}.draining`;
|
|
37828
37967
|
try {
|
|
37829
|
-
(0,
|
|
37968
|
+
(0, import_fs10.renameSync)(path422, tmpPath);
|
|
37830
37969
|
} catch {
|
|
37831
37970
|
return null;
|
|
37832
37971
|
}
|
|
37833
37972
|
try {
|
|
37834
|
-
const content = (0,
|
|
37973
|
+
const content = (0, import_fs10.readFileSync)(tmpPath, "utf-8");
|
|
37835
37974
|
try {
|
|
37836
|
-
(0,
|
|
37975
|
+
(0, import_fs10.unlinkSync)(tmpPath);
|
|
37837
37976
|
} catch {
|
|
37838
37977
|
}
|
|
37839
37978
|
return content;
|
|
37840
37979
|
} catch {
|
|
37841
37980
|
try {
|
|
37842
|
-
(0,
|
|
37981
|
+
(0, import_fs10.unlinkSync)(tmpPath);
|
|
37843
37982
|
} catch {
|
|
37844
37983
|
}
|
|
37845
37984
|
return null;
|
|
@@ -37848,16 +37987,16 @@ Next step: ${nextStep}`;
|
|
|
37848
37987
|
function selectiveDrainFile(path422, predicate) {
|
|
37849
37988
|
const tmpPath = `${path422}.draining`;
|
|
37850
37989
|
try {
|
|
37851
|
-
(0,
|
|
37990
|
+
(0, import_fs10.renameSync)(path422, tmpPath);
|
|
37852
37991
|
} catch {
|
|
37853
37992
|
return [];
|
|
37854
37993
|
}
|
|
37855
37994
|
let content;
|
|
37856
37995
|
try {
|
|
37857
|
-
content = (0,
|
|
37996
|
+
content = (0, import_fs10.readFileSync)(tmpPath, "utf-8");
|
|
37858
37997
|
} catch {
|
|
37859
37998
|
try {
|
|
37860
|
-
(0,
|
|
37999
|
+
(0, import_fs10.unlinkSync)(tmpPath);
|
|
37861
38000
|
} catch {
|
|
37862
38001
|
}
|
|
37863
38002
|
return [];
|
|
@@ -37880,12 +38019,12 @@ Next step: ${nextStep}`;
|
|
|
37880
38019
|
}
|
|
37881
38020
|
try {
|
|
37882
38021
|
if (keptLines.length > 0) {
|
|
37883
|
-
(0,
|
|
38022
|
+
(0, import_fs10.writeFileSync)(path422, keptLines.join("\n") + "\n", "utf-8");
|
|
37884
38023
|
}
|
|
37885
|
-
(0,
|
|
38024
|
+
(0, import_fs10.unlinkSync)(tmpPath);
|
|
37886
38025
|
} catch {
|
|
37887
38026
|
try {
|
|
37888
|
-
if ((0,
|
|
38027
|
+
if ((0, import_fs10.existsSync)(tmpPath) && !(0, import_fs10.existsSync)(path422)) (0, import_fs10.renameSync)(tmpPath, path422);
|
|
37889
38028
|
} catch {
|
|
37890
38029
|
}
|
|
37891
38030
|
return [];
|
|
@@ -37979,13 +38118,13 @@ Next step: ${nextStep}`;
|
|
|
37979
38118
|
}
|
|
37980
38119
|
const paths = coordinatorDaemonId ? [getPendingEventsPath(meshId, coordinatorDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
37981
38120
|
for (const path422 of paths) {
|
|
37982
|
-
if ((0,
|
|
37983
|
-
(0,
|
|
38121
|
+
if ((0, import_fs10.existsSync)(path422)) try {
|
|
38122
|
+
(0, import_fs10.unlinkSync)(path422);
|
|
37984
38123
|
} catch {
|
|
37985
38124
|
}
|
|
37986
38125
|
}
|
|
37987
38126
|
}
|
|
37988
|
-
var
|
|
38127
|
+
var import_fs10;
|
|
37989
38128
|
var import_path9;
|
|
37990
38129
|
var import_crypto7;
|
|
37991
38130
|
var REFINE_TERMINAL_EVENTS;
|
|
@@ -37994,7 +38133,7 @@ Next step: ${nextStep}`;
|
|
|
37994
38133
|
var init_mesh_events_pending = __esm2({
|
|
37995
38134
|
"src/mesh/mesh-events-pending.ts"() {
|
|
37996
38135
|
"use strict";
|
|
37997
|
-
|
|
38136
|
+
import_fs10 = require("fs");
|
|
37998
38137
|
import_path9 = require("path");
|
|
37999
38138
|
import_crypto7 = require("crypto");
|
|
38000
38139
|
init_logger();
|
|
@@ -38484,24 +38623,24 @@ Next step: ${nextStep}`;
|
|
|
38484
38623
|
function findBinary(name) {
|
|
38485
38624
|
const trimmed = String(name || "").trim();
|
|
38486
38625
|
if (!trimmed) return trimmed;
|
|
38487
|
-
const expanded = trimmed.startsWith("~") ?
|
|
38488
|
-
if (
|
|
38489
|
-
return
|
|
38626
|
+
const expanded = trimmed.startsWith("~") ? path11.join(os52.homedir(), trimmed.slice(1)) : trimmed;
|
|
38627
|
+
if (path11.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
|
|
38628
|
+
return path11.isAbsolute(expanded) ? expanded : path11.resolve(expanded);
|
|
38490
38629
|
}
|
|
38491
38630
|
const isWin = os52.platform() === "win32";
|
|
38492
|
-
const paths = (process.env.PATH || "").split(
|
|
38631
|
+
const paths = (process.env.PATH || "").split(path11.delimiter);
|
|
38493
38632
|
const extraDirs = [];
|
|
38494
38633
|
if (isWin) {
|
|
38495
|
-
if (process.env.APPDATA) extraDirs.push(
|
|
38634
|
+
if (process.env.APPDATA) extraDirs.push(path11.join(process.env.APPDATA, "npm"));
|
|
38496
38635
|
try {
|
|
38497
|
-
extraDirs.push(
|
|
38636
|
+
extraDirs.push(path11.dirname(process.execPath));
|
|
38498
38637
|
} catch {
|
|
38499
38638
|
}
|
|
38500
38639
|
} else {
|
|
38501
|
-
extraDirs.push(
|
|
38640
|
+
extraDirs.push(path11.join(os52.homedir(), ".npm-global", "bin"));
|
|
38502
38641
|
extraDirs.push("/usr/local/bin", "/opt/homebrew/bin");
|
|
38503
38642
|
try {
|
|
38504
|
-
extraDirs.push(
|
|
38643
|
+
extraDirs.push(path11.dirname(process.execPath));
|
|
38505
38644
|
} catch {
|
|
38506
38645
|
}
|
|
38507
38646
|
}
|
|
@@ -38510,7 +38649,7 @@ Next step: ${nextStep}`;
|
|
|
38510
38649
|
for (const p of searchDirs) {
|
|
38511
38650
|
if (!p) continue;
|
|
38512
38651
|
for (const ext of exes) {
|
|
38513
|
-
const fullPath =
|
|
38652
|
+
const fullPath = path11.join(p, trimmed + ext);
|
|
38514
38653
|
try {
|
|
38515
38654
|
const fs322 = require("fs");
|
|
38516
38655
|
if (fs322.existsSync(fullPath)) {
|
|
@@ -38526,7 +38665,7 @@ Next step: ${nextStep}`;
|
|
|
38526
38665
|
return isWin ? `${trimmed}.cmd` : trimmed;
|
|
38527
38666
|
}
|
|
38528
38667
|
function isScriptBinary(binaryPath) {
|
|
38529
|
-
if (!
|
|
38668
|
+
if (!path11.isAbsolute(binaryPath)) return false;
|
|
38530
38669
|
try {
|
|
38531
38670
|
const fs322 = require("fs");
|
|
38532
38671
|
const resolved = fs322.realpathSync(binaryPath);
|
|
@@ -38542,7 +38681,7 @@ Next step: ${nextStep}`;
|
|
|
38542
38681
|
}
|
|
38543
38682
|
}
|
|
38544
38683
|
function looksLikeMachOOrElf(filePath) {
|
|
38545
|
-
if (!
|
|
38684
|
+
if (!path11.isAbsolute(filePath)) return false;
|
|
38546
38685
|
try {
|
|
38547
38686
|
const fs322 = require("fs");
|
|
38548
38687
|
const resolved = fs322.realpathSync(filePath);
|
|
@@ -38632,14 +38771,14 @@ Next step: ${nextStep}`;
|
|
|
38632
38771
|
};
|
|
38633
38772
|
}
|
|
38634
38773
|
var os52;
|
|
38635
|
-
var
|
|
38774
|
+
var path11;
|
|
38636
38775
|
var TerminalTranscriptAccumulator;
|
|
38637
38776
|
var buildCliSpawnEnv;
|
|
38638
38777
|
var init_provider_cli_shared = __esm2({
|
|
38639
38778
|
"src/cli-adapters/provider-cli-shared.ts"() {
|
|
38640
38779
|
"use strict";
|
|
38641
38780
|
os52 = __toESM2(require("os"));
|
|
38642
|
-
|
|
38781
|
+
path11 = __toESM2(require("path"));
|
|
38643
38782
|
init_spawn_env();
|
|
38644
38783
|
TerminalTranscriptAccumulator = class {
|
|
38645
38784
|
lines = [[]];
|
|
@@ -38811,19 +38950,19 @@ Next step: ${nextStep}`;
|
|
|
38811
38950
|
function expandHome(value) {
|
|
38812
38951
|
const trimmed = value.trim();
|
|
38813
38952
|
if (!trimmed.startsWith("~")) return trimmed;
|
|
38814
|
-
return
|
|
38953
|
+
return path12.join(os6.homedir(), trimmed.slice(1));
|
|
38815
38954
|
}
|
|
38816
38955
|
function isExplicitCommandPath(command) {
|
|
38817
38956
|
const trimmed = command.trim();
|
|
38818
|
-
return
|
|
38957
|
+
return path12.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
|
|
38819
38958
|
}
|
|
38820
38959
|
function resolveCommandPath(command) {
|
|
38821
38960
|
const trimmed = command.trim();
|
|
38822
38961
|
if (!trimmed) return null;
|
|
38823
38962
|
if (isExplicitCommandPath(trimmed)) {
|
|
38824
38963
|
const expanded = expandHome(trimmed);
|
|
38825
|
-
const candidate =
|
|
38826
|
-
return (0,
|
|
38964
|
+
const candidate = path12.isAbsolute(expanded) ? expanded : path12.resolve(expanded);
|
|
38965
|
+
return (0, import_fs11.existsSync)(candidate) ? candidate : null;
|
|
38827
38966
|
}
|
|
38828
38967
|
return null;
|
|
38829
38968
|
}
|
|
@@ -38833,12 +38972,12 @@ Next step: ${nextStep}`;
|
|
|
38833
38972
|
const whichResult = await execAsync(`${whichCmd} ${shellQuote(command)}`);
|
|
38834
38973
|
if (whichResult) return whichResult.split("\n")[0];
|
|
38835
38974
|
const resolved = findBinary(command);
|
|
38836
|
-
if (
|
|
38975
|
+
if (path12.isAbsolute(resolved) && (0, import_fs11.existsSync)(resolved)) return resolved;
|
|
38837
38976
|
return null;
|
|
38838
38977
|
}
|
|
38839
38978
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
38840
38979
|
return new Promise((resolve24) => {
|
|
38841
|
-
const child = (0,
|
|
38980
|
+
const child = (0, import_child_process2.exec)(cmd, {
|
|
38842
38981
|
encoding: "utf-8",
|
|
38843
38982
|
timeout: timeoutMs,
|
|
38844
38983
|
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
@@ -38928,17 +39067,17 @@ Next step: ${nextStep}`;
|
|
|
38928
39067
|
const all = await detectCLIs(providerLoader, options);
|
|
38929
39068
|
return all.find((c) => c.id === resolvedId && c.installed) || null;
|
|
38930
39069
|
}
|
|
38931
|
-
var
|
|
39070
|
+
var import_child_process2;
|
|
38932
39071
|
var os6;
|
|
38933
|
-
var
|
|
38934
|
-
var
|
|
39072
|
+
var path12;
|
|
39073
|
+
var import_fs11;
|
|
38935
39074
|
var init_cli_detector = __esm2({
|
|
38936
39075
|
"src/detection/cli-detector.ts"() {
|
|
38937
39076
|
"use strict";
|
|
38938
|
-
|
|
39077
|
+
import_child_process2 = require("child_process");
|
|
38939
39078
|
os6 = __toESM2(require("os"));
|
|
38940
|
-
|
|
38941
|
-
|
|
39079
|
+
path12 = __toESM2(require("path"));
|
|
39080
|
+
import_fs11 = require("fs");
|
|
38942
39081
|
init_provider_cli_shared();
|
|
38943
39082
|
}
|
|
38944
39083
|
});
|
|
@@ -39194,8 +39333,8 @@ Next step: ${nextStep}`;
|
|
|
39194
39333
|
}
|
|
39195
39334
|
function getCachedMeshByWorkspace(workspace) {
|
|
39196
39335
|
const now = Date.now();
|
|
39197
|
-
const
|
|
39198
|
-
if (
|
|
39336
|
+
const cached3 = meshByWorkspaceCache.get(workspace);
|
|
39337
|
+
if (cached3 && now - cached3.cachedAt < MESH_WORKSPACE_CACHE_TTL_MS) return cached3.mesh;
|
|
39199
39338
|
const mesh = getMeshByRepo(workspace);
|
|
39200
39339
|
meshByWorkspaceCache.set(workspace, { mesh, cachedAt: now });
|
|
39201
39340
|
return mesh;
|
|
@@ -39971,7 +40110,7 @@ Next step: ${nextStep}`;
|
|
|
39971
40110
|
const node = mesh?.nodes?.find((candidate) => meshNodeIdMatches(candidate, args.nodeId));
|
|
39972
40111
|
const workspace = readNonEmptyString2(node?.workspace);
|
|
39973
40112
|
if (!workspace) return;
|
|
39974
|
-
if (!(0,
|
|
40113
|
+
if (!(0, import_fs12.existsSync)(workspace)) return;
|
|
39975
40114
|
const policy = resolveAutoFastForwardPolicy(mesh);
|
|
39976
40115
|
if (!policy.enabled) return;
|
|
39977
40116
|
if (nodeHasActiveMeshWork(components, args.meshId, args.nodeId, args.sessionId)) return;
|
|
@@ -40170,8 +40309,10 @@ Next step: ${nextStep}`;
|
|
|
40170
40309
|
}
|
|
40171
40310
|
}
|
|
40172
40311
|
function markSessionTerminal(sessionId, outcome, occurredAtMs) {
|
|
40312
|
+
const eventTaskId = readNonEmptyString2(args.metadataEvent.taskId) || void 0;
|
|
40173
40313
|
const task = updateSessionTaskStatus(args.meshId, sessionId, outcome, {
|
|
40174
|
-
occurredAt: occurredAtMs != null ? new Date(occurredAtMs).toISOString() : void 0
|
|
40314
|
+
occurredAt: occurredAtMs != null ? new Date(occurredAtMs).toISOString() : void 0,
|
|
40315
|
+
taskId: eventTaskId
|
|
40175
40316
|
});
|
|
40176
40317
|
updateDirectDispatchStatus(args.meshId, sessionId, outcome);
|
|
40177
40318
|
markSessionDeliveriesTerminal(args.meshId, sessionId, outcome);
|
|
@@ -40582,7 +40723,7 @@ Next step: ${nextStep}`;
|
|
|
40582
40723
|
});
|
|
40583
40724
|
});
|
|
40584
40725
|
}
|
|
40585
|
-
var
|
|
40726
|
+
var import_fs12;
|
|
40586
40727
|
var REMOTE_IDLE_SESSION_TTL_MS;
|
|
40587
40728
|
var meshByWorkspaceCache;
|
|
40588
40729
|
var MESH_WORKSPACE_CACHE_TTL_MS;
|
|
@@ -40602,7 +40743,7 @@ Next step: ${nextStep}`;
|
|
|
40602
40743
|
var init_mesh_events_coordinator = __esm2({
|
|
40603
40744
|
"src/mesh/mesh-events-coordinator.ts"() {
|
|
40604
40745
|
"use strict";
|
|
40605
|
-
|
|
40746
|
+
import_fs12 = require("fs");
|
|
40606
40747
|
init_config();
|
|
40607
40748
|
init_mesh_config();
|
|
40608
40749
|
init_cli_detector();
|
|
@@ -42485,16 +42626,16 @@ Next step: ${nextStep}`;
|
|
|
42485
42626
|
sourcesProviding: () => sourcesProviding
|
|
42486
42627
|
});
|
|
42487
42628
|
function adhdevDir() {
|
|
42488
|
-
return
|
|
42629
|
+
return path18.join(os11.homedir(), ".adhdev");
|
|
42489
42630
|
}
|
|
42490
42631
|
function externalRoot() {
|
|
42491
|
-
return
|
|
42632
|
+
return path18.join(adhdevDir(), "external");
|
|
42492
42633
|
}
|
|
42493
42634
|
function sourcesFilePath() {
|
|
42494
|
-
return
|
|
42635
|
+
return path18.join(adhdevDir(), SOURCES_FILENAME);
|
|
42495
42636
|
}
|
|
42496
42637
|
function activeFilePath() {
|
|
42497
|
-
return
|
|
42638
|
+
return path18.join(adhdevDir(), ACTIVE_FILENAME);
|
|
42498
42639
|
}
|
|
42499
42640
|
function ensureAdhdevDir() {
|
|
42500
42641
|
const d = adhdevDir();
|
|
@@ -42561,7 +42702,7 @@ Next step: ${nextStep}`;
|
|
|
42561
42702
|
for (const sourceEntry of entries) {
|
|
42562
42703
|
if (!sourceEntry.isDirectory()) continue;
|
|
42563
42704
|
const sourceName = sourceEntry.name;
|
|
42564
|
-
const sourceDir =
|
|
42705
|
+
const sourceDir = path18.join(root, sourceName);
|
|
42565
42706
|
const providers = {};
|
|
42566
42707
|
let categoryEntries;
|
|
42567
42708
|
try {
|
|
@@ -42572,7 +42713,7 @@ Next step: ${nextStep}`;
|
|
|
42572
42713
|
for (const categoryEntry of categoryEntries) {
|
|
42573
42714
|
if (!categoryEntry.isDirectory()) continue;
|
|
42574
42715
|
const category = categoryEntry.name;
|
|
42575
|
-
const categoryDir =
|
|
42716
|
+
const categoryDir = path18.join(sourceDir, category);
|
|
42576
42717
|
let typeEntries;
|
|
42577
42718
|
try {
|
|
42578
42719
|
typeEntries = fs9.readdirSync(categoryDir, { withFileTypes: true });
|
|
@@ -42582,9 +42723,9 @@ Next step: ${nextStep}`;
|
|
|
42582
42723
|
const types = [];
|
|
42583
42724
|
for (const typeEntry of typeEntries) {
|
|
42584
42725
|
if (!typeEntry.isDirectory()) continue;
|
|
42585
|
-
const typeDir =
|
|
42586
|
-
const hasV1 = fs9.existsSync(
|
|
42587
|
-
const hasV0 = fs9.existsSync(
|
|
42726
|
+
const typeDir = path18.join(categoryDir, typeEntry.name);
|
|
42727
|
+
const hasV1 = fs9.existsSync(path18.join(typeDir, "provider.v1.json"));
|
|
42728
|
+
const hasV0 = fs9.existsSync(path18.join(typeDir, "provider.json"));
|
|
42588
42729
|
if (hasV1 || hasV0) types.push(typeEntry.name);
|
|
42589
42730
|
}
|
|
42590
42731
|
if (types.length > 0) providers[category] = types;
|
|
@@ -42609,7 +42750,7 @@ Next step: ${nextStep}`;
|
|
|
42609
42750
|
}
|
|
42610
42751
|
var fs9;
|
|
42611
42752
|
var os11;
|
|
42612
|
-
var
|
|
42753
|
+
var path18;
|
|
42613
42754
|
var SOURCES_FILENAME;
|
|
42614
42755
|
var ACTIVE_FILENAME;
|
|
42615
42756
|
var init_external_sources = __esm2({
|
|
@@ -42617,7 +42758,7 @@ Next step: ${nextStep}`;
|
|
|
42617
42758
|
"use strict";
|
|
42618
42759
|
fs9 = __toESM2(require("fs"));
|
|
42619
42760
|
os11 = __toESM2(require("os"));
|
|
42620
|
-
|
|
42761
|
+
path18 = __toESM2(require("path"));
|
|
42621
42762
|
SOURCES_FILENAME = "providers-sources.json";
|
|
42622
42763
|
ACTIVE_FILENAME = "providers-active.json";
|
|
42623
42764
|
}
|
|
@@ -42795,61 +42936,6 @@ Next step: ${nextStep}`;
|
|
|
42795
42936
|
};
|
|
42796
42937
|
}
|
|
42797
42938
|
});
|
|
42798
|
-
function resolveWin32GlobalBin(trimmed) {
|
|
42799
|
-
if (path18.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\")) {
|
|
42800
|
-
return null;
|
|
42801
|
-
}
|
|
42802
|
-
const extraDirs = [];
|
|
42803
|
-
if (process.env.APPDATA) extraDirs.push(path18.join(process.env.APPDATA, "npm"));
|
|
42804
|
-
try {
|
|
42805
|
-
extraDirs.push(path18.dirname(process.execPath));
|
|
42806
|
-
} catch {
|
|
42807
|
-
}
|
|
42808
|
-
for (const dir of extraDirs) {
|
|
42809
|
-
if (!dir) continue;
|
|
42810
|
-
for (const ext of WIN_EXEC_EXT) {
|
|
42811
|
-
const full = path18.join(dir, trimmed + ext);
|
|
42812
|
-
if ((0, import_fs14.existsSync)(full)) return full;
|
|
42813
|
-
}
|
|
42814
|
-
}
|
|
42815
|
-
return null;
|
|
42816
|
-
}
|
|
42817
|
-
function resolveWin32Executable(command) {
|
|
42818
|
-
if (process.platform !== "win32") return command;
|
|
42819
|
-
const trimmed = (command || "").trim();
|
|
42820
|
-
if (!trimmed) return command;
|
|
42821
|
-
if (path18.isAbsolute(trimmed) && (0, import_fs14.existsSync)(trimmed)) return trimmed;
|
|
42822
|
-
try {
|
|
42823
|
-
const out = (0, import_child_process4.execFileSync)("where", [trimmed], {
|
|
42824
|
-
encoding: "utf8",
|
|
42825
|
-
windowsHide: true
|
|
42826
|
-
}).trim();
|
|
42827
|
-
if (out) {
|
|
42828
|
-
const matches = out.split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
|
|
42829
|
-
const direct = matches.find((m) => DIRECT_EXEC_EXT.has(path18.extname(m).toLowerCase()));
|
|
42830
|
-
return direct || matches[0] || command;
|
|
42831
|
-
}
|
|
42832
|
-
} catch {
|
|
42833
|
-
}
|
|
42834
|
-
const globalBin = resolveWin32GlobalBin(trimmed);
|
|
42835
|
-
if (globalBin) return globalBin;
|
|
42836
|
-
return command;
|
|
42837
|
-
}
|
|
42838
|
-
var import_child_process4;
|
|
42839
|
-
var import_fs14;
|
|
42840
|
-
var path18;
|
|
42841
|
-
var DIRECT_EXEC_EXT;
|
|
42842
|
-
var WIN_EXEC_EXT;
|
|
42843
|
-
var init_resolve_executable = __esm2({
|
|
42844
|
-
"src/cli-adapters/resolve-executable.ts"() {
|
|
42845
|
-
"use strict";
|
|
42846
|
-
import_child_process4 = require("child_process");
|
|
42847
|
-
import_fs14 = require("fs");
|
|
42848
|
-
path18 = __toESM2(require("path"));
|
|
42849
|
-
DIRECT_EXEC_EXT = /* @__PURE__ */ new Set([".exe", ".com"]);
|
|
42850
|
-
WIN_EXEC_EXT = [".exe", ".com", ".cmd", ".bat"];
|
|
42851
|
-
}
|
|
42852
|
-
});
|
|
42853
42939
|
var pty_transport_exports = {};
|
|
42854
42940
|
__export2(pty_transport_exports, {
|
|
42855
42941
|
NodePtyTransportFactory: () => NodePtyTransportFactory
|
|
@@ -45061,10 +45147,10 @@ ${lastSnapshot}`;
|
|
|
45061
45147
|
return this.accumulatedRawBuffer.replace(/\x1B\][^\x07]*(?:\x07|\x1B\\)/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
|
|
45062
45148
|
}
|
|
45063
45149
|
getFreshParsedStatusCache() {
|
|
45064
|
-
const
|
|
45150
|
+
const cached3 = this.parsedStatusCache;
|
|
45065
45151
|
const accumulatedRawBufferKey = this.getAccumulatedRawBufferCacheKey();
|
|
45066
|
-
if (
|
|
45067
|
-
return
|
|
45152
|
+
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) {
|
|
45153
|
+
return cached3.result;
|
|
45068
45154
|
}
|
|
45069
45155
|
return null;
|
|
45070
45156
|
}
|
|
@@ -45526,10 +45612,10 @@ ${lastSnapshot}`;
|
|
|
45526
45612
|
getScriptParsedStatus() {
|
|
45527
45613
|
const screenText = this.readTerminalScreenText();
|
|
45528
45614
|
const parseScreenText = this.getParseScreenText(screenText);
|
|
45529
|
-
const
|
|
45615
|
+
const cached3 = this.parsedStatusCache;
|
|
45530
45616
|
const accumulatedRawBufferKey = this.getAccumulatedRawBufferCacheKey();
|
|
45531
|
-
if (!this.providerOwnsTranscript() &&
|
|
45532
|
-
return
|
|
45617
|
+
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) {
|
|
45618
|
+
return cached3.result;
|
|
45533
45619
|
}
|
|
45534
45620
|
const parsed = this.runParseSession();
|
|
45535
45621
|
if (!parsed || !Array.isArray(parsed.messages)) {
|
|
@@ -49519,13 +49605,20 @@ ${lastSnapshot}`;
|
|
|
49519
49605
|
function isMeshConfigRecord(value) {
|
|
49520
49606
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
49521
49607
|
}
|
|
49608
|
+
var SHELL_METACHAR_RE = /[;&|<>`$\n\r'"]/;
|
|
49609
|
+
var SAFE_TOKEN_RE = /^[A-Za-z0-9_@./:=+-]+$/;
|
|
49610
|
+
var SAFE_WIN32_EXEC_TOKEN_RE = /^[A-Za-z0-9_@./:=+\\-]+$/;
|
|
49522
49611
|
function tokenizeCommandString(command) {
|
|
49523
49612
|
const trimmed = command.trim();
|
|
49524
49613
|
if (!trimmed) return null;
|
|
49525
|
-
if (
|
|
49614
|
+
if (SHELL_METACHAR_RE.test(trimmed)) return null;
|
|
49526
49615
|
const tokens = trimmed.split(/\s+/).filter(Boolean);
|
|
49527
49616
|
if (!tokens.length) return null;
|
|
49528
|
-
|
|
49617
|
+
const isWin32 = process.platform === "win32";
|
|
49618
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
49619
|
+
const re = isWin32 && i === 0 ? SAFE_WIN32_EXEC_TOKEN_RE : SAFE_TOKEN_RE;
|
|
49620
|
+
if (!re.test(tokens[i])) return null;
|
|
49621
|
+
}
|
|
49529
49622
|
return tokens;
|
|
49530
49623
|
}
|
|
49531
49624
|
function validateCategory(value) {
|
|
@@ -49733,12 +49826,13 @@ ${lastSnapshot}`;
|
|
|
49733
49826
|
unavailableReason: validation.commands.length ? void 0 : "validation_unavailable: repo mesh/refine config has no validation.commands"
|
|
49734
49827
|
};
|
|
49735
49828
|
}
|
|
49736
|
-
var
|
|
49829
|
+
var import_fs9 = require("fs");
|
|
49737
49830
|
var import_path8 = require("path");
|
|
49738
49831
|
var import_node_child_process3 = require("child_process");
|
|
49739
49832
|
var import_node_crypto2 = require("crypto");
|
|
49740
49833
|
var import_node_util3 = require("util");
|
|
49741
49834
|
var yaml3 = __toESM2(require_js_yaml());
|
|
49835
|
+
init_resolve_executable();
|
|
49742
49836
|
var MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS = [
|
|
49743
49837
|
".adhdev/worktree_bootstrap.json",
|
|
49744
49838
|
".adhdev/worktree_bootstrap.yaml",
|
|
@@ -49826,9 +49920,9 @@ ${lastSnapshot}`;
|
|
|
49826
49920
|
}
|
|
49827
49921
|
for (const relative5 of MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS) {
|
|
49828
49922
|
const configPath = (0, import_path8.join)(workspace, relative5);
|
|
49829
|
-
if (!(0,
|
|
49923
|
+
if (!(0, import_fs9.existsSync)(configPath)) continue;
|
|
49830
49924
|
try {
|
|
49831
|
-
const parsed = parseConfigText3(configPath, (0,
|
|
49925
|
+
const parsed = parseConfigText3(configPath, (0, import_fs9.readFileSync)(configPath, "utf-8"));
|
|
49832
49926
|
const validation = validateMeshWorktreeBootstrapConfig(parsed, relative5);
|
|
49833
49927
|
if (!validation.valid) return { source: relative5, sourceType: "invalid", path: configPath, error: String(validation.rejectedCommands[0]?.reason || validation.errors.join("; ")) };
|
|
49834
49928
|
return { config: parsed, source: relative5, sourceType: "repo_file", path: configPath };
|
|
@@ -49843,7 +49937,7 @@ ${lastSnapshot}`;
|
|
|
49843
49937
|
for (const relative5 of staleInputs ?? []) {
|
|
49844
49938
|
const filePath = (0, import_path8.join)(workspace, relative5);
|
|
49845
49939
|
try {
|
|
49846
|
-
digest[relative5] = (0, import_node_crypto2.createHash)("sha256").update((0,
|
|
49940
|
+
digest[relative5] = (0, import_node_crypto2.createHash)("sha256").update((0, import_fs9.readFileSync)(filePath)).digest("hex");
|
|
49847
49941
|
} catch {
|
|
49848
49942
|
digest[relative5] = "absent";
|
|
49849
49943
|
}
|
|
@@ -49913,10 +50007,10 @@ ${lastSnapshot}`;
|
|
|
49913
50007
|
staleInputs: loaded.config.staleInputs
|
|
49914
50008
|
};
|
|
49915
50009
|
const staleInputPaths = loaded.config.staleInputs ?? [];
|
|
49916
|
-
const initiallyAbsent = staleInputPaths.filter((p) => !(0,
|
|
50010
|
+
const initiallyAbsent = staleInputPaths.filter((p) => !(0, import_fs9.existsSync)((0, import_path8.join)(workspace, p)));
|
|
49917
50011
|
for (const command of validation.commands) {
|
|
49918
50012
|
if (initiallyAbsent.length > 0) {
|
|
49919
|
-
const appearedNow = initiallyAbsent.filter((p) => (0,
|
|
50013
|
+
const appearedNow = initiallyAbsent.filter((p) => (0, import_fs9.existsSync)((0, import_path8.join)(workspace, p)));
|
|
49920
50014
|
if (appearedNow.length > 0) {
|
|
49921
50015
|
state.status = "stale";
|
|
49922
50016
|
state.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -49927,8 +50021,9 @@ ${lastSnapshot}`;
|
|
|
49927
50021
|
const cwd = command.cwd ? (0, import_path8.resolve)(workspace, command.cwd) : workspace;
|
|
49928
50022
|
const startedAt = Date.now();
|
|
49929
50023
|
state.lastCommand = command.displayCommand;
|
|
50024
|
+
const resolvedCommand = resolveWin32Executable(command.command);
|
|
49930
50025
|
try {
|
|
49931
|
-
const result = await execFileAsync4(
|
|
50026
|
+
const result = await execFileAsync4(resolvedCommand, command.args, {
|
|
49932
50027
|
cwd,
|
|
49933
50028
|
encoding: "utf8",
|
|
49934
50029
|
timeout: command.timeoutMs || DEFAULT_TIMEOUT_MS2,
|
|
@@ -50153,7 +50248,7 @@ ${lastSnapshot}`;
|
|
|
50153
50248
|
this.targetDaemonId = context.targetDaemonId;
|
|
50154
50249
|
}
|
|
50155
50250
|
};
|
|
50156
|
-
var
|
|
50251
|
+
var import_fs13 = require("fs");
|
|
50157
50252
|
var import_path10 = require("path");
|
|
50158
50253
|
init_config();
|
|
50159
50254
|
var DEFAULT_STATE = {
|
|
@@ -50204,11 +50299,11 @@ ${lastSnapshot}`;
|
|
|
50204
50299
|
}
|
|
50205
50300
|
function loadState() {
|
|
50206
50301
|
const statePath = getStatePath();
|
|
50207
|
-
if (!(0,
|
|
50302
|
+
if (!(0, import_fs13.existsSync)(statePath)) {
|
|
50208
50303
|
return { ...DEFAULT_STATE };
|
|
50209
50304
|
}
|
|
50210
50305
|
try {
|
|
50211
|
-
const raw = (0,
|
|
50306
|
+
const raw = (0, import_fs13.readFileSync)(statePath, "utf-8");
|
|
50212
50307
|
return normalizeState(JSON.parse(raw));
|
|
50213
50308
|
} catch {
|
|
50214
50309
|
return { ...DEFAULT_STATE };
|
|
@@ -50217,24 +50312,24 @@ ${lastSnapshot}`;
|
|
|
50217
50312
|
function saveState(state) {
|
|
50218
50313
|
const statePath = getStatePath();
|
|
50219
50314
|
const normalized = normalizeState(state);
|
|
50220
|
-
(0,
|
|
50315
|
+
(0, import_fs13.writeFileSync)(statePath, JSON.stringify(normalized, null, 2), { encoding: "utf-8", mode: 384 });
|
|
50221
50316
|
}
|
|
50222
50317
|
function resetState() {
|
|
50223
50318
|
saveState({ ...DEFAULT_STATE });
|
|
50224
50319
|
}
|
|
50225
|
-
var
|
|
50320
|
+
var import_child_process3 = require("child_process");
|
|
50226
50321
|
var import_util3 = require("util");
|
|
50227
|
-
var
|
|
50322
|
+
var import_fs14 = require("fs");
|
|
50228
50323
|
var import_os22 = require("os");
|
|
50229
|
-
var
|
|
50324
|
+
var path14 = __toESM2(require("path"));
|
|
50230
50325
|
var fs52 = __toESM2(require("fs"));
|
|
50231
|
-
var
|
|
50326
|
+
var path13 = __toESM2(require("path"));
|
|
50232
50327
|
function manifestCandidates(exeDir) {
|
|
50233
50328
|
return [
|
|
50234
|
-
|
|
50235
|
-
|
|
50329
|
+
path13.join(exeDir, "resources", "app", "product.json"),
|
|
50330
|
+
path13.join(exeDir, "resources", "app", "package.json"),
|
|
50236
50331
|
// Some packagings keep product.json one level up.
|
|
50237
|
-
|
|
50332
|
+
path13.join(exeDir, "product.json")
|
|
50238
50333
|
];
|
|
50239
50334
|
}
|
|
50240
50335
|
function parseVersionFromManifest(raw) {
|
|
@@ -50252,9 +50347,9 @@ ${lastSnapshot}`;
|
|
|
50252
50347
|
if (!exePath) return null;
|
|
50253
50348
|
let exeDir;
|
|
50254
50349
|
try {
|
|
50255
|
-
exeDir = fs52.statSync(exePath).isDirectory() ? exePath :
|
|
50350
|
+
exeDir = fs52.statSync(exePath).isDirectory() ? exePath : path13.dirname(exePath);
|
|
50256
50351
|
} catch {
|
|
50257
|
-
exeDir =
|
|
50352
|
+
exeDir = path13.dirname(exePath);
|
|
50258
50353
|
}
|
|
50259
50354
|
for (const candidate of manifestCandidates(exeDir)) {
|
|
50260
50355
|
try {
|
|
@@ -50268,7 +50363,7 @@ ${lastSnapshot}`;
|
|
|
50268
50363
|
}
|
|
50269
50364
|
function isKnownWin32GuiExe(binPath, win32ProcessNames) {
|
|
50270
50365
|
if (!binPath) return false;
|
|
50271
|
-
const base =
|
|
50366
|
+
const base = path13.win32.basename(binPath).toLowerCase();
|
|
50272
50367
|
if (!base.endsWith(".exe")) return false;
|
|
50273
50368
|
for (const names of Object.values(win32ProcessNames)) {
|
|
50274
50369
|
for (const name of names) {
|
|
@@ -50279,7 +50374,7 @@ ${lastSnapshot}`;
|
|
|
50279
50374
|
}
|
|
50280
50375
|
return false;
|
|
50281
50376
|
}
|
|
50282
|
-
var execAsync2 = (0, import_util3.promisify)(
|
|
50377
|
+
var execAsync2 = (0, import_util3.promisify)(import_child_process3.exec);
|
|
50283
50378
|
var BUILTIN_IDE_DEFINITIONS = [];
|
|
50284
50379
|
var registeredIDEs = /* @__PURE__ */ new Map();
|
|
50285
50380
|
function registerIDEDefinition(def) {
|
|
@@ -50298,10 +50393,10 @@ ${lastSnapshot}`;
|
|
|
50298
50393
|
function findCliCommand(command) {
|
|
50299
50394
|
const trimmed = String(command || "").trim();
|
|
50300
50395
|
if (!trimmed) return null;
|
|
50301
|
-
if (
|
|
50302
|
-
const candidate = trimmed.startsWith("~") ?
|
|
50303
|
-
const resolved =
|
|
50304
|
-
return (0,
|
|
50396
|
+
if (path14.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~")) {
|
|
50397
|
+
const candidate = trimmed.startsWith("~") ? path14.join((0, import_os22.homedir)(), trimmed.slice(1)) : trimmed;
|
|
50398
|
+
const resolved = path14.isAbsolute(candidate) ? candidate : path14.resolve(candidate);
|
|
50399
|
+
return (0, import_fs14.existsSync)(resolved) ? resolved : null;
|
|
50305
50400
|
}
|
|
50306
50401
|
const isWin = (0, import_os22.platform)() === "win32";
|
|
50307
50402
|
const paths = (process.env.PATH || "").split(isWin ? ";" : ":");
|
|
@@ -50309,10 +50404,10 @@ ${lastSnapshot}`;
|
|
|
50309
50404
|
for (const p of paths) {
|
|
50310
50405
|
if (!p) continue;
|
|
50311
50406
|
for (const ext of exes) {
|
|
50312
|
-
const fullPath =
|
|
50407
|
+
const fullPath = path14.join(p, trimmed + ext);
|
|
50313
50408
|
try {
|
|
50314
|
-
if ((0,
|
|
50315
|
-
const stat2 = (0,
|
|
50409
|
+
if ((0, import_fs14.existsSync)(fullPath)) {
|
|
50410
|
+
const stat2 = (0, import_fs14.statSync)(fullPath);
|
|
50316
50411
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
50317
50412
|
return fullPath;
|
|
50318
50413
|
}
|
|
@@ -50326,13 +50421,13 @@ ${lastSnapshot}`;
|
|
|
50326
50421
|
function checkPathExists(paths) {
|
|
50327
50422
|
const home = (0, import_os22.homedir)();
|
|
50328
50423
|
for (const p of paths) {
|
|
50329
|
-
const normalized = p.startsWith("~") ?
|
|
50424
|
+
const normalized = p.startsWith("~") ? path14.join(home, p.slice(1)) : p;
|
|
50330
50425
|
if (normalized.includes("*")) {
|
|
50331
50426
|
const username = home.split(/[\\/]/).pop() || "";
|
|
50332
50427
|
const resolved = normalized.replace("*", username);
|
|
50333
|
-
if ((0,
|
|
50428
|
+
if ((0, import_fs14.existsSync)(resolved)) return resolved;
|
|
50334
50429
|
} else {
|
|
50335
|
-
if ((0,
|
|
50430
|
+
if ((0, import_fs14.existsSync)(normalized)) return normalized;
|
|
50336
50431
|
}
|
|
50337
50432
|
}
|
|
50338
50433
|
return null;
|
|
@@ -50346,7 +50441,7 @@ ${lastSnapshot}`;
|
|
|
50346
50441
|
let resolvedCli = cliPath;
|
|
50347
50442
|
if (!resolvedCli && appPath && os30 === "darwin") {
|
|
50348
50443
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
50349
|
-
if ((0,
|
|
50444
|
+
if ((0, import_fs14.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
50350
50445
|
}
|
|
50351
50446
|
if (!resolvedCli && appPath && os30 === "win32") {
|
|
50352
50447
|
const { dirname: dirname17 } = await import("path");
|
|
@@ -50359,7 +50454,7 @@ ${lastSnapshot}`;
|
|
|
50359
50454
|
`${appDir}\\\\resources\\\\app\\\\bin\\\\${def.cli}.cmd`
|
|
50360
50455
|
];
|
|
50361
50456
|
for (const c of candidates) {
|
|
50362
|
-
if ((0,
|
|
50457
|
+
if ((0, import_fs14.existsSync)(c)) {
|
|
50363
50458
|
resolvedCli = c;
|
|
50364
50459
|
break;
|
|
50365
50460
|
}
|
|
@@ -50382,9 +50477,9 @@ ${lastSnapshot}`;
|
|
|
50382
50477
|
}
|
|
50383
50478
|
init_cli_detector();
|
|
50384
50479
|
var os72 = __toESM2(require("os"));
|
|
50385
|
-
var
|
|
50480
|
+
var import_child_process4 = require("child_process");
|
|
50386
50481
|
var import_util22 = require("util");
|
|
50387
|
-
var execAsync3 = (0, import_util22.promisify)(
|
|
50482
|
+
var execAsync3 = (0, import_util22.promisify)(import_child_process4.exec);
|
|
50388
50483
|
var cachedDarwinAvail = null;
|
|
50389
50484
|
var darwinMemoryInterval = null;
|
|
50390
50485
|
async function updateDarwinMemoryCache() {
|
|
@@ -52195,10 +52290,10 @@ ${cleanBody}`;
|
|
|
52195
52290
|
return cleanTitle || cleanBody;
|
|
52196
52291
|
}
|
|
52197
52292
|
var fs6 = __toESM2(require("fs"));
|
|
52198
|
-
var
|
|
52293
|
+
var path15 = __toESM2(require("path"));
|
|
52199
52294
|
var os8 = __toESM2(require("os"));
|
|
52200
52295
|
init_chat_message_normalization();
|
|
52201
|
-
var HISTORY_DIR =
|
|
52296
|
+
var HISTORY_DIR = path15.join(os8.homedir(), ".adhdev", "history");
|
|
52202
52297
|
var RETAIN_DAYS = 30;
|
|
52203
52298
|
var SAVED_HISTORY_INDEX_VERSION = 1;
|
|
52204
52299
|
var SAVED_HISTORY_INDEX_FILE = ".saved-history-index.json";
|
|
@@ -52214,11 +52309,11 @@ ${cleanBody}`;
|
|
|
52214
52309
|
var BOUNDED_TAIL_CACHE_MAX_ENTRIES = 64;
|
|
52215
52310
|
var boundedTailReadCache = /* @__PURE__ */ new Map();
|
|
52216
52311
|
function readBoundedTailCache(key, signature) {
|
|
52217
|
-
const
|
|
52218
|
-
if (!
|
|
52312
|
+
const cached3 = boundedTailReadCache.get(key);
|
|
52313
|
+
if (!cached3 || cached3.signature !== signature) return null;
|
|
52219
52314
|
boundedTailReadCache.delete(key);
|
|
52220
|
-
boundedTailReadCache.set(key,
|
|
52221
|
-
return
|
|
52315
|
+
boundedTailReadCache.set(key, cached3);
|
|
52316
|
+
return cached3.result;
|
|
52222
52317
|
}
|
|
52223
52318
|
function writeBoundedTailCache(key, signature, result) {
|
|
52224
52319
|
boundedTailReadCache.delete(key);
|
|
@@ -52384,7 +52479,7 @@ ${cleanBody}`;
|
|
|
52384
52479
|
function buildSavedHistoryFileSignatureMap(dir, files) {
|
|
52385
52480
|
return new Map(files.map((file2) => {
|
|
52386
52481
|
try {
|
|
52387
|
-
const stat2 = fs6.statSync(
|
|
52482
|
+
const stat2 = fs6.statSync(path15.join(dir, file2));
|
|
52388
52483
|
return [file2, `${file2}:${stat2.size}:${Math.trunc(stat2.mtimeMs)}`];
|
|
52389
52484
|
} catch {
|
|
52390
52485
|
return [file2, `${file2}:missing`];
|
|
@@ -52395,7 +52490,7 @@ ${cleanBody}`;
|
|
|
52395
52490
|
return files.map((file2) => fileSignatures.get(file2) || `${file2}:missing`).join("|");
|
|
52396
52491
|
}
|
|
52397
52492
|
function getSavedHistoryIndexFilePath(dir) {
|
|
52398
|
-
return
|
|
52493
|
+
return path15.join(dir, SAVED_HISTORY_INDEX_FILE);
|
|
52399
52494
|
}
|
|
52400
52495
|
function getSavedHistoryIndexLockPath(dir) {
|
|
52401
52496
|
return `${getSavedHistoryIndexFilePath(dir)}${SAVED_HISTORY_INDEX_LOCK_SUFFIX}`;
|
|
@@ -52497,7 +52592,7 @@ ${cleanBody}`;
|
|
|
52497
52592
|
}
|
|
52498
52593
|
for (const file2 of Array.from(currentEntries.keys())) {
|
|
52499
52594
|
if (incomingFiles.has(file2)) continue;
|
|
52500
|
-
if (!fs6.existsSync(
|
|
52595
|
+
if (!fs6.existsSync(path15.join(dir, file2))) {
|
|
52501
52596
|
currentEntries.delete(file2);
|
|
52502
52597
|
}
|
|
52503
52598
|
}
|
|
@@ -52523,7 +52618,7 @@ ${cleanBody}`;
|
|
|
52523
52618
|
const indexStat = fs6.statSync(getSavedHistoryIndexFilePath(dir));
|
|
52524
52619
|
const files = listHistoryFiles(dir);
|
|
52525
52620
|
for (const file2 of files) {
|
|
52526
|
-
const stat2 = fs6.statSync(
|
|
52621
|
+
const stat2 = fs6.statSync(path15.join(dir, file2));
|
|
52527
52622
|
if (stat2.mtimeMs > indexStat.mtimeMs) return true;
|
|
52528
52623
|
}
|
|
52529
52624
|
return false;
|
|
@@ -52533,14 +52628,14 @@ ${cleanBody}`;
|
|
|
52533
52628
|
}
|
|
52534
52629
|
function buildSavedHistoryFileSignature(dir, file2) {
|
|
52535
52630
|
try {
|
|
52536
|
-
const stat2 = fs6.statSync(
|
|
52631
|
+
const stat2 = fs6.statSync(path15.join(dir, file2));
|
|
52537
52632
|
return `${file2}:${stat2.size}:${Math.trunc(stat2.mtimeMs)}`;
|
|
52538
52633
|
} catch {
|
|
52539
52634
|
return `${file2}:missing`;
|
|
52540
52635
|
}
|
|
52541
52636
|
}
|
|
52542
52637
|
function persistSavedHistoryFileSummaryEntry(agentType, dir, file2, updater) {
|
|
52543
|
-
const filePath =
|
|
52638
|
+
const filePath = path15.join(dir, file2);
|
|
52544
52639
|
const result = withLockedPersistedSavedHistoryIndex(dir, (entries) => {
|
|
52545
52640
|
const currentEntry = entries.get(file2) || null;
|
|
52546
52641
|
const nextSummary = updater(currentEntry?.summary || null);
|
|
@@ -52613,7 +52708,7 @@ ${cleanBody}`;
|
|
|
52613
52708
|
function computeSavedHistoryFileSummary(dir, file2) {
|
|
52614
52709
|
const historySessionId = extractSavedHistorySessionIdFromFile(file2);
|
|
52615
52710
|
if (!historySessionId) return null;
|
|
52616
|
-
const filePath =
|
|
52711
|
+
const filePath = path15.join(dir, file2);
|
|
52617
52712
|
const content = fs6.readFileSync(filePath, "utf-8");
|
|
52618
52713
|
const lines = content.split("\n").filter(Boolean);
|
|
52619
52714
|
let messageCount = 0;
|
|
@@ -52700,11 +52795,11 @@ ${cleanBody}`;
|
|
|
52700
52795
|
const summaryBySessionId = /* @__PURE__ */ new Map();
|
|
52701
52796
|
const nextPersistedEntries = /* @__PURE__ */ new Map();
|
|
52702
52797
|
for (const file2 of files.slice().sort()) {
|
|
52703
|
-
const filePath =
|
|
52798
|
+
const filePath = path15.join(dir, file2);
|
|
52704
52799
|
const signature = fileSignatures.get(file2) || `${file2}:missing`;
|
|
52705
|
-
const
|
|
52800
|
+
const cached3 = savedHistoryFileSummaryCache.get(filePath);
|
|
52706
52801
|
const persisted = persistedEntries.get(file2);
|
|
52707
|
-
const reusableEntry =
|
|
52802
|
+
const reusableEntry = cached3?.signature === signature ? cached3 : persisted?.signature === signature ? persisted : null;
|
|
52708
52803
|
const fileSummary = reusableEntry?.summary || computeSavedHistoryFileSummary(dir, file2);
|
|
52709
52804
|
const nextEntry = reusableEntry || {
|
|
52710
52805
|
signature,
|
|
@@ -52820,12 +52915,12 @@ ${cleanBody}`;
|
|
|
52820
52915
|
});
|
|
52821
52916
|
}
|
|
52822
52917
|
if (newMessages.length === 0) return;
|
|
52823
|
-
const dir =
|
|
52918
|
+
const dir = path15.join(HISTORY_DIR, this.sanitize(agentType));
|
|
52824
52919
|
fs6.mkdirSync(dir, { recursive: true });
|
|
52825
52920
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
52826
52921
|
const filePrefix = effectiveHistoryKey ? `${this.sanitize(effectiveHistoryKey)}_` : "";
|
|
52827
52922
|
const fileName = `${filePrefix}${date5}.jsonl`;
|
|
52828
|
-
const filePath =
|
|
52923
|
+
const filePath = path15.join(dir, fileName);
|
|
52829
52924
|
const lines = newMessages.map((m) => JSON.stringify(m)).join("\n") + "\n";
|
|
52830
52925
|
fs6.appendFileSync(filePath, lines, "utf-8");
|
|
52831
52926
|
updateSavedHistoryIndexForAppendedMessages(agentType, dir, fileName, effectiveHistoryKey, newMessages);
|
|
@@ -52916,11 +53011,11 @@ ${cleanBody}`;
|
|
|
52916
53011
|
const ws = String(workspace || "").trim();
|
|
52917
53012
|
if (!id || !ws) return;
|
|
52918
53013
|
try {
|
|
52919
|
-
const dir =
|
|
53014
|
+
const dir = path15.join(HISTORY_DIR, this.sanitize(agentType));
|
|
52920
53015
|
fs6.mkdirSync(dir, { recursive: true });
|
|
52921
53016
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
52922
53017
|
const fileName = `${this.sanitize(id)}_${date5}.jsonl`;
|
|
52923
|
-
const filePath =
|
|
53018
|
+
const filePath = path15.join(dir, fileName);
|
|
52924
53019
|
const record2 = {
|
|
52925
53020
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
52926
53021
|
receivedAt: Date.now(),
|
|
@@ -52966,14 +53061,14 @@ ${cleanBody}`;
|
|
|
52966
53061
|
this.lastSeenCounts.set(toDedupKey, Math.max(fromCount, this.lastSeenCounts.get(toDedupKey) || 0));
|
|
52967
53062
|
this.lastSeenCounts.delete(fromDedupKey);
|
|
52968
53063
|
}
|
|
52969
|
-
const dir =
|
|
53064
|
+
const dir = path15.join(HISTORY_DIR, this.sanitize(agentType));
|
|
52970
53065
|
if (!fs6.existsSync(dir)) return;
|
|
52971
53066
|
const fromPrefix = `${this.sanitize(fromId)}_`;
|
|
52972
53067
|
const toPrefix = `${this.sanitize(toId)}_`;
|
|
52973
53068
|
const files = fs6.readdirSync(dir).filter((file2) => file2.startsWith(fromPrefix) && file2.endsWith(".jsonl"));
|
|
52974
53069
|
for (const file2 of files) {
|
|
52975
|
-
const sourcePath =
|
|
52976
|
-
const targetPath =
|
|
53070
|
+
const sourcePath = path15.join(dir, file2);
|
|
53071
|
+
const targetPath = path15.join(dir, `${toPrefix}${file2.slice(fromPrefix.length)}`);
|
|
52977
53072
|
const sourceLines = fs6.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
|
|
52978
53073
|
const rewritten = sourceLines.map((line) => {
|
|
52979
53074
|
try {
|
|
@@ -53007,13 +53102,13 @@ ${cleanBody}`;
|
|
|
53007
53102
|
const sessionId = String(historySessionId || "").trim();
|
|
53008
53103
|
if (!sessionId) return;
|
|
53009
53104
|
try {
|
|
53010
|
-
const dir =
|
|
53105
|
+
const dir = path15.join(HISTORY_DIR, this.sanitize(agentType));
|
|
53011
53106
|
if (!fs6.existsSync(dir)) return;
|
|
53012
53107
|
const prefix = `${this.sanitize(sessionId)}_`;
|
|
53013
53108
|
const files = fs6.readdirSync(dir).filter((file2) => file2.startsWith(prefix) && file2.endsWith(".jsonl")).sort();
|
|
53014
53109
|
const seen = /* @__PURE__ */ new Set();
|
|
53015
53110
|
for (const file2 of files) {
|
|
53016
|
-
const filePath =
|
|
53111
|
+
const filePath = path15.join(dir, file2);
|
|
53017
53112
|
const lines = fs6.readFileSync(filePath, "utf-8").split("\n").filter(Boolean);
|
|
53018
53113
|
const next = [];
|
|
53019
53114
|
for (const line of lines) {
|
|
@@ -53067,11 +53162,11 @@ ${cleanBody}`;
|
|
|
53067
53162
|
const cutoff = Date.now() - RETAIN_DAYS * 24 * 60 * 60 * 1e3;
|
|
53068
53163
|
const agentDirs = fs6.readdirSync(HISTORY_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
53069
53164
|
for (const dir of agentDirs) {
|
|
53070
|
-
const dirPath =
|
|
53165
|
+
const dirPath = path15.join(HISTORY_DIR, dir.name);
|
|
53071
53166
|
const files = fs6.readdirSync(dirPath).filter((f) => f.endsWith(".jsonl") || f.endsWith(".terminal.log"));
|
|
53072
53167
|
let removedAny = false;
|
|
53073
53168
|
for (const file2 of files) {
|
|
53074
|
-
const filePath =
|
|
53169
|
+
const filePath = path15.join(dirPath, file2);
|
|
53075
53170
|
const stat2 = fs6.statSync(filePath);
|
|
53076
53171
|
if (stat2.mtimeMs < cutoff) {
|
|
53077
53172
|
fs6.unlinkSync(filePath);
|
|
@@ -53200,16 +53295,16 @@ ${cleanBody}`;
|
|
|
53200
53295
|
incrementalTailCache.delete(filePath);
|
|
53201
53296
|
return { lines: [], coversWholeFile: true };
|
|
53202
53297
|
}
|
|
53203
|
-
const
|
|
53204
|
-
if (
|
|
53205
|
-
if (
|
|
53298
|
+
const cached3 = incrementalTailCache.get(filePath);
|
|
53299
|
+
if (cached3) {
|
|
53300
|
+
if (cached3.size === size && cached3.mtimeMs === mtimeMs) {
|
|
53206
53301
|
incrementalTailCache.delete(filePath);
|
|
53207
|
-
incrementalTailCache.set(filePath,
|
|
53208
|
-
if (
|
|
53209
|
-
return { lines:
|
|
53302
|
+
incrementalTailCache.set(filePath, cached3);
|
|
53303
|
+
if (cached3.coversWholeFile || cached3.lines.length >= needed) {
|
|
53304
|
+
return { lines: cached3.lines, coversWholeFile: cached3.coversWholeFile };
|
|
53210
53305
|
}
|
|
53211
|
-
} else if (size >
|
|
53212
|
-
const incremental = tryIncrementalTailGrowth(filePath,
|
|
53306
|
+
} else if (size > cached3.size) {
|
|
53307
|
+
const incremental = tryIncrementalTailGrowth(filePath, cached3, size, mtimeMs, needed);
|
|
53213
53308
|
if (incremental) return { lines: incremental.lines, coversWholeFile: incremental.coversWholeFile };
|
|
53214
53309
|
}
|
|
53215
53310
|
incrementalTailCache.delete(filePath);
|
|
@@ -53235,22 +53330,22 @@ ${cleanBody}`;
|
|
|
53235
53330
|
storeIncrementalTailCache(filePath, result.size, result.mtimeMs, result.lines, result.coversWholeFile);
|
|
53236
53331
|
return { lines: result.lines, coversWholeFile: result.coversWholeFile };
|
|
53237
53332
|
}
|
|
53238
|
-
function tryIncrementalTailGrowth(filePath,
|
|
53333
|
+
function tryIncrementalTailGrowth(filePath, cached3, size, mtimeMs, needed) {
|
|
53239
53334
|
const fd = fs6.openSync(filePath, "r");
|
|
53240
53335
|
try {
|
|
53241
|
-
if (
|
|
53336
|
+
if (cached3.size > 0) {
|
|
53242
53337
|
const boundary = Buffer.alloc(1);
|
|
53243
|
-
fs6.readSync(fd, boundary, 0, 1,
|
|
53338
|
+
fs6.readSync(fd, boundary, 0, 1, cached3.size - 1);
|
|
53244
53339
|
if (boundary[0] !== 10) return null;
|
|
53245
53340
|
}
|
|
53246
|
-
const appendedLength = size -
|
|
53341
|
+
const appendedLength = size - cached3.size;
|
|
53247
53342
|
const appended = Buffer.alloc(appendedLength);
|
|
53248
|
-
fs6.readSync(fd, appended, 0, appendedLength,
|
|
53343
|
+
fs6.readSync(fd, appended, 0, appendedLength, cached3.size);
|
|
53249
53344
|
const newLines = appended.toString("utf-8").split("\n");
|
|
53250
53345
|
if (newLines.length && newLines[newLines.length - 1] === "") newLines.pop();
|
|
53251
|
-
const merged =
|
|
53346
|
+
const merged = cached3.lines.concat(newLines);
|
|
53252
53347
|
const trimmed = merged.length > TAIL_LINES_RETAINED ? merged.slice(merged.length - TAIL_LINES_RETAINED) : merged;
|
|
53253
|
-
const coversWholeFile =
|
|
53348
|
+
const coversWholeFile = cached3.coversWholeFile && trimmed.length === merged.length;
|
|
53254
53349
|
storeIncrementalTailCache(filePath, size, mtimeMs, trimmed, coversWholeFile);
|
|
53255
53350
|
if (coversWholeFile || trimmed.length >= needed) {
|
|
53256
53351
|
return { lines: trimmed, coversWholeFile };
|
|
@@ -53274,7 +53369,7 @@ ${cleanBody}`;
|
|
|
53274
53369
|
const seen = /* @__PURE__ */ new Set();
|
|
53275
53370
|
let readAllFiles = true;
|
|
53276
53371
|
for (let f = 0; f < files.length; f++) {
|
|
53277
|
-
const filePath =
|
|
53372
|
+
const filePath = path15.join(dir, files[f]);
|
|
53278
53373
|
const remaining = Math.max(0, needed - collected.length);
|
|
53279
53374
|
const perFileNeeded = Math.min(needed, remaining + BOUNDED_TAIL_SLACK);
|
|
53280
53375
|
const { lines, coversWholeFile } = readFileTailLines(filePath, perFileNeeded);
|
|
@@ -53307,7 +53402,7 @@ ${cleanBody}`;
|
|
|
53307
53402
|
function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, excludeRecentCount = 0, historyBehavior) {
|
|
53308
53403
|
try {
|
|
53309
53404
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
53310
|
-
const dir =
|
|
53405
|
+
const dir = path15.join(HISTORY_DIR, sanitized);
|
|
53311
53406
|
if (!fs6.existsSync(dir)) return { messages: [], hasMore: false };
|
|
53312
53407
|
const files = listHistoryFiles(dir, historySessionId);
|
|
53313
53408
|
const bounded = isBoundedTailRequest(limit, offset, excludeRecentCount);
|
|
@@ -53315,8 +53410,8 @@ ${cleanBody}`;
|
|
|
53315
53410
|
const fileSignatures = buildSavedHistoryFileSignatureMap(dir, files);
|
|
53316
53411
|
const cacheKey = `${sanitized}\0${historySessionId || ""}\0${offset}\0${limit}\0${excludeRecentCount}\0${historyBehavior?.collapseConsecutiveAssistantTurns ? "1" : "0"}`;
|
|
53317
53412
|
const signature = buildSavedHistoryCacheSignature(files, fileSignatures);
|
|
53318
|
-
const
|
|
53319
|
-
if (
|
|
53413
|
+
const cached3 = readBoundedTailCache(cacheKey, signature);
|
|
53414
|
+
if (cached3) return cached3;
|
|
53320
53415
|
const numericLimit = Math.max(1, Number(limit));
|
|
53321
53416
|
const numericOffset = Math.max(0, Number(offset));
|
|
53322
53417
|
const numericExclude = Math.max(0, Number(excludeRecentCount));
|
|
@@ -53330,7 +53425,7 @@ ${cleanBody}`;
|
|
|
53330
53425
|
const allMessages = [];
|
|
53331
53426
|
const seen = /* @__PURE__ */ new Set();
|
|
53332
53427
|
for (const file2 of files) {
|
|
53333
|
-
const filePath =
|
|
53428
|
+
const filePath = path15.join(dir, file2);
|
|
53334
53429
|
const content = fs6.readFileSync(filePath, "utf-8");
|
|
53335
53430
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
53336
53431
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -53354,28 +53449,28 @@ ${cleanBody}`;
|
|
|
53354
53449
|
function listSavedHistorySessions(agentType, options = {}, historyBehavior) {
|
|
53355
53450
|
try {
|
|
53356
53451
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
53357
|
-
const dir =
|
|
53452
|
+
const dir = path15.join(HISTORY_DIR, sanitized);
|
|
53358
53453
|
if (!fs6.existsSync(dir)) {
|
|
53359
53454
|
savedHistorySessionCache.delete(sanitized);
|
|
53360
53455
|
return { sessions: [], hasMore: false };
|
|
53361
53456
|
}
|
|
53362
|
-
const
|
|
53457
|
+
const cached3 = savedHistorySessionCache.get(sanitized);
|
|
53363
53458
|
const offset = Math.max(0, options.offset || 0);
|
|
53364
53459
|
const limit = Math.max(1, options.limit || 30);
|
|
53365
53460
|
const indexSignature = buildSavedHistoryIndexFileSignature(dir);
|
|
53366
53461
|
let cacheWasInvalidated = false;
|
|
53367
|
-
if (
|
|
53368
|
-
const cacheLooksPersisted =
|
|
53369
|
-
const cacheStillValid = cacheLooksPersisted ?
|
|
53462
|
+
if (cached3) {
|
|
53463
|
+
const cacheLooksPersisted = cached3.signature.startsWith("index:");
|
|
53464
|
+
const cacheStillValid = cacheLooksPersisted ? cached3.signature === indexSignature : (() => {
|
|
53370
53465
|
const files2 = listHistoryFiles(dir);
|
|
53371
53466
|
const fileSignatures2 = buildSavedHistoryFileSignatureMap(dir, files2);
|
|
53372
|
-
return
|
|
53467
|
+
return cached3.signature === buildSavedHistoryCacheSignature(files2, fileSignatures2);
|
|
53373
53468
|
})();
|
|
53374
53469
|
if (cacheStillValid) {
|
|
53375
|
-
const sliced2 =
|
|
53470
|
+
const sliced2 = cached3.summaries.slice(offset, offset + limit);
|
|
53376
53471
|
return {
|
|
53377
53472
|
sessions: sliced2,
|
|
53378
|
-
hasMore:
|
|
53473
|
+
hasMore: cached3.summaries.length > offset + limit
|
|
53379
53474
|
};
|
|
53380
53475
|
}
|
|
53381
53476
|
cacheWasInvalidated = true;
|
|
@@ -53415,11 +53510,11 @@ ${cleanBody}`;
|
|
|
53415
53510
|
}
|
|
53416
53511
|
function readExistingSessionStartRecord(agentType, historySessionId) {
|
|
53417
53512
|
try {
|
|
53418
|
-
const dir =
|
|
53513
|
+
const dir = path15.join(HISTORY_DIR, agentType);
|
|
53419
53514
|
if (!fs6.existsSync(dir)) return null;
|
|
53420
53515
|
const files = listHistoryFiles(dir, historySessionId).sort();
|
|
53421
53516
|
for (const file2 of files) {
|
|
53422
|
-
const lines = fs6.readFileSync(
|
|
53517
|
+
const lines = fs6.readFileSync(path15.join(dir, file2), "utf-8").split("\n").filter(Boolean);
|
|
53423
53518
|
for (const line of lines) {
|
|
53424
53519
|
try {
|
|
53425
53520
|
const parsed = JSON.parse(line);
|
|
@@ -53439,16 +53534,16 @@ ${cleanBody}`;
|
|
|
53439
53534
|
function rewriteCanonicalSavedHistory(agentType, historySessionId, records) {
|
|
53440
53535
|
if (records.length === 0) return false;
|
|
53441
53536
|
try {
|
|
53442
|
-
const dir =
|
|
53537
|
+
const dir = path15.join(HISTORY_DIR, agentType);
|
|
53443
53538
|
fs6.mkdirSync(dir, { recursive: true });
|
|
53444
53539
|
const prefix = `${historySessionId.replace(/[^a-zA-Z0-9_-]/g, "_")}_`;
|
|
53445
53540
|
for (const file2 of fs6.readdirSync(dir)) {
|
|
53446
53541
|
if (file2.startsWith(prefix) && file2.endsWith(".jsonl")) {
|
|
53447
|
-
fs6.unlinkSync(
|
|
53542
|
+
fs6.unlinkSync(path15.join(dir, file2));
|
|
53448
53543
|
}
|
|
53449
53544
|
}
|
|
53450
53545
|
const targetDate = new Date(records[records.length - 1].receivedAt || Date.now()).toISOString().slice(0, 10);
|
|
53451
|
-
const filePath =
|
|
53546
|
+
const filePath = path15.join(dir, `${prefix}${targetDate}.jsonl`);
|
|
53452
53547
|
fs6.writeFileSync(filePath, `${records.map((record2) => JSON.stringify(record2)).join("\n")}
|
|
53453
53548
|
`, "utf-8");
|
|
53454
53549
|
invalidatePersistedSavedHistoryIndex(agentType, dir);
|
|
@@ -56007,7 +56102,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
56007
56102
|
}
|
|
56008
56103
|
var fs7 = __toESM2(require("fs"));
|
|
56009
56104
|
var os9 = __toESM2(require("os"));
|
|
56010
|
-
var
|
|
56105
|
+
var path16 = __toESM2(require("path"));
|
|
56011
56106
|
var import_node_crypto3 = require("crypto");
|
|
56012
56107
|
init_contracts();
|
|
56013
56108
|
init_logger();
|
|
@@ -57048,7 +57143,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
57048
57143
|
function normalizeComparableWorkspace(value) {
|
|
57049
57144
|
const text = typeof value === "string" ? value.trim() : "";
|
|
57050
57145
|
if (!text) return "";
|
|
57051
|
-
return
|
|
57146
|
+
return path16.resolve(text);
|
|
57052
57147
|
}
|
|
57053
57148
|
function isCurrentRuntimePtySafelyAttributed(args) {
|
|
57054
57149
|
if (args.adapter.cliType !== "codex-cli") return false;
|
|
@@ -57533,7 +57628,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
57533
57628
|
}
|
|
57534
57629
|
function getChatDebugBundleDir() {
|
|
57535
57630
|
const override = typeof process.env.ADHDEV_DEBUG_BUNDLE_DIR === "string" ? process.env.ADHDEV_DEBUG_BUNDLE_DIR.trim() : "";
|
|
57536
|
-
return override ||
|
|
57631
|
+
return override || path16.join(os9.homedir(), ".adhdev", "debug-bundles", "chat");
|
|
57537
57632
|
}
|
|
57538
57633
|
function safeBundleIdSegment(value, fallback) {
|
|
57539
57634
|
const normalized = String(value || fallback).trim().replace(/[^A-Za-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
|
|
@@ -57590,7 +57685,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
57590
57685
|
const bundleId = createChatDebugBundleId(targetSessionId);
|
|
57591
57686
|
const dir = getChatDebugBundleDir();
|
|
57592
57687
|
fs7.mkdirSync(dir, { recursive: true });
|
|
57593
|
-
const savedPath =
|
|
57688
|
+
const savedPath = path16.join(dir, `${bundleId}.json`);
|
|
57594
57689
|
const json2 = `${JSON.stringify(bundle, null, 2)}
|
|
57595
57690
|
`;
|
|
57596
57691
|
fs7.writeFileSync(savedPath, json2, { encoding: "utf8", mode: 384 });
|
|
@@ -59152,7 +59247,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
59152
59247
|
return { success: false, error: "resolveAction script not available for this provider" };
|
|
59153
59248
|
}
|
|
59154
59249
|
var fs8 = __toESM2(require("fs"));
|
|
59155
|
-
var
|
|
59250
|
+
var path17 = __toESM2(require("path"));
|
|
59156
59251
|
var os10 = __toESM2(require("os"));
|
|
59157
59252
|
var KEY_TO_VK = {
|
|
59158
59253
|
Backspace: 8,
|
|
@@ -59409,25 +59504,25 @@ ${effect.notification.body || ""}`.trim();
|
|
|
59409
59504
|
const inputPath = rawPath || ".";
|
|
59410
59505
|
const home = os10.homedir();
|
|
59411
59506
|
if (inputPath.startsWith("~")) {
|
|
59412
|
-
return
|
|
59507
|
+
return path17.resolve(path17.join(home, inputPath.slice(1)));
|
|
59413
59508
|
}
|
|
59414
59509
|
if (process.platform === "win32") {
|
|
59415
59510
|
const normalized = normalizeWindowsRequestedPath(inputPath);
|
|
59416
|
-
if (
|
|
59417
|
-
return
|
|
59511
|
+
if (path17.win32.isAbsolute(normalized)) {
|
|
59512
|
+
return path17.win32.normalize(normalized);
|
|
59418
59513
|
}
|
|
59419
|
-
return
|
|
59514
|
+
return path17.win32.resolve(normalized);
|
|
59420
59515
|
}
|
|
59421
|
-
if (
|
|
59422
|
-
return
|
|
59516
|
+
if (path17.isAbsolute(inputPath)) {
|
|
59517
|
+
return path17.normalize(inputPath);
|
|
59423
59518
|
}
|
|
59424
|
-
return
|
|
59519
|
+
return path17.resolve(inputPath);
|
|
59425
59520
|
}
|
|
59426
59521
|
function listDirectoryEntriesSafe(dirPath) {
|
|
59427
59522
|
const entries = fs8.readdirSync(dirPath, { withFileTypes: true });
|
|
59428
59523
|
const files = [];
|
|
59429
59524
|
for (const entry of entries) {
|
|
59430
|
-
const entryPath =
|
|
59525
|
+
const entryPath = path17.join(dirPath, entry.name);
|
|
59431
59526
|
try {
|
|
59432
59527
|
if (entry.isDirectory()) {
|
|
59433
59528
|
files.push({ name: entry.name, type: "directory" });
|
|
@@ -59481,7 +59576,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
59481
59576
|
async function handleFileWrite(h, args) {
|
|
59482
59577
|
try {
|
|
59483
59578
|
const filePath = resolveSafePath(args?.path);
|
|
59484
|
-
fs8.mkdirSync(
|
|
59579
|
+
fs8.mkdirSync(path17.dirname(filePath), { recursive: true });
|
|
59485
59580
|
fs8.writeFileSync(filePath, args?.content || "", "utf-8");
|
|
59486
59581
|
return { success: true, path: filePath };
|
|
59487
59582
|
} catch (e) {
|
|
@@ -62235,6 +62330,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62235
62330
|
var os17 = __toESM2(require("os"));
|
|
62236
62331
|
var path222 = __toESM2(require("path"));
|
|
62237
62332
|
init_logger();
|
|
62333
|
+
init_load_better_sqlite3();
|
|
62238
62334
|
var UUID_RE = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
|
|
62239
62335
|
function executeNativeHistory(cfg, input) {
|
|
62240
62336
|
if (!cfg?.source) return null;
|
|
@@ -62359,7 +62455,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62359
62455
|
if (!resolved || !fs13.existsSync(resolved)) return null;
|
|
62360
62456
|
let Database;
|
|
62361
62457
|
try {
|
|
62362
|
-
Database =
|
|
62458
|
+
Database = loadBetterSqlite3();
|
|
62363
62459
|
} catch {
|
|
62364
62460
|
return null;
|
|
62365
62461
|
}
|
|
@@ -69143,6 +69239,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69143
69239
|
var fs20 = __toESM2(require("fs"));
|
|
69144
69240
|
var path30 = __toESM2(require("path"));
|
|
69145
69241
|
var os21 = __toESM2(require("os"));
|
|
69242
|
+
init_load_better_sqlite3();
|
|
69146
69243
|
var HERMES_STATE_DB = path30.join(os21.homedir(), ".hermes", "state.db");
|
|
69147
69244
|
var HERMES_LEGACY_SESSIONS_DIR = path30.join(os21.homedir(), ".hermes", "sessions");
|
|
69148
69245
|
function statMtimeMs4(p) {
|
|
@@ -69155,7 +69252,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69155
69252
|
function openDb() {
|
|
69156
69253
|
if (!fs20.existsSync(HERMES_STATE_DB)) return null;
|
|
69157
69254
|
try {
|
|
69158
|
-
const Database =
|
|
69255
|
+
const Database = loadBetterSqlite3();
|
|
69159
69256
|
return new Database(HERMES_STATE_DB, { readonly: true, fileMustExist: true });
|
|
69160
69257
|
} catch {
|
|
69161
69258
|
return null;
|
|
@@ -70526,8 +70623,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
70526
70623
|
return null;
|
|
70527
70624
|
}
|
|
70528
70625
|
registerProviderScriptRootSafely(path332.dirname(path332.dirname(providerDir)));
|
|
70529
|
-
const
|
|
70530
|
-
if (
|
|
70626
|
+
const cached3 = this.scriptsCache.get(dir);
|
|
70627
|
+
if (cached3) return cached3;
|
|
70531
70628
|
const scriptsJs = path332.join(dir, "scripts.js");
|
|
70532
70629
|
if (fs222.existsSync(scriptsJs)) {
|
|
70533
70630
|
try {
|
|
@@ -73181,6 +73278,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
73181
73278
|
var import_path12 = require("path");
|
|
73182
73279
|
var fs26 = __toESM2(require("fs"));
|
|
73183
73280
|
var import_node_child_process6 = require("child_process");
|
|
73281
|
+
init_resolve_executable();
|
|
73184
73282
|
var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
|
|
73185
73283
|
var CHANNEL_SERVER_URL = {
|
|
73186
73284
|
stable: "https://api.adhf.dev",
|
|
@@ -73574,13 +73672,13 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
73574
73672
|
nodes
|
|
73575
73673
|
};
|
|
73576
73674
|
}
|
|
73577
|
-
function reconcileInlineMeshCache(
|
|
73578
|
-
if (!
|
|
73579
|
-
if (!incoming || typeof incoming !== "object" || Array.isArray(incoming)) return
|
|
73580
|
-
const cachedNodes = Array.isArray(
|
|
73675
|
+
function reconcileInlineMeshCache(cached3, incoming) {
|
|
73676
|
+
if (!cached3 || typeof cached3 !== "object" || Array.isArray(cached3)) return incoming;
|
|
73677
|
+
if (!incoming || typeof incoming !== "object" || Array.isArray(incoming)) return cached3;
|
|
73678
|
+
const cachedNodes = Array.isArray(cached3.nodes) ? cached3.nodes : [];
|
|
73581
73679
|
const incomingNodes = Array.isArray(incoming.nodes) ? incoming.nodes : [];
|
|
73582
|
-
if (!cachedNodes.length || !incomingNodes.length) return { ...
|
|
73583
|
-
const cachedUpdatedAt = Date.parse(readStringValue(
|
|
73680
|
+
if (!cachedNodes.length || !incomingNodes.length) return { ...cached3, ...incoming };
|
|
73681
|
+
const cachedUpdatedAt = Date.parse(readStringValue(cached3.updatedAt, cached3.updated_at) || "");
|
|
73584
73682
|
const incomingUpdatedAt = Date.parse(readStringValue(incoming.updatedAt, incoming.updated_at) || "");
|
|
73585
73683
|
const preserveCachedMembership = Number.isFinite(cachedUpdatedAt) && (!Number.isFinite(incomingUpdatedAt) || cachedUpdatedAt > incomingUpdatedAt);
|
|
73586
73684
|
const cachedById = /* @__PURE__ */ new Map();
|
|
@@ -73609,7 +73707,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
73609
73707
|
}
|
|
73610
73708
|
}
|
|
73611
73709
|
return {
|
|
73612
|
-
...
|
|
73710
|
+
...cached3,
|
|
73613
73711
|
...incoming,
|
|
73614
73712
|
nodes
|
|
73615
73713
|
};
|
|
@@ -73942,9 +74040,9 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
73942
74040
|
*/
|
|
73943
74041
|
async probe(daemonId, workspace, probe) {
|
|
73944
74042
|
const key = this.key(daemonId, workspace);
|
|
73945
|
-
const
|
|
73946
|
-
if (
|
|
73947
|
-
return
|
|
74043
|
+
const cached3 = this.recent.get(key);
|
|
74044
|
+
if (cached3 && this.now() - cached3.at < this.reuseMs) {
|
|
74045
|
+
return cached3.value;
|
|
73948
74046
|
}
|
|
73949
74047
|
const existing = this.inflight.get(key);
|
|
73950
74048
|
if (existing) return existing;
|
|
@@ -74279,6 +74377,18 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
74279
74377
|
return `${text.slice(0, REFINE_VALIDATION_SUMMARY_CHARS)}
|
|
74280
74378
|
[truncated ${text.length - REFINE_VALIDATION_SUMMARY_CHARS} chars]`;
|
|
74281
74379
|
}
|
|
74380
|
+
function isSpawnResolutionError(error48) {
|
|
74381
|
+
if (!error48) return false;
|
|
74382
|
+
if (error48.code === "ENOENT" && typeof error48.syscall === "string" && error48.syscall.startsWith("spawn")) return true;
|
|
74383
|
+
return error48.code === "ENOENT" && (error48.syscall === void 0 || String(error48.syscall).startsWith("spawn"));
|
|
74384
|
+
}
|
|
74385
|
+
function describeSpawnError(error48, command, spawnResolutionFailed) {
|
|
74386
|
+
if (spawnResolutionFailed) {
|
|
74387
|
+
const hint = process.platform === "win32" ? " On Windows, npm-family commands (npm/npx/tsc/vitest) are .cmd shims that the bare-command spawn search does not resolve; configure an absolute path or ensure the command is on PATH." : "";
|
|
74388
|
+
return `Could not resolve executable "${command}" (spawn ENOENT).${hint}`;
|
|
74389
|
+
}
|
|
74390
|
+
return String(error48?.message || error48);
|
|
74391
|
+
}
|
|
74282
74392
|
function recordMeshRefineStage(stages, stage, status, startedAt, details) {
|
|
74283
74393
|
stages.push({
|
|
74284
74394
|
stage,
|
|
@@ -75180,8 +75290,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75180
75290
|
const startedAt = Date.now();
|
|
75181
75291
|
const cwd = candidate.cwd ? (0, import_path12.resolve)(workspace, candidate.cwd) : workspace;
|
|
75182
75292
|
const timeout = candidate.timeoutMs || REFINE_VALIDATION_TIMEOUT_MS;
|
|
75293
|
+
const resolvedCommand = resolveWin32Executable(candidate.command);
|
|
75183
75294
|
try {
|
|
75184
|
-
const result = await execFileAsync4(
|
|
75295
|
+
const result = await execFileAsync4(resolvedCommand, candidate.args, {
|
|
75185
75296
|
cwd,
|
|
75186
75297
|
encoding: "utf8",
|
|
75187
75298
|
timeout,
|
|
@@ -75190,16 +75301,17 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75190
75301
|
});
|
|
75191
75302
|
summary.bootstrapCommandsRun.push(commandRecord(candidate, cwd, startedAt, result, true, { exitCode: 0 }));
|
|
75192
75303
|
} catch (error48) {
|
|
75304
|
+
const spawnResolutionFailed = isSpawnResolutionError(error48);
|
|
75193
75305
|
summary.bootstrapCommandsRun.push(commandRecord(candidate, cwd, startedAt, error48, false, {
|
|
75194
75306
|
exitCode: typeof error48?.code === "number" ? error48.code : null,
|
|
75195
75307
|
signal: typeof error48?.signal === "string" ? error48.signal : null,
|
|
75196
75308
|
timedOut: error48?.killed === true || /timed out/i.test(String(error48?.message || "")),
|
|
75197
|
-
failureKind: "dependency_bootstrap_failed"
|
|
75309
|
+
...spawnResolutionFailed ? { failureKind: "spawn_resolution_failed", resolvedCommand } : { failureKind: "dependency_bootstrap_failed" }
|
|
75198
75310
|
}));
|
|
75199
|
-
summary.bootstrap = { stage: "failed", error:
|
|
75311
|
+
summary.bootstrap = { stage: "failed", error: describeSpawnError(error48, candidate.command, spawnResolutionFailed) };
|
|
75200
75312
|
summary.status = "failed";
|
|
75201
|
-
summary.failureKind = "dependency_bootstrap_failed";
|
|
75202
|
-
summary.failureCode = "dependency_bootstrap_failed";
|
|
75313
|
+
summary.failureKind = spawnResolutionFailed ? "spawn_resolution_failed" : "dependency_bootstrap_failed";
|
|
75314
|
+
summary.failureCode = spawnResolutionFailed ? "spawn_resolution_failed" : "dependency_bootstrap_failed";
|
|
75203
75315
|
return summary;
|
|
75204
75316
|
}
|
|
75205
75317
|
}
|
|
@@ -75222,8 +75334,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75222
75334
|
summary.failureCode = "missing_dependencies";
|
|
75223
75335
|
return summary;
|
|
75224
75336
|
}
|
|
75337
|
+
const resolvedCommand = resolveWin32Executable(candidate.command);
|
|
75225
75338
|
try {
|
|
75226
|
-
const result = await execFileAsync4(
|
|
75339
|
+
const result = await execFileAsync4(resolvedCommand, candidate.args, {
|
|
75227
75340
|
cwd,
|
|
75228
75341
|
encoding: "utf8",
|
|
75229
75342
|
timeout,
|
|
@@ -75232,16 +75345,21 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75232
75345
|
});
|
|
75233
75346
|
summary.commandsRun.push(commandRecord(candidate, cwd, startedAt, result, true, { exitCode: 0 }));
|
|
75234
75347
|
} catch (error48) {
|
|
75348
|
+
const spawnResolutionFailed = isSpawnResolutionError(error48);
|
|
75235
75349
|
const stderr = truncateValidationOutput(error48?.stderr || error48?.message);
|
|
75236
|
-
const missingDependencyFailure = /Cannot find module|MODULE_NOT_FOUND|node_modules|command not found|not found/i.test(stderr);
|
|
75350
|
+
const missingDependencyFailure = !spawnResolutionFailed && /Cannot find module|MODULE_NOT_FOUND|node_modules|command not found|not found/i.test(stderr);
|
|
75237
75351
|
summary.commandsRun.push(commandRecord(candidate, cwd, startedAt, error48, false, {
|
|
75238
75352
|
exitCode: typeof error48?.code === "number" ? error48.code : null,
|
|
75239
75353
|
signal: typeof error48?.signal === "string" ? error48.signal : null,
|
|
75240
75354
|
timedOut: error48?.killed === true || /timed out/i.test(String(error48?.message || "")),
|
|
75241
|
-
...missingDependencyFailure ? { failureKind: "missing_dependencies" } : {}
|
|
75355
|
+
...spawnResolutionFailed ? { failureKind: "spawn_resolution_failed", resolvedCommand } : missingDependencyFailure ? { failureKind: "missing_dependencies" } : {}
|
|
75242
75356
|
}));
|
|
75243
75357
|
summary.status = "failed";
|
|
75244
|
-
if (
|
|
75358
|
+
if (spawnResolutionFailed) {
|
|
75359
|
+
summary.failureKind = "spawn_resolution_failed";
|
|
75360
|
+
summary.failureCode = "spawn_resolution_failed";
|
|
75361
|
+
summary.spawnResolutionError = describeSpawnError(error48, candidate.command, true);
|
|
75362
|
+
} else if (missingDependencyFailure) {
|
|
75245
75363
|
summary.failureKind = "missing_dependencies";
|
|
75246
75364
|
summary.failureCode = "missing_dependencies";
|
|
75247
75365
|
}
|
|
@@ -75592,13 +75710,13 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75592
75710
|
};
|
|
75593
75711
|
}
|
|
75594
75712
|
getCachedAggregateMeshStatus(meshId, mesh, options) {
|
|
75595
|
-
const
|
|
75596
|
-
if (!
|
|
75597
|
-
if (
|
|
75598
|
-
let snapshot = this.cloneJsonValue(
|
|
75713
|
+
const cached3 = this.aggregateMeshStatusCache.get(meshId);
|
|
75714
|
+
if (!cached3?.snapshot || cached3.snapshot.success !== true || !Array.isArray(cached3.snapshot.nodes)) return null;
|
|
75715
|
+
if (cached3.queueRevision !== getMeshQueueRevision(meshId)) return null;
|
|
75716
|
+
let snapshot = this.cloneJsonValue(cached3.snapshot);
|
|
75599
75717
|
snapshot = this.hydrateCachedAggregateMeshStatusFromInline(snapshot, mesh, options);
|
|
75600
75718
|
if (shouldRefreshStalePendingAggregate(snapshot, options)) return null;
|
|
75601
|
-
const ageMs = Math.max(0, Date.now() -
|
|
75719
|
+
const ageMs = Math.max(0, Date.now() - cached3.builtAt);
|
|
75602
75720
|
const sourceOfTruth = snapshot.sourceOfTruth && typeof snapshot.sourceOfTruth === "object" ? snapshot.sourceOfTruth : {};
|
|
75603
75721
|
snapshot.sourceOfTruth = {
|
|
75604
75722
|
...sourceOfTruth,
|
|
@@ -75609,7 +75727,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75609
75727
|
source: "memory",
|
|
75610
75728
|
refreshReason: "memory_cache_hit",
|
|
75611
75729
|
ageMs,
|
|
75612
|
-
cachedAt: new Date(
|
|
75730
|
+
cachedAt: new Date(cached3.builtAt).toISOString(),
|
|
75613
75731
|
returnedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
75614
75732
|
}
|
|
75615
75733
|
};
|
|
@@ -75656,9 +75774,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75656
75774
|
meshId,
|
|
75657
75775
|
sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(inlineMesh))
|
|
75658
75776
|
);
|
|
75659
|
-
const
|
|
75660
|
-
if (
|
|
75661
|
-
const merged = reconcileInlineMeshCache(
|
|
75777
|
+
const cached3 = this.inlineMeshCache.get(meshId);
|
|
75778
|
+
if (cached3) {
|
|
75779
|
+
const merged = reconcileInlineMeshCache(cached3, sanitizedInlineMesh);
|
|
75662
75780
|
this.inlineMeshCache.set(meshId, merged);
|
|
75663
75781
|
return merged;
|
|
75664
75782
|
}
|
|
@@ -75668,17 +75786,17 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75668
75786
|
async getMeshForCommand(meshId, inlineMesh, options) {
|
|
75669
75787
|
const preferInline = options?.preferInline === true;
|
|
75670
75788
|
if (preferInline) {
|
|
75671
|
-
const
|
|
75672
|
-
if (
|
|
75789
|
+
const cached4 = this.getCachedInlineMesh(meshId);
|
|
75790
|
+
if (cached4) {
|
|
75673
75791
|
if (inlineMeshCarriesTransientNodeTruth(inlineMesh)) {
|
|
75674
75792
|
const merged = reconcileInlineMeshCache(
|
|
75675
|
-
|
|
75793
|
+
cached4,
|
|
75676
75794
|
this.applyInlineMeshNodeTombstones(meshId, inlineMesh)
|
|
75677
75795
|
);
|
|
75678
75796
|
this.inlineMeshCache.set(meshId, sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(merged)));
|
|
75679
75797
|
return { mesh: merged, inline: true, source: "inline_cache" };
|
|
75680
75798
|
}
|
|
75681
|
-
return { mesh:
|
|
75799
|
+
return { mesh: cached4, inline: true, source: "inline_cache" };
|
|
75682
75800
|
}
|
|
75683
75801
|
if (inlineMeshCarriesTransientNodeTruth(inlineMesh)) {
|
|
75684
75802
|
this.warmInlineMeshCache(meshId, inlineMesh);
|
|
@@ -75691,8 +75809,8 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75691
75809
|
if (mesh) return { mesh, inline: false, source: "local_config" };
|
|
75692
75810
|
} catch {
|
|
75693
75811
|
}
|
|
75694
|
-
const
|
|
75695
|
-
if (
|
|
75812
|
+
const cached3 = this.getCachedInlineMesh(meshId);
|
|
75813
|
+
if (cached3) return { mesh: cached3, inline: true, source: "inline_cache" };
|
|
75696
75814
|
const warmedInline = this.warmInlineMeshCache(meshId, inlineMesh);
|
|
75697
75815
|
return warmedInline ? { mesh: warmedInline, inline: true, source: "inline_bootstrap" } : null;
|
|
75698
75816
|
}
|
|
@@ -76502,7 +76620,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
76502
76620
|
if (validationSummary.status === "failed") {
|
|
76503
76621
|
const firstFailedCmd = Array.isArray(validationSummary.commandsRun) ? validationSummary.commandsRun.find((c) => c.success === false) : void 0;
|
|
76504
76622
|
const buildValidationFailedError = () => {
|
|
76505
|
-
const base = validationSummary.failureCode === "missing_dependencies" ? "Refinery validation dependencies are missing; merge/refine was not attempted. Configure validation.bootstrapCommands if Refinery should bootstrap dependencies before validation." : validationSummary.failureCode === "dependency_bootstrap_failed" ? "Refinery dependency/bootstrap command failed; merge/refine was not attempted." : "Refinery validation gate failed; merge/refine was not attempted.";
|
|
76623
|
+
const base = validationSummary.failureCode === "missing_dependencies" ? "Refinery validation dependencies are missing; merge/refine was not attempted. Configure validation.bootstrapCommands if Refinery should bootstrap dependencies before validation." : validationSummary.failureCode === "dependency_bootstrap_failed" ? "Refinery dependency/bootstrap command failed; merge/refine was not attempted." : validationSummary.failureCode === "spawn_resolution_failed" ? validationSummary.spawnResolutionError || "Refinery validation command could not be spawned (executable not found); merge/refine was not attempted." : "Refinery validation gate failed; merge/refine was not attempted.";
|
|
76506
76624
|
if (!firstFailedCmd) return base;
|
|
76507
76625
|
const cmdName = typeof firstFailedCmd.displayCommand === "string" ? firstFailedCmd.displayCommand : typeof firstFailedCmd.command === "string" ? [firstFailedCmd.command, ...Array.isArray(firstFailedCmd.args) ? firstFailedCmd.args : []].join(" ").trim() : typeof firstFailedCmd.cmd === "string" ? firstFailedCmd.cmd : "";
|
|
76508
76626
|
const rawOutput = [firstFailedCmd.stdout, firstFailedCmd.stderr, firstFailedCmd.output].filter((s) => typeof s === "string" && s.length > 0).join("\n");
|
|
@@ -77122,8 +77240,8 @@ ${hintLines.join("\n")}` : "",
|
|
|
77122
77240
|
const repoRootBaseRef = /* @__PURE__ */ new Map();
|
|
77123
77241
|
const submodulePathsByRepoRoot = /* @__PURE__ */ new Map();
|
|
77124
77242
|
const resolveBaseRef = async (repoRoot) => {
|
|
77125
|
-
const
|
|
77126
|
-
if (
|
|
77243
|
+
const cached3 = repoRootBaseRef.get(repoRoot);
|
|
77244
|
+
if (cached3) return cached3;
|
|
77127
77245
|
let baseBranch = "main";
|
|
77128
77246
|
try {
|
|
77129
77247
|
const { stdout } = await execFileAsync4("git", ["branch", "--show-current"], { cwd: repoRoot, encoding: "utf8" });
|