@adhdev/daemon-standalone 0.9.82-rc.333 → 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 +607 -528
- 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
|
}
|
|
@@ -33012,6 +33012,314 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
33012
33012
|
ledgerImportDone = /* @__PURE__ */ new Set();
|
|
33013
33013
|
}
|
|
33014
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
|
+
});
|
|
33015
33323
|
var mesh_work_queue_exports = {};
|
|
33016
33324
|
__export2(mesh_work_queue_exports, {
|
|
33017
33325
|
ACTIVE_MESH_QUEUE_STATUSES: () => ACTIVE_MESH_QUEUE_STATUSES,
|
|
@@ -33475,11 +33783,18 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
33475
33783
|
}
|
|
33476
33784
|
function updateSessionTaskStatus(meshId, sessionId, status, opts) {
|
|
33477
33785
|
return withQueueLock(meshId, () => {
|
|
33786
|
+
const store = MeshRuntimeStore.getInstance();
|
|
33478
33787
|
const occurredAtIso = opts?.occurredAt ? new Date(opts.occurredAt).toISOString() : void 0;
|
|
33479
|
-
const entry =
|
|
33480
|
-
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
|
+
}
|
|
33481
33796
|
entry.status = status;
|
|
33482
|
-
|
|
33797
|
+
store.updateQueueEntry(entry);
|
|
33483
33798
|
if (DEPENDENCY_FAILURE_TERMINALS.has(status)) propagateDependencyFailure(meshId, entry.id);
|
|
33484
33799
|
return entry;
|
|
33485
33800
|
});
|
|
@@ -33597,6 +33912,7 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
33597
33912
|
init_repo_mesh_types();
|
|
33598
33913
|
init_mesh_runtime_store();
|
|
33599
33914
|
init_mesh_config();
|
|
33915
|
+
init_logger();
|
|
33600
33916
|
ACTIVE_MESH_QUEUE_STATUSES = ["pending", "assigned"];
|
|
33601
33917
|
HISTORICAL_MESH_QUEUE_STATUSES = ["completed", "failed", "cancelled"];
|
|
33602
33918
|
MESH_TASK_MODES = ["code_change", "validation", "live_debug_readonly", "launch_app", "convergence"];
|
|
@@ -34256,12 +34572,51 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
34256
34572
|
return { id, nodeId: r.assigned_node_id ?? void 0, sessionId: r.assigned_session_id ?? void 0, message };
|
|
34257
34573
|
});
|
|
34258
34574
|
}
|
|
34259
|
-
|
|
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) {
|
|
34260
34593
|
this.ensureLegacyQueueMigrated(meshId);
|
|
34261
|
-
|
|
34262
|
-
|
|
34263
|
-
|
|
34264
|
-
|
|
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];
|
|
34265
34620
|
}
|
|
34266
34621
|
toRow(entry) {
|
|
34267
34622
|
return {
|
|
@@ -35512,314 +35867,6 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
35512
35867
|
MAX_CHANGED_FILES = 100;
|
|
35513
35868
|
}
|
|
35514
35869
|
});
|
|
35515
|
-
var fs32;
|
|
35516
|
-
var AsyncBatchWriter;
|
|
35517
|
-
var init_async_batch_writer = __esm2({
|
|
35518
|
-
"src/logging/async-batch-writer.ts"() {
|
|
35519
|
-
"use strict";
|
|
35520
|
-
fs32 = __toESM2(require("fs"));
|
|
35521
|
-
AsyncBatchWriter = class {
|
|
35522
|
-
// Maps filePath -> string buffer
|
|
35523
|
-
static buffers = /* @__PURE__ */ new Map();
|
|
35524
|
-
static writePromises = /* @__PURE__ */ new Map();
|
|
35525
|
-
static flushTimer = null;
|
|
35526
|
-
/**
|
|
35527
|
-
* Queues data to be written to a file asynchronously in a batch.
|
|
35528
|
-
*/
|
|
35529
|
-
static write(filePath, data) {
|
|
35530
|
-
let buf = this.buffers.get(filePath);
|
|
35531
|
-
if (!buf) {
|
|
35532
|
-
buf = [];
|
|
35533
|
-
this.buffers.set(filePath, buf);
|
|
35534
|
-
}
|
|
35535
|
-
buf.push(data);
|
|
35536
|
-
if (!this.flushTimer) {
|
|
35537
|
-
this.flushTimer = setTimeout(() => {
|
|
35538
|
-
this.flushTimer = null;
|
|
35539
|
-
this.flushAll();
|
|
35540
|
-
}, 50);
|
|
35541
|
-
}
|
|
35542
|
-
}
|
|
35543
|
-
static async flushAll() {
|
|
35544
|
-
const entries = Array.from(this.buffers.entries());
|
|
35545
|
-
this.buffers.clear();
|
|
35546
|
-
for (const [filePath, buffer] of entries) {
|
|
35547
|
-
const dataToWrite = buffer.join("");
|
|
35548
|
-
const doWrite = async () => {
|
|
35549
|
-
try {
|
|
35550
|
-
const prevPromise = this.writePromises.get(filePath);
|
|
35551
|
-
if (prevPromise) await prevPromise;
|
|
35552
|
-
await fs32.promises.appendFile(filePath, dataToWrite, { encoding: "utf-8", mode: 384 });
|
|
35553
|
-
} catch {
|
|
35554
|
-
}
|
|
35555
|
-
};
|
|
35556
|
-
const writePromise = doWrite();
|
|
35557
|
-
this.writePromises.set(filePath, writePromise);
|
|
35558
|
-
writePromise.finally(() => {
|
|
35559
|
-
if (this.writePromises.get(filePath) === writePromise) {
|
|
35560
|
-
this.writePromises.delete(filePath);
|
|
35561
|
-
}
|
|
35562
|
-
});
|
|
35563
|
-
}
|
|
35564
|
-
}
|
|
35565
|
-
};
|
|
35566
|
-
}
|
|
35567
|
-
});
|
|
35568
|
-
var logger_exports = {};
|
|
35569
|
-
__export2(logger_exports, {
|
|
35570
|
-
LOG: () => LOG2,
|
|
35571
|
-
LOG_DIR_PATH: () => LOG_DIR_PATH,
|
|
35572
|
-
LOG_PATH: () => LOG_PATH,
|
|
35573
|
-
daemonLog: () => daemonLog,
|
|
35574
|
-
getCurrentDaemonLogPath: () => getCurrentDaemonLogPath,
|
|
35575
|
-
getDaemonLogDir: () => getDaemonLogDir,
|
|
35576
|
-
getLogBufferSize: () => getLogBufferSize,
|
|
35577
|
-
getLogLevel: () => getLogLevel,
|
|
35578
|
-
getLogPath: () => getLogPath,
|
|
35579
|
-
getRecentLogs: () => getRecentLogs,
|
|
35580
|
-
installGlobalInterceptor: () => installGlobalInterceptor,
|
|
35581
|
-
setLogLevel: () => setLogLevel
|
|
35582
|
-
});
|
|
35583
|
-
function setLogLevel(level) {
|
|
35584
|
-
currentLevel = level;
|
|
35585
|
-
daemonLog("Logger", `Log level set to: ${level}`, "info");
|
|
35586
|
-
}
|
|
35587
|
-
function getLogLevel() {
|
|
35588
|
-
return currentLevel;
|
|
35589
|
-
}
|
|
35590
|
-
function getDateStr() {
|
|
35591
|
-
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
35592
|
-
}
|
|
35593
|
-
function getDaemonLogDir() {
|
|
35594
|
-
return LOG_DIR;
|
|
35595
|
-
}
|
|
35596
|
-
function getCurrentDaemonLogPath(date5 = /* @__PURE__ */ new Date()) {
|
|
35597
|
-
return path9.join(LOG_DIR, `daemon-${date5.toISOString().slice(0, 10)}.log`);
|
|
35598
|
-
}
|
|
35599
|
-
function checkDateRotation() {
|
|
35600
|
-
const today = getDateStr();
|
|
35601
|
-
if (today !== currentDate) {
|
|
35602
|
-
currentDate = today;
|
|
35603
|
-
currentLogFile = path9.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
35604
|
-
cleanOldLogs();
|
|
35605
|
-
}
|
|
35606
|
-
}
|
|
35607
|
-
function cleanOldLogs() {
|
|
35608
|
-
try {
|
|
35609
|
-
const files = fs4.readdirSync(LOG_DIR).filter((f) => f.startsWith("daemon-") && f.endsWith(".log"));
|
|
35610
|
-
const cutoff = /* @__PURE__ */ new Date();
|
|
35611
|
-
cutoff.setDate(cutoff.getDate() - MAX_LOG_DAYS);
|
|
35612
|
-
const cutoffStr = cutoff.toISOString().slice(0, 10);
|
|
35613
|
-
for (const file2 of files) {
|
|
35614
|
-
const dateMatch = file2.match(/daemon-(\d{4}-\d{2}-\d{2})/);
|
|
35615
|
-
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
35616
|
-
try {
|
|
35617
|
-
fs4.unlinkSync(path9.join(LOG_DIR, file2));
|
|
35618
|
-
} catch {
|
|
35619
|
-
}
|
|
35620
|
-
}
|
|
35621
|
-
}
|
|
35622
|
-
} catch {
|
|
35623
|
-
}
|
|
35624
|
-
}
|
|
35625
|
-
function rotateSizeIfNeeded() {
|
|
35626
|
-
try {
|
|
35627
|
-
const stat2 = fs4.statSync(currentLogFile);
|
|
35628
|
-
if (stat2.size > MAX_LOG_SIZE) {
|
|
35629
|
-
const backup = currentLogFile.replace(".log", ".1.log");
|
|
35630
|
-
try {
|
|
35631
|
-
fs4.unlinkSync(backup);
|
|
35632
|
-
} catch {
|
|
35633
|
-
}
|
|
35634
|
-
fs4.renameSync(currentLogFile, backup);
|
|
35635
|
-
}
|
|
35636
|
-
} catch {
|
|
35637
|
-
}
|
|
35638
|
-
}
|
|
35639
|
-
function writeToFile(line) {
|
|
35640
|
-
try {
|
|
35641
|
-
if (++writeCount % 1e3 === 0) {
|
|
35642
|
-
checkDateRotation();
|
|
35643
|
-
rotateSizeIfNeeded();
|
|
35644
|
-
}
|
|
35645
|
-
AsyncBatchWriter.write(currentLogFile, line + "\n");
|
|
35646
|
-
} catch {
|
|
35647
|
-
}
|
|
35648
|
-
}
|
|
35649
|
-
function getRecentLogs(count = 50, minLevel = "info") {
|
|
35650
|
-
const minNum = LEVEL_NUM[minLevel];
|
|
35651
|
-
const filtered = ringBuffer.filter((e) => LEVEL_NUM[e.level] >= minNum);
|
|
35652
|
-
return filtered.slice(-count);
|
|
35653
|
-
}
|
|
35654
|
-
function getLogBufferSize() {
|
|
35655
|
-
return ringBuffer.length;
|
|
35656
|
-
}
|
|
35657
|
-
function ts() {
|
|
35658
|
-
return (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
|
|
35659
|
-
}
|
|
35660
|
-
function fullTs() {
|
|
35661
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
35662
|
-
}
|
|
35663
|
-
function daemonLog(category, msg, level = "info") {
|
|
35664
|
-
const shouldOutput = LEVEL_NUM[level] >= LEVEL_NUM[currentLevel];
|
|
35665
|
-
const label = LEVEL_LABEL[level];
|
|
35666
|
-
const line = `[${ts()}] [${label}] [${category}] ${msg}`;
|
|
35667
|
-
if (!shouldOutput) return;
|
|
35668
|
-
writeToFile(line);
|
|
35669
|
-
ringBuffer.push({ ts: Date.now(), level, category, message: msg });
|
|
35670
|
-
if (ringBuffer.length > RING_BUFFER_SIZE) {
|
|
35671
|
-
ringBuffer.splice(0, ringBuffer.length - RING_BUFFER_SIZE);
|
|
35672
|
-
}
|
|
35673
|
-
origConsoleLog(line);
|
|
35674
|
-
}
|
|
35675
|
-
function installGlobalInterceptor() {
|
|
35676
|
-
if (interceptorInstalled) return;
|
|
35677
|
-
interceptorInstalled = true;
|
|
35678
|
-
const stripAnsi4 = (str) => str.replace(/\x1B\[[0-9;]*m/g, "");
|
|
35679
|
-
const isDaemonLogLine = (msg) => /\[(DBG|INF|WRN|ERR)\]/.test(msg);
|
|
35680
|
-
console.log = (...args) => {
|
|
35681
|
-
origConsoleLog(...args);
|
|
35682
|
-
try {
|
|
35683
|
-
const msg = args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ");
|
|
35684
|
-
const clean = stripAnsi4(msg);
|
|
35685
|
-
if (isDaemonLogLine(clean)) return;
|
|
35686
|
-
const line = clean.startsWith("[20") ? clean : `[${fullTs()}] ${clean}`;
|
|
35687
|
-
writeToFile(line);
|
|
35688
|
-
const catMatch = clean.match(/\[([^\]]+)\]/);
|
|
35689
|
-
ringBuffer.push({
|
|
35690
|
-
ts: Date.now(),
|
|
35691
|
-
level: "info",
|
|
35692
|
-
category: catMatch?.[1] || "System",
|
|
35693
|
-
message: clean
|
|
35694
|
-
});
|
|
35695
|
-
if (ringBuffer.length > RING_BUFFER_SIZE) {
|
|
35696
|
-
ringBuffer.splice(0, ringBuffer.length - RING_BUFFER_SIZE);
|
|
35697
|
-
}
|
|
35698
|
-
} catch {
|
|
35699
|
-
}
|
|
35700
|
-
};
|
|
35701
|
-
console.error = (...args) => {
|
|
35702
|
-
origConsoleError(...args);
|
|
35703
|
-
try {
|
|
35704
|
-
const msg = args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ");
|
|
35705
|
-
const clean = stripAnsi4(msg);
|
|
35706
|
-
if (isDaemonLogLine(clean)) return;
|
|
35707
|
-
const line = `[${fullTs()}] [ERROR] ${clean}`;
|
|
35708
|
-
writeToFile(line);
|
|
35709
|
-
ringBuffer.push({ ts: Date.now(), level: "error", category: "System", message: clean });
|
|
35710
|
-
if (ringBuffer.length > RING_BUFFER_SIZE) {
|
|
35711
|
-
ringBuffer.splice(0, ringBuffer.length - RING_BUFFER_SIZE);
|
|
35712
|
-
}
|
|
35713
|
-
} catch {
|
|
35714
|
-
}
|
|
35715
|
-
};
|
|
35716
|
-
console.warn = (...args) => {
|
|
35717
|
-
origConsoleWarn(...args);
|
|
35718
|
-
try {
|
|
35719
|
-
const msg = args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ");
|
|
35720
|
-
const clean = stripAnsi4(msg);
|
|
35721
|
-
if (isDaemonLogLine(clean)) return;
|
|
35722
|
-
const line = `[${fullTs()}] [WARN] ${clean}`;
|
|
35723
|
-
writeToFile(line);
|
|
35724
|
-
ringBuffer.push({ ts: Date.now(), level: "warn", category: "System", message: clean });
|
|
35725
|
-
if (ringBuffer.length > RING_BUFFER_SIZE) {
|
|
35726
|
-
ringBuffer.splice(0, ringBuffer.length - RING_BUFFER_SIZE);
|
|
35727
|
-
}
|
|
35728
|
-
} catch {
|
|
35729
|
-
}
|
|
35730
|
-
};
|
|
35731
|
-
writeToFile(`
|
|
35732
|
-
=== ADHDev Daemon started at ${fullTs()} ===`);
|
|
35733
|
-
writeToFile(`Log file: ${currentLogFile}`);
|
|
35734
|
-
writeToFile(`Log level: ${currentLevel}`);
|
|
35735
|
-
}
|
|
35736
|
-
function getLogPath() {
|
|
35737
|
-
return currentLogFile;
|
|
35738
|
-
}
|
|
35739
|
-
var fs4;
|
|
35740
|
-
var path9;
|
|
35741
|
-
var os32;
|
|
35742
|
-
var LEVEL_NUM;
|
|
35743
|
-
var LEVEL_LABEL;
|
|
35744
|
-
var currentLevel;
|
|
35745
|
-
var LOG_DIR;
|
|
35746
|
-
var MAX_LOG_SIZE;
|
|
35747
|
-
var MAX_LOG_DAYS;
|
|
35748
|
-
var currentDate;
|
|
35749
|
-
var currentLogFile;
|
|
35750
|
-
var writeCount;
|
|
35751
|
-
var RING_BUFFER_SIZE;
|
|
35752
|
-
var ringBuffer;
|
|
35753
|
-
var origConsoleLog;
|
|
35754
|
-
var origConsoleError;
|
|
35755
|
-
var origConsoleWarn;
|
|
35756
|
-
var LOG2;
|
|
35757
|
-
var interceptorInstalled;
|
|
35758
|
-
var LOG_PATH;
|
|
35759
|
-
var LOG_DIR_PATH;
|
|
35760
|
-
var init_logger = __esm2({
|
|
35761
|
-
"src/logging/logger.ts"() {
|
|
35762
|
-
"use strict";
|
|
35763
|
-
fs4 = __toESM2(require("fs"));
|
|
35764
|
-
path9 = __toESM2(require("path"));
|
|
35765
|
-
os32 = __toESM2(require("os"));
|
|
35766
|
-
init_async_batch_writer();
|
|
35767
|
-
LEVEL_NUM = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
35768
|
-
LEVEL_LABEL = { debug: "DBG", info: "INF", warn: "WRN", error: "ERR" };
|
|
35769
|
-
currentLevel = "info";
|
|
35770
|
-
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");
|
|
35771
|
-
MAX_LOG_SIZE = 5 * 1024 * 1024;
|
|
35772
|
-
MAX_LOG_DAYS = 7;
|
|
35773
|
-
try {
|
|
35774
|
-
fs4.mkdirSync(LOG_DIR, { recursive: true });
|
|
35775
|
-
} catch {
|
|
35776
|
-
}
|
|
35777
|
-
currentDate = getDateStr();
|
|
35778
|
-
currentLogFile = path9.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
35779
|
-
cleanOldLogs();
|
|
35780
|
-
try {
|
|
35781
|
-
const oldLog = path9.join(LOG_DIR, "daemon.log");
|
|
35782
|
-
if (fs4.existsSync(oldLog)) {
|
|
35783
|
-
const stat2 = fs4.statSync(oldLog);
|
|
35784
|
-
const oldDate = stat2.mtime.toISOString().slice(0, 10);
|
|
35785
|
-
fs4.renameSync(oldLog, path9.join(LOG_DIR, `daemon-${oldDate}.log`));
|
|
35786
|
-
}
|
|
35787
|
-
const oldLogBackup = path9.join(LOG_DIR, "daemon.log.old");
|
|
35788
|
-
if (fs4.existsSync(oldLogBackup)) {
|
|
35789
|
-
fs4.unlinkSync(oldLogBackup);
|
|
35790
|
-
}
|
|
35791
|
-
} catch {
|
|
35792
|
-
}
|
|
35793
|
-
writeCount = 0;
|
|
35794
|
-
RING_BUFFER_SIZE = 200;
|
|
35795
|
-
ringBuffer = [];
|
|
35796
|
-
origConsoleLog = console.log.bind(console);
|
|
35797
|
-
origConsoleError = console.error.bind(console);
|
|
35798
|
-
origConsoleWarn = console.warn.bind(console);
|
|
35799
|
-
LOG2 = {
|
|
35800
|
-
debug: (category, msg) => daemonLog(category, msg, "debug"),
|
|
35801
|
-
info: (category, msg) => daemonLog(category, msg, "info"),
|
|
35802
|
-
warn: (category, msg) => daemonLog(category, msg, "warn"),
|
|
35803
|
-
error: (category, msg) => daemonLog(category, msg, "error"),
|
|
35804
|
-
/**
|
|
35805
|
-
* Create a scoped logger for a specific component.
|
|
35806
|
-
* Category is baked in so callers only pass the message.
|
|
35807
|
-
*/
|
|
35808
|
-
forComponent(category) {
|
|
35809
|
-
return {
|
|
35810
|
-
debug: (msg) => daemonLog(category, msg, "debug"),
|
|
35811
|
-
info: (msg) => daemonLog(category, msg, "info"),
|
|
35812
|
-
warn: (msg) => daemonLog(category, msg, "warn"),
|
|
35813
|
-
error: (msg) => daemonLog(category, msg, "error"),
|
|
35814
|
-
asLogFn: (level = "info") => (msg) => daemonLog(category, msg, level)
|
|
35815
|
-
};
|
|
35816
|
-
}
|
|
35817
|
-
};
|
|
35818
|
-
interceptorInstalled = false;
|
|
35819
|
-
LOG_PATH = path9.join(LOG_DIR, `daemon-${getDateStr()}.log`);
|
|
35820
|
-
LOG_DIR_PATH = LOG_DIR;
|
|
35821
|
-
}
|
|
35822
|
-
});
|
|
35823
35870
|
var mesh_coordinator_exports = {};
|
|
35824
35871
|
__export2(mesh_coordinator_exports, {
|
|
35825
35872
|
applyMeshCoordinatorSystemPromptInjection: () => applyMeshCoordinatorSystemPromptInjection,
|
|
@@ -36227,6 +36274,61 @@ ${rendered}`, "utf-8");
|
|
|
36227
36274
|
HERMES_MCP_CONFIG_PATH = "~/.hermes/config.yaml";
|
|
36228
36275
|
}
|
|
36229
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
|
+
});
|
|
36230
36332
|
async function fastForwardMeshNode(args) {
|
|
36231
36333
|
const workspace = typeof args.workspace === "string" ? args.workspace.trim() : "";
|
|
36232
36334
|
const nodeId = normalizeOptionalString(args.nodeId);
|
|
@@ -37743,9 +37845,9 @@ Next step: ${nextStep}`;
|
|
|
37743
37845
|
const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
37744
37846
|
const events = [];
|
|
37745
37847
|
for (const path422 of paths) {
|
|
37746
|
-
if (!(0,
|
|
37848
|
+
if (!(0, import_fs10.existsSync)(path422)) continue;
|
|
37747
37849
|
try {
|
|
37748
|
-
const raw = (0,
|
|
37850
|
+
const raw = (0, import_fs10.readFileSync)(path422, "utf-8");
|
|
37749
37851
|
const parsed = raw.split("\n").filter(Boolean).flatMap((line) => {
|
|
37750
37852
|
try {
|
|
37751
37853
|
return [JSON.parse(line)];
|
|
@@ -37820,11 +37922,11 @@ Next step: ${nextStep}`;
|
|
|
37820
37922
|
}
|
|
37821
37923
|
function trimPendingEventsIfNeeded(path422) {
|
|
37822
37924
|
try {
|
|
37823
|
-
if (!(0,
|
|
37824
|
-
if ((0,
|
|
37825
|
-
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);
|
|
37826
37928
|
if (lines.length <= MAX_PENDING_EVENTS_KEEP) return;
|
|
37827
|
-
(0,
|
|
37929
|
+
(0, import_fs10.writeFileSync)(path422, lines.slice(-MAX_PENDING_EVENTS_KEEP).join("\n") + "\n", "utf-8");
|
|
37828
37930
|
} catch {
|
|
37829
37931
|
}
|
|
37830
37932
|
}
|
|
@@ -37853,7 +37955,7 @@ Next step: ${nextStep}`;
|
|
|
37853
37955
|
}
|
|
37854
37956
|
const path422 = getPendingEventsPath(event.meshId, event.targetCoordinatorDaemonId);
|
|
37855
37957
|
trimPendingEventsIfNeeded(path422);
|
|
37856
|
-
(0,
|
|
37958
|
+
(0, import_fs10.appendFileSync)(path422, JSON.stringify(event) + "\n", "utf-8");
|
|
37857
37959
|
return true;
|
|
37858
37960
|
} catch (e) {
|
|
37859
37961
|
LOG2.warn("MeshEvents", `Failed to persist pending coordinator event: ${e?.message || e}`);
|
|
@@ -37863,20 +37965,20 @@ Next step: ${nextStep}`;
|
|
|
37863
37965
|
function atomicDrainFile(path422) {
|
|
37864
37966
|
const tmpPath = `${path422}.draining`;
|
|
37865
37967
|
try {
|
|
37866
|
-
(0,
|
|
37968
|
+
(0, import_fs10.renameSync)(path422, tmpPath);
|
|
37867
37969
|
} catch {
|
|
37868
37970
|
return null;
|
|
37869
37971
|
}
|
|
37870
37972
|
try {
|
|
37871
|
-
const content = (0,
|
|
37973
|
+
const content = (0, import_fs10.readFileSync)(tmpPath, "utf-8");
|
|
37872
37974
|
try {
|
|
37873
|
-
(0,
|
|
37975
|
+
(0, import_fs10.unlinkSync)(tmpPath);
|
|
37874
37976
|
} catch {
|
|
37875
37977
|
}
|
|
37876
37978
|
return content;
|
|
37877
37979
|
} catch {
|
|
37878
37980
|
try {
|
|
37879
|
-
(0,
|
|
37981
|
+
(0, import_fs10.unlinkSync)(tmpPath);
|
|
37880
37982
|
} catch {
|
|
37881
37983
|
}
|
|
37882
37984
|
return null;
|
|
@@ -37885,16 +37987,16 @@ Next step: ${nextStep}`;
|
|
|
37885
37987
|
function selectiveDrainFile(path422, predicate) {
|
|
37886
37988
|
const tmpPath = `${path422}.draining`;
|
|
37887
37989
|
try {
|
|
37888
|
-
(0,
|
|
37990
|
+
(0, import_fs10.renameSync)(path422, tmpPath);
|
|
37889
37991
|
} catch {
|
|
37890
37992
|
return [];
|
|
37891
37993
|
}
|
|
37892
37994
|
let content;
|
|
37893
37995
|
try {
|
|
37894
|
-
content = (0,
|
|
37996
|
+
content = (0, import_fs10.readFileSync)(tmpPath, "utf-8");
|
|
37895
37997
|
} catch {
|
|
37896
37998
|
try {
|
|
37897
|
-
(0,
|
|
37999
|
+
(0, import_fs10.unlinkSync)(tmpPath);
|
|
37898
38000
|
} catch {
|
|
37899
38001
|
}
|
|
37900
38002
|
return [];
|
|
@@ -37917,12 +38019,12 @@ Next step: ${nextStep}`;
|
|
|
37917
38019
|
}
|
|
37918
38020
|
try {
|
|
37919
38021
|
if (keptLines.length > 0) {
|
|
37920
|
-
(0,
|
|
38022
|
+
(0, import_fs10.writeFileSync)(path422, keptLines.join("\n") + "\n", "utf-8");
|
|
37921
38023
|
}
|
|
37922
|
-
(0,
|
|
38024
|
+
(0, import_fs10.unlinkSync)(tmpPath);
|
|
37923
38025
|
} catch {
|
|
37924
38026
|
try {
|
|
37925
|
-
if ((0,
|
|
38027
|
+
if ((0, import_fs10.existsSync)(tmpPath) && !(0, import_fs10.existsSync)(path422)) (0, import_fs10.renameSync)(tmpPath, path422);
|
|
37926
38028
|
} catch {
|
|
37927
38029
|
}
|
|
37928
38030
|
return [];
|
|
@@ -38016,13 +38118,13 @@ Next step: ${nextStep}`;
|
|
|
38016
38118
|
}
|
|
38017
38119
|
const paths = coordinatorDaemonId ? [getPendingEventsPath(meshId, coordinatorDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
|
|
38018
38120
|
for (const path422 of paths) {
|
|
38019
|
-
if ((0,
|
|
38020
|
-
(0,
|
|
38121
|
+
if ((0, import_fs10.existsSync)(path422)) try {
|
|
38122
|
+
(0, import_fs10.unlinkSync)(path422);
|
|
38021
38123
|
} catch {
|
|
38022
38124
|
}
|
|
38023
38125
|
}
|
|
38024
38126
|
}
|
|
38025
|
-
var
|
|
38127
|
+
var import_fs10;
|
|
38026
38128
|
var import_path9;
|
|
38027
38129
|
var import_crypto7;
|
|
38028
38130
|
var REFINE_TERMINAL_EVENTS;
|
|
@@ -38031,7 +38133,7 @@ Next step: ${nextStep}`;
|
|
|
38031
38133
|
var init_mesh_events_pending = __esm2({
|
|
38032
38134
|
"src/mesh/mesh-events-pending.ts"() {
|
|
38033
38135
|
"use strict";
|
|
38034
|
-
|
|
38136
|
+
import_fs10 = require("fs");
|
|
38035
38137
|
import_path9 = require("path");
|
|
38036
38138
|
import_crypto7 = require("crypto");
|
|
38037
38139
|
init_logger();
|
|
@@ -38521,24 +38623,24 @@ Next step: ${nextStep}`;
|
|
|
38521
38623
|
function findBinary(name) {
|
|
38522
38624
|
const trimmed = String(name || "").trim();
|
|
38523
38625
|
if (!trimmed) return trimmed;
|
|
38524
|
-
const expanded = trimmed.startsWith("~") ?
|
|
38525
|
-
if (
|
|
38526
|
-
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);
|
|
38527
38629
|
}
|
|
38528
38630
|
const isWin = os52.platform() === "win32";
|
|
38529
|
-
const paths = (process.env.PATH || "").split(
|
|
38631
|
+
const paths = (process.env.PATH || "").split(path11.delimiter);
|
|
38530
38632
|
const extraDirs = [];
|
|
38531
38633
|
if (isWin) {
|
|
38532
|
-
if (process.env.APPDATA) extraDirs.push(
|
|
38634
|
+
if (process.env.APPDATA) extraDirs.push(path11.join(process.env.APPDATA, "npm"));
|
|
38533
38635
|
try {
|
|
38534
|
-
extraDirs.push(
|
|
38636
|
+
extraDirs.push(path11.dirname(process.execPath));
|
|
38535
38637
|
} catch {
|
|
38536
38638
|
}
|
|
38537
38639
|
} else {
|
|
38538
|
-
extraDirs.push(
|
|
38640
|
+
extraDirs.push(path11.join(os52.homedir(), ".npm-global", "bin"));
|
|
38539
38641
|
extraDirs.push("/usr/local/bin", "/opt/homebrew/bin");
|
|
38540
38642
|
try {
|
|
38541
|
-
extraDirs.push(
|
|
38643
|
+
extraDirs.push(path11.dirname(process.execPath));
|
|
38542
38644
|
} catch {
|
|
38543
38645
|
}
|
|
38544
38646
|
}
|
|
@@ -38547,7 +38649,7 @@ Next step: ${nextStep}`;
|
|
|
38547
38649
|
for (const p of searchDirs) {
|
|
38548
38650
|
if (!p) continue;
|
|
38549
38651
|
for (const ext of exes) {
|
|
38550
|
-
const fullPath =
|
|
38652
|
+
const fullPath = path11.join(p, trimmed + ext);
|
|
38551
38653
|
try {
|
|
38552
38654
|
const fs322 = require("fs");
|
|
38553
38655
|
if (fs322.existsSync(fullPath)) {
|
|
@@ -38563,7 +38665,7 @@ Next step: ${nextStep}`;
|
|
|
38563
38665
|
return isWin ? `${trimmed}.cmd` : trimmed;
|
|
38564
38666
|
}
|
|
38565
38667
|
function isScriptBinary(binaryPath) {
|
|
38566
|
-
if (!
|
|
38668
|
+
if (!path11.isAbsolute(binaryPath)) return false;
|
|
38567
38669
|
try {
|
|
38568
38670
|
const fs322 = require("fs");
|
|
38569
38671
|
const resolved = fs322.realpathSync(binaryPath);
|
|
@@ -38579,7 +38681,7 @@ Next step: ${nextStep}`;
|
|
|
38579
38681
|
}
|
|
38580
38682
|
}
|
|
38581
38683
|
function looksLikeMachOOrElf(filePath) {
|
|
38582
|
-
if (!
|
|
38684
|
+
if (!path11.isAbsolute(filePath)) return false;
|
|
38583
38685
|
try {
|
|
38584
38686
|
const fs322 = require("fs");
|
|
38585
38687
|
const resolved = fs322.realpathSync(filePath);
|
|
@@ -38669,14 +38771,14 @@ Next step: ${nextStep}`;
|
|
|
38669
38771
|
};
|
|
38670
38772
|
}
|
|
38671
38773
|
var os52;
|
|
38672
|
-
var
|
|
38774
|
+
var path11;
|
|
38673
38775
|
var TerminalTranscriptAccumulator;
|
|
38674
38776
|
var buildCliSpawnEnv;
|
|
38675
38777
|
var init_provider_cli_shared = __esm2({
|
|
38676
38778
|
"src/cli-adapters/provider-cli-shared.ts"() {
|
|
38677
38779
|
"use strict";
|
|
38678
38780
|
os52 = __toESM2(require("os"));
|
|
38679
|
-
|
|
38781
|
+
path11 = __toESM2(require("path"));
|
|
38680
38782
|
init_spawn_env();
|
|
38681
38783
|
TerminalTranscriptAccumulator = class {
|
|
38682
38784
|
lines = [[]];
|
|
@@ -38848,19 +38950,19 @@ Next step: ${nextStep}`;
|
|
|
38848
38950
|
function expandHome(value) {
|
|
38849
38951
|
const trimmed = value.trim();
|
|
38850
38952
|
if (!trimmed.startsWith("~")) return trimmed;
|
|
38851
|
-
return
|
|
38953
|
+
return path12.join(os6.homedir(), trimmed.slice(1));
|
|
38852
38954
|
}
|
|
38853
38955
|
function isExplicitCommandPath(command) {
|
|
38854
38956
|
const trimmed = command.trim();
|
|
38855
|
-
return
|
|
38957
|
+
return path12.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
|
|
38856
38958
|
}
|
|
38857
38959
|
function resolveCommandPath(command) {
|
|
38858
38960
|
const trimmed = command.trim();
|
|
38859
38961
|
if (!trimmed) return null;
|
|
38860
38962
|
if (isExplicitCommandPath(trimmed)) {
|
|
38861
38963
|
const expanded = expandHome(trimmed);
|
|
38862
|
-
const candidate =
|
|
38863
|
-
return (0,
|
|
38964
|
+
const candidate = path12.isAbsolute(expanded) ? expanded : path12.resolve(expanded);
|
|
38965
|
+
return (0, import_fs11.existsSync)(candidate) ? candidate : null;
|
|
38864
38966
|
}
|
|
38865
38967
|
return null;
|
|
38866
38968
|
}
|
|
@@ -38870,12 +38972,12 @@ Next step: ${nextStep}`;
|
|
|
38870
38972
|
const whichResult = await execAsync(`${whichCmd} ${shellQuote(command)}`);
|
|
38871
38973
|
if (whichResult) return whichResult.split("\n")[0];
|
|
38872
38974
|
const resolved = findBinary(command);
|
|
38873
|
-
if (
|
|
38975
|
+
if (path12.isAbsolute(resolved) && (0, import_fs11.existsSync)(resolved)) return resolved;
|
|
38874
38976
|
return null;
|
|
38875
38977
|
}
|
|
38876
38978
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
38877
38979
|
return new Promise((resolve24) => {
|
|
38878
|
-
const child = (0,
|
|
38980
|
+
const child = (0, import_child_process2.exec)(cmd, {
|
|
38879
38981
|
encoding: "utf-8",
|
|
38880
38982
|
timeout: timeoutMs,
|
|
38881
38983
|
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
@@ -38965,17 +39067,17 @@ Next step: ${nextStep}`;
|
|
|
38965
39067
|
const all = await detectCLIs(providerLoader, options);
|
|
38966
39068
|
return all.find((c) => c.id === resolvedId && c.installed) || null;
|
|
38967
39069
|
}
|
|
38968
|
-
var
|
|
39070
|
+
var import_child_process2;
|
|
38969
39071
|
var os6;
|
|
38970
|
-
var
|
|
38971
|
-
var
|
|
39072
|
+
var path12;
|
|
39073
|
+
var import_fs11;
|
|
38972
39074
|
var init_cli_detector = __esm2({
|
|
38973
39075
|
"src/detection/cli-detector.ts"() {
|
|
38974
39076
|
"use strict";
|
|
38975
|
-
|
|
39077
|
+
import_child_process2 = require("child_process");
|
|
38976
39078
|
os6 = __toESM2(require("os"));
|
|
38977
|
-
|
|
38978
|
-
|
|
39079
|
+
path12 = __toESM2(require("path"));
|
|
39080
|
+
import_fs11 = require("fs");
|
|
38979
39081
|
init_provider_cli_shared();
|
|
38980
39082
|
}
|
|
38981
39083
|
});
|
|
@@ -40008,7 +40110,7 @@ Next step: ${nextStep}`;
|
|
|
40008
40110
|
const node = mesh?.nodes?.find((candidate) => meshNodeIdMatches(candidate, args.nodeId));
|
|
40009
40111
|
const workspace = readNonEmptyString2(node?.workspace);
|
|
40010
40112
|
if (!workspace) return;
|
|
40011
|
-
if (!(0,
|
|
40113
|
+
if (!(0, import_fs12.existsSync)(workspace)) return;
|
|
40012
40114
|
const policy = resolveAutoFastForwardPolicy(mesh);
|
|
40013
40115
|
if (!policy.enabled) return;
|
|
40014
40116
|
if (nodeHasActiveMeshWork(components, args.meshId, args.nodeId, args.sessionId)) return;
|
|
@@ -40207,8 +40309,10 @@ Next step: ${nextStep}`;
|
|
|
40207
40309
|
}
|
|
40208
40310
|
}
|
|
40209
40311
|
function markSessionTerminal(sessionId, outcome, occurredAtMs) {
|
|
40312
|
+
const eventTaskId = readNonEmptyString2(args.metadataEvent.taskId) || void 0;
|
|
40210
40313
|
const task = updateSessionTaskStatus(args.meshId, sessionId, outcome, {
|
|
40211
|
-
occurredAt: occurredAtMs != null ? new Date(occurredAtMs).toISOString() : void 0
|
|
40314
|
+
occurredAt: occurredAtMs != null ? new Date(occurredAtMs).toISOString() : void 0,
|
|
40315
|
+
taskId: eventTaskId
|
|
40212
40316
|
});
|
|
40213
40317
|
updateDirectDispatchStatus(args.meshId, sessionId, outcome);
|
|
40214
40318
|
markSessionDeliveriesTerminal(args.meshId, sessionId, outcome);
|
|
@@ -40619,7 +40723,7 @@ Next step: ${nextStep}`;
|
|
|
40619
40723
|
});
|
|
40620
40724
|
});
|
|
40621
40725
|
}
|
|
40622
|
-
var
|
|
40726
|
+
var import_fs12;
|
|
40623
40727
|
var REMOTE_IDLE_SESSION_TTL_MS;
|
|
40624
40728
|
var meshByWorkspaceCache;
|
|
40625
40729
|
var MESH_WORKSPACE_CACHE_TTL_MS;
|
|
@@ -40639,7 +40743,7 @@ Next step: ${nextStep}`;
|
|
|
40639
40743
|
var init_mesh_events_coordinator = __esm2({
|
|
40640
40744
|
"src/mesh/mesh-events-coordinator.ts"() {
|
|
40641
40745
|
"use strict";
|
|
40642
|
-
|
|
40746
|
+
import_fs12 = require("fs");
|
|
40643
40747
|
init_config();
|
|
40644
40748
|
init_mesh_config();
|
|
40645
40749
|
init_cli_detector();
|
|
@@ -42522,16 +42626,16 @@ Next step: ${nextStep}`;
|
|
|
42522
42626
|
sourcesProviding: () => sourcesProviding
|
|
42523
42627
|
});
|
|
42524
42628
|
function adhdevDir() {
|
|
42525
|
-
return
|
|
42629
|
+
return path18.join(os11.homedir(), ".adhdev");
|
|
42526
42630
|
}
|
|
42527
42631
|
function externalRoot() {
|
|
42528
|
-
return
|
|
42632
|
+
return path18.join(adhdevDir(), "external");
|
|
42529
42633
|
}
|
|
42530
42634
|
function sourcesFilePath() {
|
|
42531
|
-
return
|
|
42635
|
+
return path18.join(adhdevDir(), SOURCES_FILENAME);
|
|
42532
42636
|
}
|
|
42533
42637
|
function activeFilePath() {
|
|
42534
|
-
return
|
|
42638
|
+
return path18.join(adhdevDir(), ACTIVE_FILENAME);
|
|
42535
42639
|
}
|
|
42536
42640
|
function ensureAdhdevDir() {
|
|
42537
42641
|
const d = adhdevDir();
|
|
@@ -42598,7 +42702,7 @@ Next step: ${nextStep}`;
|
|
|
42598
42702
|
for (const sourceEntry of entries) {
|
|
42599
42703
|
if (!sourceEntry.isDirectory()) continue;
|
|
42600
42704
|
const sourceName = sourceEntry.name;
|
|
42601
|
-
const sourceDir =
|
|
42705
|
+
const sourceDir = path18.join(root, sourceName);
|
|
42602
42706
|
const providers = {};
|
|
42603
42707
|
let categoryEntries;
|
|
42604
42708
|
try {
|
|
@@ -42609,7 +42713,7 @@ Next step: ${nextStep}`;
|
|
|
42609
42713
|
for (const categoryEntry of categoryEntries) {
|
|
42610
42714
|
if (!categoryEntry.isDirectory()) continue;
|
|
42611
42715
|
const category = categoryEntry.name;
|
|
42612
|
-
const categoryDir =
|
|
42716
|
+
const categoryDir = path18.join(sourceDir, category);
|
|
42613
42717
|
let typeEntries;
|
|
42614
42718
|
try {
|
|
42615
42719
|
typeEntries = fs9.readdirSync(categoryDir, { withFileTypes: true });
|
|
@@ -42619,9 +42723,9 @@ Next step: ${nextStep}`;
|
|
|
42619
42723
|
const types = [];
|
|
42620
42724
|
for (const typeEntry of typeEntries) {
|
|
42621
42725
|
if (!typeEntry.isDirectory()) continue;
|
|
42622
|
-
const typeDir =
|
|
42623
|
-
const hasV1 = fs9.existsSync(
|
|
42624
|
-
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"));
|
|
42625
42729
|
if (hasV1 || hasV0) types.push(typeEntry.name);
|
|
42626
42730
|
}
|
|
42627
42731
|
if (types.length > 0) providers[category] = types;
|
|
@@ -42646,7 +42750,7 @@ Next step: ${nextStep}`;
|
|
|
42646
42750
|
}
|
|
42647
42751
|
var fs9;
|
|
42648
42752
|
var os11;
|
|
42649
|
-
var
|
|
42753
|
+
var path18;
|
|
42650
42754
|
var SOURCES_FILENAME;
|
|
42651
42755
|
var ACTIVE_FILENAME;
|
|
42652
42756
|
var init_external_sources = __esm2({
|
|
@@ -42654,7 +42758,7 @@ Next step: ${nextStep}`;
|
|
|
42654
42758
|
"use strict";
|
|
42655
42759
|
fs9 = __toESM2(require("fs"));
|
|
42656
42760
|
os11 = __toESM2(require("os"));
|
|
42657
|
-
|
|
42761
|
+
path18 = __toESM2(require("path"));
|
|
42658
42762
|
SOURCES_FILENAME = "providers-sources.json";
|
|
42659
42763
|
ACTIVE_FILENAME = "providers-active.json";
|
|
42660
42764
|
}
|
|
@@ -42832,61 +42936,6 @@ Next step: ${nextStep}`;
|
|
|
42832
42936
|
};
|
|
42833
42937
|
}
|
|
42834
42938
|
});
|
|
42835
|
-
function resolveWin32GlobalBin(trimmed) {
|
|
42836
|
-
if (path18.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\")) {
|
|
42837
|
-
return null;
|
|
42838
|
-
}
|
|
42839
|
-
const extraDirs = [];
|
|
42840
|
-
if (process.env.APPDATA) extraDirs.push(path18.join(process.env.APPDATA, "npm"));
|
|
42841
|
-
try {
|
|
42842
|
-
extraDirs.push(path18.dirname(process.execPath));
|
|
42843
|
-
} catch {
|
|
42844
|
-
}
|
|
42845
|
-
for (const dir of extraDirs) {
|
|
42846
|
-
if (!dir) continue;
|
|
42847
|
-
for (const ext of WIN_EXEC_EXT) {
|
|
42848
|
-
const full = path18.join(dir, trimmed + ext);
|
|
42849
|
-
if ((0, import_fs14.existsSync)(full)) return full;
|
|
42850
|
-
}
|
|
42851
|
-
}
|
|
42852
|
-
return null;
|
|
42853
|
-
}
|
|
42854
|
-
function resolveWin32Executable(command) {
|
|
42855
|
-
if (process.platform !== "win32") return command;
|
|
42856
|
-
const trimmed = (command || "").trim();
|
|
42857
|
-
if (!trimmed) return command;
|
|
42858
|
-
if (path18.isAbsolute(trimmed) && (0, import_fs14.existsSync)(trimmed)) return trimmed;
|
|
42859
|
-
try {
|
|
42860
|
-
const out = (0, import_child_process4.execFileSync)("where", [trimmed], {
|
|
42861
|
-
encoding: "utf8",
|
|
42862
|
-
windowsHide: true
|
|
42863
|
-
}).trim();
|
|
42864
|
-
if (out) {
|
|
42865
|
-
const matches = out.split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
|
|
42866
|
-
const direct = matches.find((m) => DIRECT_EXEC_EXT.has(path18.extname(m).toLowerCase()));
|
|
42867
|
-
return direct || matches[0] || command;
|
|
42868
|
-
}
|
|
42869
|
-
} catch {
|
|
42870
|
-
}
|
|
42871
|
-
const globalBin = resolveWin32GlobalBin(trimmed);
|
|
42872
|
-
if (globalBin) return globalBin;
|
|
42873
|
-
return command;
|
|
42874
|
-
}
|
|
42875
|
-
var import_child_process4;
|
|
42876
|
-
var import_fs14;
|
|
42877
|
-
var path18;
|
|
42878
|
-
var DIRECT_EXEC_EXT;
|
|
42879
|
-
var WIN_EXEC_EXT;
|
|
42880
|
-
var init_resolve_executable = __esm2({
|
|
42881
|
-
"src/cli-adapters/resolve-executable.ts"() {
|
|
42882
|
-
"use strict";
|
|
42883
|
-
import_child_process4 = require("child_process");
|
|
42884
|
-
import_fs14 = require("fs");
|
|
42885
|
-
path18 = __toESM2(require("path"));
|
|
42886
|
-
DIRECT_EXEC_EXT = /* @__PURE__ */ new Set([".exe", ".com"]);
|
|
42887
|
-
WIN_EXEC_EXT = [".exe", ".com", ".cmd", ".bat"];
|
|
42888
|
-
}
|
|
42889
|
-
});
|
|
42890
42939
|
var pty_transport_exports = {};
|
|
42891
42940
|
__export2(pty_transport_exports, {
|
|
42892
42941
|
NodePtyTransportFactory: () => NodePtyTransportFactory
|
|
@@ -49556,13 +49605,20 @@ ${lastSnapshot}`;
|
|
|
49556
49605
|
function isMeshConfigRecord(value) {
|
|
49557
49606
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
49558
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_@./:=+\\-]+$/;
|
|
49559
49611
|
function tokenizeCommandString(command) {
|
|
49560
49612
|
const trimmed = command.trim();
|
|
49561
49613
|
if (!trimmed) return null;
|
|
49562
|
-
if (
|
|
49614
|
+
if (SHELL_METACHAR_RE.test(trimmed)) return null;
|
|
49563
49615
|
const tokens = trimmed.split(/\s+/).filter(Boolean);
|
|
49564
49616
|
if (!tokens.length) return null;
|
|
49565
|
-
|
|
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
|
+
}
|
|
49566
49622
|
return tokens;
|
|
49567
49623
|
}
|
|
49568
49624
|
function validateCategory(value) {
|
|
@@ -49770,12 +49826,13 @@ ${lastSnapshot}`;
|
|
|
49770
49826
|
unavailableReason: validation.commands.length ? void 0 : "validation_unavailable: repo mesh/refine config has no validation.commands"
|
|
49771
49827
|
};
|
|
49772
49828
|
}
|
|
49773
|
-
var
|
|
49829
|
+
var import_fs9 = require("fs");
|
|
49774
49830
|
var import_path8 = require("path");
|
|
49775
49831
|
var import_node_child_process3 = require("child_process");
|
|
49776
49832
|
var import_node_crypto2 = require("crypto");
|
|
49777
49833
|
var import_node_util3 = require("util");
|
|
49778
49834
|
var yaml3 = __toESM2(require_js_yaml());
|
|
49835
|
+
init_resolve_executable();
|
|
49779
49836
|
var MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS = [
|
|
49780
49837
|
".adhdev/worktree_bootstrap.json",
|
|
49781
49838
|
".adhdev/worktree_bootstrap.yaml",
|
|
@@ -49863,9 +49920,9 @@ ${lastSnapshot}`;
|
|
|
49863
49920
|
}
|
|
49864
49921
|
for (const relative5 of MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS) {
|
|
49865
49922
|
const configPath = (0, import_path8.join)(workspace, relative5);
|
|
49866
|
-
if (!(0,
|
|
49923
|
+
if (!(0, import_fs9.existsSync)(configPath)) continue;
|
|
49867
49924
|
try {
|
|
49868
|
-
const parsed = parseConfigText3(configPath, (0,
|
|
49925
|
+
const parsed = parseConfigText3(configPath, (0, import_fs9.readFileSync)(configPath, "utf-8"));
|
|
49869
49926
|
const validation = validateMeshWorktreeBootstrapConfig(parsed, relative5);
|
|
49870
49927
|
if (!validation.valid) return { source: relative5, sourceType: "invalid", path: configPath, error: String(validation.rejectedCommands[0]?.reason || validation.errors.join("; ")) };
|
|
49871
49928
|
return { config: parsed, source: relative5, sourceType: "repo_file", path: configPath };
|
|
@@ -49880,7 +49937,7 @@ ${lastSnapshot}`;
|
|
|
49880
49937
|
for (const relative5 of staleInputs ?? []) {
|
|
49881
49938
|
const filePath = (0, import_path8.join)(workspace, relative5);
|
|
49882
49939
|
try {
|
|
49883
|
-
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");
|
|
49884
49941
|
} catch {
|
|
49885
49942
|
digest[relative5] = "absent";
|
|
49886
49943
|
}
|
|
@@ -49950,10 +50007,10 @@ ${lastSnapshot}`;
|
|
|
49950
50007
|
staleInputs: loaded.config.staleInputs
|
|
49951
50008
|
};
|
|
49952
50009
|
const staleInputPaths = loaded.config.staleInputs ?? [];
|
|
49953
|
-
const initiallyAbsent = staleInputPaths.filter((p) => !(0,
|
|
50010
|
+
const initiallyAbsent = staleInputPaths.filter((p) => !(0, import_fs9.existsSync)((0, import_path8.join)(workspace, p)));
|
|
49954
50011
|
for (const command of validation.commands) {
|
|
49955
50012
|
if (initiallyAbsent.length > 0) {
|
|
49956
|
-
const appearedNow = initiallyAbsent.filter((p) => (0,
|
|
50013
|
+
const appearedNow = initiallyAbsent.filter((p) => (0, import_fs9.existsSync)((0, import_path8.join)(workspace, p)));
|
|
49957
50014
|
if (appearedNow.length > 0) {
|
|
49958
50015
|
state.status = "stale";
|
|
49959
50016
|
state.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -49964,8 +50021,9 @@ ${lastSnapshot}`;
|
|
|
49964
50021
|
const cwd = command.cwd ? (0, import_path8.resolve)(workspace, command.cwd) : workspace;
|
|
49965
50022
|
const startedAt = Date.now();
|
|
49966
50023
|
state.lastCommand = command.displayCommand;
|
|
50024
|
+
const resolvedCommand = resolveWin32Executable(command.command);
|
|
49967
50025
|
try {
|
|
49968
|
-
const result = await execFileAsync4(
|
|
50026
|
+
const result = await execFileAsync4(resolvedCommand, command.args, {
|
|
49969
50027
|
cwd,
|
|
49970
50028
|
encoding: "utf8",
|
|
49971
50029
|
timeout: command.timeoutMs || DEFAULT_TIMEOUT_MS2,
|
|
@@ -50190,7 +50248,7 @@ ${lastSnapshot}`;
|
|
|
50190
50248
|
this.targetDaemonId = context.targetDaemonId;
|
|
50191
50249
|
}
|
|
50192
50250
|
};
|
|
50193
|
-
var
|
|
50251
|
+
var import_fs13 = require("fs");
|
|
50194
50252
|
var import_path10 = require("path");
|
|
50195
50253
|
init_config();
|
|
50196
50254
|
var DEFAULT_STATE = {
|
|
@@ -50241,11 +50299,11 @@ ${lastSnapshot}`;
|
|
|
50241
50299
|
}
|
|
50242
50300
|
function loadState() {
|
|
50243
50301
|
const statePath = getStatePath();
|
|
50244
|
-
if (!(0,
|
|
50302
|
+
if (!(0, import_fs13.existsSync)(statePath)) {
|
|
50245
50303
|
return { ...DEFAULT_STATE };
|
|
50246
50304
|
}
|
|
50247
50305
|
try {
|
|
50248
|
-
const raw = (0,
|
|
50306
|
+
const raw = (0, import_fs13.readFileSync)(statePath, "utf-8");
|
|
50249
50307
|
return normalizeState(JSON.parse(raw));
|
|
50250
50308
|
} catch {
|
|
50251
50309
|
return { ...DEFAULT_STATE };
|
|
@@ -50254,24 +50312,24 @@ ${lastSnapshot}`;
|
|
|
50254
50312
|
function saveState(state) {
|
|
50255
50313
|
const statePath = getStatePath();
|
|
50256
50314
|
const normalized = normalizeState(state);
|
|
50257
|
-
(0,
|
|
50315
|
+
(0, import_fs13.writeFileSync)(statePath, JSON.stringify(normalized, null, 2), { encoding: "utf-8", mode: 384 });
|
|
50258
50316
|
}
|
|
50259
50317
|
function resetState() {
|
|
50260
50318
|
saveState({ ...DEFAULT_STATE });
|
|
50261
50319
|
}
|
|
50262
|
-
var
|
|
50320
|
+
var import_child_process3 = require("child_process");
|
|
50263
50321
|
var import_util3 = require("util");
|
|
50264
|
-
var
|
|
50322
|
+
var import_fs14 = require("fs");
|
|
50265
50323
|
var import_os22 = require("os");
|
|
50266
|
-
var
|
|
50324
|
+
var path14 = __toESM2(require("path"));
|
|
50267
50325
|
var fs52 = __toESM2(require("fs"));
|
|
50268
|
-
var
|
|
50326
|
+
var path13 = __toESM2(require("path"));
|
|
50269
50327
|
function manifestCandidates(exeDir) {
|
|
50270
50328
|
return [
|
|
50271
|
-
|
|
50272
|
-
|
|
50329
|
+
path13.join(exeDir, "resources", "app", "product.json"),
|
|
50330
|
+
path13.join(exeDir, "resources", "app", "package.json"),
|
|
50273
50331
|
// Some packagings keep product.json one level up.
|
|
50274
|
-
|
|
50332
|
+
path13.join(exeDir, "product.json")
|
|
50275
50333
|
];
|
|
50276
50334
|
}
|
|
50277
50335
|
function parseVersionFromManifest(raw) {
|
|
@@ -50289,9 +50347,9 @@ ${lastSnapshot}`;
|
|
|
50289
50347
|
if (!exePath) return null;
|
|
50290
50348
|
let exeDir;
|
|
50291
50349
|
try {
|
|
50292
|
-
exeDir = fs52.statSync(exePath).isDirectory() ? exePath :
|
|
50350
|
+
exeDir = fs52.statSync(exePath).isDirectory() ? exePath : path13.dirname(exePath);
|
|
50293
50351
|
} catch {
|
|
50294
|
-
exeDir =
|
|
50352
|
+
exeDir = path13.dirname(exePath);
|
|
50295
50353
|
}
|
|
50296
50354
|
for (const candidate of manifestCandidates(exeDir)) {
|
|
50297
50355
|
try {
|
|
@@ -50305,7 +50363,7 @@ ${lastSnapshot}`;
|
|
|
50305
50363
|
}
|
|
50306
50364
|
function isKnownWin32GuiExe(binPath, win32ProcessNames) {
|
|
50307
50365
|
if (!binPath) return false;
|
|
50308
|
-
const base =
|
|
50366
|
+
const base = path13.win32.basename(binPath).toLowerCase();
|
|
50309
50367
|
if (!base.endsWith(".exe")) return false;
|
|
50310
50368
|
for (const names of Object.values(win32ProcessNames)) {
|
|
50311
50369
|
for (const name of names) {
|
|
@@ -50316,7 +50374,7 @@ ${lastSnapshot}`;
|
|
|
50316
50374
|
}
|
|
50317
50375
|
return false;
|
|
50318
50376
|
}
|
|
50319
|
-
var execAsync2 = (0, import_util3.promisify)(
|
|
50377
|
+
var execAsync2 = (0, import_util3.promisify)(import_child_process3.exec);
|
|
50320
50378
|
var BUILTIN_IDE_DEFINITIONS = [];
|
|
50321
50379
|
var registeredIDEs = /* @__PURE__ */ new Map();
|
|
50322
50380
|
function registerIDEDefinition(def) {
|
|
@@ -50335,10 +50393,10 @@ ${lastSnapshot}`;
|
|
|
50335
50393
|
function findCliCommand(command) {
|
|
50336
50394
|
const trimmed = String(command || "").trim();
|
|
50337
50395
|
if (!trimmed) return null;
|
|
50338
|
-
if (
|
|
50339
|
-
const candidate = trimmed.startsWith("~") ?
|
|
50340
|
-
const resolved =
|
|
50341
|
-
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;
|
|
50342
50400
|
}
|
|
50343
50401
|
const isWin = (0, import_os22.platform)() === "win32";
|
|
50344
50402
|
const paths = (process.env.PATH || "").split(isWin ? ";" : ":");
|
|
@@ -50346,10 +50404,10 @@ ${lastSnapshot}`;
|
|
|
50346
50404
|
for (const p of paths) {
|
|
50347
50405
|
if (!p) continue;
|
|
50348
50406
|
for (const ext of exes) {
|
|
50349
|
-
const fullPath =
|
|
50407
|
+
const fullPath = path14.join(p, trimmed + ext);
|
|
50350
50408
|
try {
|
|
50351
|
-
if ((0,
|
|
50352
|
-
const stat2 = (0,
|
|
50409
|
+
if ((0, import_fs14.existsSync)(fullPath)) {
|
|
50410
|
+
const stat2 = (0, import_fs14.statSync)(fullPath);
|
|
50353
50411
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
50354
50412
|
return fullPath;
|
|
50355
50413
|
}
|
|
@@ -50363,13 +50421,13 @@ ${lastSnapshot}`;
|
|
|
50363
50421
|
function checkPathExists(paths) {
|
|
50364
50422
|
const home = (0, import_os22.homedir)();
|
|
50365
50423
|
for (const p of paths) {
|
|
50366
|
-
const normalized = p.startsWith("~") ?
|
|
50424
|
+
const normalized = p.startsWith("~") ? path14.join(home, p.slice(1)) : p;
|
|
50367
50425
|
if (normalized.includes("*")) {
|
|
50368
50426
|
const username = home.split(/[\\/]/).pop() || "";
|
|
50369
50427
|
const resolved = normalized.replace("*", username);
|
|
50370
|
-
if ((0,
|
|
50428
|
+
if ((0, import_fs14.existsSync)(resolved)) return resolved;
|
|
50371
50429
|
} else {
|
|
50372
|
-
if ((0,
|
|
50430
|
+
if ((0, import_fs14.existsSync)(normalized)) return normalized;
|
|
50373
50431
|
}
|
|
50374
50432
|
}
|
|
50375
50433
|
return null;
|
|
@@ -50383,7 +50441,7 @@ ${lastSnapshot}`;
|
|
|
50383
50441
|
let resolvedCli = cliPath;
|
|
50384
50442
|
if (!resolvedCli && appPath && os30 === "darwin") {
|
|
50385
50443
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
50386
|
-
if ((0,
|
|
50444
|
+
if ((0, import_fs14.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
50387
50445
|
}
|
|
50388
50446
|
if (!resolvedCli && appPath && os30 === "win32") {
|
|
50389
50447
|
const { dirname: dirname17 } = await import("path");
|
|
@@ -50396,7 +50454,7 @@ ${lastSnapshot}`;
|
|
|
50396
50454
|
`${appDir}\\\\resources\\\\app\\\\bin\\\\${def.cli}.cmd`
|
|
50397
50455
|
];
|
|
50398
50456
|
for (const c of candidates) {
|
|
50399
|
-
if ((0,
|
|
50457
|
+
if ((0, import_fs14.existsSync)(c)) {
|
|
50400
50458
|
resolvedCli = c;
|
|
50401
50459
|
break;
|
|
50402
50460
|
}
|
|
@@ -50419,9 +50477,9 @@ ${lastSnapshot}`;
|
|
|
50419
50477
|
}
|
|
50420
50478
|
init_cli_detector();
|
|
50421
50479
|
var os72 = __toESM2(require("os"));
|
|
50422
|
-
var
|
|
50480
|
+
var import_child_process4 = require("child_process");
|
|
50423
50481
|
var import_util22 = require("util");
|
|
50424
|
-
var execAsync3 = (0, import_util22.promisify)(
|
|
50482
|
+
var execAsync3 = (0, import_util22.promisify)(import_child_process4.exec);
|
|
50425
50483
|
var cachedDarwinAvail = null;
|
|
50426
50484
|
var darwinMemoryInterval = null;
|
|
50427
50485
|
async function updateDarwinMemoryCache() {
|
|
@@ -52232,10 +52290,10 @@ ${cleanBody}`;
|
|
|
52232
52290
|
return cleanTitle || cleanBody;
|
|
52233
52291
|
}
|
|
52234
52292
|
var fs6 = __toESM2(require("fs"));
|
|
52235
|
-
var
|
|
52293
|
+
var path15 = __toESM2(require("path"));
|
|
52236
52294
|
var os8 = __toESM2(require("os"));
|
|
52237
52295
|
init_chat_message_normalization();
|
|
52238
|
-
var HISTORY_DIR =
|
|
52296
|
+
var HISTORY_DIR = path15.join(os8.homedir(), ".adhdev", "history");
|
|
52239
52297
|
var RETAIN_DAYS = 30;
|
|
52240
52298
|
var SAVED_HISTORY_INDEX_VERSION = 1;
|
|
52241
52299
|
var SAVED_HISTORY_INDEX_FILE = ".saved-history-index.json";
|
|
@@ -52421,7 +52479,7 @@ ${cleanBody}`;
|
|
|
52421
52479
|
function buildSavedHistoryFileSignatureMap(dir, files) {
|
|
52422
52480
|
return new Map(files.map((file2) => {
|
|
52423
52481
|
try {
|
|
52424
|
-
const stat2 = fs6.statSync(
|
|
52482
|
+
const stat2 = fs6.statSync(path15.join(dir, file2));
|
|
52425
52483
|
return [file2, `${file2}:${stat2.size}:${Math.trunc(stat2.mtimeMs)}`];
|
|
52426
52484
|
} catch {
|
|
52427
52485
|
return [file2, `${file2}:missing`];
|
|
@@ -52432,7 +52490,7 @@ ${cleanBody}`;
|
|
|
52432
52490
|
return files.map((file2) => fileSignatures.get(file2) || `${file2}:missing`).join("|");
|
|
52433
52491
|
}
|
|
52434
52492
|
function getSavedHistoryIndexFilePath(dir) {
|
|
52435
|
-
return
|
|
52493
|
+
return path15.join(dir, SAVED_HISTORY_INDEX_FILE);
|
|
52436
52494
|
}
|
|
52437
52495
|
function getSavedHistoryIndexLockPath(dir) {
|
|
52438
52496
|
return `${getSavedHistoryIndexFilePath(dir)}${SAVED_HISTORY_INDEX_LOCK_SUFFIX}`;
|
|
@@ -52534,7 +52592,7 @@ ${cleanBody}`;
|
|
|
52534
52592
|
}
|
|
52535
52593
|
for (const file2 of Array.from(currentEntries.keys())) {
|
|
52536
52594
|
if (incomingFiles.has(file2)) continue;
|
|
52537
|
-
if (!fs6.existsSync(
|
|
52595
|
+
if (!fs6.existsSync(path15.join(dir, file2))) {
|
|
52538
52596
|
currentEntries.delete(file2);
|
|
52539
52597
|
}
|
|
52540
52598
|
}
|
|
@@ -52560,7 +52618,7 @@ ${cleanBody}`;
|
|
|
52560
52618
|
const indexStat = fs6.statSync(getSavedHistoryIndexFilePath(dir));
|
|
52561
52619
|
const files = listHistoryFiles(dir);
|
|
52562
52620
|
for (const file2 of files) {
|
|
52563
|
-
const stat2 = fs6.statSync(
|
|
52621
|
+
const stat2 = fs6.statSync(path15.join(dir, file2));
|
|
52564
52622
|
if (stat2.mtimeMs > indexStat.mtimeMs) return true;
|
|
52565
52623
|
}
|
|
52566
52624
|
return false;
|
|
@@ -52570,14 +52628,14 @@ ${cleanBody}`;
|
|
|
52570
52628
|
}
|
|
52571
52629
|
function buildSavedHistoryFileSignature(dir, file2) {
|
|
52572
52630
|
try {
|
|
52573
|
-
const stat2 = fs6.statSync(
|
|
52631
|
+
const stat2 = fs6.statSync(path15.join(dir, file2));
|
|
52574
52632
|
return `${file2}:${stat2.size}:${Math.trunc(stat2.mtimeMs)}`;
|
|
52575
52633
|
} catch {
|
|
52576
52634
|
return `${file2}:missing`;
|
|
52577
52635
|
}
|
|
52578
52636
|
}
|
|
52579
52637
|
function persistSavedHistoryFileSummaryEntry(agentType, dir, file2, updater) {
|
|
52580
|
-
const filePath =
|
|
52638
|
+
const filePath = path15.join(dir, file2);
|
|
52581
52639
|
const result = withLockedPersistedSavedHistoryIndex(dir, (entries) => {
|
|
52582
52640
|
const currentEntry = entries.get(file2) || null;
|
|
52583
52641
|
const nextSummary = updater(currentEntry?.summary || null);
|
|
@@ -52650,7 +52708,7 @@ ${cleanBody}`;
|
|
|
52650
52708
|
function computeSavedHistoryFileSummary(dir, file2) {
|
|
52651
52709
|
const historySessionId = extractSavedHistorySessionIdFromFile(file2);
|
|
52652
52710
|
if (!historySessionId) return null;
|
|
52653
|
-
const filePath =
|
|
52711
|
+
const filePath = path15.join(dir, file2);
|
|
52654
52712
|
const content = fs6.readFileSync(filePath, "utf-8");
|
|
52655
52713
|
const lines = content.split("\n").filter(Boolean);
|
|
52656
52714
|
let messageCount = 0;
|
|
@@ -52737,7 +52795,7 @@ ${cleanBody}`;
|
|
|
52737
52795
|
const summaryBySessionId = /* @__PURE__ */ new Map();
|
|
52738
52796
|
const nextPersistedEntries = /* @__PURE__ */ new Map();
|
|
52739
52797
|
for (const file2 of files.slice().sort()) {
|
|
52740
|
-
const filePath =
|
|
52798
|
+
const filePath = path15.join(dir, file2);
|
|
52741
52799
|
const signature = fileSignatures.get(file2) || `${file2}:missing`;
|
|
52742
52800
|
const cached3 = savedHistoryFileSummaryCache.get(filePath);
|
|
52743
52801
|
const persisted = persistedEntries.get(file2);
|
|
@@ -52857,12 +52915,12 @@ ${cleanBody}`;
|
|
|
52857
52915
|
});
|
|
52858
52916
|
}
|
|
52859
52917
|
if (newMessages.length === 0) return;
|
|
52860
|
-
const dir =
|
|
52918
|
+
const dir = path15.join(HISTORY_DIR, this.sanitize(agentType));
|
|
52861
52919
|
fs6.mkdirSync(dir, { recursive: true });
|
|
52862
52920
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
52863
52921
|
const filePrefix = effectiveHistoryKey ? `${this.sanitize(effectiveHistoryKey)}_` : "";
|
|
52864
52922
|
const fileName = `${filePrefix}${date5}.jsonl`;
|
|
52865
|
-
const filePath =
|
|
52923
|
+
const filePath = path15.join(dir, fileName);
|
|
52866
52924
|
const lines = newMessages.map((m) => JSON.stringify(m)).join("\n") + "\n";
|
|
52867
52925
|
fs6.appendFileSync(filePath, lines, "utf-8");
|
|
52868
52926
|
updateSavedHistoryIndexForAppendedMessages(agentType, dir, fileName, effectiveHistoryKey, newMessages);
|
|
@@ -52953,11 +53011,11 @@ ${cleanBody}`;
|
|
|
52953
53011
|
const ws = String(workspace || "").trim();
|
|
52954
53012
|
if (!id || !ws) return;
|
|
52955
53013
|
try {
|
|
52956
|
-
const dir =
|
|
53014
|
+
const dir = path15.join(HISTORY_DIR, this.sanitize(agentType));
|
|
52957
53015
|
fs6.mkdirSync(dir, { recursive: true });
|
|
52958
53016
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
52959
53017
|
const fileName = `${this.sanitize(id)}_${date5}.jsonl`;
|
|
52960
|
-
const filePath =
|
|
53018
|
+
const filePath = path15.join(dir, fileName);
|
|
52961
53019
|
const record2 = {
|
|
52962
53020
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
52963
53021
|
receivedAt: Date.now(),
|
|
@@ -53003,14 +53061,14 @@ ${cleanBody}`;
|
|
|
53003
53061
|
this.lastSeenCounts.set(toDedupKey, Math.max(fromCount, this.lastSeenCounts.get(toDedupKey) || 0));
|
|
53004
53062
|
this.lastSeenCounts.delete(fromDedupKey);
|
|
53005
53063
|
}
|
|
53006
|
-
const dir =
|
|
53064
|
+
const dir = path15.join(HISTORY_DIR, this.sanitize(agentType));
|
|
53007
53065
|
if (!fs6.existsSync(dir)) return;
|
|
53008
53066
|
const fromPrefix = `${this.sanitize(fromId)}_`;
|
|
53009
53067
|
const toPrefix = `${this.sanitize(toId)}_`;
|
|
53010
53068
|
const files = fs6.readdirSync(dir).filter((file2) => file2.startsWith(fromPrefix) && file2.endsWith(".jsonl"));
|
|
53011
53069
|
for (const file2 of files) {
|
|
53012
|
-
const sourcePath =
|
|
53013
|
-
const targetPath =
|
|
53070
|
+
const sourcePath = path15.join(dir, file2);
|
|
53071
|
+
const targetPath = path15.join(dir, `${toPrefix}${file2.slice(fromPrefix.length)}`);
|
|
53014
53072
|
const sourceLines = fs6.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
|
|
53015
53073
|
const rewritten = sourceLines.map((line) => {
|
|
53016
53074
|
try {
|
|
@@ -53044,13 +53102,13 @@ ${cleanBody}`;
|
|
|
53044
53102
|
const sessionId = String(historySessionId || "").trim();
|
|
53045
53103
|
if (!sessionId) return;
|
|
53046
53104
|
try {
|
|
53047
|
-
const dir =
|
|
53105
|
+
const dir = path15.join(HISTORY_DIR, this.sanitize(agentType));
|
|
53048
53106
|
if (!fs6.existsSync(dir)) return;
|
|
53049
53107
|
const prefix = `${this.sanitize(sessionId)}_`;
|
|
53050
53108
|
const files = fs6.readdirSync(dir).filter((file2) => file2.startsWith(prefix) && file2.endsWith(".jsonl")).sort();
|
|
53051
53109
|
const seen = /* @__PURE__ */ new Set();
|
|
53052
53110
|
for (const file2 of files) {
|
|
53053
|
-
const filePath =
|
|
53111
|
+
const filePath = path15.join(dir, file2);
|
|
53054
53112
|
const lines = fs6.readFileSync(filePath, "utf-8").split("\n").filter(Boolean);
|
|
53055
53113
|
const next = [];
|
|
53056
53114
|
for (const line of lines) {
|
|
@@ -53104,11 +53162,11 @@ ${cleanBody}`;
|
|
|
53104
53162
|
const cutoff = Date.now() - RETAIN_DAYS * 24 * 60 * 60 * 1e3;
|
|
53105
53163
|
const agentDirs = fs6.readdirSync(HISTORY_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
53106
53164
|
for (const dir of agentDirs) {
|
|
53107
|
-
const dirPath =
|
|
53165
|
+
const dirPath = path15.join(HISTORY_DIR, dir.name);
|
|
53108
53166
|
const files = fs6.readdirSync(dirPath).filter((f) => f.endsWith(".jsonl") || f.endsWith(".terminal.log"));
|
|
53109
53167
|
let removedAny = false;
|
|
53110
53168
|
for (const file2 of files) {
|
|
53111
|
-
const filePath =
|
|
53169
|
+
const filePath = path15.join(dirPath, file2);
|
|
53112
53170
|
const stat2 = fs6.statSync(filePath);
|
|
53113
53171
|
if (stat2.mtimeMs < cutoff) {
|
|
53114
53172
|
fs6.unlinkSync(filePath);
|
|
@@ -53311,7 +53369,7 @@ ${cleanBody}`;
|
|
|
53311
53369
|
const seen = /* @__PURE__ */ new Set();
|
|
53312
53370
|
let readAllFiles = true;
|
|
53313
53371
|
for (let f = 0; f < files.length; f++) {
|
|
53314
|
-
const filePath =
|
|
53372
|
+
const filePath = path15.join(dir, files[f]);
|
|
53315
53373
|
const remaining = Math.max(0, needed - collected.length);
|
|
53316
53374
|
const perFileNeeded = Math.min(needed, remaining + BOUNDED_TAIL_SLACK);
|
|
53317
53375
|
const { lines, coversWholeFile } = readFileTailLines(filePath, perFileNeeded);
|
|
@@ -53344,7 +53402,7 @@ ${cleanBody}`;
|
|
|
53344
53402
|
function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, excludeRecentCount = 0, historyBehavior) {
|
|
53345
53403
|
try {
|
|
53346
53404
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
53347
|
-
const dir =
|
|
53405
|
+
const dir = path15.join(HISTORY_DIR, sanitized);
|
|
53348
53406
|
if (!fs6.existsSync(dir)) return { messages: [], hasMore: false };
|
|
53349
53407
|
const files = listHistoryFiles(dir, historySessionId);
|
|
53350
53408
|
const bounded = isBoundedTailRequest(limit, offset, excludeRecentCount);
|
|
@@ -53367,7 +53425,7 @@ ${cleanBody}`;
|
|
|
53367
53425
|
const allMessages = [];
|
|
53368
53426
|
const seen = /* @__PURE__ */ new Set();
|
|
53369
53427
|
for (const file2 of files) {
|
|
53370
|
-
const filePath =
|
|
53428
|
+
const filePath = path15.join(dir, file2);
|
|
53371
53429
|
const content = fs6.readFileSync(filePath, "utf-8");
|
|
53372
53430
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
53373
53431
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -53391,7 +53449,7 @@ ${cleanBody}`;
|
|
|
53391
53449
|
function listSavedHistorySessions(agentType, options = {}, historyBehavior) {
|
|
53392
53450
|
try {
|
|
53393
53451
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
53394
|
-
const dir =
|
|
53452
|
+
const dir = path15.join(HISTORY_DIR, sanitized);
|
|
53395
53453
|
if (!fs6.existsSync(dir)) {
|
|
53396
53454
|
savedHistorySessionCache.delete(sanitized);
|
|
53397
53455
|
return { sessions: [], hasMore: false };
|
|
@@ -53452,11 +53510,11 @@ ${cleanBody}`;
|
|
|
53452
53510
|
}
|
|
53453
53511
|
function readExistingSessionStartRecord(agentType, historySessionId) {
|
|
53454
53512
|
try {
|
|
53455
|
-
const dir =
|
|
53513
|
+
const dir = path15.join(HISTORY_DIR, agentType);
|
|
53456
53514
|
if (!fs6.existsSync(dir)) return null;
|
|
53457
53515
|
const files = listHistoryFiles(dir, historySessionId).sort();
|
|
53458
53516
|
for (const file2 of files) {
|
|
53459
|
-
const lines = fs6.readFileSync(
|
|
53517
|
+
const lines = fs6.readFileSync(path15.join(dir, file2), "utf-8").split("\n").filter(Boolean);
|
|
53460
53518
|
for (const line of lines) {
|
|
53461
53519
|
try {
|
|
53462
53520
|
const parsed = JSON.parse(line);
|
|
@@ -53476,16 +53534,16 @@ ${cleanBody}`;
|
|
|
53476
53534
|
function rewriteCanonicalSavedHistory(agentType, historySessionId, records) {
|
|
53477
53535
|
if (records.length === 0) return false;
|
|
53478
53536
|
try {
|
|
53479
|
-
const dir =
|
|
53537
|
+
const dir = path15.join(HISTORY_DIR, agentType);
|
|
53480
53538
|
fs6.mkdirSync(dir, { recursive: true });
|
|
53481
53539
|
const prefix = `${historySessionId.replace(/[^a-zA-Z0-9_-]/g, "_")}_`;
|
|
53482
53540
|
for (const file2 of fs6.readdirSync(dir)) {
|
|
53483
53541
|
if (file2.startsWith(prefix) && file2.endsWith(".jsonl")) {
|
|
53484
|
-
fs6.unlinkSync(
|
|
53542
|
+
fs6.unlinkSync(path15.join(dir, file2));
|
|
53485
53543
|
}
|
|
53486
53544
|
}
|
|
53487
53545
|
const targetDate = new Date(records[records.length - 1].receivedAt || Date.now()).toISOString().slice(0, 10);
|
|
53488
|
-
const filePath =
|
|
53546
|
+
const filePath = path15.join(dir, `${prefix}${targetDate}.jsonl`);
|
|
53489
53547
|
fs6.writeFileSync(filePath, `${records.map((record2) => JSON.stringify(record2)).join("\n")}
|
|
53490
53548
|
`, "utf-8");
|
|
53491
53549
|
invalidatePersistedSavedHistoryIndex(agentType, dir);
|
|
@@ -56044,7 +56102,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
56044
56102
|
}
|
|
56045
56103
|
var fs7 = __toESM2(require("fs"));
|
|
56046
56104
|
var os9 = __toESM2(require("os"));
|
|
56047
|
-
var
|
|
56105
|
+
var path16 = __toESM2(require("path"));
|
|
56048
56106
|
var import_node_crypto3 = require("crypto");
|
|
56049
56107
|
init_contracts();
|
|
56050
56108
|
init_logger();
|
|
@@ -57085,7 +57143,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
57085
57143
|
function normalizeComparableWorkspace(value) {
|
|
57086
57144
|
const text = typeof value === "string" ? value.trim() : "";
|
|
57087
57145
|
if (!text) return "";
|
|
57088
|
-
return
|
|
57146
|
+
return path16.resolve(text);
|
|
57089
57147
|
}
|
|
57090
57148
|
function isCurrentRuntimePtySafelyAttributed(args) {
|
|
57091
57149
|
if (args.adapter.cliType !== "codex-cli") return false;
|
|
@@ -57570,7 +57628,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
57570
57628
|
}
|
|
57571
57629
|
function getChatDebugBundleDir() {
|
|
57572
57630
|
const override = typeof process.env.ADHDEV_DEBUG_BUNDLE_DIR === "string" ? process.env.ADHDEV_DEBUG_BUNDLE_DIR.trim() : "";
|
|
57573
|
-
return override ||
|
|
57631
|
+
return override || path16.join(os9.homedir(), ".adhdev", "debug-bundles", "chat");
|
|
57574
57632
|
}
|
|
57575
57633
|
function safeBundleIdSegment(value, fallback) {
|
|
57576
57634
|
const normalized = String(value || fallback).trim().replace(/[^A-Za-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
|
|
@@ -57627,7 +57685,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
57627
57685
|
const bundleId = createChatDebugBundleId(targetSessionId);
|
|
57628
57686
|
const dir = getChatDebugBundleDir();
|
|
57629
57687
|
fs7.mkdirSync(dir, { recursive: true });
|
|
57630
|
-
const savedPath =
|
|
57688
|
+
const savedPath = path16.join(dir, `${bundleId}.json`);
|
|
57631
57689
|
const json2 = `${JSON.stringify(bundle, null, 2)}
|
|
57632
57690
|
`;
|
|
57633
57691
|
fs7.writeFileSync(savedPath, json2, { encoding: "utf8", mode: 384 });
|
|
@@ -59189,7 +59247,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
59189
59247
|
return { success: false, error: "resolveAction script not available for this provider" };
|
|
59190
59248
|
}
|
|
59191
59249
|
var fs8 = __toESM2(require("fs"));
|
|
59192
|
-
var
|
|
59250
|
+
var path17 = __toESM2(require("path"));
|
|
59193
59251
|
var os10 = __toESM2(require("os"));
|
|
59194
59252
|
var KEY_TO_VK = {
|
|
59195
59253
|
Backspace: 8,
|
|
@@ -59446,25 +59504,25 @@ ${effect.notification.body || ""}`.trim();
|
|
|
59446
59504
|
const inputPath = rawPath || ".";
|
|
59447
59505
|
const home = os10.homedir();
|
|
59448
59506
|
if (inputPath.startsWith("~")) {
|
|
59449
|
-
return
|
|
59507
|
+
return path17.resolve(path17.join(home, inputPath.slice(1)));
|
|
59450
59508
|
}
|
|
59451
59509
|
if (process.platform === "win32") {
|
|
59452
59510
|
const normalized = normalizeWindowsRequestedPath(inputPath);
|
|
59453
|
-
if (
|
|
59454
|
-
return
|
|
59511
|
+
if (path17.win32.isAbsolute(normalized)) {
|
|
59512
|
+
return path17.win32.normalize(normalized);
|
|
59455
59513
|
}
|
|
59456
|
-
return
|
|
59514
|
+
return path17.win32.resolve(normalized);
|
|
59457
59515
|
}
|
|
59458
|
-
if (
|
|
59459
|
-
return
|
|
59516
|
+
if (path17.isAbsolute(inputPath)) {
|
|
59517
|
+
return path17.normalize(inputPath);
|
|
59460
59518
|
}
|
|
59461
|
-
return
|
|
59519
|
+
return path17.resolve(inputPath);
|
|
59462
59520
|
}
|
|
59463
59521
|
function listDirectoryEntriesSafe(dirPath) {
|
|
59464
59522
|
const entries = fs8.readdirSync(dirPath, { withFileTypes: true });
|
|
59465
59523
|
const files = [];
|
|
59466
59524
|
for (const entry of entries) {
|
|
59467
|
-
const entryPath =
|
|
59525
|
+
const entryPath = path17.join(dirPath, entry.name);
|
|
59468
59526
|
try {
|
|
59469
59527
|
if (entry.isDirectory()) {
|
|
59470
59528
|
files.push({ name: entry.name, type: "directory" });
|
|
@@ -59518,7 +59576,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
59518
59576
|
async function handleFileWrite(h, args) {
|
|
59519
59577
|
try {
|
|
59520
59578
|
const filePath = resolveSafePath(args?.path);
|
|
59521
|
-
fs8.mkdirSync(
|
|
59579
|
+
fs8.mkdirSync(path17.dirname(filePath), { recursive: true });
|
|
59522
59580
|
fs8.writeFileSync(filePath, args?.content || "", "utf-8");
|
|
59523
59581
|
return { success: true, path: filePath };
|
|
59524
59582
|
} catch (e) {
|
|
@@ -73220,6 +73278,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
73220
73278
|
var import_path12 = require("path");
|
|
73221
73279
|
var fs26 = __toESM2(require("fs"));
|
|
73222
73280
|
var import_node_child_process6 = require("child_process");
|
|
73281
|
+
init_resolve_executable();
|
|
73223
73282
|
var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
|
|
73224
73283
|
var CHANNEL_SERVER_URL = {
|
|
73225
73284
|
stable: "https://api.adhf.dev",
|
|
@@ -74318,6 +74377,18 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
74318
74377
|
return `${text.slice(0, REFINE_VALIDATION_SUMMARY_CHARS)}
|
|
74319
74378
|
[truncated ${text.length - REFINE_VALIDATION_SUMMARY_CHARS} chars]`;
|
|
74320
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
|
+
}
|
|
74321
74392
|
function recordMeshRefineStage(stages, stage, status, startedAt, details) {
|
|
74322
74393
|
stages.push({
|
|
74323
74394
|
stage,
|
|
@@ -75219,8 +75290,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75219
75290
|
const startedAt = Date.now();
|
|
75220
75291
|
const cwd = candidate.cwd ? (0, import_path12.resolve)(workspace, candidate.cwd) : workspace;
|
|
75221
75292
|
const timeout = candidate.timeoutMs || REFINE_VALIDATION_TIMEOUT_MS;
|
|
75293
|
+
const resolvedCommand = resolveWin32Executable(candidate.command);
|
|
75222
75294
|
try {
|
|
75223
|
-
const result = await execFileAsync4(
|
|
75295
|
+
const result = await execFileAsync4(resolvedCommand, candidate.args, {
|
|
75224
75296
|
cwd,
|
|
75225
75297
|
encoding: "utf8",
|
|
75226
75298
|
timeout,
|
|
@@ -75229,16 +75301,17 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75229
75301
|
});
|
|
75230
75302
|
summary.bootstrapCommandsRun.push(commandRecord(candidate, cwd, startedAt, result, true, { exitCode: 0 }));
|
|
75231
75303
|
} catch (error48) {
|
|
75304
|
+
const spawnResolutionFailed = isSpawnResolutionError(error48);
|
|
75232
75305
|
summary.bootstrapCommandsRun.push(commandRecord(candidate, cwd, startedAt, error48, false, {
|
|
75233
75306
|
exitCode: typeof error48?.code === "number" ? error48.code : null,
|
|
75234
75307
|
signal: typeof error48?.signal === "string" ? error48.signal : null,
|
|
75235
75308
|
timedOut: error48?.killed === true || /timed out/i.test(String(error48?.message || "")),
|
|
75236
|
-
failureKind: "dependency_bootstrap_failed"
|
|
75309
|
+
...spawnResolutionFailed ? { failureKind: "spawn_resolution_failed", resolvedCommand } : { failureKind: "dependency_bootstrap_failed" }
|
|
75237
75310
|
}));
|
|
75238
|
-
summary.bootstrap = { stage: "failed", error:
|
|
75311
|
+
summary.bootstrap = { stage: "failed", error: describeSpawnError(error48, candidate.command, spawnResolutionFailed) };
|
|
75239
75312
|
summary.status = "failed";
|
|
75240
|
-
summary.failureKind = "dependency_bootstrap_failed";
|
|
75241
|
-
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";
|
|
75242
75315
|
return summary;
|
|
75243
75316
|
}
|
|
75244
75317
|
}
|
|
@@ -75261,8 +75334,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75261
75334
|
summary.failureCode = "missing_dependencies";
|
|
75262
75335
|
return summary;
|
|
75263
75336
|
}
|
|
75337
|
+
const resolvedCommand = resolveWin32Executable(candidate.command);
|
|
75264
75338
|
try {
|
|
75265
|
-
const result = await execFileAsync4(
|
|
75339
|
+
const result = await execFileAsync4(resolvedCommand, candidate.args, {
|
|
75266
75340
|
cwd,
|
|
75267
75341
|
encoding: "utf8",
|
|
75268
75342
|
timeout,
|
|
@@ -75271,16 +75345,21 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
75271
75345
|
});
|
|
75272
75346
|
summary.commandsRun.push(commandRecord(candidate, cwd, startedAt, result, true, { exitCode: 0 }));
|
|
75273
75347
|
} catch (error48) {
|
|
75348
|
+
const spawnResolutionFailed = isSpawnResolutionError(error48);
|
|
75274
75349
|
const stderr = truncateValidationOutput(error48?.stderr || error48?.message);
|
|
75275
|
-
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);
|
|
75276
75351
|
summary.commandsRun.push(commandRecord(candidate, cwd, startedAt, error48, false, {
|
|
75277
75352
|
exitCode: typeof error48?.code === "number" ? error48.code : null,
|
|
75278
75353
|
signal: typeof error48?.signal === "string" ? error48.signal : null,
|
|
75279
75354
|
timedOut: error48?.killed === true || /timed out/i.test(String(error48?.message || "")),
|
|
75280
|
-
...missingDependencyFailure ? { failureKind: "missing_dependencies" } : {}
|
|
75355
|
+
...spawnResolutionFailed ? { failureKind: "spawn_resolution_failed", resolvedCommand } : missingDependencyFailure ? { failureKind: "missing_dependencies" } : {}
|
|
75281
75356
|
}));
|
|
75282
75357
|
summary.status = "failed";
|
|
75283
|
-
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) {
|
|
75284
75363
|
summary.failureKind = "missing_dependencies";
|
|
75285
75364
|
summary.failureCode = "missing_dependencies";
|
|
75286
75365
|
}
|
|
@@ -76541,7 +76620,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
76541
76620
|
if (validationSummary.status === "failed") {
|
|
76542
76621
|
const firstFailedCmd = Array.isArray(validationSummary.commandsRun) ? validationSummary.commandsRun.find((c) => c.success === false) : void 0;
|
|
76543
76622
|
const buildValidationFailedError = () => {
|
|
76544
|
-
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.";
|
|
76545
76624
|
if (!firstFailedCmd) return base;
|
|
76546
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 : "";
|
|
76547
76626
|
const rawOutput = [firstFailedCmd.stdout, firstFailedCmd.stderr, firstFailedCmd.output].filter((s) => typeof s === "string" && s.length > 0).join("\n");
|