@adhdev/daemon-standalone 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/index.js +615 -422
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/{index-CNw7Sk14.js → index-DyZAxHxl.js} +18 -18
- package/public/index.html +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/dist/index.js
CHANGED
|
@@ -283,10 +283,10 @@ function mergeDefs(...defs) {
|
|
|
283
283
|
function cloneDef(schema) {
|
|
284
284
|
return mergeDefs(schema._zod.def);
|
|
285
285
|
}
|
|
286
|
-
function getElementAtPath(obj,
|
|
287
|
-
if (!
|
|
286
|
+
function getElementAtPath(obj, path19) {
|
|
287
|
+
if (!path19)
|
|
288
288
|
return obj;
|
|
289
|
-
return
|
|
289
|
+
return path19.reduce((acc, key) => acc?.[key], obj);
|
|
290
290
|
}
|
|
291
291
|
function promiseAllObject(promisesObj) {
|
|
292
292
|
const keys = Object.keys(promisesObj);
|
|
@@ -598,11 +598,11 @@ function aborted(x, startIndex = 0) {
|
|
|
598
598
|
}
|
|
599
599
|
return false;
|
|
600
600
|
}
|
|
601
|
-
function prefixIssues(
|
|
601
|
+
function prefixIssues(path19, issues) {
|
|
602
602
|
return issues.map((iss) => {
|
|
603
603
|
var _a2;
|
|
604
604
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
605
|
-
iss.path.unshift(
|
|
605
|
+
iss.path.unshift(path19);
|
|
606
606
|
return iss;
|
|
607
607
|
});
|
|
608
608
|
}
|
|
@@ -845,7 +845,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
845
845
|
}
|
|
846
846
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
847
847
|
const result = { errors: [] };
|
|
848
|
-
const processError = (error49,
|
|
848
|
+
const processError = (error49, path19 = []) => {
|
|
849
849
|
var _a2, _b;
|
|
850
850
|
for (const issue2 of error49.issues) {
|
|
851
851
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -855,7 +855,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
855
855
|
} else if (issue2.code === "invalid_element") {
|
|
856
856
|
processError({ issues: issue2.issues }, issue2.path);
|
|
857
857
|
} else {
|
|
858
|
-
const fullpath = [...
|
|
858
|
+
const fullpath = [...path19, ...issue2.path];
|
|
859
859
|
if (fullpath.length === 0) {
|
|
860
860
|
result.errors.push(mapper(issue2));
|
|
861
861
|
continue;
|
|
@@ -887,8 +887,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
887
887
|
}
|
|
888
888
|
function toDotPath(_path) {
|
|
889
889
|
const segs = [];
|
|
890
|
-
const
|
|
891
|
-
for (const seg of
|
|
890
|
+
const path19 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
891
|
+
for (const seg of path19) {
|
|
892
892
|
if (typeof seg === "number")
|
|
893
893
|
segs.push(`[${seg}]`);
|
|
894
894
|
else if (typeof seg === "symbol")
|
|
@@ -13652,13 +13652,13 @@ function resolveRef(ref, ctx) {
|
|
|
13652
13652
|
if (!ref.startsWith("#")) {
|
|
13653
13653
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
13654
13654
|
}
|
|
13655
|
-
const
|
|
13656
|
-
if (
|
|
13655
|
+
const path19 = ref.slice(1).split("/").filter(Boolean);
|
|
13656
|
+
if (path19.length === 0) {
|
|
13657
13657
|
return ctx.rootSchema;
|
|
13658
13658
|
}
|
|
13659
13659
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
13660
|
-
if (
|
|
13661
|
-
const key =
|
|
13660
|
+
if (path19[0] === defsKey) {
|
|
13661
|
+
const key = path19[1];
|
|
13662
13662
|
if (!key || !ctx.defs[key]) {
|
|
13663
13663
|
throw new Error(`Reference not found: ${ref}`);
|
|
13664
13664
|
}
|
|
@@ -16334,9 +16334,9 @@ var init_acp = __esm({
|
|
|
16334
16334
|
// src/index.ts
|
|
16335
16335
|
var import_http = require("http");
|
|
16336
16336
|
var import_ws2 = require("ws");
|
|
16337
|
-
var
|
|
16338
|
-
var
|
|
16339
|
-
var
|
|
16337
|
+
var path18 = __toESM(require("path"));
|
|
16338
|
+
var fs13 = __toESM(require("fs"));
|
|
16339
|
+
var os18 = __toESM(require("os"));
|
|
16340
16340
|
|
|
16341
16341
|
// ../daemon-core/dist/index.mjs
|
|
16342
16342
|
var import_os = require("os");
|
|
@@ -16346,9 +16346,9 @@ var import_crypto2 = require("crypto");
|
|
|
16346
16346
|
var fs2 = __toESM(require("fs"), 1);
|
|
16347
16347
|
var path3 = __toESM(require("path"), 1);
|
|
16348
16348
|
var os4 = __toESM(require("os"), 1);
|
|
16349
|
-
var os11 = __toESM(require("os"), 1);
|
|
16350
16349
|
var os12 = __toESM(require("os"), 1);
|
|
16351
|
-
var
|
|
16350
|
+
var os13 = __toESM(require("os"), 1);
|
|
16351
|
+
var path10 = __toESM(require("path"), 1);
|
|
16352
16352
|
var import_child_process = require("child_process");
|
|
16353
16353
|
var fs = __toESM(require("fs"), 1);
|
|
16354
16354
|
var os2 = __toESM(require("os"), 1);
|
|
@@ -16469,7 +16469,7 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
16469
16469
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
16470
16470
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
16471
16471
|
if (wantBigintFsStats) {
|
|
16472
|
-
this._stat = (
|
|
16472
|
+
this._stat = (path19) => statMethod(path19, { bigint: true });
|
|
16473
16473
|
} else {
|
|
16474
16474
|
this._stat = statMethod;
|
|
16475
16475
|
}
|
|
@@ -16494,8 +16494,8 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
16494
16494
|
const par = this.parent;
|
|
16495
16495
|
const fil = par && par.files;
|
|
16496
16496
|
if (fil && fil.length > 0) {
|
|
16497
|
-
const { path:
|
|
16498
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
16497
|
+
const { path: path19, depth } = par;
|
|
16498
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path19));
|
|
16499
16499
|
const awaited = await Promise.all(slice);
|
|
16500
16500
|
for (const entry of awaited) {
|
|
16501
16501
|
if (!entry)
|
|
@@ -16535,20 +16535,20 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
16535
16535
|
this.reading = false;
|
|
16536
16536
|
}
|
|
16537
16537
|
}
|
|
16538
|
-
async _exploreDir(
|
|
16538
|
+
async _exploreDir(path19, depth) {
|
|
16539
16539
|
let files;
|
|
16540
16540
|
try {
|
|
16541
|
-
files = await (0, import_promises.readdir)(
|
|
16541
|
+
files = await (0, import_promises.readdir)(path19, this._rdOptions);
|
|
16542
16542
|
} catch (error48) {
|
|
16543
16543
|
this._onError(error48);
|
|
16544
16544
|
}
|
|
16545
|
-
return { files, depth, path:
|
|
16545
|
+
return { files, depth, path: path19 };
|
|
16546
16546
|
}
|
|
16547
|
-
async _formatEntry(dirent,
|
|
16547
|
+
async _formatEntry(dirent, path19) {
|
|
16548
16548
|
let entry;
|
|
16549
16549
|
const basename7 = this._isDirent ? dirent.name : dirent;
|
|
16550
16550
|
try {
|
|
16551
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
16551
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path19, basename7));
|
|
16552
16552
|
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename7 };
|
|
16553
16553
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
16554
16554
|
} catch (err) {
|
|
@@ -16948,16 +16948,16 @@ var delFromSet = (main2, prop, item) => {
|
|
|
16948
16948
|
};
|
|
16949
16949
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
16950
16950
|
var FsWatchInstances = /* @__PURE__ */ new Map();
|
|
16951
|
-
function createFsWatchInstance(
|
|
16951
|
+
function createFsWatchInstance(path19, options, listener, errHandler, emitRaw) {
|
|
16952
16952
|
const handleEvent = (rawEvent, evPath) => {
|
|
16953
|
-
listener(
|
|
16954
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
16955
|
-
if (evPath &&
|
|
16956
|
-
fsWatchBroadcast(sp.resolve(
|
|
16953
|
+
listener(path19);
|
|
16954
|
+
emitRaw(rawEvent, evPath, { watchedPath: path19 });
|
|
16955
|
+
if (evPath && path19 !== evPath) {
|
|
16956
|
+
fsWatchBroadcast(sp.resolve(path19, evPath), KEY_LISTENERS, sp.join(path19, evPath));
|
|
16957
16957
|
}
|
|
16958
16958
|
};
|
|
16959
16959
|
try {
|
|
16960
|
-
return (0, import_node_fs.watch)(
|
|
16960
|
+
return (0, import_node_fs.watch)(path19, {
|
|
16961
16961
|
persistent: options.persistent
|
|
16962
16962
|
}, handleEvent);
|
|
16963
16963
|
} catch (error48) {
|
|
@@ -16973,12 +16973,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
16973
16973
|
listener(val1, val2, val3);
|
|
16974
16974
|
});
|
|
16975
16975
|
};
|
|
16976
|
-
var setFsWatchListener = (
|
|
16976
|
+
var setFsWatchListener = (path19, fullPath, options, handlers) => {
|
|
16977
16977
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
16978
16978
|
let cont = FsWatchInstances.get(fullPath);
|
|
16979
16979
|
let watcher;
|
|
16980
16980
|
if (!options.persistent) {
|
|
16981
|
-
watcher = createFsWatchInstance(
|
|
16981
|
+
watcher = createFsWatchInstance(path19, options, listener, errHandler, rawEmitter);
|
|
16982
16982
|
if (!watcher)
|
|
16983
16983
|
return;
|
|
16984
16984
|
return watcher.close.bind(watcher);
|
|
@@ -16989,7 +16989,7 @@ var setFsWatchListener = (path18, fullPath, options, handlers) => {
|
|
|
16989
16989
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
16990
16990
|
} else {
|
|
16991
16991
|
watcher = createFsWatchInstance(
|
|
16992
|
-
|
|
16992
|
+
path19,
|
|
16993
16993
|
options,
|
|
16994
16994
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
16995
16995
|
errHandler,
|
|
@@ -17004,7 +17004,7 @@ var setFsWatchListener = (path18, fullPath, options, handlers) => {
|
|
|
17004
17004
|
cont.watcherUnusable = true;
|
|
17005
17005
|
if (isWindows && error48.code === "EPERM") {
|
|
17006
17006
|
try {
|
|
17007
|
-
const fd = await (0, import_promises2.open)(
|
|
17007
|
+
const fd = await (0, import_promises2.open)(path19, "r");
|
|
17008
17008
|
await fd.close();
|
|
17009
17009
|
broadcastErr(error48);
|
|
17010
17010
|
} catch (err) {
|
|
@@ -17035,7 +17035,7 @@ var setFsWatchListener = (path18, fullPath, options, handlers) => {
|
|
|
17035
17035
|
};
|
|
17036
17036
|
};
|
|
17037
17037
|
var FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
17038
|
-
var setFsWatchFileListener = (
|
|
17038
|
+
var setFsWatchFileListener = (path19, fullPath, options, handlers) => {
|
|
17039
17039
|
const { listener, rawEmitter } = handlers;
|
|
17040
17040
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
17041
17041
|
const copts = cont && cont.options;
|
|
@@ -17057,7 +17057,7 @@ var setFsWatchFileListener = (path18, fullPath, options, handlers) => {
|
|
|
17057
17057
|
});
|
|
17058
17058
|
const currmtime = curr.mtimeMs;
|
|
17059
17059
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
17060
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
17060
|
+
foreach(cont.listeners, (listener2) => listener2(path19, curr));
|
|
17061
17061
|
}
|
|
17062
17062
|
})
|
|
17063
17063
|
};
|
|
@@ -17087,13 +17087,13 @@ var NodeFsHandler = class {
|
|
|
17087
17087
|
* @param listener on fs change
|
|
17088
17088
|
* @returns closer for the watcher instance
|
|
17089
17089
|
*/
|
|
17090
|
-
_watchWithNodeFs(
|
|
17090
|
+
_watchWithNodeFs(path19, listener) {
|
|
17091
17091
|
const opts = this.fsw.options;
|
|
17092
|
-
const directory = sp.dirname(
|
|
17093
|
-
const basename7 = sp.basename(
|
|
17092
|
+
const directory = sp.dirname(path19);
|
|
17093
|
+
const basename7 = sp.basename(path19);
|
|
17094
17094
|
const parent = this.fsw._getWatchedDir(directory);
|
|
17095
17095
|
parent.add(basename7);
|
|
17096
|
-
const absolutePath = sp.resolve(
|
|
17096
|
+
const absolutePath = sp.resolve(path19);
|
|
17097
17097
|
const options = {
|
|
17098
17098
|
persistent: opts.persistent
|
|
17099
17099
|
};
|
|
@@ -17103,12 +17103,12 @@ var NodeFsHandler = class {
|
|
|
17103
17103
|
if (opts.usePolling) {
|
|
17104
17104
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
17105
17105
|
options.interval = enableBin && isBinaryPath(basename7) ? opts.binaryInterval : opts.interval;
|
|
17106
|
-
closer = setFsWatchFileListener(
|
|
17106
|
+
closer = setFsWatchFileListener(path19, absolutePath, options, {
|
|
17107
17107
|
listener,
|
|
17108
17108
|
rawEmitter: this.fsw._emitRaw
|
|
17109
17109
|
});
|
|
17110
17110
|
} else {
|
|
17111
|
-
closer = setFsWatchListener(
|
|
17111
|
+
closer = setFsWatchListener(path19, absolutePath, options, {
|
|
17112
17112
|
listener,
|
|
17113
17113
|
errHandler: this._boundHandleError,
|
|
17114
17114
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -17130,7 +17130,7 @@ var NodeFsHandler = class {
|
|
|
17130
17130
|
let prevStats = stats;
|
|
17131
17131
|
if (parent.has(basename7))
|
|
17132
17132
|
return;
|
|
17133
|
-
const listener = async (
|
|
17133
|
+
const listener = async (path19, newStats) => {
|
|
17134
17134
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
17135
17135
|
return;
|
|
17136
17136
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -17144,11 +17144,11 @@ var NodeFsHandler = class {
|
|
|
17144
17144
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
17145
17145
|
}
|
|
17146
17146
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
17147
|
-
this.fsw._closeFile(
|
|
17147
|
+
this.fsw._closeFile(path19);
|
|
17148
17148
|
prevStats = newStats2;
|
|
17149
17149
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
17150
17150
|
if (closer2)
|
|
17151
|
-
this.fsw._addPathCloser(
|
|
17151
|
+
this.fsw._addPathCloser(path19, closer2);
|
|
17152
17152
|
} else {
|
|
17153
17153
|
prevStats = newStats2;
|
|
17154
17154
|
}
|
|
@@ -17180,7 +17180,7 @@ var NodeFsHandler = class {
|
|
|
17180
17180
|
* @param item basename of this item
|
|
17181
17181
|
* @returns true if no more processing is needed for this entry.
|
|
17182
17182
|
*/
|
|
17183
|
-
async _handleSymlink(entry, directory,
|
|
17183
|
+
async _handleSymlink(entry, directory, path19, item) {
|
|
17184
17184
|
if (this.fsw.closed) {
|
|
17185
17185
|
return;
|
|
17186
17186
|
}
|
|
@@ -17190,7 +17190,7 @@ var NodeFsHandler = class {
|
|
|
17190
17190
|
this.fsw._incrReadyCount();
|
|
17191
17191
|
let linkPath;
|
|
17192
17192
|
try {
|
|
17193
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
17193
|
+
linkPath = await (0, import_promises2.realpath)(path19);
|
|
17194
17194
|
} catch (e) {
|
|
17195
17195
|
this.fsw._emitReady();
|
|
17196
17196
|
return true;
|
|
@@ -17200,12 +17200,12 @@ var NodeFsHandler = class {
|
|
|
17200
17200
|
if (dir.has(item)) {
|
|
17201
17201
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
17202
17202
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
17203
|
-
this.fsw._emit(EV.CHANGE,
|
|
17203
|
+
this.fsw._emit(EV.CHANGE, path19, entry.stats);
|
|
17204
17204
|
}
|
|
17205
17205
|
} else {
|
|
17206
17206
|
dir.add(item);
|
|
17207
17207
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
17208
|
-
this.fsw._emit(EV.ADD,
|
|
17208
|
+
this.fsw._emit(EV.ADD, path19, entry.stats);
|
|
17209
17209
|
}
|
|
17210
17210
|
this.fsw._emitReady();
|
|
17211
17211
|
return true;
|
|
@@ -17235,9 +17235,9 @@ var NodeFsHandler = class {
|
|
|
17235
17235
|
return;
|
|
17236
17236
|
}
|
|
17237
17237
|
const item = entry.path;
|
|
17238
|
-
let
|
|
17238
|
+
let path19 = sp.join(directory, item);
|
|
17239
17239
|
current.add(item);
|
|
17240
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
17240
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path19, item)) {
|
|
17241
17241
|
return;
|
|
17242
17242
|
}
|
|
17243
17243
|
if (this.fsw.closed) {
|
|
@@ -17246,8 +17246,8 @@ var NodeFsHandler = class {
|
|
|
17246
17246
|
}
|
|
17247
17247
|
if (item === target || !target && !previous.has(item)) {
|
|
17248
17248
|
this.fsw._incrReadyCount();
|
|
17249
|
-
|
|
17250
|
-
this._addToNodeFs(
|
|
17249
|
+
path19 = sp.join(dir, sp.relative(dir, path19));
|
|
17250
|
+
this._addToNodeFs(path19, initialAdd, wh, depth + 1);
|
|
17251
17251
|
}
|
|
17252
17252
|
}).on(EV.ERROR, this._boundHandleError);
|
|
17253
17253
|
return new Promise((resolve12, reject) => {
|
|
@@ -17316,13 +17316,13 @@ var NodeFsHandler = class {
|
|
|
17316
17316
|
* @param depth Child path actually targeted for watch
|
|
17317
17317
|
* @param target Child path actually targeted for watch
|
|
17318
17318
|
*/
|
|
17319
|
-
async _addToNodeFs(
|
|
17319
|
+
async _addToNodeFs(path19, initialAdd, priorWh, depth, target) {
|
|
17320
17320
|
const ready = this.fsw._emitReady;
|
|
17321
|
-
if (this.fsw._isIgnored(
|
|
17321
|
+
if (this.fsw._isIgnored(path19) || this.fsw.closed) {
|
|
17322
17322
|
ready();
|
|
17323
17323
|
return false;
|
|
17324
17324
|
}
|
|
17325
|
-
const wh = this.fsw._getWatchHelpers(
|
|
17325
|
+
const wh = this.fsw._getWatchHelpers(path19);
|
|
17326
17326
|
if (priorWh) {
|
|
17327
17327
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
17328
17328
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -17338,8 +17338,8 @@ var NodeFsHandler = class {
|
|
|
17338
17338
|
const follow = this.fsw.options.followSymlinks;
|
|
17339
17339
|
let closer;
|
|
17340
17340
|
if (stats.isDirectory()) {
|
|
17341
|
-
const absPath = sp.resolve(
|
|
17342
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
17341
|
+
const absPath = sp.resolve(path19);
|
|
17342
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path19) : path19;
|
|
17343
17343
|
if (this.fsw.closed)
|
|
17344
17344
|
return;
|
|
17345
17345
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -17349,29 +17349,29 @@ var NodeFsHandler = class {
|
|
|
17349
17349
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
17350
17350
|
}
|
|
17351
17351
|
} else if (stats.isSymbolicLink()) {
|
|
17352
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
17352
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path19) : path19;
|
|
17353
17353
|
if (this.fsw.closed)
|
|
17354
17354
|
return;
|
|
17355
17355
|
const parent = sp.dirname(wh.watchPath);
|
|
17356
17356
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
17357
17357
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
17358
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
17358
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path19, wh, targetPath);
|
|
17359
17359
|
if (this.fsw.closed)
|
|
17360
17360
|
return;
|
|
17361
17361
|
if (targetPath !== void 0) {
|
|
17362
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
17362
|
+
this.fsw._symlinkPaths.set(sp.resolve(path19), targetPath);
|
|
17363
17363
|
}
|
|
17364
17364
|
} else {
|
|
17365
17365
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
17366
17366
|
}
|
|
17367
17367
|
ready();
|
|
17368
17368
|
if (closer)
|
|
17369
|
-
this.fsw._addPathCloser(
|
|
17369
|
+
this.fsw._addPathCloser(path19, closer);
|
|
17370
17370
|
return false;
|
|
17371
17371
|
} catch (error48) {
|
|
17372
17372
|
if (this.fsw._handleError(error48)) {
|
|
17373
17373
|
ready();
|
|
17374
|
-
return
|
|
17374
|
+
return path19;
|
|
17375
17375
|
}
|
|
17376
17376
|
}
|
|
17377
17377
|
}
|
|
@@ -17414,24 +17414,24 @@ function createPattern(matcher) {
|
|
|
17414
17414
|
}
|
|
17415
17415
|
return () => false;
|
|
17416
17416
|
}
|
|
17417
|
-
function normalizePath(
|
|
17418
|
-
if (typeof
|
|
17417
|
+
function normalizePath(path19) {
|
|
17418
|
+
if (typeof path19 !== "string")
|
|
17419
17419
|
throw new Error("string expected");
|
|
17420
|
-
|
|
17421
|
-
|
|
17420
|
+
path19 = sp2.normalize(path19);
|
|
17421
|
+
path19 = path19.replace(/\\/g, "/");
|
|
17422
17422
|
let prepend = false;
|
|
17423
|
-
if (
|
|
17423
|
+
if (path19.startsWith("//"))
|
|
17424
17424
|
prepend = true;
|
|
17425
|
-
|
|
17425
|
+
path19 = path19.replace(DOUBLE_SLASH_RE, "/");
|
|
17426
17426
|
if (prepend)
|
|
17427
|
-
|
|
17428
|
-
return
|
|
17427
|
+
path19 = "/" + path19;
|
|
17428
|
+
return path19;
|
|
17429
17429
|
}
|
|
17430
17430
|
function matchPatterns(patterns, testString, stats) {
|
|
17431
|
-
const
|
|
17431
|
+
const path19 = normalizePath(testString);
|
|
17432
17432
|
for (let index = 0; index < patterns.length; index++) {
|
|
17433
17433
|
const pattern = patterns[index];
|
|
17434
|
-
if (pattern(
|
|
17434
|
+
if (pattern(path19, stats)) {
|
|
17435
17435
|
return true;
|
|
17436
17436
|
}
|
|
17437
17437
|
}
|
|
@@ -17469,19 +17469,19 @@ var toUnix = (string4) => {
|
|
|
17469
17469
|
}
|
|
17470
17470
|
return str;
|
|
17471
17471
|
};
|
|
17472
|
-
var normalizePathToUnix = (
|
|
17473
|
-
var normalizeIgnored = (cwd = "") => (
|
|
17474
|
-
if (typeof
|
|
17475
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
17472
|
+
var normalizePathToUnix = (path19) => toUnix(sp2.normalize(toUnix(path19)));
|
|
17473
|
+
var normalizeIgnored = (cwd = "") => (path19) => {
|
|
17474
|
+
if (typeof path19 === "string") {
|
|
17475
|
+
return normalizePathToUnix(sp2.isAbsolute(path19) ? path19 : sp2.join(cwd, path19));
|
|
17476
17476
|
} else {
|
|
17477
|
-
return
|
|
17477
|
+
return path19;
|
|
17478
17478
|
}
|
|
17479
17479
|
};
|
|
17480
|
-
var getAbsolutePath = (
|
|
17481
|
-
if (sp2.isAbsolute(
|
|
17482
|
-
return
|
|
17480
|
+
var getAbsolutePath = (path19, cwd) => {
|
|
17481
|
+
if (sp2.isAbsolute(path19)) {
|
|
17482
|
+
return path19;
|
|
17483
17483
|
}
|
|
17484
|
-
return sp2.join(cwd,
|
|
17484
|
+
return sp2.join(cwd, path19);
|
|
17485
17485
|
};
|
|
17486
17486
|
var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
17487
17487
|
var DirEntry = class {
|
|
@@ -17546,10 +17546,10 @@ var WatchHelper = class {
|
|
|
17546
17546
|
dirParts;
|
|
17547
17547
|
followSymlinks;
|
|
17548
17548
|
statMethod;
|
|
17549
|
-
constructor(
|
|
17549
|
+
constructor(path19, follow, fsw) {
|
|
17550
17550
|
this.fsw = fsw;
|
|
17551
|
-
const watchPath =
|
|
17552
|
-
this.path =
|
|
17551
|
+
const watchPath = path19;
|
|
17552
|
+
this.path = path19 = path19.replace(REPLACER_RE, "");
|
|
17553
17553
|
this.watchPath = watchPath;
|
|
17554
17554
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
17555
17555
|
this.dirParts = [];
|
|
@@ -17689,20 +17689,20 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17689
17689
|
this._closePromise = void 0;
|
|
17690
17690
|
let paths = unifyPaths(paths_);
|
|
17691
17691
|
if (cwd) {
|
|
17692
|
-
paths = paths.map((
|
|
17693
|
-
const absPath = getAbsolutePath(
|
|
17692
|
+
paths = paths.map((path19) => {
|
|
17693
|
+
const absPath = getAbsolutePath(path19, cwd);
|
|
17694
17694
|
return absPath;
|
|
17695
17695
|
});
|
|
17696
17696
|
}
|
|
17697
|
-
paths.forEach((
|
|
17698
|
-
this._removeIgnoredPath(
|
|
17697
|
+
paths.forEach((path19) => {
|
|
17698
|
+
this._removeIgnoredPath(path19);
|
|
17699
17699
|
});
|
|
17700
17700
|
this._userIgnored = void 0;
|
|
17701
17701
|
if (!this._readyCount)
|
|
17702
17702
|
this._readyCount = 0;
|
|
17703
17703
|
this._readyCount += paths.length;
|
|
17704
|
-
Promise.all(paths.map(async (
|
|
17705
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
17704
|
+
Promise.all(paths.map(async (path19) => {
|
|
17705
|
+
const res = await this._nodeFsHandler._addToNodeFs(path19, !_internal, void 0, 0, _origAdd);
|
|
17706
17706
|
if (res)
|
|
17707
17707
|
this._emitReady();
|
|
17708
17708
|
return res;
|
|
@@ -17724,17 +17724,17 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17724
17724
|
return this;
|
|
17725
17725
|
const paths = unifyPaths(paths_);
|
|
17726
17726
|
const { cwd } = this.options;
|
|
17727
|
-
paths.forEach((
|
|
17728
|
-
if (!sp2.isAbsolute(
|
|
17727
|
+
paths.forEach((path19) => {
|
|
17728
|
+
if (!sp2.isAbsolute(path19) && !this._closers.has(path19)) {
|
|
17729
17729
|
if (cwd)
|
|
17730
|
-
|
|
17731
|
-
|
|
17730
|
+
path19 = sp2.join(cwd, path19);
|
|
17731
|
+
path19 = sp2.resolve(path19);
|
|
17732
17732
|
}
|
|
17733
|
-
this._closePath(
|
|
17734
|
-
this._addIgnoredPath(
|
|
17735
|
-
if (this._watched.has(
|
|
17733
|
+
this._closePath(path19);
|
|
17734
|
+
this._addIgnoredPath(path19);
|
|
17735
|
+
if (this._watched.has(path19)) {
|
|
17736
17736
|
this._addIgnoredPath({
|
|
17737
|
-
path:
|
|
17737
|
+
path: path19,
|
|
17738
17738
|
recursive: true
|
|
17739
17739
|
});
|
|
17740
17740
|
}
|
|
@@ -17798,38 +17798,38 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17798
17798
|
* @param stats arguments to be passed with event
|
|
17799
17799
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
17800
17800
|
*/
|
|
17801
|
-
async _emit(event,
|
|
17801
|
+
async _emit(event, path19, stats) {
|
|
17802
17802
|
if (this.closed)
|
|
17803
17803
|
return;
|
|
17804
17804
|
const opts = this.options;
|
|
17805
17805
|
if (isWindows)
|
|
17806
|
-
|
|
17806
|
+
path19 = sp2.normalize(path19);
|
|
17807
17807
|
if (opts.cwd)
|
|
17808
|
-
|
|
17809
|
-
const args = [
|
|
17808
|
+
path19 = sp2.relative(opts.cwd, path19);
|
|
17809
|
+
const args = [path19];
|
|
17810
17810
|
if (stats != null)
|
|
17811
17811
|
args.push(stats);
|
|
17812
17812
|
const awf = opts.awaitWriteFinish;
|
|
17813
17813
|
let pw;
|
|
17814
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
17814
|
+
if (awf && (pw = this._pendingWrites.get(path19))) {
|
|
17815
17815
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
17816
17816
|
return this;
|
|
17817
17817
|
}
|
|
17818
17818
|
if (opts.atomic) {
|
|
17819
17819
|
if (event === EVENTS.UNLINK) {
|
|
17820
|
-
this._pendingUnlinks.set(
|
|
17820
|
+
this._pendingUnlinks.set(path19, [event, ...args]);
|
|
17821
17821
|
setTimeout(() => {
|
|
17822
|
-
this._pendingUnlinks.forEach((entry,
|
|
17822
|
+
this._pendingUnlinks.forEach((entry, path20) => {
|
|
17823
17823
|
this.emit(...entry);
|
|
17824
17824
|
this.emit(EVENTS.ALL, ...entry);
|
|
17825
|
-
this._pendingUnlinks.delete(
|
|
17825
|
+
this._pendingUnlinks.delete(path20);
|
|
17826
17826
|
});
|
|
17827
17827
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
17828
17828
|
return this;
|
|
17829
17829
|
}
|
|
17830
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
17830
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path19)) {
|
|
17831
17831
|
event = EVENTS.CHANGE;
|
|
17832
|
-
this._pendingUnlinks.delete(
|
|
17832
|
+
this._pendingUnlinks.delete(path19);
|
|
17833
17833
|
}
|
|
17834
17834
|
}
|
|
17835
17835
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -17847,16 +17847,16 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17847
17847
|
this.emitWithAll(event, args);
|
|
17848
17848
|
}
|
|
17849
17849
|
};
|
|
17850
|
-
this._awaitWriteFinish(
|
|
17850
|
+
this._awaitWriteFinish(path19, awf.stabilityThreshold, event, awfEmit);
|
|
17851
17851
|
return this;
|
|
17852
17852
|
}
|
|
17853
17853
|
if (event === EVENTS.CHANGE) {
|
|
17854
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
17854
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path19, 50);
|
|
17855
17855
|
if (isThrottled)
|
|
17856
17856
|
return this;
|
|
17857
17857
|
}
|
|
17858
17858
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
17859
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
17859
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path19) : path19;
|
|
17860
17860
|
let stats2;
|
|
17861
17861
|
try {
|
|
17862
17862
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -17887,23 +17887,23 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17887
17887
|
* @param timeout duration of time to suppress duplicate actions
|
|
17888
17888
|
* @returns tracking object or false if action should be suppressed
|
|
17889
17889
|
*/
|
|
17890
|
-
_throttle(actionType,
|
|
17890
|
+
_throttle(actionType, path19, timeout) {
|
|
17891
17891
|
if (!this._throttled.has(actionType)) {
|
|
17892
17892
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
17893
17893
|
}
|
|
17894
17894
|
const action = this._throttled.get(actionType);
|
|
17895
17895
|
if (!action)
|
|
17896
17896
|
throw new Error("invalid throttle");
|
|
17897
|
-
const actionPath = action.get(
|
|
17897
|
+
const actionPath = action.get(path19);
|
|
17898
17898
|
if (actionPath) {
|
|
17899
17899
|
actionPath.count++;
|
|
17900
17900
|
return false;
|
|
17901
17901
|
}
|
|
17902
17902
|
let timeoutObject;
|
|
17903
17903
|
const clear = () => {
|
|
17904
|
-
const item = action.get(
|
|
17904
|
+
const item = action.get(path19);
|
|
17905
17905
|
const count = item ? item.count : 0;
|
|
17906
|
-
action.delete(
|
|
17906
|
+
action.delete(path19);
|
|
17907
17907
|
clearTimeout(timeoutObject);
|
|
17908
17908
|
if (item)
|
|
17909
17909
|
clearTimeout(item.timeoutObject);
|
|
@@ -17911,7 +17911,7 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17911
17911
|
};
|
|
17912
17912
|
timeoutObject = setTimeout(clear, timeout);
|
|
17913
17913
|
const thr = { timeoutObject, clear, count: 0 };
|
|
17914
|
-
action.set(
|
|
17914
|
+
action.set(path19, thr);
|
|
17915
17915
|
return thr;
|
|
17916
17916
|
}
|
|
17917
17917
|
_incrReadyCount() {
|
|
@@ -17925,44 +17925,44 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17925
17925
|
* @param event
|
|
17926
17926
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
17927
17927
|
*/
|
|
17928
|
-
_awaitWriteFinish(
|
|
17928
|
+
_awaitWriteFinish(path19, threshold, event, awfEmit) {
|
|
17929
17929
|
const awf = this.options.awaitWriteFinish;
|
|
17930
17930
|
if (typeof awf !== "object")
|
|
17931
17931
|
return;
|
|
17932
17932
|
const pollInterval = awf.pollInterval;
|
|
17933
17933
|
let timeoutHandler;
|
|
17934
|
-
let fullPath =
|
|
17935
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
17936
|
-
fullPath = sp2.join(this.options.cwd,
|
|
17934
|
+
let fullPath = path19;
|
|
17935
|
+
if (this.options.cwd && !sp2.isAbsolute(path19)) {
|
|
17936
|
+
fullPath = sp2.join(this.options.cwd, path19);
|
|
17937
17937
|
}
|
|
17938
17938
|
const now = /* @__PURE__ */ new Date();
|
|
17939
17939
|
const writes = this._pendingWrites;
|
|
17940
17940
|
function awaitWriteFinishFn(prevStat) {
|
|
17941
17941
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
17942
|
-
if (err || !writes.has(
|
|
17942
|
+
if (err || !writes.has(path19)) {
|
|
17943
17943
|
if (err && err.code !== "ENOENT")
|
|
17944
17944
|
awfEmit(err);
|
|
17945
17945
|
return;
|
|
17946
17946
|
}
|
|
17947
17947
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
17948
17948
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
17949
|
-
writes.get(
|
|
17949
|
+
writes.get(path19).lastChange = now2;
|
|
17950
17950
|
}
|
|
17951
|
-
const pw = writes.get(
|
|
17951
|
+
const pw = writes.get(path19);
|
|
17952
17952
|
const df = now2 - pw.lastChange;
|
|
17953
17953
|
if (df >= threshold) {
|
|
17954
|
-
writes.delete(
|
|
17954
|
+
writes.delete(path19);
|
|
17955
17955
|
awfEmit(void 0, curStat);
|
|
17956
17956
|
} else {
|
|
17957
17957
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
17958
17958
|
}
|
|
17959
17959
|
});
|
|
17960
17960
|
}
|
|
17961
|
-
if (!writes.has(
|
|
17962
|
-
writes.set(
|
|
17961
|
+
if (!writes.has(path19)) {
|
|
17962
|
+
writes.set(path19, {
|
|
17963
17963
|
lastChange: now,
|
|
17964
17964
|
cancelWait: () => {
|
|
17965
|
-
writes.delete(
|
|
17965
|
+
writes.delete(path19);
|
|
17966
17966
|
clearTimeout(timeoutHandler);
|
|
17967
17967
|
return event;
|
|
17968
17968
|
}
|
|
@@ -17973,8 +17973,8 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17973
17973
|
/**
|
|
17974
17974
|
* Determines whether user has asked to ignore this path.
|
|
17975
17975
|
*/
|
|
17976
|
-
_isIgnored(
|
|
17977
|
-
if (this.options.atomic && DOT_RE.test(
|
|
17976
|
+
_isIgnored(path19, stats) {
|
|
17977
|
+
if (this.options.atomic && DOT_RE.test(path19))
|
|
17978
17978
|
return true;
|
|
17979
17979
|
if (!this._userIgnored) {
|
|
17980
17980
|
const { cwd } = this.options;
|
|
@@ -17984,17 +17984,17 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
17984
17984
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
17985
17985
|
this._userIgnored = anymatch(list, void 0);
|
|
17986
17986
|
}
|
|
17987
|
-
return this._userIgnored(
|
|
17987
|
+
return this._userIgnored(path19, stats);
|
|
17988
17988
|
}
|
|
17989
|
-
_isntIgnored(
|
|
17990
|
-
return !this._isIgnored(
|
|
17989
|
+
_isntIgnored(path19, stat4) {
|
|
17990
|
+
return !this._isIgnored(path19, stat4);
|
|
17991
17991
|
}
|
|
17992
17992
|
/**
|
|
17993
17993
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
17994
17994
|
* @param path file or directory pattern being watched
|
|
17995
17995
|
*/
|
|
17996
|
-
_getWatchHelpers(
|
|
17997
|
-
return new WatchHelper(
|
|
17996
|
+
_getWatchHelpers(path19) {
|
|
17997
|
+
return new WatchHelper(path19, this.options.followSymlinks, this);
|
|
17998
17998
|
}
|
|
17999
17999
|
// Directory helpers
|
|
18000
18000
|
// -----------------
|
|
@@ -18026,63 +18026,63 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
18026
18026
|
* @param item base path of item/directory
|
|
18027
18027
|
*/
|
|
18028
18028
|
_remove(directory, item, isDirectory) {
|
|
18029
|
-
const
|
|
18030
|
-
const fullPath = sp2.resolve(
|
|
18031
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
18032
|
-
if (!this._throttle("remove",
|
|
18029
|
+
const path19 = sp2.join(directory, item);
|
|
18030
|
+
const fullPath = sp2.resolve(path19);
|
|
18031
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path19) || this._watched.has(fullPath);
|
|
18032
|
+
if (!this._throttle("remove", path19, 100))
|
|
18033
18033
|
return;
|
|
18034
18034
|
if (!isDirectory && this._watched.size === 1) {
|
|
18035
18035
|
this.add(directory, item, true);
|
|
18036
18036
|
}
|
|
18037
|
-
const wp = this._getWatchedDir(
|
|
18037
|
+
const wp = this._getWatchedDir(path19);
|
|
18038
18038
|
const nestedDirectoryChildren = wp.getChildren();
|
|
18039
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
18039
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path19, nested));
|
|
18040
18040
|
const parent = this._getWatchedDir(directory);
|
|
18041
18041
|
const wasTracked = parent.has(item);
|
|
18042
18042
|
parent.remove(item);
|
|
18043
18043
|
if (this._symlinkPaths.has(fullPath)) {
|
|
18044
18044
|
this._symlinkPaths.delete(fullPath);
|
|
18045
18045
|
}
|
|
18046
|
-
let relPath =
|
|
18046
|
+
let relPath = path19;
|
|
18047
18047
|
if (this.options.cwd)
|
|
18048
|
-
relPath = sp2.relative(this.options.cwd,
|
|
18048
|
+
relPath = sp2.relative(this.options.cwd, path19);
|
|
18049
18049
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
18050
18050
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
18051
18051
|
if (event === EVENTS.ADD)
|
|
18052
18052
|
return;
|
|
18053
18053
|
}
|
|
18054
|
-
this._watched.delete(
|
|
18054
|
+
this._watched.delete(path19);
|
|
18055
18055
|
this._watched.delete(fullPath);
|
|
18056
18056
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
18057
|
-
if (wasTracked && !this._isIgnored(
|
|
18058
|
-
this._emit(eventName,
|
|
18059
|
-
this._closePath(
|
|
18057
|
+
if (wasTracked && !this._isIgnored(path19))
|
|
18058
|
+
this._emit(eventName, path19);
|
|
18059
|
+
this._closePath(path19);
|
|
18060
18060
|
}
|
|
18061
18061
|
/**
|
|
18062
18062
|
* Closes all watchers for a path
|
|
18063
18063
|
*/
|
|
18064
|
-
_closePath(
|
|
18065
|
-
this._closeFile(
|
|
18066
|
-
const dir = sp2.dirname(
|
|
18067
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
18064
|
+
_closePath(path19) {
|
|
18065
|
+
this._closeFile(path19);
|
|
18066
|
+
const dir = sp2.dirname(path19);
|
|
18067
|
+
this._getWatchedDir(dir).remove(sp2.basename(path19));
|
|
18068
18068
|
}
|
|
18069
18069
|
/**
|
|
18070
18070
|
* Closes only file-specific watchers
|
|
18071
18071
|
*/
|
|
18072
|
-
_closeFile(
|
|
18073
|
-
const closers = this._closers.get(
|
|
18072
|
+
_closeFile(path19) {
|
|
18073
|
+
const closers = this._closers.get(path19);
|
|
18074
18074
|
if (!closers)
|
|
18075
18075
|
return;
|
|
18076
18076
|
closers.forEach((closer) => closer());
|
|
18077
|
-
this._closers.delete(
|
|
18077
|
+
this._closers.delete(path19);
|
|
18078
18078
|
}
|
|
18079
|
-
_addPathCloser(
|
|
18079
|
+
_addPathCloser(path19, closer) {
|
|
18080
18080
|
if (!closer)
|
|
18081
18081
|
return;
|
|
18082
|
-
let list = this._closers.get(
|
|
18082
|
+
let list = this._closers.get(path19);
|
|
18083
18083
|
if (!list) {
|
|
18084
18084
|
list = [];
|
|
18085
|
-
this._closers.set(
|
|
18085
|
+
this._closers.set(path19, list);
|
|
18086
18086
|
}
|
|
18087
18087
|
list.push(closer);
|
|
18088
18088
|
}
|
|
@@ -18115,28 +18115,33 @@ var fs6 = __toESM(require("fs"), 1);
|
|
|
18115
18115
|
var path8 = __toESM(require("path"), 1);
|
|
18116
18116
|
var os9 = __toESM(require("os"), 1);
|
|
18117
18117
|
var os10 = __toESM(require("os"), 1);
|
|
18118
|
+
var import_child_process6 = require("child_process");
|
|
18119
|
+
var import_child_process7 = require("child_process");
|
|
18118
18120
|
var fs7 = __toESM(require("fs"), 1);
|
|
18119
|
-
var
|
|
18120
|
-
var
|
|
18121
|
+
var os11 = __toESM(require("os"), 1);
|
|
18122
|
+
var path9 = __toESM(require("path"), 1);
|
|
18123
|
+
var fs8 = __toESM(require("fs"), 1);
|
|
18124
|
+
var os14 = __toESM(require("os"), 1);
|
|
18125
|
+
var path11 = __toESM(require("path"), 1);
|
|
18121
18126
|
var crypto4 = __toESM(require("crypto"), 1);
|
|
18122
18127
|
var import_chalk = __toESM(require("chalk"), 1);
|
|
18123
18128
|
var crypto3 = __toESM(require("crypto"), 1);
|
|
18124
18129
|
var import_stream = require("stream");
|
|
18125
|
-
var
|
|
18130
|
+
var import_child_process8 = require("child_process");
|
|
18126
18131
|
init_acp();
|
|
18127
|
-
var fs8 = __toESM(require("fs"), 1);
|
|
18128
|
-
var path11 = __toESM(require("path"), 1);
|
|
18129
|
-
var os14 = __toESM(require("os"), 1);
|
|
18130
|
-
var import_child_process7 = require("child_process");
|
|
18131
|
-
var import_os3 = require("os");
|
|
18132
|
-
var http2 = __toESM(require("http"), 1);
|
|
18133
|
-
var fs11 = __toESM(require("fs"), 1);
|
|
18134
|
-
var path14 = __toESM(require("path"), 1);
|
|
18135
18132
|
var fs9 = __toESM(require("fs"), 1);
|
|
18136
18133
|
var path12 = __toESM(require("path"), 1);
|
|
18134
|
+
var os15 = __toESM(require("os"), 1);
|
|
18135
|
+
var import_child_process9 = require("child_process");
|
|
18136
|
+
var import_os3 = require("os");
|
|
18137
|
+
var http2 = __toESM(require("http"), 1);
|
|
18138
|
+
var fs12 = __toESM(require("fs"), 1);
|
|
18139
|
+
var path15 = __toESM(require("path"), 1);
|
|
18137
18140
|
var fs10 = __toESM(require("fs"), 1);
|
|
18138
18141
|
var path13 = __toESM(require("path"), 1);
|
|
18139
|
-
var
|
|
18142
|
+
var fs11 = __toESM(require("fs"), 1);
|
|
18143
|
+
var path14 = __toESM(require("path"), 1);
|
|
18144
|
+
var os16 = __toESM(require("os"), 1);
|
|
18140
18145
|
|
|
18141
18146
|
// ../session-host-core/dist/index.mjs
|
|
18142
18147
|
var os = __toESM(require("os"), 1);
|
|
@@ -18996,7 +19001,7 @@ var init_pty_transport = __esm2({
|
|
|
18996
19001
|
spawn(command, args, options) {
|
|
18997
19002
|
if (!pty) throw new Error("node-pty is not installed");
|
|
18998
19003
|
const handle = pty.spawn(command, args, {
|
|
18999
|
-
name:
|
|
19004
|
+
name: os12.platform() === "win32" ? "xterm-color" : "xterm-256color",
|
|
19000
19005
|
cols: options.cols,
|
|
19001
19006
|
rows: options.rows,
|
|
19002
19007
|
cwd: options.cwd,
|
|
@@ -19048,7 +19053,7 @@ function computeTerminalQueryTail(buffer) {
|
|
|
19048
19053
|
return "";
|
|
19049
19054
|
}
|
|
19050
19055
|
function findBinary(name) {
|
|
19051
|
-
const isWin =
|
|
19056
|
+
const isWin = os13.platform() === "win32";
|
|
19052
19057
|
try {
|
|
19053
19058
|
const cmd = isWin ? `where ${name}` : `which ${name}`;
|
|
19054
19059
|
return (0, import_child_process.execSync)(cmd, { encoding: "utf-8", timeout: 5e3, stdio: ["pipe", "pipe", "pipe"] }).trim().split("\n")[0].trim();
|
|
@@ -19057,14 +19062,14 @@ function findBinary(name) {
|
|
|
19057
19062
|
}
|
|
19058
19063
|
}
|
|
19059
19064
|
function isScriptBinary(binaryPath) {
|
|
19060
|
-
if (!
|
|
19065
|
+
if (!path10.isAbsolute(binaryPath)) return false;
|
|
19061
19066
|
try {
|
|
19062
|
-
const
|
|
19063
|
-
const resolved =
|
|
19067
|
+
const fs132 = __require("fs");
|
|
19068
|
+
const resolved = fs132.realpathSync(binaryPath);
|
|
19064
19069
|
const head = Buffer.alloc(8);
|
|
19065
|
-
const fd =
|
|
19066
|
-
|
|
19067
|
-
|
|
19070
|
+
const fd = fs132.openSync(resolved, "r");
|
|
19071
|
+
fs132.readSync(fd, head, 0, 8, 0);
|
|
19072
|
+
fs132.closeSync(fd);
|
|
19068
19073
|
let i = 0;
|
|
19069
19074
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
19070
19075
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -19073,14 +19078,14 @@ function isScriptBinary(binaryPath) {
|
|
|
19073
19078
|
}
|
|
19074
19079
|
}
|
|
19075
19080
|
function looksLikeMachOOrElf(filePath) {
|
|
19076
|
-
if (!
|
|
19081
|
+
if (!path10.isAbsolute(filePath)) return false;
|
|
19077
19082
|
try {
|
|
19078
|
-
const
|
|
19079
|
-
const resolved =
|
|
19083
|
+
const fs132 = __require("fs");
|
|
19084
|
+
const resolved = fs132.realpathSync(filePath);
|
|
19080
19085
|
const buf = Buffer.alloc(8);
|
|
19081
|
-
const fd =
|
|
19082
|
-
|
|
19083
|
-
|
|
19086
|
+
const fd = fs132.openSync(resolved, "r");
|
|
19087
|
+
fs132.readSync(fd, buf, 0, 8, 0);
|
|
19088
|
+
fs132.closeSync(fd);
|
|
19084
19089
|
let i = 0;
|
|
19085
19090
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
19086
19091
|
const b = buf.subarray(i);
|
|
@@ -19096,12 +19101,12 @@ function looksLikeMachOOrElf(filePath) {
|
|
|
19096
19101
|
}
|
|
19097
19102
|
function shSingleQuote(arg) {
|
|
19098
19103
|
if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
|
|
19099
|
-
if (
|
|
19104
|
+
if (os13.platform() === "win32") {
|
|
19100
19105
|
return `"${arg.replace(/"/g, '""')}"`;
|
|
19101
19106
|
}
|
|
19102
19107
|
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
19103
19108
|
}
|
|
19104
|
-
function estimatePromptDisplayLines(text, cols =
|
|
19109
|
+
function estimatePromptDisplayLines(text, cols = 80) {
|
|
19105
19110
|
const normalized = String(text || "").replace(/\r/g, "");
|
|
19106
19111
|
if (!normalized) return 1;
|
|
19107
19112
|
return normalized.split("\n").reduce((sum, line) => sum + Math.max(1, Math.ceil(Math.max(1, line.length) / cols)), 0);
|
|
@@ -19167,16 +19172,16 @@ var init_provider_cli_adapter = __esm2({
|
|
|
19167
19172
|
init_pty_transport();
|
|
19168
19173
|
try {
|
|
19169
19174
|
pty2 = __require("node-pty");
|
|
19170
|
-
if (
|
|
19175
|
+
if (os13.platform() !== "win32") {
|
|
19171
19176
|
try {
|
|
19172
|
-
const
|
|
19173
|
-
const ptyDir =
|
|
19174
|
-
const platformArch = `${
|
|
19175
|
-
const helper =
|
|
19176
|
-
if (
|
|
19177
|
-
const stat4 =
|
|
19177
|
+
const fs132 = __require("fs");
|
|
19178
|
+
const ptyDir = path10.resolve(path10.dirname(__require.resolve("node-pty")), "..");
|
|
19179
|
+
const platformArch = `${os13.platform()}-${os13.arch()}`;
|
|
19180
|
+
const helper = path10.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
19181
|
+
if (fs132.existsSync(helper)) {
|
|
19182
|
+
const stat4 = fs132.statSync(helper);
|
|
19178
19183
|
if (!(stat4.mode & 73)) {
|
|
19179
|
-
|
|
19184
|
+
fs132.chmodSync(helper, stat4.mode | 493);
|
|
19180
19185
|
LOG.info("CLI", "[node-pty] Fixed spawn-helper permissions");
|
|
19181
19186
|
}
|
|
19182
19187
|
}
|
|
@@ -19193,7 +19198,7 @@ var init_provider_cli_adapter = __esm2({
|
|
|
19193
19198
|
this.transportFactory = transportFactory;
|
|
19194
19199
|
this.cliType = provider.type;
|
|
19195
19200
|
this.cliName = provider.name;
|
|
19196
|
-
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/,
|
|
19201
|
+
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os13.homedir()) : workingDir;
|
|
19197
19202
|
const t = provider.timeouts || {};
|
|
19198
19203
|
this.timeouts = {
|
|
19199
19204
|
ptyFlush: t.ptyFlush ?? 50,
|
|
@@ -19360,12 +19365,12 @@ var init_provider_cli_adapter = __esm2({
|
|
|
19360
19365
|
if (this.ptyProcess) return;
|
|
19361
19366
|
const { spawn: spawnConfig } = this.provider;
|
|
19362
19367
|
const binaryPath = findBinary(spawnConfig.command);
|
|
19363
|
-
const isWin =
|
|
19368
|
+
const isWin = os13.platform() === "win32";
|
|
19364
19369
|
const allArgs = [...spawnConfig.args, ...this.extraArgs];
|
|
19365
19370
|
LOG.info("CLI", `[${this.cliType}] Spawning in ${this.workingDir}`);
|
|
19366
19371
|
let shellCmd;
|
|
19367
19372
|
let shellArgs;
|
|
19368
|
-
const useShellUnix = !isWin && (!!spawnConfig.shell || !
|
|
19373
|
+
const useShellUnix = !isWin && (!!spawnConfig.shell || !path10.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
19369
19374
|
const useShell = isWin ? !!spawnConfig.shell : useShellUnix;
|
|
19370
19375
|
if (useShell) {
|
|
19371
19376
|
if (!spawnConfig.shell && !isWin) {
|
|
@@ -19383,8 +19388,8 @@ var init_provider_cli_adapter = __esm2({
|
|
|
19383
19388
|
shellArgs = allArgs;
|
|
19384
19389
|
}
|
|
19385
19390
|
const ptyOpts = {
|
|
19386
|
-
cols:
|
|
19387
|
-
rows:
|
|
19391
|
+
cols: 80,
|
|
19392
|
+
rows: 24,
|
|
19388
19393
|
cwd: this.workingDir,
|
|
19389
19394
|
env: buildCliSpawnEnv(process.env, spawnConfig.env)
|
|
19390
19395
|
};
|
|
@@ -19440,7 +19445,7 @@ var init_provider_cli_adapter = __esm2({
|
|
|
19440
19445
|
this.spawnAt = Date.now();
|
|
19441
19446
|
this.startupParseGate = true;
|
|
19442
19447
|
this.startupBuffer = "";
|
|
19443
|
-
this.terminalScreen.reset(
|
|
19448
|
+
this.terminalScreen.reset(24, 80);
|
|
19444
19449
|
this.pendingTerminalQueryTail = "";
|
|
19445
19450
|
this.currentTurnScope = null;
|
|
19446
19451
|
this.ready = false;
|
|
@@ -20452,18 +20457,18 @@ function checkPathExists(paths) {
|
|
|
20452
20457
|
return null;
|
|
20453
20458
|
}
|
|
20454
20459
|
async function detectIDEs() {
|
|
20455
|
-
const
|
|
20460
|
+
const os172 = (0, import_os2.platform)();
|
|
20456
20461
|
const results = [];
|
|
20457
20462
|
for (const def of getMergedDefinitions()) {
|
|
20458
20463
|
const cliPath = findCliCommand(def.cli);
|
|
20459
|
-
const appPath = checkPathExists(def.paths[
|
|
20464
|
+
const appPath = checkPathExists(def.paths[os172] || []);
|
|
20460
20465
|
const installed = !!(cliPath || appPath);
|
|
20461
20466
|
let resolvedCli = cliPath;
|
|
20462
|
-
if (!resolvedCli && appPath &&
|
|
20467
|
+
if (!resolvedCli && appPath && os172 === "darwin") {
|
|
20463
20468
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
20464
20469
|
if ((0, import_fs2.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
20465
20470
|
}
|
|
20466
|
-
if (!resolvedCli && appPath &&
|
|
20471
|
+
if (!resolvedCli && appPath && os172 === "win32") {
|
|
20467
20472
|
const { dirname: dirname72 } = await import("path");
|
|
20468
20473
|
const appDir = dirname72(appPath);
|
|
20469
20474
|
const candidates = [
|
|
@@ -26249,7 +26254,7 @@ function detectCurrentWorkspace(ideId) {
|
|
|
26249
26254
|
}
|
|
26250
26255
|
} else if (plat === "win32") {
|
|
26251
26256
|
try {
|
|
26252
|
-
const
|
|
26257
|
+
const fs132 = __require("fs");
|
|
26253
26258
|
const appNameMap = getMacAppIdentifiers();
|
|
26254
26259
|
const appName = appNameMap[ideId];
|
|
26255
26260
|
if (appName) {
|
|
@@ -26258,8 +26263,8 @@ function detectCurrentWorkspace(ideId) {
|
|
|
26258
26263
|
appName,
|
|
26259
26264
|
"storage.json"
|
|
26260
26265
|
);
|
|
26261
|
-
if (
|
|
26262
|
-
const data = JSON.parse(
|
|
26266
|
+
if (fs132.existsSync(storagePath)) {
|
|
26267
|
+
const data = JSON.parse(fs132.readFileSync(storagePath, "utf-8"));
|
|
26263
26268
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
26264
26269
|
if (workspaces.length > 0) {
|
|
26265
26270
|
const recent = workspaces[0];
|
|
@@ -26663,6 +26668,182 @@ function buildStatusSnapshot(options) {
|
|
|
26663
26668
|
availableProviders: buildAvailableProviders(options.providerLoader)
|
|
26664
26669
|
};
|
|
26665
26670
|
}
|
|
26671
|
+
var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
26672
|
+
function getUpgradeLogPath() {
|
|
26673
|
+
const home = os11.homedir();
|
|
26674
|
+
const dir = path9.join(home, ".adhdev");
|
|
26675
|
+
fs7.mkdirSync(dir, { recursive: true });
|
|
26676
|
+
return path9.join(dir, "daemon-upgrade.log");
|
|
26677
|
+
}
|
|
26678
|
+
function appendUpgradeLog(message) {
|
|
26679
|
+
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
26680
|
+
`;
|
|
26681
|
+
try {
|
|
26682
|
+
fs7.appendFileSync(getUpgradeLogPath(), line, "utf8");
|
|
26683
|
+
} catch {
|
|
26684
|
+
}
|
|
26685
|
+
}
|
|
26686
|
+
function getNpmExecutable() {
|
|
26687
|
+
return process.platform === "win32" ? "npm.cmd" : "npm";
|
|
26688
|
+
}
|
|
26689
|
+
function killPid(pid) {
|
|
26690
|
+
try {
|
|
26691
|
+
if (process.platform === "win32") {
|
|
26692
|
+
(0, import_child_process6.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
|
|
26693
|
+
} else {
|
|
26694
|
+
process.kill(pid, "SIGTERM");
|
|
26695
|
+
}
|
|
26696
|
+
return true;
|
|
26697
|
+
} catch {
|
|
26698
|
+
return false;
|
|
26699
|
+
}
|
|
26700
|
+
}
|
|
26701
|
+
async function waitForPidExit(pid, timeoutMs) {
|
|
26702
|
+
const start = Date.now();
|
|
26703
|
+
while (Date.now() - start < timeoutMs) {
|
|
26704
|
+
try {
|
|
26705
|
+
process.kill(pid, 0);
|
|
26706
|
+
await new Promise((resolve92) => setTimeout(resolve92, 250));
|
|
26707
|
+
} catch {
|
|
26708
|
+
return;
|
|
26709
|
+
}
|
|
26710
|
+
}
|
|
26711
|
+
}
|
|
26712
|
+
function stopSessionHostProcesses(appName) {
|
|
26713
|
+
const pidFile = path9.join(os11.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
26714
|
+
try {
|
|
26715
|
+
if (fs7.existsSync(pidFile)) {
|
|
26716
|
+
const pid = Number.parseInt(fs7.readFileSync(pidFile, "utf8").trim(), 10);
|
|
26717
|
+
if (Number.isFinite(pid)) {
|
|
26718
|
+
killPid(pid);
|
|
26719
|
+
}
|
|
26720
|
+
}
|
|
26721
|
+
} catch {
|
|
26722
|
+
} finally {
|
|
26723
|
+
try {
|
|
26724
|
+
fs7.unlinkSync(pidFile);
|
|
26725
|
+
} catch {
|
|
26726
|
+
}
|
|
26727
|
+
}
|
|
26728
|
+
if (process.platform !== "win32") {
|
|
26729
|
+
try {
|
|
26730
|
+
const raw = (0, import_child_process6.execFileSync)("pgrep", ["-f", "session-host-daemon"], { encoding: "utf8" }).trim();
|
|
26731
|
+
for (const line of raw.split("\n")) {
|
|
26732
|
+
const pid = Number.parseInt(line.trim(), 10);
|
|
26733
|
+
if (Number.isFinite(pid)) {
|
|
26734
|
+
killPid(pid);
|
|
26735
|
+
}
|
|
26736
|
+
}
|
|
26737
|
+
} catch {
|
|
26738
|
+
}
|
|
26739
|
+
}
|
|
26740
|
+
}
|
|
26741
|
+
function removeDaemonPidFile() {
|
|
26742
|
+
const pidFile = path9.join(os11.homedir(), ".adhdev", "daemon.pid");
|
|
26743
|
+
try {
|
|
26744
|
+
fs7.unlinkSync(pidFile);
|
|
26745
|
+
} catch {
|
|
26746
|
+
}
|
|
26747
|
+
}
|
|
26748
|
+
function cleanupStaleGlobalInstallDirs(pkgName) {
|
|
26749
|
+
const npmRoot = (0, import_child_process6.execFileSync)(getNpmExecutable(), ["root", "-g"], { encoding: "utf8" }).trim();
|
|
26750
|
+
if (!npmRoot) return;
|
|
26751
|
+
const npmPrefix = (0, import_child_process6.execFileSync)(getNpmExecutable(), ["prefix", "-g"], { encoding: "utf8" }).trim();
|
|
26752
|
+
const binDir = process.platform === "win32" ? npmPrefix : path9.join(npmPrefix, "bin");
|
|
26753
|
+
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
26754
|
+
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
26755
|
+
if (pkgName === "@adhdev/daemon-standalone") {
|
|
26756
|
+
binNames.add("adhdev-standalone");
|
|
26757
|
+
}
|
|
26758
|
+
if (pkgName.startsWith("@")) {
|
|
26759
|
+
const [scope, name] = pkgName.split("/");
|
|
26760
|
+
const scopeDir = path9.join(npmRoot, scope);
|
|
26761
|
+
if (!fs7.existsSync(scopeDir)) return;
|
|
26762
|
+
for (const entry of fs7.readdirSync(scopeDir)) {
|
|
26763
|
+
if (!entry.startsWith(`.${name}-`)) continue;
|
|
26764
|
+
fs7.rmSync(path9.join(scopeDir, entry), { recursive: true, force: true });
|
|
26765
|
+
appendUpgradeLog(`Removed stale scoped staging dir: ${path9.join(scopeDir, entry)}`);
|
|
26766
|
+
}
|
|
26767
|
+
} else {
|
|
26768
|
+
for (const entry of fs7.readdirSync(npmRoot)) {
|
|
26769
|
+
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
26770
|
+
fs7.rmSync(path9.join(npmRoot, entry), { recursive: true, force: true });
|
|
26771
|
+
appendUpgradeLog(`Removed stale staging dir: ${path9.join(npmRoot, entry)}`);
|
|
26772
|
+
}
|
|
26773
|
+
}
|
|
26774
|
+
if (fs7.existsSync(binDir)) {
|
|
26775
|
+
for (const entry of fs7.readdirSync(binDir)) {
|
|
26776
|
+
if (![...binNames].some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
26777
|
+
fs7.rmSync(path9.join(binDir, entry), { recursive: true, force: true });
|
|
26778
|
+
appendUpgradeLog(`Removed stale bin staging entry: ${path9.join(binDir, entry)}`);
|
|
26779
|
+
}
|
|
26780
|
+
}
|
|
26781
|
+
}
|
|
26782
|
+
function spawnDetachedDaemonUpgradeHelper(payload) {
|
|
26783
|
+
const env = { ...process.env, [UPGRADE_HELPER_ENV]: JSON.stringify(payload) };
|
|
26784
|
+
const child = (0, import_child_process7.spawn)(process.execPath, process.argv.slice(1), {
|
|
26785
|
+
detached: true,
|
|
26786
|
+
stdio: "ignore",
|
|
26787
|
+
windowsHide: true,
|
|
26788
|
+
cwd: payload.cwd || process.cwd(),
|
|
26789
|
+
env
|
|
26790
|
+
});
|
|
26791
|
+
child.unref();
|
|
26792
|
+
}
|
|
26793
|
+
async function runDaemonUpgradeHelper(payload) {
|
|
26794
|
+
const restartArgv = Array.isArray(payload.restartArgv) ? payload.restartArgv : [];
|
|
26795
|
+
const sessionHostAppName = payload.sessionHostAppName || process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
|
|
26796
|
+
appendUpgradeLog(`Upgrade helper started for ${payload.packageName}@${payload.targetVersion}`);
|
|
26797
|
+
if (Number.isFinite(payload.parentPid) && payload.parentPid > 0) {
|
|
26798
|
+
appendUpgradeLog(`Waiting for parent pid ${payload.parentPid} to exit`);
|
|
26799
|
+
await waitForPidExit(payload.parentPid, 15e3);
|
|
26800
|
+
}
|
|
26801
|
+
stopSessionHostProcesses(sessionHostAppName);
|
|
26802
|
+
removeDaemonPidFile();
|
|
26803
|
+
cleanupStaleGlobalInstallDirs(payload.packageName);
|
|
26804
|
+
const spec = `${payload.packageName}@${payload.targetVersion || "latest"}`;
|
|
26805
|
+
appendUpgradeLog(`Installing ${spec}`);
|
|
26806
|
+
const installOutput = (0, import_child_process6.execFileSync)(
|
|
26807
|
+
getNpmExecutable(),
|
|
26808
|
+
["install", "-g", spec, "--force"],
|
|
26809
|
+
{
|
|
26810
|
+
encoding: "utf8",
|
|
26811
|
+
stdio: "pipe",
|
|
26812
|
+
maxBuffer: 20 * 1024 * 1024
|
|
26813
|
+
}
|
|
26814
|
+
);
|
|
26815
|
+
if (installOutput.trim()) {
|
|
26816
|
+
appendUpgradeLog(installOutput.trim());
|
|
26817
|
+
}
|
|
26818
|
+
if (restartArgv.length > 0) {
|
|
26819
|
+
const env = { ...process.env };
|
|
26820
|
+
delete env[UPGRADE_HELPER_ENV];
|
|
26821
|
+
appendUpgradeLog(`Restarting daemon with args: ${restartArgv.join(" ")}`);
|
|
26822
|
+
const child = (0, import_child_process7.spawn)(process.execPath, restartArgv, {
|
|
26823
|
+
detached: true,
|
|
26824
|
+
stdio: "ignore",
|
|
26825
|
+
windowsHide: true,
|
|
26826
|
+
cwd: payload.cwd || process.cwd(),
|
|
26827
|
+
env
|
|
26828
|
+
});
|
|
26829
|
+
child.unref();
|
|
26830
|
+
} else {
|
|
26831
|
+
appendUpgradeLog("No restart argv provided; upgrade completed without restart");
|
|
26832
|
+
}
|
|
26833
|
+
}
|
|
26834
|
+
async function maybeRunDaemonUpgradeHelperFromEnv() {
|
|
26835
|
+
const raw = process.env[UPGRADE_HELPER_ENV];
|
|
26836
|
+
if (!raw) return false;
|
|
26837
|
+
delete process.env[UPGRADE_HELPER_ENV];
|
|
26838
|
+
try {
|
|
26839
|
+
const payload = JSON.parse(raw);
|
|
26840
|
+
await runDaemonUpgradeHelper(payload);
|
|
26841
|
+
process.exit(0);
|
|
26842
|
+
} catch (error48) {
|
|
26843
|
+
appendUpgradeLog(`Upgrade helper failed: ${error48?.stack || error48?.message || String(error48)}`);
|
|
26844
|
+
process.exit(1);
|
|
26845
|
+
}
|
|
26846
|
+
}
|
|
26666
26847
|
var CHAT_COMMANDS = [
|
|
26667
26848
|
"send_chat",
|
|
26668
26849
|
"new_chat",
|
|
@@ -26733,8 +26914,8 @@ var DaemonCommandRouter = class {
|
|
|
26733
26914
|
if (logs.length > 0) {
|
|
26734
26915
|
return { success: true, logs, totalBuffered: logs.length };
|
|
26735
26916
|
}
|
|
26736
|
-
if (
|
|
26737
|
-
const content =
|
|
26917
|
+
if (fs8.existsSync(LOG_PATH)) {
|
|
26918
|
+
const content = fs8.readFileSync(LOG_PATH, "utf-8");
|
|
26738
26919
|
const allLines = content.split("\n");
|
|
26739
26920
|
const recent = allLines.slice(-count).join("\n");
|
|
26740
26921
|
return { success: true, logs: recent, totalLines: allLines.length };
|
|
@@ -26882,31 +27063,35 @@ var DaemonCommandRouter = class {
|
|
|
26882
27063
|
const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
|
|
26883
27064
|
const latest = execSync7(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
26884
27065
|
LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
|
|
26885
|
-
|
|
26886
|
-
|
|
26887
|
-
|
|
26888
|
-
|
|
27066
|
+
let currentInstalled = null;
|
|
27067
|
+
try {
|
|
27068
|
+
const currentJson = execSync7(`npm ls -g ${pkgName} --depth=0 --json`, {
|
|
27069
|
+
encoding: "utf-8",
|
|
27070
|
+
timeout: 1e4,
|
|
27071
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
27072
|
+
}).trim();
|
|
27073
|
+
const parsed = JSON.parse(currentJson);
|
|
27074
|
+
currentInstalled = parsed?.dependencies?.[pkgName]?.version || null;
|
|
27075
|
+
} catch {
|
|
27076
|
+
}
|
|
27077
|
+
if (currentInstalled === latest) {
|
|
27078
|
+
LOG.info("Upgrade", `Already on latest version v${latest}; skipping install`);
|
|
27079
|
+
return { success: true, upgraded: false, alreadyLatest: true, version: latest };
|
|
27080
|
+
}
|
|
27081
|
+
spawnDetachedDaemonUpgradeHelper({
|
|
27082
|
+
packageName: pkgName,
|
|
27083
|
+
targetVersion: latest,
|
|
27084
|
+
parentPid: process.pid,
|
|
27085
|
+
restartArgv: process.argv.slice(1),
|
|
27086
|
+
cwd: process.cwd(),
|
|
27087
|
+
sessionHostAppName: process.env.ADHDEV_SESSION_HOST_NAME || "adhdev"
|
|
26889
27088
|
});
|
|
26890
|
-
LOG.info("Upgrade",
|
|
27089
|
+
LOG.info("Upgrade", `Scheduled detached upgrade to v${latest}`);
|
|
26891
27090
|
setTimeout(() => {
|
|
26892
|
-
LOG.info("Upgrade", "
|
|
26893
|
-
try {
|
|
26894
|
-
const path152 = __require("path");
|
|
26895
|
-
const fs122 = __require("fs");
|
|
26896
|
-
const pidFile = path152.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
|
|
26897
|
-
if (fs122.existsSync(pidFile)) fs122.unlinkSync(pidFile);
|
|
26898
|
-
} catch {
|
|
26899
|
-
}
|
|
26900
|
-
const { spawn: spawn32 } = __require("child_process");
|
|
26901
|
-
const child = spawn32(process.execPath, process.argv.slice(1), {
|
|
26902
|
-
detached: true,
|
|
26903
|
-
stdio: "ignore",
|
|
26904
|
-
env: { ...process.env }
|
|
26905
|
-
});
|
|
26906
|
-
child.unref();
|
|
27091
|
+
LOG.info("Upgrade", "Exiting daemon so detached upgrader can continue...");
|
|
26907
27092
|
process.exit(0);
|
|
26908
27093
|
}, 3e3);
|
|
26909
|
-
return { success: true, upgraded: true, version: latest };
|
|
27094
|
+
return { success: true, upgraded: true, version: latest, restarting: true };
|
|
26910
27095
|
} catch (e) {
|
|
26911
27096
|
LOG.error("Upgrade", `Failed: ${e.message}`);
|
|
26912
27097
|
return { success: false, error: e.message };
|
|
@@ -27548,7 +27733,7 @@ var AcpProviderInstance = class {
|
|
|
27548
27733
|
this.errorMessage = null;
|
|
27549
27734
|
this.errorReason = null;
|
|
27550
27735
|
this.stderrBuffer = [];
|
|
27551
|
-
this.process = (0,
|
|
27736
|
+
this.process = (0, import_child_process8.spawn)(command, args, {
|
|
27552
27737
|
cwd: this.workingDir,
|
|
27553
27738
|
env,
|
|
27554
27739
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -28229,7 +28414,7 @@ var DaemonCliManager = class {
|
|
|
28229
28414
|
async startSession(cliType, workingDir, cliArgs, initialModel) {
|
|
28230
28415
|
const trimmed = (workingDir || "").trim();
|
|
28231
28416
|
if (!trimmed) throw new Error("working directory required");
|
|
28232
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/,
|
|
28417
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os14.homedir()) : path11.resolve(trimmed);
|
|
28233
28418
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
28234
28419
|
const provider = this.providerLoader.getByAlias(cliType);
|
|
28235
28420
|
const key = crypto4.randomUUID();
|
|
@@ -29410,7 +29595,7 @@ var ProviderInstanceManager = class {
|
|
|
29410
29595
|
this.eventListeners = [];
|
|
29411
29596
|
}
|
|
29412
29597
|
};
|
|
29413
|
-
var ARCHIVE_PATH =
|
|
29598
|
+
var ARCHIVE_PATH = path12.join(os15.homedir(), ".adhdev", "version-history.json");
|
|
29414
29599
|
var MAX_ENTRIES_PER_PROVIDER = 20;
|
|
29415
29600
|
var VersionArchive = class {
|
|
29416
29601
|
history = {};
|
|
@@ -29419,8 +29604,8 @@ var VersionArchive = class {
|
|
|
29419
29604
|
}
|
|
29420
29605
|
load() {
|
|
29421
29606
|
try {
|
|
29422
|
-
if (
|
|
29423
|
-
this.history = JSON.parse(
|
|
29607
|
+
if (fs9.existsSync(ARCHIVE_PATH)) {
|
|
29608
|
+
this.history = JSON.parse(fs9.readFileSync(ARCHIVE_PATH, "utf-8"));
|
|
29424
29609
|
}
|
|
29425
29610
|
} catch {
|
|
29426
29611
|
this.history = {};
|
|
@@ -29457,15 +29642,15 @@ var VersionArchive = class {
|
|
|
29457
29642
|
}
|
|
29458
29643
|
save() {
|
|
29459
29644
|
try {
|
|
29460
|
-
|
|
29461
|
-
|
|
29645
|
+
fs9.mkdirSync(path12.dirname(ARCHIVE_PATH), { recursive: true });
|
|
29646
|
+
fs9.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
29462
29647
|
} catch {
|
|
29463
29648
|
}
|
|
29464
29649
|
}
|
|
29465
29650
|
};
|
|
29466
29651
|
function runCommand(cmd, timeout = 1e4) {
|
|
29467
29652
|
try {
|
|
29468
|
-
return (0,
|
|
29653
|
+
return (0, import_child_process9.execSync)(cmd, {
|
|
29469
29654
|
encoding: "utf-8",
|
|
29470
29655
|
timeout,
|
|
29471
29656
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -29497,19 +29682,19 @@ function getVersion(binary, versionCommand) {
|
|
|
29497
29682
|
function checkPathExists2(paths) {
|
|
29498
29683
|
for (const p of paths) {
|
|
29499
29684
|
if (p.includes("*")) {
|
|
29500
|
-
const home =
|
|
29501
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
29502
|
-
if (
|
|
29685
|
+
const home = os15.homedir();
|
|
29686
|
+
const resolved = p.replace(/\*/g, home.split(path12.sep).pop() || "");
|
|
29687
|
+
if (fs9.existsSync(resolved)) return resolved;
|
|
29503
29688
|
} else {
|
|
29504
|
-
if (
|
|
29689
|
+
if (fs9.existsSync(p)) return p;
|
|
29505
29690
|
}
|
|
29506
29691
|
}
|
|
29507
29692
|
return null;
|
|
29508
29693
|
}
|
|
29509
29694
|
function getMacAppVersion(appPath) {
|
|
29510
29695
|
if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
29511
|
-
const plistPath =
|
|
29512
|
-
if (!
|
|
29696
|
+
const plistPath = path12.join(appPath, "Contents", "Info.plist");
|
|
29697
|
+
if (!fs9.existsSync(plistPath)) return null;
|
|
29513
29698
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
29514
29699
|
return raw || null;
|
|
29515
29700
|
}
|
|
@@ -29535,8 +29720,8 @@ async function detectAllVersions(loader, archive) {
|
|
|
29535
29720
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
29536
29721
|
let resolvedBin = cliBin;
|
|
29537
29722
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
29538
|
-
const bundled =
|
|
29539
|
-
if (provider.cli &&
|
|
29723
|
+
const bundled = path12.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
29724
|
+
if (provider.cli && fs9.existsSync(bundled)) resolvedBin = bundled;
|
|
29540
29725
|
}
|
|
29541
29726
|
info.installed = !!(appPath || resolvedBin);
|
|
29542
29727
|
info.path = appPath || null;
|
|
@@ -30078,18 +30263,18 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
30078
30263
|
return;
|
|
30079
30264
|
}
|
|
30080
30265
|
let scriptsPath = "";
|
|
30081
|
-
const directScripts =
|
|
30082
|
-
if (
|
|
30266
|
+
const directScripts = path13.join(dir, "scripts.js");
|
|
30267
|
+
if (fs10.existsSync(directScripts)) {
|
|
30083
30268
|
scriptsPath = directScripts;
|
|
30084
30269
|
} else {
|
|
30085
|
-
const scriptsDir =
|
|
30086
|
-
if (
|
|
30087
|
-
const versions =
|
|
30088
|
-
return
|
|
30270
|
+
const scriptsDir = path13.join(dir, "scripts");
|
|
30271
|
+
if (fs10.existsSync(scriptsDir)) {
|
|
30272
|
+
const versions = fs10.readdirSync(scriptsDir).filter((d) => {
|
|
30273
|
+
return fs10.statSync(path13.join(scriptsDir, d)).isDirectory();
|
|
30089
30274
|
}).sort().reverse();
|
|
30090
30275
|
for (const ver of versions) {
|
|
30091
|
-
const p =
|
|
30092
|
-
if (
|
|
30276
|
+
const p = path13.join(scriptsDir, ver, "scripts.js");
|
|
30277
|
+
if (fs10.existsSync(p)) {
|
|
30093
30278
|
scriptsPath = p;
|
|
30094
30279
|
break;
|
|
30095
30280
|
}
|
|
@@ -30101,7 +30286,7 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
30101
30286
|
return;
|
|
30102
30287
|
}
|
|
30103
30288
|
try {
|
|
30104
|
-
const source =
|
|
30289
|
+
const source = fs10.readFileSync(scriptsPath, "utf-8");
|
|
30105
30290
|
const hints = {};
|
|
30106
30291
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
30107
30292
|
let match;
|
|
@@ -31153,45 +31338,45 @@ function resolveAutoImplReference(ctx, category, requestedReference, targetType)
|
|
|
31153
31338
|
return fallback?.type || null;
|
|
31154
31339
|
}
|
|
31155
31340
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
31156
|
-
if (!
|
|
31157
|
-
const versions =
|
|
31341
|
+
if (!fs11.existsSync(scriptsDir)) return null;
|
|
31342
|
+
const versions = fs11.readdirSync(scriptsDir).filter((d) => {
|
|
31158
31343
|
try {
|
|
31159
|
-
return
|
|
31344
|
+
return fs11.statSync(path14.join(scriptsDir, d)).isDirectory();
|
|
31160
31345
|
} catch {
|
|
31161
31346
|
return false;
|
|
31162
31347
|
}
|
|
31163
31348
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
31164
31349
|
if (versions.length === 0) return null;
|
|
31165
|
-
return
|
|
31350
|
+
return path14.join(scriptsDir, versions[0]);
|
|
31166
31351
|
}
|
|
31167
31352
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
31168
|
-
const canonicalUserDir =
|
|
31169
|
-
const desiredDir = requestedDir ?
|
|
31170
|
-
const upstreamRoot =
|
|
31171
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
31353
|
+
const canonicalUserDir = path14.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
31354
|
+
const desiredDir = requestedDir ? path14.resolve(requestedDir) : canonicalUserDir;
|
|
31355
|
+
const upstreamRoot = path14.resolve(ctx.providerLoader.getUpstreamDir());
|
|
31356
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path14.sep}`)) {
|
|
31172
31357
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
31173
31358
|
}
|
|
31174
|
-
if (
|
|
31359
|
+
if (path14.basename(desiredDir) !== type) {
|
|
31175
31360
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
31176
31361
|
}
|
|
31177
31362
|
const sourceDir = ctx.findProviderDir(type);
|
|
31178
31363
|
if (!sourceDir) {
|
|
31179
31364
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
31180
31365
|
}
|
|
31181
|
-
if (!
|
|
31182
|
-
|
|
31183
|
-
|
|
31366
|
+
if (!fs11.existsSync(desiredDir)) {
|
|
31367
|
+
fs11.mkdirSync(path14.dirname(desiredDir), { recursive: true });
|
|
31368
|
+
fs11.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
31184
31369
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
31185
31370
|
}
|
|
31186
|
-
const providerJson =
|
|
31187
|
-
if (!
|
|
31371
|
+
const providerJson = path14.join(desiredDir, "provider.json");
|
|
31372
|
+
if (!fs11.existsSync(providerJson)) {
|
|
31188
31373
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
31189
31374
|
}
|
|
31190
31375
|
try {
|
|
31191
|
-
const providerData = JSON.parse(
|
|
31376
|
+
const providerData = JSON.parse(fs11.readFileSync(providerJson, "utf-8"));
|
|
31192
31377
|
if (providerData.disableUpstream !== true) {
|
|
31193
31378
|
providerData.disableUpstream = true;
|
|
31194
|
-
|
|
31379
|
+
fs11.writeFileSync(providerJson, JSON.stringify(providerData, null, 2));
|
|
31195
31380
|
}
|
|
31196
31381
|
} catch (error48) {
|
|
31197
31382
|
return {
|
|
@@ -31204,15 +31389,15 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
31204
31389
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
31205
31390
|
if (!referenceType) return {};
|
|
31206
31391
|
const refDir = ctx.findProviderDir(referenceType);
|
|
31207
|
-
if (!refDir || !
|
|
31392
|
+
if (!refDir || !fs11.existsSync(refDir)) return {};
|
|
31208
31393
|
const referenceScripts = {};
|
|
31209
|
-
const scriptsDir =
|
|
31394
|
+
const scriptsDir = path14.join(refDir, "scripts");
|
|
31210
31395
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
31211
31396
|
if (!latestDir) return referenceScripts;
|
|
31212
|
-
for (const file2 of
|
|
31397
|
+
for (const file2 of fs11.readdirSync(latestDir)) {
|
|
31213
31398
|
if (!file2.endsWith(".js")) continue;
|
|
31214
31399
|
try {
|
|
31215
|
-
referenceScripts[file2] =
|
|
31400
|
+
referenceScripts[file2] = fs11.readFileSync(path14.join(latestDir, file2), "utf-8");
|
|
31216
31401
|
} catch {
|
|
31217
31402
|
}
|
|
31218
31403
|
}
|
|
@@ -31263,16 +31448,16 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
31263
31448
|
});
|
|
31264
31449
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
31265
31450
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference);
|
|
31266
|
-
const tmpDir =
|
|
31267
|
-
if (!
|
|
31268
|
-
const promptFile =
|
|
31269
|
-
|
|
31451
|
+
const tmpDir = path14.join(os16.tmpdir(), "adhdev-autoimpl");
|
|
31452
|
+
if (!fs11.existsSync(tmpDir)) fs11.mkdirSync(tmpDir, { recursive: true });
|
|
31453
|
+
const promptFile = path14.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
31454
|
+
fs11.writeFileSync(promptFile, prompt, "utf-8");
|
|
31270
31455
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
31271
31456
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
31272
|
-
const
|
|
31273
|
-
if (!
|
|
31457
|
+
const spawn42 = agentProvider?.spawn;
|
|
31458
|
+
if (!spawn42?.command) {
|
|
31274
31459
|
try {
|
|
31275
|
-
|
|
31460
|
+
fs11.unlinkSync(promptFile);
|
|
31276
31461
|
} catch {
|
|
31277
31462
|
}
|
|
31278
31463
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -31280,21 +31465,21 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
31280
31465
|
}
|
|
31281
31466
|
const agentCategory = agentProvider?.category;
|
|
31282
31467
|
if (agentCategory === "acp") {
|
|
31283
|
-
sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${
|
|
31468
|
+
sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${spawn42.command} ${(spawn42.args || []).join(" ")}` } });
|
|
31284
31469
|
ctx.autoImplStatus = { running: true, type, progress: [] };
|
|
31285
31470
|
const { ClientSideConnection: ClientSideConnection2, ndJsonStream: ndJsonStream2, PROTOCOL_VERSION: PROTOCOL_VERSION2 } = await Promise.resolve().then(() => (init_acp(), acp_exports));
|
|
31286
31471
|
const { Readable: Readable22, Writable: Writable2 } = await import("stream");
|
|
31287
31472
|
const { spawn: spawnFn2 } = await import("child_process");
|
|
31288
|
-
const acpArgs = [...
|
|
31473
|
+
const acpArgs = [...spawn42.args || []];
|
|
31289
31474
|
if (model) {
|
|
31290
31475
|
acpArgs.push("--model", model);
|
|
31291
31476
|
ctx.log(`Auto-implement ACP using model: ${model}`);
|
|
31292
31477
|
}
|
|
31293
|
-
const child2 = spawnFn2(
|
|
31478
|
+
const child2 = spawnFn2(spawn42.command, acpArgs, {
|
|
31294
31479
|
cwd: providerDir,
|
|
31295
31480
|
stdio: ["pipe", "pipe", "pipe"],
|
|
31296
|
-
shell:
|
|
31297
|
-
env: { ...process.env, ...
|
|
31481
|
+
shell: spawn42.shell ?? false,
|
|
31482
|
+
env: { ...process.env, ...spawn42.env || {} }
|
|
31298
31483
|
});
|
|
31299
31484
|
ctx.autoImplProcess = child2;
|
|
31300
31485
|
child2.stderr?.on("data", (d) => {
|
|
@@ -31373,7 +31558,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
31373
31558
|
} catch {
|
|
31374
31559
|
}
|
|
31375
31560
|
try {
|
|
31376
|
-
|
|
31561
|
+
fs11.unlinkSync(promptFile);
|
|
31377
31562
|
} catch {
|
|
31378
31563
|
}
|
|
31379
31564
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -31404,7 +31589,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
31404
31589
|
ctx.json(res, 202, {
|
|
31405
31590
|
started: true,
|
|
31406
31591
|
type,
|
|
31407
|
-
agent:
|
|
31592
|
+
agent: spawn42.command,
|
|
31408
31593
|
functions,
|
|
31409
31594
|
providerDir,
|
|
31410
31595
|
message: "ACP Auto-implement started. Connect to SSE for progress.",
|
|
@@ -31412,11 +31597,11 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
31412
31597
|
});
|
|
31413
31598
|
return;
|
|
31414
31599
|
}
|
|
31415
|
-
const command =
|
|
31600
|
+
const command = spawn42.command;
|
|
31416
31601
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
31417
|
-
const baseArgs = [...
|
|
31602
|
+
const baseArgs = [...spawn42.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
31418
31603
|
let shellCmd;
|
|
31419
|
-
const isWin =
|
|
31604
|
+
const isWin = os16.platform() === "win32";
|
|
31420
31605
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
31421
31606
|
if (command === "claude") {
|
|
31422
31607
|
const args = [...baseArgs, "--dangerously-skip-permissions"];
|
|
@@ -31459,13 +31644,13 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
31459
31644
|
try {
|
|
31460
31645
|
const pty3 = __require("node-pty");
|
|
31461
31646
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
31462
|
-
const isWin2 =
|
|
31647
|
+
const isWin2 = os16.platform() === "win32";
|
|
31463
31648
|
child = pty3.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
31464
31649
|
name: "xterm-256color",
|
|
31465
31650
|
cols: 120,
|
|
31466
31651
|
rows: 40,
|
|
31467
31652
|
cwd: providerDir,
|
|
31468
|
-
env: { ...process.env, ...
|
|
31653
|
+
env: { ...process.env, ...spawn42.env || {} }
|
|
31469
31654
|
});
|
|
31470
31655
|
isPty = true;
|
|
31471
31656
|
} catch (err) {
|
|
@@ -31477,7 +31662,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
31477
31662
|
stdio: ["pipe", "pipe", "pipe"],
|
|
31478
31663
|
env: {
|
|
31479
31664
|
...process.env,
|
|
31480
|
-
...
|
|
31665
|
+
...spawn42.env || {},
|
|
31481
31666
|
...command === "gemini" ? { SANDBOX: "1", GEMINI_CLI_NO_RELAUNCH: "1" } : {}
|
|
31482
31667
|
}
|
|
31483
31668
|
});
|
|
@@ -31553,7 +31738,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
31553
31738
|
} catch {
|
|
31554
31739
|
}
|
|
31555
31740
|
try {
|
|
31556
|
-
|
|
31741
|
+
fs11.unlinkSync(promptFile);
|
|
31557
31742
|
} catch {
|
|
31558
31743
|
}
|
|
31559
31744
|
});
|
|
@@ -31589,7 +31774,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
31589
31774
|
} catch {
|
|
31590
31775
|
}
|
|
31591
31776
|
try {
|
|
31592
|
-
|
|
31777
|
+
fs11.unlinkSync(promptFile);
|
|
31593
31778
|
} catch {
|
|
31594
31779
|
}
|
|
31595
31780
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -31636,7 +31821,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
31636
31821
|
setMode: "set_mode.js"
|
|
31637
31822
|
};
|
|
31638
31823
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
31639
|
-
const scriptsDir =
|
|
31824
|
+
const scriptsDir = path14.join(providerDir, "scripts");
|
|
31640
31825
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
31641
31826
|
if (latestScriptsDir) {
|
|
31642
31827
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -31644,10 +31829,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
31644
31829
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
31645
31830
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
31646
31831
|
lines.push("");
|
|
31647
|
-
for (const file2 of
|
|
31832
|
+
for (const file2 of fs11.readdirSync(latestScriptsDir)) {
|
|
31648
31833
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
31649
31834
|
try {
|
|
31650
|
-
const content =
|
|
31835
|
+
const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
31651
31836
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
31652
31837
|
lines.push("```javascript");
|
|
31653
31838
|
lines.push(content);
|
|
@@ -31657,14 +31842,14 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
31657
31842
|
}
|
|
31658
31843
|
}
|
|
31659
31844
|
}
|
|
31660
|
-
const refFiles =
|
|
31845
|
+
const refFiles = fs11.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
31661
31846
|
if (refFiles.length > 0) {
|
|
31662
31847
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
31663
31848
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
31664
31849
|
lines.push("");
|
|
31665
31850
|
for (const file2 of refFiles) {
|
|
31666
31851
|
try {
|
|
31667
|
-
const content =
|
|
31852
|
+
const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
31668
31853
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
31669
31854
|
lines.push("```javascript");
|
|
31670
31855
|
lines.push(content);
|
|
@@ -31705,11 +31890,11 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
31705
31890
|
lines.push("");
|
|
31706
31891
|
}
|
|
31707
31892
|
}
|
|
31708
|
-
const docsDir =
|
|
31893
|
+
const docsDir = path14.join(providerDir, "../../docs");
|
|
31709
31894
|
const loadGuide = (name) => {
|
|
31710
31895
|
try {
|
|
31711
|
-
const p =
|
|
31712
|
-
if (
|
|
31896
|
+
const p = path14.join(docsDir, name);
|
|
31897
|
+
if (fs11.existsSync(p)) return fs11.readFileSync(p, "utf-8");
|
|
31713
31898
|
} catch {
|
|
31714
31899
|
}
|
|
31715
31900
|
return null;
|
|
@@ -31882,7 +32067,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
31882
32067
|
parseApproval: "parse_approval.js"
|
|
31883
32068
|
};
|
|
31884
32069
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
31885
|
-
const scriptsDir =
|
|
32070
|
+
const scriptsDir = path14.join(providerDir, "scripts");
|
|
31886
32071
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
31887
32072
|
if (latestScriptsDir) {
|
|
31888
32073
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -31890,11 +32075,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
31890
32075
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
31891
32076
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
31892
32077
|
lines.push("");
|
|
31893
|
-
for (const file2 of
|
|
32078
|
+
for (const file2 of fs11.readdirSync(latestScriptsDir)) {
|
|
31894
32079
|
if (!file2.endsWith(".js")) continue;
|
|
31895
32080
|
if (!targetFileNames.has(file2)) continue;
|
|
31896
32081
|
try {
|
|
31897
|
-
const content =
|
|
32082
|
+
const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
31898
32083
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
31899
32084
|
lines.push("```javascript");
|
|
31900
32085
|
lines.push(content);
|
|
@@ -31903,14 +32088,14 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
31903
32088
|
} catch {
|
|
31904
32089
|
}
|
|
31905
32090
|
}
|
|
31906
|
-
const refFiles =
|
|
32091
|
+
const refFiles = fs11.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
31907
32092
|
if (refFiles.length > 0) {
|
|
31908
32093
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
31909
32094
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
31910
32095
|
lines.push("");
|
|
31911
32096
|
for (const file2 of refFiles) {
|
|
31912
32097
|
try {
|
|
31913
|
-
const content =
|
|
32098
|
+
const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
31914
32099
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
31915
32100
|
lines.push("```javascript");
|
|
31916
32101
|
lines.push(content);
|
|
@@ -31943,11 +32128,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
31943
32128
|
lines.push("");
|
|
31944
32129
|
}
|
|
31945
32130
|
}
|
|
31946
|
-
const docsDir =
|
|
32131
|
+
const docsDir = path14.join(providerDir, "../../docs");
|
|
31947
32132
|
const loadGuide = (name) => {
|
|
31948
32133
|
try {
|
|
31949
|
-
const p =
|
|
31950
|
-
if (
|
|
32134
|
+
const p = path14.join(docsDir, name);
|
|
32135
|
+
if (fs11.existsSync(p)) return fs11.readFileSync(p, "utf-8");
|
|
31951
32136
|
} catch {
|
|
31952
32137
|
}
|
|
31953
32138
|
return null;
|
|
@@ -32202,8 +32387,8 @@ var DevServer = class _DevServer {
|
|
|
32202
32387
|
}
|
|
32203
32388
|
getEndpointList() {
|
|
32204
32389
|
return this.routes.map((r) => {
|
|
32205
|
-
const
|
|
32206
|
-
return `${r.method.padEnd(5)} ${
|
|
32390
|
+
const path162 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
32391
|
+
return `${r.method.padEnd(5)} ${path162}`;
|
|
32207
32392
|
});
|
|
32208
32393
|
}
|
|
32209
32394
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -32304,16 +32489,16 @@ var DevServer = class _DevServer {
|
|
|
32304
32489
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
32305
32490
|
return;
|
|
32306
32491
|
}
|
|
32307
|
-
const
|
|
32308
|
-
if (!
|
|
32492
|
+
const spawn42 = provider.spawn;
|
|
32493
|
+
if (!spawn42) {
|
|
32309
32494
|
this.json(res, 400, { error: `Provider ${type} has no spawn config` });
|
|
32310
32495
|
return;
|
|
32311
32496
|
}
|
|
32312
32497
|
const { spawn: spawnFn } = await import("child_process");
|
|
32313
32498
|
const start = Date.now();
|
|
32314
32499
|
try {
|
|
32315
|
-
const child = spawnFn(
|
|
32316
|
-
shell:
|
|
32500
|
+
const child = spawnFn(spawn42.command, [...spawn42.args || []], {
|
|
32501
|
+
shell: spawn42.shell ?? false,
|
|
32317
32502
|
timeout: 5e3,
|
|
32318
32503
|
stdio: ["pipe", "pipe", "pipe"]
|
|
32319
32504
|
});
|
|
@@ -32345,7 +32530,7 @@ var DevServer = class _DevServer {
|
|
|
32345
32530
|
const elapsed = Date.now() - start;
|
|
32346
32531
|
this.json(res, 200, {
|
|
32347
32532
|
success: true,
|
|
32348
|
-
command: `${
|
|
32533
|
+
command: `${spawn42.command} ${(spawn42.args || []).join(" ")}`,
|
|
32349
32534
|
elapsed,
|
|
32350
32535
|
stdout: stdout.trim(),
|
|
32351
32536
|
stderr: stderr.trim(),
|
|
@@ -32355,7 +32540,7 @@ var DevServer = class _DevServer {
|
|
|
32355
32540
|
const elapsed = Date.now() - start;
|
|
32356
32541
|
this.json(res, 200, {
|
|
32357
32542
|
success: false,
|
|
32358
|
-
command: `${
|
|
32543
|
+
command: `${spawn42.command} ${(spawn42.args || []).join(" ")}`,
|
|
32359
32544
|
elapsed,
|
|
32360
32545
|
error: e.message
|
|
32361
32546
|
});
|
|
@@ -32485,12 +32670,12 @@ var DevServer = class _DevServer {
|
|
|
32485
32670
|
// ─── DevConsole SPA ───
|
|
32486
32671
|
getConsoleDistDir() {
|
|
32487
32672
|
const candidates = [
|
|
32488
|
-
|
|
32489
|
-
|
|
32490
|
-
|
|
32673
|
+
path15.resolve(__dirname, "../../web-devconsole/dist"),
|
|
32674
|
+
path15.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
32675
|
+
path15.join(process.cwd(), "packages/web-devconsole/dist")
|
|
32491
32676
|
];
|
|
32492
32677
|
for (const dir of candidates) {
|
|
32493
|
-
if (
|
|
32678
|
+
if (fs12.existsSync(path15.join(dir, "index.html"))) return dir;
|
|
32494
32679
|
}
|
|
32495
32680
|
return null;
|
|
32496
32681
|
}
|
|
@@ -32500,9 +32685,9 @@ var DevServer = class _DevServer {
|
|
|
32500
32685
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
32501
32686
|
return;
|
|
32502
32687
|
}
|
|
32503
|
-
const htmlPath =
|
|
32688
|
+
const htmlPath = path15.join(distDir, "index.html");
|
|
32504
32689
|
try {
|
|
32505
|
-
const html =
|
|
32690
|
+
const html = fs12.readFileSync(htmlPath, "utf-8");
|
|
32506
32691
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
32507
32692
|
res.end(html);
|
|
32508
32693
|
} catch (e) {
|
|
@@ -32525,15 +32710,15 @@ var DevServer = class _DevServer {
|
|
|
32525
32710
|
this.json(res, 404, { error: "Not found" });
|
|
32526
32711
|
return;
|
|
32527
32712
|
}
|
|
32528
|
-
const safePath =
|
|
32529
|
-
const filePath =
|
|
32713
|
+
const safePath = path15.normalize(pathname).replace(/^\.\.\//, "");
|
|
32714
|
+
const filePath = path15.join(distDir, safePath);
|
|
32530
32715
|
if (!filePath.startsWith(distDir)) {
|
|
32531
32716
|
this.json(res, 403, { error: "Forbidden" });
|
|
32532
32717
|
return;
|
|
32533
32718
|
}
|
|
32534
32719
|
try {
|
|
32535
|
-
const content =
|
|
32536
|
-
const ext =
|
|
32720
|
+
const content = fs12.readFileSync(filePath);
|
|
32721
|
+
const ext = path15.extname(filePath);
|
|
32537
32722
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
32538
32723
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
32539
32724
|
res.end(content);
|
|
@@ -32641,14 +32826,14 @@ var DevServer = class _DevServer {
|
|
|
32641
32826
|
const files = [];
|
|
32642
32827
|
const scan = (d, prefix) => {
|
|
32643
32828
|
try {
|
|
32644
|
-
for (const entry of
|
|
32829
|
+
for (const entry of fs12.readdirSync(d, { withFileTypes: true })) {
|
|
32645
32830
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
32646
32831
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
32647
32832
|
if (entry.isDirectory()) {
|
|
32648
32833
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
32649
|
-
scan(
|
|
32834
|
+
scan(path15.join(d, entry.name), rel);
|
|
32650
32835
|
} else {
|
|
32651
|
-
const stat4 =
|
|
32836
|
+
const stat4 = fs12.statSync(path15.join(d, entry.name));
|
|
32652
32837
|
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
32653
32838
|
}
|
|
32654
32839
|
}
|
|
@@ -32671,16 +32856,16 @@ var DevServer = class _DevServer {
|
|
|
32671
32856
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
32672
32857
|
return;
|
|
32673
32858
|
}
|
|
32674
|
-
const fullPath =
|
|
32859
|
+
const fullPath = path15.resolve(dir, path15.normalize(filePath));
|
|
32675
32860
|
if (!fullPath.startsWith(dir)) {
|
|
32676
32861
|
this.json(res, 403, { error: "Forbidden" });
|
|
32677
32862
|
return;
|
|
32678
32863
|
}
|
|
32679
|
-
if (!
|
|
32864
|
+
if (!fs12.existsSync(fullPath) || fs12.statSync(fullPath).isDirectory()) {
|
|
32680
32865
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
32681
32866
|
return;
|
|
32682
32867
|
}
|
|
32683
|
-
const content =
|
|
32868
|
+
const content = fs12.readFileSync(fullPath, "utf-8");
|
|
32684
32869
|
this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
|
|
32685
32870
|
}
|
|
32686
32871
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -32696,15 +32881,15 @@ var DevServer = class _DevServer {
|
|
|
32696
32881
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
32697
32882
|
return;
|
|
32698
32883
|
}
|
|
32699
|
-
const fullPath =
|
|
32884
|
+
const fullPath = path15.resolve(dir, path15.normalize(filePath));
|
|
32700
32885
|
if (!fullPath.startsWith(dir)) {
|
|
32701
32886
|
this.json(res, 403, { error: "Forbidden" });
|
|
32702
32887
|
return;
|
|
32703
32888
|
}
|
|
32704
32889
|
try {
|
|
32705
|
-
if (
|
|
32706
|
-
|
|
32707
|
-
|
|
32890
|
+
if (fs12.existsSync(fullPath)) fs12.copyFileSync(fullPath, fullPath + ".bak");
|
|
32891
|
+
fs12.mkdirSync(path15.dirname(fullPath), { recursive: true });
|
|
32892
|
+
fs12.writeFileSync(fullPath, content, "utf-8");
|
|
32708
32893
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
32709
32894
|
this.providerLoader.reload();
|
|
32710
32895
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -32720,9 +32905,9 @@ var DevServer = class _DevServer {
|
|
|
32720
32905
|
return;
|
|
32721
32906
|
}
|
|
32722
32907
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
32723
|
-
const p =
|
|
32724
|
-
if (
|
|
32725
|
-
const source =
|
|
32908
|
+
const p = path15.join(dir, name);
|
|
32909
|
+
if (fs12.existsSync(p)) {
|
|
32910
|
+
const source = fs12.readFileSync(p, "utf-8");
|
|
32726
32911
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
32727
32912
|
return;
|
|
32728
32913
|
}
|
|
@@ -32741,11 +32926,11 @@ var DevServer = class _DevServer {
|
|
|
32741
32926
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
32742
32927
|
return;
|
|
32743
32928
|
}
|
|
32744
|
-
const target =
|
|
32745
|
-
const targetPath =
|
|
32929
|
+
const target = fs12.existsSync(path15.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
32930
|
+
const targetPath = path15.join(dir, target);
|
|
32746
32931
|
try {
|
|
32747
|
-
if (
|
|
32748
|
-
|
|
32932
|
+
if (fs12.existsSync(targetPath)) fs12.copyFileSync(targetPath, targetPath + ".bak");
|
|
32933
|
+
fs12.writeFileSync(targetPath, source, "utf-8");
|
|
32749
32934
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
32750
32935
|
this.providerLoader.reload();
|
|
32751
32936
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -32824,20 +33009,20 @@ var DevServer = class _DevServer {
|
|
|
32824
33009
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
32825
33010
|
return;
|
|
32826
33011
|
}
|
|
32827
|
-
const
|
|
32828
|
-
if (!
|
|
33012
|
+
const spawn42 = provider.spawn;
|
|
33013
|
+
if (!spawn42) {
|
|
32829
33014
|
this.json(res, 400, { error: `Provider ${type} has no spawn config` });
|
|
32830
33015
|
return;
|
|
32831
33016
|
}
|
|
32832
33017
|
const { spawn: spawnFn } = await import("child_process");
|
|
32833
33018
|
const start = Date.now();
|
|
32834
33019
|
try {
|
|
32835
|
-
const args = [...
|
|
32836
|
-
const child = spawnFn(
|
|
32837
|
-
shell:
|
|
33020
|
+
const args = [...spawn42.args || [], message];
|
|
33021
|
+
const child = spawnFn(spawn42.command, args, {
|
|
33022
|
+
shell: spawn42.shell ?? false,
|
|
32838
33023
|
timeout,
|
|
32839
33024
|
stdio: ["pipe", "pipe", "pipe"],
|
|
32840
|
-
env: { ...process.env, ...
|
|
33025
|
+
env: { ...process.env, ...spawn42.env || {} }
|
|
32841
33026
|
});
|
|
32842
33027
|
let stdout = "";
|
|
32843
33028
|
let stderr = "";
|
|
@@ -32902,21 +33087,21 @@ var DevServer = class _DevServer {
|
|
|
32902
33087
|
}
|
|
32903
33088
|
let targetDir;
|
|
32904
33089
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
32905
|
-
const jsonPath =
|
|
32906
|
-
if (
|
|
33090
|
+
const jsonPath = path15.join(targetDir, "provider.json");
|
|
33091
|
+
if (fs12.existsSync(jsonPath)) {
|
|
32907
33092
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
32908
33093
|
return;
|
|
32909
33094
|
}
|
|
32910
33095
|
try {
|
|
32911
33096
|
const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
|
|
32912
|
-
|
|
32913
|
-
|
|
33097
|
+
fs12.mkdirSync(targetDir, { recursive: true });
|
|
33098
|
+
fs12.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
32914
33099
|
const createdFiles = ["provider.json"];
|
|
32915
33100
|
if (result.files) {
|
|
32916
33101
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
32917
|
-
const fullPath =
|
|
32918
|
-
|
|
32919
|
-
|
|
33102
|
+
const fullPath = path15.join(targetDir, relPath);
|
|
33103
|
+
fs12.mkdirSync(path15.dirname(fullPath), { recursive: true });
|
|
33104
|
+
fs12.writeFileSync(fullPath, content, "utf-8");
|
|
32920
33105
|
createdFiles.push(relPath);
|
|
32921
33106
|
}
|
|
32922
33107
|
}
|
|
@@ -32965,45 +33150,45 @@ var DevServer = class _DevServer {
|
|
|
32965
33150
|
}
|
|
32966
33151
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
32967
33152
|
getLatestScriptVersionDir(scriptsDir) {
|
|
32968
|
-
if (!
|
|
32969
|
-
const versions =
|
|
33153
|
+
if (!fs12.existsSync(scriptsDir)) return null;
|
|
33154
|
+
const versions = fs12.readdirSync(scriptsDir).filter((d) => {
|
|
32970
33155
|
try {
|
|
32971
|
-
return
|
|
33156
|
+
return fs12.statSync(path15.join(scriptsDir, d)).isDirectory();
|
|
32972
33157
|
} catch {
|
|
32973
33158
|
return false;
|
|
32974
33159
|
}
|
|
32975
33160
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
32976
33161
|
if (versions.length === 0) return null;
|
|
32977
|
-
return
|
|
33162
|
+
return path15.join(scriptsDir, versions[0]);
|
|
32978
33163
|
}
|
|
32979
33164
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
32980
|
-
const canonicalUserDir =
|
|
32981
|
-
const desiredDir = requestedDir ?
|
|
32982
|
-
const upstreamRoot =
|
|
32983
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
33165
|
+
const canonicalUserDir = path15.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
33166
|
+
const desiredDir = requestedDir ? path15.resolve(requestedDir) : canonicalUserDir;
|
|
33167
|
+
const upstreamRoot = path15.resolve(this.providerLoader.getUpstreamDir());
|
|
33168
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path15.sep}`)) {
|
|
32984
33169
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
32985
33170
|
}
|
|
32986
|
-
if (
|
|
33171
|
+
if (path15.basename(desiredDir) !== type) {
|
|
32987
33172
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
32988
33173
|
}
|
|
32989
33174
|
const sourceDir = this.findProviderDir(type);
|
|
32990
33175
|
if (!sourceDir) {
|
|
32991
33176
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
32992
33177
|
}
|
|
32993
|
-
if (!
|
|
32994
|
-
|
|
32995
|
-
|
|
33178
|
+
if (!fs12.existsSync(desiredDir)) {
|
|
33179
|
+
fs12.mkdirSync(path15.dirname(desiredDir), { recursive: true });
|
|
33180
|
+
fs12.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
32996
33181
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
32997
33182
|
}
|
|
32998
|
-
const providerJson =
|
|
32999
|
-
if (!
|
|
33183
|
+
const providerJson = path15.join(desiredDir, "provider.json");
|
|
33184
|
+
if (!fs12.existsSync(providerJson)) {
|
|
33000
33185
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
33001
33186
|
}
|
|
33002
33187
|
try {
|
|
33003
|
-
const providerData = JSON.parse(
|
|
33188
|
+
const providerData = JSON.parse(fs12.readFileSync(providerJson, "utf-8"));
|
|
33004
33189
|
if (providerData.disableUpstream !== true) {
|
|
33005
33190
|
providerData.disableUpstream = true;
|
|
33006
|
-
|
|
33191
|
+
fs12.writeFileSync(providerJson, JSON.stringify(providerData, null, 2));
|
|
33007
33192
|
}
|
|
33008
33193
|
} catch (error48) {
|
|
33009
33194
|
return {
|
|
@@ -33043,7 +33228,7 @@ var DevServer = class _DevServer {
|
|
|
33043
33228
|
setMode: "set_mode.js"
|
|
33044
33229
|
};
|
|
33045
33230
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
33046
|
-
const scriptsDir =
|
|
33231
|
+
const scriptsDir = path15.join(providerDir, "scripts");
|
|
33047
33232
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
33048
33233
|
if (latestScriptsDir) {
|
|
33049
33234
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -33051,10 +33236,10 @@ var DevServer = class _DevServer {
|
|
|
33051
33236
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
33052
33237
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
33053
33238
|
lines.push("");
|
|
33054
|
-
for (const file2 of
|
|
33239
|
+
for (const file2 of fs12.readdirSync(latestScriptsDir)) {
|
|
33055
33240
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
33056
33241
|
try {
|
|
33057
|
-
const content =
|
|
33242
|
+
const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
33058
33243
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
33059
33244
|
lines.push("```javascript");
|
|
33060
33245
|
lines.push(content);
|
|
@@ -33064,14 +33249,14 @@ var DevServer = class _DevServer {
|
|
|
33064
33249
|
}
|
|
33065
33250
|
}
|
|
33066
33251
|
}
|
|
33067
|
-
const refFiles =
|
|
33252
|
+
const refFiles = fs12.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
33068
33253
|
if (refFiles.length > 0) {
|
|
33069
33254
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
33070
33255
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
33071
33256
|
lines.push("");
|
|
33072
33257
|
for (const file2 of refFiles) {
|
|
33073
33258
|
try {
|
|
33074
|
-
const content =
|
|
33259
|
+
const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
33075
33260
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
33076
33261
|
lines.push("```javascript");
|
|
33077
33262
|
lines.push(content);
|
|
@@ -33112,11 +33297,11 @@ var DevServer = class _DevServer {
|
|
|
33112
33297
|
lines.push("");
|
|
33113
33298
|
}
|
|
33114
33299
|
}
|
|
33115
|
-
const docsDir =
|
|
33300
|
+
const docsDir = path15.join(providerDir, "../../docs");
|
|
33116
33301
|
const loadGuide = (name) => {
|
|
33117
33302
|
try {
|
|
33118
|
-
const p =
|
|
33119
|
-
if (
|
|
33303
|
+
const p = path15.join(docsDir, name);
|
|
33304
|
+
if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
|
|
33120
33305
|
} catch {
|
|
33121
33306
|
}
|
|
33122
33307
|
return null;
|
|
@@ -33289,7 +33474,7 @@ var DevServer = class _DevServer {
|
|
|
33289
33474
|
parseApproval: "parse_approval.js"
|
|
33290
33475
|
};
|
|
33291
33476
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
33292
|
-
const scriptsDir =
|
|
33477
|
+
const scriptsDir = path15.join(providerDir, "scripts");
|
|
33293
33478
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
33294
33479
|
if (latestScriptsDir) {
|
|
33295
33480
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -33297,11 +33482,11 @@ var DevServer = class _DevServer {
|
|
|
33297
33482
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
33298
33483
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
33299
33484
|
lines.push("");
|
|
33300
|
-
for (const file2 of
|
|
33485
|
+
for (const file2 of fs12.readdirSync(latestScriptsDir)) {
|
|
33301
33486
|
if (!file2.endsWith(".js")) continue;
|
|
33302
33487
|
if (!targetFileNames.has(file2)) continue;
|
|
33303
33488
|
try {
|
|
33304
|
-
const content =
|
|
33489
|
+
const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
33305
33490
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
33306
33491
|
lines.push("```javascript");
|
|
33307
33492
|
lines.push(content);
|
|
@@ -33310,14 +33495,14 @@ var DevServer = class _DevServer {
|
|
|
33310
33495
|
} catch {
|
|
33311
33496
|
}
|
|
33312
33497
|
}
|
|
33313
|
-
const refFiles =
|
|
33498
|
+
const refFiles = fs12.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
33314
33499
|
if (refFiles.length > 0) {
|
|
33315
33500
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
33316
33501
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
33317
33502
|
lines.push("");
|
|
33318
33503
|
for (const file2 of refFiles) {
|
|
33319
33504
|
try {
|
|
33320
|
-
const content =
|
|
33505
|
+
const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
33321
33506
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
33322
33507
|
lines.push("```javascript");
|
|
33323
33508
|
lines.push(content);
|
|
@@ -33350,11 +33535,11 @@ var DevServer = class _DevServer {
|
|
|
33350
33535
|
lines.push("");
|
|
33351
33536
|
}
|
|
33352
33537
|
}
|
|
33353
|
-
const docsDir =
|
|
33538
|
+
const docsDir = path15.join(providerDir, "../../docs");
|
|
33354
33539
|
const loadGuide = (name) => {
|
|
33355
33540
|
try {
|
|
33356
|
-
const p =
|
|
33357
|
-
if (
|
|
33541
|
+
const p = path15.join(docsDir, name);
|
|
33542
|
+
if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
|
|
33358
33543
|
} catch {
|
|
33359
33544
|
}
|
|
33360
33545
|
return null;
|
|
@@ -34208,8 +34393,8 @@ async function shutdownDaemonComponents(components) {
|
|
|
34208
34393
|
}
|
|
34209
34394
|
|
|
34210
34395
|
// src/session-host.ts
|
|
34211
|
-
var
|
|
34212
|
-
var
|
|
34396
|
+
var import_child_process10 = require("child_process");
|
|
34397
|
+
var path16 = __toESM(require("path"));
|
|
34213
34398
|
var SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
|
|
34214
34399
|
function buildSessionHostEnv(baseEnv) {
|
|
34215
34400
|
const env = {};
|
|
@@ -34227,8 +34412,8 @@ function buildSessionHostEnv(baseEnv) {
|
|
|
34227
34412
|
}
|
|
34228
34413
|
function resolveSessionHostEntry() {
|
|
34229
34414
|
const localCandidates = [
|
|
34230
|
-
|
|
34231
|
-
|
|
34415
|
+
path16.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
34416
|
+
path16.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
34232
34417
|
];
|
|
34233
34418
|
for (const candidate of localCandidates) {
|
|
34234
34419
|
if (require("fs").existsSync(candidate)) {
|
|
@@ -34239,7 +34424,7 @@ function resolveSessionHostEntry() {
|
|
|
34239
34424
|
}
|
|
34240
34425
|
async function runSessionHostCli(args) {
|
|
34241
34426
|
const entry = resolveSessionHostEntry();
|
|
34242
|
-
const child = (0,
|
|
34427
|
+
const child = (0, import_child_process10.spawn)(process.execPath, [entry, ...args], {
|
|
34243
34428
|
stdio: "inherit",
|
|
34244
34429
|
env: buildSessionHostEnv(process.env)
|
|
34245
34430
|
});
|
|
@@ -34253,7 +34438,7 @@ async function ensureSessionHostReady2() {
|
|
|
34253
34438
|
appName: SESSION_HOST_APP_NAME,
|
|
34254
34439
|
spawnHost: () => {
|
|
34255
34440
|
const entry = resolveSessionHostEntry();
|
|
34256
|
-
const child = (0,
|
|
34441
|
+
const child = (0, import_child_process10.spawn)(process.execPath, [entry], {
|
|
34257
34442
|
detached: true,
|
|
34258
34443
|
stdio: "ignore",
|
|
34259
34444
|
windowsHide: true,
|
|
@@ -34442,12 +34627,12 @@ var pkgVersion = process.env.ADHDEV_PKG_VERSION || "unknown";
|
|
|
34442
34627
|
if (pkgVersion === "unknown") {
|
|
34443
34628
|
try {
|
|
34444
34629
|
const possiblePaths = [
|
|
34445
|
-
|
|
34446
|
-
|
|
34630
|
+
path18.join(__dirname, "..", "package.json"),
|
|
34631
|
+
path18.join(__dirname, "package.json")
|
|
34447
34632
|
];
|
|
34448
34633
|
for (const candidate of possiblePaths) {
|
|
34449
34634
|
try {
|
|
34450
|
-
const data = JSON.parse(
|
|
34635
|
+
const data = JSON.parse(fs13.readFileSync(candidate, "utf-8"));
|
|
34451
34636
|
if (data.version) {
|
|
34452
34637
|
pkgVersion = data.version;
|
|
34453
34638
|
break;
|
|
@@ -34510,6 +34695,10 @@ var StandaloneServer = class {
|
|
|
34510
34695
|
isTerminalCliSession(sessionId) {
|
|
34511
34696
|
return this.getCliPresentationMode(sessionId) === "terminal";
|
|
34512
34697
|
}
|
|
34698
|
+
isCliSession(sessionId) {
|
|
34699
|
+
const mode = this.getCliPresentationMode(sessionId);
|
|
34700
|
+
return mode === "chat" || mode === "terminal";
|
|
34701
|
+
}
|
|
34513
34702
|
async start(options = {}) {
|
|
34514
34703
|
const port = options.port || DEFAULT_PORT;
|
|
34515
34704
|
const host = options.host || "127.0.0.1";
|
|
@@ -34521,7 +34710,7 @@ var StandaloneServer = class {
|
|
|
34521
34710
|
getServerConn: () => null,
|
|
34522
34711
|
getP2p: () => ({
|
|
34523
34712
|
broadcastPtyOutput: (key, data) => {
|
|
34524
|
-
if (this.clients.size === 0 || !this.
|
|
34713
|
+
if (this.clients.size === 0 || !this.isCliSession(key)) return;
|
|
34525
34714
|
const msg = JSON.stringify({ type: "pty_output", sessionId: key, data });
|
|
34526
34715
|
for (const client of this.clients) {
|
|
34527
34716
|
if (client.readyState === 1) {
|
|
@@ -34736,9 +34925,9 @@ var StandaloneServer = class {
|
|
|
34736
34925
|
return;
|
|
34737
34926
|
}
|
|
34738
34927
|
if (action === "snapshot" && method === "GET") {
|
|
34739
|
-
if (!this.
|
|
34928
|
+
if (!this.isCliSession(sessionId)) {
|
|
34740
34929
|
res.writeHead(409, { "Content-Type": "application/json" });
|
|
34741
|
-
res.end(JSON.stringify({ error: "CLI session
|
|
34930
|
+
res.end(JSON.stringify({ error: "CLI session runtime unavailable", code: "CLI_RUNTIME_UNAVAILABLE" }));
|
|
34742
34931
|
return;
|
|
34743
34932
|
}
|
|
34744
34933
|
void (async () => {
|
|
@@ -34790,9 +34979,9 @@ var StandaloneServer = class {
|
|
|
34790
34979
|
}
|
|
34791
34980
|
if (publicDir) {
|
|
34792
34981
|
const filePath = url2 === "/" ? "/index.html" : url2;
|
|
34793
|
-
const fullPath =
|
|
34794
|
-
if (
|
|
34795
|
-
const ext =
|
|
34982
|
+
const fullPath = path18.join(publicDir, filePath);
|
|
34983
|
+
if (fs13.existsSync(fullPath) && fs13.statSync(fullPath).isFile()) {
|
|
34984
|
+
const ext = path18.extname(fullPath);
|
|
34796
34985
|
const mimeTypes = {
|
|
34797
34986
|
".html": "text/html",
|
|
34798
34987
|
".js": "application/javascript",
|
|
@@ -34804,13 +34993,13 @@ var StandaloneServer = class {
|
|
|
34804
34993
|
".woff2": "font/woff2"
|
|
34805
34994
|
};
|
|
34806
34995
|
res.writeHead(200, { "Content-Type": mimeTypes[ext] || "application/octet-stream" });
|
|
34807
|
-
|
|
34996
|
+
fs13.createReadStream(fullPath).pipe(res);
|
|
34808
34997
|
return;
|
|
34809
34998
|
}
|
|
34810
|
-
const indexPath =
|
|
34811
|
-
if (
|
|
34999
|
+
const indexPath = path18.join(publicDir, "index.html");
|
|
35000
|
+
if (fs13.existsSync(indexPath) && !url2.startsWith("/api/")) {
|
|
34812
35001
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
34813
|
-
|
|
35002
|
+
fs13.createReadStream(indexPath).pipe(res);
|
|
34814
35003
|
return;
|
|
34815
35004
|
}
|
|
34816
35005
|
}
|
|
@@ -34862,9 +35051,9 @@ var StandaloneServer = class {
|
|
|
34862
35051
|
req.on("aborted", cleanup);
|
|
34863
35052
|
}
|
|
34864
35053
|
async handleRuntimeEvents(req, res, sessionId) {
|
|
34865
|
-
if (!this.
|
|
35054
|
+
if (!this.isCliSession(sessionId)) {
|
|
34866
35055
|
res.writeHead(409, { "Content-Type": "application/json" });
|
|
34867
|
-
res.end(JSON.stringify({ error: "CLI session
|
|
35056
|
+
res.end(JSON.stringify({ error: "CLI session runtime unavailable", code: "CLI_RUNTIME_UNAVAILABLE" }));
|
|
34868
35057
|
return;
|
|
34869
35058
|
}
|
|
34870
35059
|
const client = await this.createSessionHostClient();
|
|
@@ -34886,7 +35075,7 @@ var StandaloneServer = class {
|
|
|
34886
35075
|
}
|
|
34887
35076
|
const writeEvent = (event) => {
|
|
34888
35077
|
if (event.sessionId !== sessionId) return;
|
|
34889
|
-
if (!this.
|
|
35078
|
+
if (!this.isCliSession(sessionId)) return;
|
|
34890
35079
|
res.write(`event: ${event.type}
|
|
34891
35080
|
`);
|
|
34892
35081
|
res.write(`data: ${JSON.stringify(event)}
|
|
@@ -34974,7 +35163,7 @@ var StandaloneServer = class {
|
|
|
34974
35163
|
const states = this.components.instanceManager.collectAllStates();
|
|
34975
35164
|
for (const state of states) {
|
|
34976
35165
|
const sessionId = typeof state?.instanceId === "string" ? state.instanceId : "";
|
|
34977
|
-
if (!sessionId || state?.category !== "cli"
|
|
35166
|
+
if (!sessionId || state?.category !== "cli") continue;
|
|
34978
35167
|
const snapshot = await client.request({
|
|
34979
35168
|
type: "get_snapshot",
|
|
34980
35169
|
payload: { sessionId }
|
|
@@ -35051,7 +35240,7 @@ var StandaloneServer = class {
|
|
|
35051
35240
|
}
|
|
35052
35241
|
// ─── Network ───
|
|
35053
35242
|
getLanIPs() {
|
|
35054
|
-
const interfaces =
|
|
35243
|
+
const interfaces = os18.networkInterfaces();
|
|
35055
35244
|
const ips = [];
|
|
35056
35245
|
for (const iface of Object.values(interfaces)) {
|
|
35057
35246
|
if (!iface) continue;
|
|
@@ -35095,6 +35284,10 @@ var StandaloneServer = class {
|
|
|
35095
35284
|
}
|
|
35096
35285
|
};
|
|
35097
35286
|
async function main() {
|
|
35287
|
+
const helperMode = await maybeRunDaemonUpgradeHelperFromEnv();
|
|
35288
|
+
if (helperMode) {
|
|
35289
|
+
return;
|
|
35290
|
+
}
|
|
35098
35291
|
const args = process.argv.slice(2);
|
|
35099
35292
|
const primaryCommand = args[0] || "";
|
|
35100
35293
|
if (primaryCommand === "attach") {
|
|
@@ -35161,12 +35354,12 @@ Runtime commands:
|
|
|
35161
35354
|
}
|
|
35162
35355
|
if (!options.publicDir) {
|
|
35163
35356
|
const candidates = [
|
|
35164
|
-
|
|
35165
|
-
|
|
35166
|
-
|
|
35357
|
+
path18.join(__dirname, "../../web-standalone/dist"),
|
|
35358
|
+
path18.join(__dirname, "../public"),
|
|
35359
|
+
path18.join(process.cwd(), "public")
|
|
35167
35360
|
];
|
|
35168
35361
|
for (const candidate of candidates) {
|
|
35169
|
-
if (
|
|
35362
|
+
if (fs13.existsSync(path18.join(candidate, "index.html"))) {
|
|
35170
35363
|
options.publicDir = candidate;
|
|
35171
35364
|
break;
|
|
35172
35365
|
}
|