@adhdev/daemon-standalone 0.7.38 → 0.7.40
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 +799 -1000
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/index-B_p34HFn.css +1 -0
- package/public/assets/index-CX6n6DJi.js +68 -0
- package/public/assets/{terminal-CpeGxRuR.js → terminal-CEvJri7V.js} +1 -1
- package/public/assets/{vendor-BZmoHkrb.js → vendor-CPghmr9Y.js} +5 -5
- package/public/index.html +4 -4
- package/public/assets/index-BKq04Gnp.css +0 -1
- package/public/assets/index-DEIAOSoT.js +0 -69
package/dist/index.js
CHANGED
|
@@ -283,10 +283,10 @@ function mergeDefs(...defs) {
|
|
|
283
283
|
function cloneDef(schema) {
|
|
284
284
|
return mergeDefs(schema._zod.def);
|
|
285
285
|
}
|
|
286
|
-
function getElementAtPath(obj,
|
|
287
|
-
if (!
|
|
286
|
+
function getElementAtPath(obj, path18) {
|
|
287
|
+
if (!path18)
|
|
288
288
|
return obj;
|
|
289
|
-
return
|
|
289
|
+
return path18.reduce((acc, key) => acc?.[key], obj);
|
|
290
290
|
}
|
|
291
291
|
function promiseAllObject(promisesObj) {
|
|
292
292
|
const keys = Object.keys(promisesObj);
|
|
@@ -598,11 +598,11 @@ function aborted(x, startIndex = 0) {
|
|
|
598
598
|
}
|
|
599
599
|
return false;
|
|
600
600
|
}
|
|
601
|
-
function prefixIssues(
|
|
601
|
+
function prefixIssues(path18, issues) {
|
|
602
602
|
return issues.map((iss) => {
|
|
603
603
|
var _a2;
|
|
604
604
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
605
|
-
iss.path.unshift(
|
|
605
|
+
iss.path.unshift(path18);
|
|
606
606
|
return iss;
|
|
607
607
|
});
|
|
608
608
|
}
|
|
@@ -845,7 +845,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
845
845
|
}
|
|
846
846
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
847
847
|
const result = { errors: [] };
|
|
848
|
-
const processError = (error49,
|
|
848
|
+
const processError = (error49, path18 = []) => {
|
|
849
849
|
var _a2, _b;
|
|
850
850
|
for (const issue2 of error49.issues) {
|
|
851
851
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -855,7 +855,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
855
855
|
} else if (issue2.code === "invalid_element") {
|
|
856
856
|
processError({ issues: issue2.issues }, issue2.path);
|
|
857
857
|
} else {
|
|
858
|
-
const fullpath = [...
|
|
858
|
+
const fullpath = [...path18, ...issue2.path];
|
|
859
859
|
if (fullpath.length === 0) {
|
|
860
860
|
result.errors.push(mapper(issue2));
|
|
861
861
|
continue;
|
|
@@ -887,8 +887,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
887
887
|
}
|
|
888
888
|
function toDotPath(_path) {
|
|
889
889
|
const segs = [];
|
|
890
|
-
const
|
|
891
|
-
for (const seg of
|
|
890
|
+
const path18 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
891
|
+
for (const seg of path18) {
|
|
892
892
|
if (typeof seg === "number")
|
|
893
893
|
segs.push(`[${seg}]`);
|
|
894
894
|
else if (typeof seg === "symbol")
|
|
@@ -13652,13 +13652,13 @@ function resolveRef(ref, ctx) {
|
|
|
13652
13652
|
if (!ref.startsWith("#")) {
|
|
13653
13653
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
13654
13654
|
}
|
|
13655
|
-
const
|
|
13656
|
-
if (
|
|
13655
|
+
const path18 = ref.slice(1).split("/").filter(Boolean);
|
|
13656
|
+
if (path18.length === 0) {
|
|
13657
13657
|
return ctx.rootSchema;
|
|
13658
13658
|
}
|
|
13659
13659
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
13660
|
-
if (
|
|
13661
|
-
const key =
|
|
13660
|
+
if (path18[0] === defsKey) {
|
|
13661
|
+
const key = path18[1];
|
|
13662
13662
|
if (!key || !ctx.defs[key]) {
|
|
13663
13663
|
throw new Error(`Reference not found: ${ref}`);
|
|
13664
13664
|
}
|
|
@@ -16085,8 +16085,8 @@ var init_acp = __esm({
|
|
|
16085
16085
|
this.#requestHandler = requestHandler;
|
|
16086
16086
|
this.#notificationHandler = notificationHandler;
|
|
16087
16087
|
this.#stream = stream;
|
|
16088
|
-
this.#closedPromise = new Promise((
|
|
16089
|
-
this.#abortController.signal.addEventListener("abort", () =>
|
|
16088
|
+
this.#closedPromise = new Promise((resolve12) => {
|
|
16089
|
+
this.#abortController.signal.addEventListener("abort", () => resolve12());
|
|
16090
16090
|
});
|
|
16091
16091
|
this.#receive();
|
|
16092
16092
|
}
|
|
@@ -16235,8 +16235,8 @@ var init_acp = __esm({
|
|
|
16235
16235
|
}
|
|
16236
16236
|
async sendRequest(method, params) {
|
|
16237
16237
|
const id = this.#nextRequestId++;
|
|
16238
|
-
const responsePromise = new Promise((
|
|
16239
|
-
this.#pendingResponses.set(id, { resolve:
|
|
16238
|
+
const responsePromise = new Promise((resolve12, reject) => {
|
|
16239
|
+
this.#pendingResponses.set(id, { resolve: resolve12, reject });
|
|
16240
16240
|
});
|
|
16241
16241
|
await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
|
|
16242
16242
|
return responsePromise;
|
|
@@ -16334,28 +16334,27 @@ var init_acp = __esm({
|
|
|
16334
16334
|
// src/index.ts
|
|
16335
16335
|
var import_http = require("http");
|
|
16336
16336
|
var import_ws2 = require("ws");
|
|
16337
|
-
var
|
|
16337
|
+
var path17 = __toESM(require("path"));
|
|
16338
16338
|
var fs12 = __toESM(require("fs"));
|
|
16339
16339
|
var os17 = __toESM(require("os"));
|
|
16340
16340
|
|
|
16341
16341
|
// ../daemon-core/dist/index.mjs
|
|
16342
|
-
var fs = __toESM(require("fs"), 1);
|
|
16343
|
-
var os2 = __toESM(require("os"), 1);
|
|
16344
|
-
var path = __toESM(require("path"), 1);
|
|
16345
|
-
var import_crypto2 = require("crypto");
|
|
16346
16342
|
var import_os = require("os");
|
|
16347
16343
|
var import_path = require("path");
|
|
16348
16344
|
var import_fs = require("fs");
|
|
16349
|
-
var
|
|
16345
|
+
var import_crypto2 = require("crypto");
|
|
16350
16346
|
var fs2 = __toESM(require("fs"), 1);
|
|
16351
|
-
var
|
|
16347
|
+
var path3 = __toESM(require("path"), 1);
|
|
16352
16348
|
var os4 = __toESM(require("os"), 1);
|
|
16353
16349
|
var os11 = __toESM(require("os"), 1);
|
|
16354
16350
|
var os12 = __toESM(require("os"), 1);
|
|
16355
|
-
var
|
|
16351
|
+
var path9 = __toESM(require("path"), 1);
|
|
16356
16352
|
var import_child_process = require("child_process");
|
|
16353
|
+
var fs = __toESM(require("fs"), 1);
|
|
16354
|
+
var os2 = __toESM(require("os"), 1);
|
|
16355
|
+
var path = __toESM(require("path"), 1);
|
|
16356
|
+
var import_crypto3 = require("crypto");
|
|
16357
16357
|
var path22 = __toESM(require("path"), 1);
|
|
16358
|
-
var path3 = __toESM(require("path"), 1);
|
|
16359
16358
|
var import_child_process2 = require("child_process");
|
|
16360
16359
|
var import_fs2 = require("fs");
|
|
16361
16360
|
var import_os2 = require("os");
|
|
@@ -16367,17 +16366,17 @@ var import_ws = __toESM(require("ws"), 1);
|
|
|
16367
16366
|
var http = __toESM(require("http"), 1);
|
|
16368
16367
|
var crypto2 = __toESM(require("crypto"), 1);
|
|
16369
16368
|
var fs3 = __toESM(require("fs"), 1);
|
|
16370
|
-
var
|
|
16369
|
+
var path4 = __toESM(require("path"), 1);
|
|
16371
16370
|
var os5 = __toESM(require("os"), 1);
|
|
16372
16371
|
var fs4 = __toESM(require("fs"), 1);
|
|
16373
|
-
var
|
|
16372
|
+
var path5 = __toESM(require("path"), 1);
|
|
16374
16373
|
var os6 = __toESM(require("os"), 1);
|
|
16375
16374
|
var import_child_process5 = require("child_process");
|
|
16376
16375
|
var net2 = __toESM(require("net"), 1);
|
|
16377
16376
|
var os8 = __toESM(require("os"), 1);
|
|
16378
|
-
var path8 = __toESM(require("path"), 1);
|
|
16379
|
-
var fs5 = __toESM(require("fs"), 1);
|
|
16380
16377
|
var path7 = __toESM(require("path"), 1);
|
|
16378
|
+
var fs5 = __toESM(require("fs"), 1);
|
|
16379
|
+
var path6 = __toESM(require("path"), 1);
|
|
16381
16380
|
var os7 = __toESM(require("os"), 1);
|
|
16382
16381
|
|
|
16383
16382
|
// ../daemon-core/node_modules/chokidar/index.js
|
|
@@ -16470,7 +16469,7 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
16470
16469
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
16471
16470
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
16472
16471
|
if (wantBigintFsStats) {
|
|
16473
|
-
this._stat = (
|
|
16472
|
+
this._stat = (path18) => statMethod(path18, { bigint: true });
|
|
16474
16473
|
} else {
|
|
16475
16474
|
this._stat = statMethod;
|
|
16476
16475
|
}
|
|
@@ -16495,8 +16494,8 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
16495
16494
|
const par = this.parent;
|
|
16496
16495
|
const fil = par && par.files;
|
|
16497
16496
|
if (fil && fil.length > 0) {
|
|
16498
|
-
const { path:
|
|
16499
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
16497
|
+
const { path: path18, depth } = par;
|
|
16498
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path18));
|
|
16500
16499
|
const awaited = await Promise.all(slice);
|
|
16501
16500
|
for (const entry of awaited) {
|
|
16502
16501
|
if (!entry)
|
|
@@ -16536,20 +16535,20 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
16536
16535
|
this.reading = false;
|
|
16537
16536
|
}
|
|
16538
16537
|
}
|
|
16539
|
-
async _exploreDir(
|
|
16538
|
+
async _exploreDir(path18, depth) {
|
|
16540
16539
|
let files;
|
|
16541
16540
|
try {
|
|
16542
|
-
files = await (0, import_promises.readdir)(
|
|
16541
|
+
files = await (0, import_promises.readdir)(path18, this._rdOptions);
|
|
16543
16542
|
} catch (error48) {
|
|
16544
16543
|
this._onError(error48);
|
|
16545
16544
|
}
|
|
16546
|
-
return { files, depth, path:
|
|
16545
|
+
return { files, depth, path: path18 };
|
|
16547
16546
|
}
|
|
16548
|
-
async _formatEntry(dirent,
|
|
16547
|
+
async _formatEntry(dirent, path18) {
|
|
16549
16548
|
let entry;
|
|
16550
16549
|
const basename7 = this._isDirent ? dirent.name : dirent;
|
|
16551
16550
|
try {
|
|
16552
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
16551
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path18, basename7));
|
|
16553
16552
|
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename7 };
|
|
16554
16553
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
16555
16554
|
} catch (err) {
|
|
@@ -16949,16 +16948,16 @@ var delFromSet = (main2, prop, item) => {
|
|
|
16949
16948
|
};
|
|
16950
16949
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
16951
16950
|
var FsWatchInstances = /* @__PURE__ */ new Map();
|
|
16952
|
-
function createFsWatchInstance(
|
|
16951
|
+
function createFsWatchInstance(path18, options, listener, errHandler, emitRaw) {
|
|
16953
16952
|
const handleEvent = (rawEvent, evPath) => {
|
|
16954
|
-
listener(
|
|
16955
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
16956
|
-
if (evPath &&
|
|
16957
|
-
fsWatchBroadcast(sp.resolve(
|
|
16953
|
+
listener(path18);
|
|
16954
|
+
emitRaw(rawEvent, evPath, { watchedPath: path18 });
|
|
16955
|
+
if (evPath && path18 !== evPath) {
|
|
16956
|
+
fsWatchBroadcast(sp.resolve(path18, evPath), KEY_LISTENERS, sp.join(path18, evPath));
|
|
16958
16957
|
}
|
|
16959
16958
|
};
|
|
16960
16959
|
try {
|
|
16961
|
-
return (0, import_node_fs.watch)(
|
|
16960
|
+
return (0, import_node_fs.watch)(path18, {
|
|
16962
16961
|
persistent: options.persistent
|
|
16963
16962
|
}, handleEvent);
|
|
16964
16963
|
} catch (error48) {
|
|
@@ -16974,12 +16973,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
16974
16973
|
listener(val1, val2, val3);
|
|
16975
16974
|
});
|
|
16976
16975
|
};
|
|
16977
|
-
var setFsWatchListener = (
|
|
16976
|
+
var setFsWatchListener = (path18, fullPath, options, handlers) => {
|
|
16978
16977
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
16979
16978
|
let cont = FsWatchInstances.get(fullPath);
|
|
16980
16979
|
let watcher;
|
|
16981
16980
|
if (!options.persistent) {
|
|
16982
|
-
watcher = createFsWatchInstance(
|
|
16981
|
+
watcher = createFsWatchInstance(path18, options, listener, errHandler, rawEmitter);
|
|
16983
16982
|
if (!watcher)
|
|
16984
16983
|
return;
|
|
16985
16984
|
return watcher.close.bind(watcher);
|
|
@@ -16990,7 +16989,7 @@ var setFsWatchListener = (path19, fullPath, options, handlers) => {
|
|
|
16990
16989
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
16991
16990
|
} else {
|
|
16992
16991
|
watcher = createFsWatchInstance(
|
|
16993
|
-
|
|
16992
|
+
path18,
|
|
16994
16993
|
options,
|
|
16995
16994
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
16996
16995
|
errHandler,
|
|
@@ -17005,7 +17004,7 @@ var setFsWatchListener = (path19, fullPath, options, handlers) => {
|
|
|
17005
17004
|
cont.watcherUnusable = true;
|
|
17006
17005
|
if (isWindows && error48.code === "EPERM") {
|
|
17007
17006
|
try {
|
|
17008
|
-
const fd = await (0, import_promises2.open)(
|
|
17007
|
+
const fd = await (0, import_promises2.open)(path18, "r");
|
|
17009
17008
|
await fd.close();
|
|
17010
17009
|
broadcastErr(error48);
|
|
17011
17010
|
} catch (err) {
|
|
@@ -17036,7 +17035,7 @@ var setFsWatchListener = (path19, fullPath, options, handlers) => {
|
|
|
17036
17035
|
};
|
|
17037
17036
|
};
|
|
17038
17037
|
var FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
17039
|
-
var setFsWatchFileListener = (
|
|
17038
|
+
var setFsWatchFileListener = (path18, fullPath, options, handlers) => {
|
|
17040
17039
|
const { listener, rawEmitter } = handlers;
|
|
17041
17040
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
17042
17041
|
const copts = cont && cont.options;
|
|
@@ -17058,7 +17057,7 @@ var setFsWatchFileListener = (path19, fullPath, options, handlers) => {
|
|
|
17058
17057
|
});
|
|
17059
17058
|
const currmtime = curr.mtimeMs;
|
|
17060
17059
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
17061
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
17060
|
+
foreach(cont.listeners, (listener2) => listener2(path18, curr));
|
|
17062
17061
|
}
|
|
17063
17062
|
})
|
|
17064
17063
|
};
|
|
@@ -17088,13 +17087,13 @@ var NodeFsHandler = class {
|
|
|
17088
17087
|
* @param listener on fs change
|
|
17089
17088
|
* @returns closer for the watcher instance
|
|
17090
17089
|
*/
|
|
17091
|
-
_watchWithNodeFs(
|
|
17090
|
+
_watchWithNodeFs(path18, listener) {
|
|
17092
17091
|
const opts = this.fsw.options;
|
|
17093
|
-
const directory = sp.dirname(
|
|
17094
|
-
const basename7 = sp.basename(
|
|
17092
|
+
const directory = sp.dirname(path18);
|
|
17093
|
+
const basename7 = sp.basename(path18);
|
|
17095
17094
|
const parent = this.fsw._getWatchedDir(directory);
|
|
17096
17095
|
parent.add(basename7);
|
|
17097
|
-
const absolutePath = sp.resolve(
|
|
17096
|
+
const absolutePath = sp.resolve(path18);
|
|
17098
17097
|
const options = {
|
|
17099
17098
|
persistent: opts.persistent
|
|
17100
17099
|
};
|
|
@@ -17104,12 +17103,12 @@ var NodeFsHandler = class {
|
|
|
17104
17103
|
if (opts.usePolling) {
|
|
17105
17104
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
17106
17105
|
options.interval = enableBin && isBinaryPath(basename7) ? opts.binaryInterval : opts.interval;
|
|
17107
|
-
closer = setFsWatchFileListener(
|
|
17106
|
+
closer = setFsWatchFileListener(path18, absolutePath, options, {
|
|
17108
17107
|
listener,
|
|
17109
17108
|
rawEmitter: this.fsw._emitRaw
|
|
17110
17109
|
});
|
|
17111
17110
|
} else {
|
|
17112
|
-
closer = setFsWatchListener(
|
|
17111
|
+
closer = setFsWatchListener(path18, absolutePath, options, {
|
|
17113
17112
|
listener,
|
|
17114
17113
|
errHandler: this._boundHandleError,
|
|
17115
17114
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -17131,7 +17130,7 @@ var NodeFsHandler = class {
|
|
|
17131
17130
|
let prevStats = stats;
|
|
17132
17131
|
if (parent.has(basename7))
|
|
17133
17132
|
return;
|
|
17134
|
-
const listener = async (
|
|
17133
|
+
const listener = async (path18, newStats) => {
|
|
17135
17134
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
17136
17135
|
return;
|
|
17137
17136
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -17145,11 +17144,11 @@ var NodeFsHandler = class {
|
|
|
17145
17144
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
17146
17145
|
}
|
|
17147
17146
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
17148
|
-
this.fsw._closeFile(
|
|
17147
|
+
this.fsw._closeFile(path18);
|
|
17149
17148
|
prevStats = newStats2;
|
|
17150
17149
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
17151
17150
|
if (closer2)
|
|
17152
|
-
this.fsw._addPathCloser(
|
|
17151
|
+
this.fsw._addPathCloser(path18, closer2);
|
|
17153
17152
|
} else {
|
|
17154
17153
|
prevStats = newStats2;
|
|
17155
17154
|
}
|
|
@@ -17181,7 +17180,7 @@ var NodeFsHandler = class {
|
|
|
17181
17180
|
* @param item basename of this item
|
|
17182
17181
|
* @returns true if no more processing is needed for this entry.
|
|
17183
17182
|
*/
|
|
17184
|
-
async _handleSymlink(entry, directory,
|
|
17183
|
+
async _handleSymlink(entry, directory, path18, item) {
|
|
17185
17184
|
if (this.fsw.closed) {
|
|
17186
17185
|
return;
|
|
17187
17186
|
}
|
|
@@ -17191,7 +17190,7 @@ var NodeFsHandler = class {
|
|
|
17191
17190
|
this.fsw._incrReadyCount();
|
|
17192
17191
|
let linkPath;
|
|
17193
17192
|
try {
|
|
17194
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
17193
|
+
linkPath = await (0, import_promises2.realpath)(path18);
|
|
17195
17194
|
} catch (e) {
|
|
17196
17195
|
this.fsw._emitReady();
|
|
17197
17196
|
return true;
|
|
@@ -17201,12 +17200,12 @@ var NodeFsHandler = class {
|
|
|
17201
17200
|
if (dir.has(item)) {
|
|
17202
17201
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
17203
17202
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
17204
|
-
this.fsw._emit(EV.CHANGE,
|
|
17203
|
+
this.fsw._emit(EV.CHANGE, path18, entry.stats);
|
|
17205
17204
|
}
|
|
17206
17205
|
} else {
|
|
17207
17206
|
dir.add(item);
|
|
17208
17207
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
17209
|
-
this.fsw._emit(EV.ADD,
|
|
17208
|
+
this.fsw._emit(EV.ADD, path18, entry.stats);
|
|
17210
17209
|
}
|
|
17211
17210
|
this.fsw._emitReady();
|
|
17212
17211
|
return true;
|
|
@@ -17236,9 +17235,9 @@ var NodeFsHandler = class {
|
|
|
17236
17235
|
return;
|
|
17237
17236
|
}
|
|
17238
17237
|
const item = entry.path;
|
|
17239
|
-
let
|
|
17238
|
+
let path18 = sp.join(directory, item);
|
|
17240
17239
|
current.add(item);
|
|
17241
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
17240
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path18, item)) {
|
|
17242
17241
|
return;
|
|
17243
17242
|
}
|
|
17244
17243
|
if (this.fsw.closed) {
|
|
@@ -17247,11 +17246,11 @@ var NodeFsHandler = class {
|
|
|
17247
17246
|
}
|
|
17248
17247
|
if (item === target || !target && !previous.has(item)) {
|
|
17249
17248
|
this.fsw._incrReadyCount();
|
|
17250
|
-
|
|
17251
|
-
this._addToNodeFs(
|
|
17249
|
+
path18 = sp.join(dir, sp.relative(dir, path18));
|
|
17250
|
+
this._addToNodeFs(path18, initialAdd, wh, depth + 1);
|
|
17252
17251
|
}
|
|
17253
17252
|
}).on(EV.ERROR, this._boundHandleError);
|
|
17254
|
-
return new Promise((
|
|
17253
|
+
return new Promise((resolve12, reject) => {
|
|
17255
17254
|
if (!stream)
|
|
17256
17255
|
return reject();
|
|
17257
17256
|
stream.once(STR_END, () => {
|
|
@@ -17260,7 +17259,7 @@ var NodeFsHandler = class {
|
|
|
17260
17259
|
return;
|
|
17261
17260
|
}
|
|
17262
17261
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
17263
|
-
|
|
17262
|
+
resolve12(void 0);
|
|
17264
17263
|
previous.getChildren().filter((item) => {
|
|
17265
17264
|
return item !== directory && !current.has(item);
|
|
17266
17265
|
}).forEach((item) => {
|
|
@@ -17317,13 +17316,13 @@ var NodeFsHandler = class {
|
|
|
17317
17316
|
* @param depth Child path actually targeted for watch
|
|
17318
17317
|
* @param target Child path actually targeted for watch
|
|
17319
17318
|
*/
|
|
17320
|
-
async _addToNodeFs(
|
|
17319
|
+
async _addToNodeFs(path18, initialAdd, priorWh, depth, target) {
|
|
17321
17320
|
const ready = this.fsw._emitReady;
|
|
17322
|
-
if (this.fsw._isIgnored(
|
|
17321
|
+
if (this.fsw._isIgnored(path18) || this.fsw.closed) {
|
|
17323
17322
|
ready();
|
|
17324
17323
|
return false;
|
|
17325
17324
|
}
|
|
17326
|
-
const wh = this.fsw._getWatchHelpers(
|
|
17325
|
+
const wh = this.fsw._getWatchHelpers(path18);
|
|
17327
17326
|
if (priorWh) {
|
|
17328
17327
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
17329
17328
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -17339,8 +17338,8 @@ var NodeFsHandler = class {
|
|
|
17339
17338
|
const follow = this.fsw.options.followSymlinks;
|
|
17340
17339
|
let closer;
|
|
17341
17340
|
if (stats.isDirectory()) {
|
|
17342
|
-
const absPath = sp.resolve(
|
|
17343
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
17341
|
+
const absPath = sp.resolve(path18);
|
|
17342
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path18) : path18;
|
|
17344
17343
|
if (this.fsw.closed)
|
|
17345
17344
|
return;
|
|
17346
17345
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -17350,29 +17349,29 @@ var NodeFsHandler = class {
|
|
|
17350
17349
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
17351
17350
|
}
|
|
17352
17351
|
} else if (stats.isSymbolicLink()) {
|
|
17353
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
17352
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path18) : path18;
|
|
17354
17353
|
if (this.fsw.closed)
|
|
17355
17354
|
return;
|
|
17356
17355
|
const parent = sp.dirname(wh.watchPath);
|
|
17357
17356
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
17358
17357
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
17359
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
17358
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path18, wh, targetPath);
|
|
17360
17359
|
if (this.fsw.closed)
|
|
17361
17360
|
return;
|
|
17362
17361
|
if (targetPath !== void 0) {
|
|
17363
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
17362
|
+
this.fsw._symlinkPaths.set(sp.resolve(path18), targetPath);
|
|
17364
17363
|
}
|
|
17365
17364
|
} else {
|
|
17366
17365
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
17367
17366
|
}
|
|
17368
17367
|
ready();
|
|
17369
17368
|
if (closer)
|
|
17370
|
-
this.fsw._addPathCloser(
|
|
17369
|
+
this.fsw._addPathCloser(path18, closer);
|
|
17371
17370
|
return false;
|
|
17372
17371
|
} catch (error48) {
|
|
17373
17372
|
if (this.fsw._handleError(error48)) {
|
|
17374
17373
|
ready();
|
|
17375
|
-
return
|
|
17374
|
+
return path18;
|
|
17376
17375
|
}
|
|
17377
17376
|
}
|
|
17378
17377
|
}
|
|
@@ -17415,24 +17414,24 @@ function createPattern(matcher) {
|
|
|
17415
17414
|
}
|
|
17416
17415
|
return () => false;
|
|
17417
17416
|
}
|
|
17418
|
-
function normalizePath(
|
|
17419
|
-
if (typeof
|
|
17417
|
+
function normalizePath(path18) {
|
|
17418
|
+
if (typeof path18 !== "string")
|
|
17420
17419
|
throw new Error("string expected");
|
|
17421
|
-
|
|
17422
|
-
|
|
17420
|
+
path18 = sp2.normalize(path18);
|
|
17421
|
+
path18 = path18.replace(/\\/g, "/");
|
|
17423
17422
|
let prepend = false;
|
|
17424
|
-
if (
|
|
17423
|
+
if (path18.startsWith("//"))
|
|
17425
17424
|
prepend = true;
|
|
17426
|
-
|
|
17425
|
+
path18 = path18.replace(DOUBLE_SLASH_RE, "/");
|
|
17427
17426
|
if (prepend)
|
|
17428
|
-
|
|
17429
|
-
return
|
|
17427
|
+
path18 = "/" + path18;
|
|
17428
|
+
return path18;
|
|
17430
17429
|
}
|
|
17431
17430
|
function matchPatterns(patterns, testString, stats) {
|
|
17432
|
-
const
|
|
17431
|
+
const path18 = normalizePath(testString);
|
|
17433
17432
|
for (let index = 0; index < patterns.length; index++) {
|
|
17434
17433
|
const pattern = patterns[index];
|
|
17435
|
-
if (pattern(
|
|
17434
|
+
if (pattern(path18, stats)) {
|
|
17436
17435
|
return true;
|
|
17437
17436
|
}
|
|
17438
17437
|
}
|
|
@@ -17470,19 +17469,19 @@ var toUnix = (string4) => {
|
|
|
17470
17469
|
}
|
|
17471
17470
|
return str;
|
|
17472
17471
|
};
|
|
17473
|
-
var normalizePathToUnix = (
|
|
17474
|
-
var normalizeIgnored = (cwd = "") => (
|
|
17475
|
-
if (typeof
|
|
17476
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
17472
|
+
var normalizePathToUnix = (path18) => toUnix(sp2.normalize(toUnix(path18)));
|
|
17473
|
+
var normalizeIgnored = (cwd = "") => (path18) => {
|
|
17474
|
+
if (typeof path18 === "string") {
|
|
17475
|
+
return normalizePathToUnix(sp2.isAbsolute(path18) ? path18 : sp2.join(cwd, path18));
|
|
17477
17476
|
} else {
|
|
17478
|
-
return
|
|
17477
|
+
return path18;
|
|
17479
17478
|
}
|
|
17480
17479
|
};
|
|
17481
|
-
var getAbsolutePath = (
|
|
17482
|
-
if (sp2.isAbsolute(
|
|
17483
|
-
return
|
|
17480
|
+
var getAbsolutePath = (path18, cwd) => {
|
|
17481
|
+
if (sp2.isAbsolute(path18)) {
|
|
17482
|
+
return path18;
|
|
17484
17483
|
}
|
|
17485
|
-
return sp2.join(cwd,
|
|
17484
|
+
return sp2.join(cwd, path18);
|
|
17486
17485
|
};
|
|
17487
17486
|
var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
17488
17487
|
var DirEntry = class {
|
|
@@ -17547,10 +17546,10 @@ var WatchHelper = class {
|
|
|
17547
17546
|
dirParts;
|
|
17548
17547
|
followSymlinks;
|
|
17549
17548
|
statMethod;
|
|
17550
|
-
constructor(
|
|
17549
|
+
constructor(path18, follow, fsw) {
|
|
17551
17550
|
this.fsw = fsw;
|
|
17552
|
-
const watchPath =
|
|
17553
|
-
this.path =
|
|
17551
|
+
const watchPath = path18;
|
|
17552
|
+
this.path = path18 = path18.replace(REPLACER_RE, "");
|
|
17554
17553
|
this.watchPath = watchPath;
|
|
17555
17554
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
17556
17555
|
this.dirParts = [];
|
|
@@ -17690,20 +17689,20 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17690
17689
|
this._closePromise = void 0;
|
|
17691
17690
|
let paths = unifyPaths(paths_);
|
|
17692
17691
|
if (cwd) {
|
|
17693
|
-
paths = paths.map((
|
|
17694
|
-
const absPath = getAbsolutePath(
|
|
17692
|
+
paths = paths.map((path18) => {
|
|
17693
|
+
const absPath = getAbsolutePath(path18, cwd);
|
|
17695
17694
|
return absPath;
|
|
17696
17695
|
});
|
|
17697
17696
|
}
|
|
17698
|
-
paths.forEach((
|
|
17699
|
-
this._removeIgnoredPath(
|
|
17697
|
+
paths.forEach((path18) => {
|
|
17698
|
+
this._removeIgnoredPath(path18);
|
|
17700
17699
|
});
|
|
17701
17700
|
this._userIgnored = void 0;
|
|
17702
17701
|
if (!this._readyCount)
|
|
17703
17702
|
this._readyCount = 0;
|
|
17704
17703
|
this._readyCount += paths.length;
|
|
17705
|
-
Promise.all(paths.map(async (
|
|
17706
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
17704
|
+
Promise.all(paths.map(async (path18) => {
|
|
17705
|
+
const res = await this._nodeFsHandler._addToNodeFs(path18, !_internal, void 0, 0, _origAdd);
|
|
17707
17706
|
if (res)
|
|
17708
17707
|
this._emitReady();
|
|
17709
17708
|
return res;
|
|
@@ -17725,17 +17724,17 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17725
17724
|
return this;
|
|
17726
17725
|
const paths = unifyPaths(paths_);
|
|
17727
17726
|
const { cwd } = this.options;
|
|
17728
|
-
paths.forEach((
|
|
17729
|
-
if (!sp2.isAbsolute(
|
|
17727
|
+
paths.forEach((path18) => {
|
|
17728
|
+
if (!sp2.isAbsolute(path18) && !this._closers.has(path18)) {
|
|
17730
17729
|
if (cwd)
|
|
17731
|
-
|
|
17732
|
-
|
|
17730
|
+
path18 = sp2.join(cwd, path18);
|
|
17731
|
+
path18 = sp2.resolve(path18);
|
|
17733
17732
|
}
|
|
17734
|
-
this._closePath(
|
|
17735
|
-
this._addIgnoredPath(
|
|
17736
|
-
if (this._watched.has(
|
|
17733
|
+
this._closePath(path18);
|
|
17734
|
+
this._addIgnoredPath(path18);
|
|
17735
|
+
if (this._watched.has(path18)) {
|
|
17737
17736
|
this._addIgnoredPath({
|
|
17738
|
-
path:
|
|
17737
|
+
path: path18,
|
|
17739
17738
|
recursive: true
|
|
17740
17739
|
});
|
|
17741
17740
|
}
|
|
@@ -17799,38 +17798,38 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17799
17798
|
* @param stats arguments to be passed with event
|
|
17800
17799
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
17801
17800
|
*/
|
|
17802
|
-
async _emit(event,
|
|
17801
|
+
async _emit(event, path18, stats) {
|
|
17803
17802
|
if (this.closed)
|
|
17804
17803
|
return;
|
|
17805
17804
|
const opts = this.options;
|
|
17806
17805
|
if (isWindows)
|
|
17807
|
-
|
|
17806
|
+
path18 = sp2.normalize(path18);
|
|
17808
17807
|
if (opts.cwd)
|
|
17809
|
-
|
|
17810
|
-
const args = [
|
|
17808
|
+
path18 = sp2.relative(opts.cwd, path18);
|
|
17809
|
+
const args = [path18];
|
|
17811
17810
|
if (stats != null)
|
|
17812
17811
|
args.push(stats);
|
|
17813
17812
|
const awf = opts.awaitWriteFinish;
|
|
17814
17813
|
let pw;
|
|
17815
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
17814
|
+
if (awf && (pw = this._pendingWrites.get(path18))) {
|
|
17816
17815
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
17817
17816
|
return this;
|
|
17818
17817
|
}
|
|
17819
17818
|
if (opts.atomic) {
|
|
17820
17819
|
if (event === EVENTS.UNLINK) {
|
|
17821
|
-
this._pendingUnlinks.set(
|
|
17820
|
+
this._pendingUnlinks.set(path18, [event, ...args]);
|
|
17822
17821
|
setTimeout(() => {
|
|
17823
|
-
this._pendingUnlinks.forEach((entry,
|
|
17822
|
+
this._pendingUnlinks.forEach((entry, path19) => {
|
|
17824
17823
|
this.emit(...entry);
|
|
17825
17824
|
this.emit(EVENTS.ALL, ...entry);
|
|
17826
|
-
this._pendingUnlinks.delete(
|
|
17825
|
+
this._pendingUnlinks.delete(path19);
|
|
17827
17826
|
});
|
|
17828
17827
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
17829
17828
|
return this;
|
|
17830
17829
|
}
|
|
17831
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
17830
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path18)) {
|
|
17832
17831
|
event = EVENTS.CHANGE;
|
|
17833
|
-
this._pendingUnlinks.delete(
|
|
17832
|
+
this._pendingUnlinks.delete(path18);
|
|
17834
17833
|
}
|
|
17835
17834
|
}
|
|
17836
17835
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -17848,16 +17847,16 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17848
17847
|
this.emitWithAll(event, args);
|
|
17849
17848
|
}
|
|
17850
17849
|
};
|
|
17851
|
-
this._awaitWriteFinish(
|
|
17850
|
+
this._awaitWriteFinish(path18, awf.stabilityThreshold, event, awfEmit);
|
|
17852
17851
|
return this;
|
|
17853
17852
|
}
|
|
17854
17853
|
if (event === EVENTS.CHANGE) {
|
|
17855
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
17854
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path18, 50);
|
|
17856
17855
|
if (isThrottled)
|
|
17857
17856
|
return this;
|
|
17858
17857
|
}
|
|
17859
17858
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
17860
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
17859
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path18) : path18;
|
|
17861
17860
|
let stats2;
|
|
17862
17861
|
try {
|
|
17863
17862
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -17888,23 +17887,23 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17888
17887
|
* @param timeout duration of time to suppress duplicate actions
|
|
17889
17888
|
* @returns tracking object or false if action should be suppressed
|
|
17890
17889
|
*/
|
|
17891
|
-
_throttle(actionType,
|
|
17890
|
+
_throttle(actionType, path18, timeout) {
|
|
17892
17891
|
if (!this._throttled.has(actionType)) {
|
|
17893
17892
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
17894
17893
|
}
|
|
17895
17894
|
const action = this._throttled.get(actionType);
|
|
17896
17895
|
if (!action)
|
|
17897
17896
|
throw new Error("invalid throttle");
|
|
17898
|
-
const actionPath = action.get(
|
|
17897
|
+
const actionPath = action.get(path18);
|
|
17899
17898
|
if (actionPath) {
|
|
17900
17899
|
actionPath.count++;
|
|
17901
17900
|
return false;
|
|
17902
17901
|
}
|
|
17903
17902
|
let timeoutObject;
|
|
17904
17903
|
const clear = () => {
|
|
17905
|
-
const item = action.get(
|
|
17904
|
+
const item = action.get(path18);
|
|
17906
17905
|
const count = item ? item.count : 0;
|
|
17907
|
-
action.delete(
|
|
17906
|
+
action.delete(path18);
|
|
17908
17907
|
clearTimeout(timeoutObject);
|
|
17909
17908
|
if (item)
|
|
17910
17909
|
clearTimeout(item.timeoutObject);
|
|
@@ -17912,7 +17911,7 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17912
17911
|
};
|
|
17913
17912
|
timeoutObject = setTimeout(clear, timeout);
|
|
17914
17913
|
const thr = { timeoutObject, clear, count: 0 };
|
|
17915
|
-
action.set(
|
|
17914
|
+
action.set(path18, thr);
|
|
17916
17915
|
return thr;
|
|
17917
17916
|
}
|
|
17918
17917
|
_incrReadyCount() {
|
|
@@ -17926,44 +17925,44 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17926
17925
|
* @param event
|
|
17927
17926
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
17928
17927
|
*/
|
|
17929
|
-
_awaitWriteFinish(
|
|
17928
|
+
_awaitWriteFinish(path18, threshold, event, awfEmit) {
|
|
17930
17929
|
const awf = this.options.awaitWriteFinish;
|
|
17931
17930
|
if (typeof awf !== "object")
|
|
17932
17931
|
return;
|
|
17933
17932
|
const pollInterval = awf.pollInterval;
|
|
17934
17933
|
let timeoutHandler;
|
|
17935
|
-
let fullPath =
|
|
17936
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
17937
|
-
fullPath = sp2.join(this.options.cwd,
|
|
17934
|
+
let fullPath = path18;
|
|
17935
|
+
if (this.options.cwd && !sp2.isAbsolute(path18)) {
|
|
17936
|
+
fullPath = sp2.join(this.options.cwd, path18);
|
|
17938
17937
|
}
|
|
17939
17938
|
const now = /* @__PURE__ */ new Date();
|
|
17940
17939
|
const writes = this._pendingWrites;
|
|
17941
17940
|
function awaitWriteFinishFn(prevStat) {
|
|
17942
17941
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
17943
|
-
if (err || !writes.has(
|
|
17942
|
+
if (err || !writes.has(path18)) {
|
|
17944
17943
|
if (err && err.code !== "ENOENT")
|
|
17945
17944
|
awfEmit(err);
|
|
17946
17945
|
return;
|
|
17947
17946
|
}
|
|
17948
17947
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
17949
17948
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
17950
|
-
writes.get(
|
|
17949
|
+
writes.get(path18).lastChange = now2;
|
|
17951
17950
|
}
|
|
17952
|
-
const pw = writes.get(
|
|
17951
|
+
const pw = writes.get(path18);
|
|
17953
17952
|
const df = now2 - pw.lastChange;
|
|
17954
17953
|
if (df >= threshold) {
|
|
17955
|
-
writes.delete(
|
|
17954
|
+
writes.delete(path18);
|
|
17956
17955
|
awfEmit(void 0, curStat);
|
|
17957
17956
|
} else {
|
|
17958
17957
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
17959
17958
|
}
|
|
17960
17959
|
});
|
|
17961
17960
|
}
|
|
17962
|
-
if (!writes.has(
|
|
17963
|
-
writes.set(
|
|
17961
|
+
if (!writes.has(path18)) {
|
|
17962
|
+
writes.set(path18, {
|
|
17964
17963
|
lastChange: now,
|
|
17965
17964
|
cancelWait: () => {
|
|
17966
|
-
writes.delete(
|
|
17965
|
+
writes.delete(path18);
|
|
17967
17966
|
clearTimeout(timeoutHandler);
|
|
17968
17967
|
return event;
|
|
17969
17968
|
}
|
|
@@ -17974,8 +17973,8 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17974
17973
|
/**
|
|
17975
17974
|
* Determines whether user has asked to ignore this path.
|
|
17976
17975
|
*/
|
|
17977
|
-
_isIgnored(
|
|
17978
|
-
if (this.options.atomic && DOT_RE.test(
|
|
17976
|
+
_isIgnored(path18, stats) {
|
|
17977
|
+
if (this.options.atomic && DOT_RE.test(path18))
|
|
17979
17978
|
return true;
|
|
17980
17979
|
if (!this._userIgnored) {
|
|
17981
17980
|
const { cwd } = this.options;
|
|
@@ -17985,17 +17984,17 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17985
17984
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
17986
17985
|
this._userIgnored = anymatch(list, void 0);
|
|
17987
17986
|
}
|
|
17988
|
-
return this._userIgnored(
|
|
17987
|
+
return this._userIgnored(path18, stats);
|
|
17989
17988
|
}
|
|
17990
|
-
_isntIgnored(
|
|
17991
|
-
return !this._isIgnored(
|
|
17989
|
+
_isntIgnored(path18, stat4) {
|
|
17990
|
+
return !this._isIgnored(path18, stat4);
|
|
17992
17991
|
}
|
|
17993
17992
|
/**
|
|
17994
17993
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
17995
17994
|
* @param path file or directory pattern being watched
|
|
17996
17995
|
*/
|
|
17997
|
-
_getWatchHelpers(
|
|
17998
|
-
return new WatchHelper(
|
|
17996
|
+
_getWatchHelpers(path18) {
|
|
17997
|
+
return new WatchHelper(path18, this.options.followSymlinks, this);
|
|
17999
17998
|
}
|
|
18000
17999
|
// Directory helpers
|
|
18001
18000
|
// -----------------
|
|
@@ -18027,63 +18026,63 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
18027
18026
|
* @param item base path of item/directory
|
|
18028
18027
|
*/
|
|
18029
18028
|
_remove(directory, item, isDirectory) {
|
|
18030
|
-
const
|
|
18031
|
-
const fullPath = sp2.resolve(
|
|
18032
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
18033
|
-
if (!this._throttle("remove",
|
|
18029
|
+
const path18 = sp2.join(directory, item);
|
|
18030
|
+
const fullPath = sp2.resolve(path18);
|
|
18031
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path18) || this._watched.has(fullPath);
|
|
18032
|
+
if (!this._throttle("remove", path18, 100))
|
|
18034
18033
|
return;
|
|
18035
18034
|
if (!isDirectory && this._watched.size === 1) {
|
|
18036
18035
|
this.add(directory, item, true);
|
|
18037
18036
|
}
|
|
18038
|
-
const wp = this._getWatchedDir(
|
|
18037
|
+
const wp = this._getWatchedDir(path18);
|
|
18039
18038
|
const nestedDirectoryChildren = wp.getChildren();
|
|
18040
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
18039
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path18, nested));
|
|
18041
18040
|
const parent = this._getWatchedDir(directory);
|
|
18042
18041
|
const wasTracked = parent.has(item);
|
|
18043
18042
|
parent.remove(item);
|
|
18044
18043
|
if (this._symlinkPaths.has(fullPath)) {
|
|
18045
18044
|
this._symlinkPaths.delete(fullPath);
|
|
18046
18045
|
}
|
|
18047
|
-
let relPath =
|
|
18046
|
+
let relPath = path18;
|
|
18048
18047
|
if (this.options.cwd)
|
|
18049
|
-
relPath = sp2.relative(this.options.cwd,
|
|
18048
|
+
relPath = sp2.relative(this.options.cwd, path18);
|
|
18050
18049
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
18051
18050
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
18052
18051
|
if (event === EVENTS.ADD)
|
|
18053
18052
|
return;
|
|
18054
18053
|
}
|
|
18055
|
-
this._watched.delete(
|
|
18054
|
+
this._watched.delete(path18);
|
|
18056
18055
|
this._watched.delete(fullPath);
|
|
18057
18056
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
18058
|
-
if (wasTracked && !this._isIgnored(
|
|
18059
|
-
this._emit(eventName,
|
|
18060
|
-
this._closePath(
|
|
18057
|
+
if (wasTracked && !this._isIgnored(path18))
|
|
18058
|
+
this._emit(eventName, path18);
|
|
18059
|
+
this._closePath(path18);
|
|
18061
18060
|
}
|
|
18062
18061
|
/**
|
|
18063
18062
|
* Closes all watchers for a path
|
|
18064
18063
|
*/
|
|
18065
|
-
_closePath(
|
|
18066
|
-
this._closeFile(
|
|
18067
|
-
const dir = sp2.dirname(
|
|
18068
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
18064
|
+
_closePath(path18) {
|
|
18065
|
+
this._closeFile(path18);
|
|
18066
|
+
const dir = sp2.dirname(path18);
|
|
18067
|
+
this._getWatchedDir(dir).remove(sp2.basename(path18));
|
|
18069
18068
|
}
|
|
18070
18069
|
/**
|
|
18071
18070
|
* Closes only file-specific watchers
|
|
18072
18071
|
*/
|
|
18073
|
-
_closeFile(
|
|
18074
|
-
const closers = this._closers.get(
|
|
18072
|
+
_closeFile(path18) {
|
|
18073
|
+
const closers = this._closers.get(path18);
|
|
18075
18074
|
if (!closers)
|
|
18076
18075
|
return;
|
|
18077
18076
|
closers.forEach((closer) => closer());
|
|
18078
|
-
this._closers.delete(
|
|
18077
|
+
this._closers.delete(path18);
|
|
18079
18078
|
}
|
|
18080
|
-
_addPathCloser(
|
|
18079
|
+
_addPathCloser(path18, closer) {
|
|
18081
18080
|
if (!closer)
|
|
18082
18081
|
return;
|
|
18083
|
-
let list = this._closers.get(
|
|
18082
|
+
let list = this._closers.get(path18);
|
|
18084
18083
|
if (!list) {
|
|
18085
18084
|
list = [];
|
|
18086
|
-
this._closers.set(
|
|
18085
|
+
this._closers.set(path18, list);
|
|
18087
18086
|
}
|
|
18088
18087
|
list.push(closer);
|
|
18089
18088
|
}
|
|
@@ -18113,12 +18112,12 @@ function watch(paths, options = {}) {
|
|
|
18113
18112
|
|
|
18114
18113
|
// ../daemon-core/dist/index.mjs
|
|
18115
18114
|
var fs6 = __toESM(require("fs"), 1);
|
|
18116
|
-
var
|
|
18115
|
+
var path8 = __toESM(require("path"), 1);
|
|
18117
18116
|
var os9 = __toESM(require("os"), 1);
|
|
18118
|
-
var fs7 = __toESM(require("fs"), 1);
|
|
18119
18117
|
var os10 = __toESM(require("os"), 1);
|
|
18118
|
+
var fs7 = __toESM(require("fs"), 1);
|
|
18120
18119
|
var os13 = __toESM(require("os"), 1);
|
|
18121
|
-
var
|
|
18120
|
+
var path10 = __toESM(require("path"), 1);
|
|
18122
18121
|
var crypto4 = __toESM(require("crypto"), 1);
|
|
18123
18122
|
var import_chalk = __toESM(require("chalk"), 1);
|
|
18124
18123
|
var crypto3 = __toESM(require("crypto"), 1);
|
|
@@ -18126,17 +18125,17 @@ var import_stream = require("stream");
|
|
|
18126
18125
|
var import_child_process6 = require("child_process");
|
|
18127
18126
|
init_acp();
|
|
18128
18127
|
var fs8 = __toESM(require("fs"), 1);
|
|
18129
|
-
var
|
|
18128
|
+
var path11 = __toESM(require("path"), 1);
|
|
18130
18129
|
var os14 = __toESM(require("os"), 1);
|
|
18131
18130
|
var import_child_process7 = require("child_process");
|
|
18132
18131
|
var import_os3 = require("os");
|
|
18133
18132
|
var http2 = __toESM(require("http"), 1);
|
|
18134
18133
|
var fs11 = __toESM(require("fs"), 1);
|
|
18135
|
-
var
|
|
18134
|
+
var path14 = __toESM(require("path"), 1);
|
|
18136
18135
|
var fs9 = __toESM(require("fs"), 1);
|
|
18137
|
-
var
|
|
18136
|
+
var path12 = __toESM(require("path"), 1);
|
|
18138
18137
|
var fs10 = __toESM(require("fs"), 1);
|
|
18139
|
-
var
|
|
18138
|
+
var path13 = __toESM(require("path"), 1);
|
|
18140
18139
|
var os15 = __toESM(require("os"), 1);
|
|
18141
18140
|
|
|
18142
18141
|
// ../session-host-core/dist/index.mjs
|
|
@@ -18206,8 +18205,8 @@ var SessionHostClient = class {
|
|
|
18206
18205
|
}
|
|
18207
18206
|
this.requestWaiters.clear();
|
|
18208
18207
|
});
|
|
18209
|
-
await new Promise((
|
|
18210
|
-
socket.once("connect", () =>
|
|
18208
|
+
await new Promise((resolve12, reject) => {
|
|
18209
|
+
socket.once("connect", () => resolve12());
|
|
18211
18210
|
socket.once("error", reject);
|
|
18212
18211
|
});
|
|
18213
18212
|
}
|
|
@@ -18226,7 +18225,7 @@ var SessionHostClient = class {
|
|
|
18226
18225
|
requestId,
|
|
18227
18226
|
request
|
|
18228
18227
|
};
|
|
18229
|
-
const response = await new Promise((
|
|
18228
|
+
const response = await new Promise((resolve12, reject) => {
|
|
18230
18229
|
const timeout = setTimeout(() => {
|
|
18231
18230
|
this.requestWaiters.delete(requestId);
|
|
18232
18231
|
reject(new Error(`Session host request timed out after 30s (${request.type})`));
|
|
@@ -18234,7 +18233,7 @@ var SessionHostClient = class {
|
|
|
18234
18233
|
this.requestWaiters.set(requestId, {
|
|
18235
18234
|
resolve: (value) => {
|
|
18236
18235
|
clearTimeout(timeout);
|
|
18237
|
-
|
|
18236
|
+
resolve12(value);
|
|
18238
18237
|
},
|
|
18239
18238
|
reject: (error48) => {
|
|
18240
18239
|
clearTimeout(timeout);
|
|
@@ -18253,12 +18252,12 @@ var SessionHostClient = class {
|
|
|
18253
18252
|
waiter.reject(new Error("Session host client closed"));
|
|
18254
18253
|
}
|
|
18255
18254
|
this.requestWaiters.clear();
|
|
18256
|
-
await new Promise((
|
|
18255
|
+
await new Promise((resolve12) => {
|
|
18257
18256
|
let settled = false;
|
|
18258
18257
|
const done = () => {
|
|
18259
18258
|
if (settled) return;
|
|
18260
18259
|
settled = true;
|
|
18261
|
-
|
|
18260
|
+
resolve12();
|
|
18262
18261
|
};
|
|
18263
18262
|
socket.once("close", done);
|
|
18264
18263
|
socket.end();
|
|
@@ -18295,194 +18294,8 @@ var __copyProps2 = (to, from, except, desc) => {
|
|
|
18295
18294
|
return to;
|
|
18296
18295
|
};
|
|
18297
18296
|
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
18298
|
-
function expandPath(p) {
|
|
18299
|
-
const t = (p || "").trim();
|
|
18300
|
-
if (!t) return "";
|
|
18301
|
-
if (t.startsWith("~")) return path.join(os2.homedir(), t.slice(1).replace(/^\//, ""));
|
|
18302
|
-
return path.resolve(t);
|
|
18303
|
-
}
|
|
18304
|
-
function validateWorkspacePath(absPath) {
|
|
18305
|
-
try {
|
|
18306
|
-
if (!absPath) return { ok: false, error: "Path required" };
|
|
18307
|
-
if (!fs.existsSync(absPath)) return { ok: false, error: "Path does not exist" };
|
|
18308
|
-
const st = fs.statSync(absPath);
|
|
18309
|
-
if (!st.isDirectory()) return { ok: false, error: "Not a directory" };
|
|
18310
|
-
return { ok: true };
|
|
18311
|
-
} catch (e) {
|
|
18312
|
-
return { ok: false, error: e?.message || "Invalid path" };
|
|
18313
|
-
}
|
|
18314
|
-
}
|
|
18315
|
-
function defaultWorkspaceLabel(absPath) {
|
|
18316
|
-
const base = path.basename(absPath) || absPath;
|
|
18317
|
-
return base;
|
|
18318
|
-
}
|
|
18319
|
-
function migrateWorkspacesFromRecent(config2) {
|
|
18320
|
-
if (!config2.workspaces) config2.workspaces = [];
|
|
18321
|
-
if (config2.workspaces.length > 0) return config2;
|
|
18322
|
-
const recent = config2.recentCliWorkspaces || [];
|
|
18323
|
-
const now = Date.now();
|
|
18324
|
-
for (const raw of recent) {
|
|
18325
|
-
const abs = expandPath(raw);
|
|
18326
|
-
if (!abs || validateWorkspacePath(abs).ok !== true) continue;
|
|
18327
|
-
if (config2.workspaces.some((w) => path.resolve(w.path) === abs)) continue;
|
|
18328
|
-
config2.workspaces.push({
|
|
18329
|
-
id: (0, import_crypto2.randomUUID)(),
|
|
18330
|
-
path: abs,
|
|
18331
|
-
label: defaultWorkspaceLabel(abs),
|
|
18332
|
-
addedAt: now
|
|
18333
|
-
});
|
|
18334
|
-
if (config2.workspaces.length >= MAX_WORKSPACES) break;
|
|
18335
|
-
}
|
|
18336
|
-
return config2;
|
|
18337
|
-
}
|
|
18338
|
-
function getDefaultWorkspacePath(config2) {
|
|
18339
|
-
const id = config2.defaultWorkspaceId;
|
|
18340
|
-
if (!id) return null;
|
|
18341
|
-
const w = (config2.workspaces || []).find((x) => x.id === id);
|
|
18342
|
-
if (!w) return null;
|
|
18343
|
-
const abs = expandPath(w.path);
|
|
18344
|
-
if (validateWorkspacePath(abs).ok !== true) return null;
|
|
18345
|
-
return abs;
|
|
18346
|
-
}
|
|
18347
|
-
function getWorkspaceState(config2) {
|
|
18348
|
-
const workspaces = [...config2.workspaces || []].sort((a, b) => b.addedAt - a.addedAt);
|
|
18349
|
-
const defaultWorkspacePath = getDefaultWorkspacePath(config2);
|
|
18350
|
-
return {
|
|
18351
|
-
workspaces,
|
|
18352
|
-
defaultWorkspaceId: config2.defaultWorkspaceId ?? null,
|
|
18353
|
-
defaultWorkspacePath
|
|
18354
|
-
};
|
|
18355
|
-
}
|
|
18356
|
-
function resolveLaunchDirectory(args, config2) {
|
|
18357
|
-
const a = args || {};
|
|
18358
|
-
if (a.dir != null && String(a.dir).trim()) {
|
|
18359
|
-
const abs = expandPath(String(a.dir).trim());
|
|
18360
|
-
if (abs && validateWorkspacePath(abs).ok === true) {
|
|
18361
|
-
return { ok: true, path: abs, source: "dir" };
|
|
18362
|
-
}
|
|
18363
|
-
return {
|
|
18364
|
-
ok: false,
|
|
18365
|
-
code: "WORKSPACE_LAUNCH_CONTEXT_REQUIRED",
|
|
18366
|
-
message: abs ? "Directory path is not valid or does not exist" : "Invalid directory path"
|
|
18367
|
-
};
|
|
18368
|
-
}
|
|
18369
|
-
if (a.workspaceId) {
|
|
18370
|
-
const w = (config2.workspaces || []).find((x) => x.id === a.workspaceId);
|
|
18371
|
-
if (w) {
|
|
18372
|
-
const abs = expandPath(w.path);
|
|
18373
|
-
if (validateWorkspacePath(abs).ok === true) {
|
|
18374
|
-
return { ok: true, path: abs, source: "workspaceId" };
|
|
18375
|
-
}
|
|
18376
|
-
}
|
|
18377
|
-
return {
|
|
18378
|
-
ok: false,
|
|
18379
|
-
code: "WORKSPACE_LAUNCH_CONTEXT_REQUIRED",
|
|
18380
|
-
message: "Saved workspace not found or path is no longer valid"
|
|
18381
|
-
};
|
|
18382
|
-
}
|
|
18383
|
-
if (a.useDefaultWorkspace === true) {
|
|
18384
|
-
const d = getDefaultWorkspacePath(config2);
|
|
18385
|
-
if (d) return { ok: true, path: d, source: "defaultWorkspace" };
|
|
18386
|
-
return {
|
|
18387
|
-
ok: false,
|
|
18388
|
-
code: "WORKSPACE_LAUNCH_CONTEXT_REQUIRED",
|
|
18389
|
-
message: "No default workspace is set"
|
|
18390
|
-
};
|
|
18391
|
-
}
|
|
18392
|
-
if (a.useHome === true) {
|
|
18393
|
-
return { ok: true, path: os2.homedir(), source: "home" };
|
|
18394
|
-
}
|
|
18395
|
-
return {
|
|
18396
|
-
ok: false,
|
|
18397
|
-
code: "WORKSPACE_LAUNCH_CONTEXT_REQUIRED",
|
|
18398
|
-
message: "Choose a directory, saved workspace, default workspace, or home before launching."
|
|
18399
|
-
};
|
|
18400
|
-
}
|
|
18401
|
-
function resolveIdeWorkspaceFromArgs(args, config2) {
|
|
18402
|
-
const ar = args || {};
|
|
18403
|
-
if (ar.workspace) {
|
|
18404
|
-
const abs = expandPath(ar.workspace);
|
|
18405
|
-
if (abs && validateWorkspacePath(abs).ok === true) return abs;
|
|
18406
|
-
}
|
|
18407
|
-
if (ar.workspaceId) {
|
|
18408
|
-
const w = (config2.workspaces || []).find((x) => x.id === ar.workspaceId);
|
|
18409
|
-
if (w) {
|
|
18410
|
-
const abs = expandPath(w.path);
|
|
18411
|
-
if (validateWorkspacePath(abs).ok === true) return abs;
|
|
18412
|
-
}
|
|
18413
|
-
}
|
|
18414
|
-
if (ar.useDefaultWorkspace === true) {
|
|
18415
|
-
return getDefaultWorkspacePath(config2) || void 0;
|
|
18416
|
-
}
|
|
18417
|
-
return void 0;
|
|
18418
|
-
}
|
|
18419
|
-
function resolveIdeLaunchWorkspace(args, config2) {
|
|
18420
|
-
const direct = resolveIdeWorkspaceFromArgs(args, config2);
|
|
18421
|
-
if (direct) return direct;
|
|
18422
|
-
if (args?.useDefaultWorkspace === false) return void 0;
|
|
18423
|
-
return getDefaultWorkspacePath(config2) || void 0;
|
|
18424
|
-
}
|
|
18425
|
-
function findWorkspaceByPath(config2, rawPath) {
|
|
18426
|
-
const abs = path.resolve(expandPath(rawPath));
|
|
18427
|
-
if (!abs) return void 0;
|
|
18428
|
-
return (config2.workspaces || []).find((w) => path.resolve(expandPath(w.path)) === abs);
|
|
18429
|
-
}
|
|
18430
|
-
function addWorkspaceEntry(config2, rawPath, label, options) {
|
|
18431
|
-
const abs = expandPath(rawPath);
|
|
18432
|
-
const createIfMissing = options?.createIfMissing === true;
|
|
18433
|
-
if (!abs) return { error: "Path required" };
|
|
18434
|
-
if (!fs.existsSync(abs) && createIfMissing) {
|
|
18435
|
-
try {
|
|
18436
|
-
fs.mkdirSync(abs, { recursive: true });
|
|
18437
|
-
} catch (e) {
|
|
18438
|
-
return { error: e?.message || "Could not create directory" };
|
|
18439
|
-
}
|
|
18440
|
-
}
|
|
18441
|
-
const v = validateWorkspacePath(abs);
|
|
18442
|
-
if (!v.ok) return { error: v.error };
|
|
18443
|
-
const list = [...config2.workspaces || []];
|
|
18444
|
-
if (list.some((w) => path.resolve(w.path) === abs)) {
|
|
18445
|
-
return { error: "Workspace already in list" };
|
|
18446
|
-
}
|
|
18447
|
-
if (list.length >= MAX_WORKSPACES) {
|
|
18448
|
-
return { error: `Maximum ${MAX_WORKSPACES} workspaces` };
|
|
18449
|
-
}
|
|
18450
|
-
const entry = {
|
|
18451
|
-
id: (0, import_crypto2.randomUUID)(),
|
|
18452
|
-
path: abs,
|
|
18453
|
-
label: (label || "").trim() || defaultWorkspaceLabel(abs),
|
|
18454
|
-
addedAt: Date.now()
|
|
18455
|
-
};
|
|
18456
|
-
list.push(entry);
|
|
18457
|
-
return { config: { ...config2, workspaces: list }, entry };
|
|
18458
|
-
}
|
|
18459
|
-
function removeWorkspaceEntry(config2, id) {
|
|
18460
|
-
const list = (config2.workspaces || []).filter((w) => w.id !== id);
|
|
18461
|
-
if (list.length === (config2.workspaces || []).length) return { error: "Workspace not found" };
|
|
18462
|
-
let defaultWorkspaceId = config2.defaultWorkspaceId;
|
|
18463
|
-
if (defaultWorkspaceId === id) defaultWorkspaceId = null;
|
|
18464
|
-
return { config: { ...config2, workspaces: list, defaultWorkspaceId } };
|
|
18465
|
-
}
|
|
18466
|
-
function setDefaultWorkspaceId(config2, id) {
|
|
18467
|
-
if (id === null) {
|
|
18468
|
-
return { config: { ...config2, defaultWorkspaceId: null } };
|
|
18469
|
-
}
|
|
18470
|
-
const w = (config2.workspaces || []).find((x) => x.id === id);
|
|
18471
|
-
if (!w) return { error: "Workspace not found" };
|
|
18472
|
-
const abs = expandPath(w.path);
|
|
18473
|
-
if (validateWorkspacePath(abs).ok !== true) return { error: "Workspace path is no longer valid" };
|
|
18474
|
-
return { config: { ...config2, defaultWorkspaceId: id } };
|
|
18475
|
-
}
|
|
18476
|
-
var MAX_WORKSPACES;
|
|
18477
|
-
var init_workspaces = __esm2({
|
|
18478
|
-
"src/config/workspaces.ts"() {
|
|
18479
|
-
"use strict";
|
|
18480
|
-
MAX_WORKSPACES = 50;
|
|
18481
|
-
}
|
|
18482
|
-
});
|
|
18483
18297
|
var config_exports = {};
|
|
18484
18298
|
__export2(config_exports, {
|
|
18485
|
-
addCliHistory: () => addCliHistory,
|
|
18486
18299
|
generateConnectionToken: () => generateConnectionToken,
|
|
18487
18300
|
generateMachineId: () => generateMachineId,
|
|
18488
18301
|
getConfigDir: () => getConfigDir,
|
|
@@ -18495,7 +18308,7 @@ __export2(config_exports, {
|
|
|
18495
18308
|
updateConfig: () => updateConfig
|
|
18496
18309
|
});
|
|
18497
18310
|
function generateMachineId() {
|
|
18498
|
-
return `${MACHINE_ID_PREFIX}${(0,
|
|
18311
|
+
return `${MACHINE_ID_PREFIX}${(0, import_crypto2.randomUUID)().replace(/-/g, "")}`;
|
|
18499
18312
|
}
|
|
18500
18313
|
function isStableMachineId(machineId) {
|
|
18501
18314
|
return typeof machineId === "string" && machineId.startsWith(MACHINE_ID_PREFIX);
|
|
@@ -18542,15 +18355,9 @@ function loadConfig() {
|
|
|
18542
18355
|
merged.defaultWorkspaceId = merged.activeWorkspaceId;
|
|
18543
18356
|
}
|
|
18544
18357
|
delete merged.activeWorkspaceId;
|
|
18545
|
-
const hadStoredWorkspaces = Array.isArray(parsed.workspaces) && parsed.workspaces.length > 0;
|
|
18546
18358
|
const ensured = ensureMachineId(merged);
|
|
18547
18359
|
const normalized = ensured.config;
|
|
18548
|
-
|
|
18549
|
-
let configChanged = ensured.changed;
|
|
18550
|
-
if (!hadStoredWorkspaces && (normalized.workspaces?.length || 0) > 0) {
|
|
18551
|
-
configChanged = true;
|
|
18552
|
-
}
|
|
18553
|
-
if (configChanged) {
|
|
18360
|
+
if (ensured.changed) {
|
|
18554
18361
|
try {
|
|
18555
18362
|
saveConfig(normalized);
|
|
18556
18363
|
} catch {
|
|
@@ -18605,40 +18412,11 @@ function generateConnectionToken() {
|
|
|
18605
18412
|
}
|
|
18606
18413
|
return token;
|
|
18607
18414
|
}
|
|
18608
|
-
function addCliHistory(entry) {
|
|
18609
|
-
const config2 = loadConfig();
|
|
18610
|
-
const history = config2.cliHistory || [];
|
|
18611
|
-
const argsKey = (entry.cliArgs || []).join(" ");
|
|
18612
|
-
const category = entry.category || "cli";
|
|
18613
|
-
const workspaceKey = entry.workspace || "";
|
|
18614
|
-
const modelKey = entry.model || "";
|
|
18615
|
-
const filtered = history.filter((h) => {
|
|
18616
|
-
const hArgsKey = (h.cliArgs || []).join(" ");
|
|
18617
|
-
return !((h.category || "cli") === category && h.cliType === entry.cliType && h.dir === entry.dir && hArgsKey === argsKey && (h.workspace || "") === workspaceKey && (h.model || "") === modelKey);
|
|
18618
|
-
});
|
|
18619
|
-
filtered.unshift({
|
|
18620
|
-
...entry,
|
|
18621
|
-
category,
|
|
18622
|
-
timestamp: Date.now(),
|
|
18623
|
-
label: entry.label || (() => {
|
|
18624
|
-
const base = `${entry.cliType} \xB7 ${entry.dir.split("/").filter(Boolean).pop() || "root"}`;
|
|
18625
|
-
const suffix = [];
|
|
18626
|
-
if (entry.workspace && entry.workspace !== entry.dir) suffix.push(entry.workspace.split("/").filter(Boolean).pop() || entry.workspace);
|
|
18627
|
-
if (entry.model) suffix.push(`model=${entry.model}`);
|
|
18628
|
-
if (argsKey) suffix.push(argsKey);
|
|
18629
|
-
if (entry.newWindow) suffix.push("new window");
|
|
18630
|
-
return suffix.length > 0 ? `${base} (${suffix.join(" \xB7 ")})` : base;
|
|
18631
|
-
})()
|
|
18632
|
-
});
|
|
18633
|
-
config2.cliHistory = filtered.slice(0, 20);
|
|
18634
|
-
saveConfig(config2);
|
|
18635
|
-
}
|
|
18636
18415
|
var DEFAULT_CONFIG;
|
|
18637
18416
|
var MACHINE_ID_PREFIX;
|
|
18638
18417
|
var init_config = __esm2({
|
|
18639
18418
|
"src/config/config.ts"() {
|
|
18640
18419
|
"use strict";
|
|
18641
|
-
init_workspaces();
|
|
18642
18420
|
DEFAULT_CONFIG = {
|
|
18643
18421
|
serverUrl: "https://api.adhf.dev",
|
|
18644
18422
|
apiToken: null,
|
|
@@ -18654,17 +18432,15 @@ var init_config = __esm2({
|
|
|
18654
18432
|
setupDate: null,
|
|
18655
18433
|
configuredCLIs: [],
|
|
18656
18434
|
enabledIdes: [],
|
|
18657
|
-
recentCliWorkspaces: [],
|
|
18658
18435
|
workspaces: [],
|
|
18659
18436
|
defaultWorkspaceId: null,
|
|
18660
|
-
recentWorkspaceActivity: [],
|
|
18661
18437
|
recentActivity: [],
|
|
18662
|
-
|
|
18438
|
+
sessionReads: {},
|
|
18439
|
+
sessionReadMarkers: {},
|
|
18663
18440
|
machineNickname: null,
|
|
18664
18441
|
machineId: void 0,
|
|
18665
18442
|
machineSecret: null,
|
|
18666
18443
|
registeredMachineId: void 0,
|
|
18667
|
-
cliHistory: [],
|
|
18668
18444
|
providerSettings: {},
|
|
18669
18445
|
ideSettings: {},
|
|
18670
18446
|
disableUpstream: false
|
|
@@ -18679,7 +18455,7 @@ function checkDateRotation() {
|
|
|
18679
18455
|
const today = getDateStr();
|
|
18680
18456
|
if (today !== currentDate) {
|
|
18681
18457
|
currentDate = today;
|
|
18682
|
-
currentLogFile =
|
|
18458
|
+
currentLogFile = path3.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
18683
18459
|
cleanOldLogs();
|
|
18684
18460
|
}
|
|
18685
18461
|
}
|
|
@@ -18693,7 +18469,7 @@ function cleanOldLogs() {
|
|
|
18693
18469
|
const dateMatch = file2.match(/daemon-(\d{4}-\d{2}-\d{2})/);
|
|
18694
18470
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
18695
18471
|
try {
|
|
18696
|
-
fs2.unlinkSync(
|
|
18472
|
+
fs2.unlinkSync(path3.join(LOG_DIR, file2));
|
|
18697
18473
|
} catch {
|
|
18698
18474
|
}
|
|
18699
18475
|
}
|
|
@@ -18833,7 +18609,7 @@ var init_logger = __esm2({
|
|
|
18833
18609
|
LEVEL_NUM = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
18834
18610
|
LEVEL_LABEL = { debug: "DBG", info: "INF", warn: "WRN", error: "ERR" };
|
|
18835
18611
|
currentLevel = "info";
|
|
18836
|
-
LOG_DIR = process.platform === "win32" ?
|
|
18612
|
+
LOG_DIR = process.platform === "win32" ? path3.join(process.env.LOCALAPPDATA || process.env.APPDATA || path3.join(os4.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path3.join(os4.homedir(), "Library", "Logs", "adhdev") : path3.join(os4.homedir(), ".local", "share", "adhdev", "logs");
|
|
18837
18613
|
MAX_LOG_SIZE = 5 * 1024 * 1024;
|
|
18838
18614
|
MAX_LOG_DAYS = 7;
|
|
18839
18615
|
try {
|
|
@@ -18841,16 +18617,16 @@ var init_logger = __esm2({
|
|
|
18841
18617
|
} catch {
|
|
18842
18618
|
}
|
|
18843
18619
|
currentDate = getDateStr();
|
|
18844
|
-
currentLogFile =
|
|
18620
|
+
currentLogFile = path3.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
18845
18621
|
cleanOldLogs();
|
|
18846
18622
|
try {
|
|
18847
|
-
const oldLog =
|
|
18623
|
+
const oldLog = path3.join(LOG_DIR, "daemon.log");
|
|
18848
18624
|
if (fs2.existsSync(oldLog)) {
|
|
18849
18625
|
const stat4 = fs2.statSync(oldLog);
|
|
18850
18626
|
const oldDate = stat4.mtime.toISOString().slice(0, 10);
|
|
18851
|
-
fs2.renameSync(oldLog,
|
|
18627
|
+
fs2.renameSync(oldLog, path3.join(LOG_DIR, `daemon-${oldDate}.log`));
|
|
18852
18628
|
}
|
|
18853
|
-
const oldLogBackup =
|
|
18629
|
+
const oldLogBackup = path3.join(LOG_DIR, "daemon.log.old");
|
|
18854
18630
|
if (fs2.existsSync(oldLogBackup)) {
|
|
18855
18631
|
fs2.unlinkSync(oldLogBackup);
|
|
18856
18632
|
}
|
|
@@ -18882,7 +18658,7 @@ var init_logger = __esm2({
|
|
|
18882
18658
|
}
|
|
18883
18659
|
};
|
|
18884
18660
|
interceptorInstalled = false;
|
|
18885
|
-
LOG_PATH =
|
|
18661
|
+
LOG_PATH = path3.join(LOG_DIR, `daemon-${getDateStr()}.log`);
|
|
18886
18662
|
}
|
|
18887
18663
|
});
|
|
18888
18664
|
function isModuleNotFoundError(error48, ref) {
|
|
@@ -19207,7 +18983,7 @@ function findBinary(name) {
|
|
|
19207
18983
|
}
|
|
19208
18984
|
}
|
|
19209
18985
|
function isScriptBinary(binaryPath) {
|
|
19210
|
-
if (!
|
|
18986
|
+
if (!path9.isAbsolute(binaryPath)) return false;
|
|
19211
18987
|
try {
|
|
19212
18988
|
const fs122 = __require("fs");
|
|
19213
18989
|
const resolved = fs122.realpathSync(binaryPath);
|
|
@@ -19223,7 +18999,7 @@ function isScriptBinary(binaryPath) {
|
|
|
19223
18999
|
}
|
|
19224
19000
|
}
|
|
19225
19001
|
function looksLikeMachOOrElf(filePath) {
|
|
19226
|
-
if (!
|
|
19002
|
+
if (!path9.isAbsolute(filePath)) return false;
|
|
19227
19003
|
try {
|
|
19228
19004
|
const fs122 = __require("fs");
|
|
19229
19005
|
const resolved = fs122.realpathSync(filePath);
|
|
@@ -19350,9 +19126,9 @@ var init_provider_cli_adapter = __esm2({
|
|
|
19350
19126
|
if (os12.platform() !== "win32") {
|
|
19351
19127
|
try {
|
|
19352
19128
|
const fs122 = __require("fs");
|
|
19353
|
-
const ptyDir =
|
|
19129
|
+
const ptyDir = path9.resolve(path9.dirname(__require.resolve("node-pty")), "..");
|
|
19354
19130
|
const platformArch = `${os12.platform()}-${os12.arch()}`;
|
|
19355
|
-
const helper =
|
|
19131
|
+
const helper = path9.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
19356
19132
|
if (fs122.existsSync(helper)) {
|
|
19357
19133
|
const stat4 = fs122.statSync(helper);
|
|
19358
19134
|
if (!(stat4.mode & 73)) {
|
|
@@ -19541,7 +19317,7 @@ var init_provider_cli_adapter = __esm2({
|
|
|
19541
19317
|
LOG.info("CLI", `[${this.cliType}] Spawning in ${this.workingDir}`);
|
|
19542
19318
|
let shellCmd;
|
|
19543
19319
|
let shellArgs;
|
|
19544
|
-
const useShellUnix = !isWin && (!!spawnConfig.shell || !
|
|
19320
|
+
const useShellUnix = !isWin && (!!spawnConfig.shell || !path9.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
19545
19321
|
const useShell = isWin ? !!spawnConfig.shell : useShellUnix;
|
|
19546
19322
|
if (useShell) {
|
|
19547
19323
|
if (!spawnConfig.shell && !isWin) {
|
|
@@ -19966,7 +19742,7 @@ ${data.message || ""}`.trim();
|
|
|
19966
19742
|
if (this.startupParseGate) {
|
|
19967
19743
|
const deadline = Date.now() + 1e4;
|
|
19968
19744
|
while (this.startupParseGate && Date.now() < deadline) {
|
|
19969
|
-
await new Promise((
|
|
19745
|
+
await new Promise((resolve92) => setTimeout(resolve92, 50));
|
|
19970
19746
|
}
|
|
19971
19747
|
}
|
|
19972
19748
|
if (!this.ready) throw new Error(`${this.cliName} not ready (status: ${this.currentStatus})`);
|
|
@@ -20134,17 +19910,17 @@ ${data.message || ""}`.trim();
|
|
|
20134
19910
|
}
|
|
20135
19911
|
}
|
|
20136
19912
|
waitForStopped(timeoutMs) {
|
|
20137
|
-
return new Promise((
|
|
19913
|
+
return new Promise((resolve92) => {
|
|
20138
19914
|
const startedAt = Date.now();
|
|
20139
19915
|
const timer = setInterval(() => {
|
|
20140
19916
|
if (!this.ptyProcess || this.currentStatus === "stopped") {
|
|
20141
19917
|
clearInterval(timer);
|
|
20142
|
-
|
|
19918
|
+
resolve92(true);
|
|
20143
19919
|
return;
|
|
20144
19920
|
}
|
|
20145
19921
|
if (Date.now() - startedAt >= timeoutMs) {
|
|
20146
19922
|
clearInterval(timer);
|
|
20147
|
-
|
|
19923
|
+
resolve92(false);
|
|
20148
19924
|
}
|
|
20149
19925
|
}, 100);
|
|
20150
19926
|
});
|
|
@@ -20334,52 +20110,173 @@ ${data.message || ""}`.trim();
|
|
|
20334
20110
|
}
|
|
20335
20111
|
});
|
|
20336
20112
|
init_config();
|
|
20337
|
-
|
|
20338
|
-
|
|
20339
|
-
|
|
20340
|
-
|
|
20113
|
+
var MAX_WORKSPACES = 50;
|
|
20114
|
+
function expandPath(p) {
|
|
20115
|
+
const t = (p || "").trim();
|
|
20116
|
+
if (!t) return "";
|
|
20117
|
+
if (t.startsWith("~")) return path.join(os2.homedir(), t.slice(1).replace(/^\//, ""));
|
|
20118
|
+
return path.resolve(t);
|
|
20119
|
+
}
|
|
20120
|
+
function validateWorkspacePath(absPath) {
|
|
20341
20121
|
try {
|
|
20342
|
-
|
|
20343
|
-
|
|
20344
|
-
|
|
20122
|
+
if (!absPath) return { ok: false, error: "Path required" };
|
|
20123
|
+
if (!fs.existsSync(absPath)) return { ok: false, error: "Path does not exist" };
|
|
20124
|
+
const st = fs.statSync(absPath);
|
|
20125
|
+
if (!st.isDirectory()) return { ok: false, error: "Not a directory" };
|
|
20126
|
+
return { ok: true };
|
|
20127
|
+
} catch (e) {
|
|
20128
|
+
return { ok: false, error: e?.message || "Invalid path" };
|
|
20129
|
+
}
|
|
20130
|
+
}
|
|
20131
|
+
function defaultWorkspaceLabel(absPath) {
|
|
20132
|
+
const base = path.basename(absPath) || absPath;
|
|
20133
|
+
return base;
|
|
20134
|
+
}
|
|
20135
|
+
function getDefaultWorkspacePath(config2) {
|
|
20136
|
+
const id = config2.defaultWorkspaceId;
|
|
20137
|
+
if (!id) return null;
|
|
20138
|
+
const w = (config2.workspaces || []).find((x) => x.id === id);
|
|
20139
|
+
if (!w) return null;
|
|
20140
|
+
const abs = expandPath(w.path);
|
|
20141
|
+
if (validateWorkspacePath(abs).ok !== true) return null;
|
|
20142
|
+
return abs;
|
|
20143
|
+
}
|
|
20144
|
+
function getWorkspaceState(config2) {
|
|
20145
|
+
const workspaces = [...config2.workspaces || []].sort((a, b) => b.addedAt - a.addedAt);
|
|
20146
|
+
const defaultWorkspacePath = getDefaultWorkspacePath(config2);
|
|
20147
|
+
return {
|
|
20148
|
+
workspaces,
|
|
20149
|
+
defaultWorkspaceId: config2.defaultWorkspaceId ?? null,
|
|
20150
|
+
defaultWorkspacePath
|
|
20151
|
+
};
|
|
20152
|
+
}
|
|
20153
|
+
function resolveLaunchDirectory(args, config2) {
|
|
20154
|
+
const a = args || {};
|
|
20155
|
+
if (a.dir != null && String(a.dir).trim()) {
|
|
20156
|
+
const abs = expandPath(String(a.dir).trim());
|
|
20157
|
+
if (abs && validateWorkspacePath(abs).ok === true) {
|
|
20158
|
+
return { ok: true, path: abs, source: "dir" };
|
|
20159
|
+
}
|
|
20160
|
+
return {
|
|
20161
|
+
ok: false,
|
|
20162
|
+
code: "WORKSPACE_LAUNCH_CONTEXT_REQUIRED",
|
|
20163
|
+
message: abs ? "Directory path is not valid or does not exist" : "Invalid directory path"
|
|
20164
|
+
};
|
|
20165
|
+
}
|
|
20166
|
+
if (a.workspaceId) {
|
|
20167
|
+
const w = (config2.workspaces || []).find((x) => x.id === a.workspaceId);
|
|
20168
|
+
if (w) {
|
|
20169
|
+
const abs = expandPath(w.path);
|
|
20170
|
+
if (validateWorkspacePath(abs).ok === true) {
|
|
20171
|
+
return { ok: true, path: abs, source: "workspaceId" };
|
|
20172
|
+
}
|
|
20173
|
+
}
|
|
20174
|
+
return {
|
|
20175
|
+
ok: false,
|
|
20176
|
+
code: "WORKSPACE_LAUNCH_CONTEXT_REQUIRED",
|
|
20177
|
+
message: "Saved workspace not found or path is no longer valid"
|
|
20178
|
+
};
|
|
20179
|
+
}
|
|
20180
|
+
if (a.useDefaultWorkspace === true) {
|
|
20181
|
+
const d = getDefaultWorkspacePath(config2);
|
|
20182
|
+
if (d) return { ok: true, path: d, source: "defaultWorkspace" };
|
|
20183
|
+
return {
|
|
20184
|
+
ok: false,
|
|
20185
|
+
code: "WORKSPACE_LAUNCH_CONTEXT_REQUIRED",
|
|
20186
|
+
message: "No default workspace is set"
|
|
20187
|
+
};
|
|
20345
20188
|
}
|
|
20189
|
+
if (a.useHome === true) {
|
|
20190
|
+
return { ok: true, path: os2.homedir(), source: "home" };
|
|
20191
|
+
}
|
|
20192
|
+
return {
|
|
20193
|
+
ok: false,
|
|
20194
|
+
code: "WORKSPACE_LAUNCH_CONTEXT_REQUIRED",
|
|
20195
|
+
message: "Choose a directory, saved workspace, default workspace, or home before launching."
|
|
20196
|
+
};
|
|
20346
20197
|
}
|
|
20347
|
-
function
|
|
20348
|
-
const
|
|
20349
|
-
if (
|
|
20350
|
-
|
|
20351
|
-
|
|
20198
|
+
function resolveIdeWorkspaceFromArgs(args, config2) {
|
|
20199
|
+
const ar = args || {};
|
|
20200
|
+
if (ar.workspace) {
|
|
20201
|
+
const abs = expandPath(ar.workspace);
|
|
20202
|
+
if (abs && validateWorkspacePath(abs).ok === true) return abs;
|
|
20203
|
+
}
|
|
20204
|
+
if (ar.workspaceId) {
|
|
20205
|
+
const w = (config2.workspaces || []).find((x) => x.id === ar.workspaceId);
|
|
20206
|
+
if (w) {
|
|
20207
|
+
const abs = expandPath(w.path);
|
|
20208
|
+
if (validateWorkspacePath(abs).ok === true) return abs;
|
|
20209
|
+
}
|
|
20210
|
+
}
|
|
20211
|
+
if (ar.useDefaultWorkspace === true) {
|
|
20212
|
+
return getDefaultWorkspacePath(config2) || void 0;
|
|
20213
|
+
}
|
|
20214
|
+
return void 0;
|
|
20215
|
+
}
|
|
20216
|
+
function resolveIdeLaunchWorkspace(args, config2) {
|
|
20217
|
+
const direct = resolveIdeWorkspaceFromArgs(args, config2);
|
|
20218
|
+
if (direct) return direct;
|
|
20219
|
+
if (args?.useDefaultWorkspace === false) return void 0;
|
|
20220
|
+
return getDefaultWorkspacePath(config2) || void 0;
|
|
20221
|
+
}
|
|
20222
|
+
function findWorkspaceByPath(config2, rawPath) {
|
|
20223
|
+
const abs = path.resolve(expandPath(rawPath));
|
|
20224
|
+
if (!abs) return void 0;
|
|
20225
|
+
return (config2.workspaces || []).find((w) => path.resolve(expandPath(w.path)) === abs);
|
|
20226
|
+
}
|
|
20227
|
+
function addWorkspaceEntry(config2, rawPath, label, options) {
|
|
20228
|
+
const abs = expandPath(rawPath);
|
|
20229
|
+
const createIfMissing = options?.createIfMissing === true;
|
|
20230
|
+
if (!abs) return { error: "Path required" };
|
|
20231
|
+
if (!fs.existsSync(abs) && createIfMissing) {
|
|
20232
|
+
try {
|
|
20233
|
+
fs.mkdirSync(abs, { recursive: true });
|
|
20234
|
+
} catch (e) {
|
|
20235
|
+
return { error: e?.message || "Could not create directory" };
|
|
20236
|
+
}
|
|
20237
|
+
}
|
|
20238
|
+
const v = validateWorkspacePath(abs);
|
|
20239
|
+
if (!v.ok) return { error: v.error };
|
|
20240
|
+
const list = [...config2.workspaces || []];
|
|
20241
|
+
if (list.some((w) => path.resolve(w.path) === abs)) {
|
|
20242
|
+
return { error: "Workspace already in list" };
|
|
20243
|
+
}
|
|
20244
|
+
if (list.length >= MAX_WORKSPACES) {
|
|
20245
|
+
return { error: `Maximum ${MAX_WORKSPACES} workspaces` };
|
|
20246
|
+
}
|
|
20352
20247
|
const entry = {
|
|
20248
|
+
id: (0, import_crypto3.randomUUID)(),
|
|
20353
20249
|
path: abs,
|
|
20354
|
-
|
|
20355
|
-
|
|
20356
|
-
agentType: meta3?.agentType
|
|
20250
|
+
label: (label || "").trim() || defaultWorkspaceLabel(abs),
|
|
20251
|
+
addedAt: Date.now()
|
|
20357
20252
|
};
|
|
20358
|
-
|
|
20359
|
-
return { ...config2,
|
|
20253
|
+
list.push(entry);
|
|
20254
|
+
return { config: { ...config2, workspaces: list }, entry };
|
|
20360
20255
|
}
|
|
20361
|
-
function
|
|
20362
|
-
const list =
|
|
20363
|
-
list.
|
|
20364
|
-
|
|
20256
|
+
function removeWorkspaceEntry(config2, id) {
|
|
20257
|
+
const list = (config2.workspaces || []).filter((w) => w.id !== id);
|
|
20258
|
+
if (list.length === (config2.workspaces || []).length) return { error: "Workspace not found" };
|
|
20259
|
+
let defaultWorkspaceId = config2.defaultWorkspaceId;
|
|
20260
|
+
if (defaultWorkspaceId === id) defaultWorkspaceId = null;
|
|
20261
|
+
return { config: { ...config2, workspaces: list, defaultWorkspaceId } };
|
|
20365
20262
|
}
|
|
20366
|
-
function
|
|
20367
|
-
|
|
20368
|
-
|
|
20369
|
-
|
|
20370
|
-
|
|
20371
|
-
|
|
20372
|
-
|
|
20373
|
-
};
|
|
20263
|
+
function setDefaultWorkspaceId(config2, id) {
|
|
20264
|
+
if (id === null) {
|
|
20265
|
+
return { config: { ...config2, defaultWorkspaceId: null } };
|
|
20266
|
+
}
|
|
20267
|
+
const w = (config2.workspaces || []).find((x) => x.id === id);
|
|
20268
|
+
if (!w) return { error: "Workspace not found" };
|
|
20269
|
+
const abs = expandPath(w.path);
|
|
20270
|
+
if (validateWorkspacePath(abs).ok !== true) return { error: "Workspace path is no longer valid" };
|
|
20271
|
+
return { config: { ...config2, defaultWorkspaceId: id } };
|
|
20374
20272
|
}
|
|
20375
|
-
|
|
20376
|
-
var MAX_ACTIVITY2 = 30;
|
|
20273
|
+
var MAX_ACTIVITY = 30;
|
|
20377
20274
|
function normalizeWorkspace(workspace) {
|
|
20378
20275
|
if (!workspace) return "";
|
|
20379
20276
|
try {
|
|
20380
|
-
return
|
|
20277
|
+
return path22.resolve(expandPath(workspace));
|
|
20381
20278
|
} catch {
|
|
20382
|
-
return
|
|
20279
|
+
return path22.resolve(workspace);
|
|
20383
20280
|
}
|
|
20384
20281
|
}
|
|
20385
20282
|
function buildRecentActivityKey(entry) {
|
|
@@ -20395,24 +20292,33 @@ function appendRecentActivity(config2, entry) {
|
|
|
20395
20292
|
const filtered = (config2.recentActivity || []).filter((item) => item.id !== nextEntry.id);
|
|
20396
20293
|
return {
|
|
20397
20294
|
...config2,
|
|
20398
|
-
recentActivity: [nextEntry, ...filtered].slice(0,
|
|
20295
|
+
recentActivity: [nextEntry, ...filtered].slice(0, MAX_ACTIVITY)
|
|
20399
20296
|
};
|
|
20400
20297
|
}
|
|
20401
20298
|
function getRecentActivity(config2, limit = 20) {
|
|
20402
20299
|
return [...config2.recentActivity || []].sort((a, b) => b.lastUsedAt - a.lastUsedAt).slice(0, limit);
|
|
20403
20300
|
}
|
|
20404
|
-
function
|
|
20405
|
-
return config2.
|
|
20301
|
+
function getSessionSeenAt(config2, sessionId) {
|
|
20302
|
+
return config2.sessionReads?.[sessionId] || 0;
|
|
20406
20303
|
}
|
|
20407
|
-
function
|
|
20408
|
-
|
|
20409
|
-
|
|
20304
|
+
function getSessionSeenMarker(config2, sessionId) {
|
|
20305
|
+
return config2.sessionReadMarkers?.[sessionId] || "";
|
|
20306
|
+
}
|
|
20307
|
+
function markSessionSeen(config2, sessionId, seenAt = Date.now(), completionMarker) {
|
|
20308
|
+
const prev = config2.sessionReads || {};
|
|
20309
|
+
const nextSeenAt = Math.max(prev[sessionId] || 0, seenAt);
|
|
20310
|
+
const prevMarkers = config2.sessionReadMarkers || {};
|
|
20311
|
+
const nextMarker = typeof completionMarker === "string" ? completionMarker : "";
|
|
20410
20312
|
return {
|
|
20411
20313
|
...config2,
|
|
20412
|
-
|
|
20314
|
+
sessionReads: {
|
|
20413
20315
|
...prev,
|
|
20414
|
-
[
|
|
20415
|
-
}
|
|
20316
|
+
[sessionId]: nextSeenAt
|
|
20317
|
+
},
|
|
20318
|
+
sessionReadMarkers: nextMarker ? {
|
|
20319
|
+
...prevMarkers,
|
|
20320
|
+
[sessionId]: nextMarker
|
|
20321
|
+
} : prevMarkers
|
|
20416
20322
|
};
|
|
20417
20323
|
}
|
|
20418
20324
|
var BUILTIN_IDE_DEFINITIONS = [];
|
|
@@ -20514,15 +20420,15 @@ function parseVersion(raw) {
|
|
|
20514
20420
|
return match ? match[1] : raw.split("\n")[0].slice(0, 100);
|
|
20515
20421
|
}
|
|
20516
20422
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
20517
|
-
return new Promise((
|
|
20423
|
+
return new Promise((resolve92) => {
|
|
20518
20424
|
const child = (0, import_child_process3.exec)(cmd, { encoding: "utf-8", timeout: timeoutMs }, (err, stdout) => {
|
|
20519
20425
|
if (err || !stdout?.trim()) {
|
|
20520
|
-
|
|
20426
|
+
resolve92(null);
|
|
20521
20427
|
} else {
|
|
20522
|
-
|
|
20428
|
+
resolve92(stdout.trim());
|
|
20523
20429
|
}
|
|
20524
20430
|
});
|
|
20525
|
-
child.on("error", () =>
|
|
20431
|
+
child.on("error", () => resolve92(null));
|
|
20526
20432
|
});
|
|
20527
20433
|
}
|
|
20528
20434
|
async function detectCLIs(providerLoader) {
|
|
@@ -20681,7 +20587,7 @@ var DaemonCdpManager = class {
|
|
|
20681
20587
|
* Returns multiple entries if multiple IDE windows are open on same port
|
|
20682
20588
|
*/
|
|
20683
20589
|
static listAllTargets(port) {
|
|
20684
|
-
return new Promise((
|
|
20590
|
+
return new Promise((resolve92) => {
|
|
20685
20591
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
20686
20592
|
let data = "";
|
|
20687
20593
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -20697,16 +20603,16 @@ var DaemonCdpManager = class {
|
|
|
20697
20603
|
(t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
|
|
20698
20604
|
);
|
|
20699
20605
|
const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
|
|
20700
|
-
|
|
20606
|
+
resolve92(mainPages.length > 0 ? mainPages : fallbackPages);
|
|
20701
20607
|
} catch {
|
|
20702
|
-
|
|
20608
|
+
resolve92([]);
|
|
20703
20609
|
}
|
|
20704
20610
|
});
|
|
20705
20611
|
});
|
|
20706
|
-
req.on("error", () =>
|
|
20612
|
+
req.on("error", () => resolve92([]));
|
|
20707
20613
|
req.setTimeout(2e3, () => {
|
|
20708
20614
|
req.destroy();
|
|
20709
|
-
|
|
20615
|
+
resolve92([]);
|
|
20710
20616
|
});
|
|
20711
20617
|
});
|
|
20712
20618
|
}
|
|
@@ -20746,7 +20652,7 @@ var DaemonCdpManager = class {
|
|
|
20746
20652
|
}
|
|
20747
20653
|
}
|
|
20748
20654
|
findTargetOnPort(port) {
|
|
20749
|
-
return new Promise((
|
|
20655
|
+
return new Promise((resolve92) => {
|
|
20750
20656
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
20751
20657
|
let data = "";
|
|
20752
20658
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -20757,7 +20663,7 @@ var DaemonCdpManager = class {
|
|
|
20757
20663
|
(t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
|
|
20758
20664
|
);
|
|
20759
20665
|
if (pages.length === 0) {
|
|
20760
|
-
|
|
20666
|
+
resolve92(targets.find((t) => t.webSocketDebuggerUrl) || null);
|
|
20761
20667
|
return;
|
|
20762
20668
|
}
|
|
20763
20669
|
const mainPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
|
|
@@ -20767,24 +20673,24 @@ var DaemonCdpManager = class {
|
|
|
20767
20673
|
const specific = list.find((t) => t.id === this._targetId);
|
|
20768
20674
|
if (specific) {
|
|
20769
20675
|
this._pageTitle = specific.title || "";
|
|
20770
|
-
|
|
20676
|
+
resolve92(specific);
|
|
20771
20677
|
} else {
|
|
20772
20678
|
this.log(`[CDP] Target ${this._targetId} not found in page list`);
|
|
20773
|
-
|
|
20679
|
+
resolve92(null);
|
|
20774
20680
|
}
|
|
20775
20681
|
return;
|
|
20776
20682
|
}
|
|
20777
20683
|
this._pageTitle = list[0]?.title || "";
|
|
20778
|
-
|
|
20684
|
+
resolve92(list[0]);
|
|
20779
20685
|
} catch {
|
|
20780
|
-
|
|
20686
|
+
resolve92(null);
|
|
20781
20687
|
}
|
|
20782
20688
|
});
|
|
20783
20689
|
});
|
|
20784
|
-
req.on("error", () =>
|
|
20690
|
+
req.on("error", () => resolve92(null));
|
|
20785
20691
|
req.setTimeout(2e3, () => {
|
|
20786
20692
|
req.destroy();
|
|
20787
|
-
|
|
20693
|
+
resolve92(null);
|
|
20788
20694
|
});
|
|
20789
20695
|
});
|
|
20790
20696
|
}
|
|
@@ -20795,7 +20701,7 @@ var DaemonCdpManager = class {
|
|
|
20795
20701
|
this.extensionProviders = providers;
|
|
20796
20702
|
}
|
|
20797
20703
|
connectToTarget(wsUrl) {
|
|
20798
|
-
return new Promise((
|
|
20704
|
+
return new Promise((resolve92) => {
|
|
20799
20705
|
this.ws = new import_ws.default(wsUrl);
|
|
20800
20706
|
this.ws.on("open", async () => {
|
|
20801
20707
|
this._connected = true;
|
|
@@ -20805,17 +20711,17 @@ var DaemonCdpManager = class {
|
|
|
20805
20711
|
}
|
|
20806
20712
|
this.connectBrowserWs().catch(() => {
|
|
20807
20713
|
});
|
|
20808
|
-
|
|
20714
|
+
resolve92(true);
|
|
20809
20715
|
});
|
|
20810
20716
|
this.ws.on("message", (data) => {
|
|
20811
20717
|
try {
|
|
20812
20718
|
const msg = JSON.parse(data.toString());
|
|
20813
20719
|
if (msg.id && this.pending.has(msg.id)) {
|
|
20814
|
-
const { resolve:
|
|
20720
|
+
const { resolve: resolve102, reject } = this.pending.get(msg.id);
|
|
20815
20721
|
this.pending.delete(msg.id);
|
|
20816
20722
|
this.failureCount = 0;
|
|
20817
20723
|
if (msg.error) reject(new Error(msg.error.message));
|
|
20818
|
-
else
|
|
20724
|
+
else resolve102(msg.result);
|
|
20819
20725
|
} else if (msg.method === "Runtime.executionContextCreated") {
|
|
20820
20726
|
this.contexts.add(msg.params.context.id);
|
|
20821
20727
|
} else if (msg.method === "Runtime.executionContextDestroyed") {
|
|
@@ -20838,7 +20744,7 @@ var DaemonCdpManager = class {
|
|
|
20838
20744
|
this.ws.on("error", (err) => {
|
|
20839
20745
|
this.log(`[CDP] WebSocket error: ${err.message}`);
|
|
20840
20746
|
this._connected = false;
|
|
20841
|
-
|
|
20747
|
+
resolve92(false);
|
|
20842
20748
|
});
|
|
20843
20749
|
});
|
|
20844
20750
|
}
|
|
@@ -20852,7 +20758,7 @@ var DaemonCdpManager = class {
|
|
|
20852
20758
|
return;
|
|
20853
20759
|
}
|
|
20854
20760
|
this.log(`[CDP] Connecting browser WS for target discovery...`);
|
|
20855
|
-
await new Promise((
|
|
20761
|
+
await new Promise((resolve92, reject) => {
|
|
20856
20762
|
this.browserWs = new import_ws.default(browserWsUrl);
|
|
20857
20763
|
this.browserWs.on("open", async () => {
|
|
20858
20764
|
this._browserConnected = true;
|
|
@@ -20862,16 +20768,16 @@ var DaemonCdpManager = class {
|
|
|
20862
20768
|
} catch (e) {
|
|
20863
20769
|
this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
|
|
20864
20770
|
}
|
|
20865
|
-
|
|
20771
|
+
resolve92();
|
|
20866
20772
|
});
|
|
20867
20773
|
this.browserWs.on("message", (data) => {
|
|
20868
20774
|
try {
|
|
20869
20775
|
const msg = JSON.parse(data.toString());
|
|
20870
20776
|
if (msg.id && this.browserPending.has(msg.id)) {
|
|
20871
|
-
const { resolve:
|
|
20777
|
+
const { resolve: resolve102, reject: reject2 } = this.browserPending.get(msg.id);
|
|
20872
20778
|
this.browserPending.delete(msg.id);
|
|
20873
20779
|
if (msg.error) reject2(new Error(msg.error.message));
|
|
20874
|
-
else
|
|
20780
|
+
else resolve102(msg.result);
|
|
20875
20781
|
}
|
|
20876
20782
|
} catch {
|
|
20877
20783
|
}
|
|
@@ -20891,31 +20797,31 @@ var DaemonCdpManager = class {
|
|
|
20891
20797
|
}
|
|
20892
20798
|
}
|
|
20893
20799
|
getBrowserWsUrl() {
|
|
20894
|
-
return new Promise((
|
|
20800
|
+
return new Promise((resolve92) => {
|
|
20895
20801
|
const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
|
|
20896
20802
|
let data = "";
|
|
20897
20803
|
res.on("data", (chunk) => data += chunk.toString());
|
|
20898
20804
|
res.on("end", () => {
|
|
20899
20805
|
try {
|
|
20900
20806
|
const info = JSON.parse(data);
|
|
20901
|
-
|
|
20807
|
+
resolve92(info.webSocketDebuggerUrl || null);
|
|
20902
20808
|
} catch {
|
|
20903
|
-
|
|
20809
|
+
resolve92(null);
|
|
20904
20810
|
}
|
|
20905
20811
|
});
|
|
20906
20812
|
});
|
|
20907
|
-
req.on("error", () =>
|
|
20813
|
+
req.on("error", () => resolve92(null));
|
|
20908
20814
|
req.setTimeout(3e3, () => {
|
|
20909
20815
|
req.destroy();
|
|
20910
|
-
|
|
20816
|
+
resolve92(null);
|
|
20911
20817
|
});
|
|
20912
20818
|
});
|
|
20913
20819
|
}
|
|
20914
20820
|
sendBrowser(method, params = {}, timeoutMs = 15e3) {
|
|
20915
|
-
return new Promise((
|
|
20821
|
+
return new Promise((resolve92, reject) => {
|
|
20916
20822
|
if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
|
|
20917
20823
|
const id = this.browserMsgId++;
|
|
20918
|
-
this.browserPending.set(id, { resolve:
|
|
20824
|
+
this.browserPending.set(id, { resolve: resolve92, reject });
|
|
20919
20825
|
this.browserWs.send(JSON.stringify({ id, method, params }));
|
|
20920
20826
|
setTimeout(() => {
|
|
20921
20827
|
if (this.browserPending.has(id)) {
|
|
@@ -20955,11 +20861,11 @@ var DaemonCdpManager = class {
|
|
|
20955
20861
|
}
|
|
20956
20862
|
// ─── CDP Protocol ────────────────────────────────────────
|
|
20957
20863
|
sendInternal(method, params = {}, timeoutMs = 15e3) {
|
|
20958
|
-
return new Promise((
|
|
20864
|
+
return new Promise((resolve92, reject) => {
|
|
20959
20865
|
if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
|
|
20960
20866
|
if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
|
|
20961
20867
|
const id = this.msgId++;
|
|
20962
|
-
this.pending.set(id, { resolve:
|
|
20868
|
+
this.pending.set(id, { resolve: resolve92, reject });
|
|
20963
20869
|
this.ws.send(JSON.stringify({ id, method, params }));
|
|
20964
20870
|
setTimeout(() => {
|
|
20965
20871
|
if (this.pending.has(id)) {
|
|
@@ -21208,7 +21114,7 @@ var DaemonCdpManager = class {
|
|
|
21208
21114
|
const browserWs = this.browserWs;
|
|
21209
21115
|
let msgId = this.browserMsgId;
|
|
21210
21116
|
const sendWs = (method, params = {}, sessionId) => {
|
|
21211
|
-
return new Promise((
|
|
21117
|
+
return new Promise((resolve92, reject) => {
|
|
21212
21118
|
const mid = msgId++;
|
|
21213
21119
|
this.browserMsgId = msgId;
|
|
21214
21120
|
const handler = (raw) => {
|
|
@@ -21217,7 +21123,7 @@ var DaemonCdpManager = class {
|
|
|
21217
21123
|
if (msg.id === mid) {
|
|
21218
21124
|
browserWs.removeListener("message", handler);
|
|
21219
21125
|
if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
|
|
21220
|
-
else
|
|
21126
|
+
else resolve92(msg.result);
|
|
21221
21127
|
}
|
|
21222
21128
|
} catch {
|
|
21223
21129
|
}
|
|
@@ -21408,14 +21314,14 @@ var DaemonCdpManager = class {
|
|
|
21408
21314
|
if (!ws || ws.readyState !== import_ws.default.OPEN) {
|
|
21409
21315
|
throw new Error("CDP not connected");
|
|
21410
21316
|
}
|
|
21411
|
-
return new Promise((
|
|
21317
|
+
return new Promise((resolve92, reject) => {
|
|
21412
21318
|
const id = getNextId();
|
|
21413
21319
|
pendingMap.set(id, {
|
|
21414
21320
|
resolve: (result) => {
|
|
21415
21321
|
if (result?.result?.subtype === "error") {
|
|
21416
21322
|
reject(new Error(result.result.description));
|
|
21417
21323
|
} else {
|
|
21418
|
-
|
|
21324
|
+
resolve92(result?.result?.value);
|
|
21419
21325
|
}
|
|
21420
21326
|
},
|
|
21421
21327
|
reject
|
|
@@ -21447,10 +21353,10 @@ var DaemonCdpManager = class {
|
|
|
21447
21353
|
throw new Error("CDP not connected");
|
|
21448
21354
|
}
|
|
21449
21355
|
const sendViaSession = (method, params = {}) => {
|
|
21450
|
-
return new Promise((
|
|
21356
|
+
return new Promise((resolve92, reject) => {
|
|
21451
21357
|
const pendingMap = this._browserConnected ? this.browserPending : this.pending;
|
|
21452
21358
|
const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
|
|
21453
|
-
pendingMap.set(id, { resolve:
|
|
21359
|
+
pendingMap.set(id, { resolve: resolve92, reject });
|
|
21454
21360
|
ws.send(JSON.stringify({ id, sessionId, method, params }));
|
|
21455
21361
|
setTimeout(() => {
|
|
21456
21362
|
if (pendingMap.has(id)) {
|
|
@@ -22145,7 +22051,7 @@ var ExtensionProviderInstance = class {
|
|
|
22145
22051
|
return title || this.agentName || this.provider.name;
|
|
22146
22052
|
}
|
|
22147
22053
|
};
|
|
22148
|
-
var HISTORY_DIR =
|
|
22054
|
+
var HISTORY_DIR = path4.join(os5.homedir(), ".adhdev", "history");
|
|
22149
22055
|
var RETAIN_DAYS = 30;
|
|
22150
22056
|
var ChatHistoryWriter = class {
|
|
22151
22057
|
/** Last seen message count per agent (deduplication) */
|
|
@@ -22188,11 +22094,11 @@ var ChatHistoryWriter = class {
|
|
|
22188
22094
|
});
|
|
22189
22095
|
}
|
|
22190
22096
|
if (newMessages.length === 0) return;
|
|
22191
|
-
const dir =
|
|
22097
|
+
const dir = path4.join(HISTORY_DIR, this.sanitize(agentType));
|
|
22192
22098
|
fs3.mkdirSync(dir, { recursive: true });
|
|
22193
22099
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
22194
22100
|
const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
|
|
22195
|
-
const filePath =
|
|
22101
|
+
const filePath = path4.join(dir, `${filePrefix}${date5}.jsonl`);
|
|
22196
22102
|
const lines = newMessages.map((m) => JSON.stringify(m)).join("\n") + "\n";
|
|
22197
22103
|
fs3.appendFileSync(filePath, lines, "utf-8");
|
|
22198
22104
|
const prevCount = this.lastSeenCounts.get(dedupKey) || 0;
|
|
@@ -22236,11 +22142,11 @@ ${next}`;
|
|
|
22236
22142
|
this.lastSeenTerminal.set(dedupKey, next);
|
|
22237
22143
|
return;
|
|
22238
22144
|
}
|
|
22239
|
-
const dir =
|
|
22145
|
+
const dir = path4.join(HISTORY_DIR, this.sanitize(agentType));
|
|
22240
22146
|
fs3.mkdirSync(dir, { recursive: true });
|
|
22241
22147
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
22242
22148
|
const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
|
|
22243
|
-
const filePath =
|
|
22149
|
+
const filePath = path4.join(dir, `${filePrefix}${date5}.terminal.log`);
|
|
22244
22150
|
fs3.appendFileSync(filePath, delta, "utf-8");
|
|
22245
22151
|
this.lastSeenTerminal.set(dedupKey, next);
|
|
22246
22152
|
if (!this.rotated) {
|
|
@@ -22264,10 +22170,10 @@ ${next}`;
|
|
|
22264
22170
|
const cutoff = Date.now() - RETAIN_DAYS * 24 * 60 * 60 * 1e3;
|
|
22265
22171
|
const agentDirs = fs3.readdirSync(HISTORY_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
22266
22172
|
for (const dir of agentDirs) {
|
|
22267
|
-
const dirPath =
|
|
22173
|
+
const dirPath = path4.join(HISTORY_DIR, dir.name);
|
|
22268
22174
|
const files = fs3.readdirSync(dirPath).filter((f) => f.endsWith(".jsonl") || f.endsWith(".terminal.log"));
|
|
22269
22175
|
for (const file2 of files) {
|
|
22270
|
-
const filePath =
|
|
22176
|
+
const filePath = path4.join(dirPath, file2);
|
|
22271
22177
|
const stat4 = fs3.statSync(filePath);
|
|
22272
22178
|
if (stat4.mtimeMs < cutoff) {
|
|
22273
22179
|
fs3.unlinkSync(filePath);
|
|
@@ -22285,7 +22191,7 @@ ${next}`;
|
|
|
22285
22191
|
function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
|
|
22286
22192
|
try {
|
|
22287
22193
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
22288
|
-
const dir =
|
|
22194
|
+
const dir = path4.join(HISTORY_DIR, sanitized);
|
|
22289
22195
|
if (!fs3.existsSync(dir)) return { messages: [], hasMore: false };
|
|
22290
22196
|
const sanitizedInstance = instanceId?.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
22291
22197
|
const files = fs3.readdirSync(dir).filter((f) => {
|
|
@@ -22299,7 +22205,7 @@ function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
|
|
|
22299
22205
|
const needed = offset + limit + 1;
|
|
22300
22206
|
for (const file2 of files) {
|
|
22301
22207
|
if (allMessages.length >= needed) break;
|
|
22302
|
-
const filePath =
|
|
22208
|
+
const filePath = path4.join(dir, file2);
|
|
22303
22209
|
const content = fs3.readFileSync(filePath, "utf-8");
|
|
22304
22210
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
22305
22211
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
@@ -23189,9 +23095,16 @@ function buildSessionEntries(allStates, cdpManagers) {
|
|
|
23189
23095
|
for (const state of acpStates) {
|
|
23190
23096
|
sessions.push(buildAcpSession(state));
|
|
23191
23097
|
}
|
|
23098
|
+
const extensionParentIds = new Set(
|
|
23099
|
+
sessions.filter((session) => session.transport === "cdp-webview" && !!session.parentId).map((session) => session.parentId)
|
|
23100
|
+
);
|
|
23101
|
+
for (const session of sessions) {
|
|
23102
|
+
if (session.transport === "cdp-page" && extensionParentIds.has(session.id)) {
|
|
23103
|
+
session.surfaceHidden = true;
|
|
23104
|
+
}
|
|
23105
|
+
}
|
|
23192
23106
|
return sessions;
|
|
23193
23107
|
}
|
|
23194
|
-
init_config();
|
|
23195
23108
|
init_logger();
|
|
23196
23109
|
init_logger();
|
|
23197
23110
|
var RECENT_SEND_WINDOW_MS = 1200;
|
|
@@ -24240,11 +24153,11 @@ function resolveSafePath(requestedPath) {
|
|
|
24240
24153
|
const home = os6.homedir();
|
|
24241
24154
|
let resolved;
|
|
24242
24155
|
if (requestedPath.startsWith("~")) {
|
|
24243
|
-
resolved =
|
|
24244
|
-
} else if (
|
|
24156
|
+
resolved = path5.join(home, requestedPath.slice(1));
|
|
24157
|
+
} else if (path5.isAbsolute(requestedPath)) {
|
|
24245
24158
|
resolved = requestedPath;
|
|
24246
24159
|
} else {
|
|
24247
|
-
resolved =
|
|
24160
|
+
resolved = path5.resolve(requestedPath);
|
|
24248
24161
|
}
|
|
24249
24162
|
return resolved;
|
|
24250
24163
|
}
|
|
@@ -24260,7 +24173,7 @@ async function handleFileRead(h, args) {
|
|
|
24260
24173
|
async function handleFileWrite(h, args) {
|
|
24261
24174
|
try {
|
|
24262
24175
|
const filePath = resolveSafePath(args?.path);
|
|
24263
|
-
fs4.mkdirSync(
|
|
24176
|
+
fs4.mkdirSync(path5.dirname(filePath), { recursive: true });
|
|
24264
24177
|
fs4.writeFileSync(filePath, args?.content || "", "utf-8");
|
|
24265
24178
|
return { success: true, path: filePath };
|
|
24266
24179
|
} catch (e) {
|
|
@@ -24274,7 +24187,7 @@ async function handleFileList(h, args) {
|
|
|
24274
24187
|
const files = entries.map((e) => ({
|
|
24275
24188
|
name: e.name,
|
|
24276
24189
|
type: e.isDirectory() ? "directory" : "file",
|
|
24277
|
-
size: e.isFile() ? fs4.statSync(
|
|
24190
|
+
size: e.isFile() ? fs4.statSync(path5.join(dirPath, e.name)).size : void 0
|
|
24278
24191
|
}));
|
|
24279
24192
|
return { success: true, files, path: dirPath };
|
|
24280
24193
|
} catch (e) {
|
|
@@ -24284,7 +24197,6 @@ async function handleFileList(h, args) {
|
|
|
24284
24197
|
async function handleFileListBrowse(h, args) {
|
|
24285
24198
|
return handleFileList(h, args);
|
|
24286
24199
|
}
|
|
24287
|
-
init_config();
|
|
24288
24200
|
init_logger();
|
|
24289
24201
|
async function handleFocusSession(h, args) {
|
|
24290
24202
|
if (!h.agentStream || !h.getCdp()) return { success: false, error: "AgentStream or CDP not available" };
|
|
@@ -24438,13 +24350,12 @@ function handleGetIdeExtensions(h, args) {
|
|
|
24438
24350
|
const loader = h.ctx.providerLoader;
|
|
24439
24351
|
if (!loader) return { success: false, error: "ProviderLoader not initialized" };
|
|
24440
24352
|
const allExtProviders = loader.getByCategory?.("extension") || [];
|
|
24441
|
-
const config2 = loadConfig();
|
|
24442
24353
|
if (ideType) {
|
|
24443
24354
|
const extensions = allExtProviders.map((p) => ({
|
|
24444
24355
|
type: p.type,
|
|
24445
24356
|
name: p.name,
|
|
24446
24357
|
extensionId: p.extensionId,
|
|
24447
|
-
enabled:
|
|
24358
|
+
enabled: loader.getIdeExtensionEnabledState?.(ideType, p.type) === true
|
|
24448
24359
|
}));
|
|
24449
24360
|
return { success: true, ideType, extensions };
|
|
24450
24361
|
}
|
|
@@ -24455,7 +24366,7 @@ function handleGetIdeExtensions(h, args) {
|
|
|
24455
24366
|
type: p.type,
|
|
24456
24367
|
name: p.name,
|
|
24457
24368
|
extensionId: p.extensionId,
|
|
24458
|
-
enabled:
|
|
24369
|
+
enabled: loader.getIdeExtensionEnabledState?.(ide, p.type) === true
|
|
24459
24370
|
}));
|
|
24460
24371
|
}
|
|
24461
24372
|
return { success: true, ideExtensions: result };
|
|
@@ -24476,7 +24387,6 @@ function handleSetIdeExtension(h, args) {
|
|
|
24476
24387
|
return { success: false, error: "Failed to save setting" };
|
|
24477
24388
|
}
|
|
24478
24389
|
init_config();
|
|
24479
|
-
init_workspaces();
|
|
24480
24390
|
function handleWorkspaceList() {
|
|
24481
24391
|
const config2 = loadConfig();
|
|
24482
24392
|
const state = getWorkspaceState(config2);
|
|
@@ -24484,9 +24394,7 @@ function handleWorkspaceList() {
|
|
|
24484
24394
|
success: true,
|
|
24485
24395
|
workspaces: state.workspaces,
|
|
24486
24396
|
defaultWorkspaceId: state.defaultWorkspaceId,
|
|
24487
|
-
defaultWorkspacePath: state.defaultWorkspacePath
|
|
24488
|
-
legacyRecentPaths: config2.recentCliWorkspaces || [],
|
|
24489
|
-
activity: getWorkspaceActivity(config2, 25)
|
|
24397
|
+
defaultWorkspacePath: state.defaultWorkspacePath
|
|
24490
24398
|
};
|
|
24491
24399
|
}
|
|
24492
24400
|
function handleWorkspaceAdd(args) {
|
|
@@ -24497,10 +24405,9 @@ function handleWorkspaceAdd(args) {
|
|
|
24497
24405
|
const config2 = loadConfig();
|
|
24498
24406
|
const result = addWorkspaceEntry(config2, rawPath, label, { createIfMissing });
|
|
24499
24407
|
if ("error" in result) return { success: false, error: result.error };
|
|
24500
|
-
|
|
24501
|
-
|
|
24502
|
-
|
|
24503
|
-
return { success: true, entry: result.entry, ...state, activity: getWorkspaceActivity(cfg, 25) };
|
|
24408
|
+
saveConfig(result.config);
|
|
24409
|
+
const state = getWorkspaceState(result.config);
|
|
24410
|
+
return { success: true, entry: result.entry, ...state };
|
|
24504
24411
|
}
|
|
24505
24412
|
function handleWorkspaceRemove(args) {
|
|
24506
24413
|
const id = (args?.id || "").trim();
|
|
@@ -24509,13 +24416,9 @@ function handleWorkspaceRemove(args) {
|
|
|
24509
24416
|
const removed = (config2.workspaces || []).find((w) => w.id === id);
|
|
24510
24417
|
const result = removeWorkspaceEntry(config2, id);
|
|
24511
24418
|
if ("error" in result) return { success: false, error: result.error };
|
|
24512
|
-
|
|
24513
|
-
|
|
24514
|
-
|
|
24515
|
-
}
|
|
24516
|
-
saveConfig(cfg);
|
|
24517
|
-
const state = getWorkspaceState(cfg);
|
|
24518
|
-
return { success: true, removedId: id, ...state, activity: getWorkspaceActivity(cfg, 25) };
|
|
24419
|
+
saveConfig(result.config);
|
|
24420
|
+
const state = getWorkspaceState(result.config);
|
|
24421
|
+
return { success: true, removedId: id, ...state };
|
|
24519
24422
|
}
|
|
24520
24423
|
function handleWorkspaceSetDefault(args) {
|
|
24521
24424
|
const clear = args?.clear === true || args?.id === null || args?.id === "";
|
|
@@ -24527,8 +24430,7 @@ function handleWorkspaceSetDefault(args) {
|
|
|
24527
24430
|
const state2 = getWorkspaceState(result2.config);
|
|
24528
24431
|
return {
|
|
24529
24432
|
success: true,
|
|
24530
|
-
...state2
|
|
24531
|
-
activity: getWorkspaceActivity(result2.config, 25)
|
|
24433
|
+
...state2
|
|
24532
24434
|
};
|
|
24533
24435
|
}
|
|
24534
24436
|
const pathArg = args?.path != null && String(args.path).trim() ? String(args.path).trim() : "";
|
|
@@ -24552,16 +24454,10 @@ function handleWorkspaceSetDefault(args) {
|
|
|
24552
24454
|
}
|
|
24553
24455
|
const result = setDefaultWorkspaceId(config2, nextId);
|
|
24554
24456
|
if ("error" in result) return { success: false, error: result.error };
|
|
24555
|
-
|
|
24556
|
-
const
|
|
24557
|
-
|
|
24558
|
-
out = appendWorkspaceActivity(out, ap, { kind: "default" });
|
|
24559
|
-
}
|
|
24560
|
-
saveConfig(out);
|
|
24561
|
-
const state = getWorkspaceState(out);
|
|
24562
|
-
return { success: true, ...state, activity: getWorkspaceActivity(out, 25) };
|
|
24457
|
+
saveConfig(result.config);
|
|
24458
|
+
const state = getWorkspaceState(result.config);
|
|
24459
|
+
return { success: true, ...state };
|
|
24563
24460
|
}
|
|
24564
|
-
init_workspaces();
|
|
24565
24461
|
var COMMAND_DEBUG_LEVELS = /* @__PURE__ */ new Set([
|
|
24566
24462
|
"pty_input",
|
|
24567
24463
|
"pty_resize",
|
|
@@ -24888,22 +24784,7 @@ var DaemonCommandHandler = class {
|
|
|
24888
24784
|
return handleFileList(this, args);
|
|
24889
24785
|
case "file_list_browse":
|
|
24890
24786
|
return handleFileListBrowse(this, args);
|
|
24891
|
-
// ─── VSCode API commands (not available) ────
|
|
24892
|
-
case "vscode_command_exec":
|
|
24893
|
-
case "execute_vscode_command": {
|
|
24894
|
-
const resolvedCmd = args?.commandId || args?.command;
|
|
24895
|
-
if (resolvedCmd === "adhdev.captureCdpScreenshot") {
|
|
24896
|
-
return handleScreenshot(this, args);
|
|
24897
|
-
}
|
|
24898
|
-
return { success: false, error: `VSCode command not available: ${resolvedCmd || cmd}` };
|
|
24899
|
-
}
|
|
24900
24787
|
// ─── Workspace cmds ──────────────
|
|
24901
|
-
case "get_recent_workspaces":
|
|
24902
|
-
return this.handleGetRecentWorkspaces(args);
|
|
24903
|
-
case "get_cli_history": {
|
|
24904
|
-
const config2 = loadConfig();
|
|
24905
|
-
return { success: true, history: config2.cliHistory || [] };
|
|
24906
|
-
}
|
|
24907
24788
|
case "workspace_list":
|
|
24908
24789
|
return handleWorkspaceList();
|
|
24909
24790
|
case "workspace_add":
|
|
@@ -24911,7 +24792,6 @@ var DaemonCommandHandler = class {
|
|
|
24911
24792
|
case "workspace_remove":
|
|
24912
24793
|
return handleWorkspaceRemove(args);
|
|
24913
24794
|
case "workspace_set_default":
|
|
24914
|
-
case "workspace_set_active":
|
|
24915
24795
|
return handleWorkspaceSetDefault(args);
|
|
24916
24796
|
// ─── Script manage ───────────────────
|
|
24917
24797
|
case "refresh_scripts":
|
|
@@ -24957,19 +24837,6 @@ var DaemonCommandHandler = class {
|
|
|
24957
24837
|
}
|
|
24958
24838
|
}
|
|
24959
24839
|
// ─── Misc (kept in handler — too small to extract) ───────
|
|
24960
|
-
async handleGetRecentWorkspaces(_args) {
|
|
24961
|
-
const config2 = loadConfig();
|
|
24962
|
-
const cliRecent = config2.recentCliWorkspaces || [];
|
|
24963
|
-
const ws = getWorkspaceState(config2);
|
|
24964
|
-
return {
|
|
24965
|
-
success: true,
|
|
24966
|
-
result: cliRecent,
|
|
24967
|
-
workspaces: ws.workspaces,
|
|
24968
|
-
defaultWorkspaceId: ws.defaultWorkspaceId,
|
|
24969
|
-
defaultWorkspacePath: ws.defaultWorkspacePath,
|
|
24970
|
-
activity: getWorkspaceActivity(config2, 25)
|
|
24971
|
-
};
|
|
24972
|
-
}
|
|
24973
24840
|
async handleRefreshScripts(_args) {
|
|
24974
24841
|
if (this._ctx.providerLoader) {
|
|
24975
24842
|
await this._ctx.providerLoader.fetchLatest().catch(() => {
|
|
@@ -24987,7 +24854,7 @@ var DaemonCommandHandler = class {
|
|
|
24987
24854
|
try {
|
|
24988
24855
|
const http3 = await import("http");
|
|
24989
24856
|
const postData = JSON.stringify(body);
|
|
24990
|
-
const result = await new Promise((
|
|
24857
|
+
const result = await new Promise((resolve92, reject) => {
|
|
24991
24858
|
const req = http3.request({
|
|
24992
24859
|
hostname: "127.0.0.1",
|
|
24993
24860
|
port: 19280,
|
|
@@ -24999,9 +24866,9 @@ var DaemonCommandHandler = class {
|
|
|
24999
24866
|
res.on("data", (chunk) => data += chunk);
|
|
25000
24867
|
res.on("end", () => {
|
|
25001
24868
|
try {
|
|
25002
|
-
|
|
24869
|
+
resolve92(JSON.parse(data));
|
|
25003
24870
|
} catch {
|
|
25004
|
-
|
|
24871
|
+
resolve92({ raw: data });
|
|
25005
24872
|
}
|
|
25006
24873
|
});
|
|
25007
24874
|
});
|
|
@@ -25019,15 +24886,15 @@ var DaemonCommandHandler = class {
|
|
|
25019
24886
|
if (!providerType) return { success: false, error: "providerType required" };
|
|
25020
24887
|
try {
|
|
25021
24888
|
const http3 = await import("http");
|
|
25022
|
-
const result = await new Promise((
|
|
24889
|
+
const result = await new Promise((resolve92, reject) => {
|
|
25023
24890
|
http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
|
|
25024
24891
|
let data = "";
|
|
25025
24892
|
res.on("data", (chunk) => data += chunk);
|
|
25026
24893
|
res.on("end", () => {
|
|
25027
24894
|
try {
|
|
25028
|
-
|
|
24895
|
+
resolve92(JSON.parse(data));
|
|
25029
24896
|
} catch {
|
|
25030
|
-
|
|
24897
|
+
resolve92({ raw: data });
|
|
25031
24898
|
}
|
|
25032
24899
|
});
|
|
25033
24900
|
}).on("error", reject);
|
|
@@ -25041,7 +24908,7 @@ var DaemonCommandHandler = class {
|
|
|
25041
24908
|
try {
|
|
25042
24909
|
const http3 = await import("http");
|
|
25043
24910
|
const postData = JSON.stringify(args || {});
|
|
25044
|
-
const result = await new Promise((
|
|
24911
|
+
const result = await new Promise((resolve92, reject) => {
|
|
25045
24912
|
const req = http3.request({
|
|
25046
24913
|
hostname: "127.0.0.1",
|
|
25047
24914
|
port: 19280,
|
|
@@ -25053,9 +24920,9 @@ var DaemonCommandHandler = class {
|
|
|
25053
24920
|
res.on("data", (chunk) => data += chunk);
|
|
25054
24921
|
res.on("end", () => {
|
|
25055
24922
|
try {
|
|
25056
|
-
|
|
24923
|
+
resolve92(JSON.parse(data));
|
|
25057
24924
|
} catch {
|
|
25058
|
-
|
|
24925
|
+
resolve92({ raw: data });
|
|
25059
24926
|
}
|
|
25060
24927
|
});
|
|
25061
24928
|
});
|
|
@@ -25087,12 +24954,12 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25087
24954
|
static META_FILE = ".meta.json";
|
|
25088
24955
|
constructor(options) {
|
|
25089
24956
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
25090
|
-
const defaultProvidersDir =
|
|
24957
|
+
const defaultProvidersDir = path6.join(os7.homedir(), ".adhdev", "providers");
|
|
25091
24958
|
if (options?.userDir) {
|
|
25092
24959
|
this.userDir = options.userDir;
|
|
25093
24960
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
25094
24961
|
} else {
|
|
25095
|
-
const localRepoPath =
|
|
24962
|
+
const localRepoPath = path6.resolve(__dirname, "../../../../../adhdev-providers");
|
|
25096
24963
|
if (fs5.existsSync(localRepoPath)) {
|
|
25097
24964
|
this.userDir = localRepoPath;
|
|
25098
24965
|
this.log(`Auto-detected local public repository: ${this.userDir} (Dev workspace speedup)`);
|
|
@@ -25101,7 +24968,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25101
24968
|
this.log(`Using default user providers directory: ${this.userDir}`);
|
|
25102
24969
|
}
|
|
25103
24970
|
}
|
|
25104
|
-
this.upstreamDir =
|
|
24971
|
+
this.upstreamDir = path6.join(defaultProvidersDir, ".upstream");
|
|
25105
24972
|
this.disableUpstream = options?.disableUpstream ?? false;
|
|
25106
24973
|
}
|
|
25107
24974
|
log(msg) {
|
|
@@ -25131,7 +24998,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25131
24998
|
* Canonical provider directory shape for a given root.
|
|
25132
24999
|
*/
|
|
25133
25000
|
getProviderDir(root, category, type) {
|
|
25134
|
-
return
|
|
25001
|
+
return path6.join(root, category, type);
|
|
25135
25002
|
}
|
|
25136
25003
|
/**
|
|
25137
25004
|
* Canonical user override directory for a provider.
|
|
@@ -25158,7 +25025,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25158
25025
|
resolveProviderFile(type, ...segments) {
|
|
25159
25026
|
const dir = this.findProviderDirInternal(type);
|
|
25160
25027
|
if (!dir) return null;
|
|
25161
|
-
return
|
|
25028
|
+
return path6.join(dir, ...segments);
|
|
25162
25029
|
}
|
|
25163
25030
|
/**
|
|
25164
25031
|
* Load all providers (3-tier priority)
|
|
@@ -25196,7 +25063,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25196
25063
|
if (!fs5.existsSync(this.upstreamDir)) return false;
|
|
25197
25064
|
try {
|
|
25198
25065
|
return fs5.readdirSync(this.upstreamDir).some(
|
|
25199
|
-
(d) => fs5.statSync(
|
|
25066
|
+
(d) => fs5.statSync(path6.join(this.upstreamDir, d)).isDirectory()
|
|
25200
25067
|
);
|
|
25201
25068
|
} catch {
|
|
25202
25069
|
return false;
|
|
@@ -25281,16 +25148,23 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25281
25148
|
isEnabled(type, ideType) {
|
|
25282
25149
|
if (!ideType) return true;
|
|
25283
25150
|
try {
|
|
25284
|
-
|
|
25285
|
-
const config2 = loadConfig2();
|
|
25286
|
-
const baseIdeType = ideType.split("_")[0];
|
|
25287
|
-
const val = config2.ideSettings?.[baseIdeType]?.extensions?.[type]?.enabled;
|
|
25288
|
-
return val === true;
|
|
25151
|
+
return this.getIdeExtensionEnabledState(ideType, type);
|
|
25289
25152
|
} catch {
|
|
25290
25153
|
return false;
|
|
25291
25154
|
}
|
|
25292
25155
|
}
|
|
25293
25156
|
/**
|
|
25157
|
+
* Resolve per-IDE extension enabled state using the same normalization
|
|
25158
|
+
* that runtime attach/remove uses.
|
|
25159
|
+
*/
|
|
25160
|
+
getIdeExtensionEnabledState(ideType, extensionType) {
|
|
25161
|
+
const { loadConfig: loadConfig2 } = (init_config(), __toCommonJS(config_exports));
|
|
25162
|
+
const config2 = loadConfig2();
|
|
25163
|
+
const baseIdeType = ideType.split("_")[0];
|
|
25164
|
+
const val = config2.ideSettings?.[baseIdeType]?.extensions?.[extensionType]?.enabled;
|
|
25165
|
+
return val === true;
|
|
25166
|
+
}
|
|
25167
|
+
/**
|
|
25294
25168
|
* Save IDE extension enabled setting
|
|
25295
25169
|
*/
|
|
25296
25170
|
setIdeExtensionEnabled(ideType, extensionType, enabled) {
|
|
@@ -25488,14 +25362,14 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25488
25362
|
this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
|
|
25489
25363
|
return null;
|
|
25490
25364
|
}
|
|
25491
|
-
const dir =
|
|
25365
|
+
const dir = path6.join(providerDir, scriptDir);
|
|
25492
25366
|
if (!fs5.existsSync(dir)) {
|
|
25493
25367
|
this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
25494
25368
|
return null;
|
|
25495
25369
|
}
|
|
25496
25370
|
const cached2 = this.scriptsCache.get(dir);
|
|
25497
25371
|
if (cached2) return cached2;
|
|
25498
|
-
const scriptsJs =
|
|
25372
|
+
const scriptsJs = path6.join(dir, "scripts.js");
|
|
25499
25373
|
if (fs5.existsSync(scriptsJs)) {
|
|
25500
25374
|
try {
|
|
25501
25375
|
delete __require.cache[__require.resolve(scriptsJs)];
|
|
@@ -25534,7 +25408,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25534
25408
|
});
|
|
25535
25409
|
const handleChange = (filePath) => {
|
|
25536
25410
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
25537
|
-
this.log(`File changed: ${
|
|
25411
|
+
this.log(`File changed: ${path6.basename(filePath)}, reloading...`);
|
|
25538
25412
|
this.reload();
|
|
25539
25413
|
}
|
|
25540
25414
|
};
|
|
@@ -25589,7 +25463,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25589
25463
|
}
|
|
25590
25464
|
const https = __require("https");
|
|
25591
25465
|
const { execSync: execSync7 } = __require("child_process");
|
|
25592
|
-
const metaPath =
|
|
25466
|
+
const metaPath = path6.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
25593
25467
|
let prevEtag = "";
|
|
25594
25468
|
let prevTimestamp = 0;
|
|
25595
25469
|
try {
|
|
@@ -25606,7 +25480,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25606
25480
|
return { updated: false };
|
|
25607
25481
|
}
|
|
25608
25482
|
try {
|
|
25609
|
-
const etag = await new Promise((
|
|
25483
|
+
const etag = await new Promise((resolve92, reject) => {
|
|
25610
25484
|
const options = {
|
|
25611
25485
|
method: "HEAD",
|
|
25612
25486
|
hostname: "github.com",
|
|
@@ -25624,7 +25498,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25624
25498
|
headers: { "User-Agent": "adhdev-launcher" },
|
|
25625
25499
|
timeout: 1e4
|
|
25626
25500
|
}, (res2) => {
|
|
25627
|
-
|
|
25501
|
+
resolve92(res2.headers.etag || res2.headers["last-modified"] || "");
|
|
25628
25502
|
});
|
|
25629
25503
|
req2.on("error", reject);
|
|
25630
25504
|
req2.on("timeout", () => {
|
|
@@ -25633,7 +25507,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25633
25507
|
});
|
|
25634
25508
|
req2.end();
|
|
25635
25509
|
} else {
|
|
25636
|
-
|
|
25510
|
+
resolve92(res.headers.etag || res.headers["last-modified"] || "");
|
|
25637
25511
|
}
|
|
25638
25512
|
});
|
|
25639
25513
|
req.on("error", reject);
|
|
@@ -25649,17 +25523,17 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25649
25523
|
return { updated: false };
|
|
25650
25524
|
}
|
|
25651
25525
|
this.log("Downloading latest providers from GitHub...");
|
|
25652
|
-
const tmpTar =
|
|
25653
|
-
const tmpExtract =
|
|
25526
|
+
const tmpTar = path6.join(os7.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
25527
|
+
const tmpExtract = path6.join(os7.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
25654
25528
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
25655
25529
|
fs5.mkdirSync(tmpExtract, { recursive: true });
|
|
25656
25530
|
execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
25657
25531
|
const extracted = fs5.readdirSync(tmpExtract);
|
|
25658
25532
|
const rootDir = extracted.find(
|
|
25659
|
-
(d) => fs5.statSync(
|
|
25533
|
+
(d) => fs5.statSync(path6.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
25660
25534
|
);
|
|
25661
25535
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
25662
|
-
const sourceDir =
|
|
25536
|
+
const sourceDir = path6.join(tmpExtract, rootDir);
|
|
25663
25537
|
const backupDir = this.upstreamDir + ".bak";
|
|
25664
25538
|
if (fs5.existsSync(this.upstreamDir)) {
|
|
25665
25539
|
if (fs5.existsSync(backupDir)) fs5.rmSync(backupDir, { recursive: true, force: true });
|
|
@@ -25697,7 +25571,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25697
25571
|
downloadFile(url2, destPath) {
|
|
25698
25572
|
const https = __require("https");
|
|
25699
25573
|
const http3 = __require("http");
|
|
25700
|
-
return new Promise((
|
|
25574
|
+
return new Promise((resolve92, reject) => {
|
|
25701
25575
|
const doRequest = (reqUrl, redirectCount = 0) => {
|
|
25702
25576
|
if (redirectCount > 5) {
|
|
25703
25577
|
reject(new Error("Too many redirects"));
|
|
@@ -25717,7 +25591,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25717
25591
|
res.pipe(ws);
|
|
25718
25592
|
ws.on("finish", () => {
|
|
25719
25593
|
ws.close();
|
|
25720
|
-
|
|
25594
|
+
resolve92();
|
|
25721
25595
|
});
|
|
25722
25596
|
ws.on("error", reject);
|
|
25723
25597
|
});
|
|
@@ -25734,8 +25608,8 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25734
25608
|
copyDirRecursive(src, dest) {
|
|
25735
25609
|
fs5.mkdirSync(dest, { recursive: true });
|
|
25736
25610
|
for (const entry of fs5.readdirSync(src, { withFileTypes: true })) {
|
|
25737
|
-
const srcPath =
|
|
25738
|
-
const destPath =
|
|
25611
|
+
const srcPath = path6.join(src, entry.name);
|
|
25612
|
+
const destPath = path6.join(dest, entry.name);
|
|
25739
25613
|
if (entry.isDirectory()) {
|
|
25740
25614
|
this.copyDirRecursive(srcPath, destPath);
|
|
25741
25615
|
} else {
|
|
@@ -25746,7 +25620,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25746
25620
|
/** .meta.json save */
|
|
25747
25621
|
writeMeta(metaPath, etag, timestamp) {
|
|
25748
25622
|
try {
|
|
25749
|
-
fs5.mkdirSync(
|
|
25623
|
+
fs5.mkdirSync(path6.dirname(metaPath), { recursive: true });
|
|
25750
25624
|
fs5.writeFileSync(metaPath, JSON.stringify({
|
|
25751
25625
|
etag,
|
|
25752
25626
|
timestamp,
|
|
@@ -25763,7 +25637,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25763
25637
|
const scan = (d) => {
|
|
25764
25638
|
try {
|
|
25765
25639
|
for (const entry of fs5.readdirSync(d, { withFileTypes: true })) {
|
|
25766
|
-
if (entry.isDirectory()) scan(
|
|
25640
|
+
if (entry.isDirectory()) scan(path6.join(d, entry.name));
|
|
25767
25641
|
else if (entry.name === "provider.json") count++;
|
|
25768
25642
|
}
|
|
25769
25643
|
} catch {
|
|
@@ -25862,17 +25736,17 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25862
25736
|
for (const root of searchRoots) {
|
|
25863
25737
|
if (!fs5.existsSync(root)) continue;
|
|
25864
25738
|
const candidate = this.getProviderDir(root, cat, type);
|
|
25865
|
-
if (fs5.existsSync(
|
|
25866
|
-
const catDir =
|
|
25739
|
+
if (fs5.existsSync(path6.join(candidate, "provider.json"))) return candidate;
|
|
25740
|
+
const catDir = path6.join(root, cat);
|
|
25867
25741
|
if (fs5.existsSync(catDir)) {
|
|
25868
25742
|
try {
|
|
25869
25743
|
for (const entry of fs5.readdirSync(catDir, { withFileTypes: true })) {
|
|
25870
25744
|
if (!entry.isDirectory()) continue;
|
|
25871
|
-
const jsonPath =
|
|
25745
|
+
const jsonPath = path6.join(catDir, entry.name, "provider.json");
|
|
25872
25746
|
if (fs5.existsSync(jsonPath)) {
|
|
25873
25747
|
try {
|
|
25874
25748
|
const data = JSON.parse(fs5.readFileSync(jsonPath, "utf-8"));
|
|
25875
|
-
if (data.type === type) return
|
|
25749
|
+
if (data.type === type) return path6.join(catDir, entry.name);
|
|
25876
25750
|
} catch {
|
|
25877
25751
|
}
|
|
25878
25752
|
}
|
|
@@ -25889,7 +25763,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25889
25763
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
25890
25764
|
*/
|
|
25891
25765
|
buildScriptWrappersFromDir(dir) {
|
|
25892
|
-
const scriptsJs =
|
|
25766
|
+
const scriptsJs = path6.join(dir, "scripts.js");
|
|
25893
25767
|
if (fs5.existsSync(scriptsJs)) {
|
|
25894
25768
|
try {
|
|
25895
25769
|
delete __require.cache[__require.resolve(scriptsJs)];
|
|
@@ -25903,7 +25777,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25903
25777
|
for (const file2 of fs5.readdirSync(dir)) {
|
|
25904
25778
|
if (!file2.endsWith(".js")) continue;
|
|
25905
25779
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
25906
|
-
const filePath =
|
|
25780
|
+
const filePath = path6.join(dir, file2);
|
|
25907
25781
|
result[scriptName] = (...args) => {
|
|
25908
25782
|
try {
|
|
25909
25783
|
let content = fs5.readFileSync(filePath, "utf-8");
|
|
@@ -25963,7 +25837,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25963
25837
|
}
|
|
25964
25838
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
25965
25839
|
if (hasJson) {
|
|
25966
|
-
const jsonPath =
|
|
25840
|
+
const jsonPath = path6.join(d, "provider.json");
|
|
25967
25841
|
try {
|
|
25968
25842
|
const raw = fs5.readFileSync(jsonPath, "utf-8");
|
|
25969
25843
|
const mod = JSON.parse(raw);
|
|
@@ -25976,7 +25850,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25976
25850
|
delete mod.extensionIdPattern_flags;
|
|
25977
25851
|
}
|
|
25978
25852
|
const hasCompatibility = Array.isArray(mod.compatibility);
|
|
25979
|
-
const scriptsPath =
|
|
25853
|
+
const scriptsPath = path6.join(d, "scripts.js");
|
|
25980
25854
|
if (!hasCompatibility && fs5.existsSync(scriptsPath)) {
|
|
25981
25855
|
try {
|
|
25982
25856
|
delete __require.cache[__require.resolve(scriptsPath)];
|
|
@@ -26002,7 +25876,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
26002
25876
|
if (!entry.isDirectory()) continue;
|
|
26003
25877
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
26004
25878
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
26005
|
-
scan(
|
|
25879
|
+
scan(path6.join(d, entry.name));
|
|
26006
25880
|
}
|
|
26007
25881
|
}
|
|
26008
25882
|
};
|
|
@@ -26080,17 +25954,17 @@ async function findFreePort(ports) {
|
|
|
26080
25954
|
throw new Error("No free port found");
|
|
26081
25955
|
}
|
|
26082
25956
|
function checkPortFree(port) {
|
|
26083
|
-
return new Promise((
|
|
25957
|
+
return new Promise((resolve92) => {
|
|
26084
25958
|
const server = net2.createServer();
|
|
26085
25959
|
server.unref();
|
|
26086
|
-
server.on("error", () =>
|
|
25960
|
+
server.on("error", () => resolve92(false));
|
|
26087
25961
|
server.listen(port, "127.0.0.1", () => {
|
|
26088
|
-
server.close(() =>
|
|
25962
|
+
server.close(() => resolve92(true));
|
|
26089
25963
|
});
|
|
26090
25964
|
});
|
|
26091
25965
|
}
|
|
26092
25966
|
async function isCdpActive(port) {
|
|
26093
|
-
return new Promise((
|
|
25967
|
+
return new Promise((resolve92) => {
|
|
26094
25968
|
const req = __require("http").get(`http://127.0.0.1:${port}/json/version`, {
|
|
26095
25969
|
timeout: 2e3
|
|
26096
25970
|
}, (res) => {
|
|
@@ -26099,16 +25973,16 @@ async function isCdpActive(port) {
|
|
|
26099
25973
|
res.on("end", () => {
|
|
26100
25974
|
try {
|
|
26101
25975
|
const info = JSON.parse(data);
|
|
26102
|
-
|
|
25976
|
+
resolve92(!!info["WebKit-Version"] || !!info["Browser"]);
|
|
26103
25977
|
} catch {
|
|
26104
|
-
|
|
25978
|
+
resolve92(false);
|
|
26105
25979
|
}
|
|
26106
25980
|
});
|
|
26107
25981
|
});
|
|
26108
|
-
req.on("error", () =>
|
|
25982
|
+
req.on("error", () => resolve92(false));
|
|
26109
25983
|
req.on("timeout", () => {
|
|
26110
25984
|
req.destroy();
|
|
26111
|
-
|
|
25985
|
+
resolve92(false);
|
|
26112
25986
|
});
|
|
26113
25987
|
});
|
|
26114
25988
|
}
|
|
@@ -26227,8 +26101,8 @@ function detectCurrentWorkspace(ideId) {
|
|
|
26227
26101
|
const appNameMap = getMacAppIdentifiers();
|
|
26228
26102
|
const appName = appNameMap[ideId];
|
|
26229
26103
|
if (appName) {
|
|
26230
|
-
const storagePath =
|
|
26231
|
-
process.env.APPDATA ||
|
|
26104
|
+
const storagePath = path7.join(
|
|
26105
|
+
process.env.APPDATA || path7.join(os8.homedir(), "AppData", "Roaming"),
|
|
26232
26106
|
appName,
|
|
26233
26107
|
"storage.json"
|
|
26234
26108
|
);
|
|
@@ -26392,10 +26266,8 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
26392
26266
|
(0, import_child_process5.spawn)(cli, args, { detached: true, stdio: "ignore" }).unref();
|
|
26393
26267
|
}
|
|
26394
26268
|
init_config();
|
|
26395
|
-
init_workspaces();
|
|
26396
|
-
init_config();
|
|
26397
26269
|
init_logger();
|
|
26398
|
-
var LOG_DIR2 = process.platform === "win32" ?
|
|
26270
|
+
var LOG_DIR2 = process.platform === "win32" ? path8.join(process.env.LOCALAPPDATA || process.env.APPDATA || path8.join(os9.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path8.join(os9.homedir(), "Library", "Logs", "adhdev") : path8.join(os9.homedir(), ".local", "share", "adhdev", "logs");
|
|
26399
26271
|
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
26400
26272
|
var MAX_DAYS = 7;
|
|
26401
26273
|
try {
|
|
@@ -26433,13 +26305,13 @@ function getDateStr2() {
|
|
|
26433
26305
|
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
26434
26306
|
}
|
|
26435
26307
|
var currentDate2 = getDateStr2();
|
|
26436
|
-
var currentFile =
|
|
26308
|
+
var currentFile = path8.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
26437
26309
|
var writeCount2 = 0;
|
|
26438
26310
|
function checkRotation() {
|
|
26439
26311
|
const today = getDateStr2();
|
|
26440
26312
|
if (today !== currentDate2) {
|
|
26441
26313
|
currentDate2 = today;
|
|
26442
|
-
currentFile =
|
|
26314
|
+
currentFile = path8.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
26443
26315
|
cleanOldFiles();
|
|
26444
26316
|
}
|
|
26445
26317
|
}
|
|
@@ -26453,7 +26325,7 @@ function cleanOldFiles() {
|
|
|
26453
26325
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
26454
26326
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
26455
26327
|
try {
|
|
26456
|
-
fs6.unlinkSync(
|
|
26328
|
+
fs6.unlinkSync(path8.join(LOG_DIR2, file2));
|
|
26457
26329
|
} catch {
|
|
26458
26330
|
}
|
|
26459
26331
|
}
|
|
@@ -26501,6 +26373,144 @@ function logCommand(entry) {
|
|
|
26501
26373
|
}
|
|
26502
26374
|
cleanOldFiles();
|
|
26503
26375
|
init_logger();
|
|
26376
|
+
init_config();
|
|
26377
|
+
init_terminal_screen();
|
|
26378
|
+
init_logger();
|
|
26379
|
+
var READ_DEBUG_ENABLED = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
|
|
26380
|
+
function buildDetectedIdeInfos(detectedIdes, cdpManagers) {
|
|
26381
|
+
return detectedIdes.filter((ide) => ide.installed !== false).map((ide) => ({
|
|
26382
|
+
id: ide.id,
|
|
26383
|
+
type: ide.id,
|
|
26384
|
+
name: ide.displayName || ide.name || ide.id,
|
|
26385
|
+
running: isCdpConnected(cdpManagers, ide.id),
|
|
26386
|
+
...ide.path ? { path: ide.path } : {}
|
|
26387
|
+
}));
|
|
26388
|
+
}
|
|
26389
|
+
function buildAvailableProviders(providerLoader) {
|
|
26390
|
+
return providerLoader.getAll().map((provider) => ({
|
|
26391
|
+
type: provider.type,
|
|
26392
|
+
name: provider.displayName || provider.type,
|
|
26393
|
+
displayName: provider.displayName || provider.type,
|
|
26394
|
+
icon: provider.icon || "\u{1F4BB}",
|
|
26395
|
+
category: provider.category
|
|
26396
|
+
}));
|
|
26397
|
+
}
|
|
26398
|
+
function parseMessageTime(value) {
|
|
26399
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
26400
|
+
if (typeof value === "string") {
|
|
26401
|
+
const parsed = Date.parse(value);
|
|
26402
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
26403
|
+
}
|
|
26404
|
+
return 0;
|
|
26405
|
+
}
|
|
26406
|
+
function getSessionMessageUpdatedAt(session) {
|
|
26407
|
+
const lastMessage = session.activeChat?.messages?.at?.(-1);
|
|
26408
|
+
if (!lastMessage) return 0;
|
|
26409
|
+
return parseMessageTime(lastMessage.timestamp) || parseMessageTime(lastMessage.receivedAt) || parseMessageTime(lastMessage.createdAt) || 0;
|
|
26410
|
+
}
|
|
26411
|
+
function getSessionCompletionMarker(session) {
|
|
26412
|
+
const lastMessage = session.activeChat?.messages?.at?.(-1);
|
|
26413
|
+
if (!lastMessage) return "";
|
|
26414
|
+
const role = typeof lastMessage.role === "string" ? lastMessage.role : "";
|
|
26415
|
+
if (role === "user" || role === "human") return "";
|
|
26416
|
+
if (typeof lastMessage._turnKey === "string" && lastMessage._turnKey) return `turn:${lastMessage._turnKey}`;
|
|
26417
|
+
if (typeof lastMessage.id === "string" && lastMessage.id) return `id:${lastMessage.id}`;
|
|
26418
|
+
if (typeof lastMessage.index === "number" && Number.isFinite(lastMessage.index)) return `idx:${lastMessage.index}`;
|
|
26419
|
+
const timestamp = parseMessageTime(lastMessage.timestamp) || parseMessageTime(lastMessage.receivedAt) || parseMessageTime(lastMessage.createdAt);
|
|
26420
|
+
return timestamp > 0 ? `ts:${timestamp}` : "";
|
|
26421
|
+
}
|
|
26422
|
+
function getSessionLastUsedAt(session) {
|
|
26423
|
+
return getSessionMessageUpdatedAt(session) || session.lastUpdated || Date.now();
|
|
26424
|
+
}
|
|
26425
|
+
function getLastMessageRole(session) {
|
|
26426
|
+
const role = session.activeChat?.messages?.at?.(-1)?.role;
|
|
26427
|
+
return typeof role === "string" ? role : "";
|
|
26428
|
+
}
|
|
26429
|
+
function getUnreadState(hasContentChange, status, lastUsedAt, lastSeenAt, lastRole, completionMarker, seenCompletionMarker) {
|
|
26430
|
+
if (status === "waiting_approval") {
|
|
26431
|
+
return { unread: false, inboxBucket: "needs_attention" };
|
|
26432
|
+
}
|
|
26433
|
+
if (status === "generating" || status === "starting") {
|
|
26434
|
+
return { unread: false, inboxBucket: "working" };
|
|
26435
|
+
}
|
|
26436
|
+
const unread = completionMarker ? completionMarker !== seenCompletionMarker : hasContentChange && lastUsedAt > lastSeenAt && lastRole !== "user" && lastRole !== "human";
|
|
26437
|
+
return { unread, inboxBucket: unread ? "task_complete" : "idle" };
|
|
26438
|
+
}
|
|
26439
|
+
function buildRecentLaunches(recentActivity) {
|
|
26440
|
+
return recentActivity.map((item) => ({
|
|
26441
|
+
id: item.id,
|
|
26442
|
+
providerType: item.providerType,
|
|
26443
|
+
providerName: item.providerName,
|
|
26444
|
+
kind: item.kind,
|
|
26445
|
+
title: item.title || item.providerName,
|
|
26446
|
+
workspace: item.workspace,
|
|
26447
|
+
currentModel: item.currentModel,
|
|
26448
|
+
lastLaunchedAt: item.lastUsedAt
|
|
26449
|
+
})).sort((a, b) => b.lastLaunchedAt - a.lastLaunchedAt).slice(0, 12);
|
|
26450
|
+
}
|
|
26451
|
+
function buildStatusSnapshot(options) {
|
|
26452
|
+
const cfg = loadConfig();
|
|
26453
|
+
const wsState = getWorkspaceState(cfg);
|
|
26454
|
+
const memSnap = getHostMemorySnapshot();
|
|
26455
|
+
const recentActivity = getRecentActivity(cfg, 20);
|
|
26456
|
+
const sessions = buildSessionEntries(
|
|
26457
|
+
options.allStates,
|
|
26458
|
+
options.cdpManagers
|
|
26459
|
+
);
|
|
26460
|
+
for (const session of sessions) {
|
|
26461
|
+
const lastSeenAt = getSessionSeenAt(cfg, session.id);
|
|
26462
|
+
const seenCompletionMarker = getSessionSeenMarker(cfg, session.id);
|
|
26463
|
+
const lastUsedAt = getSessionLastUsedAt(session);
|
|
26464
|
+
const completionMarker = getSessionCompletionMarker(session);
|
|
26465
|
+
const { unread, inboxBucket } = session.surfaceHidden ? { unread: false, inboxBucket: "idle" } : getUnreadState(
|
|
26466
|
+
getSessionMessageUpdatedAt(session) > 0,
|
|
26467
|
+
session.status,
|
|
26468
|
+
lastUsedAt,
|
|
26469
|
+
lastSeenAt,
|
|
26470
|
+
getLastMessageRole(session),
|
|
26471
|
+
completionMarker,
|
|
26472
|
+
seenCompletionMarker
|
|
26473
|
+
);
|
|
26474
|
+
session.lastSeenAt = lastSeenAt;
|
|
26475
|
+
session.unread = unread;
|
|
26476
|
+
session.inboxBucket = inboxBucket;
|
|
26477
|
+
if (READ_DEBUG_ENABLED && (session.unread || session.inboxBucket !== "idle" || session.providerType.includes("codex"))) {
|
|
26478
|
+
LOG.info(
|
|
26479
|
+
"RecentRead",
|
|
26480
|
+
`snapshot session id=${session.id} provider=${session.providerType} status=${String(session.status || "")} bucket=${inboxBucket} unread=${String(unread)} lastSeenAt=${lastSeenAt} completionMarker=${completionMarker || "-"} seenMarker=${seenCompletionMarker || "-"} lastUpdated=${String(session.lastUpdated || 0)} lastUsedAt=${lastUsedAt} lastRole=${getLastMessageRole(session)} msgUpdatedAt=${getSessionMessageUpdatedAt(session)}`
|
|
26481
|
+
);
|
|
26482
|
+
}
|
|
26483
|
+
}
|
|
26484
|
+
const terminalBackend = getTerminalBackendRuntimeStatus();
|
|
26485
|
+
return {
|
|
26486
|
+
instanceId: options.instanceId,
|
|
26487
|
+
version: options.version,
|
|
26488
|
+
daemonMode: options.daemonMode,
|
|
26489
|
+
machine: {
|
|
26490
|
+
hostname: os10.hostname(),
|
|
26491
|
+
platform: os10.platform(),
|
|
26492
|
+
arch: os10.arch(),
|
|
26493
|
+
cpus: os10.cpus().length,
|
|
26494
|
+
totalMem: memSnap.totalMem,
|
|
26495
|
+
freeMem: memSnap.freeMem,
|
|
26496
|
+
availableMem: memSnap.availableMem,
|
|
26497
|
+
loadavg: os10.loadavg(),
|
|
26498
|
+
uptime: os10.uptime(),
|
|
26499
|
+
release: os10.release()
|
|
26500
|
+
},
|
|
26501
|
+
machineNickname: options.machineNickname ?? cfg.machineNickname ?? null,
|
|
26502
|
+
timestamp: options.timestamp ?? Date.now(),
|
|
26503
|
+
detectedIdes: buildDetectedIdeInfos(options.detectedIdes, options.cdpManagers),
|
|
26504
|
+
...options.p2p ? { p2p: options.p2p } : {},
|
|
26505
|
+
sessions,
|
|
26506
|
+
workspaces: wsState.workspaces,
|
|
26507
|
+
defaultWorkspaceId: wsState.defaultWorkspaceId,
|
|
26508
|
+
defaultWorkspacePath: wsState.defaultWorkspacePath,
|
|
26509
|
+
recentLaunches: buildRecentLaunches(recentActivity),
|
|
26510
|
+
terminalBackend,
|
|
26511
|
+
availableProviders: buildAvailableProviders(options.providerLoader)
|
|
26512
|
+
};
|
|
26513
|
+
}
|
|
26504
26514
|
var CHAT_COMMANDS = [
|
|
26505
26515
|
"send_chat",
|
|
26506
26516
|
"new_chat",
|
|
@@ -26508,6 +26518,7 @@ var CHAT_COMMANDS = [
|
|
|
26508
26518
|
"set_mode",
|
|
26509
26519
|
"change_model"
|
|
26510
26520
|
];
|
|
26521
|
+
var READ_DEBUG_ENABLED2 = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
|
|
26511
26522
|
var DaemonCommandRouter = class {
|
|
26512
26523
|
deps;
|
|
26513
26524
|
constructor(deps) {
|
|
@@ -26626,18 +26637,6 @@ var DaemonCommandRouter = class {
|
|
|
26626
26637
|
};
|
|
26627
26638
|
LOG.info("LaunchIDE", `target=${ideKey || "auto"}`);
|
|
26628
26639
|
const result = await launchWithCdp(launchArgs);
|
|
26629
|
-
if (result.success && (result.ideId || ideKey)) {
|
|
26630
|
-
try {
|
|
26631
|
-
addCliHistory({
|
|
26632
|
-
category: "ide",
|
|
26633
|
-
cliType: result.ideId || ideKey,
|
|
26634
|
-
dir: resolvedWorkspace || "",
|
|
26635
|
-
workspace: resolvedWorkspace || "",
|
|
26636
|
-
newWindow: args?.newWindow === true
|
|
26637
|
-
});
|
|
26638
|
-
} catch {
|
|
26639
|
-
}
|
|
26640
|
-
}
|
|
26641
26640
|
if (result.success && result.port && result.ideId && !this.deps.cdpManagers.has(result.ideId)) {
|
|
26642
26641
|
const logFn = this.deps.getCdpLogFn ? this.deps.getCdpLogFn(result.ideId) : LOG.forComponent(`CDP:${result.ideId}`).asLogFn();
|
|
26643
26642
|
const provider = this.deps.providerLoader.getMeta(result.ideId);
|
|
@@ -26654,11 +26653,7 @@ var DaemonCommandRouter = class {
|
|
|
26654
26653
|
this.deps.onIdeConnected?.();
|
|
26655
26654
|
if (result.success && resolvedWorkspace) {
|
|
26656
26655
|
try {
|
|
26657
|
-
|
|
26658
|
-
kind: "ide",
|
|
26659
|
-
agentType: result.ideId
|
|
26660
|
-
});
|
|
26661
|
-
next = appendRecentActivity(next, {
|
|
26656
|
+
const next = appendRecentActivity(loadConfig(), {
|
|
26662
26657
|
kind: "ide",
|
|
26663
26658
|
providerType: result.ideId || ideKey,
|
|
26664
26659
|
providerName: result.ideId || ideKey,
|
|
@@ -26694,28 +26689,35 @@ var DaemonCommandRouter = class {
|
|
|
26694
26689
|
updateConfig({ userName: name });
|
|
26695
26690
|
return { success: true, userName: name };
|
|
26696
26691
|
}
|
|
26697
|
-
case "
|
|
26698
|
-
const
|
|
26699
|
-
|
|
26700
|
-
|
|
26701
|
-
return { success: false, error: "kind and providerType are required" };
|
|
26692
|
+
case "mark_session_seen": {
|
|
26693
|
+
const sessionId = args?.sessionId;
|
|
26694
|
+
if (!sessionId || typeof sessionId !== "string") {
|
|
26695
|
+
return { success: false, error: "sessionId is required" };
|
|
26702
26696
|
}
|
|
26703
|
-
const
|
|
26704
|
-
|
|
26705
|
-
|
|
26706
|
-
|
|
26707
|
-
|
|
26708
|
-
|
|
26709
|
-
|
|
26710
|
-
|
|
26711
|
-
|
|
26697
|
+
const currentConfig = loadConfig();
|
|
26698
|
+
const prevSeenAt = currentConfig.sessionReads?.[sessionId] || 0;
|
|
26699
|
+
const sessionEntries = buildSessionEntries(
|
|
26700
|
+
this.deps.instanceManager.collectAllStates(),
|
|
26701
|
+
this.deps.cdpManagers
|
|
26702
|
+
);
|
|
26703
|
+
const targetSession = sessionEntries.find((entry) => entry.id === sessionId);
|
|
26704
|
+
const completionMarker = targetSession ? getSessionCompletionMarker(targetSession) : "";
|
|
26705
|
+
const next = markSessionSeen(
|
|
26706
|
+
currentConfig,
|
|
26707
|
+
sessionId,
|
|
26708
|
+
typeof args?.seenAt === "number" ? args.seenAt : Date.now(),
|
|
26709
|
+
completionMarker
|
|
26712
26710
|
);
|
|
26711
|
+
if (READ_DEBUG_ENABLED2) {
|
|
26712
|
+
LOG.info("RecentRead", `mark_session_seen sessionId=${sessionId} seenAt=${String(args?.seenAt || "")} prevSeenAt=${String(prevSeenAt)} nextSeenAt=${String(next.sessionReads?.[sessionId] || 0)} marker=${completionMarker || "-"}`);
|
|
26713
|
+
}
|
|
26713
26714
|
saveConfig(next);
|
|
26714
26715
|
this.deps.onStatusChange?.();
|
|
26715
26716
|
return {
|
|
26716
26717
|
success: true,
|
|
26717
|
-
|
|
26718
|
-
seenAt: next.
|
|
26718
|
+
sessionId,
|
|
26719
|
+
seenAt: next.sessionReads?.[sessionId] || Date.now(),
|
|
26720
|
+
completionMarker
|
|
26719
26721
|
};
|
|
26720
26722
|
}
|
|
26721
26723
|
// ─── Daemon Self-Upgrade ───
|
|
@@ -26736,9 +26738,9 @@ var DaemonCommandRouter = class {
|
|
|
26736
26738
|
setTimeout(() => {
|
|
26737
26739
|
LOG.info("Upgrade", "Restarting daemon with new version...");
|
|
26738
26740
|
try {
|
|
26739
|
-
const
|
|
26741
|
+
const path152 = __require("path");
|
|
26740
26742
|
const fs122 = __require("fs");
|
|
26741
|
-
const pidFile =
|
|
26743
|
+
const pidFile = path152.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
|
|
26742
26744
|
if (fs122.existsSync(pidFile)) fs122.unlinkSync(pidFile);
|
|
26743
26745
|
} catch {
|
|
26744
26746
|
}
|
|
@@ -26830,182 +26832,9 @@ var DaemonCommandRouter = class {
|
|
|
26830
26832
|
}
|
|
26831
26833
|
};
|
|
26832
26834
|
init_logger();
|
|
26833
|
-
init_config();
|
|
26834
|
-
init_workspaces();
|
|
26835
|
-
init_terminal_screen();
|
|
26836
|
-
function buildDetectedIdeInfos(detectedIdes, cdpManagers) {
|
|
26837
|
-
return detectedIdes.filter((ide) => ide.installed !== false).map((ide) => ({
|
|
26838
|
-
id: ide.id,
|
|
26839
|
-
type: ide.id,
|
|
26840
|
-
name: ide.displayName || ide.name || ide.id,
|
|
26841
|
-
running: isCdpConnected(cdpManagers, ide.id),
|
|
26842
|
-
...ide.path ? { path: ide.path } : {}
|
|
26843
|
-
}));
|
|
26844
|
-
}
|
|
26845
|
-
function buildAvailableProviders(providerLoader) {
|
|
26846
|
-
return providerLoader.getAll().map((provider) => ({
|
|
26847
|
-
type: provider.type,
|
|
26848
|
-
name: provider.displayName || provider.type,
|
|
26849
|
-
displayName: provider.displayName || provider.type,
|
|
26850
|
-
icon: provider.icon || "\u{1F4BB}",
|
|
26851
|
-
category: provider.category
|
|
26852
|
-
}));
|
|
26853
|
-
}
|
|
26854
|
-
function parseMessageTime(value) {
|
|
26855
|
-
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
26856
|
-
if (typeof value === "string") {
|
|
26857
|
-
const parsed = Date.parse(value);
|
|
26858
|
-
if (Number.isFinite(parsed)) return parsed;
|
|
26859
|
-
}
|
|
26860
|
-
return 0;
|
|
26861
|
-
}
|
|
26862
|
-
function getSessionMessageUpdatedAt(session) {
|
|
26863
|
-
const lastMessage = session.activeChat?.messages?.at?.(-1);
|
|
26864
|
-
if (!lastMessage) return 0;
|
|
26865
|
-
return parseMessageTime(lastMessage.timestamp) || parseMessageTime(lastMessage.receivedAt) || parseMessageTime(lastMessage.createdAt) || 0;
|
|
26866
|
-
}
|
|
26867
|
-
function getSessionLastUsedAt(session) {
|
|
26868
|
-
return getSessionMessageUpdatedAt(session) || session.lastUpdated || Date.now();
|
|
26869
|
-
}
|
|
26870
|
-
function getSessionKind(session) {
|
|
26871
|
-
return session.transport === "cdp-page" || session.transport === "cdp-webview" ? "ide" : session.transport === "acp" ? "acp" : "cli";
|
|
26872
|
-
}
|
|
26873
|
-
function getLastMessageRole(session) {
|
|
26874
|
-
const role = session.activeChat?.messages?.at?.(-1)?.role;
|
|
26875
|
-
return typeof role === "string" ? role : "";
|
|
26876
|
-
}
|
|
26877
|
-
function getUnreadState(hasContentChange, status, lastUsedAt, lastSeenAt, lastRole) {
|
|
26878
|
-
if (status === "waiting_approval") {
|
|
26879
|
-
return { unread: false, inboxBucket: "needs_attention" };
|
|
26880
|
-
}
|
|
26881
|
-
if (status === "generating" || status === "starting") {
|
|
26882
|
-
return { unread: false, inboxBucket: "working" };
|
|
26883
|
-
}
|
|
26884
|
-
const unread = hasContentChange && lastUsedAt > lastSeenAt && lastRole !== "user" && lastRole !== "human";
|
|
26885
|
-
return { unread, inboxBucket: unread ? "task_complete" : "idle" };
|
|
26886
|
-
}
|
|
26887
|
-
function buildRecentSessions(sessions, recentActivity, readState) {
|
|
26888
|
-
const live = sessions.filter((session) => !session.parentId && session.status !== "stopped").map((session) => {
|
|
26889
|
-
const kind = getSessionKind(session);
|
|
26890
|
-
const recentKey = buildRecentActivityKey({
|
|
26891
|
-
kind,
|
|
26892
|
-
providerType: session.providerType,
|
|
26893
|
-
workspace: session.workspace
|
|
26894
|
-
});
|
|
26895
|
-
const lastSeenAt = readState[recentKey] || 0;
|
|
26896
|
-
const lastUsedAt = getSessionLastUsedAt(session);
|
|
26897
|
-
const { unread, inboxBucket } = getUnreadState(
|
|
26898
|
-
getSessionMessageUpdatedAt(session) > 0,
|
|
26899
|
-
session.status,
|
|
26900
|
-
lastUsedAt,
|
|
26901
|
-
lastSeenAt,
|
|
26902
|
-
getLastMessageRole(session)
|
|
26903
|
-
);
|
|
26904
|
-
return {
|
|
26905
|
-
id: session.id,
|
|
26906
|
-
recentKey,
|
|
26907
|
-
sessionId: session.id,
|
|
26908
|
-
providerType: session.providerType,
|
|
26909
|
-
providerName: session.providerName,
|
|
26910
|
-
kind,
|
|
26911
|
-
title: session.activeChat?.title || session.title || session.providerName,
|
|
26912
|
-
workspace: session.workspace,
|
|
26913
|
-
currentModel: session.currentModel,
|
|
26914
|
-
status: session.status,
|
|
26915
|
-
lastUsedAt,
|
|
26916
|
-
unread,
|
|
26917
|
-
lastSeenAt,
|
|
26918
|
-
inboxBucket
|
|
26919
|
-
};
|
|
26920
|
-
});
|
|
26921
|
-
const seen = new Set(live.map((item) => `${item.kind}:${item.providerType}:${item.workspace || ""}`));
|
|
26922
|
-
const persisted = recentActivity.filter((item) => !seen.has(`${item.kind}:${item.providerType}:${item.workspace || ""}`)).map((item) => {
|
|
26923
|
-
const lastSeenAt = readState[item.id] || 0;
|
|
26924
|
-
const unread = item.lastUsedAt > lastSeenAt;
|
|
26925
|
-
return {
|
|
26926
|
-
id: item.id,
|
|
26927
|
-
recentKey: item.id,
|
|
26928
|
-
sessionId: item.sessionId || null,
|
|
26929
|
-
providerType: item.providerType,
|
|
26930
|
-
providerName: item.providerName,
|
|
26931
|
-
kind: item.kind,
|
|
26932
|
-
title: item.title || item.providerName,
|
|
26933
|
-
workspace: item.workspace,
|
|
26934
|
-
currentModel: item.currentModel,
|
|
26935
|
-
lastUsedAt: item.lastUsedAt,
|
|
26936
|
-
unread,
|
|
26937
|
-
lastSeenAt,
|
|
26938
|
-
inboxBucket: unread ? "task_complete" : "idle"
|
|
26939
|
-
};
|
|
26940
|
-
});
|
|
26941
|
-
return [...live, ...persisted].sort((a, b) => b.lastUsedAt - a.lastUsedAt).slice(0, 12);
|
|
26942
|
-
}
|
|
26943
|
-
function buildStatusSnapshot(options) {
|
|
26944
|
-
const cfg = loadConfig();
|
|
26945
|
-
const wsState = getWorkspaceState(cfg);
|
|
26946
|
-
const memSnap = getHostMemorySnapshot();
|
|
26947
|
-
const recentActivity = getRecentActivity(cfg, 20);
|
|
26948
|
-
const sessions = buildSessionEntries(
|
|
26949
|
-
options.allStates,
|
|
26950
|
-
options.cdpManagers
|
|
26951
|
-
);
|
|
26952
|
-
const readState = cfg.recentSessionReads || {};
|
|
26953
|
-
for (const session of sessions) {
|
|
26954
|
-
const kind = getSessionKind(session);
|
|
26955
|
-
const recentKey = buildRecentActivityKey({
|
|
26956
|
-
kind,
|
|
26957
|
-
providerType: session.providerType,
|
|
26958
|
-
workspace: session.workspace
|
|
26959
|
-
});
|
|
26960
|
-
const lastSeenAt = getRecentSessionSeenAt(cfg, recentKey);
|
|
26961
|
-
const lastUsedAt = getSessionLastUsedAt(session);
|
|
26962
|
-
const { unread, inboxBucket } = getUnreadState(
|
|
26963
|
-
getSessionMessageUpdatedAt(session) > 0,
|
|
26964
|
-
session.status,
|
|
26965
|
-
lastUsedAt,
|
|
26966
|
-
lastSeenAt,
|
|
26967
|
-
getLastMessageRole(session)
|
|
26968
|
-
);
|
|
26969
|
-
session.recentKey = recentKey;
|
|
26970
|
-
session.lastSeenAt = lastSeenAt;
|
|
26971
|
-
session.unread = unread;
|
|
26972
|
-
session.inboxBucket = inboxBucket;
|
|
26973
|
-
}
|
|
26974
|
-
const terminalBackend = getTerminalBackendRuntimeStatus();
|
|
26975
|
-
return {
|
|
26976
|
-
instanceId: options.instanceId,
|
|
26977
|
-
version: options.version,
|
|
26978
|
-
daemonMode: options.daemonMode,
|
|
26979
|
-
machine: {
|
|
26980
|
-
hostname: os10.hostname(),
|
|
26981
|
-
platform: os10.platform(),
|
|
26982
|
-
arch: os10.arch(),
|
|
26983
|
-
cpus: os10.cpus().length,
|
|
26984
|
-
totalMem: memSnap.totalMem,
|
|
26985
|
-
freeMem: memSnap.freeMem,
|
|
26986
|
-
availableMem: memSnap.availableMem,
|
|
26987
|
-
loadavg: os10.loadavg(),
|
|
26988
|
-
uptime: os10.uptime(),
|
|
26989
|
-
release: os10.release()
|
|
26990
|
-
},
|
|
26991
|
-
machineNickname: options.machineNickname ?? cfg.machineNickname ?? null,
|
|
26992
|
-
timestamp: options.timestamp ?? Date.now(),
|
|
26993
|
-
detectedIdes: buildDetectedIdeInfos(options.detectedIdes, options.cdpManagers),
|
|
26994
|
-
...options.p2p ? { p2p: options.p2p } : {},
|
|
26995
|
-
sessions,
|
|
26996
|
-
workspaces: wsState.workspaces,
|
|
26997
|
-
defaultWorkspaceId: wsState.defaultWorkspaceId,
|
|
26998
|
-
defaultWorkspacePath: wsState.defaultWorkspacePath,
|
|
26999
|
-
workspaceActivity: getWorkspaceActivity(cfg, 15),
|
|
27000
|
-
recentSessions: buildRecentSessions(sessions, recentActivity, readState),
|
|
27001
|
-
terminalBackend,
|
|
27002
|
-
availableProviders: buildAvailableProviders(options.providerLoader)
|
|
27003
|
-
};
|
|
27004
|
-
}
|
|
27005
26835
|
init_logger();
|
|
27006
26836
|
init_provider_cli_adapter();
|
|
27007
26837
|
init_config();
|
|
27008
|
-
init_workspaces();
|
|
27009
26838
|
init_provider_cli_adapter();
|
|
27010
26839
|
init_logger();
|
|
27011
26840
|
var CliProviderInstance = class {
|
|
@@ -27669,13 +27498,13 @@ var AcpProviderInstance = class {
|
|
|
27669
27498
|
}
|
|
27670
27499
|
this.currentStatus = "waiting_approval";
|
|
27671
27500
|
this.detectStatusTransition();
|
|
27672
|
-
const approved = await new Promise((
|
|
27673
|
-
this.permissionResolvers.push(
|
|
27501
|
+
const approved = await new Promise((resolve92) => {
|
|
27502
|
+
this.permissionResolvers.push(resolve92);
|
|
27674
27503
|
setTimeout(() => {
|
|
27675
|
-
const idx = this.permissionResolvers.indexOf(
|
|
27504
|
+
const idx = this.permissionResolvers.indexOf(resolve92);
|
|
27676
27505
|
if (idx >= 0) {
|
|
27677
27506
|
this.permissionResolvers.splice(idx, 1);
|
|
27678
|
-
|
|
27507
|
+
resolve92(false);
|
|
27679
27508
|
}
|
|
27680
27509
|
}, 3e5);
|
|
27681
27510
|
});
|
|
@@ -28148,24 +27977,6 @@ var DaemonCliManager = class {
|
|
|
28148
27977
|
const hash2 = __require("crypto").createHash("md5").update(__require("path").resolve(dir)).digest("hex").slice(0, 8);
|
|
28149
27978
|
return `${cliType}_${hash2}`;
|
|
28150
27979
|
}
|
|
28151
|
-
persistRecentDir(cliType, dir) {
|
|
28152
|
-
try {
|
|
28153
|
-
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
28154
|
-
const provider = this.providerLoader.getByAlias(cliType);
|
|
28155
|
-
const actKind = provider?.category === "acp" ? "acp" : "cli";
|
|
28156
|
-
let next = loadConfig();
|
|
28157
|
-
console.log(colorize("cyan", ` \u{1F4C2} Saving recent workspace: ${dir}`));
|
|
28158
|
-
const recent = next.recentCliWorkspaces || [];
|
|
28159
|
-
if (!recent.includes(dir)) {
|
|
28160
|
-
next = { ...next, recentCliWorkspaces: [dir, ...recent].slice(0, 10) };
|
|
28161
|
-
}
|
|
28162
|
-
next = appendWorkspaceActivity(next, dir, { kind: actKind, agentType: normalizedType });
|
|
28163
|
-
saveConfig(next);
|
|
28164
|
-
console.log(colorize("green", ` \u2713 Recent workspace saved: ${dir}`));
|
|
28165
|
-
} catch (e) {
|
|
28166
|
-
console.error(colorize("red", ` \u2717 Failed to save recent workspace: ${e}`));
|
|
28167
|
-
}
|
|
28168
|
-
}
|
|
28169
27980
|
persistRecentActivity(entry) {
|
|
28170
27981
|
try {
|
|
28171
27982
|
saveConfig(appendRecentActivity(loadConfig(), entry));
|
|
@@ -28255,7 +28066,7 @@ var DaemonCliManager = class {
|
|
|
28255
28066
|
async startSession(cliType, workingDir, cliArgs, initialModel) {
|
|
28256
28067
|
const trimmed = (workingDir || "").trim();
|
|
28257
28068
|
if (!trimmed) throw new Error("working directory required");
|
|
28258
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os13.homedir()) :
|
|
28069
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os13.homedir()) : path10.resolve(trimmed);
|
|
28259
28070
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
28260
28071
|
const provider = this.providerLoader.getByAlias(cliType);
|
|
28261
28072
|
const key = crypto4.randomUUID();
|
|
@@ -28326,11 +28137,6 @@ ${installInfo}`
|
|
|
28326
28137
|
LOG.warn("CLI", `[ACP] Initial model set failed: ${e?.message}`);
|
|
28327
28138
|
}
|
|
28328
28139
|
}
|
|
28329
|
-
try {
|
|
28330
|
-
addCliHistory({ category: "acp", cliType: normalizedType, dir: resolvedDir, workspace: resolvedDir, cliArgs, model: initialModel });
|
|
28331
|
-
} catch (e) {
|
|
28332
|
-
LOG.warn("CLI", `ACP history save failed: ${e?.message}`);
|
|
28333
|
-
}
|
|
28334
28140
|
this.persistRecentActivity({
|
|
28335
28141
|
kind: "acp",
|
|
28336
28142
|
providerType: normalizedType,
|
|
@@ -28397,11 +28203,6 @@ ${installInfo}`
|
|
|
28397
28203
|
this.adapters.set(key, adapter);
|
|
28398
28204
|
console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
|
|
28399
28205
|
}
|
|
28400
|
-
try {
|
|
28401
|
-
addCliHistory({ category: "cli", cliType, dir: resolvedDir, workspace: resolvedDir, cliArgs, model: initialModel });
|
|
28402
|
-
} catch (e) {
|
|
28403
|
-
LOG.warn("CLI", `CLI history save failed: ${e?.message}`);
|
|
28404
|
-
}
|
|
28405
28206
|
this.persistRecentActivity({
|
|
28406
28207
|
kind: "cli",
|
|
28407
28208
|
providerType: normalizedType,
|
|
@@ -28554,7 +28355,6 @@ ${installInfo}`
|
|
|
28554
28355
|
newKey = k;
|
|
28555
28356
|
}
|
|
28556
28357
|
}
|
|
28557
|
-
this.persistRecentDir(cliType, dir);
|
|
28558
28358
|
return { success: true, cliType, dir, id: newKey, launchSource };
|
|
28559
28359
|
}
|
|
28560
28360
|
case "stop_cli": {
|
|
@@ -28597,7 +28397,6 @@ ${installInfo}`
|
|
|
28597
28397
|
const found = this.findAdapter(cliType, { instanceKey: args?.targetSessionId, dir });
|
|
28598
28398
|
if (found) await this.stopSession(found.key);
|
|
28599
28399
|
await this.startSession(cliType, dir);
|
|
28600
|
-
this.persistRecentDir(cliType, dir);
|
|
28601
28400
|
return { success: true, restarted: true };
|
|
28602
28401
|
}
|
|
28603
28402
|
case "agent_command": {
|
|
@@ -29403,7 +29202,7 @@ var ProviderInstanceManager = class {
|
|
|
29403
29202
|
this.eventListeners = [];
|
|
29404
29203
|
}
|
|
29405
29204
|
};
|
|
29406
|
-
var ARCHIVE_PATH =
|
|
29205
|
+
var ARCHIVE_PATH = path11.join(os14.homedir(), ".adhdev", "version-history.json");
|
|
29407
29206
|
var MAX_ENTRIES_PER_PROVIDER = 20;
|
|
29408
29207
|
var VersionArchive = class {
|
|
29409
29208
|
history = {};
|
|
@@ -29450,7 +29249,7 @@ var VersionArchive = class {
|
|
|
29450
29249
|
}
|
|
29451
29250
|
save() {
|
|
29452
29251
|
try {
|
|
29453
|
-
fs8.mkdirSync(
|
|
29252
|
+
fs8.mkdirSync(path11.dirname(ARCHIVE_PATH), { recursive: true });
|
|
29454
29253
|
fs8.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
29455
29254
|
} catch {
|
|
29456
29255
|
}
|
|
@@ -29491,7 +29290,7 @@ function checkPathExists2(paths) {
|
|
|
29491
29290
|
for (const p of paths) {
|
|
29492
29291
|
if (p.includes("*")) {
|
|
29493
29292
|
const home = os14.homedir();
|
|
29494
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
29293
|
+
const resolved = p.replace(/\*/g, home.split(path11.sep).pop() || "");
|
|
29495
29294
|
if (fs8.existsSync(resolved)) return resolved;
|
|
29496
29295
|
} else {
|
|
29497
29296
|
if (fs8.existsSync(p)) return p;
|
|
@@ -29501,7 +29300,7 @@ function checkPathExists2(paths) {
|
|
|
29501
29300
|
}
|
|
29502
29301
|
function getMacAppVersion(appPath) {
|
|
29503
29302
|
if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
29504
|
-
const plistPath =
|
|
29303
|
+
const plistPath = path11.join(appPath, "Contents", "Info.plist");
|
|
29505
29304
|
if (!fs8.existsSync(plistPath)) return null;
|
|
29506
29305
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
29507
29306
|
return raw || null;
|
|
@@ -29528,7 +29327,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
29528
29327
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
29529
29328
|
let resolvedBin = cliBin;
|
|
29530
29329
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
29531
|
-
const bundled =
|
|
29330
|
+
const bundled = path11.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
29532
29331
|
if (provider.cli && fs8.existsSync(bundled)) resolvedBin = bundled;
|
|
29533
29332
|
}
|
|
29534
29333
|
info.installed = !!(appPath || resolvedBin);
|
|
@@ -30071,17 +29870,17 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
30071
29870
|
return;
|
|
30072
29871
|
}
|
|
30073
29872
|
let scriptsPath = "";
|
|
30074
|
-
const directScripts =
|
|
29873
|
+
const directScripts = path12.join(dir, "scripts.js");
|
|
30075
29874
|
if (fs9.existsSync(directScripts)) {
|
|
30076
29875
|
scriptsPath = directScripts;
|
|
30077
29876
|
} else {
|
|
30078
|
-
const scriptsDir =
|
|
29877
|
+
const scriptsDir = path12.join(dir, "scripts");
|
|
30079
29878
|
if (fs9.existsSync(scriptsDir)) {
|
|
30080
29879
|
const versions = fs9.readdirSync(scriptsDir).filter((d) => {
|
|
30081
|
-
return fs9.statSync(
|
|
29880
|
+
return fs9.statSync(path12.join(scriptsDir, d)).isDirectory();
|
|
30082
29881
|
}).sort().reverse();
|
|
30083
29882
|
for (const ver of versions) {
|
|
30084
|
-
const p =
|
|
29883
|
+
const p = path12.join(scriptsDir, ver, "scripts.js");
|
|
30085
29884
|
if (fs9.existsSync(p)) {
|
|
30086
29885
|
scriptsPath = p;
|
|
30087
29886
|
break;
|
|
@@ -31149,22 +30948,22 @@ function getLatestScriptVersionDir(scriptsDir) {
|
|
|
31149
30948
|
if (!fs10.existsSync(scriptsDir)) return null;
|
|
31150
30949
|
const versions = fs10.readdirSync(scriptsDir).filter((d) => {
|
|
31151
30950
|
try {
|
|
31152
|
-
return fs10.statSync(
|
|
30951
|
+
return fs10.statSync(path13.join(scriptsDir, d)).isDirectory();
|
|
31153
30952
|
} catch {
|
|
31154
30953
|
return false;
|
|
31155
30954
|
}
|
|
31156
30955
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
31157
30956
|
if (versions.length === 0) return null;
|
|
31158
|
-
return
|
|
30957
|
+
return path13.join(scriptsDir, versions[0]);
|
|
31159
30958
|
}
|
|
31160
30959
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
31161
|
-
const canonicalUserDir =
|
|
31162
|
-
const desiredDir = requestedDir ?
|
|
31163
|
-
const upstreamRoot =
|
|
31164
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
30960
|
+
const canonicalUserDir = path13.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
30961
|
+
const desiredDir = requestedDir ? path13.resolve(requestedDir) : canonicalUserDir;
|
|
30962
|
+
const upstreamRoot = path13.resolve(ctx.providerLoader.getUpstreamDir());
|
|
30963
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path13.sep}`)) {
|
|
31165
30964
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
31166
30965
|
}
|
|
31167
|
-
if (
|
|
30966
|
+
if (path13.basename(desiredDir) !== type) {
|
|
31168
30967
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
31169
30968
|
}
|
|
31170
30969
|
const sourceDir = ctx.findProviderDir(type);
|
|
@@ -31172,11 +30971,11 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
31172
30971
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
31173
30972
|
}
|
|
31174
30973
|
if (!fs10.existsSync(desiredDir)) {
|
|
31175
|
-
fs10.mkdirSync(
|
|
30974
|
+
fs10.mkdirSync(path13.dirname(desiredDir), { recursive: true });
|
|
31176
30975
|
fs10.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
31177
30976
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
31178
30977
|
}
|
|
31179
|
-
const providerJson =
|
|
30978
|
+
const providerJson = path13.join(desiredDir, "provider.json");
|
|
31180
30979
|
if (!fs10.existsSync(providerJson)) {
|
|
31181
30980
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
31182
30981
|
}
|
|
@@ -31199,13 +30998,13 @@ function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
|
31199
30998
|
const refDir = ctx.findProviderDir(referenceType);
|
|
31200
30999
|
if (!refDir || !fs10.existsSync(refDir)) return {};
|
|
31201
31000
|
const referenceScripts = {};
|
|
31202
|
-
const scriptsDir =
|
|
31001
|
+
const scriptsDir = path13.join(refDir, "scripts");
|
|
31203
31002
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
31204
31003
|
if (!latestDir) return referenceScripts;
|
|
31205
31004
|
for (const file2 of fs10.readdirSync(latestDir)) {
|
|
31206
31005
|
if (!file2.endsWith(".js")) continue;
|
|
31207
31006
|
try {
|
|
31208
|
-
referenceScripts[file2] = fs10.readFileSync(
|
|
31007
|
+
referenceScripts[file2] = fs10.readFileSync(path13.join(latestDir, file2), "utf-8");
|
|
31209
31008
|
} catch {
|
|
31210
31009
|
}
|
|
31211
31010
|
}
|
|
@@ -31256,9 +31055,9 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
31256
31055
|
});
|
|
31257
31056
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
31258
31057
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference);
|
|
31259
|
-
const tmpDir =
|
|
31058
|
+
const tmpDir = path13.join(os15.tmpdir(), "adhdev-autoimpl");
|
|
31260
31059
|
if (!fs10.existsSync(tmpDir)) fs10.mkdirSync(tmpDir, { recursive: true });
|
|
31261
|
-
const promptFile =
|
|
31060
|
+
const promptFile = path13.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
31262
31061
|
fs10.writeFileSync(promptFile, prompt, "utf-8");
|
|
31263
31062
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
31264
31063
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
@@ -31629,7 +31428,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
31629
31428
|
setMode: "set_mode.js"
|
|
31630
31429
|
};
|
|
31631
31430
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
31632
|
-
const scriptsDir =
|
|
31431
|
+
const scriptsDir = path13.join(providerDir, "scripts");
|
|
31633
31432
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
31634
31433
|
if (latestScriptsDir) {
|
|
31635
31434
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -31640,7 +31439,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
31640
31439
|
for (const file2 of fs10.readdirSync(latestScriptsDir)) {
|
|
31641
31440
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
31642
31441
|
try {
|
|
31643
|
-
const content = fs10.readFileSync(
|
|
31442
|
+
const content = fs10.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
|
|
31644
31443
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
31645
31444
|
lines.push("```javascript");
|
|
31646
31445
|
lines.push(content);
|
|
@@ -31657,7 +31456,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
31657
31456
|
lines.push("");
|
|
31658
31457
|
for (const file2 of refFiles) {
|
|
31659
31458
|
try {
|
|
31660
|
-
const content = fs10.readFileSync(
|
|
31459
|
+
const content = fs10.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
|
|
31661
31460
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
31662
31461
|
lines.push("```javascript");
|
|
31663
31462
|
lines.push(content);
|
|
@@ -31698,10 +31497,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
31698
31497
|
lines.push("");
|
|
31699
31498
|
}
|
|
31700
31499
|
}
|
|
31701
|
-
const docsDir =
|
|
31500
|
+
const docsDir = path13.join(providerDir, "../../docs");
|
|
31702
31501
|
const loadGuide = (name) => {
|
|
31703
31502
|
try {
|
|
31704
|
-
const p =
|
|
31503
|
+
const p = path13.join(docsDir, name);
|
|
31705
31504
|
if (fs10.existsSync(p)) return fs10.readFileSync(p, "utf-8");
|
|
31706
31505
|
} catch {
|
|
31707
31506
|
}
|
|
@@ -31875,7 +31674,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
31875
31674
|
parseApproval: "parse_approval.js"
|
|
31876
31675
|
};
|
|
31877
31676
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
31878
|
-
const scriptsDir =
|
|
31677
|
+
const scriptsDir = path13.join(providerDir, "scripts");
|
|
31879
31678
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
31880
31679
|
if (latestScriptsDir) {
|
|
31881
31680
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -31887,7 +31686,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
31887
31686
|
if (!file2.endsWith(".js")) continue;
|
|
31888
31687
|
if (!targetFileNames.has(file2)) continue;
|
|
31889
31688
|
try {
|
|
31890
|
-
const content = fs10.readFileSync(
|
|
31689
|
+
const content = fs10.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
|
|
31891
31690
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
31892
31691
|
lines.push("```javascript");
|
|
31893
31692
|
lines.push(content);
|
|
@@ -31903,7 +31702,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
31903
31702
|
lines.push("");
|
|
31904
31703
|
for (const file2 of refFiles) {
|
|
31905
31704
|
try {
|
|
31906
|
-
const content = fs10.readFileSync(
|
|
31705
|
+
const content = fs10.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
|
|
31907
31706
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
31908
31707
|
lines.push("```javascript");
|
|
31909
31708
|
lines.push(content);
|
|
@@ -31936,10 +31735,10 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
31936
31735
|
lines.push("");
|
|
31937
31736
|
}
|
|
31938
31737
|
}
|
|
31939
|
-
const docsDir =
|
|
31738
|
+
const docsDir = path13.join(providerDir, "../../docs");
|
|
31940
31739
|
const loadGuide = (name) => {
|
|
31941
31740
|
try {
|
|
31942
|
-
const p =
|
|
31741
|
+
const p = path13.join(docsDir, name);
|
|
31943
31742
|
if (fs10.existsSync(p)) return fs10.readFileSync(p, "utf-8");
|
|
31944
31743
|
} catch {
|
|
31945
31744
|
}
|
|
@@ -32195,8 +31994,8 @@ var DevServer = class _DevServer {
|
|
|
32195
31994
|
}
|
|
32196
31995
|
getEndpointList() {
|
|
32197
31996
|
return this.routes.map((r) => {
|
|
32198
|
-
const
|
|
32199
|
-
return `${r.method.padEnd(5)} ${
|
|
31997
|
+
const path152 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
31998
|
+
return `${r.method.padEnd(5)} ${path152}`;
|
|
32200
31999
|
});
|
|
32201
32000
|
}
|
|
32202
32001
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -32227,15 +32026,15 @@ var DevServer = class _DevServer {
|
|
|
32227
32026
|
this.json(res, 500, { error: e.message });
|
|
32228
32027
|
}
|
|
32229
32028
|
});
|
|
32230
|
-
return new Promise((
|
|
32029
|
+
return new Promise((resolve92, reject) => {
|
|
32231
32030
|
this.server.listen(port, "127.0.0.1", () => {
|
|
32232
32031
|
this.log(`Dev server listening on http://127.0.0.1:${port}`);
|
|
32233
|
-
|
|
32032
|
+
resolve92();
|
|
32234
32033
|
});
|
|
32235
32034
|
this.server.on("error", (e) => {
|
|
32236
32035
|
if (e.code === "EADDRINUSE") {
|
|
32237
32036
|
this.log(`Port ${port} in use, skipping dev server`);
|
|
32238
|
-
|
|
32037
|
+
resolve92();
|
|
32239
32038
|
} else {
|
|
32240
32039
|
reject(e);
|
|
32241
32040
|
}
|
|
@@ -32318,20 +32117,20 @@ var DevServer = class _DevServer {
|
|
|
32318
32117
|
child.stderr?.on("data", (d) => {
|
|
32319
32118
|
stderr += d.toString().slice(0, 2e3);
|
|
32320
32119
|
});
|
|
32321
|
-
await new Promise((
|
|
32120
|
+
await new Promise((resolve92) => {
|
|
32322
32121
|
const timer = setTimeout(() => {
|
|
32323
32122
|
child.kill();
|
|
32324
|
-
|
|
32123
|
+
resolve92();
|
|
32325
32124
|
}, 3e3);
|
|
32326
32125
|
child.on("exit", () => {
|
|
32327
32126
|
clearTimeout(timer);
|
|
32328
|
-
|
|
32127
|
+
resolve92();
|
|
32329
32128
|
});
|
|
32330
32129
|
child.stdout?.once("data", () => {
|
|
32331
32130
|
setTimeout(() => {
|
|
32332
32131
|
child.kill();
|
|
32333
32132
|
clearTimeout(timer);
|
|
32334
|
-
|
|
32133
|
+
resolve92();
|
|
32335
32134
|
}, 500);
|
|
32336
32135
|
});
|
|
32337
32136
|
});
|
|
@@ -32478,12 +32277,12 @@ var DevServer = class _DevServer {
|
|
|
32478
32277
|
// ─── DevConsole SPA ───
|
|
32479
32278
|
getConsoleDistDir() {
|
|
32480
32279
|
const candidates = [
|
|
32481
|
-
|
|
32482
|
-
|
|
32483
|
-
|
|
32280
|
+
path14.resolve(__dirname, "../../web-devconsole/dist"),
|
|
32281
|
+
path14.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
32282
|
+
path14.join(process.cwd(), "packages/web-devconsole/dist")
|
|
32484
32283
|
];
|
|
32485
32284
|
for (const dir of candidates) {
|
|
32486
|
-
if (fs11.existsSync(
|
|
32285
|
+
if (fs11.existsSync(path14.join(dir, "index.html"))) return dir;
|
|
32487
32286
|
}
|
|
32488
32287
|
return null;
|
|
32489
32288
|
}
|
|
@@ -32493,7 +32292,7 @@ var DevServer = class _DevServer {
|
|
|
32493
32292
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
32494
32293
|
return;
|
|
32495
32294
|
}
|
|
32496
|
-
const htmlPath =
|
|
32295
|
+
const htmlPath = path14.join(distDir, "index.html");
|
|
32497
32296
|
try {
|
|
32498
32297
|
const html = fs11.readFileSync(htmlPath, "utf-8");
|
|
32499
32298
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
@@ -32518,15 +32317,15 @@ var DevServer = class _DevServer {
|
|
|
32518
32317
|
this.json(res, 404, { error: "Not found" });
|
|
32519
32318
|
return;
|
|
32520
32319
|
}
|
|
32521
|
-
const safePath =
|
|
32522
|
-
const filePath =
|
|
32320
|
+
const safePath = path14.normalize(pathname).replace(/^\.\.\//, "");
|
|
32321
|
+
const filePath = path14.join(distDir, safePath);
|
|
32523
32322
|
if (!filePath.startsWith(distDir)) {
|
|
32524
32323
|
this.json(res, 403, { error: "Forbidden" });
|
|
32525
32324
|
return;
|
|
32526
32325
|
}
|
|
32527
32326
|
try {
|
|
32528
32327
|
const content = fs11.readFileSync(filePath);
|
|
32529
|
-
const ext =
|
|
32328
|
+
const ext = path14.extname(filePath);
|
|
32530
32329
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
32531
32330
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
32532
32331
|
res.end(content);
|
|
@@ -32639,9 +32438,9 @@ var DevServer = class _DevServer {
|
|
|
32639
32438
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
32640
32439
|
if (entry.isDirectory()) {
|
|
32641
32440
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
32642
|
-
scan(
|
|
32441
|
+
scan(path14.join(d, entry.name), rel);
|
|
32643
32442
|
} else {
|
|
32644
|
-
const stat4 = fs11.statSync(
|
|
32443
|
+
const stat4 = fs11.statSync(path14.join(d, entry.name));
|
|
32645
32444
|
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
32646
32445
|
}
|
|
32647
32446
|
}
|
|
@@ -32664,7 +32463,7 @@ var DevServer = class _DevServer {
|
|
|
32664
32463
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
32665
32464
|
return;
|
|
32666
32465
|
}
|
|
32667
|
-
const fullPath =
|
|
32466
|
+
const fullPath = path14.resolve(dir, path14.normalize(filePath));
|
|
32668
32467
|
if (!fullPath.startsWith(dir)) {
|
|
32669
32468
|
this.json(res, 403, { error: "Forbidden" });
|
|
32670
32469
|
return;
|
|
@@ -32689,14 +32488,14 @@ var DevServer = class _DevServer {
|
|
|
32689
32488
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
32690
32489
|
return;
|
|
32691
32490
|
}
|
|
32692
|
-
const fullPath =
|
|
32491
|
+
const fullPath = path14.resolve(dir, path14.normalize(filePath));
|
|
32693
32492
|
if (!fullPath.startsWith(dir)) {
|
|
32694
32493
|
this.json(res, 403, { error: "Forbidden" });
|
|
32695
32494
|
return;
|
|
32696
32495
|
}
|
|
32697
32496
|
try {
|
|
32698
32497
|
if (fs11.existsSync(fullPath)) fs11.copyFileSync(fullPath, fullPath + ".bak");
|
|
32699
|
-
fs11.mkdirSync(
|
|
32498
|
+
fs11.mkdirSync(path14.dirname(fullPath), { recursive: true });
|
|
32700
32499
|
fs11.writeFileSync(fullPath, content, "utf-8");
|
|
32701
32500
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
32702
32501
|
this.providerLoader.reload();
|
|
@@ -32713,7 +32512,7 @@ var DevServer = class _DevServer {
|
|
|
32713
32512
|
return;
|
|
32714
32513
|
}
|
|
32715
32514
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
32716
|
-
const p =
|
|
32515
|
+
const p = path14.join(dir, name);
|
|
32717
32516
|
if (fs11.existsSync(p)) {
|
|
32718
32517
|
const source = fs11.readFileSync(p, "utf-8");
|
|
32719
32518
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
@@ -32734,8 +32533,8 @@ var DevServer = class _DevServer {
|
|
|
32734
32533
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
32735
32534
|
return;
|
|
32736
32535
|
}
|
|
32737
|
-
const target = fs11.existsSync(
|
|
32738
|
-
const targetPath =
|
|
32536
|
+
const target = fs11.existsSync(path14.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
32537
|
+
const targetPath = path14.join(dir, target);
|
|
32739
32538
|
try {
|
|
32740
32539
|
if (fs11.existsSync(targetPath)) fs11.copyFileSync(targetPath, targetPath + ".bak");
|
|
32741
32540
|
fs11.writeFileSync(targetPath, source, "utf-8");
|
|
@@ -32840,14 +32639,14 @@ var DevServer = class _DevServer {
|
|
|
32840
32639
|
child.stderr?.on("data", (d) => {
|
|
32841
32640
|
stderr += d.toString();
|
|
32842
32641
|
});
|
|
32843
|
-
await new Promise((
|
|
32642
|
+
await new Promise((resolve92) => {
|
|
32844
32643
|
const timer = setTimeout(() => {
|
|
32845
32644
|
child.kill();
|
|
32846
|
-
|
|
32645
|
+
resolve92();
|
|
32847
32646
|
}, timeout);
|
|
32848
32647
|
child.on("exit", () => {
|
|
32849
32648
|
clearTimeout(timer);
|
|
32850
|
-
|
|
32649
|
+
resolve92();
|
|
32851
32650
|
});
|
|
32852
32651
|
});
|
|
32853
32652
|
const elapsed = Date.now() - start;
|
|
@@ -32895,7 +32694,7 @@ var DevServer = class _DevServer {
|
|
|
32895
32694
|
}
|
|
32896
32695
|
let targetDir;
|
|
32897
32696
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
32898
|
-
const jsonPath =
|
|
32697
|
+
const jsonPath = path14.join(targetDir, "provider.json");
|
|
32899
32698
|
if (fs11.existsSync(jsonPath)) {
|
|
32900
32699
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
32901
32700
|
return;
|
|
@@ -32907,8 +32706,8 @@ var DevServer = class _DevServer {
|
|
|
32907
32706
|
const createdFiles = ["provider.json"];
|
|
32908
32707
|
if (result.files) {
|
|
32909
32708
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
32910
|
-
const fullPath =
|
|
32911
|
-
fs11.mkdirSync(
|
|
32709
|
+
const fullPath = path14.join(targetDir, relPath);
|
|
32710
|
+
fs11.mkdirSync(path14.dirname(fullPath), { recursive: true });
|
|
32912
32711
|
fs11.writeFileSync(fullPath, content, "utf-8");
|
|
32913
32712
|
createdFiles.push(relPath);
|
|
32914
32713
|
}
|
|
@@ -32961,22 +32760,22 @@ var DevServer = class _DevServer {
|
|
|
32961
32760
|
if (!fs11.existsSync(scriptsDir)) return null;
|
|
32962
32761
|
const versions = fs11.readdirSync(scriptsDir).filter((d) => {
|
|
32963
32762
|
try {
|
|
32964
|
-
return fs11.statSync(
|
|
32763
|
+
return fs11.statSync(path14.join(scriptsDir, d)).isDirectory();
|
|
32965
32764
|
} catch {
|
|
32966
32765
|
return false;
|
|
32967
32766
|
}
|
|
32968
32767
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
32969
32768
|
if (versions.length === 0) return null;
|
|
32970
|
-
return
|
|
32769
|
+
return path14.join(scriptsDir, versions[0]);
|
|
32971
32770
|
}
|
|
32972
32771
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
32973
|
-
const canonicalUserDir =
|
|
32974
|
-
const desiredDir = requestedDir ?
|
|
32975
|
-
const upstreamRoot =
|
|
32976
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
32772
|
+
const canonicalUserDir = path14.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
32773
|
+
const desiredDir = requestedDir ? path14.resolve(requestedDir) : canonicalUserDir;
|
|
32774
|
+
const upstreamRoot = path14.resolve(this.providerLoader.getUpstreamDir());
|
|
32775
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path14.sep}`)) {
|
|
32977
32776
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
32978
32777
|
}
|
|
32979
|
-
if (
|
|
32778
|
+
if (path14.basename(desiredDir) !== type) {
|
|
32980
32779
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
32981
32780
|
}
|
|
32982
32781
|
const sourceDir = this.findProviderDir(type);
|
|
@@ -32984,11 +32783,11 @@ var DevServer = class _DevServer {
|
|
|
32984
32783
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
32985
32784
|
}
|
|
32986
32785
|
if (!fs11.existsSync(desiredDir)) {
|
|
32987
|
-
fs11.mkdirSync(
|
|
32786
|
+
fs11.mkdirSync(path14.dirname(desiredDir), { recursive: true });
|
|
32988
32787
|
fs11.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
32989
32788
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
32990
32789
|
}
|
|
32991
|
-
const providerJson =
|
|
32790
|
+
const providerJson = path14.join(desiredDir, "provider.json");
|
|
32992
32791
|
if (!fs11.existsSync(providerJson)) {
|
|
32993
32792
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
32994
32793
|
}
|
|
@@ -33036,7 +32835,7 @@ var DevServer = class _DevServer {
|
|
|
33036
32835
|
setMode: "set_mode.js"
|
|
33037
32836
|
};
|
|
33038
32837
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
33039
|
-
const scriptsDir =
|
|
32838
|
+
const scriptsDir = path14.join(providerDir, "scripts");
|
|
33040
32839
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
33041
32840
|
if (latestScriptsDir) {
|
|
33042
32841
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -33047,7 +32846,7 @@ var DevServer = class _DevServer {
|
|
|
33047
32846
|
for (const file2 of fs11.readdirSync(latestScriptsDir)) {
|
|
33048
32847
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
33049
32848
|
try {
|
|
33050
|
-
const content = fs11.readFileSync(
|
|
32849
|
+
const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
33051
32850
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
33052
32851
|
lines.push("```javascript");
|
|
33053
32852
|
lines.push(content);
|
|
@@ -33064,7 +32863,7 @@ var DevServer = class _DevServer {
|
|
|
33064
32863
|
lines.push("");
|
|
33065
32864
|
for (const file2 of refFiles) {
|
|
33066
32865
|
try {
|
|
33067
|
-
const content = fs11.readFileSync(
|
|
32866
|
+
const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
33068
32867
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
33069
32868
|
lines.push("```javascript");
|
|
33070
32869
|
lines.push(content);
|
|
@@ -33105,10 +32904,10 @@ var DevServer = class _DevServer {
|
|
|
33105
32904
|
lines.push("");
|
|
33106
32905
|
}
|
|
33107
32906
|
}
|
|
33108
|
-
const docsDir =
|
|
32907
|
+
const docsDir = path14.join(providerDir, "../../docs");
|
|
33109
32908
|
const loadGuide = (name) => {
|
|
33110
32909
|
try {
|
|
33111
|
-
const p =
|
|
32910
|
+
const p = path14.join(docsDir, name);
|
|
33112
32911
|
if (fs11.existsSync(p)) return fs11.readFileSync(p, "utf-8");
|
|
33113
32912
|
} catch {
|
|
33114
32913
|
}
|
|
@@ -33282,7 +33081,7 @@ var DevServer = class _DevServer {
|
|
|
33282
33081
|
parseApproval: "parse_approval.js"
|
|
33283
33082
|
};
|
|
33284
33083
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
33285
|
-
const scriptsDir =
|
|
33084
|
+
const scriptsDir = path14.join(providerDir, "scripts");
|
|
33286
33085
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
33287
33086
|
if (latestScriptsDir) {
|
|
33288
33087
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -33294,7 +33093,7 @@ var DevServer = class _DevServer {
|
|
|
33294
33093
|
if (!file2.endsWith(".js")) continue;
|
|
33295
33094
|
if (!targetFileNames.has(file2)) continue;
|
|
33296
33095
|
try {
|
|
33297
|
-
const content = fs11.readFileSync(
|
|
33096
|
+
const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
33298
33097
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
33299
33098
|
lines.push("```javascript");
|
|
33300
33099
|
lines.push(content);
|
|
@@ -33310,7 +33109,7 @@ var DevServer = class _DevServer {
|
|
|
33310
33109
|
lines.push("");
|
|
33311
33110
|
for (const file2 of refFiles) {
|
|
33312
33111
|
try {
|
|
33313
|
-
const content = fs11.readFileSync(
|
|
33112
|
+
const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
33314
33113
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
33315
33114
|
lines.push("```javascript");
|
|
33316
33115
|
lines.push(content);
|
|
@@ -33343,10 +33142,10 @@ var DevServer = class _DevServer {
|
|
|
33343
33142
|
lines.push("");
|
|
33344
33143
|
}
|
|
33345
33144
|
}
|
|
33346
|
-
const docsDir =
|
|
33145
|
+
const docsDir = path14.join(providerDir, "../../docs");
|
|
33347
33146
|
const loadGuide = (name) => {
|
|
33348
33147
|
try {
|
|
33349
|
-
const p =
|
|
33148
|
+
const p = path14.join(docsDir, name);
|
|
33350
33149
|
if (fs11.existsSync(p)) return fs11.readFileSync(p, "utf-8");
|
|
33351
33150
|
} catch {
|
|
33352
33151
|
}
|
|
@@ -33503,14 +33302,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
33503
33302
|
res.end(JSON.stringify(data, null, 2));
|
|
33504
33303
|
}
|
|
33505
33304
|
async readBody(req) {
|
|
33506
|
-
return new Promise((
|
|
33305
|
+
return new Promise((resolve92) => {
|
|
33507
33306
|
let body = "";
|
|
33508
33307
|
req.on("data", (chunk) => body += chunk);
|
|
33509
33308
|
req.on("end", () => {
|
|
33510
33309
|
try {
|
|
33511
|
-
|
|
33310
|
+
resolve92(JSON.parse(body));
|
|
33512
33311
|
} catch {
|
|
33513
|
-
|
|
33312
|
+
resolve92({});
|
|
33514
33313
|
}
|
|
33515
33314
|
});
|
|
33516
33315
|
});
|
|
@@ -33919,7 +33718,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
|
|
|
33919
33718
|
const deadline = Date.now() + timeoutMs;
|
|
33920
33719
|
while (Date.now() < deadline) {
|
|
33921
33720
|
if (await canConnect(endpoint)) return;
|
|
33922
|
-
await new Promise((
|
|
33721
|
+
await new Promise((resolve92) => setTimeout(resolve92, STARTUP_POLL_MS));
|
|
33923
33722
|
}
|
|
33924
33723
|
throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
|
|
33925
33724
|
}
|
|
@@ -34201,12 +34000,12 @@ async function shutdownDaemonComponents(components) {
|
|
|
34201
34000
|
|
|
34202
34001
|
// src/session-host.ts
|
|
34203
34002
|
var import_child_process8 = require("child_process");
|
|
34204
|
-
var
|
|
34003
|
+
var path15 = __toESM(require("path"));
|
|
34205
34004
|
var SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
|
|
34206
34005
|
function resolveSessionHostEntry() {
|
|
34207
34006
|
const localCandidates = [
|
|
34208
|
-
|
|
34209
|
-
|
|
34007
|
+
path15.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
34008
|
+
path15.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
34210
34009
|
];
|
|
34211
34010
|
for (const candidate of localCandidates) {
|
|
34212
34011
|
if (require("fs").existsSync(candidate)) {
|
|
@@ -34224,9 +34023,9 @@ async function runSessionHostCli(args) {
|
|
|
34224
34023
|
ADHDEV_SESSION_HOST_NAME: SESSION_HOST_APP_NAME
|
|
34225
34024
|
}
|
|
34226
34025
|
});
|
|
34227
|
-
return await new Promise((
|
|
34026
|
+
return await new Promise((resolve12, reject) => {
|
|
34228
34027
|
child.on("error", reject);
|
|
34229
|
-
child.on("exit", (code) =>
|
|
34028
|
+
child.on("exit", (code) => resolve12(code ?? 0));
|
|
34230
34029
|
});
|
|
34231
34030
|
}
|
|
34232
34031
|
async function ensureSessionHostReady2() {
|
|
@@ -34333,8 +34132,8 @@ var AdhMuxControlClient = class {
|
|
|
34333
34132
|
}
|
|
34334
34133
|
this.waiters.clear();
|
|
34335
34134
|
});
|
|
34336
|
-
await new Promise((
|
|
34337
|
-
socket.once("connect", () =>
|
|
34135
|
+
await new Promise((resolve12, reject) => {
|
|
34136
|
+
socket.once("connect", () => resolve12());
|
|
34338
34137
|
socket.once("error", reject);
|
|
34339
34138
|
});
|
|
34340
34139
|
}
|
|
@@ -34343,8 +34142,8 @@ var AdhMuxControlClient = class {
|
|
|
34343
34142
|
if (!this.socket) throw new Error("adhmux control socket unavailable");
|
|
34344
34143
|
const requestId = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
34345
34144
|
const envelope = { kind: "request", requestId, request };
|
|
34346
|
-
const response = await new Promise((
|
|
34347
|
-
this.waiters.set(requestId, { resolve:
|
|
34145
|
+
const response = await new Promise((resolve12, reject) => {
|
|
34146
|
+
this.waiters.set(requestId, { resolve: resolve12, reject });
|
|
34348
34147
|
this.socket?.write(serializeEnvelope2(envelope));
|
|
34349
34148
|
});
|
|
34350
34149
|
return response;
|
|
@@ -34363,12 +34162,12 @@ var AdhMuxControlClient = class {
|
|
|
34363
34162
|
waiter.reject(new Error("adhmux control client closed"));
|
|
34364
34163
|
}
|
|
34365
34164
|
this.waiters.clear();
|
|
34366
|
-
await new Promise((
|
|
34165
|
+
await new Promise((resolve12) => {
|
|
34367
34166
|
let settled = false;
|
|
34368
34167
|
const done = () => {
|
|
34369
34168
|
if (settled) return;
|
|
34370
34169
|
settled = true;
|
|
34371
|
-
|
|
34170
|
+
resolve12();
|
|
34372
34171
|
};
|
|
34373
34172
|
socket.once("close", done);
|
|
34374
34173
|
socket.end();
|
|
@@ -34426,8 +34225,8 @@ var pkgVersion = process.env.ADHDEV_PKG_VERSION || "unknown";
|
|
|
34426
34225
|
if (pkgVersion === "unknown") {
|
|
34427
34226
|
try {
|
|
34428
34227
|
const possiblePaths = [
|
|
34429
|
-
|
|
34430
|
-
|
|
34228
|
+
path17.join(__dirname, "..", "package.json"),
|
|
34229
|
+
path17.join(__dirname, "package.json")
|
|
34431
34230
|
];
|
|
34432
34231
|
for (const candidate of possiblePaths) {
|
|
34433
34232
|
try {
|
|
@@ -34563,9 +34362,9 @@ var StandaloneServer = class {
|
|
|
34563
34362
|
this.scheduleBroadcastStatus();
|
|
34564
34363
|
}, STATUS_INTERVAL);
|
|
34565
34364
|
this.running = true;
|
|
34566
|
-
await new Promise((
|
|
34365
|
+
await new Promise((resolve12) => {
|
|
34567
34366
|
this.httpServer.listen(port, host, () => {
|
|
34568
|
-
|
|
34367
|
+
resolve12();
|
|
34569
34368
|
});
|
|
34570
34369
|
});
|
|
34571
34370
|
console.log("");
|
|
@@ -34759,9 +34558,9 @@ var StandaloneServer = class {
|
|
|
34759
34558
|
}
|
|
34760
34559
|
if (publicDir) {
|
|
34761
34560
|
const filePath = url2 === "/" ? "/index.html" : url2;
|
|
34762
|
-
const fullPath =
|
|
34561
|
+
const fullPath = path17.join(publicDir, filePath);
|
|
34763
34562
|
if (fs12.existsSync(fullPath) && fs12.statSync(fullPath).isFile()) {
|
|
34764
|
-
const ext =
|
|
34563
|
+
const ext = path17.extname(fullPath);
|
|
34765
34564
|
const mimeTypes = {
|
|
34766
34565
|
".html": "text/html",
|
|
34767
34566
|
".js": "application/javascript",
|
|
@@ -34776,7 +34575,7 @@ var StandaloneServer = class {
|
|
|
34776
34575
|
fs12.createReadStream(fullPath).pipe(res);
|
|
34777
34576
|
return;
|
|
34778
34577
|
}
|
|
34779
|
-
const indexPath =
|
|
34578
|
+
const indexPath = path17.join(publicDir, "index.html");
|
|
34780
34579
|
if (fs12.existsSync(indexPath) && !url2.startsWith("/api/")) {
|
|
34781
34580
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
34782
34581
|
fs12.createReadStream(indexPath).pipe(res);
|
|
@@ -35124,12 +34923,12 @@ Runtime commands:
|
|
|
35124
34923
|
}
|
|
35125
34924
|
if (!options.publicDir) {
|
|
35126
34925
|
const candidates = [
|
|
35127
|
-
|
|
35128
|
-
|
|
35129
|
-
|
|
34926
|
+
path17.join(__dirname, "../../web-standalone/dist"),
|
|
34927
|
+
path17.join(__dirname, "../public"),
|
|
34928
|
+
path17.join(process.cwd(), "public")
|
|
35130
34929
|
];
|
|
35131
34930
|
for (const candidate of candidates) {
|
|
35132
|
-
if (fs12.existsSync(
|
|
34931
|
+
if (fs12.existsSync(path17.join(candidate, "index.html"))) {
|
|
35133
34932
|
options.publicDir = candidate;
|
|
35134
34933
|
break;
|
|
35135
34934
|
}
|