adhdev 0.7.42 → 0.7.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +788 -630
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +158 -175
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/vendor/session-host-daemon/index.d.mts +1 -0
- package/vendor/session-host-daemon/index.d.ts +1 -0
- package/vendor/session-host-daemon/index.js +82 -12
- package/vendor/session-host-daemon/index.js.map +1 -1
- package/vendor/session-host-daemon/index.mjs +82 -12
- package/vendor/session-host-daemon/index.mjs.map +1 -1
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.js +2 -2
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.js.map +1 -1
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.mjs +2 -2
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.mjs.map +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -508,18 +508,18 @@ function checkPathExists(paths) {
|
|
|
508
508
|
return null;
|
|
509
509
|
}
|
|
510
510
|
async function detectIDEs() {
|
|
511
|
-
const
|
|
511
|
+
const os22 = (0, import_os2.platform)();
|
|
512
512
|
const results = [];
|
|
513
513
|
for (const def of getMergedDefinitions()) {
|
|
514
514
|
const cliPath = findCliCommand(def.cli);
|
|
515
|
-
const appPath = checkPathExists(def.paths[
|
|
515
|
+
const appPath = checkPathExists(def.paths[os22] || []);
|
|
516
516
|
const installed = !!(cliPath || appPath);
|
|
517
517
|
let resolvedCli = cliPath;
|
|
518
|
-
if (!resolvedCli && appPath &&
|
|
518
|
+
if (!resolvedCli && appPath && os22 === "darwin") {
|
|
519
519
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
520
520
|
if ((0, import_fs2.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
521
521
|
}
|
|
522
|
-
if (!resolvedCli && appPath &&
|
|
522
|
+
if (!resolvedCli && appPath && os22 === "win32") {
|
|
523
523
|
const { dirname: dirname10 } = await import("path");
|
|
524
524
|
const appDir = dirname10(appPath);
|
|
525
525
|
const candidates = [
|
|
@@ -2539,8 +2539,6 @@ var init_chat_history = __esm({
|
|
|
2539
2539
|
lastSeenCounts = /* @__PURE__ */ new Map();
|
|
2540
2540
|
/** Last seen message hash per agent (deduplication) */
|
|
2541
2541
|
lastSeenHashes = /* @__PURE__ */ new Map();
|
|
2542
|
-
/** Last seen append-only terminal transcript per agent */
|
|
2543
|
-
lastSeenTerminal = /* @__PURE__ */ new Map();
|
|
2544
2542
|
rotated = false;
|
|
2545
2543
|
/**
|
|
2546
2544
|
* Append new messages to history
|
|
@@ -2598,51 +2596,10 @@ var init_chat_history = __esm({
|
|
|
2598
2596
|
} catch {
|
|
2599
2597
|
}
|
|
2600
2598
|
}
|
|
2601
|
-
appendTerminalHistory(agentType, terminalHistory, sessionTitle, instanceId) {
|
|
2602
|
-
const next = String(terminalHistory || "");
|
|
2603
|
-
if (!next.trim()) return;
|
|
2604
|
-
try {
|
|
2605
|
-
const dedupKey = instanceId ? `${agentType}:${instanceId}:terminal` : `${agentType}:terminal`;
|
|
2606
|
-
const prev = this.lastSeenTerminal.get(dedupKey) || "";
|
|
2607
|
-
if (prev === next) return;
|
|
2608
|
-
let delta = "";
|
|
2609
|
-
if (!prev) {
|
|
2610
|
-
delta = next;
|
|
2611
|
-
} else if (next.startsWith(prev)) {
|
|
2612
|
-
delta = next.slice(prev.length);
|
|
2613
|
-
} else if (prev.includes(next)) {
|
|
2614
|
-
this.lastSeenTerminal.set(dedupKey, next);
|
|
2615
|
-
return;
|
|
2616
|
-
} else {
|
|
2617
|
-
delta = `
|
|
2618
|
-
|
|
2619
|
-
[terminal snapshot reset ${(/* @__PURE__ */ new Date()).toISOString()} | ${sessionTitle || agentType}]
|
|
2620
|
-
${next}`;
|
|
2621
|
-
}
|
|
2622
|
-
if (!delta) {
|
|
2623
|
-
this.lastSeenTerminal.set(dedupKey, next);
|
|
2624
|
-
return;
|
|
2625
|
-
}
|
|
2626
|
-
const dir = path4.join(HISTORY_DIR, this.sanitize(agentType));
|
|
2627
|
-
fs3.mkdirSync(dir, { recursive: true });
|
|
2628
|
-
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
2629
|
-
const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
|
|
2630
|
-
const filePath = path4.join(dir, `${filePrefix}${date5}.terminal.log`);
|
|
2631
|
-
fs3.appendFileSync(filePath, delta, "utf-8");
|
|
2632
|
-
this.lastSeenTerminal.set(dedupKey, next);
|
|
2633
|
-
if (!this.rotated) {
|
|
2634
|
-
this.rotated = true;
|
|
2635
|
-
this.rotateOldFiles().catch(() => {
|
|
2636
|
-
});
|
|
2637
|
-
}
|
|
2638
|
-
} catch {
|
|
2639
|
-
}
|
|
2640
|
-
}
|
|
2641
2599
|
/** Called when agent session is explicitly changed */
|
|
2642
2600
|
onSessionChange(agentType) {
|
|
2643
2601
|
this.lastSeenHashes.delete(agentType);
|
|
2644
2602
|
this.lastSeenCounts.delete(agentType);
|
|
2645
|
-
this.lastSeenTerminal.delete(`${agentType}:terminal`);
|
|
2646
2603
|
}
|
|
2647
2604
|
/** Delete history files older than 30 days */
|
|
2648
2605
|
async rotateOldFiles() {
|
|
@@ -3488,11 +3445,6 @@ function truncateString(value, maxChars) {
|
|
|
3488
3445
|
if (maxChars <= 12) return value.slice(0, Math.max(0, maxChars));
|
|
3489
3446
|
return `${value.slice(0, maxChars - 12)}...[truncated]`;
|
|
3490
3447
|
}
|
|
3491
|
-
function truncateStringTail(value, maxChars) {
|
|
3492
|
-
if (value.length <= maxChars) return value;
|
|
3493
|
-
if (maxChars <= 12) return value.slice(value.length - Math.max(0, maxChars));
|
|
3494
|
-
return `...[truncated]${value.slice(value.length - (maxChars - 12))}`;
|
|
3495
|
-
}
|
|
3496
3448
|
function trimStructuredStrings(value, maxChars) {
|
|
3497
3449
|
if (typeof value === "string") return truncateString(value, maxChars);
|
|
3498
3450
|
if (Array.isArray(value)) return value.map((item) => trimStructuredStrings(item, maxChars));
|
|
@@ -3566,11 +3518,10 @@ function normalizeActiveChatData(activeChat) {
|
|
|
3566
3518
|
(button) => truncateString(String(button || ""), STATUS_MODAL_BUTTON_LIMIT)
|
|
3567
3519
|
)
|
|
3568
3520
|
} : activeChat.activeModal,
|
|
3569
|
-
terminalHistory: activeChat.terminalHistory ? truncateStringTail(activeChat.terminalHistory, STATUS_TERMINAL_HISTORY_LIMIT) : activeChat.terminalHistory,
|
|
3570
3521
|
inputContent: activeChat.inputContent ? truncateString(activeChat.inputContent, STATUS_INPUT_CONTENT_LIMIT) : activeChat.inputContent
|
|
3571
3522
|
};
|
|
3572
3523
|
}
|
|
3573
|
-
var WORKING_STATUSES, STATUS_ACTIVE_CHAT_MESSAGE_LIMIT, STATUS_ACTIVE_CHAT_TOTAL_BYTES_LIMIT, STATUS_ACTIVE_CHAT_STRING_LIMIT, STATUS_ACTIVE_CHAT_FALLBACK_STRING_LIMIT,
|
|
3524
|
+
var WORKING_STATUSES, STATUS_ACTIVE_CHAT_MESSAGE_LIMIT, STATUS_ACTIVE_CHAT_TOTAL_BYTES_LIMIT, STATUS_ACTIVE_CHAT_STRING_LIMIT, STATUS_ACTIVE_CHAT_FALLBACK_STRING_LIMIT, STATUS_INPUT_CONTENT_LIMIT, STATUS_MODAL_MESSAGE_LIMIT, STATUS_MODAL_BUTTON_LIMIT;
|
|
3574
3525
|
var init_normalize = __esm({
|
|
3575
3526
|
"../../oss/packages/daemon-core/src/status/normalize.ts"() {
|
|
3576
3527
|
"use strict";
|
|
@@ -3586,7 +3537,6 @@ var init_normalize = __esm({
|
|
|
3586
3537
|
STATUS_ACTIVE_CHAT_TOTAL_BYTES_LIMIT = 96 * 1024;
|
|
3587
3538
|
STATUS_ACTIVE_CHAT_STRING_LIMIT = 4 * 1024;
|
|
3588
3539
|
STATUS_ACTIVE_CHAT_FALLBACK_STRING_LIMIT = 1024;
|
|
3589
|
-
STATUS_TERMINAL_HISTORY_LIMIT = 8 * 1024;
|
|
3590
3540
|
STATUS_INPUT_CONTENT_LIMIT = 2 * 1024;
|
|
3591
3541
|
STATUS_MODAL_MESSAGE_LIMIT = 2 * 1024;
|
|
3592
3542
|
STATUS_MODAL_BUTTON_LIMIT = 120;
|
|
@@ -5860,7 +5810,7 @@ var init_readdirp = __esm({
|
|
|
5860
5810
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
5861
5811
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
5862
5812
|
if (wantBigintFsStats) {
|
|
5863
|
-
this._stat = (
|
|
5813
|
+
this._stat = (path19) => statMethod(path19, { bigint: true });
|
|
5864
5814
|
} else {
|
|
5865
5815
|
this._stat = statMethod;
|
|
5866
5816
|
}
|
|
@@ -5885,8 +5835,8 @@ var init_readdirp = __esm({
|
|
|
5885
5835
|
const par = this.parent;
|
|
5886
5836
|
const fil = par && par.files;
|
|
5887
5837
|
if (fil && fil.length > 0) {
|
|
5888
|
-
const { path:
|
|
5889
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
5838
|
+
const { path: path19, depth } = par;
|
|
5839
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path19));
|
|
5890
5840
|
const awaited = await Promise.all(slice);
|
|
5891
5841
|
for (const entry of awaited) {
|
|
5892
5842
|
if (!entry)
|
|
@@ -5926,20 +5876,20 @@ var init_readdirp = __esm({
|
|
|
5926
5876
|
this.reading = false;
|
|
5927
5877
|
}
|
|
5928
5878
|
}
|
|
5929
|
-
async _exploreDir(
|
|
5879
|
+
async _exploreDir(path19, depth) {
|
|
5930
5880
|
let files;
|
|
5931
5881
|
try {
|
|
5932
|
-
files = await (0, import_promises.readdir)(
|
|
5882
|
+
files = await (0, import_promises.readdir)(path19, this._rdOptions);
|
|
5933
5883
|
} catch (error48) {
|
|
5934
5884
|
this._onError(error48);
|
|
5935
5885
|
}
|
|
5936
|
-
return { files, depth, path:
|
|
5886
|
+
return { files, depth, path: path19 };
|
|
5937
5887
|
}
|
|
5938
|
-
async _formatEntry(dirent,
|
|
5888
|
+
async _formatEntry(dirent, path19) {
|
|
5939
5889
|
let entry;
|
|
5940
5890
|
const basename7 = this._isDirent ? dirent.name : dirent;
|
|
5941
5891
|
try {
|
|
5942
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
5892
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path19, basename7));
|
|
5943
5893
|
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename7 };
|
|
5944
5894
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
5945
5895
|
} catch (err) {
|
|
@@ -5996,16 +5946,16 @@ var init_readdirp = __esm({
|
|
|
5996
5946
|
});
|
|
5997
5947
|
|
|
5998
5948
|
// ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
|
|
5999
|
-
function createFsWatchInstance(
|
|
5949
|
+
function createFsWatchInstance(path19, options, listener, errHandler, emitRaw) {
|
|
6000
5950
|
const handleEvent = (rawEvent, evPath) => {
|
|
6001
|
-
listener(
|
|
6002
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
6003
|
-
if (evPath &&
|
|
6004
|
-
fsWatchBroadcast(sp.resolve(
|
|
5951
|
+
listener(path19);
|
|
5952
|
+
emitRaw(rawEvent, evPath, { watchedPath: path19 });
|
|
5953
|
+
if (evPath && path19 !== evPath) {
|
|
5954
|
+
fsWatchBroadcast(sp.resolve(path19, evPath), KEY_LISTENERS, sp.join(path19, evPath));
|
|
6005
5955
|
}
|
|
6006
5956
|
};
|
|
6007
5957
|
try {
|
|
6008
|
-
return (0, import_node_fs.watch)(
|
|
5958
|
+
return (0, import_node_fs.watch)(path19, {
|
|
6009
5959
|
persistent: options.persistent
|
|
6010
5960
|
}, handleEvent);
|
|
6011
5961
|
} catch (error48) {
|
|
@@ -6354,12 +6304,12 @@ var init_handler2 = __esm({
|
|
|
6354
6304
|
listener(val1, val2, val3);
|
|
6355
6305
|
});
|
|
6356
6306
|
};
|
|
6357
|
-
setFsWatchListener = (
|
|
6307
|
+
setFsWatchListener = (path19, fullPath, options, handlers) => {
|
|
6358
6308
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
6359
6309
|
let cont = FsWatchInstances.get(fullPath);
|
|
6360
6310
|
let watcher;
|
|
6361
6311
|
if (!options.persistent) {
|
|
6362
|
-
watcher = createFsWatchInstance(
|
|
6312
|
+
watcher = createFsWatchInstance(path19, options, listener, errHandler, rawEmitter);
|
|
6363
6313
|
if (!watcher)
|
|
6364
6314
|
return;
|
|
6365
6315
|
return watcher.close.bind(watcher);
|
|
@@ -6370,7 +6320,7 @@ var init_handler2 = __esm({
|
|
|
6370
6320
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
6371
6321
|
} else {
|
|
6372
6322
|
watcher = createFsWatchInstance(
|
|
6373
|
-
|
|
6323
|
+
path19,
|
|
6374
6324
|
options,
|
|
6375
6325
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
6376
6326
|
errHandler,
|
|
@@ -6385,7 +6335,7 @@ var init_handler2 = __esm({
|
|
|
6385
6335
|
cont.watcherUnusable = true;
|
|
6386
6336
|
if (isWindows && error48.code === "EPERM") {
|
|
6387
6337
|
try {
|
|
6388
|
-
const fd = await (0, import_promises2.open)(
|
|
6338
|
+
const fd = await (0, import_promises2.open)(path19, "r");
|
|
6389
6339
|
await fd.close();
|
|
6390
6340
|
broadcastErr(error48);
|
|
6391
6341
|
} catch (err) {
|
|
@@ -6416,7 +6366,7 @@ var init_handler2 = __esm({
|
|
|
6416
6366
|
};
|
|
6417
6367
|
};
|
|
6418
6368
|
FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
6419
|
-
setFsWatchFileListener = (
|
|
6369
|
+
setFsWatchFileListener = (path19, fullPath, options, handlers) => {
|
|
6420
6370
|
const { listener, rawEmitter } = handlers;
|
|
6421
6371
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
6422
6372
|
const copts = cont && cont.options;
|
|
@@ -6438,7 +6388,7 @@ var init_handler2 = __esm({
|
|
|
6438
6388
|
});
|
|
6439
6389
|
const currmtime = curr.mtimeMs;
|
|
6440
6390
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
6441
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
6391
|
+
foreach(cont.listeners, (listener2) => listener2(path19, curr));
|
|
6442
6392
|
}
|
|
6443
6393
|
})
|
|
6444
6394
|
};
|
|
@@ -6468,13 +6418,13 @@ var init_handler2 = __esm({
|
|
|
6468
6418
|
* @param listener on fs change
|
|
6469
6419
|
* @returns closer for the watcher instance
|
|
6470
6420
|
*/
|
|
6471
|
-
_watchWithNodeFs(
|
|
6421
|
+
_watchWithNodeFs(path19, listener) {
|
|
6472
6422
|
const opts = this.fsw.options;
|
|
6473
|
-
const directory = sp.dirname(
|
|
6474
|
-
const basename7 = sp.basename(
|
|
6423
|
+
const directory = sp.dirname(path19);
|
|
6424
|
+
const basename7 = sp.basename(path19);
|
|
6475
6425
|
const parent = this.fsw._getWatchedDir(directory);
|
|
6476
6426
|
parent.add(basename7);
|
|
6477
|
-
const absolutePath = sp.resolve(
|
|
6427
|
+
const absolutePath = sp.resolve(path19);
|
|
6478
6428
|
const options = {
|
|
6479
6429
|
persistent: opts.persistent
|
|
6480
6430
|
};
|
|
@@ -6484,12 +6434,12 @@ var init_handler2 = __esm({
|
|
|
6484
6434
|
if (opts.usePolling) {
|
|
6485
6435
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
6486
6436
|
options.interval = enableBin && isBinaryPath(basename7) ? opts.binaryInterval : opts.interval;
|
|
6487
|
-
closer = setFsWatchFileListener(
|
|
6437
|
+
closer = setFsWatchFileListener(path19, absolutePath, options, {
|
|
6488
6438
|
listener,
|
|
6489
6439
|
rawEmitter: this.fsw._emitRaw
|
|
6490
6440
|
});
|
|
6491
6441
|
} else {
|
|
6492
|
-
closer = setFsWatchListener(
|
|
6442
|
+
closer = setFsWatchListener(path19, absolutePath, options, {
|
|
6493
6443
|
listener,
|
|
6494
6444
|
errHandler: this._boundHandleError,
|
|
6495
6445
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -6511,7 +6461,7 @@ var init_handler2 = __esm({
|
|
|
6511
6461
|
let prevStats = stats;
|
|
6512
6462
|
if (parent.has(basename7))
|
|
6513
6463
|
return;
|
|
6514
|
-
const listener = async (
|
|
6464
|
+
const listener = async (path19, newStats) => {
|
|
6515
6465
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
6516
6466
|
return;
|
|
6517
6467
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -6525,11 +6475,11 @@ var init_handler2 = __esm({
|
|
|
6525
6475
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
6526
6476
|
}
|
|
6527
6477
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
6528
|
-
this.fsw._closeFile(
|
|
6478
|
+
this.fsw._closeFile(path19);
|
|
6529
6479
|
prevStats = newStats2;
|
|
6530
6480
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
6531
6481
|
if (closer2)
|
|
6532
|
-
this.fsw._addPathCloser(
|
|
6482
|
+
this.fsw._addPathCloser(path19, closer2);
|
|
6533
6483
|
} else {
|
|
6534
6484
|
prevStats = newStats2;
|
|
6535
6485
|
}
|
|
@@ -6561,7 +6511,7 @@ var init_handler2 = __esm({
|
|
|
6561
6511
|
* @param item basename of this item
|
|
6562
6512
|
* @returns true if no more processing is needed for this entry.
|
|
6563
6513
|
*/
|
|
6564
|
-
async _handleSymlink(entry, directory,
|
|
6514
|
+
async _handleSymlink(entry, directory, path19, item) {
|
|
6565
6515
|
if (this.fsw.closed) {
|
|
6566
6516
|
return;
|
|
6567
6517
|
}
|
|
@@ -6571,7 +6521,7 @@ var init_handler2 = __esm({
|
|
|
6571
6521
|
this.fsw._incrReadyCount();
|
|
6572
6522
|
let linkPath;
|
|
6573
6523
|
try {
|
|
6574
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
6524
|
+
linkPath = await (0, import_promises2.realpath)(path19);
|
|
6575
6525
|
} catch (e) {
|
|
6576
6526
|
this.fsw._emitReady();
|
|
6577
6527
|
return true;
|
|
@@ -6581,12 +6531,12 @@ var init_handler2 = __esm({
|
|
|
6581
6531
|
if (dir.has(item)) {
|
|
6582
6532
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
6583
6533
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
6584
|
-
this.fsw._emit(EV.CHANGE,
|
|
6534
|
+
this.fsw._emit(EV.CHANGE, path19, entry.stats);
|
|
6585
6535
|
}
|
|
6586
6536
|
} else {
|
|
6587
6537
|
dir.add(item);
|
|
6588
6538
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
6589
|
-
this.fsw._emit(EV.ADD,
|
|
6539
|
+
this.fsw._emit(EV.ADD, path19, entry.stats);
|
|
6590
6540
|
}
|
|
6591
6541
|
this.fsw._emitReady();
|
|
6592
6542
|
return true;
|
|
@@ -6616,9 +6566,9 @@ var init_handler2 = __esm({
|
|
|
6616
6566
|
return;
|
|
6617
6567
|
}
|
|
6618
6568
|
const item = entry.path;
|
|
6619
|
-
let
|
|
6569
|
+
let path19 = sp.join(directory, item);
|
|
6620
6570
|
current.add(item);
|
|
6621
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
6571
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path19, item)) {
|
|
6622
6572
|
return;
|
|
6623
6573
|
}
|
|
6624
6574
|
if (this.fsw.closed) {
|
|
@@ -6627,8 +6577,8 @@ var init_handler2 = __esm({
|
|
|
6627
6577
|
}
|
|
6628
6578
|
if (item === target || !target && !previous.has(item)) {
|
|
6629
6579
|
this.fsw._incrReadyCount();
|
|
6630
|
-
|
|
6631
|
-
this._addToNodeFs(
|
|
6580
|
+
path19 = sp.join(dir, sp.relative(dir, path19));
|
|
6581
|
+
this._addToNodeFs(path19, initialAdd, wh, depth + 1);
|
|
6632
6582
|
}
|
|
6633
6583
|
}).on(EV.ERROR, this._boundHandleError);
|
|
6634
6584
|
return new Promise((resolve12, reject) => {
|
|
@@ -6697,13 +6647,13 @@ var init_handler2 = __esm({
|
|
|
6697
6647
|
* @param depth Child path actually targeted for watch
|
|
6698
6648
|
* @param target Child path actually targeted for watch
|
|
6699
6649
|
*/
|
|
6700
|
-
async _addToNodeFs(
|
|
6650
|
+
async _addToNodeFs(path19, initialAdd, priorWh, depth, target) {
|
|
6701
6651
|
const ready = this.fsw._emitReady;
|
|
6702
|
-
if (this.fsw._isIgnored(
|
|
6652
|
+
if (this.fsw._isIgnored(path19) || this.fsw.closed) {
|
|
6703
6653
|
ready();
|
|
6704
6654
|
return false;
|
|
6705
6655
|
}
|
|
6706
|
-
const wh = this.fsw._getWatchHelpers(
|
|
6656
|
+
const wh = this.fsw._getWatchHelpers(path19);
|
|
6707
6657
|
if (priorWh) {
|
|
6708
6658
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
6709
6659
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -6719,8 +6669,8 @@ var init_handler2 = __esm({
|
|
|
6719
6669
|
const follow = this.fsw.options.followSymlinks;
|
|
6720
6670
|
let closer;
|
|
6721
6671
|
if (stats.isDirectory()) {
|
|
6722
|
-
const absPath = sp.resolve(
|
|
6723
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
6672
|
+
const absPath = sp.resolve(path19);
|
|
6673
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path19) : path19;
|
|
6724
6674
|
if (this.fsw.closed)
|
|
6725
6675
|
return;
|
|
6726
6676
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -6730,29 +6680,29 @@ var init_handler2 = __esm({
|
|
|
6730
6680
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
6731
6681
|
}
|
|
6732
6682
|
} else if (stats.isSymbolicLink()) {
|
|
6733
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
6683
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path19) : path19;
|
|
6734
6684
|
if (this.fsw.closed)
|
|
6735
6685
|
return;
|
|
6736
6686
|
const parent = sp.dirname(wh.watchPath);
|
|
6737
6687
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
6738
6688
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
6739
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
6689
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path19, wh, targetPath);
|
|
6740
6690
|
if (this.fsw.closed)
|
|
6741
6691
|
return;
|
|
6742
6692
|
if (targetPath !== void 0) {
|
|
6743
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
6693
|
+
this.fsw._symlinkPaths.set(sp.resolve(path19), targetPath);
|
|
6744
6694
|
}
|
|
6745
6695
|
} else {
|
|
6746
6696
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
6747
6697
|
}
|
|
6748
6698
|
ready();
|
|
6749
6699
|
if (closer)
|
|
6750
|
-
this.fsw._addPathCloser(
|
|
6700
|
+
this.fsw._addPathCloser(path19, closer);
|
|
6751
6701
|
return false;
|
|
6752
6702
|
} catch (error48) {
|
|
6753
6703
|
if (this.fsw._handleError(error48)) {
|
|
6754
6704
|
ready();
|
|
6755
|
-
return
|
|
6705
|
+
return path19;
|
|
6756
6706
|
}
|
|
6757
6707
|
}
|
|
6758
6708
|
}
|
|
@@ -6787,24 +6737,24 @@ function createPattern(matcher) {
|
|
|
6787
6737
|
}
|
|
6788
6738
|
return () => false;
|
|
6789
6739
|
}
|
|
6790
|
-
function normalizePath(
|
|
6791
|
-
if (typeof
|
|
6740
|
+
function normalizePath(path19) {
|
|
6741
|
+
if (typeof path19 !== "string")
|
|
6792
6742
|
throw new Error("string expected");
|
|
6793
|
-
|
|
6794
|
-
|
|
6743
|
+
path19 = sp2.normalize(path19);
|
|
6744
|
+
path19 = path19.replace(/\\/g, "/");
|
|
6795
6745
|
let prepend = false;
|
|
6796
|
-
if (
|
|
6746
|
+
if (path19.startsWith("//"))
|
|
6797
6747
|
prepend = true;
|
|
6798
|
-
|
|
6748
|
+
path19 = path19.replace(DOUBLE_SLASH_RE, "/");
|
|
6799
6749
|
if (prepend)
|
|
6800
|
-
|
|
6801
|
-
return
|
|
6750
|
+
path19 = "/" + path19;
|
|
6751
|
+
return path19;
|
|
6802
6752
|
}
|
|
6803
6753
|
function matchPatterns(patterns, testString, stats) {
|
|
6804
|
-
const
|
|
6754
|
+
const path19 = normalizePath(testString);
|
|
6805
6755
|
for (let index = 0; index < patterns.length; index++) {
|
|
6806
6756
|
const pattern = patterns[index];
|
|
6807
|
-
if (pattern(
|
|
6757
|
+
if (pattern(path19, stats)) {
|
|
6808
6758
|
return true;
|
|
6809
6759
|
}
|
|
6810
6760
|
}
|
|
@@ -6867,19 +6817,19 @@ var init_chokidar = __esm({
|
|
|
6867
6817
|
}
|
|
6868
6818
|
return str;
|
|
6869
6819
|
};
|
|
6870
|
-
normalizePathToUnix = (
|
|
6871
|
-
normalizeIgnored = (cwd = "") => (
|
|
6872
|
-
if (typeof
|
|
6873
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
6820
|
+
normalizePathToUnix = (path19) => toUnix(sp2.normalize(toUnix(path19)));
|
|
6821
|
+
normalizeIgnored = (cwd = "") => (path19) => {
|
|
6822
|
+
if (typeof path19 === "string") {
|
|
6823
|
+
return normalizePathToUnix(sp2.isAbsolute(path19) ? path19 : sp2.join(cwd, path19));
|
|
6874
6824
|
} else {
|
|
6875
|
-
return
|
|
6825
|
+
return path19;
|
|
6876
6826
|
}
|
|
6877
6827
|
};
|
|
6878
|
-
getAbsolutePath = (
|
|
6879
|
-
if (sp2.isAbsolute(
|
|
6880
|
-
return
|
|
6828
|
+
getAbsolutePath = (path19, cwd) => {
|
|
6829
|
+
if (sp2.isAbsolute(path19)) {
|
|
6830
|
+
return path19;
|
|
6881
6831
|
}
|
|
6882
|
-
return sp2.join(cwd,
|
|
6832
|
+
return sp2.join(cwd, path19);
|
|
6883
6833
|
};
|
|
6884
6834
|
EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
6885
6835
|
DirEntry = class {
|
|
@@ -6944,10 +6894,10 @@ var init_chokidar = __esm({
|
|
|
6944
6894
|
dirParts;
|
|
6945
6895
|
followSymlinks;
|
|
6946
6896
|
statMethod;
|
|
6947
|
-
constructor(
|
|
6897
|
+
constructor(path19, follow, fsw) {
|
|
6948
6898
|
this.fsw = fsw;
|
|
6949
|
-
const watchPath =
|
|
6950
|
-
this.path =
|
|
6899
|
+
const watchPath = path19;
|
|
6900
|
+
this.path = path19 = path19.replace(REPLACER_RE, "");
|
|
6951
6901
|
this.watchPath = watchPath;
|
|
6952
6902
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
6953
6903
|
this.dirParts = [];
|
|
@@ -7087,20 +7037,20 @@ var init_chokidar = __esm({
|
|
|
7087
7037
|
this._closePromise = void 0;
|
|
7088
7038
|
let paths = unifyPaths(paths_);
|
|
7089
7039
|
if (cwd) {
|
|
7090
|
-
paths = paths.map((
|
|
7091
|
-
const absPath = getAbsolutePath(
|
|
7040
|
+
paths = paths.map((path19) => {
|
|
7041
|
+
const absPath = getAbsolutePath(path19, cwd);
|
|
7092
7042
|
return absPath;
|
|
7093
7043
|
});
|
|
7094
7044
|
}
|
|
7095
|
-
paths.forEach((
|
|
7096
|
-
this._removeIgnoredPath(
|
|
7045
|
+
paths.forEach((path19) => {
|
|
7046
|
+
this._removeIgnoredPath(path19);
|
|
7097
7047
|
});
|
|
7098
7048
|
this._userIgnored = void 0;
|
|
7099
7049
|
if (!this._readyCount)
|
|
7100
7050
|
this._readyCount = 0;
|
|
7101
7051
|
this._readyCount += paths.length;
|
|
7102
|
-
Promise.all(paths.map(async (
|
|
7103
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
7052
|
+
Promise.all(paths.map(async (path19) => {
|
|
7053
|
+
const res = await this._nodeFsHandler._addToNodeFs(path19, !_internal, void 0, 0, _origAdd);
|
|
7104
7054
|
if (res)
|
|
7105
7055
|
this._emitReady();
|
|
7106
7056
|
return res;
|
|
@@ -7122,17 +7072,17 @@ var init_chokidar = __esm({
|
|
|
7122
7072
|
return this;
|
|
7123
7073
|
const paths = unifyPaths(paths_);
|
|
7124
7074
|
const { cwd } = this.options;
|
|
7125
|
-
paths.forEach((
|
|
7126
|
-
if (!sp2.isAbsolute(
|
|
7075
|
+
paths.forEach((path19) => {
|
|
7076
|
+
if (!sp2.isAbsolute(path19) && !this._closers.has(path19)) {
|
|
7127
7077
|
if (cwd)
|
|
7128
|
-
|
|
7129
|
-
|
|
7078
|
+
path19 = sp2.join(cwd, path19);
|
|
7079
|
+
path19 = sp2.resolve(path19);
|
|
7130
7080
|
}
|
|
7131
|
-
this._closePath(
|
|
7132
|
-
this._addIgnoredPath(
|
|
7133
|
-
if (this._watched.has(
|
|
7081
|
+
this._closePath(path19);
|
|
7082
|
+
this._addIgnoredPath(path19);
|
|
7083
|
+
if (this._watched.has(path19)) {
|
|
7134
7084
|
this._addIgnoredPath({
|
|
7135
|
-
path:
|
|
7085
|
+
path: path19,
|
|
7136
7086
|
recursive: true
|
|
7137
7087
|
});
|
|
7138
7088
|
}
|
|
@@ -7196,38 +7146,38 @@ var init_chokidar = __esm({
|
|
|
7196
7146
|
* @param stats arguments to be passed with event
|
|
7197
7147
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
7198
7148
|
*/
|
|
7199
|
-
async _emit(event,
|
|
7149
|
+
async _emit(event, path19, stats) {
|
|
7200
7150
|
if (this.closed)
|
|
7201
7151
|
return;
|
|
7202
7152
|
const opts = this.options;
|
|
7203
7153
|
if (isWindows)
|
|
7204
|
-
|
|
7154
|
+
path19 = sp2.normalize(path19);
|
|
7205
7155
|
if (opts.cwd)
|
|
7206
|
-
|
|
7207
|
-
const args = [
|
|
7156
|
+
path19 = sp2.relative(opts.cwd, path19);
|
|
7157
|
+
const args = [path19];
|
|
7208
7158
|
if (stats != null)
|
|
7209
7159
|
args.push(stats);
|
|
7210
7160
|
const awf = opts.awaitWriteFinish;
|
|
7211
7161
|
let pw;
|
|
7212
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
7162
|
+
if (awf && (pw = this._pendingWrites.get(path19))) {
|
|
7213
7163
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
7214
7164
|
return this;
|
|
7215
7165
|
}
|
|
7216
7166
|
if (opts.atomic) {
|
|
7217
7167
|
if (event === EVENTS.UNLINK) {
|
|
7218
|
-
this._pendingUnlinks.set(
|
|
7168
|
+
this._pendingUnlinks.set(path19, [event, ...args]);
|
|
7219
7169
|
setTimeout(() => {
|
|
7220
|
-
this._pendingUnlinks.forEach((entry,
|
|
7170
|
+
this._pendingUnlinks.forEach((entry, path20) => {
|
|
7221
7171
|
this.emit(...entry);
|
|
7222
7172
|
this.emit(EVENTS.ALL, ...entry);
|
|
7223
|
-
this._pendingUnlinks.delete(
|
|
7173
|
+
this._pendingUnlinks.delete(path20);
|
|
7224
7174
|
});
|
|
7225
7175
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
7226
7176
|
return this;
|
|
7227
7177
|
}
|
|
7228
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
7178
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path19)) {
|
|
7229
7179
|
event = EVENTS.CHANGE;
|
|
7230
|
-
this._pendingUnlinks.delete(
|
|
7180
|
+
this._pendingUnlinks.delete(path19);
|
|
7231
7181
|
}
|
|
7232
7182
|
}
|
|
7233
7183
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -7245,16 +7195,16 @@ var init_chokidar = __esm({
|
|
|
7245
7195
|
this.emitWithAll(event, args);
|
|
7246
7196
|
}
|
|
7247
7197
|
};
|
|
7248
|
-
this._awaitWriteFinish(
|
|
7198
|
+
this._awaitWriteFinish(path19, awf.stabilityThreshold, event, awfEmit);
|
|
7249
7199
|
return this;
|
|
7250
7200
|
}
|
|
7251
7201
|
if (event === EVENTS.CHANGE) {
|
|
7252
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
7202
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path19, 50);
|
|
7253
7203
|
if (isThrottled)
|
|
7254
7204
|
return this;
|
|
7255
7205
|
}
|
|
7256
7206
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
7257
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
7207
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path19) : path19;
|
|
7258
7208
|
let stats2;
|
|
7259
7209
|
try {
|
|
7260
7210
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -7285,23 +7235,23 @@ var init_chokidar = __esm({
|
|
|
7285
7235
|
* @param timeout duration of time to suppress duplicate actions
|
|
7286
7236
|
* @returns tracking object or false if action should be suppressed
|
|
7287
7237
|
*/
|
|
7288
|
-
_throttle(actionType,
|
|
7238
|
+
_throttle(actionType, path19, timeout) {
|
|
7289
7239
|
if (!this._throttled.has(actionType)) {
|
|
7290
7240
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
7291
7241
|
}
|
|
7292
7242
|
const action = this._throttled.get(actionType);
|
|
7293
7243
|
if (!action)
|
|
7294
7244
|
throw new Error("invalid throttle");
|
|
7295
|
-
const actionPath = action.get(
|
|
7245
|
+
const actionPath = action.get(path19);
|
|
7296
7246
|
if (actionPath) {
|
|
7297
7247
|
actionPath.count++;
|
|
7298
7248
|
return false;
|
|
7299
7249
|
}
|
|
7300
7250
|
let timeoutObject;
|
|
7301
7251
|
const clear = () => {
|
|
7302
|
-
const item = action.get(
|
|
7252
|
+
const item = action.get(path19);
|
|
7303
7253
|
const count = item ? item.count : 0;
|
|
7304
|
-
action.delete(
|
|
7254
|
+
action.delete(path19);
|
|
7305
7255
|
clearTimeout(timeoutObject);
|
|
7306
7256
|
if (item)
|
|
7307
7257
|
clearTimeout(item.timeoutObject);
|
|
@@ -7309,7 +7259,7 @@ var init_chokidar = __esm({
|
|
|
7309
7259
|
};
|
|
7310
7260
|
timeoutObject = setTimeout(clear, timeout);
|
|
7311
7261
|
const thr = { timeoutObject, clear, count: 0 };
|
|
7312
|
-
action.set(
|
|
7262
|
+
action.set(path19, thr);
|
|
7313
7263
|
return thr;
|
|
7314
7264
|
}
|
|
7315
7265
|
_incrReadyCount() {
|
|
@@ -7323,44 +7273,44 @@ var init_chokidar = __esm({
|
|
|
7323
7273
|
* @param event
|
|
7324
7274
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
7325
7275
|
*/
|
|
7326
|
-
_awaitWriteFinish(
|
|
7276
|
+
_awaitWriteFinish(path19, threshold, event, awfEmit) {
|
|
7327
7277
|
const awf = this.options.awaitWriteFinish;
|
|
7328
7278
|
if (typeof awf !== "object")
|
|
7329
7279
|
return;
|
|
7330
7280
|
const pollInterval = awf.pollInterval;
|
|
7331
7281
|
let timeoutHandler;
|
|
7332
|
-
let fullPath =
|
|
7333
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
7334
|
-
fullPath = sp2.join(this.options.cwd,
|
|
7282
|
+
let fullPath = path19;
|
|
7283
|
+
if (this.options.cwd && !sp2.isAbsolute(path19)) {
|
|
7284
|
+
fullPath = sp2.join(this.options.cwd, path19);
|
|
7335
7285
|
}
|
|
7336
7286
|
const now = /* @__PURE__ */ new Date();
|
|
7337
7287
|
const writes = this._pendingWrites;
|
|
7338
7288
|
function awaitWriteFinishFn(prevStat) {
|
|
7339
7289
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
7340
|
-
if (err || !writes.has(
|
|
7290
|
+
if (err || !writes.has(path19)) {
|
|
7341
7291
|
if (err && err.code !== "ENOENT")
|
|
7342
7292
|
awfEmit(err);
|
|
7343
7293
|
return;
|
|
7344
7294
|
}
|
|
7345
7295
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
7346
7296
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
7347
|
-
writes.get(
|
|
7297
|
+
writes.get(path19).lastChange = now2;
|
|
7348
7298
|
}
|
|
7349
|
-
const pw = writes.get(
|
|
7299
|
+
const pw = writes.get(path19);
|
|
7350
7300
|
const df = now2 - pw.lastChange;
|
|
7351
7301
|
if (df >= threshold) {
|
|
7352
|
-
writes.delete(
|
|
7302
|
+
writes.delete(path19);
|
|
7353
7303
|
awfEmit(void 0, curStat);
|
|
7354
7304
|
} else {
|
|
7355
7305
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
7356
7306
|
}
|
|
7357
7307
|
});
|
|
7358
7308
|
}
|
|
7359
|
-
if (!writes.has(
|
|
7360
|
-
writes.set(
|
|
7309
|
+
if (!writes.has(path19)) {
|
|
7310
|
+
writes.set(path19, {
|
|
7361
7311
|
lastChange: now,
|
|
7362
7312
|
cancelWait: () => {
|
|
7363
|
-
writes.delete(
|
|
7313
|
+
writes.delete(path19);
|
|
7364
7314
|
clearTimeout(timeoutHandler);
|
|
7365
7315
|
return event;
|
|
7366
7316
|
}
|
|
@@ -7371,8 +7321,8 @@ var init_chokidar = __esm({
|
|
|
7371
7321
|
/**
|
|
7372
7322
|
* Determines whether user has asked to ignore this path.
|
|
7373
7323
|
*/
|
|
7374
|
-
_isIgnored(
|
|
7375
|
-
if (this.options.atomic && DOT_RE.test(
|
|
7324
|
+
_isIgnored(path19, stats) {
|
|
7325
|
+
if (this.options.atomic && DOT_RE.test(path19))
|
|
7376
7326
|
return true;
|
|
7377
7327
|
if (!this._userIgnored) {
|
|
7378
7328
|
const { cwd } = this.options;
|
|
@@ -7382,17 +7332,17 @@ var init_chokidar = __esm({
|
|
|
7382
7332
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
7383
7333
|
this._userIgnored = anymatch(list, void 0);
|
|
7384
7334
|
}
|
|
7385
|
-
return this._userIgnored(
|
|
7335
|
+
return this._userIgnored(path19, stats);
|
|
7386
7336
|
}
|
|
7387
|
-
_isntIgnored(
|
|
7388
|
-
return !this._isIgnored(
|
|
7337
|
+
_isntIgnored(path19, stat4) {
|
|
7338
|
+
return !this._isIgnored(path19, stat4);
|
|
7389
7339
|
}
|
|
7390
7340
|
/**
|
|
7391
7341
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
7392
7342
|
* @param path file or directory pattern being watched
|
|
7393
7343
|
*/
|
|
7394
|
-
_getWatchHelpers(
|
|
7395
|
-
return new WatchHelper(
|
|
7344
|
+
_getWatchHelpers(path19) {
|
|
7345
|
+
return new WatchHelper(path19, this.options.followSymlinks, this);
|
|
7396
7346
|
}
|
|
7397
7347
|
// Directory helpers
|
|
7398
7348
|
// -----------------
|
|
@@ -7424,63 +7374,63 @@ var init_chokidar = __esm({
|
|
|
7424
7374
|
* @param item base path of item/directory
|
|
7425
7375
|
*/
|
|
7426
7376
|
_remove(directory, item, isDirectory) {
|
|
7427
|
-
const
|
|
7428
|
-
const fullPath = sp2.resolve(
|
|
7429
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
7430
|
-
if (!this._throttle("remove",
|
|
7377
|
+
const path19 = sp2.join(directory, item);
|
|
7378
|
+
const fullPath = sp2.resolve(path19);
|
|
7379
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path19) || this._watched.has(fullPath);
|
|
7380
|
+
if (!this._throttle("remove", path19, 100))
|
|
7431
7381
|
return;
|
|
7432
7382
|
if (!isDirectory && this._watched.size === 1) {
|
|
7433
7383
|
this.add(directory, item, true);
|
|
7434
7384
|
}
|
|
7435
|
-
const wp = this._getWatchedDir(
|
|
7385
|
+
const wp = this._getWatchedDir(path19);
|
|
7436
7386
|
const nestedDirectoryChildren = wp.getChildren();
|
|
7437
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
7387
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path19, nested));
|
|
7438
7388
|
const parent = this._getWatchedDir(directory);
|
|
7439
7389
|
const wasTracked = parent.has(item);
|
|
7440
7390
|
parent.remove(item);
|
|
7441
7391
|
if (this._symlinkPaths.has(fullPath)) {
|
|
7442
7392
|
this._symlinkPaths.delete(fullPath);
|
|
7443
7393
|
}
|
|
7444
|
-
let relPath =
|
|
7394
|
+
let relPath = path19;
|
|
7445
7395
|
if (this.options.cwd)
|
|
7446
|
-
relPath = sp2.relative(this.options.cwd,
|
|
7396
|
+
relPath = sp2.relative(this.options.cwd, path19);
|
|
7447
7397
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
7448
7398
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
7449
7399
|
if (event === EVENTS.ADD)
|
|
7450
7400
|
return;
|
|
7451
7401
|
}
|
|
7452
|
-
this._watched.delete(
|
|
7402
|
+
this._watched.delete(path19);
|
|
7453
7403
|
this._watched.delete(fullPath);
|
|
7454
7404
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
7455
|
-
if (wasTracked && !this._isIgnored(
|
|
7456
|
-
this._emit(eventName,
|
|
7457
|
-
this._closePath(
|
|
7405
|
+
if (wasTracked && !this._isIgnored(path19))
|
|
7406
|
+
this._emit(eventName, path19);
|
|
7407
|
+
this._closePath(path19);
|
|
7458
7408
|
}
|
|
7459
7409
|
/**
|
|
7460
7410
|
* Closes all watchers for a path
|
|
7461
7411
|
*/
|
|
7462
|
-
_closePath(
|
|
7463
|
-
this._closeFile(
|
|
7464
|
-
const dir = sp2.dirname(
|
|
7465
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
7412
|
+
_closePath(path19) {
|
|
7413
|
+
this._closeFile(path19);
|
|
7414
|
+
const dir = sp2.dirname(path19);
|
|
7415
|
+
this._getWatchedDir(dir).remove(sp2.basename(path19));
|
|
7466
7416
|
}
|
|
7467
7417
|
/**
|
|
7468
7418
|
* Closes only file-specific watchers
|
|
7469
7419
|
*/
|
|
7470
|
-
_closeFile(
|
|
7471
|
-
const closers = this._closers.get(
|
|
7420
|
+
_closeFile(path19) {
|
|
7421
|
+
const closers = this._closers.get(path19);
|
|
7472
7422
|
if (!closers)
|
|
7473
7423
|
return;
|
|
7474
7424
|
closers.forEach((closer) => closer());
|
|
7475
|
-
this._closers.delete(
|
|
7425
|
+
this._closers.delete(path19);
|
|
7476
7426
|
}
|
|
7477
|
-
_addPathCloser(
|
|
7427
|
+
_addPathCloser(path19, closer) {
|
|
7478
7428
|
if (!closer)
|
|
7479
7429
|
return;
|
|
7480
|
-
let list = this._closers.get(
|
|
7430
|
+
let list = this._closers.get(path19);
|
|
7481
7431
|
if (!list) {
|
|
7482
7432
|
list = [];
|
|
7483
|
-
this._closers.set(
|
|
7433
|
+
this._closers.set(path19, list);
|
|
7484
7434
|
}
|
|
7485
7435
|
list.push(closer);
|
|
7486
7436
|
}
|
|
@@ -8679,7 +8629,7 @@ function detectCurrentWorkspace(ideId) {
|
|
|
8679
8629
|
}
|
|
8680
8630
|
} else if (plat === "win32") {
|
|
8681
8631
|
try {
|
|
8682
|
-
const
|
|
8632
|
+
const fs17 = require("fs");
|
|
8683
8633
|
const appNameMap = getMacAppIdentifiers();
|
|
8684
8634
|
const appName = appNameMap[ideId];
|
|
8685
8635
|
if (appName) {
|
|
@@ -8688,8 +8638,8 @@ function detectCurrentWorkspace(ideId) {
|
|
|
8688
8638
|
appName,
|
|
8689
8639
|
"storage.json"
|
|
8690
8640
|
);
|
|
8691
|
-
if (
|
|
8692
|
-
const data = JSON.parse(
|
|
8641
|
+
if (fs17.existsSync(storagePath)) {
|
|
8642
|
+
const data = JSON.parse(fs17.readFileSync(storagePath, "utf-8"));
|
|
8693
8643
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
8694
8644
|
if (workspaces.length > 0) {
|
|
8695
8645
|
const recent = workspaces[0];
|
|
@@ -9093,6 +9043,9 @@ var init_ghostty_vt_backend = __esm({
|
|
|
9093
9043
|
getText() {
|
|
9094
9044
|
return this.terminal.formatPlainText({ trim: true }) || "";
|
|
9095
9045
|
}
|
|
9046
|
+
getCursorPosition() {
|
|
9047
|
+
return this.terminal.getCursorPosition();
|
|
9048
|
+
}
|
|
9096
9049
|
dispose() {
|
|
9097
9050
|
this.terminal.dispose();
|
|
9098
9051
|
}
|
|
@@ -18245,6 +18198,13 @@ var init_xterm_backend = __esm({
|
|
|
18245
18198
|
while (last > first && !lines[last - 1]?.trim()) last--;
|
|
18246
18199
|
return lines.slice(first, last).join("\n");
|
|
18247
18200
|
}
|
|
18201
|
+
getCursorPosition() {
|
|
18202
|
+
const buffer = this.terminal.buffer.active;
|
|
18203
|
+
return {
|
|
18204
|
+
col: Math.max(0, buffer.cursorX || 0),
|
|
18205
|
+
row: Math.max(0, buffer.cursorY || 0)
|
|
18206
|
+
};
|
|
18207
|
+
}
|
|
18248
18208
|
dispose() {
|
|
18249
18209
|
this.terminal.dispose();
|
|
18250
18210
|
}
|
|
@@ -18331,6 +18291,9 @@ var init_terminal_screen = __esm({
|
|
|
18331
18291
|
getText() {
|
|
18332
18292
|
return this.terminal.getText();
|
|
18333
18293
|
}
|
|
18294
|
+
getCursorPosition() {
|
|
18295
|
+
return this.terminal.getCursorPosition();
|
|
18296
|
+
}
|
|
18334
18297
|
dispose() {
|
|
18335
18298
|
this.terminal.dispose();
|
|
18336
18299
|
}
|
|
@@ -18496,8 +18459,197 @@ var init_snapshot = __esm({
|
|
|
18496
18459
|
}
|
|
18497
18460
|
});
|
|
18498
18461
|
|
|
18462
|
+
// ../../oss/packages/daemon-core/src/commands/upgrade-helper.ts
|
|
18463
|
+
function getUpgradeLogPath() {
|
|
18464
|
+
const home = os12.homedir();
|
|
18465
|
+
const dir = path9.join(home, ".adhdev");
|
|
18466
|
+
fs8.mkdirSync(dir, { recursive: true });
|
|
18467
|
+
return path9.join(dir, "daemon-upgrade.log");
|
|
18468
|
+
}
|
|
18469
|
+
function appendUpgradeLog(message) {
|
|
18470
|
+
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
18471
|
+
`;
|
|
18472
|
+
try {
|
|
18473
|
+
fs8.appendFileSync(getUpgradeLogPath(), line, "utf8");
|
|
18474
|
+
} catch {
|
|
18475
|
+
}
|
|
18476
|
+
}
|
|
18477
|
+
function getNpmExecutable() {
|
|
18478
|
+
return process.platform === "win32" ? "npm.cmd" : "npm";
|
|
18479
|
+
}
|
|
18480
|
+
function killPid(pid) {
|
|
18481
|
+
try {
|
|
18482
|
+
if (process.platform === "win32") {
|
|
18483
|
+
(0, import_child_process5.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
|
|
18484
|
+
} else {
|
|
18485
|
+
process.kill(pid, "SIGTERM");
|
|
18486
|
+
}
|
|
18487
|
+
return true;
|
|
18488
|
+
} catch {
|
|
18489
|
+
return false;
|
|
18490
|
+
}
|
|
18491
|
+
}
|
|
18492
|
+
async function waitForPidExit(pid, timeoutMs) {
|
|
18493
|
+
const start = Date.now();
|
|
18494
|
+
while (Date.now() - start < timeoutMs) {
|
|
18495
|
+
try {
|
|
18496
|
+
process.kill(pid, 0);
|
|
18497
|
+
await new Promise((resolve12) => setTimeout(resolve12, 250));
|
|
18498
|
+
} catch {
|
|
18499
|
+
return;
|
|
18500
|
+
}
|
|
18501
|
+
}
|
|
18502
|
+
}
|
|
18503
|
+
function stopSessionHostProcesses(appName) {
|
|
18504
|
+
const pidFile = path9.join(os12.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
18505
|
+
try {
|
|
18506
|
+
if (fs8.existsSync(pidFile)) {
|
|
18507
|
+
const pid = Number.parseInt(fs8.readFileSync(pidFile, "utf8").trim(), 10);
|
|
18508
|
+
if (Number.isFinite(pid)) {
|
|
18509
|
+
killPid(pid);
|
|
18510
|
+
}
|
|
18511
|
+
}
|
|
18512
|
+
} catch {
|
|
18513
|
+
} finally {
|
|
18514
|
+
try {
|
|
18515
|
+
fs8.unlinkSync(pidFile);
|
|
18516
|
+
} catch {
|
|
18517
|
+
}
|
|
18518
|
+
}
|
|
18519
|
+
if (process.platform !== "win32") {
|
|
18520
|
+
try {
|
|
18521
|
+
const raw = (0, import_child_process5.execFileSync)("pgrep", ["-f", "session-host-daemon"], { encoding: "utf8" }).trim();
|
|
18522
|
+
for (const line of raw.split("\n")) {
|
|
18523
|
+
const pid = Number.parseInt(line.trim(), 10);
|
|
18524
|
+
if (Number.isFinite(pid)) {
|
|
18525
|
+
killPid(pid);
|
|
18526
|
+
}
|
|
18527
|
+
}
|
|
18528
|
+
} catch {
|
|
18529
|
+
}
|
|
18530
|
+
}
|
|
18531
|
+
}
|
|
18532
|
+
function removeDaemonPidFile() {
|
|
18533
|
+
const pidFile = path9.join(os12.homedir(), ".adhdev", "daemon.pid");
|
|
18534
|
+
try {
|
|
18535
|
+
fs8.unlinkSync(pidFile);
|
|
18536
|
+
} catch {
|
|
18537
|
+
}
|
|
18538
|
+
}
|
|
18539
|
+
function cleanupStaleGlobalInstallDirs(pkgName) {
|
|
18540
|
+
const npmRoot = (0, import_child_process5.execFileSync)(getNpmExecutable(), ["root", "-g"], { encoding: "utf8" }).trim();
|
|
18541
|
+
if (!npmRoot) return;
|
|
18542
|
+
const npmPrefix = (0, import_child_process5.execFileSync)(getNpmExecutable(), ["prefix", "-g"], { encoding: "utf8" }).trim();
|
|
18543
|
+
const binDir = process.platform === "win32" ? npmPrefix : path9.join(npmPrefix, "bin");
|
|
18544
|
+
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
18545
|
+
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
18546
|
+
if (pkgName === "@adhdev/daemon-standalone") {
|
|
18547
|
+
binNames.add("adhdev-standalone");
|
|
18548
|
+
}
|
|
18549
|
+
if (pkgName.startsWith("@")) {
|
|
18550
|
+
const [scope, name] = pkgName.split("/");
|
|
18551
|
+
const scopeDir = path9.join(npmRoot, scope);
|
|
18552
|
+
if (!fs8.existsSync(scopeDir)) return;
|
|
18553
|
+
for (const entry of fs8.readdirSync(scopeDir)) {
|
|
18554
|
+
if (!entry.startsWith(`.${name}-`)) continue;
|
|
18555
|
+
fs8.rmSync(path9.join(scopeDir, entry), { recursive: true, force: true });
|
|
18556
|
+
appendUpgradeLog(`Removed stale scoped staging dir: ${path9.join(scopeDir, entry)}`);
|
|
18557
|
+
}
|
|
18558
|
+
} else {
|
|
18559
|
+
for (const entry of fs8.readdirSync(npmRoot)) {
|
|
18560
|
+
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
18561
|
+
fs8.rmSync(path9.join(npmRoot, entry), { recursive: true, force: true });
|
|
18562
|
+
appendUpgradeLog(`Removed stale staging dir: ${path9.join(npmRoot, entry)}`);
|
|
18563
|
+
}
|
|
18564
|
+
}
|
|
18565
|
+
if (fs8.existsSync(binDir)) {
|
|
18566
|
+
for (const entry of fs8.readdirSync(binDir)) {
|
|
18567
|
+
if (![...binNames].some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
18568
|
+
fs8.rmSync(path9.join(binDir, entry), { recursive: true, force: true });
|
|
18569
|
+
appendUpgradeLog(`Removed stale bin staging entry: ${path9.join(binDir, entry)}`);
|
|
18570
|
+
}
|
|
18571
|
+
}
|
|
18572
|
+
}
|
|
18573
|
+
function spawnDetachedDaemonUpgradeHelper(payload) {
|
|
18574
|
+
const env = { ...process.env, [UPGRADE_HELPER_ENV]: JSON.stringify(payload) };
|
|
18575
|
+
const child = (0, import_child_process6.spawn)(process.execPath, process.argv.slice(1), {
|
|
18576
|
+
detached: true,
|
|
18577
|
+
stdio: "ignore",
|
|
18578
|
+
windowsHide: true,
|
|
18579
|
+
cwd: payload.cwd || process.cwd(),
|
|
18580
|
+
env
|
|
18581
|
+
});
|
|
18582
|
+
child.unref();
|
|
18583
|
+
}
|
|
18584
|
+
async function runDaemonUpgradeHelper(payload) {
|
|
18585
|
+
const restartArgv = Array.isArray(payload.restartArgv) ? payload.restartArgv : [];
|
|
18586
|
+
const sessionHostAppName = payload.sessionHostAppName || process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
|
|
18587
|
+
appendUpgradeLog(`Upgrade helper started for ${payload.packageName}@${payload.targetVersion}`);
|
|
18588
|
+
if (Number.isFinite(payload.parentPid) && payload.parentPid > 0) {
|
|
18589
|
+
appendUpgradeLog(`Waiting for parent pid ${payload.parentPid} to exit`);
|
|
18590
|
+
await waitForPidExit(payload.parentPid, 15e3);
|
|
18591
|
+
}
|
|
18592
|
+
stopSessionHostProcesses(sessionHostAppName);
|
|
18593
|
+
removeDaemonPidFile();
|
|
18594
|
+
cleanupStaleGlobalInstallDirs(payload.packageName);
|
|
18595
|
+
const spec = `${payload.packageName}@${payload.targetVersion || "latest"}`;
|
|
18596
|
+
appendUpgradeLog(`Installing ${spec}`);
|
|
18597
|
+
const installOutput = (0, import_child_process5.execFileSync)(
|
|
18598
|
+
getNpmExecutable(),
|
|
18599
|
+
["install", "-g", spec, "--force"],
|
|
18600
|
+
{
|
|
18601
|
+
encoding: "utf8",
|
|
18602
|
+
stdio: "pipe",
|
|
18603
|
+
maxBuffer: 20 * 1024 * 1024
|
|
18604
|
+
}
|
|
18605
|
+
);
|
|
18606
|
+
if (installOutput.trim()) {
|
|
18607
|
+
appendUpgradeLog(installOutput.trim());
|
|
18608
|
+
}
|
|
18609
|
+
if (restartArgv.length > 0) {
|
|
18610
|
+
const env = { ...process.env };
|
|
18611
|
+
delete env[UPGRADE_HELPER_ENV];
|
|
18612
|
+
appendUpgradeLog(`Restarting daemon with args: ${restartArgv.join(" ")}`);
|
|
18613
|
+
const child = (0, import_child_process6.spawn)(process.execPath, restartArgv, {
|
|
18614
|
+
detached: true,
|
|
18615
|
+
stdio: "ignore",
|
|
18616
|
+
windowsHide: true,
|
|
18617
|
+
cwd: payload.cwd || process.cwd(),
|
|
18618
|
+
env
|
|
18619
|
+
});
|
|
18620
|
+
child.unref();
|
|
18621
|
+
} else {
|
|
18622
|
+
appendUpgradeLog("No restart argv provided; upgrade completed without restart");
|
|
18623
|
+
}
|
|
18624
|
+
}
|
|
18625
|
+
async function maybeRunDaemonUpgradeHelperFromEnv() {
|
|
18626
|
+
const raw = process.env[UPGRADE_HELPER_ENV];
|
|
18627
|
+
if (!raw) return false;
|
|
18628
|
+
delete process.env[UPGRADE_HELPER_ENV];
|
|
18629
|
+
try {
|
|
18630
|
+
const payload = JSON.parse(raw);
|
|
18631
|
+
await runDaemonUpgradeHelper(payload);
|
|
18632
|
+
process.exit(0);
|
|
18633
|
+
} catch (error48) {
|
|
18634
|
+
appendUpgradeLog(`Upgrade helper failed: ${error48?.stack || error48?.message || String(error48)}`);
|
|
18635
|
+
process.exit(1);
|
|
18636
|
+
}
|
|
18637
|
+
}
|
|
18638
|
+
var import_child_process5, import_child_process6, fs8, os12, path9, UPGRADE_HELPER_ENV;
|
|
18639
|
+
var init_upgrade_helper = __esm({
|
|
18640
|
+
"../../oss/packages/daemon-core/src/commands/upgrade-helper.ts"() {
|
|
18641
|
+
"use strict";
|
|
18642
|
+
import_child_process5 = require("child_process");
|
|
18643
|
+
import_child_process6 = require("child_process");
|
|
18644
|
+
fs8 = __toESM(require("fs"));
|
|
18645
|
+
os12 = __toESM(require("os"));
|
|
18646
|
+
path9 = __toESM(require("path"));
|
|
18647
|
+
UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
18648
|
+
}
|
|
18649
|
+
});
|
|
18650
|
+
|
|
18499
18651
|
// ../../oss/packages/daemon-core/src/commands/router.ts
|
|
18500
|
-
var
|
|
18652
|
+
var fs9, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
|
|
18501
18653
|
var init_router = __esm({
|
|
18502
18654
|
"../../oss/packages/daemon-core/src/commands/router.ts"() {
|
|
18503
18655
|
"use strict";
|
|
@@ -18513,7 +18665,8 @@ var init_router = __esm({
|
|
|
18513
18665
|
init_logger();
|
|
18514
18666
|
init_builders();
|
|
18515
18667
|
init_snapshot();
|
|
18516
|
-
|
|
18668
|
+
init_upgrade_helper();
|
|
18669
|
+
fs9 = __toESM(require("fs"));
|
|
18517
18670
|
CHAT_COMMANDS = [
|
|
18518
18671
|
"send_chat",
|
|
18519
18672
|
"new_chat",
|
|
@@ -18584,8 +18737,8 @@ var init_router = __esm({
|
|
|
18584
18737
|
if (logs.length > 0) {
|
|
18585
18738
|
return { success: true, logs, totalBuffered: logs.length };
|
|
18586
18739
|
}
|
|
18587
|
-
if (
|
|
18588
|
-
const content =
|
|
18740
|
+
if (fs9.existsSync(LOG_PATH)) {
|
|
18741
|
+
const content = fs9.readFileSync(LOG_PATH, "utf-8");
|
|
18589
18742
|
const allLines = content.split("\n");
|
|
18590
18743
|
const recent = allLines.slice(-count).join("\n");
|
|
18591
18744
|
return { success: true, logs: recent, totalLines: allLines.length };
|
|
@@ -18733,31 +18886,35 @@ var init_router = __esm({
|
|
|
18733
18886
|
const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
|
|
18734
18887
|
const latest = execSync7(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
18735
18888
|
LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
|
|
18736
|
-
|
|
18737
|
-
|
|
18738
|
-
|
|
18739
|
-
|
|
18889
|
+
let currentInstalled = null;
|
|
18890
|
+
try {
|
|
18891
|
+
const currentJson = execSync7(`npm ls -g ${pkgName} --depth=0 --json`, {
|
|
18892
|
+
encoding: "utf-8",
|
|
18893
|
+
timeout: 1e4,
|
|
18894
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
18895
|
+
}).trim();
|
|
18896
|
+
const parsed = JSON.parse(currentJson);
|
|
18897
|
+
currentInstalled = parsed?.dependencies?.[pkgName]?.version || null;
|
|
18898
|
+
} catch {
|
|
18899
|
+
}
|
|
18900
|
+
if (currentInstalled === latest) {
|
|
18901
|
+
LOG.info("Upgrade", `Already on latest version v${latest}; skipping install`);
|
|
18902
|
+
return { success: true, upgraded: false, alreadyLatest: true, version: latest };
|
|
18903
|
+
}
|
|
18904
|
+
spawnDetachedDaemonUpgradeHelper({
|
|
18905
|
+
packageName: pkgName,
|
|
18906
|
+
targetVersion: latest,
|
|
18907
|
+
parentPid: process.pid,
|
|
18908
|
+
restartArgv: process.argv.slice(1),
|
|
18909
|
+
cwd: process.cwd(),
|
|
18910
|
+
sessionHostAppName: process.env.ADHDEV_SESSION_HOST_NAME || "adhdev"
|
|
18740
18911
|
});
|
|
18741
|
-
LOG.info("Upgrade",
|
|
18912
|
+
LOG.info("Upgrade", `Scheduled detached upgrade to v${latest}`);
|
|
18742
18913
|
setTimeout(() => {
|
|
18743
|
-
LOG.info("Upgrade", "
|
|
18744
|
-
try {
|
|
18745
|
-
const path18 = require("path");
|
|
18746
|
-
const fs16 = require("fs");
|
|
18747
|
-
const pidFile = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
|
|
18748
|
-
if (fs16.existsSync(pidFile)) fs16.unlinkSync(pidFile);
|
|
18749
|
-
} catch {
|
|
18750
|
-
}
|
|
18751
|
-
const { spawn: spawn4 } = require("child_process");
|
|
18752
|
-
const child = spawn4(process.execPath, process.argv.slice(1), {
|
|
18753
|
-
detached: true,
|
|
18754
|
-
stdio: "ignore",
|
|
18755
|
-
env: { ...process.env }
|
|
18756
|
-
});
|
|
18757
|
-
child.unref();
|
|
18914
|
+
LOG.info("Upgrade", "Exiting daemon so detached upgrader can continue...");
|
|
18758
18915
|
process.exit(0);
|
|
18759
18916
|
}, 3e3);
|
|
18760
|
-
return { success: true, upgraded: true, version: latest };
|
|
18917
|
+
return { success: true, upgraded: true, version: latest, restarting: true };
|
|
18761
18918
|
} catch (e) {
|
|
18762
18919
|
LOG.error("Upgrade", `Failed: ${e.message}`);
|
|
18763
18920
|
return { success: false, error: e.message };
|
|
@@ -19060,11 +19217,11 @@ var init_reporter = __esm({
|
|
|
19060
19217
|
});
|
|
19061
19218
|
|
|
19062
19219
|
// ../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts
|
|
19063
|
-
var
|
|
19220
|
+
var os13, pty, NodePtyRuntimeTransport, NodePtyTransportFactory;
|
|
19064
19221
|
var init_pty_transport = __esm({
|
|
19065
19222
|
"../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts"() {
|
|
19066
19223
|
"use strict";
|
|
19067
|
-
|
|
19224
|
+
os13 = __toESM(require("os"));
|
|
19068
19225
|
try {
|
|
19069
19226
|
pty = require("node-pty");
|
|
19070
19227
|
} catch {
|
|
@@ -19075,6 +19232,7 @@ var init_pty_transport = __esm({
|
|
|
19075
19232
|
this.handle = handle;
|
|
19076
19233
|
}
|
|
19077
19234
|
ready = Promise.resolve();
|
|
19235
|
+
terminalQueriesHandled = false;
|
|
19078
19236
|
get pid() {
|
|
19079
19237
|
return this.handle.pid;
|
|
19080
19238
|
}
|
|
@@ -19101,7 +19259,7 @@ var init_pty_transport = __esm({
|
|
|
19101
19259
|
spawn(command, args, options) {
|
|
19102
19260
|
if (!pty) throw new Error("node-pty is not installed");
|
|
19103
19261
|
const handle = pty.spawn(command, args, {
|
|
19104
|
-
name:
|
|
19262
|
+
name: os13.platform() === "win32" ? "xterm-color" : "xterm-256color",
|
|
19105
19263
|
cols: options.cols,
|
|
19106
19264
|
rows: options.rows,
|
|
19107
19265
|
cwd: options.cwd,
|
|
@@ -19128,24 +19286,50 @@ function stripTerminalNoise(str) {
|
|
|
19128
19286
|
function sanitizeTerminalText(str) {
|
|
19129
19287
|
return stripTerminalNoise(stripAnsi(str));
|
|
19130
19288
|
}
|
|
19289
|
+
function buildCliSpawnEnv(baseEnv, overrides) {
|
|
19290
|
+
const env = {};
|
|
19291
|
+
const source = { ...baseEnv, ...overrides || {} };
|
|
19292
|
+
for (const [key, value] of Object.entries(source)) {
|
|
19293
|
+
if (typeof value !== "string") continue;
|
|
19294
|
+
env[key] = value;
|
|
19295
|
+
}
|
|
19296
|
+
for (const key of Object.keys(env)) {
|
|
19297
|
+
if (key === "INIT_CWD" || key === "NO_COLOR" || key === "FORCE_COLOR" || key === "npm_command" || key === "npm_execpath" || key === "npm_node_execpath" || key.startsWith("npm_") || key.startsWith("npm_config_") || key.startsWith("npm_package_") || key.startsWith("npm_lifecycle_") || key.startsWith("PNPM_") || key.startsWith("YARN_") || key.startsWith("BUN_")) {
|
|
19298
|
+
delete env[key];
|
|
19299
|
+
}
|
|
19300
|
+
}
|
|
19301
|
+
return env;
|
|
19302
|
+
}
|
|
19303
|
+
function computeTerminalQueryTail(buffer) {
|
|
19304
|
+
const prefixes = ["\x1B[6n", "\x1B[?6n"];
|
|
19305
|
+
const maxLength = prefixes.reduce((n, value) => Math.max(n, value.length), 0) - 1;
|
|
19306
|
+
const start = Math.max(0, buffer.length - maxLength);
|
|
19307
|
+
for (let i = start; i < buffer.length; i++) {
|
|
19308
|
+
const suffix = buffer.slice(i);
|
|
19309
|
+
if (prefixes.some((pattern) => suffix.length < pattern.length && pattern.startsWith(suffix))) {
|
|
19310
|
+
return suffix;
|
|
19311
|
+
}
|
|
19312
|
+
}
|
|
19313
|
+
return "";
|
|
19314
|
+
}
|
|
19131
19315
|
function findBinary(name) {
|
|
19132
|
-
const isWin =
|
|
19316
|
+
const isWin = os14.platform() === "win32";
|
|
19133
19317
|
try {
|
|
19134
19318
|
const cmd = isWin ? `where ${name}` : `which ${name}`;
|
|
19135
|
-
return (0,
|
|
19319
|
+
return (0, import_child_process7.execSync)(cmd, { encoding: "utf-8", timeout: 5e3, stdio: ["pipe", "pipe", "pipe"] }).trim().split("\n")[0].trim();
|
|
19136
19320
|
} catch {
|
|
19137
19321
|
return isWin ? `${name}.cmd` : name;
|
|
19138
19322
|
}
|
|
19139
19323
|
}
|
|
19140
19324
|
function isScriptBinary(binaryPath) {
|
|
19141
|
-
if (!
|
|
19325
|
+
if (!path10.isAbsolute(binaryPath)) return false;
|
|
19142
19326
|
try {
|
|
19143
|
-
const
|
|
19144
|
-
const resolved =
|
|
19327
|
+
const fs17 = require("fs");
|
|
19328
|
+
const resolved = fs17.realpathSync(binaryPath);
|
|
19145
19329
|
const head = Buffer.alloc(8);
|
|
19146
|
-
const fd =
|
|
19147
|
-
|
|
19148
|
-
|
|
19330
|
+
const fd = fs17.openSync(resolved, "r");
|
|
19331
|
+
fs17.readSync(fd, head, 0, 8, 0);
|
|
19332
|
+
fs17.closeSync(fd);
|
|
19149
19333
|
let i = 0;
|
|
19150
19334
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
19151
19335
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -19154,14 +19338,14 @@ function isScriptBinary(binaryPath) {
|
|
|
19154
19338
|
}
|
|
19155
19339
|
}
|
|
19156
19340
|
function looksLikeMachOOrElf(filePath) {
|
|
19157
|
-
if (!
|
|
19341
|
+
if (!path10.isAbsolute(filePath)) return false;
|
|
19158
19342
|
try {
|
|
19159
|
-
const
|
|
19160
|
-
const resolved =
|
|
19343
|
+
const fs17 = require("fs");
|
|
19344
|
+
const resolved = fs17.realpathSync(filePath);
|
|
19161
19345
|
const buf = Buffer.alloc(8);
|
|
19162
|
-
const fd =
|
|
19163
|
-
|
|
19164
|
-
|
|
19346
|
+
const fd = fs17.openSync(resolved, "r");
|
|
19347
|
+
fs17.readSync(fd, buf, 0, 8, 0);
|
|
19348
|
+
fs17.closeSync(fd);
|
|
19165
19349
|
let i = 0;
|
|
19166
19350
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
19167
19351
|
const b2 = buf.subarray(i);
|
|
@@ -19177,7 +19361,7 @@ function looksLikeMachOOrElf(filePath) {
|
|
|
19177
19361
|
}
|
|
19178
19362
|
function shSingleQuote(arg) {
|
|
19179
19363
|
if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
|
|
19180
|
-
if (
|
|
19364
|
+
if (os14.platform() === "win32") {
|
|
19181
19365
|
return `"${arg.replace(/"/g, '""')}"`;
|
|
19182
19366
|
}
|
|
19183
19367
|
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
@@ -19214,36 +19398,6 @@ function promptLikelyVisible(screenText, promptSnippet) {
|
|
|
19214
19398
|
).length;
|
|
19215
19399
|
return matched >= required2;
|
|
19216
19400
|
}
|
|
19217
|
-
function splitHistoryLines(text) {
|
|
19218
|
-
return String(text || "").split("\n").map((line) => line.replace(/\s+$/, ""));
|
|
19219
|
-
}
|
|
19220
|
-
function normalizeHistoryLine(line) {
|
|
19221
|
-
return String(line || "").replace(/\s+/g, " ").trim();
|
|
19222
|
-
}
|
|
19223
|
-
function mergeTerminalHistory(existing, snapshot) {
|
|
19224
|
-
const next = String(snapshot || "").trim();
|
|
19225
|
-
if (!next) return existing;
|
|
19226
|
-
const prev = String(existing || "").trim();
|
|
19227
|
-
if (!prev) return next;
|
|
19228
|
-
if (prev === next || prev.endsWith(next)) return prev;
|
|
19229
|
-
const prevLines = splitHistoryLines(prev);
|
|
19230
|
-
const nextLines = splitHistoryLines(next);
|
|
19231
|
-
const prevNorm = prevLines.map(normalizeHistoryLine);
|
|
19232
|
-
const nextNorm = nextLines.map(normalizeHistoryLine);
|
|
19233
|
-
const maxOverlap = Math.min(prevLines.length, nextLines.length);
|
|
19234
|
-
for (let overlap = maxOverlap; overlap >= 1; overlap -= 1) {
|
|
19235
|
-
const prevTail = prevNorm.slice(prevNorm.length - overlap);
|
|
19236
|
-
const nextHead = nextNorm.slice(0, overlap);
|
|
19237
|
-
if (prevTail.every((line, index) => line === nextHead[index])) {
|
|
19238
|
-
return [...prevLines, ...nextLines.slice(overlap)].join("\n").trim();
|
|
19239
|
-
}
|
|
19240
|
-
}
|
|
19241
|
-
const compactPrev = prevNorm.join("\n");
|
|
19242
|
-
const compactNext = nextNorm.join("\n");
|
|
19243
|
-
if (compactPrev.includes(compactNext)) return prev;
|
|
19244
|
-
return `${prev}
|
|
19245
|
-
${next}`.trim();
|
|
19246
|
-
}
|
|
19247
19401
|
function parsePatternEntry(x) {
|
|
19248
19402
|
if (x instanceof RegExp) return x;
|
|
19249
19403
|
if (x && typeof x === "object" && typeof x.source === "string") {
|
|
@@ -19268,28 +19422,28 @@ function normalizeCliProviderForRuntime(raw) {
|
|
|
19268
19422
|
}
|
|
19269
19423
|
};
|
|
19270
19424
|
}
|
|
19271
|
-
var
|
|
19425
|
+
var os14, path10, import_child_process7, pty2, ProviderCliAdapter;
|
|
19272
19426
|
var init_provider_cli_adapter = __esm({
|
|
19273
19427
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
|
|
19274
19428
|
"use strict";
|
|
19275
|
-
|
|
19276
|
-
|
|
19277
|
-
|
|
19429
|
+
os14 = __toESM(require("os"));
|
|
19430
|
+
path10 = __toESM(require("path"));
|
|
19431
|
+
import_child_process7 = require("child_process");
|
|
19278
19432
|
init_logger();
|
|
19279
19433
|
init_terminal_screen();
|
|
19280
19434
|
init_pty_transport();
|
|
19281
19435
|
try {
|
|
19282
19436
|
pty2 = require("node-pty");
|
|
19283
|
-
if (
|
|
19437
|
+
if (os14.platform() !== "win32") {
|
|
19284
19438
|
try {
|
|
19285
|
-
const
|
|
19286
|
-
const ptyDir =
|
|
19287
|
-
const platformArch = `${
|
|
19288
|
-
const helper =
|
|
19289
|
-
if (
|
|
19290
|
-
const stat4 =
|
|
19439
|
+
const fs17 = require("fs");
|
|
19440
|
+
const ptyDir = path10.resolve(path10.dirname(require.resolve("node-pty")), "..");
|
|
19441
|
+
const platformArch = `${os14.platform()}-${os14.arch()}`;
|
|
19442
|
+
const helper = path10.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
19443
|
+
if (fs17.existsSync(helper)) {
|
|
19444
|
+
const stat4 = fs17.statSync(helper);
|
|
19291
19445
|
if (!(stat4.mode & 73)) {
|
|
19292
|
-
|
|
19446
|
+
fs17.chmodSync(helper, stat4.mode | 493);
|
|
19293
19447
|
LOG.info("CLI", "[node-pty] Fixed spawn-helper permissions");
|
|
19294
19448
|
}
|
|
19295
19449
|
}
|
|
@@ -19306,7 +19460,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
19306
19460
|
this.transportFactory = transportFactory;
|
|
19307
19461
|
this.cliType = provider.type;
|
|
19308
19462
|
this.cliName = provider.name;
|
|
19309
|
-
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/,
|
|
19463
|
+
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os14.homedir()) : workingDir;
|
|
19310
19464
|
const t = provider.timeouts || {};
|
|
19311
19465
|
this.timeouts = {
|
|
19312
19466
|
ptyFlush: t.ptyFlush ?? 50,
|
|
@@ -19358,6 +19512,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
19358
19512
|
pendingOutputParseTimer = null;
|
|
19359
19513
|
ptyOutputBuffer = "";
|
|
19360
19514
|
ptyOutputFlushTimer = null;
|
|
19515
|
+
pendingTerminalQueryTail = "";
|
|
19361
19516
|
// Server log forwarding
|
|
19362
19517
|
serverConn = null;
|
|
19363
19518
|
logBuffer = [];
|
|
@@ -19389,9 +19544,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
19389
19544
|
/** Full accumulated raw PTY output (with ANSI) */
|
|
19390
19545
|
accumulatedRawBuffer = "";
|
|
19391
19546
|
/** Current visible terminal screen snapshot */
|
|
19392
|
-
terminalScreen = new TerminalScreen(
|
|
19393
|
-
/** Rolling append-only terminal transcript built from screen snapshots */
|
|
19394
|
-
terminalHistory = "";
|
|
19547
|
+
terminalScreen = new TerminalScreen(30, 100);
|
|
19395
19548
|
/** Max accumulated buffer size (last 50KB) */
|
|
19396
19549
|
static MAX_ACCUMULATED_BUFFER = 5e4;
|
|
19397
19550
|
currentTurnScope = null;
|
|
@@ -19413,15 +19566,13 @@ var init_provider_cli_adapter = __esm({
|
|
|
19413
19566
|
return text.slice(start);
|
|
19414
19567
|
}
|
|
19415
19568
|
buildParseInput(baseMessages, partialResponse, scope) {
|
|
19416
|
-
const buffer = scope ? this.sliceFromOffset(this.
|
|
19569
|
+
const buffer = scope ? this.sliceFromOffset(this.accumulatedBuffer, scope.bufferStart) || this.accumulatedBuffer : this.accumulatedBuffer;
|
|
19417
19570
|
const rawBuffer = scope ? this.sliceFromOffset(this.accumulatedRawBuffer, scope.rawBufferStart) || this.accumulatedRawBuffer : this.accumulatedRawBuffer;
|
|
19418
|
-
const terminalHistory = scope ? this.sliceFromOffset(this.terminalHistory, scope.terminalHistoryStart) || this.terminalHistory : this.terminalHistory;
|
|
19419
19571
|
return {
|
|
19420
19572
|
buffer,
|
|
19421
19573
|
rawBuffer,
|
|
19422
19574
|
recentBuffer: buffer.slice(-1e3) || this.recentOutputBuffer,
|
|
19423
19575
|
screenText: this.terminalScreen.getText(),
|
|
19424
|
-
terminalHistory,
|
|
19425
19576
|
messages: [...baseMessages],
|
|
19426
19577
|
partialResponse
|
|
19427
19578
|
};
|
|
@@ -19476,12 +19627,12 @@ var init_provider_cli_adapter = __esm({
|
|
|
19476
19627
|
if (this.ptyProcess) return;
|
|
19477
19628
|
const { spawn: spawnConfig } = this.provider;
|
|
19478
19629
|
const binaryPath = findBinary(spawnConfig.command);
|
|
19479
|
-
const isWin =
|
|
19630
|
+
const isWin = os14.platform() === "win32";
|
|
19480
19631
|
const allArgs = [...spawnConfig.args, ...this.extraArgs];
|
|
19481
19632
|
LOG.info("CLI", `[${this.cliType}] Spawning in ${this.workingDir}`);
|
|
19482
19633
|
let shellCmd;
|
|
19483
19634
|
let shellArgs;
|
|
19484
|
-
const useShellUnix = !isWin && (!!spawnConfig.shell || !
|
|
19635
|
+
const useShellUnix = !isWin && (!!spawnConfig.shell || !path10.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
19485
19636
|
const useShell = isWin ? !!spawnConfig.shell : useShellUnix;
|
|
19486
19637
|
if (useShell) {
|
|
19487
19638
|
if (!spawnConfig.shell && !isWin) {
|
|
@@ -19499,13 +19650,10 @@ var init_provider_cli_adapter = __esm({
|
|
|
19499
19650
|
shellArgs = allArgs;
|
|
19500
19651
|
}
|
|
19501
19652
|
const ptyOpts = {
|
|
19502
|
-
cols:
|
|
19503
|
-
rows:
|
|
19653
|
+
cols: 100,
|
|
19654
|
+
rows: 30,
|
|
19504
19655
|
cwd: this.workingDir,
|
|
19505
|
-
env:
|
|
19506
|
-
...process.env,
|
|
19507
|
-
...spawnConfig.env
|
|
19508
|
-
}
|
|
19656
|
+
env: buildCliSpawnEnv(process.env, spawnConfig.env)
|
|
19509
19657
|
};
|
|
19510
19658
|
try {
|
|
19511
19659
|
this.ptyProcess = this.transportFactory.spawn(shellCmd, shellArgs, ptyOpts);
|
|
@@ -19523,8 +19671,8 @@ var init_provider_cli_adapter = __esm({
|
|
|
19523
19671
|
}
|
|
19524
19672
|
this.ptyProcess.onData((data) => {
|
|
19525
19673
|
if (Date.now() < this.resizeSuppressUntil) return;
|
|
19526
|
-
if (
|
|
19527
|
-
this.
|
|
19674
|
+
if (!this.ptyProcess?.terminalQueriesHandled) {
|
|
19675
|
+
this.respondToTerminalQueries(data);
|
|
19528
19676
|
}
|
|
19529
19677
|
this.pendingOutputParseBuffer += data;
|
|
19530
19678
|
if (!this.pendingOutputParseTimer) {
|
|
@@ -19559,8 +19707,8 @@ var init_provider_cli_adapter = __esm({
|
|
|
19559
19707
|
this.spawnAt = Date.now();
|
|
19560
19708
|
this.startupParseGate = true;
|
|
19561
19709
|
this.startupBuffer = "";
|
|
19562
|
-
this.terminalScreen.reset(
|
|
19563
|
-
this.
|
|
19710
|
+
this.terminalScreen.reset(30, 100);
|
|
19711
|
+
this.pendingTerminalQueryTail = "";
|
|
19564
19712
|
this.currentTurnScope = null;
|
|
19565
19713
|
this.ready = false;
|
|
19566
19714
|
await this.ptyProcess.ready;
|
|
@@ -19570,7 +19718,6 @@ var init_provider_cli_adapter = __esm({
|
|
|
19570
19718
|
// ─── Output Handling ────────────────────────────
|
|
19571
19719
|
handleOutput(rawData) {
|
|
19572
19720
|
this.terminalScreen.write(rawData);
|
|
19573
|
-
this.terminalHistory = mergeTerminalHistory(this.terminalHistory, this.terminalScreen.getText());
|
|
19574
19721
|
const cleanData = sanitizeTerminalText(rawData);
|
|
19575
19722
|
if (this.isWaitingForResponse && cleanData) {
|
|
19576
19723
|
this.responseBuffer = (this.responseBuffer + cleanData).slice(-8e3);
|
|
@@ -19846,8 +19993,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
19846
19993
|
status: this.currentStatus,
|
|
19847
19994
|
messages: [...this.committedMessages],
|
|
19848
19995
|
workingDir: this.workingDir,
|
|
19849
|
-
activeModal: this.activeModal
|
|
19850
|
-
terminalHistory: this.terminalHistory
|
|
19996
|
+
activeModal: this.activeModal
|
|
19851
19997
|
};
|
|
19852
19998
|
}
|
|
19853
19999
|
/**
|
|
@@ -19865,7 +20011,6 @@ var init_provider_cli_adapter = __esm({
|
|
|
19865
20011
|
id: parsed.id || "cli_session",
|
|
19866
20012
|
status: parsed.status || this.currentStatus,
|
|
19867
20013
|
title: parsed.title || this.cliName,
|
|
19868
|
-
terminalHistory: this.terminalHistory,
|
|
19869
20014
|
messages: parsed.messages,
|
|
19870
20015
|
activeModal: parsed.activeModal ?? this.activeModal
|
|
19871
20016
|
};
|
|
@@ -19875,7 +20020,6 @@ var init_provider_cli_adapter = __esm({
|
|
|
19875
20020
|
id: "cli_session",
|
|
19876
20021
|
status: this.currentStatus,
|
|
19877
20022
|
title: this.cliName,
|
|
19878
|
-
terminalHistory: this.terminalHistory,
|
|
19879
20023
|
messages: messages.slice(-50).map((message, index) => ({
|
|
19880
20024
|
id: `msg_${index}`,
|
|
19881
20025
|
role: message.role,
|
|
@@ -19943,10 +20087,9 @@ ${data.message || ""}`.trim();
|
|
|
19943
20087
|
prompt: text,
|
|
19944
20088
|
startedAt: Date.now(),
|
|
19945
20089
|
bufferStart: this.accumulatedBuffer.length,
|
|
19946
|
-
rawBufferStart: this.accumulatedRawBuffer.length
|
|
19947
|
-
terminalHistoryStart: this.terminalHistory.length
|
|
20090
|
+
rawBufferStart: this.accumulatedRawBuffer.length
|
|
19948
20091
|
};
|
|
19949
|
-
LOG.info("CLI", `[${this.cliType}] sendMessage turn scope buffer=${this.currentTurnScope.bufferStart} raw=${this.currentTurnScope.rawBufferStart}
|
|
20092
|
+
LOG.info("CLI", `[${this.cliType}] sendMessage turn scope buffer=${this.currentTurnScope.bufferStart} raw=${this.currentTurnScope.rawBufferStart} prompt=${JSON.stringify(text).slice(0, 120)}`);
|
|
19950
20093
|
this.submitRetryUsed = false;
|
|
19951
20094
|
this.submitRetryPromptSnippet = extractPromptRetrySnippet(text);
|
|
19952
20095
|
const normalizedPromptSnippet = normalizePromptText(this.submitRetryPromptSnippet);
|
|
@@ -20131,6 +20274,7 @@ ${data.message || ""}`.trim();
|
|
|
20131
20274
|
this.pendingOutputParseTimer = null;
|
|
20132
20275
|
}
|
|
20133
20276
|
this.pendingOutputParseBuffer = "";
|
|
20277
|
+
this.pendingTerminalQueryTail = "";
|
|
20134
20278
|
if (this.ptyOutputFlushTimer) {
|
|
20135
20279
|
clearTimeout(this.ptyOutputFlushTimer);
|
|
20136
20280
|
this.ptyOutputFlushTimer = null;
|
|
@@ -20170,6 +20314,7 @@ ${data.message || ""}`.trim();
|
|
|
20170
20314
|
this.pendingOutputParseTimer = null;
|
|
20171
20315
|
}
|
|
20172
20316
|
this.pendingOutputParseBuffer = "";
|
|
20317
|
+
this.pendingTerminalQueryTail = "";
|
|
20173
20318
|
if (this.ptyOutputFlushTimer) {
|
|
20174
20319
|
clearTimeout(this.ptyOutputFlushTimer);
|
|
20175
20320
|
this.ptyOutputFlushTimer = null;
|
|
@@ -20196,7 +20341,6 @@ ${data.message || ""}`.trim();
|
|
|
20196
20341
|
this.syncMessageViews();
|
|
20197
20342
|
this.accumulatedBuffer = "";
|
|
20198
20343
|
this.accumulatedRawBuffer = "";
|
|
20199
|
-
this.terminalHistory = "";
|
|
20200
20344
|
this.currentTurnScope = null;
|
|
20201
20345
|
this.submitRetryUsed = false;
|
|
20202
20346
|
this.submitRetryPromptSnippet = "";
|
|
@@ -20205,6 +20349,7 @@ ${data.message || ""}`.trim();
|
|
|
20205
20349
|
this.pendingOutputParseTimer = null;
|
|
20206
20350
|
}
|
|
20207
20351
|
this.pendingOutputParseBuffer = "";
|
|
20352
|
+
this.pendingTerminalQueryTail = "";
|
|
20208
20353
|
if (this.ptyOutputFlushTimer) {
|
|
20209
20354
|
clearTimeout(this.ptyOutputFlushTimer);
|
|
20210
20355
|
this.ptyOutputFlushTimer = null;
|
|
@@ -20266,7 +20411,6 @@ ${data.message || ""}`.trim();
|
|
|
20266
20411
|
structuredMessages: this.structuredMessages.slice(-20),
|
|
20267
20412
|
messageCount: this.committedMessages.length,
|
|
20268
20413
|
screenText: sanitizeTerminalText(this.terminalScreen.getText()).slice(-4e3),
|
|
20269
|
-
terminalHistory: this.terminalHistory.slice(-8e3),
|
|
20270
20414
|
currentTurnScope: this.currentTurnScope,
|
|
20271
20415
|
startupBuffer: this.startupBuffer.slice(-4e3),
|
|
20272
20416
|
recentOutputBuffer: this.recentOutputBuffer.slice(-500),
|
|
@@ -20294,6 +20438,20 @@ ${data.message || ""}`.trim();
|
|
|
20294
20438
|
ptyAlive: !!this.ptyProcess
|
|
20295
20439
|
};
|
|
20296
20440
|
}
|
|
20441
|
+
respondToTerminalQueries(data) {
|
|
20442
|
+
if (!this.ptyProcess || !data) return;
|
|
20443
|
+
const combined = this.pendingTerminalQueryTail + data;
|
|
20444
|
+
const regex = /\x1b\[(\?)?6n/g;
|
|
20445
|
+
let match;
|
|
20446
|
+
while ((match = regex.exec(combined)) !== null) {
|
|
20447
|
+
const cursor = this.terminalScreen.getCursorPosition();
|
|
20448
|
+
const row = Math.max(1, (cursor.row | 0) + 1);
|
|
20449
|
+
const col = Math.max(1, (cursor.col | 0) + 1);
|
|
20450
|
+
const response = match[1] ? `\x1B[?${row};${col}R` : `\x1B[${row};${col}R`;
|
|
20451
|
+
this.ptyProcess.write(response);
|
|
20452
|
+
}
|
|
20453
|
+
this.pendingTerminalQueryTail = computeTerminalQueryTail(combined);
|
|
20454
|
+
}
|
|
20297
20455
|
};
|
|
20298
20456
|
}
|
|
20299
20457
|
});
|
|
@@ -20315,7 +20473,7 @@ var init_cli_provider_instance = __esm({
|
|
|
20315
20473
|
this.cliArgs = cliArgs;
|
|
20316
20474
|
this.type = provider.type;
|
|
20317
20475
|
this.instanceId = instanceId || crypto3.randomUUID();
|
|
20318
|
-
this.presentationMode = "
|
|
20476
|
+
this.presentationMode = "chat";
|
|
20319
20477
|
this.adapter = new ProviderCliAdapter(provider, workingDir, cliArgs, transportFactory);
|
|
20320
20478
|
this.monitor = new StatusMonitor();
|
|
20321
20479
|
this.historyWriter = new ChatHistoryWriter();
|
|
@@ -20362,14 +20520,6 @@ var init_cli_provider_instance = __esm({
|
|
|
20362
20520
|
const parsedStatus = this.adapter.getScriptParsedStatus?.() || null;
|
|
20363
20521
|
const runtime = this.adapter.getRuntimeMetadata();
|
|
20364
20522
|
const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
|
|
20365
|
-
if (adapterStatus.terminalHistory?.trim()) {
|
|
20366
|
-
this.historyWriter.appendTerminalHistory(
|
|
20367
|
-
this.type,
|
|
20368
|
-
adapterStatus.terminalHistory,
|
|
20369
|
-
`${this.provider.name} \xB7 ${dirName}`,
|
|
20370
|
-
this.instanceId
|
|
20371
|
-
);
|
|
20372
|
-
}
|
|
20373
20523
|
return {
|
|
20374
20524
|
type: this.type,
|
|
20375
20525
|
name: this.provider.name,
|
|
@@ -20382,7 +20532,6 @@ var init_cli_provider_instance = __esm({
|
|
|
20382
20532
|
status: parsedStatus?.status || adapterStatus.status,
|
|
20383
20533
|
messages: Array.isArray(parsedStatus?.messages) ? parsedStatus.messages : [],
|
|
20384
20534
|
activeModal: parsedStatus?.activeModal ?? adapterStatus.activeModal,
|
|
20385
|
-
terminalHistory: adapterStatus.terminalHistory,
|
|
20386
20535
|
inputContent: ""
|
|
20387
20536
|
},
|
|
20388
20537
|
workspace: this.workingDir,
|
|
@@ -20807,10 +20956,10 @@ function mergeDefs(...defs) {
|
|
|
20807
20956
|
function cloneDef(schema) {
|
|
20808
20957
|
return mergeDefs(schema._zod.def);
|
|
20809
20958
|
}
|
|
20810
|
-
function getElementAtPath(obj,
|
|
20811
|
-
if (!
|
|
20959
|
+
function getElementAtPath(obj, path19) {
|
|
20960
|
+
if (!path19)
|
|
20812
20961
|
return obj;
|
|
20813
|
-
return
|
|
20962
|
+
return path19.reduce((acc, key) => acc?.[key], obj);
|
|
20814
20963
|
}
|
|
20815
20964
|
function promiseAllObject(promisesObj) {
|
|
20816
20965
|
const keys = Object.keys(promisesObj);
|
|
@@ -21122,11 +21271,11 @@ function aborted(x, startIndex = 0) {
|
|
|
21122
21271
|
}
|
|
21123
21272
|
return false;
|
|
21124
21273
|
}
|
|
21125
|
-
function prefixIssues(
|
|
21274
|
+
function prefixIssues(path19, issues) {
|
|
21126
21275
|
return issues.map((iss) => {
|
|
21127
21276
|
var _a2;
|
|
21128
21277
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
21129
|
-
iss.path.unshift(
|
|
21278
|
+
iss.path.unshift(path19);
|
|
21130
21279
|
return iss;
|
|
21131
21280
|
});
|
|
21132
21281
|
}
|
|
@@ -21369,7 +21518,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
21369
21518
|
}
|
|
21370
21519
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
21371
21520
|
const result = { errors: [] };
|
|
21372
|
-
const processError = (error49,
|
|
21521
|
+
const processError = (error49, path19 = []) => {
|
|
21373
21522
|
var _a2, _b;
|
|
21374
21523
|
for (const issue2 of error49.issues) {
|
|
21375
21524
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -21379,7 +21528,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
21379
21528
|
} else if (issue2.code === "invalid_element") {
|
|
21380
21529
|
processError({ issues: issue2.issues }, issue2.path);
|
|
21381
21530
|
} else {
|
|
21382
|
-
const fullpath = [...
|
|
21531
|
+
const fullpath = [...path19, ...issue2.path];
|
|
21383
21532
|
if (fullpath.length === 0) {
|
|
21384
21533
|
result.errors.push(mapper(issue2));
|
|
21385
21534
|
continue;
|
|
@@ -21411,8 +21560,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
21411
21560
|
}
|
|
21412
21561
|
function toDotPath(_path) {
|
|
21413
21562
|
const segs = [];
|
|
21414
|
-
const
|
|
21415
|
-
for (const seg of
|
|
21563
|
+
const path19 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
21564
|
+
for (const seg of path19) {
|
|
21416
21565
|
if (typeof seg === "number")
|
|
21417
21566
|
segs.push(`[${seg}]`);
|
|
21418
21567
|
else if (typeof seg === "symbol")
|
|
@@ -34176,13 +34325,13 @@ function resolveRef(ref, ctx) {
|
|
|
34176
34325
|
if (!ref.startsWith("#")) {
|
|
34177
34326
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
34178
34327
|
}
|
|
34179
|
-
const
|
|
34180
|
-
if (
|
|
34328
|
+
const path19 = ref.slice(1).split("/").filter(Boolean);
|
|
34329
|
+
if (path19.length === 0) {
|
|
34181
34330
|
return ctx.rootSchema;
|
|
34182
34331
|
}
|
|
34183
34332
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
34184
|
-
if (
|
|
34185
|
-
const key =
|
|
34333
|
+
if (path19[0] === defsKey) {
|
|
34334
|
+
const key = path19[1];
|
|
34186
34335
|
if (!key || !ctx.defs[key]) {
|
|
34187
34336
|
throw new Error(`Reference not found: ${ref}`);
|
|
34188
34337
|
}
|
|
@@ -36867,12 +37016,12 @@ var init_contracts = __esm({
|
|
|
36867
37016
|
});
|
|
36868
37017
|
|
|
36869
37018
|
// ../../oss/packages/daemon-core/src/providers/acp-provider-instance.ts
|
|
36870
|
-
var import_stream,
|
|
37019
|
+
var import_stream, import_child_process8, AcpProviderInstance;
|
|
36871
37020
|
var init_acp_provider_instance = __esm({
|
|
36872
37021
|
"../../oss/packages/daemon-core/src/providers/acp-provider-instance.ts"() {
|
|
36873
37022
|
"use strict";
|
|
36874
37023
|
import_stream = require("stream");
|
|
36875
|
-
|
|
37024
|
+
import_child_process8 = require("child_process");
|
|
36876
37025
|
init_acp();
|
|
36877
37026
|
init_contracts();
|
|
36878
37027
|
init_status_monitor();
|
|
@@ -37196,7 +37345,7 @@ var init_acp_provider_instance = __esm({
|
|
|
37196
37345
|
this.errorMessage = null;
|
|
37197
37346
|
this.errorReason = null;
|
|
37198
37347
|
this.stderrBuffer = [];
|
|
37199
|
-
this.process = (0,
|
|
37348
|
+
this.process = (0, import_child_process8.spawn)(command, args, {
|
|
37200
37349
|
cwd: this.workingDir,
|
|
37201
37350
|
env,
|
|
37202
37351
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -37768,12 +37917,12 @@ function colorize(color, text) {
|
|
|
37768
37917
|
const fn2 = chalkApi?.[color];
|
|
37769
37918
|
return typeof fn2 === "function" ? fn2(text) : text;
|
|
37770
37919
|
}
|
|
37771
|
-
var
|
|
37920
|
+
var os15, path11, crypto4, import_chalk, chalkApi, DaemonCliManager;
|
|
37772
37921
|
var init_cli_manager = __esm({
|
|
37773
37922
|
"../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
|
|
37774
37923
|
"use strict";
|
|
37775
|
-
|
|
37776
|
-
|
|
37924
|
+
os15 = __toESM(require("os"));
|
|
37925
|
+
path11 = __toESM(require("path"));
|
|
37777
37926
|
crypto4 = __toESM(require("crypto"));
|
|
37778
37927
|
import_chalk = __toESM(require("chalk"));
|
|
37779
37928
|
init_provider_cli_adapter();
|
|
@@ -37896,7 +38045,7 @@ var init_cli_manager = __esm({
|
|
|
37896
38045
|
async startSession(cliType, workingDir, cliArgs, initialModel) {
|
|
37897
38046
|
const trimmed = (workingDir || "").trim();
|
|
37898
38047
|
if (!trimmed) throw new Error("working directory required");
|
|
37899
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/,
|
|
38048
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os15.homedir()) : path11.resolve(trimmed);
|
|
37900
38049
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
37901
38050
|
const provider = this.providerLoader.getByAlias(cliType);
|
|
37902
38051
|
const key = crypto4.randomUUID();
|
|
@@ -39152,7 +39301,7 @@ var init_provider_instance_manager = __esm({
|
|
|
39152
39301
|
// ../../oss/packages/daemon-core/src/providers/version-archive.ts
|
|
39153
39302
|
function runCommand(cmd, timeout = 1e4) {
|
|
39154
39303
|
try {
|
|
39155
|
-
return (0,
|
|
39304
|
+
return (0, import_child_process9.execSync)(cmd, {
|
|
39156
39305
|
encoding: "utf-8",
|
|
39157
39306
|
timeout,
|
|
39158
39307
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -39184,19 +39333,19 @@ function getVersion(binary, versionCommand) {
|
|
|
39184
39333
|
function checkPathExists2(paths) {
|
|
39185
39334
|
for (const p of paths) {
|
|
39186
39335
|
if (p.includes("*")) {
|
|
39187
|
-
const home =
|
|
39188
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
39189
|
-
if (
|
|
39336
|
+
const home = os16.homedir();
|
|
39337
|
+
const resolved = p.replace(/\*/g, home.split(path12.sep).pop() || "");
|
|
39338
|
+
if (fs10.existsSync(resolved)) return resolved;
|
|
39190
39339
|
} else {
|
|
39191
|
-
if (
|
|
39340
|
+
if (fs10.existsSync(p)) return p;
|
|
39192
39341
|
}
|
|
39193
39342
|
}
|
|
39194
39343
|
return null;
|
|
39195
39344
|
}
|
|
39196
39345
|
function getMacAppVersion(appPath) {
|
|
39197
39346
|
if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
39198
|
-
const plistPath =
|
|
39199
|
-
if (!
|
|
39347
|
+
const plistPath = path12.join(appPath, "Contents", "Info.plist");
|
|
39348
|
+
if (!fs10.existsSync(plistPath)) return null;
|
|
39200
39349
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
39201
39350
|
return raw || null;
|
|
39202
39351
|
}
|
|
@@ -39222,8 +39371,8 @@ async function detectAllVersions(loader, archive) {
|
|
|
39222
39371
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
39223
39372
|
let resolvedBin = cliBin;
|
|
39224
39373
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
39225
|
-
const bundled =
|
|
39226
|
-
if (provider.cli &&
|
|
39374
|
+
const bundled = path12.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
39375
|
+
if (provider.cli && fs10.existsSync(bundled)) resolvedBin = bundled;
|
|
39227
39376
|
}
|
|
39228
39377
|
info.installed = !!(appPath || resolvedBin);
|
|
39229
39378
|
info.path = appPath || null;
|
|
@@ -39259,16 +39408,16 @@ async function detectAllVersions(loader, archive) {
|
|
|
39259
39408
|
}
|
|
39260
39409
|
return results;
|
|
39261
39410
|
}
|
|
39262
|
-
var
|
|
39411
|
+
var fs10, path12, os16, import_child_process9, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
|
|
39263
39412
|
var init_version_archive = __esm({
|
|
39264
39413
|
"../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
|
|
39265
39414
|
"use strict";
|
|
39266
|
-
|
|
39267
|
-
|
|
39268
|
-
|
|
39269
|
-
|
|
39415
|
+
fs10 = __toESM(require("fs"));
|
|
39416
|
+
path12 = __toESM(require("path"));
|
|
39417
|
+
os16 = __toESM(require("os"));
|
|
39418
|
+
import_child_process9 = require("child_process");
|
|
39270
39419
|
import_os3 = require("os");
|
|
39271
|
-
ARCHIVE_PATH =
|
|
39420
|
+
ARCHIVE_PATH = path12.join(os16.homedir(), ".adhdev", "version-history.json");
|
|
39272
39421
|
MAX_ENTRIES_PER_PROVIDER = 20;
|
|
39273
39422
|
VersionArchive = class {
|
|
39274
39423
|
history = {};
|
|
@@ -39277,8 +39426,8 @@ var init_version_archive = __esm({
|
|
|
39277
39426
|
}
|
|
39278
39427
|
load() {
|
|
39279
39428
|
try {
|
|
39280
|
-
if (
|
|
39281
|
-
this.history = JSON.parse(
|
|
39429
|
+
if (fs10.existsSync(ARCHIVE_PATH)) {
|
|
39430
|
+
this.history = JSON.parse(fs10.readFileSync(ARCHIVE_PATH, "utf-8"));
|
|
39282
39431
|
}
|
|
39283
39432
|
} catch {
|
|
39284
39433
|
this.history = {};
|
|
@@ -39315,8 +39464,8 @@ var init_version_archive = __esm({
|
|
|
39315
39464
|
}
|
|
39316
39465
|
save() {
|
|
39317
39466
|
try {
|
|
39318
|
-
|
|
39319
|
-
|
|
39467
|
+
fs10.mkdirSync(path12.dirname(ARCHIVE_PATH), { recursive: true });
|
|
39468
|
+
fs10.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
39320
39469
|
} catch {
|
|
39321
39470
|
}
|
|
39322
39471
|
}
|
|
@@ -39836,18 +39985,18 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
39836
39985
|
return;
|
|
39837
39986
|
}
|
|
39838
39987
|
let scriptsPath = "";
|
|
39839
|
-
const directScripts =
|
|
39840
|
-
if (
|
|
39988
|
+
const directScripts = path13.join(dir, "scripts.js");
|
|
39989
|
+
if (fs11.existsSync(directScripts)) {
|
|
39841
39990
|
scriptsPath = directScripts;
|
|
39842
39991
|
} else {
|
|
39843
|
-
const scriptsDir =
|
|
39844
|
-
if (
|
|
39845
|
-
const versions =
|
|
39846
|
-
return
|
|
39992
|
+
const scriptsDir = path13.join(dir, "scripts");
|
|
39993
|
+
if (fs11.existsSync(scriptsDir)) {
|
|
39994
|
+
const versions = fs11.readdirSync(scriptsDir).filter((d) => {
|
|
39995
|
+
return fs11.statSync(path13.join(scriptsDir, d)).isDirectory();
|
|
39847
39996
|
}).sort().reverse();
|
|
39848
39997
|
for (const ver of versions) {
|
|
39849
|
-
const p =
|
|
39850
|
-
if (
|
|
39998
|
+
const p = path13.join(scriptsDir, ver, "scripts.js");
|
|
39999
|
+
if (fs11.existsSync(p)) {
|
|
39851
40000
|
scriptsPath = p;
|
|
39852
40001
|
break;
|
|
39853
40002
|
}
|
|
@@ -39859,7 +40008,7 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
39859
40008
|
return;
|
|
39860
40009
|
}
|
|
39861
40010
|
try {
|
|
39862
|
-
const source =
|
|
40011
|
+
const source = fs11.readFileSync(scriptsPath, "utf-8");
|
|
39863
40012
|
const hints = {};
|
|
39864
40013
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
39865
40014
|
let match;
|
|
@@ -40662,12 +40811,12 @@ async function handleDomContext(ctx, type, req, res) {
|
|
|
40662
40811
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
40663
40812
|
}
|
|
40664
40813
|
}
|
|
40665
|
-
var
|
|
40814
|
+
var fs11, path13;
|
|
40666
40815
|
var init_dev_cdp_handlers = __esm({
|
|
40667
40816
|
"../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
|
|
40668
40817
|
"use strict";
|
|
40669
|
-
|
|
40670
|
-
|
|
40818
|
+
fs11 = __toESM(require("fs"));
|
|
40819
|
+
path13 = __toESM(require("path"));
|
|
40671
40820
|
init_logger();
|
|
40672
40821
|
}
|
|
40673
40822
|
});
|
|
@@ -40929,45 +41078,45 @@ function resolveAutoImplReference(ctx, category, requestedReference, targetType)
|
|
|
40929
41078
|
return fallback?.type || null;
|
|
40930
41079
|
}
|
|
40931
41080
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
40932
|
-
if (!
|
|
40933
|
-
const versions =
|
|
41081
|
+
if (!fs12.existsSync(scriptsDir)) return null;
|
|
41082
|
+
const versions = fs12.readdirSync(scriptsDir).filter((d) => {
|
|
40934
41083
|
try {
|
|
40935
|
-
return
|
|
41084
|
+
return fs12.statSync(path14.join(scriptsDir, d)).isDirectory();
|
|
40936
41085
|
} catch {
|
|
40937
41086
|
return false;
|
|
40938
41087
|
}
|
|
40939
41088
|
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
40940
41089
|
if (versions.length === 0) return null;
|
|
40941
|
-
return
|
|
41090
|
+
return path14.join(scriptsDir, versions[0]);
|
|
40942
41091
|
}
|
|
40943
41092
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
40944
|
-
const canonicalUserDir =
|
|
40945
|
-
const desiredDir = requestedDir ?
|
|
40946
|
-
const upstreamRoot =
|
|
40947
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
41093
|
+
const canonicalUserDir = path14.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
41094
|
+
const desiredDir = requestedDir ? path14.resolve(requestedDir) : canonicalUserDir;
|
|
41095
|
+
const upstreamRoot = path14.resolve(ctx.providerLoader.getUpstreamDir());
|
|
41096
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path14.sep}`)) {
|
|
40948
41097
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
40949
41098
|
}
|
|
40950
|
-
if (
|
|
41099
|
+
if (path14.basename(desiredDir) !== type) {
|
|
40951
41100
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
40952
41101
|
}
|
|
40953
41102
|
const sourceDir = ctx.findProviderDir(type);
|
|
40954
41103
|
if (!sourceDir) {
|
|
40955
41104
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
40956
41105
|
}
|
|
40957
|
-
if (!
|
|
40958
|
-
|
|
40959
|
-
|
|
41106
|
+
if (!fs12.existsSync(desiredDir)) {
|
|
41107
|
+
fs12.mkdirSync(path14.dirname(desiredDir), { recursive: true });
|
|
41108
|
+
fs12.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
40960
41109
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
40961
41110
|
}
|
|
40962
|
-
const providerJson =
|
|
40963
|
-
if (!
|
|
41111
|
+
const providerJson = path14.join(desiredDir, "provider.json");
|
|
41112
|
+
if (!fs12.existsSync(providerJson)) {
|
|
40964
41113
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
40965
41114
|
}
|
|
40966
41115
|
try {
|
|
40967
|
-
const providerData = JSON.parse(
|
|
41116
|
+
const providerData = JSON.parse(fs12.readFileSync(providerJson, "utf-8"));
|
|
40968
41117
|
if (providerData.disableUpstream !== true) {
|
|
40969
41118
|
providerData.disableUpstream = true;
|
|
40970
|
-
|
|
41119
|
+
fs12.writeFileSync(providerJson, JSON.stringify(providerData, null, 2));
|
|
40971
41120
|
}
|
|
40972
41121
|
} catch (error48) {
|
|
40973
41122
|
return {
|
|
@@ -40980,15 +41129,15 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
40980
41129
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
40981
41130
|
if (!referenceType) return {};
|
|
40982
41131
|
const refDir = ctx.findProviderDir(referenceType);
|
|
40983
|
-
if (!refDir || !
|
|
41132
|
+
if (!refDir || !fs12.existsSync(refDir)) return {};
|
|
40984
41133
|
const referenceScripts = {};
|
|
40985
|
-
const scriptsDir =
|
|
41134
|
+
const scriptsDir = path14.join(refDir, "scripts");
|
|
40986
41135
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
40987
41136
|
if (!latestDir) return referenceScripts;
|
|
40988
|
-
for (const file2 of
|
|
41137
|
+
for (const file2 of fs12.readdirSync(latestDir)) {
|
|
40989
41138
|
if (!file2.endsWith(".js")) continue;
|
|
40990
41139
|
try {
|
|
40991
|
-
referenceScripts[file2] =
|
|
41140
|
+
referenceScripts[file2] = fs12.readFileSync(path14.join(latestDir, file2), "utf-8");
|
|
40992
41141
|
} catch {
|
|
40993
41142
|
}
|
|
40994
41143
|
}
|
|
@@ -41039,16 +41188,16 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41039
41188
|
});
|
|
41040
41189
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
41041
41190
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference);
|
|
41042
|
-
const tmpDir =
|
|
41043
|
-
if (!
|
|
41044
|
-
const promptFile =
|
|
41045
|
-
|
|
41191
|
+
const tmpDir = path14.join(os17.tmpdir(), "adhdev-autoimpl");
|
|
41192
|
+
if (!fs12.existsSync(tmpDir)) fs12.mkdirSync(tmpDir, { recursive: true });
|
|
41193
|
+
const promptFile = path14.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
41194
|
+
fs12.writeFileSync(promptFile, prompt, "utf-8");
|
|
41046
41195
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
41047
41196
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
41048
|
-
const
|
|
41049
|
-
if (!
|
|
41197
|
+
const spawn5 = agentProvider?.spawn;
|
|
41198
|
+
if (!spawn5?.command) {
|
|
41050
41199
|
try {
|
|
41051
|
-
|
|
41200
|
+
fs12.unlinkSync(promptFile);
|
|
41052
41201
|
} catch {
|
|
41053
41202
|
}
|
|
41054
41203
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -41056,21 +41205,21 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41056
41205
|
}
|
|
41057
41206
|
const agentCategory = agentProvider?.category;
|
|
41058
41207
|
if (agentCategory === "acp") {
|
|
41059
|
-
sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${
|
|
41208
|
+
sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${spawn5.command} ${(spawn5.args || []).join(" ")}` } });
|
|
41060
41209
|
ctx.autoImplStatus = { running: true, type, progress: [] };
|
|
41061
41210
|
const { ClientSideConnection: ClientSideConnection2, ndJsonStream: ndJsonStream2, PROTOCOL_VERSION: PROTOCOL_VERSION2 } = await Promise.resolve().then(() => (init_acp(), acp_exports));
|
|
41062
41211
|
const { Readable: Readable3, Writable: Writable2 } = await import("stream");
|
|
41063
41212
|
const { spawn: spawnFn2 } = await import("child_process");
|
|
41064
|
-
const acpArgs = [...
|
|
41213
|
+
const acpArgs = [...spawn5.args || []];
|
|
41065
41214
|
if (model) {
|
|
41066
41215
|
acpArgs.push("--model", model);
|
|
41067
41216
|
ctx.log(`Auto-implement ACP using model: ${model}`);
|
|
41068
41217
|
}
|
|
41069
|
-
const child2 = spawnFn2(
|
|
41218
|
+
const child2 = spawnFn2(spawn5.command, acpArgs, {
|
|
41070
41219
|
cwd: providerDir,
|
|
41071
41220
|
stdio: ["pipe", "pipe", "pipe"],
|
|
41072
|
-
shell:
|
|
41073
|
-
env: { ...process.env, ...
|
|
41221
|
+
shell: spawn5.shell ?? false,
|
|
41222
|
+
env: { ...process.env, ...spawn5.env || {} }
|
|
41074
41223
|
});
|
|
41075
41224
|
ctx.autoImplProcess = child2;
|
|
41076
41225
|
child2.stderr?.on("data", (d) => {
|
|
@@ -41149,7 +41298,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41149
41298
|
} catch {
|
|
41150
41299
|
}
|
|
41151
41300
|
try {
|
|
41152
|
-
|
|
41301
|
+
fs12.unlinkSync(promptFile);
|
|
41153
41302
|
} catch {
|
|
41154
41303
|
}
|
|
41155
41304
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -41180,7 +41329,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41180
41329
|
ctx.json(res, 202, {
|
|
41181
41330
|
started: true,
|
|
41182
41331
|
type,
|
|
41183
|
-
agent:
|
|
41332
|
+
agent: spawn5.command,
|
|
41184
41333
|
functions,
|
|
41185
41334
|
providerDir,
|
|
41186
41335
|
message: "ACP Auto-implement started. Connect to SSE for progress.",
|
|
@@ -41188,11 +41337,11 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41188
41337
|
});
|
|
41189
41338
|
return;
|
|
41190
41339
|
}
|
|
41191
|
-
const command =
|
|
41340
|
+
const command = spawn5.command;
|
|
41192
41341
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
41193
|
-
const baseArgs = [...
|
|
41342
|
+
const baseArgs = [...spawn5.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
41194
41343
|
let shellCmd;
|
|
41195
|
-
const isWin =
|
|
41344
|
+
const isWin = os17.platform() === "win32";
|
|
41196
41345
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
41197
41346
|
if (command === "claude") {
|
|
41198
41347
|
const args = [...baseArgs, "--dangerously-skip-permissions"];
|
|
@@ -41235,13 +41384,13 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41235
41384
|
try {
|
|
41236
41385
|
const pty3 = require("node-pty");
|
|
41237
41386
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
41238
|
-
const isWin2 =
|
|
41387
|
+
const isWin2 = os17.platform() === "win32";
|
|
41239
41388
|
child = pty3.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
41240
41389
|
name: "xterm-256color",
|
|
41241
41390
|
cols: 120,
|
|
41242
41391
|
rows: 40,
|
|
41243
41392
|
cwd: providerDir,
|
|
41244
|
-
env: { ...process.env, ...
|
|
41393
|
+
env: { ...process.env, ...spawn5.env || {} }
|
|
41245
41394
|
});
|
|
41246
41395
|
isPty = true;
|
|
41247
41396
|
} catch (err) {
|
|
@@ -41253,7 +41402,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41253
41402
|
stdio: ["pipe", "pipe", "pipe"],
|
|
41254
41403
|
env: {
|
|
41255
41404
|
...process.env,
|
|
41256
|
-
...
|
|
41405
|
+
...spawn5.env || {},
|
|
41257
41406
|
...command === "gemini" ? { SANDBOX: "1", GEMINI_CLI_NO_RELAUNCH: "1" } : {}
|
|
41258
41407
|
}
|
|
41259
41408
|
});
|
|
@@ -41329,7 +41478,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41329
41478
|
} catch {
|
|
41330
41479
|
}
|
|
41331
41480
|
try {
|
|
41332
|
-
|
|
41481
|
+
fs12.unlinkSync(promptFile);
|
|
41333
41482
|
} catch {
|
|
41334
41483
|
}
|
|
41335
41484
|
});
|
|
@@ -41365,7 +41514,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
41365
41514
|
} catch {
|
|
41366
41515
|
}
|
|
41367
41516
|
try {
|
|
41368
|
-
|
|
41517
|
+
fs12.unlinkSync(promptFile);
|
|
41369
41518
|
} catch {
|
|
41370
41519
|
}
|
|
41371
41520
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -41412,7 +41561,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41412
41561
|
setMode: "set_mode.js"
|
|
41413
41562
|
};
|
|
41414
41563
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
41415
|
-
const scriptsDir =
|
|
41564
|
+
const scriptsDir = path14.join(providerDir, "scripts");
|
|
41416
41565
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
41417
41566
|
if (latestScriptsDir) {
|
|
41418
41567
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -41420,10 +41569,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41420
41569
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
41421
41570
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
41422
41571
|
lines.push("");
|
|
41423
|
-
for (const file2 of
|
|
41572
|
+
for (const file2 of fs12.readdirSync(latestScriptsDir)) {
|
|
41424
41573
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
41425
41574
|
try {
|
|
41426
|
-
const content =
|
|
41575
|
+
const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
41427
41576
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
41428
41577
|
lines.push("```javascript");
|
|
41429
41578
|
lines.push(content);
|
|
@@ -41433,14 +41582,14 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41433
41582
|
}
|
|
41434
41583
|
}
|
|
41435
41584
|
}
|
|
41436
|
-
const refFiles =
|
|
41585
|
+
const refFiles = fs12.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
41437
41586
|
if (refFiles.length > 0) {
|
|
41438
41587
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
41439
41588
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
41440
41589
|
lines.push("");
|
|
41441
41590
|
for (const file2 of refFiles) {
|
|
41442
41591
|
try {
|
|
41443
|
-
const content =
|
|
41592
|
+
const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
41444
41593
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
41445
41594
|
lines.push("```javascript");
|
|
41446
41595
|
lines.push(content);
|
|
@@ -41481,11 +41630,11 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41481
41630
|
lines.push("");
|
|
41482
41631
|
}
|
|
41483
41632
|
}
|
|
41484
|
-
const docsDir =
|
|
41633
|
+
const docsDir = path14.join(providerDir, "../../docs");
|
|
41485
41634
|
const loadGuide = (name) => {
|
|
41486
41635
|
try {
|
|
41487
|
-
const p =
|
|
41488
|
-
if (
|
|
41636
|
+
const p = path14.join(docsDir, name);
|
|
41637
|
+
if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
|
|
41489
41638
|
} catch {
|
|
41490
41639
|
}
|
|
41491
41640
|
return null;
|
|
@@ -41658,7 +41807,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41658
41807
|
parseApproval: "parse_approval.js"
|
|
41659
41808
|
};
|
|
41660
41809
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
41661
|
-
const scriptsDir =
|
|
41810
|
+
const scriptsDir = path14.join(providerDir, "scripts");
|
|
41662
41811
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
41663
41812
|
if (latestScriptsDir) {
|
|
41664
41813
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -41666,11 +41815,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41666
41815
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
41667
41816
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
41668
41817
|
lines.push("");
|
|
41669
|
-
for (const file2 of
|
|
41818
|
+
for (const file2 of fs12.readdirSync(latestScriptsDir)) {
|
|
41670
41819
|
if (!file2.endsWith(".js")) continue;
|
|
41671
41820
|
if (!targetFileNames.has(file2)) continue;
|
|
41672
41821
|
try {
|
|
41673
|
-
const content =
|
|
41822
|
+
const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
41674
41823
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
41675
41824
|
lines.push("```javascript");
|
|
41676
41825
|
lines.push(content);
|
|
@@ -41679,14 +41828,14 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41679
41828
|
} catch {
|
|
41680
41829
|
}
|
|
41681
41830
|
}
|
|
41682
|
-
const refFiles =
|
|
41831
|
+
const refFiles = fs12.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
41683
41832
|
if (refFiles.length > 0) {
|
|
41684
41833
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
41685
41834
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
41686
41835
|
lines.push("");
|
|
41687
41836
|
for (const file2 of refFiles) {
|
|
41688
41837
|
try {
|
|
41689
|
-
const content =
|
|
41838
|
+
const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
41690
41839
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
41691
41840
|
lines.push("```javascript");
|
|
41692
41841
|
lines.push(content);
|
|
@@ -41719,11 +41868,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41719
41868
|
lines.push("");
|
|
41720
41869
|
}
|
|
41721
41870
|
}
|
|
41722
|
-
const docsDir =
|
|
41871
|
+
const docsDir = path14.join(providerDir, "../../docs");
|
|
41723
41872
|
const loadGuide = (name) => {
|
|
41724
41873
|
try {
|
|
41725
|
-
const p =
|
|
41726
|
-
if (
|
|
41874
|
+
const p = path14.join(docsDir, name);
|
|
41875
|
+
if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
|
|
41727
41876
|
} catch {
|
|
41728
41877
|
}
|
|
41729
41878
|
return null;
|
|
@@ -41886,25 +42035,25 @@ data: ${JSON.stringify(msg.data)}
|
|
|
41886
42035
|
}
|
|
41887
42036
|
}
|
|
41888
42037
|
}
|
|
41889
|
-
var
|
|
42038
|
+
var fs12, path14, os17;
|
|
41890
42039
|
var init_dev_auto_implement = __esm({
|
|
41891
42040
|
"../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
|
|
41892
42041
|
"use strict";
|
|
41893
|
-
|
|
41894
|
-
|
|
41895
|
-
|
|
42042
|
+
fs12 = __toESM(require("fs"));
|
|
42043
|
+
path14 = __toESM(require("path"));
|
|
42044
|
+
os17 = __toESM(require("os"));
|
|
41896
42045
|
init_dev_server();
|
|
41897
42046
|
}
|
|
41898
42047
|
});
|
|
41899
42048
|
|
|
41900
42049
|
// ../../oss/packages/daemon-core/src/daemon/dev-server.ts
|
|
41901
|
-
var http2,
|
|
42050
|
+
var http2, fs13, path15, DEV_SERVER_PORT, DevServer;
|
|
41902
42051
|
var init_dev_server = __esm({
|
|
41903
42052
|
"../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
|
|
41904
42053
|
"use strict";
|
|
41905
42054
|
http2 = __toESM(require("http"));
|
|
41906
|
-
|
|
41907
|
-
|
|
42055
|
+
fs13 = __toESM(require("fs"));
|
|
42056
|
+
path15 = __toESM(require("path"));
|
|
41908
42057
|
init_scaffold_template();
|
|
41909
42058
|
init_version_archive();
|
|
41910
42059
|
init_logger();
|
|
@@ -42003,8 +42152,8 @@ var init_dev_server = __esm({
|
|
|
42003
42152
|
}
|
|
42004
42153
|
getEndpointList() {
|
|
42005
42154
|
return this.routes.map((r) => {
|
|
42006
|
-
const
|
|
42007
|
-
return `${r.method.padEnd(5)} ${
|
|
42155
|
+
const path19 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
42156
|
+
return `${r.method.padEnd(5)} ${path19}`;
|
|
42008
42157
|
});
|
|
42009
42158
|
}
|
|
42010
42159
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -42105,16 +42254,16 @@ var init_dev_server = __esm({
|
|
|
42105
42254
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
42106
42255
|
return;
|
|
42107
42256
|
}
|
|
42108
|
-
const
|
|
42109
|
-
if (!
|
|
42257
|
+
const spawn5 = provider.spawn;
|
|
42258
|
+
if (!spawn5) {
|
|
42110
42259
|
this.json(res, 400, { error: `Provider ${type} has no spawn config` });
|
|
42111
42260
|
return;
|
|
42112
42261
|
}
|
|
42113
42262
|
const { spawn: spawnFn } = await import("child_process");
|
|
42114
42263
|
const start = Date.now();
|
|
42115
42264
|
try {
|
|
42116
|
-
const child = spawnFn(
|
|
42117
|
-
shell:
|
|
42265
|
+
const child = spawnFn(spawn5.command, [...spawn5.args || []], {
|
|
42266
|
+
shell: spawn5.shell ?? false,
|
|
42118
42267
|
timeout: 5e3,
|
|
42119
42268
|
stdio: ["pipe", "pipe", "pipe"]
|
|
42120
42269
|
});
|
|
@@ -42146,7 +42295,7 @@ var init_dev_server = __esm({
|
|
|
42146
42295
|
const elapsed = Date.now() - start;
|
|
42147
42296
|
this.json(res, 200, {
|
|
42148
42297
|
success: true,
|
|
42149
|
-
command: `${
|
|
42298
|
+
command: `${spawn5.command} ${(spawn5.args || []).join(" ")}`,
|
|
42150
42299
|
elapsed,
|
|
42151
42300
|
stdout: stdout.trim(),
|
|
42152
42301
|
stderr: stderr.trim(),
|
|
@@ -42156,7 +42305,7 @@ var init_dev_server = __esm({
|
|
|
42156
42305
|
const elapsed = Date.now() - start;
|
|
42157
42306
|
this.json(res, 200, {
|
|
42158
42307
|
success: false,
|
|
42159
|
-
command: `${
|
|
42308
|
+
command: `${spawn5.command} ${(spawn5.args || []).join(" ")}`,
|
|
42160
42309
|
elapsed,
|
|
42161
42310
|
error: e.message
|
|
42162
42311
|
});
|
|
@@ -42286,12 +42435,12 @@ var init_dev_server = __esm({
|
|
|
42286
42435
|
// ─── DevConsole SPA ───
|
|
42287
42436
|
getConsoleDistDir() {
|
|
42288
42437
|
const candidates = [
|
|
42289
|
-
|
|
42290
|
-
|
|
42291
|
-
|
|
42438
|
+
path15.resolve(__dirname, "../../web-devconsole/dist"),
|
|
42439
|
+
path15.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
42440
|
+
path15.join(process.cwd(), "packages/web-devconsole/dist")
|
|
42292
42441
|
];
|
|
42293
42442
|
for (const dir of candidates) {
|
|
42294
|
-
if (
|
|
42443
|
+
if (fs13.existsSync(path15.join(dir, "index.html"))) return dir;
|
|
42295
42444
|
}
|
|
42296
42445
|
return null;
|
|
42297
42446
|
}
|
|
@@ -42301,9 +42450,9 @@ var init_dev_server = __esm({
|
|
|
42301
42450
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
42302
42451
|
return;
|
|
42303
42452
|
}
|
|
42304
|
-
const htmlPath =
|
|
42453
|
+
const htmlPath = path15.join(distDir, "index.html");
|
|
42305
42454
|
try {
|
|
42306
|
-
const html =
|
|
42455
|
+
const html = fs13.readFileSync(htmlPath, "utf-8");
|
|
42307
42456
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
42308
42457
|
res.end(html);
|
|
42309
42458
|
} catch (e) {
|
|
@@ -42326,15 +42475,15 @@ var init_dev_server = __esm({
|
|
|
42326
42475
|
this.json(res, 404, { error: "Not found" });
|
|
42327
42476
|
return;
|
|
42328
42477
|
}
|
|
42329
|
-
const safePath =
|
|
42330
|
-
const filePath =
|
|
42478
|
+
const safePath = path15.normalize(pathname).replace(/^\.\.\//, "");
|
|
42479
|
+
const filePath = path15.join(distDir, safePath);
|
|
42331
42480
|
if (!filePath.startsWith(distDir)) {
|
|
42332
42481
|
this.json(res, 403, { error: "Forbidden" });
|
|
42333
42482
|
return;
|
|
42334
42483
|
}
|
|
42335
42484
|
try {
|
|
42336
|
-
const content =
|
|
42337
|
-
const ext =
|
|
42485
|
+
const content = fs13.readFileSync(filePath);
|
|
42486
|
+
const ext = path15.extname(filePath);
|
|
42338
42487
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
42339
42488
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
42340
42489
|
res.end(content);
|
|
@@ -42442,14 +42591,14 @@ var init_dev_server = __esm({
|
|
|
42442
42591
|
const files = [];
|
|
42443
42592
|
const scan = (d, prefix) => {
|
|
42444
42593
|
try {
|
|
42445
|
-
for (const entry of
|
|
42594
|
+
for (const entry of fs13.readdirSync(d, { withFileTypes: true })) {
|
|
42446
42595
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
42447
42596
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
42448
42597
|
if (entry.isDirectory()) {
|
|
42449
42598
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
42450
|
-
scan(
|
|
42599
|
+
scan(path15.join(d, entry.name), rel);
|
|
42451
42600
|
} else {
|
|
42452
|
-
const stat4 =
|
|
42601
|
+
const stat4 = fs13.statSync(path15.join(d, entry.name));
|
|
42453
42602
|
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
42454
42603
|
}
|
|
42455
42604
|
}
|
|
@@ -42472,16 +42621,16 @@ var init_dev_server = __esm({
|
|
|
42472
42621
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
42473
42622
|
return;
|
|
42474
42623
|
}
|
|
42475
|
-
const fullPath =
|
|
42624
|
+
const fullPath = path15.resolve(dir, path15.normalize(filePath));
|
|
42476
42625
|
if (!fullPath.startsWith(dir)) {
|
|
42477
42626
|
this.json(res, 403, { error: "Forbidden" });
|
|
42478
42627
|
return;
|
|
42479
42628
|
}
|
|
42480
|
-
if (!
|
|
42629
|
+
if (!fs13.existsSync(fullPath) || fs13.statSync(fullPath).isDirectory()) {
|
|
42481
42630
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
42482
42631
|
return;
|
|
42483
42632
|
}
|
|
42484
|
-
const content =
|
|
42633
|
+
const content = fs13.readFileSync(fullPath, "utf-8");
|
|
42485
42634
|
this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
|
|
42486
42635
|
}
|
|
42487
42636
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -42497,15 +42646,15 @@ var init_dev_server = __esm({
|
|
|
42497
42646
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
42498
42647
|
return;
|
|
42499
42648
|
}
|
|
42500
|
-
const fullPath =
|
|
42649
|
+
const fullPath = path15.resolve(dir, path15.normalize(filePath));
|
|
42501
42650
|
if (!fullPath.startsWith(dir)) {
|
|
42502
42651
|
this.json(res, 403, { error: "Forbidden" });
|
|
42503
42652
|
return;
|
|
42504
42653
|
}
|
|
42505
42654
|
try {
|
|
42506
|
-
if (
|
|
42507
|
-
|
|
42508
|
-
|
|
42655
|
+
if (fs13.existsSync(fullPath)) fs13.copyFileSync(fullPath, fullPath + ".bak");
|
|
42656
|
+
fs13.mkdirSync(path15.dirname(fullPath), { recursive: true });
|
|
42657
|
+
fs13.writeFileSync(fullPath, content, "utf-8");
|
|
42509
42658
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
42510
42659
|
this.providerLoader.reload();
|
|
42511
42660
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -42521,9 +42670,9 @@ var init_dev_server = __esm({
|
|
|
42521
42670
|
return;
|
|
42522
42671
|
}
|
|
42523
42672
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
42524
|
-
const p =
|
|
42525
|
-
if (
|
|
42526
|
-
const source =
|
|
42673
|
+
const p = path15.join(dir, name);
|
|
42674
|
+
if (fs13.existsSync(p)) {
|
|
42675
|
+
const source = fs13.readFileSync(p, "utf-8");
|
|
42527
42676
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
42528
42677
|
return;
|
|
42529
42678
|
}
|
|
@@ -42542,11 +42691,11 @@ var init_dev_server = __esm({
|
|
|
42542
42691
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
42543
42692
|
return;
|
|
42544
42693
|
}
|
|
42545
|
-
const target =
|
|
42546
|
-
const targetPath =
|
|
42694
|
+
const target = fs13.existsSync(path15.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
42695
|
+
const targetPath = path15.join(dir, target);
|
|
42547
42696
|
try {
|
|
42548
|
-
if (
|
|
42549
|
-
|
|
42697
|
+
if (fs13.existsSync(targetPath)) fs13.copyFileSync(targetPath, targetPath + ".bak");
|
|
42698
|
+
fs13.writeFileSync(targetPath, source, "utf-8");
|
|
42550
42699
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
42551
42700
|
this.providerLoader.reload();
|
|
42552
42701
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -42625,20 +42774,20 @@ var init_dev_server = __esm({
|
|
|
42625
42774
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
42626
42775
|
return;
|
|
42627
42776
|
}
|
|
42628
|
-
const
|
|
42629
|
-
if (!
|
|
42777
|
+
const spawn5 = provider.spawn;
|
|
42778
|
+
if (!spawn5) {
|
|
42630
42779
|
this.json(res, 400, { error: `Provider ${type} has no spawn config` });
|
|
42631
42780
|
return;
|
|
42632
42781
|
}
|
|
42633
42782
|
const { spawn: spawnFn } = await import("child_process");
|
|
42634
42783
|
const start = Date.now();
|
|
42635
42784
|
try {
|
|
42636
|
-
const args = [...
|
|
42637
|
-
const child = spawnFn(
|
|
42638
|
-
shell:
|
|
42785
|
+
const args = [...spawn5.args || [], message];
|
|
42786
|
+
const child = spawnFn(spawn5.command, args, {
|
|
42787
|
+
shell: spawn5.shell ?? false,
|
|
42639
42788
|
timeout,
|
|
42640
42789
|
stdio: ["pipe", "pipe", "pipe"],
|
|
42641
|
-
env: { ...process.env, ...
|
|
42790
|
+
env: { ...process.env, ...spawn5.env || {} }
|
|
42642
42791
|
});
|
|
42643
42792
|
let stdout = "";
|
|
42644
42793
|
let stderr = "";
|
|
@@ -42703,21 +42852,21 @@ var init_dev_server = __esm({
|
|
|
42703
42852
|
}
|
|
42704
42853
|
let targetDir;
|
|
42705
42854
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
42706
|
-
const jsonPath =
|
|
42707
|
-
if (
|
|
42855
|
+
const jsonPath = path15.join(targetDir, "provider.json");
|
|
42856
|
+
if (fs13.existsSync(jsonPath)) {
|
|
42708
42857
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
42709
42858
|
return;
|
|
42710
42859
|
}
|
|
42711
42860
|
try {
|
|
42712
42861
|
const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
|
|
42713
|
-
|
|
42714
|
-
|
|
42862
|
+
fs13.mkdirSync(targetDir, { recursive: true });
|
|
42863
|
+
fs13.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
42715
42864
|
const createdFiles = ["provider.json"];
|
|
42716
42865
|
if (result.files) {
|
|
42717
42866
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
42718
|
-
const fullPath =
|
|
42719
|
-
|
|
42720
|
-
|
|
42867
|
+
const fullPath = path15.join(targetDir, relPath);
|
|
42868
|
+
fs13.mkdirSync(path15.dirname(fullPath), { recursive: true });
|
|
42869
|
+
fs13.writeFileSync(fullPath, content, "utf-8");
|
|
42721
42870
|
createdFiles.push(relPath);
|
|
42722
42871
|
}
|
|
42723
42872
|
}
|
|
@@ -42766,45 +42915,45 @@ var init_dev_server = __esm({
|
|
|
42766
42915
|
}
|
|
42767
42916
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
42768
42917
|
getLatestScriptVersionDir(scriptsDir) {
|
|
42769
|
-
if (!
|
|
42770
|
-
const versions =
|
|
42918
|
+
if (!fs13.existsSync(scriptsDir)) return null;
|
|
42919
|
+
const versions = fs13.readdirSync(scriptsDir).filter((d) => {
|
|
42771
42920
|
try {
|
|
42772
|
-
return
|
|
42921
|
+
return fs13.statSync(path15.join(scriptsDir, d)).isDirectory();
|
|
42773
42922
|
} catch {
|
|
42774
42923
|
return false;
|
|
42775
42924
|
}
|
|
42776
42925
|
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
42777
42926
|
if (versions.length === 0) return null;
|
|
42778
|
-
return
|
|
42927
|
+
return path15.join(scriptsDir, versions[0]);
|
|
42779
42928
|
}
|
|
42780
42929
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
42781
|
-
const canonicalUserDir =
|
|
42782
|
-
const desiredDir = requestedDir ?
|
|
42783
|
-
const upstreamRoot =
|
|
42784
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
42930
|
+
const canonicalUserDir = path15.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
42931
|
+
const desiredDir = requestedDir ? path15.resolve(requestedDir) : canonicalUserDir;
|
|
42932
|
+
const upstreamRoot = path15.resolve(this.providerLoader.getUpstreamDir());
|
|
42933
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path15.sep}`)) {
|
|
42785
42934
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
42786
42935
|
}
|
|
42787
|
-
if (
|
|
42936
|
+
if (path15.basename(desiredDir) !== type) {
|
|
42788
42937
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
42789
42938
|
}
|
|
42790
42939
|
const sourceDir = this.findProviderDir(type);
|
|
42791
42940
|
if (!sourceDir) {
|
|
42792
42941
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
42793
42942
|
}
|
|
42794
|
-
if (!
|
|
42795
|
-
|
|
42796
|
-
|
|
42943
|
+
if (!fs13.existsSync(desiredDir)) {
|
|
42944
|
+
fs13.mkdirSync(path15.dirname(desiredDir), { recursive: true });
|
|
42945
|
+
fs13.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
42797
42946
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
42798
42947
|
}
|
|
42799
|
-
const providerJson =
|
|
42800
|
-
if (!
|
|
42948
|
+
const providerJson = path15.join(desiredDir, "provider.json");
|
|
42949
|
+
if (!fs13.existsSync(providerJson)) {
|
|
42801
42950
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
42802
42951
|
}
|
|
42803
42952
|
try {
|
|
42804
|
-
const providerData = JSON.parse(
|
|
42953
|
+
const providerData = JSON.parse(fs13.readFileSync(providerJson, "utf-8"));
|
|
42805
42954
|
if (providerData.disableUpstream !== true) {
|
|
42806
42955
|
providerData.disableUpstream = true;
|
|
42807
|
-
|
|
42956
|
+
fs13.writeFileSync(providerJson, JSON.stringify(providerData, null, 2));
|
|
42808
42957
|
}
|
|
42809
42958
|
} catch (error48) {
|
|
42810
42959
|
return {
|
|
@@ -42844,7 +42993,7 @@ var init_dev_server = __esm({
|
|
|
42844
42993
|
setMode: "set_mode.js"
|
|
42845
42994
|
};
|
|
42846
42995
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
42847
|
-
const scriptsDir =
|
|
42996
|
+
const scriptsDir = path15.join(providerDir, "scripts");
|
|
42848
42997
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
42849
42998
|
if (latestScriptsDir) {
|
|
42850
42999
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -42852,10 +43001,10 @@ var init_dev_server = __esm({
|
|
|
42852
43001
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
42853
43002
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
42854
43003
|
lines.push("");
|
|
42855
|
-
for (const file2 of
|
|
43004
|
+
for (const file2 of fs13.readdirSync(latestScriptsDir)) {
|
|
42856
43005
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
42857
43006
|
try {
|
|
42858
|
-
const content =
|
|
43007
|
+
const content = fs13.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
42859
43008
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
42860
43009
|
lines.push("```javascript");
|
|
42861
43010
|
lines.push(content);
|
|
@@ -42865,14 +43014,14 @@ var init_dev_server = __esm({
|
|
|
42865
43014
|
}
|
|
42866
43015
|
}
|
|
42867
43016
|
}
|
|
42868
|
-
const refFiles =
|
|
43017
|
+
const refFiles = fs13.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
42869
43018
|
if (refFiles.length > 0) {
|
|
42870
43019
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
42871
43020
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
42872
43021
|
lines.push("");
|
|
42873
43022
|
for (const file2 of refFiles) {
|
|
42874
43023
|
try {
|
|
42875
|
-
const content =
|
|
43024
|
+
const content = fs13.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
42876
43025
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
42877
43026
|
lines.push("```javascript");
|
|
42878
43027
|
lines.push(content);
|
|
@@ -42913,11 +43062,11 @@ var init_dev_server = __esm({
|
|
|
42913
43062
|
lines.push("");
|
|
42914
43063
|
}
|
|
42915
43064
|
}
|
|
42916
|
-
const docsDir =
|
|
43065
|
+
const docsDir = path15.join(providerDir, "../../docs");
|
|
42917
43066
|
const loadGuide = (name) => {
|
|
42918
43067
|
try {
|
|
42919
|
-
const p =
|
|
42920
|
-
if (
|
|
43068
|
+
const p = path15.join(docsDir, name);
|
|
43069
|
+
if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
|
|
42921
43070
|
} catch {
|
|
42922
43071
|
}
|
|
42923
43072
|
return null;
|
|
@@ -43090,7 +43239,7 @@ var init_dev_server = __esm({
|
|
|
43090
43239
|
parseApproval: "parse_approval.js"
|
|
43091
43240
|
};
|
|
43092
43241
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
43093
|
-
const scriptsDir =
|
|
43242
|
+
const scriptsDir = path15.join(providerDir, "scripts");
|
|
43094
43243
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
43095
43244
|
if (latestScriptsDir) {
|
|
43096
43245
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -43098,11 +43247,11 @@ var init_dev_server = __esm({
|
|
|
43098
43247
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
43099
43248
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
43100
43249
|
lines.push("");
|
|
43101
|
-
for (const file2 of
|
|
43250
|
+
for (const file2 of fs13.readdirSync(latestScriptsDir)) {
|
|
43102
43251
|
if (!file2.endsWith(".js")) continue;
|
|
43103
43252
|
if (!targetFileNames.has(file2)) continue;
|
|
43104
43253
|
try {
|
|
43105
|
-
const content =
|
|
43254
|
+
const content = fs13.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
43106
43255
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
43107
43256
|
lines.push("```javascript");
|
|
43108
43257
|
lines.push(content);
|
|
@@ -43111,14 +43260,14 @@ var init_dev_server = __esm({
|
|
|
43111
43260
|
} catch {
|
|
43112
43261
|
}
|
|
43113
43262
|
}
|
|
43114
|
-
const refFiles =
|
|
43263
|
+
const refFiles = fs13.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
43115
43264
|
if (refFiles.length > 0) {
|
|
43116
43265
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
43117
43266
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
43118
43267
|
lines.push("");
|
|
43119
43268
|
for (const file2 of refFiles) {
|
|
43120
43269
|
try {
|
|
43121
|
-
const content =
|
|
43270
|
+
const content = fs13.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
43122
43271
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
43123
43272
|
lines.push("```javascript");
|
|
43124
43273
|
lines.push(content);
|
|
@@ -43151,11 +43300,11 @@ var init_dev_server = __esm({
|
|
|
43151
43300
|
lines.push("");
|
|
43152
43301
|
}
|
|
43153
43302
|
}
|
|
43154
|
-
const docsDir =
|
|
43303
|
+
const docsDir = path15.join(providerDir, "../../docs");
|
|
43155
43304
|
const loadGuide = (name) => {
|
|
43156
43305
|
try {
|
|
43157
|
-
const p =
|
|
43158
|
-
if (
|
|
43306
|
+
const p = path15.join(docsDir, name);
|
|
43307
|
+
if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
|
|
43159
43308
|
} catch {
|
|
43160
43309
|
}
|
|
43161
43310
|
return null;
|
|
@@ -43381,7 +43530,7 @@ function getDefaultSessionHostEndpoint(appName = "adhdev") {
|
|
|
43381
43530
|
}
|
|
43382
43531
|
return {
|
|
43383
43532
|
kind: "unix",
|
|
43384
|
-
path: path22.join(
|
|
43533
|
+
path: path22.join(os18.tmpdir(), `${appName}-session-host.sock`)
|
|
43385
43534
|
};
|
|
43386
43535
|
}
|
|
43387
43536
|
function serializeEnvelope(envelope) {
|
|
@@ -43403,11 +43552,11 @@ function createLineParser(onEnvelope) {
|
|
|
43403
43552
|
}
|
|
43404
43553
|
};
|
|
43405
43554
|
}
|
|
43406
|
-
var
|
|
43555
|
+
var os18, path22, net2, import_crypto3, SessionHostClient;
|
|
43407
43556
|
var init_dist = __esm({
|
|
43408
43557
|
"../../oss/packages/session-host-core/dist/index.mjs"() {
|
|
43409
43558
|
"use strict";
|
|
43410
|
-
|
|
43559
|
+
os18 = __toESM(require("os"), 1);
|
|
43411
43560
|
path22 = __toESM(require("path"), 1);
|
|
43412
43561
|
net2 = __toESM(require("net"), 1);
|
|
43413
43562
|
import_crypto3 = require("crypto");
|
|
@@ -43523,6 +43672,7 @@ var init_session_host_transport = __esm({
|
|
|
43523
43672
|
this.ready = this.boot();
|
|
43524
43673
|
}
|
|
43525
43674
|
ready;
|
|
43675
|
+
terminalQueriesHandled = true;
|
|
43526
43676
|
client;
|
|
43527
43677
|
dataCallbacks = /* @__PURE__ */ new Set();
|
|
43528
43678
|
exitCallbacks = /* @__PURE__ */ new Set();
|
|
@@ -43922,7 +44072,7 @@ var init_runtime_support = __esm({
|
|
|
43922
44072
|
function isExtensionInstalled(ide, marketplaceId) {
|
|
43923
44073
|
if (!ide.cliCommand) return false;
|
|
43924
44074
|
try {
|
|
43925
|
-
const result = (0,
|
|
44075
|
+
const result = (0, import_child_process10.execSync)(`"${ide.cliCommand}" --list-extensions`, {
|
|
43926
44076
|
encoding: "utf-8",
|
|
43927
44077
|
timeout: 15e3,
|
|
43928
44078
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -43959,11 +44109,11 @@ async function installExtension(ide, extension) {
|
|
|
43959
44109
|
const res = await fetch(extension.vsixUrl);
|
|
43960
44110
|
if (res.ok) {
|
|
43961
44111
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
43962
|
-
const
|
|
43963
|
-
|
|
44112
|
+
const fs17 = await import("fs");
|
|
44113
|
+
fs17.writeFileSync(vsixPath, buffer);
|
|
43964
44114
|
return new Promise((resolve12) => {
|
|
43965
44115
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
43966
|
-
(0,
|
|
44116
|
+
(0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
43967
44117
|
resolve12({
|
|
43968
44118
|
extensionId: extension.id,
|
|
43969
44119
|
marketplaceId: extension.marketplaceId,
|
|
@@ -43979,7 +44129,7 @@ async function installExtension(ide, extension) {
|
|
|
43979
44129
|
}
|
|
43980
44130
|
return new Promise((resolve12) => {
|
|
43981
44131
|
const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
|
|
43982
|
-
(0,
|
|
44132
|
+
(0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
|
|
43983
44133
|
if (error48) {
|
|
43984
44134
|
resolve12({
|
|
43985
44135
|
extensionId: extension.id,
|
|
@@ -44016,17 +44166,17 @@ function launchIDE(ide, workspacePath) {
|
|
|
44016
44166
|
if (!ide.cliCommand) return false;
|
|
44017
44167
|
try {
|
|
44018
44168
|
const args = workspacePath ? `"${workspacePath}"` : "";
|
|
44019
|
-
(0,
|
|
44169
|
+
(0, import_child_process10.exec)(`"${ide.cliCommand}" ${args}`, { timeout: 1e4 });
|
|
44020
44170
|
return true;
|
|
44021
44171
|
} catch {
|
|
44022
44172
|
return false;
|
|
44023
44173
|
}
|
|
44024
44174
|
}
|
|
44025
|
-
var
|
|
44175
|
+
var import_child_process10, EXTENSION_CATALOG;
|
|
44026
44176
|
var init_installer = __esm({
|
|
44027
44177
|
"../../oss/packages/daemon-core/src/installer.ts"() {
|
|
44028
44178
|
"use strict";
|
|
44029
|
-
|
|
44179
|
+
import_child_process10 = require("child_process");
|
|
44030
44180
|
EXTENSION_CATALOG = [
|
|
44031
44181
|
// AI Agent extensions
|
|
44032
44182
|
{
|
|
@@ -44434,6 +44584,7 @@ __export(src_exports, {
|
|
|
44434
44584
|
loadConfig: () => loadConfig,
|
|
44435
44585
|
logCommand: () => logCommand,
|
|
44436
44586
|
markSetupComplete: () => markSetupComplete,
|
|
44587
|
+
maybeRunDaemonUpgradeHelperFromEnv: () => maybeRunDaemonUpgradeHelperFromEnv,
|
|
44437
44588
|
normalizeActiveChatData: () => normalizeActiveChatData,
|
|
44438
44589
|
normalizeManagedStatus: () => normalizeManagedStatus,
|
|
44439
44590
|
probeCdpPort: () => probeCdpPort,
|
|
@@ -44463,6 +44614,7 @@ var init_src = __esm({
|
|
|
44463
44614
|
init_initializer();
|
|
44464
44615
|
init_handler();
|
|
44465
44616
|
init_router();
|
|
44617
|
+
init_upgrade_helper();
|
|
44466
44618
|
init_reporter();
|
|
44467
44619
|
init_builders();
|
|
44468
44620
|
init_snapshot();
|
|
@@ -44792,17 +44944,17 @@ function canPeerUsePrivilegedShareCommand(commandType, permission) {
|
|
|
44792
44944
|
return false;
|
|
44793
44945
|
}
|
|
44794
44946
|
}
|
|
44795
|
-
var
|
|
44947
|
+
var fs14, path16, os19, import_node_module, esmRequire, logFile, log, logDebug, DaemonP2PSender;
|
|
44796
44948
|
var init_daemon_p2p = __esm({
|
|
44797
44949
|
"src/daemon-p2p.ts"() {
|
|
44798
44950
|
"use strict";
|
|
44799
|
-
|
|
44951
|
+
fs14 = __toESM(require("fs"));
|
|
44800
44952
|
init_src();
|
|
44801
|
-
|
|
44802
|
-
|
|
44953
|
+
path16 = __toESM(require("path"));
|
|
44954
|
+
os19 = __toESM(require("os"));
|
|
44803
44955
|
import_node_module = require("module");
|
|
44804
44956
|
esmRequire = (0, import_node_module.createRequire)(__filename);
|
|
44805
|
-
logFile =
|
|
44957
|
+
logFile = path16.join(os19.tmpdir(), "adhdev_daemon_p2p.log");
|
|
44806
44958
|
log = (msg) => {
|
|
44807
44959
|
LOG.info("P2P", `[${(/* @__PURE__ */ new Date()).toISOString()}] [P2P] ${msg}`);
|
|
44808
44960
|
};
|
|
@@ -44870,17 +45022,17 @@ ${e?.stack || ""}`);
|
|
|
44870
45022
|
const prebuildKey = `${platform11}-${arch3}`;
|
|
44871
45023
|
try {
|
|
44872
45024
|
const candidates = [
|
|
44873
|
-
|
|
44874
|
-
|
|
44875
|
-
|
|
45025
|
+
path16.join(__dirname, "node_modules", "node-datachannel"),
|
|
45026
|
+
path16.join(__dirname, "..", "node_modules", "node-datachannel"),
|
|
45027
|
+
path16.join(__dirname, "..", "..", "node_modules", "node-datachannel")
|
|
44876
45028
|
];
|
|
44877
45029
|
for (const candidate of candidates) {
|
|
44878
|
-
const prebuildPath =
|
|
44879
|
-
if (
|
|
44880
|
-
const targetDir =
|
|
44881
|
-
const targetPath =
|
|
44882
|
-
|
|
44883
|
-
|
|
45030
|
+
const prebuildPath = path16.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
|
|
45031
|
+
if (fs14.existsSync(prebuildPath)) {
|
|
45032
|
+
const targetDir = path16.join(candidate, "build", "Release");
|
|
45033
|
+
const targetPath = path16.join(targetDir, "node_datachannel.node");
|
|
45034
|
+
fs14.mkdirSync(targetDir, { recursive: true });
|
|
45035
|
+
fs14.copyFileSync(prebuildPath, targetPath);
|
|
44884
45036
|
try {
|
|
44885
45037
|
delete esmRequire.cache[esmRequire.resolve("node-datachannel")];
|
|
44886
45038
|
} catch {
|
|
@@ -45782,23 +45934,23 @@ __export(session_host_exports, {
|
|
|
45782
45934
|
});
|
|
45783
45935
|
function resolveSessionHostEntry() {
|
|
45784
45936
|
const packagedCandidates = [
|
|
45785
|
-
|
|
45786
|
-
|
|
45937
|
+
path17.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
45938
|
+
path17.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
45787
45939
|
];
|
|
45788
45940
|
for (const candidate of packagedCandidates) {
|
|
45789
|
-
if (
|
|
45941
|
+
if (fs15.existsSync(candidate)) {
|
|
45790
45942
|
return candidate;
|
|
45791
45943
|
}
|
|
45792
45944
|
}
|
|
45793
45945
|
return require.resolve("@adhdev/session-host-daemon");
|
|
45794
45946
|
}
|
|
45795
45947
|
function getSessionHostPidFile() {
|
|
45796
|
-
return
|
|
45948
|
+
return path17.join(os20.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
|
|
45797
45949
|
}
|
|
45798
|
-
function
|
|
45950
|
+
function killPid2(pid) {
|
|
45799
45951
|
try {
|
|
45800
45952
|
if (process.platform === "win32") {
|
|
45801
|
-
(0,
|
|
45953
|
+
(0, import_child_process11.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
|
|
45802
45954
|
} else {
|
|
45803
45955
|
process.kill(pid, "SIGTERM");
|
|
45804
45956
|
}
|
|
@@ -45811,26 +45963,26 @@ function stopSessionHost() {
|
|
|
45811
45963
|
let stopped = false;
|
|
45812
45964
|
const pidFile = getSessionHostPidFile();
|
|
45813
45965
|
try {
|
|
45814
|
-
if (
|
|
45815
|
-
const pid = Number.parseInt(
|
|
45966
|
+
if (fs15.existsSync(pidFile)) {
|
|
45967
|
+
const pid = Number.parseInt(fs15.readFileSync(pidFile, "utf8").trim(), 10);
|
|
45816
45968
|
if (Number.isFinite(pid)) {
|
|
45817
|
-
stopped =
|
|
45969
|
+
stopped = killPid2(pid) || stopped;
|
|
45818
45970
|
}
|
|
45819
45971
|
}
|
|
45820
45972
|
} catch {
|
|
45821
45973
|
} finally {
|
|
45822
45974
|
try {
|
|
45823
|
-
|
|
45975
|
+
fs15.unlinkSync(pidFile);
|
|
45824
45976
|
} catch {
|
|
45825
45977
|
}
|
|
45826
45978
|
}
|
|
45827
45979
|
if (process.platform !== "win32") {
|
|
45828
45980
|
try {
|
|
45829
|
-
const raw = (0,
|
|
45981
|
+
const raw = (0, import_child_process11.execFileSync)("pgrep", ["-f", "session-host-daemon"], { encoding: "utf8" }).trim();
|
|
45830
45982
|
for (const line of raw.split("\n")) {
|
|
45831
45983
|
const pid = Number.parseInt(line.trim(), 10);
|
|
45832
45984
|
if (Number.isFinite(pid)) {
|
|
45833
|
-
stopped =
|
|
45985
|
+
stopped = killPid2(pid) || stopped;
|
|
45834
45986
|
}
|
|
45835
45987
|
}
|
|
45836
45988
|
} catch {
|
|
@@ -45843,7 +45995,7 @@ async function ensureSessionHostReady2() {
|
|
|
45843
45995
|
appName: SESSION_HOST_APP_NAME,
|
|
45844
45996
|
spawnHost: () => {
|
|
45845
45997
|
const entry = resolveSessionHostEntry();
|
|
45846
|
-
const child = (0,
|
|
45998
|
+
const child = (0, import_child_process11.spawn)(process.execPath, [entry], {
|
|
45847
45999
|
detached: true,
|
|
45848
46000
|
stdio: "ignore",
|
|
45849
46001
|
windowsHide: true,
|
|
@@ -45859,14 +46011,14 @@ async function ensureSessionHostReady2() {
|
|
|
45859
46011
|
async function listHostedCliRuntimes2(endpoint) {
|
|
45860
46012
|
return listHostedCliRuntimes(endpoint);
|
|
45861
46013
|
}
|
|
45862
|
-
var
|
|
46014
|
+
var import_child_process11, fs15, os20, path17, SESSION_HOST_APP_NAME;
|
|
45863
46015
|
var init_session_host = __esm({
|
|
45864
46016
|
"src/session-host.ts"() {
|
|
45865
46017
|
"use strict";
|
|
45866
|
-
|
|
45867
|
-
|
|
45868
|
-
|
|
45869
|
-
|
|
46018
|
+
import_child_process11 = require("child_process");
|
|
46019
|
+
fs15 = __toESM(require("fs"));
|
|
46020
|
+
os20 = __toESM(require("os"));
|
|
46021
|
+
path17 = __toESM(require("path"));
|
|
45870
46022
|
init_src();
|
|
45871
46023
|
SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
|
|
45872
46024
|
}
|
|
@@ -45880,24 +46032,24 @@ __export(adhdev_daemon_exports, {
|
|
|
45880
46032
|
stopDaemon: () => stopDaemon
|
|
45881
46033
|
});
|
|
45882
46034
|
function getDaemonPidFile() {
|
|
45883
|
-
const dir =
|
|
45884
|
-
if (!
|
|
45885
|
-
return
|
|
46035
|
+
const dir = path18.join(os21.homedir(), ".adhdev");
|
|
46036
|
+
if (!fs16.existsSync(dir)) fs16.mkdirSync(dir, { recursive: true });
|
|
46037
|
+
return path18.join(dir, "daemon.pid");
|
|
45886
46038
|
}
|
|
45887
46039
|
function writeDaemonPid(pid) {
|
|
45888
|
-
|
|
46040
|
+
fs16.writeFileSync(getDaemonPidFile(), String(pid), "utf-8");
|
|
45889
46041
|
}
|
|
45890
46042
|
function removeDaemonPid() {
|
|
45891
46043
|
try {
|
|
45892
|
-
|
|
46044
|
+
fs16.unlinkSync(getDaemonPidFile());
|
|
45893
46045
|
} catch (e) {
|
|
45894
46046
|
}
|
|
45895
46047
|
}
|
|
45896
46048
|
function isDaemonRunning() {
|
|
45897
46049
|
const pidFile = getDaemonPidFile();
|
|
45898
46050
|
try {
|
|
45899
|
-
if (!
|
|
45900
|
-
const pid = parseInt(
|
|
46051
|
+
if (!fs16.existsSync(pidFile)) return false;
|
|
46052
|
+
const pid = parseInt(fs16.readFileSync(pidFile, "utf-8").trim());
|
|
45901
46053
|
process.kill(pid, 0);
|
|
45902
46054
|
return true;
|
|
45903
46055
|
} catch {
|
|
@@ -45908,8 +46060,8 @@ function isDaemonRunning() {
|
|
|
45908
46060
|
function stopDaemon() {
|
|
45909
46061
|
const pidFile = getDaemonPidFile();
|
|
45910
46062
|
try {
|
|
45911
|
-
if (!
|
|
45912
|
-
const pid = parseInt(
|
|
46063
|
+
if (!fs16.existsSync(pidFile)) return false;
|
|
46064
|
+
const pid = parseInt(fs16.readFileSync(pidFile, "utf-8").trim());
|
|
45913
46065
|
process.kill(pid, "SIGTERM");
|
|
45914
46066
|
removeDaemonPid();
|
|
45915
46067
|
return true;
|
|
@@ -45918,7 +46070,7 @@ function stopDaemon() {
|
|
|
45918
46070
|
return false;
|
|
45919
46071
|
}
|
|
45920
46072
|
}
|
|
45921
|
-
var
|
|
46073
|
+
var os21, fs16, path18, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
|
|
45922
46074
|
var init_adhdev_daemon = __esm({
|
|
45923
46075
|
"src/adhdev-daemon.ts"() {
|
|
45924
46076
|
"use strict";
|
|
@@ -45928,20 +46080,20 @@ var init_adhdev_daemon = __esm({
|
|
|
45928
46080
|
init_screenshot_controller();
|
|
45929
46081
|
init_session_host();
|
|
45930
46082
|
init_dist();
|
|
45931
|
-
|
|
45932
|
-
|
|
45933
|
-
|
|
46083
|
+
os21 = __toESM(require("os"));
|
|
46084
|
+
fs16 = __toESM(require("fs"));
|
|
46085
|
+
path18 = __toESM(require("path"));
|
|
45934
46086
|
import_chalk2 = __toESM(require("chalk"));
|
|
45935
|
-
pkgVersion = "0.7.
|
|
46087
|
+
pkgVersion = "0.7.44";
|
|
45936
46088
|
if (pkgVersion === "unknown") {
|
|
45937
46089
|
try {
|
|
45938
46090
|
const possiblePaths = [
|
|
45939
|
-
|
|
45940
|
-
|
|
46091
|
+
path18.join(__dirname, "..", "package.json"),
|
|
46092
|
+
path18.join(__dirname, "package.json")
|
|
45941
46093
|
];
|
|
45942
46094
|
for (const p of possiblePaths) {
|
|
45943
46095
|
try {
|
|
45944
|
-
const data = JSON.parse(
|
|
46096
|
+
const data = JSON.parse(fs16.readFileSync(p, "utf-8"));
|
|
45945
46097
|
if (data.version) {
|
|
45946
46098
|
pkgVersion = data.version;
|
|
45947
46099
|
break;
|
|
@@ -46079,8 +46231,8 @@ ${err?.stack || ""}`);
|
|
|
46079
46231
|
cliInfo: {
|
|
46080
46232
|
type: "adhdev-daemon",
|
|
46081
46233
|
version: pkgVersion,
|
|
46082
|
-
platform:
|
|
46083
|
-
hostname:
|
|
46234
|
+
platform: os21.platform(),
|
|
46235
|
+
hostname: os21.hostname(),
|
|
46084
46236
|
machineId: config2.machineId,
|
|
46085
46237
|
instanceId
|
|
46086
46238
|
}
|
|
@@ -46520,16 +46672,16 @@ async function loginFlow() {
|
|
|
46520
46672
|
let verificationUrl;
|
|
46521
46673
|
try {
|
|
46522
46674
|
const config2 = loadConfig();
|
|
46523
|
-
const
|
|
46675
|
+
const os22 = await import("os");
|
|
46524
46676
|
const res = await fetch(`${SERVER_URL}/auth/cli/init`, {
|
|
46525
46677
|
method: "POST",
|
|
46526
46678
|
headers: { "Content-Type": "application/json" },
|
|
46527
46679
|
body: JSON.stringify({
|
|
46528
46680
|
clientMachineId: config2.machineId,
|
|
46529
46681
|
registeredMachineId: config2.registeredMachineId,
|
|
46530
|
-
hostname:
|
|
46531
|
-
platform:
|
|
46532
|
-
arch:
|
|
46682
|
+
hostname: os22.hostname(),
|
|
46683
|
+
platform: os22.platform(),
|
|
46684
|
+
arch: os22.arch()
|
|
46533
46685
|
})
|
|
46534
46686
|
});
|
|
46535
46687
|
if (!res.ok) {
|
|
@@ -46628,10 +46780,10 @@ async function startDaemonFlow() {
|
|
|
46628
46780
|
const { AdhdevDaemon: AdhdevDaemon2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
46629
46781
|
const daemon = new AdhdevDaemon2();
|
|
46630
46782
|
const { execSync: execSync7 } = await import("child_process");
|
|
46631
|
-
const
|
|
46632
|
-
const
|
|
46633
|
-
const logPath =
|
|
46634
|
-
const platform11 =
|
|
46783
|
+
const os22 = await import("os");
|
|
46784
|
+
const path19 = await import("path");
|
|
46785
|
+
const logPath = path19.join(os22.homedir(), ".adhdev", "daemon.log");
|
|
46786
|
+
const platform11 = os22.platform();
|
|
46635
46787
|
try {
|
|
46636
46788
|
if (platform11 === "win32") {
|
|
46637
46789
|
execSync7(`start /B adhdev daemon > "${logPath}" 2>&1`, {
|
|
@@ -47267,7 +47419,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
47267
47419
|
});
|
|
47268
47420
|
});
|
|
47269
47421
|
program2.command("standalone").description("\u{1F5A5}\uFE0F Start ADHDev Standalone Server (Local Dashboard & Embedded Daemon)").option("-p, --port <port>", "Local HTTP/WS server port", "3847").option("--host <host>", "Bind to specific host (use 0.0.0.0 for LAN access)").option("--no-open", "Prevent opening browser automatically").option("--token <token>", "Require token authentication").option("--dev", "Enable Dev Mode").action(async (options) => {
|
|
47270
|
-
const { spawn:
|
|
47422
|
+
const { spawn: spawn5, execSync: execSync7 } = await import("child_process");
|
|
47271
47423
|
console.log(import_chalk5.default.cyan("\n Starting ADHDev Standalone Server..."));
|
|
47272
47424
|
const args = [];
|
|
47273
47425
|
if (options.port) args.push("--port", options.port);
|
|
@@ -47285,7 +47437,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
47285
47437
|
console.log(import_chalk5.default.gray(" Downloading and running via npx (this may take a moment)..."));
|
|
47286
47438
|
}
|
|
47287
47439
|
const spawnArgs = bin === "npx" ? npxArgs : args;
|
|
47288
|
-
const child =
|
|
47440
|
+
const child = spawn5(bin, spawnArgs, {
|
|
47289
47441
|
stdio: "inherit",
|
|
47290
47442
|
shell: process.platform === "win32"
|
|
47291
47443
|
});
|
|
@@ -47322,7 +47474,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
47322
47474
|
hideCommand(program2.command("daemon:restart").description("Restart ADHDev Daemon (stop \u2192 start)").option("-p, --port <port>", "Local WS server port", "19222").option("--server <url>", "Override server URL").option("--dev", "Enable Dev Mode").action(async (options) => {
|
|
47323
47475
|
const { stopDaemon: stopDaemon2, isDaemonRunning: isDaemonRunning2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
47324
47476
|
const { stopSessionHost: stopSessionHost2 } = await Promise.resolve().then(() => (init_session_host(), session_host_exports));
|
|
47325
|
-
const { spawn:
|
|
47477
|
+
const { spawn: spawn5 } = await import("child_process");
|
|
47326
47478
|
if (isDaemonRunning2()) {
|
|
47327
47479
|
console.log(import_chalk5.default.yellow("\n Stopping existing daemon..."));
|
|
47328
47480
|
stopDaemon2();
|
|
@@ -47334,7 +47486,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
47334
47486
|
const args = ["daemon", "-p", options.port || "19222"];
|
|
47335
47487
|
if (options.server) args.push("--server", options.server);
|
|
47336
47488
|
if (options.dev) args.push("--dev");
|
|
47337
|
-
const child =
|
|
47489
|
+
const child = spawn5(process.execPath, [process.argv[1], ...args], {
|
|
47338
47490
|
detached: true,
|
|
47339
47491
|
stdio: "ignore",
|
|
47340
47492
|
env: { ...process.env }
|
|
@@ -47353,7 +47505,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
47353
47505
|
hideCommand(program2.command("daemon:upgrade").description("Upgrade ADHDev to latest version and restart daemon").option("--no-restart", "Upgrade only, skip daemon restart").action(async (options) => {
|
|
47354
47506
|
const { isDaemonRunning: isDaemonRunning2, stopDaemon: stopDaemon2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
47355
47507
|
const { stopSessionHost: stopSessionHost2 } = await Promise.resolve().then(() => (init_session_host(), session_host_exports));
|
|
47356
|
-
const { execSync: execSync7, spawn:
|
|
47508
|
+
const { execSync: execSync7, spawn: spawn5 } = await import("child_process");
|
|
47357
47509
|
const fsMod = await import("fs");
|
|
47358
47510
|
const pathMod = await import("path");
|
|
47359
47511
|
console.log(import_chalk5.default.bold("\n \u{1F504} ADHDev Upgrade\n"));
|
|
@@ -47411,7 +47563,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
47411
47563
|
await new Promise((r) => setTimeout(r, 2e3));
|
|
47412
47564
|
stopSessionHost2();
|
|
47413
47565
|
await new Promise((r) => setTimeout(r, 500));
|
|
47414
|
-
const child =
|
|
47566
|
+
const child = spawn5(process.execPath, [process.argv[1], "daemon", "-p", "19222"], {
|
|
47415
47567
|
detached: true,
|
|
47416
47568
|
stdio: "ignore",
|
|
47417
47569
|
env: { ...process.env }
|
|
@@ -47620,35 +47772,35 @@ function registerProviderCommands(program2) {
|
|
|
47620
47772
|
let osPaths = {};
|
|
47621
47773
|
let processNames = {};
|
|
47622
47774
|
if (category === "ide") {
|
|
47623
|
-
const
|
|
47624
|
-
const
|
|
47625
|
-
const
|
|
47626
|
-
if (
|
|
47775
|
+
const fs17 = await import("fs");
|
|
47776
|
+
const path19 = await import("path");
|
|
47777
|
+
const os22 = await import("os");
|
|
47778
|
+
if (os22.platform() === "darwin") {
|
|
47627
47779
|
while (true) {
|
|
47628
47780
|
const p = (await rl.question(`macOS Application Path (e.g. /Applications/${defaultName}.app): `)).trim() || `/Applications/${defaultName}.app`;
|
|
47629
47781
|
if (p === "skip") break;
|
|
47630
|
-
if (!
|
|
47782
|
+
if (!fs17.existsSync(p)) {
|
|
47631
47783
|
console.log(import_chalk6.default.red(` \u2717 Path not found: ${p}`));
|
|
47632
47784
|
console.log(import_chalk6.default.gray(` (Please provide the exact absolute path to the .app or binary, or type 'skip')`));
|
|
47633
47785
|
continue;
|
|
47634
47786
|
}
|
|
47635
47787
|
console.log(import_chalk6.default.green(` \u2713 Path verified: ${p}`));
|
|
47636
47788
|
osPaths["darwin"] = [p];
|
|
47637
|
-
processNames["darwin"] =
|
|
47789
|
+
processNames["darwin"] = path19.basename(p, ".app");
|
|
47638
47790
|
break;
|
|
47639
47791
|
}
|
|
47640
|
-
} else if (
|
|
47792
|
+
} else if (os22.platform() === "win32") {
|
|
47641
47793
|
while (true) {
|
|
47642
47794
|
const p = (await rl.question(`Windows Executable Path (e.g. C:\\Program Files\\${defaultName}\\${defaultName}.exe): `)).trim();
|
|
47643
47795
|
if (!p || p === "skip") break;
|
|
47644
|
-
if (!
|
|
47796
|
+
if (!fs17.existsSync(p)) {
|
|
47645
47797
|
console.log(import_chalk6.default.red(` \u2717 Path not found: ${p}`));
|
|
47646
47798
|
console.log(import_chalk6.default.gray(` (Please provide the exact absolute path, or type 'skip')`));
|
|
47647
47799
|
continue;
|
|
47648
47800
|
}
|
|
47649
47801
|
console.log(import_chalk6.default.green(` \u2713 Path verified: ${p}`));
|
|
47650
47802
|
osPaths["win32"] = [p];
|
|
47651
|
-
processNames["win32"] =
|
|
47803
|
+
processNames["win32"] = path19.basename(p, ".exe");
|
|
47652
47804
|
break;
|
|
47653
47805
|
}
|
|
47654
47806
|
}
|
|
@@ -48324,8 +48476,8 @@ function registerCdpCommands(program2) {
|
|
|
48324
48476
|
}
|
|
48325
48477
|
const output = typeof result === "string" ? result : JSON.stringify(result, null, 2);
|
|
48326
48478
|
if (options.output) {
|
|
48327
|
-
const
|
|
48328
|
-
|
|
48479
|
+
const fs17 = await import("fs");
|
|
48480
|
+
fs17.writeFileSync(options.output, output, "utf-8");
|
|
48329
48481
|
console.log(import_chalk6.default.green(`
|
|
48330
48482
|
\u2713 Saved to ${options.output} (${output.length} chars)
|
|
48331
48483
|
`));
|
|
@@ -48428,8 +48580,8 @@ function registerCdpCommands(program2) {
|
|
|
48428
48580
|
ws2.on("message", async (data) => {
|
|
48429
48581
|
const msg = JSON.parse(data.toString());
|
|
48430
48582
|
if (msg.id === 1 && msg.result?.data) {
|
|
48431
|
-
const
|
|
48432
|
-
|
|
48583
|
+
const fs17 = await import("fs");
|
|
48584
|
+
fs17.writeFileSync(options.output, Buffer.from(msg.result.data, "base64"));
|
|
48433
48585
|
console.log(import_chalk6.default.green(`
|
|
48434
48586
|
\u2713 Screenshot saved to ${options.output}
|
|
48435
48587
|
`));
|
|
@@ -48478,29 +48630,35 @@ registerSetupCommands(program, _cliProviderLoader);
|
|
|
48478
48630
|
registerDaemonCommands(program, pkgVersion2);
|
|
48479
48631
|
registerProviderCommands(program);
|
|
48480
48632
|
registerCdpCommands(program);
|
|
48481
|
-
|
|
48482
|
-
|
|
48483
|
-
|
|
48484
|
-
|
|
48485
|
-
|
|
48486
|
-
|
|
48487
|
-
|
|
48488
|
-
|
|
48489
|
-
|
|
48490
|
-
|
|
48491
|
-
|
|
48492
|
-
|
|
48493
|
-
|
|
48494
|
-
|
|
48495
|
-
|
|
48496
|
-
|
|
48497
|
-
|
|
48498
|
-
|
|
48499
|
-
console.
|
|
48633
|
+
void (async () => {
|
|
48634
|
+
const helperMode = await maybeRunDaemonUpgradeHelperFromEnv();
|
|
48635
|
+
if (helperMode) {
|
|
48636
|
+
return;
|
|
48637
|
+
}
|
|
48638
|
+
if (process.argv.length <= 2) {
|
|
48639
|
+
program.outputHelp();
|
|
48640
|
+
console.log();
|
|
48641
|
+
console.log(import_chalk7.default.gray(" Quick start:"));
|
|
48642
|
+
console.log(import_chalk7.default.gray(" adhdev setup \u2014 First-time setup & login"));
|
|
48643
|
+
console.log(import_chalk7.default.gray(" adhdev daemon \u2014 Start unified daemon (Required)"));
|
|
48644
|
+
console.log(import_chalk7.default.gray(" adhdev standalone \u2014 Start standalone local dashboard & daemon"));
|
|
48645
|
+
console.log(import_chalk7.default.gray(" adhdev launch cursor \u2014 Launch IDE with CDP (e.g. cursor, windsurf)"));
|
|
48646
|
+
console.log(import_chalk7.default.gray(" adhdev launch claude \u2014 Launch CLI agent (e.g. gemini, claude)"));
|
|
48647
|
+
console.log(import_chalk7.default.gray(" adhdev status \u2014 Check current setup"));
|
|
48648
|
+
console.log(import_chalk7.default.gray(" adhdev update \u2014 Upgrade to latest version"));
|
|
48649
|
+
console.log();
|
|
48650
|
+
console.log(import_chalk7.default.gray(" Advanced tools:"));
|
|
48651
|
+
console.log(import_chalk7.default.gray(" adhdev provider ... \u2014 Provider development commands"));
|
|
48652
|
+
console.log(import_chalk7.default.gray(" adhdev cdp ... \u2014 CDP debugging tools"));
|
|
48653
|
+
console.log();
|
|
48654
|
+
return;
|
|
48655
|
+
}
|
|
48656
|
+
await program.parseAsync(process.argv);
|
|
48657
|
+
})().catch((err) => {
|
|
48658
|
+
console.error(import_chalk7.default.red(`
|
|
48500
48659
|
\u2717 ${err.message}`));
|
|
48501
|
-
|
|
48502
|
-
|
|
48503
|
-
}
|
|
48660
|
+
process.exit(1);
|
|
48661
|
+
});
|
|
48504
48662
|
/*! Bundled license information:
|
|
48505
48663
|
|
|
48506
48664
|
chokidar/index.js:
|