adhdev 0.7.43 → 0.7.45
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/cli/index.js +726 -520
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +96 -65
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/vendor/session-host-daemon/index.js +2 -2
- package/vendor/session-host-daemon/index.js.map +1 -1
- package/vendor/session-host-daemon/index.mjs +2 -2
- package/vendor/session-host-daemon/index.mjs.map +1 -1
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.js +2 -2
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.js.map +1 -1
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.mjs +2 -2
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.mjs.map +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -508,18 +508,18 @@ function checkPathExists(paths) {
|
|
|
508
508
|
return null;
|
|
509
509
|
}
|
|
510
510
|
async function detectIDEs() {
|
|
511
|
-
const
|
|
511
|
+
const os22 = (0, import_os2.platform)();
|
|
512
512
|
const results = [];
|
|
513
513
|
for (const def of getMergedDefinitions()) {
|
|
514
514
|
const cliPath = findCliCommand(def.cli);
|
|
515
|
-
const appPath = checkPathExists(def.paths[
|
|
515
|
+
const appPath = checkPathExists(def.paths[os22] || []);
|
|
516
516
|
const installed = !!(cliPath || appPath);
|
|
517
517
|
let resolvedCli = cliPath;
|
|
518
|
-
if (!resolvedCli && appPath &&
|
|
518
|
+
if (!resolvedCli && appPath && os22 === "darwin") {
|
|
519
519
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
520
520
|
if ((0, import_fs2.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
521
521
|
}
|
|
522
|
-
if (!resolvedCli && appPath &&
|
|
522
|
+
if (!resolvedCli && appPath && os22 === "win32") {
|
|
523
523
|
const { dirname: dirname10 } = await import("path");
|
|
524
524
|
const appDir = dirname10(appPath);
|
|
525
525
|
const candidates = [
|
|
@@ -5810,7 +5810,7 @@ var init_readdirp = __esm({
|
|
|
5810
5810
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
5811
5811
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
5812
5812
|
if (wantBigintFsStats) {
|
|
5813
|
-
this._stat = (
|
|
5813
|
+
this._stat = (path19) => statMethod(path19, { bigint: true });
|
|
5814
5814
|
} else {
|
|
5815
5815
|
this._stat = statMethod;
|
|
5816
5816
|
}
|
|
@@ -5835,8 +5835,8 @@ var init_readdirp = __esm({
|
|
|
5835
5835
|
const par = this.parent;
|
|
5836
5836
|
const fil = par && par.files;
|
|
5837
5837
|
if (fil && fil.length > 0) {
|
|
5838
|
-
const { path:
|
|
5839
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
5838
|
+
const { path: path19, depth } = par;
|
|
5839
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path19));
|
|
5840
5840
|
const awaited = await Promise.all(slice);
|
|
5841
5841
|
for (const entry of awaited) {
|
|
5842
5842
|
if (!entry)
|
|
@@ -5876,20 +5876,20 @@ var init_readdirp = __esm({
|
|
|
5876
5876
|
this.reading = false;
|
|
5877
5877
|
}
|
|
5878
5878
|
}
|
|
5879
|
-
async _exploreDir(
|
|
5879
|
+
async _exploreDir(path19, depth) {
|
|
5880
5880
|
let files;
|
|
5881
5881
|
try {
|
|
5882
|
-
files = await (0, import_promises.readdir)(
|
|
5882
|
+
files = await (0, import_promises.readdir)(path19, this._rdOptions);
|
|
5883
5883
|
} catch (error48) {
|
|
5884
5884
|
this._onError(error48);
|
|
5885
5885
|
}
|
|
5886
|
-
return { files, depth, path:
|
|
5886
|
+
return { files, depth, path: path19 };
|
|
5887
5887
|
}
|
|
5888
|
-
async _formatEntry(dirent,
|
|
5888
|
+
async _formatEntry(dirent, path19) {
|
|
5889
5889
|
let entry;
|
|
5890
5890
|
const basename7 = this._isDirent ? dirent.name : dirent;
|
|
5891
5891
|
try {
|
|
5892
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
5892
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path19, basename7));
|
|
5893
5893
|
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename7 };
|
|
5894
5894
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
5895
5895
|
} catch (err) {
|
|
@@ -5946,16 +5946,16 @@ var init_readdirp = __esm({
|
|
|
5946
5946
|
});
|
|
5947
5947
|
|
|
5948
5948
|
// ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
|
|
5949
|
-
function createFsWatchInstance(
|
|
5949
|
+
function createFsWatchInstance(path19, options, listener, errHandler, emitRaw) {
|
|
5950
5950
|
const handleEvent = (rawEvent, evPath) => {
|
|
5951
|
-
listener(
|
|
5952
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
5953
|
-
if (evPath &&
|
|
5954
|
-
fsWatchBroadcast(sp.resolve(
|
|
5951
|
+
listener(path19);
|
|
5952
|
+
emitRaw(rawEvent, evPath, { watchedPath: path19 });
|
|
5953
|
+
if (evPath && path19 !== evPath) {
|
|
5954
|
+
fsWatchBroadcast(sp.resolve(path19, evPath), KEY_LISTENERS, sp.join(path19, evPath));
|
|
5955
5955
|
}
|
|
5956
5956
|
};
|
|
5957
5957
|
try {
|
|
5958
|
-
return (0, import_node_fs.watch)(
|
|
5958
|
+
return (0, import_node_fs.watch)(path19, {
|
|
5959
5959
|
persistent: options.persistent
|
|
5960
5960
|
}, handleEvent);
|
|
5961
5961
|
} catch (error48) {
|
|
@@ -6304,12 +6304,12 @@ var init_handler2 = __esm({
|
|
|
6304
6304
|
listener(val1, val2, val3);
|
|
6305
6305
|
});
|
|
6306
6306
|
};
|
|
6307
|
-
setFsWatchListener = (
|
|
6307
|
+
setFsWatchListener = (path19, fullPath, options, handlers) => {
|
|
6308
6308
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
6309
6309
|
let cont = FsWatchInstances.get(fullPath);
|
|
6310
6310
|
let watcher;
|
|
6311
6311
|
if (!options.persistent) {
|
|
6312
|
-
watcher = createFsWatchInstance(
|
|
6312
|
+
watcher = createFsWatchInstance(path19, options, listener, errHandler, rawEmitter);
|
|
6313
6313
|
if (!watcher)
|
|
6314
6314
|
return;
|
|
6315
6315
|
return watcher.close.bind(watcher);
|
|
@@ -6320,7 +6320,7 @@ var init_handler2 = __esm({
|
|
|
6320
6320
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
6321
6321
|
} else {
|
|
6322
6322
|
watcher = createFsWatchInstance(
|
|
6323
|
-
|
|
6323
|
+
path19,
|
|
6324
6324
|
options,
|
|
6325
6325
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
6326
6326
|
errHandler,
|
|
@@ -6335,7 +6335,7 @@ var init_handler2 = __esm({
|
|
|
6335
6335
|
cont.watcherUnusable = true;
|
|
6336
6336
|
if (isWindows && error48.code === "EPERM") {
|
|
6337
6337
|
try {
|
|
6338
|
-
const fd = await (0, import_promises2.open)(
|
|
6338
|
+
const fd = await (0, import_promises2.open)(path19, "r");
|
|
6339
6339
|
await fd.close();
|
|
6340
6340
|
broadcastErr(error48);
|
|
6341
6341
|
} catch (err) {
|
|
@@ -6366,7 +6366,7 @@ var init_handler2 = __esm({
|
|
|
6366
6366
|
};
|
|
6367
6367
|
};
|
|
6368
6368
|
FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
6369
|
-
setFsWatchFileListener = (
|
|
6369
|
+
setFsWatchFileListener = (path19, fullPath, options, handlers) => {
|
|
6370
6370
|
const { listener, rawEmitter } = handlers;
|
|
6371
6371
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
6372
6372
|
const copts = cont && cont.options;
|
|
@@ -6388,7 +6388,7 @@ var init_handler2 = __esm({
|
|
|
6388
6388
|
});
|
|
6389
6389
|
const currmtime = curr.mtimeMs;
|
|
6390
6390
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
6391
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
6391
|
+
foreach(cont.listeners, (listener2) => listener2(path19, curr));
|
|
6392
6392
|
}
|
|
6393
6393
|
})
|
|
6394
6394
|
};
|
|
@@ -6418,13 +6418,13 @@ var init_handler2 = __esm({
|
|
|
6418
6418
|
* @param listener on fs change
|
|
6419
6419
|
* @returns closer for the watcher instance
|
|
6420
6420
|
*/
|
|
6421
|
-
_watchWithNodeFs(
|
|
6421
|
+
_watchWithNodeFs(path19, listener) {
|
|
6422
6422
|
const opts = this.fsw.options;
|
|
6423
|
-
const directory = sp.dirname(
|
|
6424
|
-
const basename7 = sp.basename(
|
|
6423
|
+
const directory = sp.dirname(path19);
|
|
6424
|
+
const basename7 = sp.basename(path19);
|
|
6425
6425
|
const parent = this.fsw._getWatchedDir(directory);
|
|
6426
6426
|
parent.add(basename7);
|
|
6427
|
-
const absolutePath = sp.resolve(
|
|
6427
|
+
const absolutePath = sp.resolve(path19);
|
|
6428
6428
|
const options = {
|
|
6429
6429
|
persistent: opts.persistent
|
|
6430
6430
|
};
|
|
@@ -6434,12 +6434,12 @@ var init_handler2 = __esm({
|
|
|
6434
6434
|
if (opts.usePolling) {
|
|
6435
6435
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
6436
6436
|
options.interval = enableBin && isBinaryPath(basename7) ? opts.binaryInterval : opts.interval;
|
|
6437
|
-
closer = setFsWatchFileListener(
|
|
6437
|
+
closer = setFsWatchFileListener(path19, absolutePath, options, {
|
|
6438
6438
|
listener,
|
|
6439
6439
|
rawEmitter: this.fsw._emitRaw
|
|
6440
6440
|
});
|
|
6441
6441
|
} else {
|
|
6442
|
-
closer = setFsWatchListener(
|
|
6442
|
+
closer = setFsWatchListener(path19, absolutePath, options, {
|
|
6443
6443
|
listener,
|
|
6444
6444
|
errHandler: this._boundHandleError,
|
|
6445
6445
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -6461,7 +6461,7 @@ var init_handler2 = __esm({
|
|
|
6461
6461
|
let prevStats = stats;
|
|
6462
6462
|
if (parent.has(basename7))
|
|
6463
6463
|
return;
|
|
6464
|
-
const listener = async (
|
|
6464
|
+
const listener = async (path19, newStats) => {
|
|
6465
6465
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
6466
6466
|
return;
|
|
6467
6467
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -6475,11 +6475,11 @@ var init_handler2 = __esm({
|
|
|
6475
6475
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
6476
6476
|
}
|
|
6477
6477
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
6478
|
-
this.fsw._closeFile(
|
|
6478
|
+
this.fsw._closeFile(path19);
|
|
6479
6479
|
prevStats = newStats2;
|
|
6480
6480
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
6481
6481
|
if (closer2)
|
|
6482
|
-
this.fsw._addPathCloser(
|
|
6482
|
+
this.fsw._addPathCloser(path19, closer2);
|
|
6483
6483
|
} else {
|
|
6484
6484
|
prevStats = newStats2;
|
|
6485
6485
|
}
|
|
@@ -6511,7 +6511,7 @@ var init_handler2 = __esm({
|
|
|
6511
6511
|
* @param item basename of this item
|
|
6512
6512
|
* @returns true if no more processing is needed for this entry.
|
|
6513
6513
|
*/
|
|
6514
|
-
async _handleSymlink(entry, directory,
|
|
6514
|
+
async _handleSymlink(entry, directory, path19, item) {
|
|
6515
6515
|
if (this.fsw.closed) {
|
|
6516
6516
|
return;
|
|
6517
6517
|
}
|
|
@@ -6521,7 +6521,7 @@ var init_handler2 = __esm({
|
|
|
6521
6521
|
this.fsw._incrReadyCount();
|
|
6522
6522
|
let linkPath;
|
|
6523
6523
|
try {
|
|
6524
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
6524
|
+
linkPath = await (0, import_promises2.realpath)(path19);
|
|
6525
6525
|
} catch (e) {
|
|
6526
6526
|
this.fsw._emitReady();
|
|
6527
6527
|
return true;
|
|
@@ -6531,12 +6531,12 @@ var init_handler2 = __esm({
|
|
|
6531
6531
|
if (dir.has(item)) {
|
|
6532
6532
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
6533
6533
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
6534
|
-
this.fsw._emit(EV.CHANGE,
|
|
6534
|
+
this.fsw._emit(EV.CHANGE, path19, entry.stats);
|
|
6535
6535
|
}
|
|
6536
6536
|
} else {
|
|
6537
6537
|
dir.add(item);
|
|
6538
6538
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
6539
|
-
this.fsw._emit(EV.ADD,
|
|
6539
|
+
this.fsw._emit(EV.ADD, path19, entry.stats);
|
|
6540
6540
|
}
|
|
6541
6541
|
this.fsw._emitReady();
|
|
6542
6542
|
return true;
|
|
@@ -6566,9 +6566,9 @@ var init_handler2 = __esm({
|
|
|
6566
6566
|
return;
|
|
6567
6567
|
}
|
|
6568
6568
|
const item = entry.path;
|
|
6569
|
-
let
|
|
6569
|
+
let path19 = sp.join(directory, item);
|
|
6570
6570
|
current.add(item);
|
|
6571
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
6571
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path19, item)) {
|
|
6572
6572
|
return;
|
|
6573
6573
|
}
|
|
6574
6574
|
if (this.fsw.closed) {
|
|
@@ -6577,8 +6577,8 @@ var init_handler2 = __esm({
|
|
|
6577
6577
|
}
|
|
6578
6578
|
if (item === target || !target && !previous.has(item)) {
|
|
6579
6579
|
this.fsw._incrReadyCount();
|
|
6580
|
-
|
|
6581
|
-
this._addToNodeFs(
|
|
6580
|
+
path19 = sp.join(dir, sp.relative(dir, path19));
|
|
6581
|
+
this._addToNodeFs(path19, initialAdd, wh, depth + 1);
|
|
6582
6582
|
}
|
|
6583
6583
|
}).on(EV.ERROR, this._boundHandleError);
|
|
6584
6584
|
return new Promise((resolve12, reject) => {
|
|
@@ -6647,13 +6647,13 @@ var init_handler2 = __esm({
|
|
|
6647
6647
|
* @param depth Child path actually targeted for watch
|
|
6648
6648
|
* @param target Child path actually targeted for watch
|
|
6649
6649
|
*/
|
|
6650
|
-
async _addToNodeFs(
|
|
6650
|
+
async _addToNodeFs(path19, initialAdd, priorWh, depth, target) {
|
|
6651
6651
|
const ready = this.fsw._emitReady;
|
|
6652
|
-
if (this.fsw._isIgnored(
|
|
6652
|
+
if (this.fsw._isIgnored(path19) || this.fsw.closed) {
|
|
6653
6653
|
ready();
|
|
6654
6654
|
return false;
|
|
6655
6655
|
}
|
|
6656
|
-
const wh = this.fsw._getWatchHelpers(
|
|
6656
|
+
const wh = this.fsw._getWatchHelpers(path19);
|
|
6657
6657
|
if (priorWh) {
|
|
6658
6658
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
6659
6659
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -6669,8 +6669,8 @@ var init_handler2 = __esm({
|
|
|
6669
6669
|
const follow = this.fsw.options.followSymlinks;
|
|
6670
6670
|
let closer;
|
|
6671
6671
|
if (stats.isDirectory()) {
|
|
6672
|
-
const absPath = sp.resolve(
|
|
6673
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
6672
|
+
const absPath = sp.resolve(path19);
|
|
6673
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path19) : path19;
|
|
6674
6674
|
if (this.fsw.closed)
|
|
6675
6675
|
return;
|
|
6676
6676
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -6680,29 +6680,29 @@ var init_handler2 = __esm({
|
|
|
6680
6680
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
6681
6681
|
}
|
|
6682
6682
|
} else if (stats.isSymbolicLink()) {
|
|
6683
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
6683
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path19) : path19;
|
|
6684
6684
|
if (this.fsw.closed)
|
|
6685
6685
|
return;
|
|
6686
6686
|
const parent = sp.dirname(wh.watchPath);
|
|
6687
6687
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
6688
6688
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
6689
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
6689
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path19, wh, targetPath);
|
|
6690
6690
|
if (this.fsw.closed)
|
|
6691
6691
|
return;
|
|
6692
6692
|
if (targetPath !== void 0) {
|
|
6693
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
6693
|
+
this.fsw._symlinkPaths.set(sp.resolve(path19), targetPath);
|
|
6694
6694
|
}
|
|
6695
6695
|
} else {
|
|
6696
6696
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
6697
6697
|
}
|
|
6698
6698
|
ready();
|
|
6699
6699
|
if (closer)
|
|
6700
|
-
this.fsw._addPathCloser(
|
|
6700
|
+
this.fsw._addPathCloser(path19, closer);
|
|
6701
6701
|
return false;
|
|
6702
6702
|
} catch (error48) {
|
|
6703
6703
|
if (this.fsw._handleError(error48)) {
|
|
6704
6704
|
ready();
|
|
6705
|
-
return
|
|
6705
|
+
return path19;
|
|
6706
6706
|
}
|
|
6707
6707
|
}
|
|
6708
6708
|
}
|
|
@@ -6737,24 +6737,24 @@ function createPattern(matcher) {
|
|
|
6737
6737
|
}
|
|
6738
6738
|
return () => false;
|
|
6739
6739
|
}
|
|
6740
|
-
function normalizePath(
|
|
6741
|
-
if (typeof
|
|
6740
|
+
function normalizePath(path19) {
|
|
6741
|
+
if (typeof path19 !== "string")
|
|
6742
6742
|
throw new Error("string expected");
|
|
6743
|
-
|
|
6744
|
-
|
|
6743
|
+
path19 = sp2.normalize(path19);
|
|
6744
|
+
path19 = path19.replace(/\\/g, "/");
|
|
6745
6745
|
let prepend = false;
|
|
6746
|
-
if (
|
|
6746
|
+
if (path19.startsWith("//"))
|
|
6747
6747
|
prepend = true;
|
|
6748
|
-
|
|
6748
|
+
path19 = path19.replace(DOUBLE_SLASH_RE, "/");
|
|
6749
6749
|
if (prepend)
|
|
6750
|
-
|
|
6751
|
-
return
|
|
6750
|
+
path19 = "/" + path19;
|
|
6751
|
+
return path19;
|
|
6752
6752
|
}
|
|
6753
6753
|
function matchPatterns(patterns, testString, stats) {
|
|
6754
|
-
const
|
|
6754
|
+
const path19 = normalizePath(testString);
|
|
6755
6755
|
for (let index = 0; index < patterns.length; index++) {
|
|
6756
6756
|
const pattern = patterns[index];
|
|
6757
|
-
if (pattern(
|
|
6757
|
+
if (pattern(path19, stats)) {
|
|
6758
6758
|
return true;
|
|
6759
6759
|
}
|
|
6760
6760
|
}
|
|
@@ -6817,19 +6817,19 @@ var init_chokidar = __esm({
|
|
|
6817
6817
|
}
|
|
6818
6818
|
return str;
|
|
6819
6819
|
};
|
|
6820
|
-
normalizePathToUnix = (
|
|
6821
|
-
normalizeIgnored = (cwd = "") => (
|
|
6822
|
-
if (typeof
|
|
6823
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
6820
|
+
normalizePathToUnix = (path19) => toUnix(sp2.normalize(toUnix(path19)));
|
|
6821
|
+
normalizeIgnored = (cwd = "") => (path19) => {
|
|
6822
|
+
if (typeof path19 === "string") {
|
|
6823
|
+
return normalizePathToUnix(sp2.isAbsolute(path19) ? path19 : sp2.join(cwd, path19));
|
|
6824
6824
|
} else {
|
|
6825
|
-
return
|
|
6825
|
+
return path19;
|
|
6826
6826
|
}
|
|
6827
6827
|
};
|
|
6828
|
-
getAbsolutePath = (
|
|
6829
|
-
if (sp2.isAbsolute(
|
|
6830
|
-
return
|
|
6828
|
+
getAbsolutePath = (path19, cwd) => {
|
|
6829
|
+
if (sp2.isAbsolute(path19)) {
|
|
6830
|
+
return path19;
|
|
6831
6831
|
}
|
|
6832
|
-
return sp2.join(cwd,
|
|
6832
|
+
return sp2.join(cwd, path19);
|
|
6833
6833
|
};
|
|
6834
6834
|
EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
6835
6835
|
DirEntry = class {
|
|
@@ -6894,10 +6894,10 @@ var init_chokidar = __esm({
|
|
|
6894
6894
|
dirParts;
|
|
6895
6895
|
followSymlinks;
|
|
6896
6896
|
statMethod;
|
|
6897
|
-
constructor(
|
|
6897
|
+
constructor(path19, follow, fsw) {
|
|
6898
6898
|
this.fsw = fsw;
|
|
6899
|
-
const watchPath =
|
|
6900
|
-
this.path =
|
|
6899
|
+
const watchPath = path19;
|
|
6900
|
+
this.path = path19 = path19.replace(REPLACER_RE, "");
|
|
6901
6901
|
this.watchPath = watchPath;
|
|
6902
6902
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
6903
6903
|
this.dirParts = [];
|
|
@@ -7037,20 +7037,20 @@ var init_chokidar = __esm({
|
|
|
7037
7037
|
this._closePromise = void 0;
|
|
7038
7038
|
let paths = unifyPaths(paths_);
|
|
7039
7039
|
if (cwd) {
|
|
7040
|
-
paths = paths.map((
|
|
7041
|
-
const absPath = getAbsolutePath(
|
|
7040
|
+
paths = paths.map((path19) => {
|
|
7041
|
+
const absPath = getAbsolutePath(path19, cwd);
|
|
7042
7042
|
return absPath;
|
|
7043
7043
|
});
|
|
7044
7044
|
}
|
|
7045
|
-
paths.forEach((
|
|
7046
|
-
this._removeIgnoredPath(
|
|
7045
|
+
paths.forEach((path19) => {
|
|
7046
|
+
this._removeIgnoredPath(path19);
|
|
7047
7047
|
});
|
|
7048
7048
|
this._userIgnored = void 0;
|
|
7049
7049
|
if (!this._readyCount)
|
|
7050
7050
|
this._readyCount = 0;
|
|
7051
7051
|
this._readyCount += paths.length;
|
|
7052
|
-
Promise.all(paths.map(async (
|
|
7053
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
7052
|
+
Promise.all(paths.map(async (path19) => {
|
|
7053
|
+
const res = await this._nodeFsHandler._addToNodeFs(path19, !_internal, void 0, 0, _origAdd);
|
|
7054
7054
|
if (res)
|
|
7055
7055
|
this._emitReady();
|
|
7056
7056
|
return res;
|
|
@@ -7072,17 +7072,17 @@ var init_chokidar = __esm({
|
|
|
7072
7072
|
return this;
|
|
7073
7073
|
const paths = unifyPaths(paths_);
|
|
7074
7074
|
const { cwd } = this.options;
|
|
7075
|
-
paths.forEach((
|
|
7076
|
-
if (!sp2.isAbsolute(
|
|
7075
|
+
paths.forEach((path19) => {
|
|
7076
|
+
if (!sp2.isAbsolute(path19) && !this._closers.has(path19)) {
|
|
7077
7077
|
if (cwd)
|
|
7078
|
-
|
|
7079
|
-
|
|
7078
|
+
path19 = sp2.join(cwd, path19);
|
|
7079
|
+
path19 = sp2.resolve(path19);
|
|
7080
7080
|
}
|
|
7081
|
-
this._closePath(
|
|
7082
|
-
this._addIgnoredPath(
|
|
7083
|
-
if (this._watched.has(
|
|
7081
|
+
this._closePath(path19);
|
|
7082
|
+
this._addIgnoredPath(path19);
|
|
7083
|
+
if (this._watched.has(path19)) {
|
|
7084
7084
|
this._addIgnoredPath({
|
|
7085
|
-
path:
|
|
7085
|
+
path: path19,
|
|
7086
7086
|
recursive: true
|
|
7087
7087
|
});
|
|
7088
7088
|
}
|
|
@@ -7146,38 +7146,38 @@ var init_chokidar = __esm({
|
|
|
7146
7146
|
* @param stats arguments to be passed with event
|
|
7147
7147
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
7148
7148
|
*/
|
|
7149
|
-
async _emit(event,
|
|
7149
|
+
async _emit(event, path19, stats) {
|
|
7150
7150
|
if (this.closed)
|
|
7151
7151
|
return;
|
|
7152
7152
|
const opts = this.options;
|
|
7153
7153
|
if (isWindows)
|
|
7154
|
-
|
|
7154
|
+
path19 = sp2.normalize(path19);
|
|
7155
7155
|
if (opts.cwd)
|
|
7156
|
-
|
|
7157
|
-
const args = [
|
|
7156
|
+
path19 = sp2.relative(opts.cwd, path19);
|
|
7157
|
+
const args = [path19];
|
|
7158
7158
|
if (stats != null)
|
|
7159
7159
|
args.push(stats);
|
|
7160
7160
|
const awf = opts.awaitWriteFinish;
|
|
7161
7161
|
let pw;
|
|
7162
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
7162
|
+
if (awf && (pw = this._pendingWrites.get(path19))) {
|
|
7163
7163
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
7164
7164
|
return this;
|
|
7165
7165
|
}
|
|
7166
7166
|
if (opts.atomic) {
|
|
7167
7167
|
if (event === EVENTS.UNLINK) {
|
|
7168
|
-
this._pendingUnlinks.set(
|
|
7168
|
+
this._pendingUnlinks.set(path19, [event, ...args]);
|
|
7169
7169
|
setTimeout(() => {
|
|
7170
|
-
this._pendingUnlinks.forEach((entry,
|
|
7170
|
+
this._pendingUnlinks.forEach((entry, path20) => {
|
|
7171
7171
|
this.emit(...entry);
|
|
7172
7172
|
this.emit(EVENTS.ALL, ...entry);
|
|
7173
|
-
this._pendingUnlinks.delete(
|
|
7173
|
+
this._pendingUnlinks.delete(path20);
|
|
7174
7174
|
});
|
|
7175
7175
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
7176
7176
|
return this;
|
|
7177
7177
|
}
|
|
7178
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
7178
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path19)) {
|
|
7179
7179
|
event = EVENTS.CHANGE;
|
|
7180
|
-
this._pendingUnlinks.delete(
|
|
7180
|
+
this._pendingUnlinks.delete(path19);
|
|
7181
7181
|
}
|
|
7182
7182
|
}
|
|
7183
7183
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -7195,16 +7195,16 @@ var init_chokidar = __esm({
|
|
|
7195
7195
|
this.emitWithAll(event, args);
|
|
7196
7196
|
}
|
|
7197
7197
|
};
|
|
7198
|
-
this._awaitWriteFinish(
|
|
7198
|
+
this._awaitWriteFinish(path19, awf.stabilityThreshold, event, awfEmit);
|
|
7199
7199
|
return this;
|
|
7200
7200
|
}
|
|
7201
7201
|
if (event === EVENTS.CHANGE) {
|
|
7202
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
7202
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path19, 50);
|
|
7203
7203
|
if (isThrottled)
|
|
7204
7204
|
return this;
|
|
7205
7205
|
}
|
|
7206
7206
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
7207
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
7207
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path19) : path19;
|
|
7208
7208
|
let stats2;
|
|
7209
7209
|
try {
|
|
7210
7210
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -7235,23 +7235,23 @@ var init_chokidar = __esm({
|
|
|
7235
7235
|
* @param timeout duration of time to suppress duplicate actions
|
|
7236
7236
|
* @returns tracking object or false if action should be suppressed
|
|
7237
7237
|
*/
|
|
7238
|
-
_throttle(actionType,
|
|
7238
|
+
_throttle(actionType, path19, timeout) {
|
|
7239
7239
|
if (!this._throttled.has(actionType)) {
|
|
7240
7240
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
7241
7241
|
}
|
|
7242
7242
|
const action = this._throttled.get(actionType);
|
|
7243
7243
|
if (!action)
|
|
7244
7244
|
throw new Error("invalid throttle");
|
|
7245
|
-
const actionPath = action.get(
|
|
7245
|
+
const actionPath = action.get(path19);
|
|
7246
7246
|
if (actionPath) {
|
|
7247
7247
|
actionPath.count++;
|
|
7248
7248
|
return false;
|
|
7249
7249
|
}
|
|
7250
7250
|
let timeoutObject;
|
|
7251
7251
|
const clear = () => {
|
|
7252
|
-
const item = action.get(
|
|
7252
|
+
const item = action.get(path19);
|
|
7253
7253
|
const count = item ? item.count : 0;
|
|
7254
|
-
action.delete(
|
|
7254
|
+
action.delete(path19);
|
|
7255
7255
|
clearTimeout(timeoutObject);
|
|
7256
7256
|
if (item)
|
|
7257
7257
|
clearTimeout(item.timeoutObject);
|
|
@@ -7259,7 +7259,7 @@ var init_chokidar = __esm({
|
|
|
7259
7259
|
};
|
|
7260
7260
|
timeoutObject = setTimeout(clear, timeout);
|
|
7261
7261
|
const thr = { timeoutObject, clear, count: 0 };
|
|
7262
|
-
action.set(
|
|
7262
|
+
action.set(path19, thr);
|
|
7263
7263
|
return thr;
|
|
7264
7264
|
}
|
|
7265
7265
|
_incrReadyCount() {
|
|
@@ -7273,44 +7273,44 @@ var init_chokidar = __esm({
|
|
|
7273
7273
|
* @param event
|
|
7274
7274
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
7275
7275
|
*/
|
|
7276
|
-
_awaitWriteFinish(
|
|
7276
|
+
_awaitWriteFinish(path19, threshold, event, awfEmit) {
|
|
7277
7277
|
const awf = this.options.awaitWriteFinish;
|
|
7278
7278
|
if (typeof awf !== "object")
|
|
7279
7279
|
return;
|
|
7280
7280
|
const pollInterval = awf.pollInterval;
|
|
7281
7281
|
let timeoutHandler;
|
|
7282
|
-
let fullPath =
|
|
7283
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
7284
|
-
fullPath = sp2.join(this.options.cwd,
|
|
7282
|
+
let fullPath = path19;
|
|
7283
|
+
if (this.options.cwd && !sp2.isAbsolute(path19)) {
|
|
7284
|
+
fullPath = sp2.join(this.options.cwd, path19);
|
|
7285
7285
|
}
|
|
7286
7286
|
const now = /* @__PURE__ */ new Date();
|
|
7287
7287
|
const writes = this._pendingWrites;
|
|
7288
7288
|
function awaitWriteFinishFn(prevStat) {
|
|
7289
7289
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
7290
|
-
if (err || !writes.has(
|
|
7290
|
+
if (err || !writes.has(path19)) {
|
|
7291
7291
|
if (err && err.code !== "ENOENT")
|
|
7292
7292
|
awfEmit(err);
|
|
7293
7293
|
return;
|
|
7294
7294
|
}
|
|
7295
7295
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
7296
7296
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
7297
|
-
writes.get(
|
|
7297
|
+
writes.get(path19).lastChange = now2;
|
|
7298
7298
|
}
|
|
7299
|
-
const pw = writes.get(
|
|
7299
|
+
const pw = writes.get(path19);
|
|
7300
7300
|
const df = now2 - pw.lastChange;
|
|
7301
7301
|
if (df >= threshold) {
|
|
7302
|
-
writes.delete(
|
|
7302
|
+
writes.delete(path19);
|
|
7303
7303
|
awfEmit(void 0, curStat);
|
|
7304
7304
|
} else {
|
|
7305
7305
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
7306
7306
|
}
|
|
7307
7307
|
});
|
|
7308
7308
|
}
|
|
7309
|
-
if (!writes.has(
|
|
7310
|
-
writes.set(
|
|
7309
|
+
if (!writes.has(path19)) {
|
|
7310
|
+
writes.set(path19, {
|
|
7311
7311
|
lastChange: now,
|
|
7312
7312
|
cancelWait: () => {
|
|
7313
|
-
writes.delete(
|
|
7313
|
+
writes.delete(path19);
|
|
7314
7314
|
clearTimeout(timeoutHandler);
|
|
7315
7315
|
return event;
|
|
7316
7316
|
}
|
|
@@ -7321,8 +7321,8 @@ var init_chokidar = __esm({
|
|
|
7321
7321
|
/**
|
|
7322
7322
|
* Determines whether user has asked to ignore this path.
|
|
7323
7323
|
*/
|
|
7324
|
-
_isIgnored(
|
|
7325
|
-
if (this.options.atomic && DOT_RE.test(
|
|
7324
|
+
_isIgnored(path19, stats) {
|
|
7325
|
+
if (this.options.atomic && DOT_RE.test(path19))
|
|
7326
7326
|
return true;
|
|
7327
7327
|
if (!this._userIgnored) {
|
|
7328
7328
|
const { cwd } = this.options;
|
|
@@ -7332,17 +7332,17 @@ var init_chokidar = __esm({
|
|
|
7332
7332
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
7333
7333
|
this._userIgnored = anymatch(list, void 0);
|
|
7334
7334
|
}
|
|
7335
|
-
return this._userIgnored(
|
|
7335
|
+
return this._userIgnored(path19, stats);
|
|
7336
7336
|
}
|
|
7337
|
-
_isntIgnored(
|
|
7338
|
-
return !this._isIgnored(
|
|
7337
|
+
_isntIgnored(path19, stat4) {
|
|
7338
|
+
return !this._isIgnored(path19, stat4);
|
|
7339
7339
|
}
|
|
7340
7340
|
/**
|
|
7341
7341
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
7342
7342
|
* @param path file or directory pattern being watched
|
|
7343
7343
|
*/
|
|
7344
|
-
_getWatchHelpers(
|
|
7345
|
-
return new WatchHelper(
|
|
7344
|
+
_getWatchHelpers(path19) {
|
|
7345
|
+
return new WatchHelper(path19, this.options.followSymlinks, this);
|
|
7346
7346
|
}
|
|
7347
7347
|
// Directory helpers
|
|
7348
7348
|
// -----------------
|
|
@@ -7374,63 +7374,63 @@ var init_chokidar = __esm({
|
|
|
7374
7374
|
* @param item base path of item/directory
|
|
7375
7375
|
*/
|
|
7376
7376
|
_remove(directory, item, isDirectory) {
|
|
7377
|
-
const
|
|
7378
|
-
const fullPath = sp2.resolve(
|
|
7379
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
7380
|
-
if (!this._throttle("remove",
|
|
7377
|
+
const path19 = sp2.join(directory, item);
|
|
7378
|
+
const fullPath = sp2.resolve(path19);
|
|
7379
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path19) || this._watched.has(fullPath);
|
|
7380
|
+
if (!this._throttle("remove", path19, 100))
|
|
7381
7381
|
return;
|
|
7382
7382
|
if (!isDirectory && this._watched.size === 1) {
|
|
7383
7383
|
this.add(directory, item, true);
|
|
7384
7384
|
}
|
|
7385
|
-
const wp = this._getWatchedDir(
|
|
7385
|
+
const wp = this._getWatchedDir(path19);
|
|
7386
7386
|
const nestedDirectoryChildren = wp.getChildren();
|
|
7387
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
7387
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path19, nested));
|
|
7388
7388
|
const parent = this._getWatchedDir(directory);
|
|
7389
7389
|
const wasTracked = parent.has(item);
|
|
7390
7390
|
parent.remove(item);
|
|
7391
7391
|
if (this._symlinkPaths.has(fullPath)) {
|
|
7392
7392
|
this._symlinkPaths.delete(fullPath);
|
|
7393
7393
|
}
|
|
7394
|
-
let relPath =
|
|
7394
|
+
let relPath = path19;
|
|
7395
7395
|
if (this.options.cwd)
|
|
7396
|
-
relPath = sp2.relative(this.options.cwd,
|
|
7396
|
+
relPath = sp2.relative(this.options.cwd, path19);
|
|
7397
7397
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
7398
7398
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
7399
7399
|
if (event === EVENTS.ADD)
|
|
7400
7400
|
return;
|
|
7401
7401
|
}
|
|
7402
|
-
this._watched.delete(
|
|
7402
|
+
this._watched.delete(path19);
|
|
7403
7403
|
this._watched.delete(fullPath);
|
|
7404
7404
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
7405
|
-
if (wasTracked && !this._isIgnored(
|
|
7406
|
-
this._emit(eventName,
|
|
7407
|
-
this._closePath(
|
|
7405
|
+
if (wasTracked && !this._isIgnored(path19))
|
|
7406
|
+
this._emit(eventName, path19);
|
|
7407
|
+
this._closePath(path19);
|
|
7408
7408
|
}
|
|
7409
7409
|
/**
|
|
7410
7410
|
* Closes all watchers for a path
|
|
7411
7411
|
*/
|
|
7412
|
-
_closePath(
|
|
7413
|
-
this._closeFile(
|
|
7414
|
-
const dir = sp2.dirname(
|
|
7415
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
7412
|
+
_closePath(path19) {
|
|
7413
|
+
this._closeFile(path19);
|
|
7414
|
+
const dir = sp2.dirname(path19);
|
|
7415
|
+
this._getWatchedDir(dir).remove(sp2.basename(path19));
|
|
7416
7416
|
}
|
|
7417
7417
|
/**
|
|
7418
7418
|
* Closes only file-specific watchers
|
|
7419
7419
|
*/
|
|
7420
|
-
_closeFile(
|
|
7421
|
-
const closers = this._closers.get(
|
|
7420
|
+
_closeFile(path19) {
|
|
7421
|
+
const closers = this._closers.get(path19);
|
|
7422
7422
|
if (!closers)
|
|
7423
7423
|
return;
|
|
7424
7424
|
closers.forEach((closer) => closer());
|
|
7425
|
-
this._closers.delete(
|
|
7425
|
+
this._closers.delete(path19);
|
|
7426
7426
|
}
|
|
7427
|
-
_addPathCloser(
|
|
7427
|
+
_addPathCloser(path19, closer) {
|
|
7428
7428
|
if (!closer)
|
|
7429
7429
|
return;
|
|
7430
|
-
let list = this._closers.get(
|
|
7430
|
+
let list = this._closers.get(path19);
|
|
7431
7431
|
if (!list) {
|
|
7432
7432
|
list = [];
|
|
7433
|
-
this._closers.set(
|
|
7433
|
+
this._closers.set(path19, list);
|
|
7434
7434
|
}
|
|
7435
7435
|
list.push(closer);
|
|
7436
7436
|
}
|
|
@@ -8629,7 +8629,7 @@ function detectCurrentWorkspace(ideId) {
|
|
|
8629
8629
|
}
|
|
8630
8630
|
} else if (plat === "win32") {
|
|
8631
8631
|
try {
|
|
8632
|
-
const
|
|
8632
|
+
const fs17 = require("fs");
|
|
8633
8633
|
const appNameMap = getMacAppIdentifiers();
|
|
8634
8634
|
const appName = appNameMap[ideId];
|
|
8635
8635
|
if (appName) {
|
|
@@ -8638,8 +8638,8 @@ function detectCurrentWorkspace(ideId) {
|
|
|
8638
8638
|
appName,
|
|
8639
8639
|
"storage.json"
|
|
8640
8640
|
);
|
|
8641
|
-
if (
|
|
8642
|
-
const data = JSON.parse(
|
|
8641
|
+
if (fs17.existsSync(storagePath)) {
|
|
8642
|
+
const data = JSON.parse(fs17.readFileSync(storagePath, "utf-8"));
|
|
8643
8643
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
8644
8644
|
if (workspaces.length > 0) {
|
|
8645
8645
|
const recent = workspaces[0];
|
|
@@ -18459,8 +18459,197 @@ var init_snapshot = __esm({
|
|
|
18459
18459
|
}
|
|
18460
18460
|
});
|
|
18461
18461
|
|
|
18462
|
+
// ../../oss/packages/daemon-core/src/commands/upgrade-helper.ts
|
|
18463
|
+
function getUpgradeLogPath() {
|
|
18464
|
+
const home = os12.homedir();
|
|
18465
|
+
const dir = path9.join(home, ".adhdev");
|
|
18466
|
+
fs8.mkdirSync(dir, { recursive: true });
|
|
18467
|
+
return path9.join(dir, "daemon-upgrade.log");
|
|
18468
|
+
}
|
|
18469
|
+
function appendUpgradeLog(message) {
|
|
18470
|
+
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
18471
|
+
`;
|
|
18472
|
+
try {
|
|
18473
|
+
fs8.appendFileSync(getUpgradeLogPath(), line, "utf8");
|
|
18474
|
+
} catch {
|
|
18475
|
+
}
|
|
18476
|
+
}
|
|
18477
|
+
function getNpmExecutable() {
|
|
18478
|
+
return process.platform === "win32" ? "npm.cmd" : "npm";
|
|
18479
|
+
}
|
|
18480
|
+
function killPid(pid) {
|
|
18481
|
+
try {
|
|
18482
|
+
if (process.platform === "win32") {
|
|
18483
|
+
(0, import_child_process5.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
|
|
18484
|
+
} else {
|
|
18485
|
+
process.kill(pid, "SIGTERM");
|
|
18486
|
+
}
|
|
18487
|
+
return true;
|
|
18488
|
+
} catch {
|
|
18489
|
+
return false;
|
|
18490
|
+
}
|
|
18491
|
+
}
|
|
18492
|
+
async function waitForPidExit(pid, timeoutMs) {
|
|
18493
|
+
const start = Date.now();
|
|
18494
|
+
while (Date.now() - start < timeoutMs) {
|
|
18495
|
+
try {
|
|
18496
|
+
process.kill(pid, 0);
|
|
18497
|
+
await new Promise((resolve12) => setTimeout(resolve12, 250));
|
|
18498
|
+
} catch {
|
|
18499
|
+
return;
|
|
18500
|
+
}
|
|
18501
|
+
}
|
|
18502
|
+
}
|
|
18503
|
+
function stopSessionHostProcesses(appName) {
|
|
18504
|
+
const pidFile = path9.join(os12.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
18505
|
+
try {
|
|
18506
|
+
if (fs8.existsSync(pidFile)) {
|
|
18507
|
+
const pid = Number.parseInt(fs8.readFileSync(pidFile, "utf8").trim(), 10);
|
|
18508
|
+
if (Number.isFinite(pid)) {
|
|
18509
|
+
killPid(pid);
|
|
18510
|
+
}
|
|
18511
|
+
}
|
|
18512
|
+
} catch {
|
|
18513
|
+
} finally {
|
|
18514
|
+
try {
|
|
18515
|
+
fs8.unlinkSync(pidFile);
|
|
18516
|
+
} catch {
|
|
18517
|
+
}
|
|
18518
|
+
}
|
|
18519
|
+
if (process.platform !== "win32") {
|
|
18520
|
+
try {
|
|
18521
|
+
const raw = (0, import_child_process5.execFileSync)("pgrep", ["-f", "session-host-daemon"], { encoding: "utf8" }).trim();
|
|
18522
|
+
for (const line of raw.split("\n")) {
|
|
18523
|
+
const pid = Number.parseInt(line.trim(), 10);
|
|
18524
|
+
if (Number.isFinite(pid)) {
|
|
18525
|
+
killPid(pid);
|
|
18526
|
+
}
|
|
18527
|
+
}
|
|
18528
|
+
} catch {
|
|
18529
|
+
}
|
|
18530
|
+
}
|
|
18531
|
+
}
|
|
18532
|
+
function removeDaemonPidFile() {
|
|
18533
|
+
const pidFile = path9.join(os12.homedir(), ".adhdev", "daemon.pid");
|
|
18534
|
+
try {
|
|
18535
|
+
fs8.unlinkSync(pidFile);
|
|
18536
|
+
} catch {
|
|
18537
|
+
}
|
|
18538
|
+
}
|
|
18539
|
+
function cleanupStaleGlobalInstallDirs(pkgName) {
|
|
18540
|
+
const npmRoot = (0, import_child_process5.execFileSync)(getNpmExecutable(), ["root", "-g"], { encoding: "utf8" }).trim();
|
|
18541
|
+
if (!npmRoot) return;
|
|
18542
|
+
const npmPrefix = (0, import_child_process5.execFileSync)(getNpmExecutable(), ["prefix", "-g"], { encoding: "utf8" }).trim();
|
|
18543
|
+
const binDir = process.platform === "win32" ? npmPrefix : path9.join(npmPrefix, "bin");
|
|
18544
|
+
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
18545
|
+
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
18546
|
+
if (pkgName === "@adhdev/daemon-standalone") {
|
|
18547
|
+
binNames.add("adhdev-standalone");
|
|
18548
|
+
}
|
|
18549
|
+
if (pkgName.startsWith("@")) {
|
|
18550
|
+
const [scope, name] = pkgName.split("/");
|
|
18551
|
+
const scopeDir = path9.join(npmRoot, scope);
|
|
18552
|
+
if (!fs8.existsSync(scopeDir)) return;
|
|
18553
|
+
for (const entry of fs8.readdirSync(scopeDir)) {
|
|
18554
|
+
if (!entry.startsWith(`.${name}-`)) continue;
|
|
18555
|
+
fs8.rmSync(path9.join(scopeDir, entry), { recursive: true, force: true });
|
|
18556
|
+
appendUpgradeLog(`Removed stale scoped staging dir: ${path9.join(scopeDir, entry)}`);
|
|
18557
|
+
}
|
|
18558
|
+
} else {
|
|
18559
|
+
for (const entry of fs8.readdirSync(npmRoot)) {
|
|
18560
|
+
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
18561
|
+
fs8.rmSync(path9.join(npmRoot, entry), { recursive: true, force: true });
|
|
18562
|
+
appendUpgradeLog(`Removed stale staging dir: ${path9.join(npmRoot, entry)}`);
|
|
18563
|
+
}
|
|
18564
|
+
}
|
|
18565
|
+
if (fs8.existsSync(binDir)) {
|
|
18566
|
+
for (const entry of fs8.readdirSync(binDir)) {
|
|
18567
|
+
if (![...binNames].some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
18568
|
+
fs8.rmSync(path9.join(binDir, entry), { recursive: true, force: true });
|
|
18569
|
+
appendUpgradeLog(`Removed stale bin staging entry: ${path9.join(binDir, entry)}`);
|
|
18570
|
+
}
|
|
18571
|
+
}
|
|
18572
|
+
}
|
|
18573
|
+
function spawnDetachedDaemonUpgradeHelper(payload) {
|
|
18574
|
+
const env = { ...process.env, [UPGRADE_HELPER_ENV]: JSON.stringify(payload) };
|
|
18575
|
+
const child = (0, import_child_process6.spawn)(process.execPath, process.argv.slice(1), {
|
|
18576
|
+
detached: true,
|
|
18577
|
+
stdio: "ignore",
|
|
18578
|
+
windowsHide: true,
|
|
18579
|
+
cwd: payload.cwd || process.cwd(),
|
|
18580
|
+
env
|
|
18581
|
+
});
|
|
18582
|
+
child.unref();
|
|
18583
|
+
}
|
|
18584
|
+
async function runDaemonUpgradeHelper(payload) {
|
|
18585
|
+
const restartArgv = Array.isArray(payload.restartArgv) ? payload.restartArgv : [];
|
|
18586
|
+
const sessionHostAppName = payload.sessionHostAppName || process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
|
|
18587
|
+
appendUpgradeLog(`Upgrade helper started for ${payload.packageName}@${payload.targetVersion}`);
|
|
18588
|
+
if (Number.isFinite(payload.parentPid) && payload.parentPid > 0) {
|
|
18589
|
+
appendUpgradeLog(`Waiting for parent pid ${payload.parentPid} to exit`);
|
|
18590
|
+
await waitForPidExit(payload.parentPid, 15e3);
|
|
18591
|
+
}
|
|
18592
|
+
stopSessionHostProcesses(sessionHostAppName);
|
|
18593
|
+
removeDaemonPidFile();
|
|
18594
|
+
cleanupStaleGlobalInstallDirs(payload.packageName);
|
|
18595
|
+
const spec = `${payload.packageName}@${payload.targetVersion || "latest"}`;
|
|
18596
|
+
appendUpgradeLog(`Installing ${spec}`);
|
|
18597
|
+
const installOutput = (0, import_child_process5.execFileSync)(
|
|
18598
|
+
getNpmExecutable(),
|
|
18599
|
+
["install", "-g", spec, "--force"],
|
|
18600
|
+
{
|
|
18601
|
+
encoding: "utf8",
|
|
18602
|
+
stdio: "pipe",
|
|
18603
|
+
maxBuffer: 20 * 1024 * 1024
|
|
18604
|
+
}
|
|
18605
|
+
);
|
|
18606
|
+
if (installOutput.trim()) {
|
|
18607
|
+
appendUpgradeLog(installOutput.trim());
|
|
18608
|
+
}
|
|
18609
|
+
if (restartArgv.length > 0) {
|
|
18610
|
+
const env = { ...process.env };
|
|
18611
|
+
delete env[UPGRADE_HELPER_ENV];
|
|
18612
|
+
appendUpgradeLog(`Restarting daemon with args: ${restartArgv.join(" ")}`);
|
|
18613
|
+
const child = (0, import_child_process6.spawn)(process.execPath, restartArgv, {
|
|
18614
|
+
detached: true,
|
|
18615
|
+
stdio: "ignore",
|
|
18616
|
+
windowsHide: true,
|
|
18617
|
+
cwd: payload.cwd || process.cwd(),
|
|
18618
|
+
env
|
|
18619
|
+
});
|
|
18620
|
+
child.unref();
|
|
18621
|
+
} else {
|
|
18622
|
+
appendUpgradeLog("No restart argv provided; upgrade completed without restart");
|
|
18623
|
+
}
|
|
18624
|
+
}
|
|
18625
|
+
async function maybeRunDaemonUpgradeHelperFromEnv() {
|
|
18626
|
+
const raw = process.env[UPGRADE_HELPER_ENV];
|
|
18627
|
+
if (!raw) return false;
|
|
18628
|
+
delete process.env[UPGRADE_HELPER_ENV];
|
|
18629
|
+
try {
|
|
18630
|
+
const payload = JSON.parse(raw);
|
|
18631
|
+
await runDaemonUpgradeHelper(payload);
|
|
18632
|
+
process.exit(0);
|
|
18633
|
+
} catch (error48) {
|
|
18634
|
+
appendUpgradeLog(`Upgrade helper failed: ${error48?.stack || error48?.message || String(error48)}`);
|
|
18635
|
+
process.exit(1);
|
|
18636
|
+
}
|
|
18637
|
+
}
|
|
18638
|
+
var import_child_process5, import_child_process6, fs8, os12, path9, UPGRADE_HELPER_ENV;
|
|
18639
|
+
var init_upgrade_helper = __esm({
|
|
18640
|
+
"../../oss/packages/daemon-core/src/commands/upgrade-helper.ts"() {
|
|
18641
|
+
"use strict";
|
|
18642
|
+
import_child_process5 = require("child_process");
|
|
18643
|
+
import_child_process6 = require("child_process");
|
|
18644
|
+
fs8 = __toESM(require("fs"));
|
|
18645
|
+
os12 = __toESM(require("os"));
|
|
18646
|
+
path9 = __toESM(require("path"));
|
|
18647
|
+
UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
18648
|
+
}
|
|
18649
|
+
});
|
|
18650
|
+
|
|
18462
18651
|
// ../../oss/packages/daemon-core/src/commands/router.ts
|
|
18463
|
-
var
|
|
18652
|
+
var fs9, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
|
|
18464
18653
|
var init_router = __esm({
|
|
18465
18654
|
"../../oss/packages/daemon-core/src/commands/router.ts"() {
|
|
18466
18655
|
"use strict";
|
|
@@ -18476,7 +18665,8 @@ var init_router = __esm({
|
|
|
18476
18665
|
init_logger();
|
|
18477
18666
|
init_builders();
|
|
18478
18667
|
init_snapshot();
|
|
18479
|
-
|
|
18668
|
+
init_upgrade_helper();
|
|
18669
|
+
fs9 = __toESM(require("fs"));
|
|
18480
18670
|
CHAT_COMMANDS = [
|
|
18481
18671
|
"send_chat",
|
|
18482
18672
|
"new_chat",
|
|
@@ -18547,8 +18737,8 @@ var init_router = __esm({
|
|
|
18547
18737
|
if (logs.length > 0) {
|
|
18548
18738
|
return { success: true, logs, totalBuffered: logs.length };
|
|
18549
18739
|
}
|
|
18550
|
-
if (
|
|
18551
|
-
const content =
|
|
18740
|
+
if (fs9.existsSync(LOG_PATH)) {
|
|
18741
|
+
const content = fs9.readFileSync(LOG_PATH, "utf-8");
|
|
18552
18742
|
const allLines = content.split("\n");
|
|
18553
18743
|
const recent = allLines.slice(-count).join("\n");
|
|
18554
18744
|
return { success: true, logs: recent, totalLines: allLines.length };
|
|
@@ -18696,31 +18886,35 @@ var init_router = __esm({
|
|
|
18696
18886
|
const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
|
|
18697
18887
|
const latest = execSync7(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
18698
18888
|
LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
|
|
18699
|
-
|
|
18700
|
-
|
|
18701
|
-
|
|
18702
|
-
|
|
18889
|
+
let currentInstalled = null;
|
|
18890
|
+
try {
|
|
18891
|
+
const currentJson = execSync7(`npm ls -g ${pkgName} --depth=0 --json`, {
|
|
18892
|
+
encoding: "utf-8",
|
|
18893
|
+
timeout: 1e4,
|
|
18894
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
18895
|
+
}).trim();
|
|
18896
|
+
const parsed = JSON.parse(currentJson);
|
|
18897
|
+
currentInstalled = parsed?.dependencies?.[pkgName]?.version || null;
|
|
18898
|
+
} catch {
|
|
18899
|
+
}
|
|
18900
|
+
if (currentInstalled === latest) {
|
|
18901
|
+
LOG.info("Upgrade", `Already on latest version v${latest}; skipping install`);
|
|
18902
|
+
return { success: true, upgraded: false, alreadyLatest: true, version: latest };
|
|
18903
|
+
}
|
|
18904
|
+
spawnDetachedDaemonUpgradeHelper({
|
|
18905
|
+
packageName: pkgName,
|
|
18906
|
+
targetVersion: latest,
|
|
18907
|
+
parentPid: process.pid,
|
|
18908
|
+
restartArgv: process.argv.slice(1),
|
|
18909
|
+
cwd: process.cwd(),
|
|
18910
|
+
sessionHostAppName: process.env.ADHDEV_SESSION_HOST_NAME || "adhdev"
|
|
18703
18911
|
});
|
|
18704
|
-
LOG.info("Upgrade",
|
|
18912
|
+
LOG.info("Upgrade", `Scheduled detached upgrade to v${latest}`);
|
|
18705
18913
|
setTimeout(() => {
|
|
18706
|
-
LOG.info("Upgrade", "
|
|
18707
|
-
try {
|
|
18708
|
-
const path18 = require("path");
|
|
18709
|
-
const fs16 = require("fs");
|
|
18710
|
-
const pidFile = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
|
|
18711
|
-
if (fs16.existsSync(pidFile)) fs16.unlinkSync(pidFile);
|
|
18712
|
-
} catch {
|
|
18713
|
-
}
|
|
18714
|
-
const { spawn: spawn4 } = require("child_process");
|
|
18715
|
-
const child = spawn4(process.execPath, process.argv.slice(1), {
|
|
18716
|
-
detached: true,
|
|
18717
|
-
stdio: "ignore",
|
|
18718
|
-
env: { ...process.env }
|
|
18719
|
-
});
|
|
18720
|
-
child.unref();
|
|
18914
|
+
LOG.info("Upgrade", "Exiting daemon so detached upgrader can continue...");
|
|
18721
18915
|
process.exit(0);
|
|
18722
18916
|
}, 3e3);
|
|
18723
|
-
return { success: true, upgraded: true, version: latest };
|
|
18917
|
+
return { success: true, upgraded: true, version: latest, restarting: true };
|
|
18724
18918
|
} catch (e) {
|
|
18725
18919
|
LOG.error("Upgrade", `Failed: ${e.message}`);
|
|
18726
18920
|
return { success: false, error: e.message };
|
|
@@ -19023,11 +19217,11 @@ var init_reporter = __esm({
|
|
|
19023
19217
|
});
|
|
19024
19218
|
|
|
19025
19219
|
// ../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts
|
|
19026
|
-
var
|
|
19220
|
+
var os13, pty, NodePtyRuntimeTransport, NodePtyTransportFactory;
|
|
19027
19221
|
var init_pty_transport = __esm({
|
|
19028
19222
|
"../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts"() {
|
|
19029
19223
|
"use strict";
|
|
19030
|
-
|
|
19224
|
+
os13 = __toESM(require("os"));
|
|
19031
19225
|
try {
|
|
19032
19226
|
pty = require("node-pty");
|
|
19033
19227
|
} catch {
|
|
@@ -19065,7 +19259,7 @@ var init_pty_transport = __esm({
|
|
|
19065
19259
|
spawn(command, args, options) {
|
|
19066
19260
|
if (!pty) throw new Error("node-pty is not installed");
|
|
19067
19261
|
const handle = pty.spawn(command, args, {
|
|
19068
|
-
name:
|
|
19262
|
+
name: os13.platform() === "win32" ? "xterm-color" : "xterm-256color",
|
|
19069
19263
|
cols: options.cols,
|
|
19070
19264
|
rows: options.rows,
|
|
19071
19265
|
cwd: options.cwd,
|
|
@@ -19119,23 +19313,23 @@ function computeTerminalQueryTail(buffer) {
|
|
|
19119
19313
|
return "";
|
|
19120
19314
|
}
|
|
19121
19315
|
function findBinary(name) {
|
|
19122
|
-
const isWin =
|
|
19316
|
+
const isWin = os14.platform() === "win32";
|
|
19123
19317
|
try {
|
|
19124
19318
|
const cmd = isWin ? `where ${name}` : `which ${name}`;
|
|
19125
|
-
return (0,
|
|
19319
|
+
return (0, import_child_process7.execSync)(cmd, { encoding: "utf-8", timeout: 5e3, stdio: ["pipe", "pipe", "pipe"] }).trim().split("\n")[0].trim();
|
|
19126
19320
|
} catch {
|
|
19127
19321
|
return isWin ? `${name}.cmd` : name;
|
|
19128
19322
|
}
|
|
19129
19323
|
}
|
|
19130
19324
|
function isScriptBinary(binaryPath) {
|
|
19131
|
-
if (!
|
|
19325
|
+
if (!path10.isAbsolute(binaryPath)) return false;
|
|
19132
19326
|
try {
|
|
19133
|
-
const
|
|
19134
|
-
const resolved =
|
|
19327
|
+
const fs17 = require("fs");
|
|
19328
|
+
const resolved = fs17.realpathSync(binaryPath);
|
|
19135
19329
|
const head = Buffer.alloc(8);
|
|
19136
|
-
const fd =
|
|
19137
|
-
|
|
19138
|
-
|
|
19330
|
+
const fd = fs17.openSync(resolved, "r");
|
|
19331
|
+
fs17.readSync(fd, head, 0, 8, 0);
|
|
19332
|
+
fs17.closeSync(fd);
|
|
19139
19333
|
let i = 0;
|
|
19140
19334
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
19141
19335
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -19144,14 +19338,14 @@ function isScriptBinary(binaryPath) {
|
|
|
19144
19338
|
}
|
|
19145
19339
|
}
|
|
19146
19340
|
function looksLikeMachOOrElf(filePath) {
|
|
19147
|
-
if (!
|
|
19341
|
+
if (!path10.isAbsolute(filePath)) return false;
|
|
19148
19342
|
try {
|
|
19149
|
-
const
|
|
19150
|
-
const resolved =
|
|
19343
|
+
const fs17 = require("fs");
|
|
19344
|
+
const resolved = fs17.realpathSync(filePath);
|
|
19151
19345
|
const buf = Buffer.alloc(8);
|
|
19152
|
-
const fd =
|
|
19153
|
-
|
|
19154
|
-
|
|
19346
|
+
const fd = fs17.openSync(resolved, "r");
|
|
19347
|
+
fs17.readSync(fd, buf, 0, 8, 0);
|
|
19348
|
+
fs17.closeSync(fd);
|
|
19155
19349
|
let i = 0;
|
|
19156
19350
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
19157
19351
|
const b2 = buf.subarray(i);
|
|
@@ -19167,12 +19361,12 @@ function looksLikeMachOOrElf(filePath) {
|
|
|
19167
19361
|
}
|
|
19168
19362
|
function shSingleQuote(arg) {
|
|
19169
19363
|
if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
|
|
19170
|
-
if (
|
|
19364
|
+
if (os14.platform() === "win32") {
|
|
19171
19365
|
return `"${arg.replace(/"/g, '""')}"`;
|
|
19172
19366
|
}
|
|
19173
19367
|
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
19174
19368
|
}
|
|
19175
|
-
function estimatePromptDisplayLines(text, cols =
|
|
19369
|
+
function estimatePromptDisplayLines(text, cols = 80) {
|
|
19176
19370
|
const normalized = String(text || "").replace(/\r/g, "");
|
|
19177
19371
|
if (!normalized) return 1;
|
|
19178
19372
|
return normalized.split("\n").reduce((sum, line) => sum + Math.max(1, Math.ceil(Math.max(1, line.length) / cols)), 0);
|
|
@@ -19228,28 +19422,28 @@ function normalizeCliProviderForRuntime(raw) {
|
|
|
19228
19422
|
}
|
|
19229
19423
|
};
|
|
19230
19424
|
}
|
|
19231
|
-
var
|
|
19425
|
+
var os14, path10, import_child_process7, pty2, ProviderCliAdapter;
|
|
19232
19426
|
var init_provider_cli_adapter = __esm({
|
|
19233
19427
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
|
|
19234
19428
|
"use strict";
|
|
19235
|
-
|
|
19236
|
-
|
|
19237
|
-
|
|
19429
|
+
os14 = __toESM(require("os"));
|
|
19430
|
+
path10 = __toESM(require("path"));
|
|
19431
|
+
import_child_process7 = require("child_process");
|
|
19238
19432
|
init_logger();
|
|
19239
19433
|
init_terminal_screen();
|
|
19240
19434
|
init_pty_transport();
|
|
19241
19435
|
try {
|
|
19242
19436
|
pty2 = require("node-pty");
|
|
19243
|
-
if (
|
|
19437
|
+
if (os14.platform() !== "win32") {
|
|
19244
19438
|
try {
|
|
19245
|
-
const
|
|
19246
|
-
const ptyDir =
|
|
19247
|
-
const platformArch = `${
|
|
19248
|
-
const helper =
|
|
19249
|
-
if (
|
|
19250
|
-
const stat4 =
|
|
19439
|
+
const fs17 = require("fs");
|
|
19440
|
+
const ptyDir = path10.resolve(path10.dirname(require.resolve("node-pty")), "..");
|
|
19441
|
+
const platformArch = `${os14.platform()}-${os14.arch()}`;
|
|
19442
|
+
const helper = path10.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
19443
|
+
if (fs17.existsSync(helper)) {
|
|
19444
|
+
const stat4 = fs17.statSync(helper);
|
|
19251
19445
|
if (!(stat4.mode & 73)) {
|
|
19252
|
-
|
|
19446
|
+
fs17.chmodSync(helper, stat4.mode | 493);
|
|
19253
19447
|
LOG.info("CLI", "[node-pty] Fixed spawn-helper permissions");
|
|
19254
19448
|
}
|
|
19255
19449
|
}
|
|
@@ -19266,7 +19460,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
19266
19460
|
this.transportFactory = transportFactory;
|
|
19267
19461
|
this.cliType = provider.type;
|
|
19268
19462
|
this.cliName = provider.name;
|
|
19269
|
-
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/,
|
|
19463
|
+
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os14.homedir()) : workingDir;
|
|
19270
19464
|
const t = provider.timeouts || {};
|
|
19271
19465
|
this.timeouts = {
|
|
19272
19466
|
ptyFlush: t.ptyFlush ?? 50,
|
|
@@ -19433,12 +19627,12 @@ var init_provider_cli_adapter = __esm({
|
|
|
19433
19627
|
if (this.ptyProcess) return;
|
|
19434
19628
|
const { spawn: spawnConfig } = this.provider;
|
|
19435
19629
|
const binaryPath = findBinary(spawnConfig.command);
|
|
19436
|
-
const isWin =
|
|
19630
|
+
const isWin = os14.platform() === "win32";
|
|
19437
19631
|
const allArgs = [...spawnConfig.args, ...this.extraArgs];
|
|
19438
19632
|
LOG.info("CLI", `[${this.cliType}] Spawning in ${this.workingDir}`);
|
|
19439
19633
|
let shellCmd;
|
|
19440
19634
|
let shellArgs;
|
|
19441
|
-
const useShellUnix = !isWin && (!!spawnConfig.shell || !
|
|
19635
|
+
const useShellUnix = !isWin && (!!spawnConfig.shell || !path10.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
19442
19636
|
const useShell = isWin ? !!spawnConfig.shell : useShellUnix;
|
|
19443
19637
|
if (useShell) {
|
|
19444
19638
|
if (!spawnConfig.shell && !isWin) {
|
|
@@ -19456,8 +19650,8 @@ var init_provider_cli_adapter = __esm({
|
|
|
19456
19650
|
shellArgs = allArgs;
|
|
19457
19651
|
}
|
|
19458
19652
|
const ptyOpts = {
|
|
19459
|
-
cols:
|
|
19460
|
-
rows:
|
|
19653
|
+
cols: 80,
|
|
19654
|
+
rows: 24,
|
|
19461
19655
|
cwd: this.workingDir,
|
|
19462
19656
|
env: buildCliSpawnEnv(process.env, spawnConfig.env)
|
|
19463
19657
|
};
|
|
@@ -19513,7 +19707,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
19513
19707
|
this.spawnAt = Date.now();
|
|
19514
19708
|
this.startupParseGate = true;
|
|
19515
19709
|
this.startupBuffer = "";
|
|
19516
|
-
this.terminalScreen.reset(
|
|
19710
|
+
this.terminalScreen.reset(24, 80);
|
|
19517
19711
|
this.pendingTerminalQueryTail = "";
|
|
19518
19712
|
this.currentTurnScope = null;
|
|
19519
19713
|
this.ready = false;
|
|
@@ -20762,10 +20956,10 @@ function mergeDefs(...defs) {
|
|
|
20762
20956
|
function cloneDef(schema) {
|
|
20763
20957
|
return mergeDefs(schema._zod.def);
|
|
20764
20958
|
}
|
|
20765
|
-
function getElementAtPath(obj,
|
|
20766
|
-
if (!
|
|
20959
|
+
function getElementAtPath(obj, path19) {
|
|
20960
|
+
if (!path19)
|
|
20767
20961
|
return obj;
|
|
20768
|
-
return
|
|
20962
|
+
return path19.reduce((acc, key) => acc?.[key], obj);
|
|
20769
20963
|
}
|
|
20770
20964
|
function promiseAllObject(promisesObj) {
|
|
20771
20965
|
const keys = Object.keys(promisesObj);
|
|
@@ -21077,11 +21271,11 @@ function aborted(x, startIndex = 0) {
|
|
|
21077
21271
|
}
|
|
21078
21272
|
return false;
|
|
21079
21273
|
}
|
|
21080
|
-
function prefixIssues(
|
|
21274
|
+
function prefixIssues(path19, issues) {
|
|
21081
21275
|
return issues.map((iss) => {
|
|
21082
21276
|
var _a2;
|
|
21083
21277
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
21084
|
-
iss.path.unshift(
|
|
21278
|
+
iss.path.unshift(path19);
|
|
21085
21279
|
return iss;
|
|
21086
21280
|
});
|
|
21087
21281
|
}
|
|
@@ -21324,7 +21518,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
21324
21518
|
}
|
|
21325
21519
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
21326
21520
|
const result = { errors: [] };
|
|
21327
|
-
const processError = (error49,
|
|
21521
|
+
const processError = (error49, path19 = []) => {
|
|
21328
21522
|
var _a2, _b;
|
|
21329
21523
|
for (const issue2 of error49.issues) {
|
|
21330
21524
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -21334,7 +21528,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
21334
21528
|
} else if (issue2.code === "invalid_element") {
|
|
21335
21529
|
processError({ issues: issue2.issues }, issue2.path);
|
|
21336
21530
|
} else {
|
|
21337
|
-
const fullpath = [...
|
|
21531
|
+
const fullpath = [...path19, ...issue2.path];
|
|
21338
21532
|
if (fullpath.length === 0) {
|
|
21339
21533
|
result.errors.push(mapper(issue2));
|
|
21340
21534
|
continue;
|
|
@@ -21366,8 +21560,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
21366
21560
|
}
|
|
21367
21561
|
function toDotPath(_path) {
|
|
21368
21562
|
const segs = [];
|
|
21369
|
-
const
|
|
21370
|
-
for (const seg of
|
|
21563
|
+
const path19 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
21564
|
+
for (const seg of path19) {
|
|
21371
21565
|
if (typeof seg === "number")
|
|
21372
21566
|
segs.push(`[${seg}]`);
|
|
21373
21567
|
else if (typeof seg === "symbol")
|
|
@@ -34131,13 +34325,13 @@ function resolveRef(ref, ctx) {
|
|
|
34131
34325
|
if (!ref.startsWith("#")) {
|
|
34132
34326
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
34133
34327
|
}
|
|
34134
|
-
const
|
|
34135
|
-
if (
|
|
34328
|
+
const path19 = ref.slice(1).split("/").filter(Boolean);
|
|
34329
|
+
if (path19.length === 0) {
|
|
34136
34330
|
return ctx.rootSchema;
|
|
34137
34331
|
}
|
|
34138
34332
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
34139
|
-
if (
|
|
34140
|
-
const key =
|
|
34333
|
+
if (path19[0] === defsKey) {
|
|
34334
|
+
const key = path19[1];
|
|
34141
34335
|
if (!key || !ctx.defs[key]) {
|
|
34142
34336
|
throw new Error(`Reference not found: ${ref}`);
|
|
34143
34337
|
}
|
|
@@ -36822,12 +37016,12 @@ var init_contracts = __esm({
|
|
|
36822
37016
|
});
|
|
36823
37017
|
|
|
36824
37018
|
// ../../oss/packages/daemon-core/src/providers/acp-provider-instance.ts
|
|
36825
|
-
var import_stream,
|
|
37019
|
+
var import_stream, import_child_process8, AcpProviderInstance;
|
|
36826
37020
|
var init_acp_provider_instance = __esm({
|
|
36827
37021
|
"../../oss/packages/daemon-core/src/providers/acp-provider-instance.ts"() {
|
|
36828
37022
|
"use strict";
|
|
36829
37023
|
import_stream = require("stream");
|
|
36830
|
-
|
|
37024
|
+
import_child_process8 = require("child_process");
|
|
36831
37025
|
init_acp();
|
|
36832
37026
|
init_contracts();
|
|
36833
37027
|
init_status_monitor();
|
|
@@ -37151,7 +37345,7 @@ var init_acp_provider_instance = __esm({
|
|
|
37151
37345
|
this.errorMessage = null;
|
|
37152
37346
|
this.errorReason = null;
|
|
37153
37347
|
this.stderrBuffer = [];
|
|
37154
|
-
this.process = (0,
|
|
37348
|
+
this.process = (0, import_child_process8.spawn)(command, args, {
|
|
37155
37349
|
cwd: this.workingDir,
|
|
37156
37350
|
env,
|
|
37157
37351
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -37723,12 +37917,12 @@ function colorize(color, text) {
|
|
|
37723
37917
|
const fn2 = chalkApi?.[color];
|
|
37724
37918
|
return typeof fn2 === "function" ? fn2(text) : text;
|
|
37725
37919
|
}
|
|
37726
|
-
var
|
|
37920
|
+
var os15, path11, crypto4, import_chalk, chalkApi, DaemonCliManager;
|
|
37727
37921
|
var init_cli_manager = __esm({
|
|
37728
37922
|
"../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
|
|
37729
37923
|
"use strict";
|
|
37730
|
-
|
|
37731
|
-
|
|
37924
|
+
os15 = __toESM(require("os"));
|
|
37925
|
+
path11 = __toESM(require("path"));
|
|
37732
37926
|
crypto4 = __toESM(require("crypto"));
|
|
37733
37927
|
import_chalk = __toESM(require("chalk"));
|
|
37734
37928
|
init_provider_cli_adapter();
|
|
@@ -37851,7 +38045,7 @@ var init_cli_manager = __esm({
|
|
|
37851
38045
|
async startSession(cliType, workingDir, cliArgs, initialModel) {
|
|
37852
38046
|
const trimmed = (workingDir || "").trim();
|
|
37853
38047
|
if (!trimmed) throw new Error("working directory required");
|
|
37854
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/,
|
|
38048
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os15.homedir()) : path11.resolve(trimmed);
|
|
37855
38049
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
37856
38050
|
const provider = this.providerLoader.getByAlias(cliType);
|
|
37857
38051
|
const key = crypto4.randomUUID();
|
|
@@ -39107,7 +39301,7 @@ var init_provider_instance_manager = __esm({
|
|
|
39107
39301
|
// ../../oss/packages/daemon-core/src/providers/version-archive.ts
|
|
39108
39302
|
function runCommand(cmd, timeout = 1e4) {
|
|
39109
39303
|
try {
|
|
39110
|
-
return (0,
|
|
39304
|
+
return (0, import_child_process9.execSync)(cmd, {
|
|
39111
39305
|
encoding: "utf-8",
|
|
39112
39306
|
timeout,
|
|
39113
39307
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -39139,19 +39333,19 @@ function getVersion(binary, versionCommand) {
|
|
|
39139
39333
|
function checkPathExists2(paths) {
|
|
39140
39334
|
for (const p of paths) {
|
|
39141
39335
|
if (p.includes("*")) {
|
|
39142
|
-
const home =
|
|
39143
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
39144
|
-
if (
|
|
39336
|
+
const home = os16.homedir();
|
|
39337
|
+
const resolved = p.replace(/\*/g, home.split(path12.sep).pop() || "");
|
|
39338
|
+
if (fs10.existsSync(resolved)) return resolved;
|
|
39145
39339
|
} else {
|
|
39146
|
-
if (
|
|
39340
|
+
if (fs10.existsSync(p)) return p;
|
|
39147
39341
|
}
|
|
39148
39342
|
}
|
|
39149
39343
|
return null;
|
|
39150
39344
|
}
|
|
39151
39345
|
function getMacAppVersion(appPath) {
|
|
39152
39346
|
if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
39153
|
-
const plistPath =
|
|
39154
|
-
if (!
|
|
39347
|
+
const plistPath = path12.join(appPath, "Contents", "Info.plist");
|
|
39348
|
+
if (!fs10.existsSync(plistPath)) return null;
|
|
39155
39349
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
39156
39350
|
return raw || null;
|
|
39157
39351
|
}
|
|
@@ -39177,8 +39371,8 @@ async function detectAllVersions(loader, archive) {
|
|
|
39177
39371
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
39178
39372
|
let resolvedBin = cliBin;
|
|
39179
39373
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
39180
|
-
const bundled =
|
|
39181
|
-
if (provider.cli &&
|
|
39374
|
+
const bundled = path12.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
39375
|
+
if (provider.cli && fs10.existsSync(bundled)) resolvedBin = bundled;
|
|
39182
39376
|
}
|
|
39183
39377
|
info.installed = !!(appPath || resolvedBin);
|
|
39184
39378
|
info.path = appPath || null;
|
|
@@ -39214,16 +39408,16 @@ async function detectAllVersions(loader, archive) {
|
|
|
39214
39408
|
}
|
|
39215
39409
|
return results;
|
|
39216
39410
|
}
|
|
39217
|
-
var
|
|
39411
|
+
var fs10, path12, os16, import_child_process9, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
|
|
39218
39412
|
var init_version_archive = __esm({
|
|
39219
39413
|
"../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
|
|
39220
39414
|
"use strict";
|
|
39221
|
-
|
|
39222
|
-
|
|
39223
|
-
|
|
39224
|
-
|
|
39415
|
+
fs10 = __toESM(require("fs"));
|
|
39416
|
+
path12 = __toESM(require("path"));
|
|
39417
|
+
os16 = __toESM(require("os"));
|
|
39418
|
+
import_child_process9 = require("child_process");
|
|
39225
39419
|
import_os3 = require("os");
|
|
39226
|
-
ARCHIVE_PATH =
|
|
39420
|
+
ARCHIVE_PATH = path12.join(os16.homedir(), ".adhdev", "version-history.json");
|
|
39227
39421
|
MAX_ENTRIES_PER_PROVIDER = 20;
|
|
39228
39422
|
VersionArchive = class {
|
|
39229
39423
|
history = {};
|
|
@@ -39232,8 +39426,8 @@ var init_version_archive = __esm({
|
|
|
39232
39426
|
}
|
|
39233
39427
|
load() {
|
|
39234
39428
|
try {
|
|
39235
|
-
if (
|
|
39236
|
-
this.history = JSON.parse(
|
|
39429
|
+
if (fs10.existsSync(ARCHIVE_PATH)) {
|
|
39430
|
+
this.history = JSON.parse(fs10.readFileSync(ARCHIVE_PATH, "utf-8"));
|
|
39237
39431
|
}
|
|
39238
39432
|
} catch {
|
|
39239
39433
|
this.history = {};
|
|
@@ -39270,8 +39464,8 @@ var init_version_archive = __esm({
|
|
|
39270
39464
|
}
|
|
39271
39465
|
save() {
|
|
39272
39466
|
try {
|
|
39273
|
-
|
|
39274
|
-
|
|
39467
|
+
fs10.mkdirSync(path12.dirname(ARCHIVE_PATH), { recursive: true });
|
|
39468
|
+
fs10.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
39275
39469
|
} catch {
|
|
39276
39470
|
}
|
|
39277
39471
|
}
|
|
@@ -39791,18 +39985,18 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
39791
39985
|
return;
|
|
39792
39986
|
}
|
|
39793
39987
|
let scriptsPath = "";
|
|
39794
|
-
const directScripts =
|
|
39795
|
-
if (
|
|
39988
|
+
const directScripts = path13.join(dir, "scripts.js");
|
|
39989
|
+
if (fs11.existsSync(directScripts)) {
|
|
39796
39990
|
scriptsPath = directScripts;
|
|
39797
39991
|
} else {
|
|
39798
|
-
const scriptsDir =
|
|
39799
|
-
if (
|
|
39800
|
-
const versions =
|
|
39801
|
-
return
|
|
39992
|
+
const scriptsDir = path13.join(dir, "scripts");
|
|
39993
|
+
if (fs11.existsSync(scriptsDir)) {
|
|
39994
|
+
const versions = fs11.readdirSync(scriptsDir).filter((d) => {
|
|
39995
|
+
return fs11.statSync(path13.join(scriptsDir, d)).isDirectory();
|
|
39802
39996
|
}).sort().reverse();
|
|
39803
39997
|
for (const ver of versions) {
|
|
39804
|
-
const p =
|
|
39805
|
-
if (
|
|
39998
|
+
const p = path13.join(scriptsDir, ver, "scripts.js");
|
|
39999
|
+
if (fs11.existsSync(p)) {
|
|
39806
40000
|
scriptsPath = p;
|
|
39807
40001
|
break;
|
|
39808
40002
|
}
|
|
@@ -39814,7 +40008,7 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
39814
40008
|
return;
|
|
39815
40009
|
}
|
|
39816
40010
|
try {
|
|
39817
|
-
const source =
|
|
40011
|
+
const source = fs11.readFileSync(scriptsPath, "utf-8");
|
|
39818
40012
|
const hints = {};
|
|
39819
40013
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
39820
40014
|
let match;
|
|
@@ -40617,12 +40811,12 @@ async function handleDomContext(ctx, type, req, res) {
|
|
|
40617
40811
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
40618
40812
|
}
|
|
40619
40813
|
}
|
|
40620
|
-
var
|
|
40814
|
+
var fs11, path13;
|
|
40621
40815
|
var init_dev_cdp_handlers = __esm({
|
|
40622
40816
|
"../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
|
|
40623
40817
|
"use strict";
|
|
40624
|
-
|
|
40625
|
-
|
|
40818
|
+
fs11 = __toESM(require("fs"));
|
|
40819
|
+
path13 = __toESM(require("path"));
|
|
40626
40820
|
init_logger();
|
|
40627
40821
|
}
|
|
40628
40822
|
});
|
|
@@ -40884,45 +41078,45 @@ function resolveAutoImplReference(ctx, category, requestedReference, targetType)
|
|
|
40884
41078
|
return fallback?.type || null;
|
|
40885
41079
|
}
|
|
40886
41080
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
40887
|
-
if (!
|
|
40888
|
-
const versions =
|
|
41081
|
+
if (!fs12.existsSync(scriptsDir)) return null;
|
|
41082
|
+
const versions = fs12.readdirSync(scriptsDir).filter((d) => {
|
|
40889
41083
|
try {
|
|
40890
|
-
return
|
|
41084
|
+
return fs12.statSync(path14.join(scriptsDir, d)).isDirectory();
|
|
40891
41085
|
} catch {
|
|
40892
41086
|
return false;
|
|
40893
41087
|
}
|
|
40894
41088
|
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
40895
41089
|
if (versions.length === 0) return null;
|
|
40896
|
-
return
|
|
41090
|
+
return path14.join(scriptsDir, versions[0]);
|
|
40897
41091
|
}
|
|
40898
41092
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
40899
|
-
const canonicalUserDir =
|
|
40900
|
-
const desiredDir = requestedDir ?
|
|
40901
|
-
const upstreamRoot =
|
|
40902
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
41093
|
+
const canonicalUserDir = path14.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
41094
|
+
const desiredDir = requestedDir ? path14.resolve(requestedDir) : canonicalUserDir;
|
|
41095
|
+
const upstreamRoot = path14.resolve(ctx.providerLoader.getUpstreamDir());
|
|
41096
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path14.sep}`)) {
|
|
40903
41097
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
40904
41098
|
}
|
|
40905
|
-
if (
|
|
41099
|
+
if (path14.basename(desiredDir) !== type) {
|
|
40906
41100
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
40907
41101
|
}
|
|
40908
41102
|
const sourceDir = ctx.findProviderDir(type);
|
|
40909
41103
|
if (!sourceDir) {
|
|
40910
41104
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
40911
41105
|
}
|
|
40912
|
-
if (!
|
|
40913
|
-
|
|
40914
|
-
|
|
41106
|
+
if (!fs12.existsSync(desiredDir)) {
|
|
41107
|
+
fs12.mkdirSync(path14.dirname(desiredDir), { recursive: true });
|
|
41108
|
+
fs12.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
40915
41109
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
40916
41110
|
}
|
|
40917
|
-
const providerJson =
|
|
40918
|
-
if (!
|
|
41111
|
+
const providerJson = path14.join(desiredDir, "provider.json");
|
|
41112
|
+
if (!fs12.existsSync(providerJson)) {
|
|
40919
41113
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
40920
41114
|
}
|
|
40921
41115
|
try {
|
|
40922
|
-
const providerData = JSON.parse(
|
|
41116
|
+
const providerData = JSON.parse(fs12.readFileSync(providerJson, "utf-8"));
|
|
40923
41117
|
if (providerData.disableUpstream !== true) {
|
|
40924
41118
|
providerData.disableUpstream = true;
|
|
40925
|
-
|
|
41119
|
+
fs12.writeFileSync(providerJson, JSON.stringify(providerData, null, 2));
|
|
40926
41120
|
}
|
|
40927
41121
|
} catch (error48) {
|
|
40928
41122
|
return {
|
|
@@ -40935,15 +41129,15 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
40935
41129
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
40936
41130
|
if (!referenceType) return {};
|
|
40937
41131
|
const refDir = ctx.findProviderDir(referenceType);
|
|
40938
|
-
if (!refDir || !
|
|
41132
|
+
if (!refDir || !fs12.existsSync(refDir)) return {};
|
|
40939
41133
|
const referenceScripts = {};
|
|
40940
|
-
const scriptsDir =
|
|
41134
|
+
const scriptsDir = path14.join(refDir, "scripts");
|
|
40941
41135
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
40942
41136
|
if (!latestDir) return referenceScripts;
|
|
40943
|
-
for (const file2 of
|
|
41137
|
+
for (const file2 of fs12.readdirSync(latestDir)) {
|
|
40944
41138
|
if (!file2.endsWith(".js")) continue;
|
|
40945
41139
|
try {
|
|
40946
|
-
referenceScripts[file2] =
|
|
41140
|
+
referenceScripts[file2] = fs12.readFileSync(path14.join(latestDir, file2), "utf-8");
|
|
40947
41141
|
} catch {
|
|
40948
41142
|
}
|
|
40949
41143
|
}
|
|
@@ -40994,16 +41188,16 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
40994
41188
|
});
|
|
40995
41189
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
40996
41190
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference);
|
|
40997
|
-
const tmpDir =
|
|
40998
|
-
if (!
|
|
40999
|
-
const promptFile =
|
|
41000
|
-
|
|
41191
|
+
const tmpDir = path14.join(os17.tmpdir(), "adhdev-autoimpl");
|
|
41192
|
+
if (!fs12.existsSync(tmpDir)) fs12.mkdirSync(tmpDir, { recursive: true });
|
|
41193
|
+
const promptFile = path14.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
41194
|
+
fs12.writeFileSync(promptFile, prompt, "utf-8");
|
|
41001
41195
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
41002
41196
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
41003
|
-
const
|
|
41004
|
-
if (!
|
|
41197
|
+
const spawn5 = agentProvider?.spawn;
|
|
41198
|
+
if (!spawn5?.command) {
|
|
41005
41199
|
try {
|
|
41006
|
-
|
|
41200
|
+
fs12.unlinkSync(promptFile);
|
|
41007
41201
|
} catch {
|
|
41008
41202
|
}
|
|
41009
41203
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -41011,21 +41205,21 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41011
41205
|
}
|
|
41012
41206
|
const agentCategory = agentProvider?.category;
|
|
41013
41207
|
if (agentCategory === "acp") {
|
|
41014
|
-
sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${
|
|
41208
|
+
sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${spawn5.command} ${(spawn5.args || []).join(" ")}` } });
|
|
41015
41209
|
ctx.autoImplStatus = { running: true, type, progress: [] };
|
|
41016
41210
|
const { ClientSideConnection: ClientSideConnection2, ndJsonStream: ndJsonStream2, PROTOCOL_VERSION: PROTOCOL_VERSION2 } = await Promise.resolve().then(() => (init_acp(), acp_exports));
|
|
41017
41211
|
const { Readable: Readable3, Writable: Writable2 } = await import("stream");
|
|
41018
41212
|
const { spawn: spawnFn2 } = await import("child_process");
|
|
41019
|
-
const acpArgs = [...
|
|
41213
|
+
const acpArgs = [...spawn5.args || []];
|
|
41020
41214
|
if (model) {
|
|
41021
41215
|
acpArgs.push("--model", model);
|
|
41022
41216
|
ctx.log(`Auto-implement ACP using model: ${model}`);
|
|
41023
41217
|
}
|
|
41024
|
-
const child2 = spawnFn2(
|
|
41218
|
+
const child2 = spawnFn2(spawn5.command, acpArgs, {
|
|
41025
41219
|
cwd: providerDir,
|
|
41026
41220
|
stdio: ["pipe", "pipe", "pipe"],
|
|
41027
|
-
shell:
|
|
41028
|
-
env: { ...process.env, ...
|
|
41221
|
+
shell: spawn5.shell ?? false,
|
|
41222
|
+
env: { ...process.env, ...spawn5.env || {} }
|
|
41029
41223
|
});
|
|
41030
41224
|
ctx.autoImplProcess = child2;
|
|
41031
41225
|
child2.stderr?.on("data", (d) => {
|
|
@@ -41104,7 +41298,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41104
41298
|
} catch {
|
|
41105
41299
|
}
|
|
41106
41300
|
try {
|
|
41107
|
-
|
|
41301
|
+
fs12.unlinkSync(promptFile);
|
|
41108
41302
|
} catch {
|
|
41109
41303
|
}
|
|
41110
41304
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -41135,7 +41329,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41135
41329
|
ctx.json(res, 202, {
|
|
41136
41330
|
started: true,
|
|
41137
41331
|
type,
|
|
41138
|
-
agent:
|
|
41332
|
+
agent: spawn5.command,
|
|
41139
41333
|
functions,
|
|
41140
41334
|
providerDir,
|
|
41141
41335
|
message: "ACP Auto-implement started. Connect to SSE for progress.",
|
|
@@ -41143,11 +41337,11 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41143
41337
|
});
|
|
41144
41338
|
return;
|
|
41145
41339
|
}
|
|
41146
|
-
const command =
|
|
41340
|
+
const command = spawn5.command;
|
|
41147
41341
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
41148
|
-
const baseArgs = [...
|
|
41342
|
+
const baseArgs = [...spawn5.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
41149
41343
|
let shellCmd;
|
|
41150
|
-
const isWin =
|
|
41344
|
+
const isWin = os17.platform() === "win32";
|
|
41151
41345
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
41152
41346
|
if (command === "claude") {
|
|
41153
41347
|
const args = [...baseArgs, "--dangerously-skip-permissions"];
|
|
@@ -41190,13 +41384,13 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41190
41384
|
try {
|
|
41191
41385
|
const pty3 = require("node-pty");
|
|
41192
41386
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
41193
|
-
const isWin2 =
|
|
41387
|
+
const isWin2 = os17.platform() === "win32";
|
|
41194
41388
|
child = pty3.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
41195
41389
|
name: "xterm-256color",
|
|
41196
41390
|
cols: 120,
|
|
41197
41391
|
rows: 40,
|
|
41198
41392
|
cwd: providerDir,
|
|
41199
|
-
env: { ...process.env, ...
|
|
41393
|
+
env: { ...process.env, ...spawn5.env || {} }
|
|
41200
41394
|
});
|
|
41201
41395
|
isPty = true;
|
|
41202
41396
|
} catch (err) {
|
|
@@ -41208,7 +41402,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41208
41402
|
stdio: ["pipe", "pipe", "pipe"],
|
|
41209
41403
|
env: {
|
|
41210
41404
|
...process.env,
|
|
41211
|
-
...
|
|
41405
|
+
...spawn5.env || {},
|
|
41212
41406
|
...command === "gemini" ? { SANDBOX: "1", GEMINI_CLI_NO_RELAUNCH: "1" } : {}
|
|
41213
41407
|
}
|
|
41214
41408
|
});
|
|
@@ -41284,7 +41478,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41284
41478
|
} catch {
|
|
41285
41479
|
}
|
|
41286
41480
|
try {
|
|
41287
|
-
|
|
41481
|
+
fs12.unlinkSync(promptFile);
|
|
41288
41482
|
} catch {
|
|
41289
41483
|
}
|
|
41290
41484
|
});
|
|
@@ -41320,7 +41514,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41320
41514
|
} catch {
|
|
41321
41515
|
}
|
|
41322
41516
|
try {
|
|
41323
|
-
|
|
41517
|
+
fs12.unlinkSync(promptFile);
|
|
41324
41518
|
} catch {
|
|
41325
41519
|
}
|
|
41326
41520
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -41367,7 +41561,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41367
41561
|
setMode: "set_mode.js"
|
|
41368
41562
|
};
|
|
41369
41563
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
41370
|
-
const scriptsDir =
|
|
41564
|
+
const scriptsDir = path14.join(providerDir, "scripts");
|
|
41371
41565
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
41372
41566
|
if (latestScriptsDir) {
|
|
41373
41567
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -41375,10 +41569,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41375
41569
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
41376
41570
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
41377
41571
|
lines.push("");
|
|
41378
|
-
for (const file2 of
|
|
41572
|
+
for (const file2 of fs12.readdirSync(latestScriptsDir)) {
|
|
41379
41573
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
41380
41574
|
try {
|
|
41381
|
-
const content =
|
|
41575
|
+
const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
41382
41576
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
41383
41577
|
lines.push("```javascript");
|
|
41384
41578
|
lines.push(content);
|
|
@@ -41388,14 +41582,14 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41388
41582
|
}
|
|
41389
41583
|
}
|
|
41390
41584
|
}
|
|
41391
|
-
const refFiles =
|
|
41585
|
+
const refFiles = fs12.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
41392
41586
|
if (refFiles.length > 0) {
|
|
41393
41587
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
41394
41588
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
41395
41589
|
lines.push("");
|
|
41396
41590
|
for (const file2 of refFiles) {
|
|
41397
41591
|
try {
|
|
41398
|
-
const content =
|
|
41592
|
+
const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
41399
41593
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
41400
41594
|
lines.push("```javascript");
|
|
41401
41595
|
lines.push(content);
|
|
@@ -41436,11 +41630,11 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41436
41630
|
lines.push("");
|
|
41437
41631
|
}
|
|
41438
41632
|
}
|
|
41439
|
-
const docsDir =
|
|
41633
|
+
const docsDir = path14.join(providerDir, "../../docs");
|
|
41440
41634
|
const loadGuide = (name) => {
|
|
41441
41635
|
try {
|
|
41442
|
-
const p =
|
|
41443
|
-
if (
|
|
41636
|
+
const p = path14.join(docsDir, name);
|
|
41637
|
+
if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
|
|
41444
41638
|
} catch {
|
|
41445
41639
|
}
|
|
41446
41640
|
return null;
|
|
@@ -41613,7 +41807,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41613
41807
|
parseApproval: "parse_approval.js"
|
|
41614
41808
|
};
|
|
41615
41809
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
41616
|
-
const scriptsDir =
|
|
41810
|
+
const scriptsDir = path14.join(providerDir, "scripts");
|
|
41617
41811
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
41618
41812
|
if (latestScriptsDir) {
|
|
41619
41813
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -41621,11 +41815,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41621
41815
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
41622
41816
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
41623
41817
|
lines.push("");
|
|
41624
|
-
for (const file2 of
|
|
41818
|
+
for (const file2 of fs12.readdirSync(latestScriptsDir)) {
|
|
41625
41819
|
if (!file2.endsWith(".js")) continue;
|
|
41626
41820
|
if (!targetFileNames.has(file2)) continue;
|
|
41627
41821
|
try {
|
|
41628
|
-
const content =
|
|
41822
|
+
const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
41629
41823
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
41630
41824
|
lines.push("```javascript");
|
|
41631
41825
|
lines.push(content);
|
|
@@ -41634,14 +41828,14 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41634
41828
|
} catch {
|
|
41635
41829
|
}
|
|
41636
41830
|
}
|
|
41637
|
-
const refFiles =
|
|
41831
|
+
const refFiles = fs12.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
41638
41832
|
if (refFiles.length > 0) {
|
|
41639
41833
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
41640
41834
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
41641
41835
|
lines.push("");
|
|
41642
41836
|
for (const file2 of refFiles) {
|
|
41643
41837
|
try {
|
|
41644
|
-
const content =
|
|
41838
|
+
const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
41645
41839
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
41646
41840
|
lines.push("```javascript");
|
|
41647
41841
|
lines.push(content);
|
|
@@ -41674,11 +41868,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41674
41868
|
lines.push("");
|
|
41675
41869
|
}
|
|
41676
41870
|
}
|
|
41677
|
-
const docsDir =
|
|
41871
|
+
const docsDir = path14.join(providerDir, "../../docs");
|
|
41678
41872
|
const loadGuide = (name) => {
|
|
41679
41873
|
try {
|
|
41680
|
-
const p =
|
|
41681
|
-
if (
|
|
41874
|
+
const p = path14.join(docsDir, name);
|
|
41875
|
+
if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
|
|
41682
41876
|
} catch {
|
|
41683
41877
|
}
|
|
41684
41878
|
return null;
|
|
@@ -41841,25 +42035,25 @@ data: ${JSON.stringify(msg.data)}
|
|
|
41841
42035
|
}
|
|
41842
42036
|
}
|
|
41843
42037
|
}
|
|
41844
|
-
var
|
|
42038
|
+
var fs12, path14, os17;
|
|
41845
42039
|
var init_dev_auto_implement = __esm({
|
|
41846
42040
|
"../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
|
|
41847
42041
|
"use strict";
|
|
41848
|
-
|
|
41849
|
-
|
|
41850
|
-
|
|
42042
|
+
fs12 = __toESM(require("fs"));
|
|
42043
|
+
path14 = __toESM(require("path"));
|
|
42044
|
+
os17 = __toESM(require("os"));
|
|
41851
42045
|
init_dev_server();
|
|
41852
42046
|
}
|
|
41853
42047
|
});
|
|
41854
42048
|
|
|
41855
42049
|
// ../../oss/packages/daemon-core/src/daemon/dev-server.ts
|
|
41856
|
-
var http2,
|
|
42050
|
+
var http2, fs13, path15, DEV_SERVER_PORT, DevServer;
|
|
41857
42051
|
var init_dev_server = __esm({
|
|
41858
42052
|
"../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
|
|
41859
42053
|
"use strict";
|
|
41860
42054
|
http2 = __toESM(require("http"));
|
|
41861
|
-
|
|
41862
|
-
|
|
42055
|
+
fs13 = __toESM(require("fs"));
|
|
42056
|
+
path15 = __toESM(require("path"));
|
|
41863
42057
|
init_scaffold_template();
|
|
41864
42058
|
init_version_archive();
|
|
41865
42059
|
init_logger();
|
|
@@ -41958,8 +42152,8 @@ var init_dev_server = __esm({
|
|
|
41958
42152
|
}
|
|
41959
42153
|
getEndpointList() {
|
|
41960
42154
|
return this.routes.map((r) => {
|
|
41961
|
-
const
|
|
41962
|
-
return `${r.method.padEnd(5)} ${
|
|
42155
|
+
const path19 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
42156
|
+
return `${r.method.padEnd(5)} ${path19}`;
|
|
41963
42157
|
});
|
|
41964
42158
|
}
|
|
41965
42159
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -42060,16 +42254,16 @@ var init_dev_server = __esm({
|
|
|
42060
42254
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
42061
42255
|
return;
|
|
42062
42256
|
}
|
|
42063
|
-
const
|
|
42064
|
-
if (!
|
|
42257
|
+
const spawn5 = provider.spawn;
|
|
42258
|
+
if (!spawn5) {
|
|
42065
42259
|
this.json(res, 400, { error: `Provider ${type} has no spawn config` });
|
|
42066
42260
|
return;
|
|
42067
42261
|
}
|
|
42068
42262
|
const { spawn: spawnFn } = await import("child_process");
|
|
42069
42263
|
const start = Date.now();
|
|
42070
42264
|
try {
|
|
42071
|
-
const child = spawnFn(
|
|
42072
|
-
shell:
|
|
42265
|
+
const child = spawnFn(spawn5.command, [...spawn5.args || []], {
|
|
42266
|
+
shell: spawn5.shell ?? false,
|
|
42073
42267
|
timeout: 5e3,
|
|
42074
42268
|
stdio: ["pipe", "pipe", "pipe"]
|
|
42075
42269
|
});
|
|
@@ -42101,7 +42295,7 @@ var init_dev_server = __esm({
|
|
|
42101
42295
|
const elapsed = Date.now() - start;
|
|
42102
42296
|
this.json(res, 200, {
|
|
42103
42297
|
success: true,
|
|
42104
|
-
command: `${
|
|
42298
|
+
command: `${spawn5.command} ${(spawn5.args || []).join(" ")}`,
|
|
42105
42299
|
elapsed,
|
|
42106
42300
|
stdout: stdout.trim(),
|
|
42107
42301
|
stderr: stderr.trim(),
|
|
@@ -42111,7 +42305,7 @@ var init_dev_server = __esm({
|
|
|
42111
42305
|
const elapsed = Date.now() - start;
|
|
42112
42306
|
this.json(res, 200, {
|
|
42113
42307
|
success: false,
|
|
42114
|
-
command: `${
|
|
42308
|
+
command: `${spawn5.command} ${(spawn5.args || []).join(" ")}`,
|
|
42115
42309
|
elapsed,
|
|
42116
42310
|
error: e.message
|
|
42117
42311
|
});
|
|
@@ -42241,12 +42435,12 @@ var init_dev_server = __esm({
|
|
|
42241
42435
|
// ─── DevConsole SPA ───
|
|
42242
42436
|
getConsoleDistDir() {
|
|
42243
42437
|
const candidates = [
|
|
42244
|
-
|
|
42245
|
-
|
|
42246
|
-
|
|
42438
|
+
path15.resolve(__dirname, "../../web-devconsole/dist"),
|
|
42439
|
+
path15.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
42440
|
+
path15.join(process.cwd(), "packages/web-devconsole/dist")
|
|
42247
42441
|
];
|
|
42248
42442
|
for (const dir of candidates) {
|
|
42249
|
-
if (
|
|
42443
|
+
if (fs13.existsSync(path15.join(dir, "index.html"))) return dir;
|
|
42250
42444
|
}
|
|
42251
42445
|
return null;
|
|
42252
42446
|
}
|
|
@@ -42256,9 +42450,9 @@ var init_dev_server = __esm({
|
|
|
42256
42450
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
42257
42451
|
return;
|
|
42258
42452
|
}
|
|
42259
|
-
const htmlPath =
|
|
42453
|
+
const htmlPath = path15.join(distDir, "index.html");
|
|
42260
42454
|
try {
|
|
42261
|
-
const html =
|
|
42455
|
+
const html = fs13.readFileSync(htmlPath, "utf-8");
|
|
42262
42456
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
42263
42457
|
res.end(html);
|
|
42264
42458
|
} catch (e) {
|
|
@@ -42281,15 +42475,15 @@ var init_dev_server = __esm({
|
|
|
42281
42475
|
this.json(res, 404, { error: "Not found" });
|
|
42282
42476
|
return;
|
|
42283
42477
|
}
|
|
42284
|
-
const safePath =
|
|
42285
|
-
const filePath =
|
|
42478
|
+
const safePath = path15.normalize(pathname).replace(/^\.\.\//, "");
|
|
42479
|
+
const filePath = path15.join(distDir, safePath);
|
|
42286
42480
|
if (!filePath.startsWith(distDir)) {
|
|
42287
42481
|
this.json(res, 403, { error: "Forbidden" });
|
|
42288
42482
|
return;
|
|
42289
42483
|
}
|
|
42290
42484
|
try {
|
|
42291
|
-
const content =
|
|
42292
|
-
const ext =
|
|
42485
|
+
const content = fs13.readFileSync(filePath);
|
|
42486
|
+
const ext = path15.extname(filePath);
|
|
42293
42487
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
42294
42488
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
42295
42489
|
res.end(content);
|
|
@@ -42397,14 +42591,14 @@ var init_dev_server = __esm({
|
|
|
42397
42591
|
const files = [];
|
|
42398
42592
|
const scan = (d, prefix) => {
|
|
42399
42593
|
try {
|
|
42400
|
-
for (const entry of
|
|
42594
|
+
for (const entry of fs13.readdirSync(d, { withFileTypes: true })) {
|
|
42401
42595
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
42402
42596
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
42403
42597
|
if (entry.isDirectory()) {
|
|
42404
42598
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
42405
|
-
scan(
|
|
42599
|
+
scan(path15.join(d, entry.name), rel);
|
|
42406
42600
|
} else {
|
|
42407
|
-
const stat4 =
|
|
42601
|
+
const stat4 = fs13.statSync(path15.join(d, entry.name));
|
|
42408
42602
|
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
42409
42603
|
}
|
|
42410
42604
|
}
|
|
@@ -42427,16 +42621,16 @@ var init_dev_server = __esm({
|
|
|
42427
42621
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
42428
42622
|
return;
|
|
42429
42623
|
}
|
|
42430
|
-
const fullPath =
|
|
42624
|
+
const fullPath = path15.resolve(dir, path15.normalize(filePath));
|
|
42431
42625
|
if (!fullPath.startsWith(dir)) {
|
|
42432
42626
|
this.json(res, 403, { error: "Forbidden" });
|
|
42433
42627
|
return;
|
|
42434
42628
|
}
|
|
42435
|
-
if (!
|
|
42629
|
+
if (!fs13.existsSync(fullPath) || fs13.statSync(fullPath).isDirectory()) {
|
|
42436
42630
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
42437
42631
|
return;
|
|
42438
42632
|
}
|
|
42439
|
-
const content =
|
|
42633
|
+
const content = fs13.readFileSync(fullPath, "utf-8");
|
|
42440
42634
|
this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
|
|
42441
42635
|
}
|
|
42442
42636
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -42452,15 +42646,15 @@ var init_dev_server = __esm({
|
|
|
42452
42646
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
42453
42647
|
return;
|
|
42454
42648
|
}
|
|
42455
|
-
const fullPath =
|
|
42649
|
+
const fullPath = path15.resolve(dir, path15.normalize(filePath));
|
|
42456
42650
|
if (!fullPath.startsWith(dir)) {
|
|
42457
42651
|
this.json(res, 403, { error: "Forbidden" });
|
|
42458
42652
|
return;
|
|
42459
42653
|
}
|
|
42460
42654
|
try {
|
|
42461
|
-
if (
|
|
42462
|
-
|
|
42463
|
-
|
|
42655
|
+
if (fs13.existsSync(fullPath)) fs13.copyFileSync(fullPath, fullPath + ".bak");
|
|
42656
|
+
fs13.mkdirSync(path15.dirname(fullPath), { recursive: true });
|
|
42657
|
+
fs13.writeFileSync(fullPath, content, "utf-8");
|
|
42464
42658
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
42465
42659
|
this.providerLoader.reload();
|
|
42466
42660
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -42476,9 +42670,9 @@ var init_dev_server = __esm({
|
|
|
42476
42670
|
return;
|
|
42477
42671
|
}
|
|
42478
42672
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
42479
|
-
const p =
|
|
42480
|
-
if (
|
|
42481
|
-
const source =
|
|
42673
|
+
const p = path15.join(dir, name);
|
|
42674
|
+
if (fs13.existsSync(p)) {
|
|
42675
|
+
const source = fs13.readFileSync(p, "utf-8");
|
|
42482
42676
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
42483
42677
|
return;
|
|
42484
42678
|
}
|
|
@@ -42497,11 +42691,11 @@ var init_dev_server = __esm({
|
|
|
42497
42691
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
42498
42692
|
return;
|
|
42499
42693
|
}
|
|
42500
|
-
const target =
|
|
42501
|
-
const targetPath =
|
|
42694
|
+
const target = fs13.existsSync(path15.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
42695
|
+
const targetPath = path15.join(dir, target);
|
|
42502
42696
|
try {
|
|
42503
|
-
if (
|
|
42504
|
-
|
|
42697
|
+
if (fs13.existsSync(targetPath)) fs13.copyFileSync(targetPath, targetPath + ".bak");
|
|
42698
|
+
fs13.writeFileSync(targetPath, source, "utf-8");
|
|
42505
42699
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
42506
42700
|
this.providerLoader.reload();
|
|
42507
42701
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -42580,20 +42774,20 @@ var init_dev_server = __esm({
|
|
|
42580
42774
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
42581
42775
|
return;
|
|
42582
42776
|
}
|
|
42583
|
-
const
|
|
42584
|
-
if (!
|
|
42777
|
+
const spawn5 = provider.spawn;
|
|
42778
|
+
if (!spawn5) {
|
|
42585
42779
|
this.json(res, 400, { error: `Provider ${type} has no spawn config` });
|
|
42586
42780
|
return;
|
|
42587
42781
|
}
|
|
42588
42782
|
const { spawn: spawnFn } = await import("child_process");
|
|
42589
42783
|
const start = Date.now();
|
|
42590
42784
|
try {
|
|
42591
|
-
const args = [...
|
|
42592
|
-
const child = spawnFn(
|
|
42593
|
-
shell:
|
|
42785
|
+
const args = [...spawn5.args || [], message];
|
|
42786
|
+
const child = spawnFn(spawn5.command, args, {
|
|
42787
|
+
shell: spawn5.shell ?? false,
|
|
42594
42788
|
timeout,
|
|
42595
42789
|
stdio: ["pipe", "pipe", "pipe"],
|
|
42596
|
-
env: { ...process.env, ...
|
|
42790
|
+
env: { ...process.env, ...spawn5.env || {} }
|
|
42597
42791
|
});
|
|
42598
42792
|
let stdout = "";
|
|
42599
42793
|
let stderr = "";
|
|
@@ -42658,21 +42852,21 @@ var init_dev_server = __esm({
|
|
|
42658
42852
|
}
|
|
42659
42853
|
let targetDir;
|
|
42660
42854
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
42661
|
-
const jsonPath =
|
|
42662
|
-
if (
|
|
42855
|
+
const jsonPath = path15.join(targetDir, "provider.json");
|
|
42856
|
+
if (fs13.existsSync(jsonPath)) {
|
|
42663
42857
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
42664
42858
|
return;
|
|
42665
42859
|
}
|
|
42666
42860
|
try {
|
|
42667
42861
|
const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
|
|
42668
|
-
|
|
42669
|
-
|
|
42862
|
+
fs13.mkdirSync(targetDir, { recursive: true });
|
|
42863
|
+
fs13.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
42670
42864
|
const createdFiles = ["provider.json"];
|
|
42671
42865
|
if (result.files) {
|
|
42672
42866
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
42673
|
-
const fullPath =
|
|
42674
|
-
|
|
42675
|
-
|
|
42867
|
+
const fullPath = path15.join(targetDir, relPath);
|
|
42868
|
+
fs13.mkdirSync(path15.dirname(fullPath), { recursive: true });
|
|
42869
|
+
fs13.writeFileSync(fullPath, content, "utf-8");
|
|
42676
42870
|
createdFiles.push(relPath);
|
|
42677
42871
|
}
|
|
42678
42872
|
}
|
|
@@ -42721,45 +42915,45 @@ var init_dev_server = __esm({
|
|
|
42721
42915
|
}
|
|
42722
42916
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
42723
42917
|
getLatestScriptVersionDir(scriptsDir) {
|
|
42724
|
-
if (!
|
|
42725
|
-
const versions =
|
|
42918
|
+
if (!fs13.existsSync(scriptsDir)) return null;
|
|
42919
|
+
const versions = fs13.readdirSync(scriptsDir).filter((d) => {
|
|
42726
42920
|
try {
|
|
42727
|
-
return
|
|
42921
|
+
return fs13.statSync(path15.join(scriptsDir, d)).isDirectory();
|
|
42728
42922
|
} catch {
|
|
42729
42923
|
return false;
|
|
42730
42924
|
}
|
|
42731
42925
|
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
42732
42926
|
if (versions.length === 0) return null;
|
|
42733
|
-
return
|
|
42927
|
+
return path15.join(scriptsDir, versions[0]);
|
|
42734
42928
|
}
|
|
42735
42929
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
42736
|
-
const canonicalUserDir =
|
|
42737
|
-
const desiredDir = requestedDir ?
|
|
42738
|
-
const upstreamRoot =
|
|
42739
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
42930
|
+
const canonicalUserDir = path15.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
42931
|
+
const desiredDir = requestedDir ? path15.resolve(requestedDir) : canonicalUserDir;
|
|
42932
|
+
const upstreamRoot = path15.resolve(this.providerLoader.getUpstreamDir());
|
|
42933
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path15.sep}`)) {
|
|
42740
42934
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
42741
42935
|
}
|
|
42742
|
-
if (
|
|
42936
|
+
if (path15.basename(desiredDir) !== type) {
|
|
42743
42937
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
42744
42938
|
}
|
|
42745
42939
|
const sourceDir = this.findProviderDir(type);
|
|
42746
42940
|
if (!sourceDir) {
|
|
42747
42941
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
42748
42942
|
}
|
|
42749
|
-
if (!
|
|
42750
|
-
|
|
42751
|
-
|
|
42943
|
+
if (!fs13.existsSync(desiredDir)) {
|
|
42944
|
+
fs13.mkdirSync(path15.dirname(desiredDir), { recursive: true });
|
|
42945
|
+
fs13.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
42752
42946
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
42753
42947
|
}
|
|
42754
|
-
const providerJson =
|
|
42755
|
-
if (!
|
|
42948
|
+
const providerJson = path15.join(desiredDir, "provider.json");
|
|
42949
|
+
if (!fs13.existsSync(providerJson)) {
|
|
42756
42950
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
42757
42951
|
}
|
|
42758
42952
|
try {
|
|
42759
|
-
const providerData = JSON.parse(
|
|
42953
|
+
const providerData = JSON.parse(fs13.readFileSync(providerJson, "utf-8"));
|
|
42760
42954
|
if (providerData.disableUpstream !== true) {
|
|
42761
42955
|
providerData.disableUpstream = true;
|
|
42762
|
-
|
|
42956
|
+
fs13.writeFileSync(providerJson, JSON.stringify(providerData, null, 2));
|
|
42763
42957
|
}
|
|
42764
42958
|
} catch (error48) {
|
|
42765
42959
|
return {
|
|
@@ -42799,7 +42993,7 @@ var init_dev_server = __esm({
|
|
|
42799
42993
|
setMode: "set_mode.js"
|
|
42800
42994
|
};
|
|
42801
42995
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
42802
|
-
const scriptsDir =
|
|
42996
|
+
const scriptsDir = path15.join(providerDir, "scripts");
|
|
42803
42997
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
42804
42998
|
if (latestScriptsDir) {
|
|
42805
42999
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -42807,10 +43001,10 @@ var init_dev_server = __esm({
|
|
|
42807
43001
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
42808
43002
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
42809
43003
|
lines.push("");
|
|
42810
|
-
for (const file2 of
|
|
43004
|
+
for (const file2 of fs13.readdirSync(latestScriptsDir)) {
|
|
42811
43005
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
42812
43006
|
try {
|
|
42813
|
-
const content =
|
|
43007
|
+
const content = fs13.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
42814
43008
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
42815
43009
|
lines.push("```javascript");
|
|
42816
43010
|
lines.push(content);
|
|
@@ -42820,14 +43014,14 @@ var init_dev_server = __esm({
|
|
|
42820
43014
|
}
|
|
42821
43015
|
}
|
|
42822
43016
|
}
|
|
42823
|
-
const refFiles =
|
|
43017
|
+
const refFiles = fs13.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
42824
43018
|
if (refFiles.length > 0) {
|
|
42825
43019
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
42826
43020
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
42827
43021
|
lines.push("");
|
|
42828
43022
|
for (const file2 of refFiles) {
|
|
42829
43023
|
try {
|
|
42830
|
-
const content =
|
|
43024
|
+
const content = fs13.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
42831
43025
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
42832
43026
|
lines.push("```javascript");
|
|
42833
43027
|
lines.push(content);
|
|
@@ -42868,11 +43062,11 @@ var init_dev_server = __esm({
|
|
|
42868
43062
|
lines.push("");
|
|
42869
43063
|
}
|
|
42870
43064
|
}
|
|
42871
|
-
const docsDir =
|
|
43065
|
+
const docsDir = path15.join(providerDir, "../../docs");
|
|
42872
43066
|
const loadGuide = (name) => {
|
|
42873
43067
|
try {
|
|
42874
|
-
const p =
|
|
42875
|
-
if (
|
|
43068
|
+
const p = path15.join(docsDir, name);
|
|
43069
|
+
if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
|
|
42876
43070
|
} catch {
|
|
42877
43071
|
}
|
|
42878
43072
|
return null;
|
|
@@ -43045,7 +43239,7 @@ var init_dev_server = __esm({
|
|
|
43045
43239
|
parseApproval: "parse_approval.js"
|
|
43046
43240
|
};
|
|
43047
43241
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
43048
|
-
const scriptsDir =
|
|
43242
|
+
const scriptsDir = path15.join(providerDir, "scripts");
|
|
43049
43243
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
43050
43244
|
if (latestScriptsDir) {
|
|
43051
43245
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -43053,11 +43247,11 @@ var init_dev_server = __esm({
|
|
|
43053
43247
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
43054
43248
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
43055
43249
|
lines.push("");
|
|
43056
|
-
for (const file2 of
|
|
43250
|
+
for (const file2 of fs13.readdirSync(latestScriptsDir)) {
|
|
43057
43251
|
if (!file2.endsWith(".js")) continue;
|
|
43058
43252
|
if (!targetFileNames.has(file2)) continue;
|
|
43059
43253
|
try {
|
|
43060
|
-
const content =
|
|
43254
|
+
const content = fs13.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
43061
43255
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
43062
43256
|
lines.push("```javascript");
|
|
43063
43257
|
lines.push(content);
|
|
@@ -43066,14 +43260,14 @@ var init_dev_server = __esm({
|
|
|
43066
43260
|
} catch {
|
|
43067
43261
|
}
|
|
43068
43262
|
}
|
|
43069
|
-
const refFiles =
|
|
43263
|
+
const refFiles = fs13.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
43070
43264
|
if (refFiles.length > 0) {
|
|
43071
43265
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
43072
43266
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
43073
43267
|
lines.push("");
|
|
43074
43268
|
for (const file2 of refFiles) {
|
|
43075
43269
|
try {
|
|
43076
|
-
const content =
|
|
43270
|
+
const content = fs13.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
43077
43271
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
43078
43272
|
lines.push("```javascript");
|
|
43079
43273
|
lines.push(content);
|
|
@@ -43106,11 +43300,11 @@ var init_dev_server = __esm({
|
|
|
43106
43300
|
lines.push("");
|
|
43107
43301
|
}
|
|
43108
43302
|
}
|
|
43109
|
-
const docsDir =
|
|
43303
|
+
const docsDir = path15.join(providerDir, "../../docs");
|
|
43110
43304
|
const loadGuide = (name) => {
|
|
43111
43305
|
try {
|
|
43112
|
-
const p =
|
|
43113
|
-
if (
|
|
43306
|
+
const p = path15.join(docsDir, name);
|
|
43307
|
+
if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
|
|
43114
43308
|
} catch {
|
|
43115
43309
|
}
|
|
43116
43310
|
return null;
|
|
@@ -43336,7 +43530,7 @@ function getDefaultSessionHostEndpoint(appName = "adhdev") {
|
|
|
43336
43530
|
}
|
|
43337
43531
|
return {
|
|
43338
43532
|
kind: "unix",
|
|
43339
|
-
path: path22.join(
|
|
43533
|
+
path: path22.join(os18.tmpdir(), `${appName}-session-host.sock`)
|
|
43340
43534
|
};
|
|
43341
43535
|
}
|
|
43342
43536
|
function serializeEnvelope(envelope) {
|
|
@@ -43358,11 +43552,11 @@ function createLineParser(onEnvelope) {
|
|
|
43358
43552
|
}
|
|
43359
43553
|
};
|
|
43360
43554
|
}
|
|
43361
|
-
var
|
|
43555
|
+
var os18, path22, net2, import_crypto3, SessionHostClient;
|
|
43362
43556
|
var init_dist = __esm({
|
|
43363
43557
|
"../../oss/packages/session-host-core/dist/index.mjs"() {
|
|
43364
43558
|
"use strict";
|
|
43365
|
-
|
|
43559
|
+
os18 = __toESM(require("os"), 1);
|
|
43366
43560
|
path22 = __toESM(require("path"), 1);
|
|
43367
43561
|
net2 = __toESM(require("net"), 1);
|
|
43368
43562
|
import_crypto3 = require("crypto");
|
|
@@ -43878,7 +44072,7 @@ var init_runtime_support = __esm({
|
|
|
43878
44072
|
function isExtensionInstalled(ide, marketplaceId) {
|
|
43879
44073
|
if (!ide.cliCommand) return false;
|
|
43880
44074
|
try {
|
|
43881
|
-
const result = (0,
|
|
44075
|
+
const result = (0, import_child_process10.execSync)(`"${ide.cliCommand}" --list-extensions`, {
|
|
43882
44076
|
encoding: "utf-8",
|
|
43883
44077
|
timeout: 15e3,
|
|
43884
44078
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -43915,11 +44109,11 @@ async function installExtension(ide, extension) {
|
|
|
43915
44109
|
const res = await fetch(extension.vsixUrl);
|
|
43916
44110
|
if (res.ok) {
|
|
43917
44111
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
43918
|
-
const
|
|
43919
|
-
|
|
44112
|
+
const fs17 = await import("fs");
|
|
44113
|
+
fs17.writeFileSync(vsixPath, buffer);
|
|
43920
44114
|
return new Promise((resolve12) => {
|
|
43921
44115
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
43922
|
-
(0,
|
|
44116
|
+
(0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
43923
44117
|
resolve12({
|
|
43924
44118
|
extensionId: extension.id,
|
|
43925
44119
|
marketplaceId: extension.marketplaceId,
|
|
@@ -43935,7 +44129,7 @@ async function installExtension(ide, extension) {
|
|
|
43935
44129
|
}
|
|
43936
44130
|
return new Promise((resolve12) => {
|
|
43937
44131
|
const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
|
|
43938
|
-
(0,
|
|
44132
|
+
(0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
|
|
43939
44133
|
if (error48) {
|
|
43940
44134
|
resolve12({
|
|
43941
44135
|
extensionId: extension.id,
|
|
@@ -43972,17 +44166,17 @@ function launchIDE(ide, workspacePath) {
|
|
|
43972
44166
|
if (!ide.cliCommand) return false;
|
|
43973
44167
|
try {
|
|
43974
44168
|
const args = workspacePath ? `"${workspacePath}"` : "";
|
|
43975
|
-
(0,
|
|
44169
|
+
(0, import_child_process10.exec)(`"${ide.cliCommand}" ${args}`, { timeout: 1e4 });
|
|
43976
44170
|
return true;
|
|
43977
44171
|
} catch {
|
|
43978
44172
|
return false;
|
|
43979
44173
|
}
|
|
43980
44174
|
}
|
|
43981
|
-
var
|
|
44175
|
+
var import_child_process10, EXTENSION_CATALOG;
|
|
43982
44176
|
var init_installer = __esm({
|
|
43983
44177
|
"../../oss/packages/daemon-core/src/installer.ts"() {
|
|
43984
44178
|
"use strict";
|
|
43985
|
-
|
|
44179
|
+
import_child_process10 = require("child_process");
|
|
43986
44180
|
EXTENSION_CATALOG = [
|
|
43987
44181
|
// AI Agent extensions
|
|
43988
44182
|
{
|
|
@@ -44390,6 +44584,7 @@ __export(src_exports, {
|
|
|
44390
44584
|
loadConfig: () => loadConfig,
|
|
44391
44585
|
logCommand: () => logCommand,
|
|
44392
44586
|
markSetupComplete: () => markSetupComplete,
|
|
44587
|
+
maybeRunDaemonUpgradeHelperFromEnv: () => maybeRunDaemonUpgradeHelperFromEnv,
|
|
44393
44588
|
normalizeActiveChatData: () => normalizeActiveChatData,
|
|
44394
44589
|
normalizeManagedStatus: () => normalizeManagedStatus,
|
|
44395
44590
|
probeCdpPort: () => probeCdpPort,
|
|
@@ -44419,6 +44614,7 @@ var init_src = __esm({
|
|
|
44419
44614
|
init_initializer();
|
|
44420
44615
|
init_handler();
|
|
44421
44616
|
init_router();
|
|
44617
|
+
init_upgrade_helper();
|
|
44422
44618
|
init_reporter();
|
|
44423
44619
|
init_builders();
|
|
44424
44620
|
init_snapshot();
|
|
@@ -44748,17 +44944,17 @@ function canPeerUsePrivilegedShareCommand(commandType, permission) {
|
|
|
44748
44944
|
return false;
|
|
44749
44945
|
}
|
|
44750
44946
|
}
|
|
44751
|
-
var
|
|
44947
|
+
var fs14, path16, os19, import_node_module, esmRequire, logFile, log, logDebug, DaemonP2PSender;
|
|
44752
44948
|
var init_daemon_p2p = __esm({
|
|
44753
44949
|
"src/daemon-p2p.ts"() {
|
|
44754
44950
|
"use strict";
|
|
44755
|
-
|
|
44951
|
+
fs14 = __toESM(require("fs"));
|
|
44756
44952
|
init_src();
|
|
44757
|
-
|
|
44758
|
-
|
|
44953
|
+
path16 = __toESM(require("path"));
|
|
44954
|
+
os19 = __toESM(require("os"));
|
|
44759
44955
|
import_node_module = require("module");
|
|
44760
44956
|
esmRequire = (0, import_node_module.createRequire)(__filename);
|
|
44761
|
-
logFile =
|
|
44957
|
+
logFile = path16.join(os19.tmpdir(), "adhdev_daemon_p2p.log");
|
|
44762
44958
|
log = (msg) => {
|
|
44763
44959
|
LOG.info("P2P", `[${(/* @__PURE__ */ new Date()).toISOString()}] [P2P] ${msg}`);
|
|
44764
44960
|
};
|
|
@@ -44826,17 +45022,17 @@ ${e?.stack || ""}`);
|
|
|
44826
45022
|
const prebuildKey = `${platform11}-${arch3}`;
|
|
44827
45023
|
try {
|
|
44828
45024
|
const candidates = [
|
|
44829
|
-
|
|
44830
|
-
|
|
44831
|
-
|
|
45025
|
+
path16.join(__dirname, "node_modules", "node-datachannel"),
|
|
45026
|
+
path16.join(__dirname, "..", "node_modules", "node-datachannel"),
|
|
45027
|
+
path16.join(__dirname, "..", "..", "node_modules", "node-datachannel")
|
|
44832
45028
|
];
|
|
44833
45029
|
for (const candidate of candidates) {
|
|
44834
|
-
const prebuildPath =
|
|
44835
|
-
if (
|
|
44836
|
-
const targetDir =
|
|
44837
|
-
const targetPath =
|
|
44838
|
-
|
|
44839
|
-
|
|
45030
|
+
const prebuildPath = path16.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
|
|
45031
|
+
if (fs14.existsSync(prebuildPath)) {
|
|
45032
|
+
const targetDir = path16.join(candidate, "build", "Release");
|
|
45033
|
+
const targetPath = path16.join(targetDir, "node_datachannel.node");
|
|
45034
|
+
fs14.mkdirSync(targetDir, { recursive: true });
|
|
45035
|
+
fs14.copyFileSync(prebuildPath, targetPath);
|
|
44840
45036
|
try {
|
|
44841
45037
|
delete esmRequire.cache[esmRequire.resolve("node-datachannel")];
|
|
44842
45038
|
} catch {
|
|
@@ -45738,23 +45934,23 @@ __export(session_host_exports, {
|
|
|
45738
45934
|
});
|
|
45739
45935
|
function resolveSessionHostEntry() {
|
|
45740
45936
|
const packagedCandidates = [
|
|
45741
|
-
|
|
45742
|
-
|
|
45937
|
+
path17.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
45938
|
+
path17.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
45743
45939
|
];
|
|
45744
45940
|
for (const candidate of packagedCandidates) {
|
|
45745
|
-
if (
|
|
45941
|
+
if (fs15.existsSync(candidate)) {
|
|
45746
45942
|
return candidate;
|
|
45747
45943
|
}
|
|
45748
45944
|
}
|
|
45749
45945
|
return require.resolve("@adhdev/session-host-daemon");
|
|
45750
45946
|
}
|
|
45751
45947
|
function getSessionHostPidFile() {
|
|
45752
|
-
return
|
|
45948
|
+
return path17.join(os20.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
|
|
45753
45949
|
}
|
|
45754
|
-
function
|
|
45950
|
+
function killPid2(pid) {
|
|
45755
45951
|
try {
|
|
45756
45952
|
if (process.platform === "win32") {
|
|
45757
|
-
(0,
|
|
45953
|
+
(0, import_child_process11.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
|
|
45758
45954
|
} else {
|
|
45759
45955
|
process.kill(pid, "SIGTERM");
|
|
45760
45956
|
}
|
|
@@ -45767,26 +45963,26 @@ function stopSessionHost() {
|
|
|
45767
45963
|
let stopped = false;
|
|
45768
45964
|
const pidFile = getSessionHostPidFile();
|
|
45769
45965
|
try {
|
|
45770
|
-
if (
|
|
45771
|
-
const pid = Number.parseInt(
|
|
45966
|
+
if (fs15.existsSync(pidFile)) {
|
|
45967
|
+
const pid = Number.parseInt(fs15.readFileSync(pidFile, "utf8").trim(), 10);
|
|
45772
45968
|
if (Number.isFinite(pid)) {
|
|
45773
|
-
stopped =
|
|
45969
|
+
stopped = killPid2(pid) || stopped;
|
|
45774
45970
|
}
|
|
45775
45971
|
}
|
|
45776
45972
|
} catch {
|
|
45777
45973
|
} finally {
|
|
45778
45974
|
try {
|
|
45779
|
-
|
|
45975
|
+
fs15.unlinkSync(pidFile);
|
|
45780
45976
|
} catch {
|
|
45781
45977
|
}
|
|
45782
45978
|
}
|
|
45783
45979
|
if (process.platform !== "win32") {
|
|
45784
45980
|
try {
|
|
45785
|
-
const raw = (0,
|
|
45981
|
+
const raw = (0, import_child_process11.execFileSync)("pgrep", ["-f", "session-host-daemon"], { encoding: "utf8" }).trim();
|
|
45786
45982
|
for (const line of raw.split("\n")) {
|
|
45787
45983
|
const pid = Number.parseInt(line.trim(), 10);
|
|
45788
45984
|
if (Number.isFinite(pid)) {
|
|
45789
|
-
stopped =
|
|
45985
|
+
stopped = killPid2(pid) || stopped;
|
|
45790
45986
|
}
|
|
45791
45987
|
}
|
|
45792
45988
|
} catch {
|
|
@@ -45799,7 +45995,7 @@ async function ensureSessionHostReady2() {
|
|
|
45799
45995
|
appName: SESSION_HOST_APP_NAME,
|
|
45800
45996
|
spawnHost: () => {
|
|
45801
45997
|
const entry = resolveSessionHostEntry();
|
|
45802
|
-
const child = (0,
|
|
45998
|
+
const child = (0, import_child_process11.spawn)(process.execPath, [entry], {
|
|
45803
45999
|
detached: true,
|
|
45804
46000
|
stdio: "ignore",
|
|
45805
46001
|
windowsHide: true,
|
|
@@ -45815,14 +46011,14 @@ async function ensureSessionHostReady2() {
|
|
|
45815
46011
|
async function listHostedCliRuntimes2(endpoint) {
|
|
45816
46012
|
return listHostedCliRuntimes(endpoint);
|
|
45817
46013
|
}
|
|
45818
|
-
var
|
|
46014
|
+
var import_child_process11, fs15, os20, path17, SESSION_HOST_APP_NAME;
|
|
45819
46015
|
var init_session_host = __esm({
|
|
45820
46016
|
"src/session-host.ts"() {
|
|
45821
46017
|
"use strict";
|
|
45822
|
-
|
|
45823
|
-
|
|
45824
|
-
|
|
45825
|
-
|
|
46018
|
+
import_child_process11 = require("child_process");
|
|
46019
|
+
fs15 = __toESM(require("fs"));
|
|
46020
|
+
os20 = __toESM(require("os"));
|
|
46021
|
+
path17 = __toESM(require("path"));
|
|
45826
46022
|
init_src();
|
|
45827
46023
|
SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
|
|
45828
46024
|
}
|
|
@@ -45836,24 +46032,24 @@ __export(adhdev_daemon_exports, {
|
|
|
45836
46032
|
stopDaemon: () => stopDaemon
|
|
45837
46033
|
});
|
|
45838
46034
|
function getDaemonPidFile() {
|
|
45839
|
-
const dir =
|
|
45840
|
-
if (!
|
|
45841
|
-
return
|
|
46035
|
+
const dir = path18.join(os21.homedir(), ".adhdev");
|
|
46036
|
+
if (!fs16.existsSync(dir)) fs16.mkdirSync(dir, { recursive: true });
|
|
46037
|
+
return path18.join(dir, "daemon.pid");
|
|
45842
46038
|
}
|
|
45843
46039
|
function writeDaemonPid(pid) {
|
|
45844
|
-
|
|
46040
|
+
fs16.writeFileSync(getDaemonPidFile(), String(pid), "utf-8");
|
|
45845
46041
|
}
|
|
45846
46042
|
function removeDaemonPid() {
|
|
45847
46043
|
try {
|
|
45848
|
-
|
|
46044
|
+
fs16.unlinkSync(getDaemonPidFile());
|
|
45849
46045
|
} catch (e) {
|
|
45850
46046
|
}
|
|
45851
46047
|
}
|
|
45852
46048
|
function isDaemonRunning() {
|
|
45853
46049
|
const pidFile = getDaemonPidFile();
|
|
45854
46050
|
try {
|
|
45855
|
-
if (!
|
|
45856
|
-
const pid = parseInt(
|
|
46051
|
+
if (!fs16.existsSync(pidFile)) return false;
|
|
46052
|
+
const pid = parseInt(fs16.readFileSync(pidFile, "utf-8").trim());
|
|
45857
46053
|
process.kill(pid, 0);
|
|
45858
46054
|
return true;
|
|
45859
46055
|
} catch {
|
|
@@ -45864,8 +46060,8 @@ function isDaemonRunning() {
|
|
|
45864
46060
|
function stopDaemon() {
|
|
45865
46061
|
const pidFile = getDaemonPidFile();
|
|
45866
46062
|
try {
|
|
45867
|
-
if (!
|
|
45868
|
-
const pid = parseInt(
|
|
46063
|
+
if (!fs16.existsSync(pidFile)) return false;
|
|
46064
|
+
const pid = parseInt(fs16.readFileSync(pidFile, "utf-8").trim());
|
|
45869
46065
|
process.kill(pid, "SIGTERM");
|
|
45870
46066
|
removeDaemonPid();
|
|
45871
46067
|
return true;
|
|
@@ -45874,7 +46070,7 @@ function stopDaemon() {
|
|
|
45874
46070
|
return false;
|
|
45875
46071
|
}
|
|
45876
46072
|
}
|
|
45877
|
-
var
|
|
46073
|
+
var os21, fs16, path18, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
|
|
45878
46074
|
var init_adhdev_daemon = __esm({
|
|
45879
46075
|
"src/adhdev-daemon.ts"() {
|
|
45880
46076
|
"use strict";
|
|
@@ -45884,20 +46080,20 @@ var init_adhdev_daemon = __esm({
|
|
|
45884
46080
|
init_screenshot_controller();
|
|
45885
46081
|
init_session_host();
|
|
45886
46082
|
init_dist();
|
|
45887
|
-
|
|
45888
|
-
|
|
45889
|
-
|
|
46083
|
+
os21 = __toESM(require("os"));
|
|
46084
|
+
fs16 = __toESM(require("fs"));
|
|
46085
|
+
path18 = __toESM(require("path"));
|
|
45890
46086
|
import_chalk2 = __toESM(require("chalk"));
|
|
45891
|
-
pkgVersion = "0.7.
|
|
46087
|
+
pkgVersion = "0.7.45";
|
|
45892
46088
|
if (pkgVersion === "unknown") {
|
|
45893
46089
|
try {
|
|
45894
46090
|
const possiblePaths = [
|
|
45895
|
-
|
|
45896
|
-
|
|
46091
|
+
path18.join(__dirname, "..", "package.json"),
|
|
46092
|
+
path18.join(__dirname, "package.json")
|
|
45897
46093
|
];
|
|
45898
46094
|
for (const p of possiblePaths) {
|
|
45899
46095
|
try {
|
|
45900
|
-
const data = JSON.parse(
|
|
46096
|
+
const data = JSON.parse(fs16.readFileSync(p, "utf-8"));
|
|
45901
46097
|
if (data.version) {
|
|
45902
46098
|
pkgVersion = data.version;
|
|
45903
46099
|
break;
|
|
@@ -45943,6 +46139,10 @@ var init_adhdev_daemon = __esm({
|
|
|
45943
46139
|
isTerminalCliSession(sessionId) {
|
|
45944
46140
|
return this.getCliPresentationMode(sessionId) === "terminal";
|
|
45945
46141
|
}
|
|
46142
|
+
isCliSession(sessionId) {
|
|
46143
|
+
const mode = this.getCliPresentationMode(sessionId);
|
|
46144
|
+
return mode === "chat" || mode === "terminal";
|
|
46145
|
+
}
|
|
45946
46146
|
async start(options = {}) {
|
|
45947
46147
|
try {
|
|
45948
46148
|
const { installGlobalInterceptor: installGlobalInterceptor2 } = require("./logging/logger");
|
|
@@ -45983,7 +46183,7 @@ ${err?.stack || ""}`);
|
|
|
45983
46183
|
getServerConn: () => this.serverConn,
|
|
45984
46184
|
getP2p: () => ({
|
|
45985
46185
|
broadcastPtyOutput: (key, data) => {
|
|
45986
|
-
if (!this.
|
|
46186
|
+
if (!this.isCliSession(key)) return;
|
|
45987
46187
|
this.p2p?.broadcastPtyOutput(key, data);
|
|
45988
46188
|
}
|
|
45989
46189
|
}),
|
|
@@ -46035,8 +46235,8 @@ ${err?.stack || ""}`);
|
|
|
46035
46235
|
cliInfo: {
|
|
46036
46236
|
type: "adhdev-daemon",
|
|
46037
46237
|
version: pkgVersion,
|
|
46038
|
-
platform:
|
|
46039
|
-
hostname:
|
|
46238
|
+
platform: os21.platform(),
|
|
46239
|
+
hostname: os21.hostname(),
|
|
46040
46240
|
machineId: config2.machineId,
|
|
46041
46241
|
instanceId
|
|
46042
46242
|
}
|
|
@@ -46248,8 +46448,8 @@ ${err?.stack || ""}`);
|
|
|
46248
46448
|
case "get_runtime_snapshot": {
|
|
46249
46449
|
const sessionId = typeof data.sessionId === "string" ? data.sessionId : "";
|
|
46250
46450
|
if (!sessionId) return { success: false, error: "sessionId is required" };
|
|
46251
|
-
if (!this.
|
|
46252
|
-
return { success: false, error: "CLI session
|
|
46451
|
+
if (!this.isCliSession(sessionId)) {
|
|
46452
|
+
return { success: false, error: "CLI session runtime unavailable", code: "CLI_RUNTIME_UNAVAILABLE" };
|
|
46253
46453
|
}
|
|
46254
46454
|
if (!this.sessionHostEndpoint) return { success: false, error: "Session host unavailable" };
|
|
46255
46455
|
const client = new SessionHostClient({ endpoint: this.sessionHostEndpoint });
|
|
@@ -46476,16 +46676,16 @@ async function loginFlow() {
|
|
|
46476
46676
|
let verificationUrl;
|
|
46477
46677
|
try {
|
|
46478
46678
|
const config2 = loadConfig();
|
|
46479
|
-
const
|
|
46679
|
+
const os22 = await import("os");
|
|
46480
46680
|
const res = await fetch(`${SERVER_URL}/auth/cli/init`, {
|
|
46481
46681
|
method: "POST",
|
|
46482
46682
|
headers: { "Content-Type": "application/json" },
|
|
46483
46683
|
body: JSON.stringify({
|
|
46484
46684
|
clientMachineId: config2.machineId,
|
|
46485
46685
|
registeredMachineId: config2.registeredMachineId,
|
|
46486
|
-
hostname:
|
|
46487
|
-
platform:
|
|
46488
|
-
arch:
|
|
46686
|
+
hostname: os22.hostname(),
|
|
46687
|
+
platform: os22.platform(),
|
|
46688
|
+
arch: os22.arch()
|
|
46489
46689
|
})
|
|
46490
46690
|
});
|
|
46491
46691
|
if (!res.ok) {
|
|
@@ -46584,10 +46784,10 @@ async function startDaemonFlow() {
|
|
|
46584
46784
|
const { AdhdevDaemon: AdhdevDaemon2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
46585
46785
|
const daemon = new AdhdevDaemon2();
|
|
46586
46786
|
const { execSync: execSync7 } = await import("child_process");
|
|
46587
|
-
const
|
|
46588
|
-
const
|
|
46589
|
-
const logPath =
|
|
46590
|
-
const platform11 =
|
|
46787
|
+
const os22 = await import("os");
|
|
46788
|
+
const path19 = await import("path");
|
|
46789
|
+
const logPath = path19.join(os22.homedir(), ".adhdev", "daemon.log");
|
|
46790
|
+
const platform11 = os22.platform();
|
|
46591
46791
|
try {
|
|
46592
46792
|
if (platform11 === "win32") {
|
|
46593
46793
|
execSync7(`start /B adhdev daemon > "${logPath}" 2>&1`, {
|
|
@@ -47223,7 +47423,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
47223
47423
|
});
|
|
47224
47424
|
});
|
|
47225
47425
|
program2.command("standalone").description("\u{1F5A5}\uFE0F Start ADHDev Standalone Server (Local Dashboard & Embedded Daemon)").option("-p, --port <port>", "Local HTTP/WS server port", "3847").option("--host <host>", "Bind to specific host (use 0.0.0.0 for LAN access)").option("--no-open", "Prevent opening browser automatically").option("--token <token>", "Require token authentication").option("--dev", "Enable Dev Mode").action(async (options) => {
|
|
47226
|
-
const { spawn:
|
|
47426
|
+
const { spawn: spawn5, execSync: execSync7 } = await import("child_process");
|
|
47227
47427
|
console.log(import_chalk5.default.cyan("\n Starting ADHDev Standalone Server..."));
|
|
47228
47428
|
const args = [];
|
|
47229
47429
|
if (options.port) args.push("--port", options.port);
|
|
@@ -47241,7 +47441,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
47241
47441
|
console.log(import_chalk5.default.gray(" Downloading and running via npx (this may take a moment)..."));
|
|
47242
47442
|
}
|
|
47243
47443
|
const spawnArgs = bin === "npx" ? npxArgs : args;
|
|
47244
|
-
const child =
|
|
47444
|
+
const child = spawn5(bin, spawnArgs, {
|
|
47245
47445
|
stdio: "inherit",
|
|
47246
47446
|
shell: process.platform === "win32"
|
|
47247
47447
|
});
|
|
@@ -47278,7 +47478,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
47278
47478
|
hideCommand(program2.command("daemon:restart").description("Restart ADHDev Daemon (stop \u2192 start)").option("-p, --port <port>", "Local WS server port", "19222").option("--server <url>", "Override server URL").option("--dev", "Enable Dev Mode").action(async (options) => {
|
|
47279
47479
|
const { stopDaemon: stopDaemon2, isDaemonRunning: isDaemonRunning2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
47280
47480
|
const { stopSessionHost: stopSessionHost2 } = await Promise.resolve().then(() => (init_session_host(), session_host_exports));
|
|
47281
|
-
const { spawn:
|
|
47481
|
+
const { spawn: spawn5 } = await import("child_process");
|
|
47282
47482
|
if (isDaemonRunning2()) {
|
|
47283
47483
|
console.log(import_chalk5.default.yellow("\n Stopping existing daemon..."));
|
|
47284
47484
|
stopDaemon2();
|
|
@@ -47290,7 +47490,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
47290
47490
|
const args = ["daemon", "-p", options.port || "19222"];
|
|
47291
47491
|
if (options.server) args.push("--server", options.server);
|
|
47292
47492
|
if (options.dev) args.push("--dev");
|
|
47293
|
-
const child =
|
|
47493
|
+
const child = spawn5(process.execPath, [process.argv[1], ...args], {
|
|
47294
47494
|
detached: true,
|
|
47295
47495
|
stdio: "ignore",
|
|
47296
47496
|
env: { ...process.env }
|
|
@@ -47309,7 +47509,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
47309
47509
|
hideCommand(program2.command("daemon:upgrade").description("Upgrade ADHDev to latest version and restart daemon").option("--no-restart", "Upgrade only, skip daemon restart").action(async (options) => {
|
|
47310
47510
|
const { isDaemonRunning: isDaemonRunning2, stopDaemon: stopDaemon2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
47311
47511
|
const { stopSessionHost: stopSessionHost2 } = await Promise.resolve().then(() => (init_session_host(), session_host_exports));
|
|
47312
|
-
const { execSync: execSync7, spawn:
|
|
47512
|
+
const { execSync: execSync7, spawn: spawn5 } = await import("child_process");
|
|
47313
47513
|
const fsMod = await import("fs");
|
|
47314
47514
|
const pathMod = await import("path");
|
|
47315
47515
|
console.log(import_chalk5.default.bold("\n \u{1F504} ADHDev Upgrade\n"));
|
|
@@ -47367,7 +47567,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
47367
47567
|
await new Promise((r) => setTimeout(r, 2e3));
|
|
47368
47568
|
stopSessionHost2();
|
|
47369
47569
|
await new Promise((r) => setTimeout(r, 500));
|
|
47370
|
-
const child =
|
|
47570
|
+
const child = spawn5(process.execPath, [process.argv[1], "daemon", "-p", "19222"], {
|
|
47371
47571
|
detached: true,
|
|
47372
47572
|
stdio: "ignore",
|
|
47373
47573
|
env: { ...process.env }
|
|
@@ -47576,35 +47776,35 @@ function registerProviderCommands(program2) {
|
|
|
47576
47776
|
let osPaths = {};
|
|
47577
47777
|
let processNames = {};
|
|
47578
47778
|
if (category === "ide") {
|
|
47579
|
-
const
|
|
47580
|
-
const
|
|
47581
|
-
const
|
|
47582
|
-
if (
|
|
47779
|
+
const fs17 = await import("fs");
|
|
47780
|
+
const path19 = await import("path");
|
|
47781
|
+
const os22 = await import("os");
|
|
47782
|
+
if (os22.platform() === "darwin") {
|
|
47583
47783
|
while (true) {
|
|
47584
47784
|
const p = (await rl.question(`macOS Application Path (e.g. /Applications/${defaultName}.app): `)).trim() || `/Applications/${defaultName}.app`;
|
|
47585
47785
|
if (p === "skip") break;
|
|
47586
|
-
if (!
|
|
47786
|
+
if (!fs17.existsSync(p)) {
|
|
47587
47787
|
console.log(import_chalk6.default.red(` \u2717 Path not found: ${p}`));
|
|
47588
47788
|
console.log(import_chalk6.default.gray(` (Please provide the exact absolute path to the .app or binary, or type 'skip')`));
|
|
47589
47789
|
continue;
|
|
47590
47790
|
}
|
|
47591
47791
|
console.log(import_chalk6.default.green(` \u2713 Path verified: ${p}`));
|
|
47592
47792
|
osPaths["darwin"] = [p];
|
|
47593
|
-
processNames["darwin"] =
|
|
47793
|
+
processNames["darwin"] = path19.basename(p, ".app");
|
|
47594
47794
|
break;
|
|
47595
47795
|
}
|
|
47596
|
-
} else if (
|
|
47796
|
+
} else if (os22.platform() === "win32") {
|
|
47597
47797
|
while (true) {
|
|
47598
47798
|
const p = (await rl.question(`Windows Executable Path (e.g. C:\\Program Files\\${defaultName}\\${defaultName}.exe): `)).trim();
|
|
47599
47799
|
if (!p || p === "skip") break;
|
|
47600
|
-
if (!
|
|
47800
|
+
if (!fs17.existsSync(p)) {
|
|
47601
47801
|
console.log(import_chalk6.default.red(` \u2717 Path not found: ${p}`));
|
|
47602
47802
|
console.log(import_chalk6.default.gray(` (Please provide the exact absolute path, or type 'skip')`));
|
|
47603
47803
|
continue;
|
|
47604
47804
|
}
|
|
47605
47805
|
console.log(import_chalk6.default.green(` \u2713 Path verified: ${p}`));
|
|
47606
47806
|
osPaths["win32"] = [p];
|
|
47607
|
-
processNames["win32"] =
|
|
47807
|
+
processNames["win32"] = path19.basename(p, ".exe");
|
|
47608
47808
|
break;
|
|
47609
47809
|
}
|
|
47610
47810
|
}
|
|
@@ -48280,8 +48480,8 @@ function registerCdpCommands(program2) {
|
|
|
48280
48480
|
}
|
|
48281
48481
|
const output = typeof result === "string" ? result : JSON.stringify(result, null, 2);
|
|
48282
48482
|
if (options.output) {
|
|
48283
|
-
const
|
|
48284
|
-
|
|
48483
|
+
const fs17 = await import("fs");
|
|
48484
|
+
fs17.writeFileSync(options.output, output, "utf-8");
|
|
48285
48485
|
console.log(import_chalk6.default.green(`
|
|
48286
48486
|
\u2713 Saved to ${options.output} (${output.length} chars)
|
|
48287
48487
|
`));
|
|
@@ -48384,8 +48584,8 @@ function registerCdpCommands(program2) {
|
|
|
48384
48584
|
ws2.on("message", async (data) => {
|
|
48385
48585
|
const msg = JSON.parse(data.toString());
|
|
48386
48586
|
if (msg.id === 1 && msg.result?.data) {
|
|
48387
|
-
const
|
|
48388
|
-
|
|
48587
|
+
const fs17 = await import("fs");
|
|
48588
|
+
fs17.writeFileSync(options.output, Buffer.from(msg.result.data, "base64"));
|
|
48389
48589
|
console.log(import_chalk6.default.green(`
|
|
48390
48590
|
\u2713 Screenshot saved to ${options.output}
|
|
48391
48591
|
`));
|
|
@@ -48434,29 +48634,35 @@ registerSetupCommands(program, _cliProviderLoader);
|
|
|
48434
48634
|
registerDaemonCommands(program, pkgVersion2);
|
|
48435
48635
|
registerProviderCommands(program);
|
|
48436
48636
|
registerCdpCommands(program);
|
|
48437
|
-
|
|
48438
|
-
|
|
48439
|
-
|
|
48440
|
-
|
|
48441
|
-
|
|
48442
|
-
|
|
48443
|
-
|
|
48444
|
-
|
|
48445
|
-
|
|
48446
|
-
|
|
48447
|
-
|
|
48448
|
-
|
|
48449
|
-
|
|
48450
|
-
|
|
48451
|
-
|
|
48452
|
-
|
|
48453
|
-
|
|
48454
|
-
|
|
48455
|
-
console.
|
|
48637
|
+
void (async () => {
|
|
48638
|
+
const helperMode = await maybeRunDaemonUpgradeHelperFromEnv();
|
|
48639
|
+
if (helperMode) {
|
|
48640
|
+
return;
|
|
48641
|
+
}
|
|
48642
|
+
if (process.argv.length <= 2) {
|
|
48643
|
+
program.outputHelp();
|
|
48644
|
+
console.log();
|
|
48645
|
+
console.log(import_chalk7.default.gray(" Quick start:"));
|
|
48646
|
+
console.log(import_chalk7.default.gray(" adhdev setup \u2014 First-time setup & login"));
|
|
48647
|
+
console.log(import_chalk7.default.gray(" adhdev daemon \u2014 Start unified daemon (Required)"));
|
|
48648
|
+
console.log(import_chalk7.default.gray(" adhdev standalone \u2014 Start standalone local dashboard & daemon"));
|
|
48649
|
+
console.log(import_chalk7.default.gray(" adhdev launch cursor \u2014 Launch IDE with CDP (e.g. cursor, windsurf)"));
|
|
48650
|
+
console.log(import_chalk7.default.gray(" adhdev launch claude \u2014 Launch CLI agent (e.g. gemini, claude)"));
|
|
48651
|
+
console.log(import_chalk7.default.gray(" adhdev status \u2014 Check current setup"));
|
|
48652
|
+
console.log(import_chalk7.default.gray(" adhdev update \u2014 Upgrade to latest version"));
|
|
48653
|
+
console.log();
|
|
48654
|
+
console.log(import_chalk7.default.gray(" Advanced tools:"));
|
|
48655
|
+
console.log(import_chalk7.default.gray(" adhdev provider ... \u2014 Provider development commands"));
|
|
48656
|
+
console.log(import_chalk7.default.gray(" adhdev cdp ... \u2014 CDP debugging tools"));
|
|
48657
|
+
console.log();
|
|
48658
|
+
return;
|
|
48659
|
+
}
|
|
48660
|
+
await program.parseAsync(process.argv);
|
|
48661
|
+
})().catch((err) => {
|
|
48662
|
+
console.error(import_chalk7.default.red(`
|
|
48456
48663
|
\u2717 ${err.message}`));
|
|
48457
|
-
|
|
48458
|
-
|
|
48459
|
-
}
|
|
48664
|
+
process.exit(1);
|
|
48665
|
+
});
|
|
48460
48666
|
/*! Bundled license information:
|
|
48461
48667
|
|
|
48462
48668
|
chokidar/index.js:
|