adhdev 0.8.12 → 0.8.13
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 +558 -329
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +502 -320
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/vendor/session-host-daemon/index.js +38 -62
- package/vendor/session-host-daemon/index.js.map +1 -1
- package/vendor/session-host-daemon/index.mjs +25 -49
- package/vendor/session-host-daemon/index.mjs.map +1 -1
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.d.mts +30 -1
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.d.ts +30 -1
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.js +73 -6
- 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 +77 -6
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.mjs.map +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
|
9
9
|
var __esm = (fn, res) => function __init() {
|
|
10
10
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
11
|
};
|
|
12
|
-
var __commonJS = (cb, mod) => function
|
|
12
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
13
13
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
14
14
|
};
|
|
15
15
|
var __export = (target, all) => {
|
|
@@ -572,18 +572,18 @@ function checkPathExists(paths) {
|
|
|
572
572
|
return null;
|
|
573
573
|
}
|
|
574
574
|
async function detectIDEs() {
|
|
575
|
-
const
|
|
575
|
+
const os24 = (0, import_os2.platform)();
|
|
576
576
|
const results = [];
|
|
577
577
|
for (const def of getMergedDefinitions()) {
|
|
578
578
|
const cliPath = findCliCommand(def.cli);
|
|
579
|
-
const appPath = checkPathExists(def.paths[
|
|
579
|
+
const appPath = checkPathExists(def.paths[os24] || []);
|
|
580
580
|
const installed = !!(cliPath || appPath);
|
|
581
581
|
let resolvedCli = cliPath;
|
|
582
|
-
if (!resolvedCli && appPath &&
|
|
582
|
+
if (!resolvedCli && appPath && os24 === "darwin") {
|
|
583
583
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
584
584
|
if ((0, import_fs2.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
585
585
|
}
|
|
586
|
-
if (!resolvedCli && appPath &&
|
|
586
|
+
if (!resolvedCli && appPath && os24 === "win32") {
|
|
587
587
|
const { dirname: dirname9 } = await import("path");
|
|
588
588
|
const appDir = dirname9(appPath);
|
|
589
589
|
const candidates = [
|
|
@@ -644,8 +644,8 @@ function execAsync(cmd, timeoutMs = 5e3) {
|
|
|
644
644
|
});
|
|
645
645
|
}
|
|
646
646
|
async function detectCLIs(providerLoader) {
|
|
647
|
-
const
|
|
648
|
-
const whichCmd =
|
|
647
|
+
const platform11 = os2.platform();
|
|
648
|
+
const whichCmd = platform11 === "win32" ? "where" : "which";
|
|
649
649
|
const cliList = providerLoader ? providerLoader.getCliDetectionList() : [];
|
|
650
650
|
const results = await Promise.all(
|
|
651
651
|
cliList.map(async (cli) => {
|
|
@@ -680,6 +680,39 @@ async function detectCLIs(providerLoader) {
|
|
|
680
680
|
}
|
|
681
681
|
async function detectCLI(cliId, providerLoader) {
|
|
682
682
|
const resolvedId = providerLoader ? providerLoader.resolveAlias(cliId) : cliId;
|
|
683
|
+
if (providerLoader) {
|
|
684
|
+
const cliList = providerLoader.getCliDetectionList();
|
|
685
|
+
const target = cliList.find((c) => c.id === resolvedId);
|
|
686
|
+
if (target) {
|
|
687
|
+
const platform11 = os2.platform();
|
|
688
|
+
const whichCmd = platform11 === "win32" ? "where" : "which";
|
|
689
|
+
try {
|
|
690
|
+
const pathResult = await execAsync(`${whichCmd} ${target.command}`);
|
|
691
|
+
if (!pathResult) return null;
|
|
692
|
+
const firstPath = pathResult.split("\n")[0];
|
|
693
|
+
let version2;
|
|
694
|
+
try {
|
|
695
|
+
const versionCommands = [
|
|
696
|
+
target.versionCommand,
|
|
697
|
+
`${target.command} --version`,
|
|
698
|
+
`${target.command} -V`,
|
|
699
|
+
`${target.command} -v`
|
|
700
|
+
].filter((v) => !!v);
|
|
701
|
+
for (const versionCommand of versionCommands) {
|
|
702
|
+
const versionResult = await execAsync(versionCommand, 3e3);
|
|
703
|
+
if (versionResult) {
|
|
704
|
+
version2 = parseVersion(versionResult);
|
|
705
|
+
break;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
} catch {
|
|
709
|
+
}
|
|
710
|
+
return { ...target, installed: true, version: version2, path: firstPath };
|
|
711
|
+
} catch {
|
|
712
|
+
return null;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
683
716
|
const all = await detectCLIs(providerLoader);
|
|
684
717
|
return all.find((c) => c.id === resolvedId && c.installed) || null;
|
|
685
718
|
}
|
|
@@ -6196,6 +6229,13 @@ function logTerminalBackendSelection(preference, ghosttyAvailable, backendKind)
|
|
|
6196
6229
|
const key = `${preference}:${ghosttyAvailable}:${backendKind}`;
|
|
6197
6230
|
if (loggedTerminalBackends.has(key)) return;
|
|
6198
6231
|
loggedTerminalBackends.add(key);
|
|
6232
|
+
if (backendKind === "xterm" && preference !== "xterm" && !ghosttyAvailable) {
|
|
6233
|
+
LOG.warn(
|
|
6234
|
+
"Terminal",
|
|
6235
|
+
`[terminal-screen] ghostty-vt unavailable; using xterm fallback (preference=${preference})`
|
|
6236
|
+
);
|
|
6237
|
+
return;
|
|
6238
|
+
}
|
|
6199
6239
|
LOG.info(
|
|
6200
6240
|
"Terminal",
|
|
6201
6241
|
`[terminal-screen] backend=${backendKind} preference=${preference} ghosttyAvailable=${ghosttyAvailable}`
|
|
@@ -6258,10 +6298,11 @@ var init_terminal_screen = __esm({
|
|
|
6258
6298
|
});
|
|
6259
6299
|
|
|
6260
6300
|
// ../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts
|
|
6261
|
-
var pty, NodePtyRuntimeTransport, NodePtyTransportFactory;
|
|
6301
|
+
var os7, pty, NodePtyRuntimeTransport, NodePtyTransportFactory;
|
|
6262
6302
|
var init_pty_transport = __esm({
|
|
6263
6303
|
"../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts"() {
|
|
6264
6304
|
"use strict";
|
|
6305
|
+
os7 = __toESM(require("os"));
|
|
6265
6306
|
try {
|
|
6266
6307
|
pty = require("node-pty");
|
|
6267
6308
|
} catch {
|
|
@@ -6298,11 +6339,21 @@ var init_pty_transport = __esm({
|
|
|
6298
6339
|
NodePtyTransportFactory = class {
|
|
6299
6340
|
spawn(command, args, options) {
|
|
6300
6341
|
if (!pty) throw new Error("node-pty is not installed");
|
|
6342
|
+
let cwd = options.cwd;
|
|
6343
|
+
if (cwd) {
|
|
6344
|
+
try {
|
|
6345
|
+
const fs19 = require("fs");
|
|
6346
|
+
const stat4 = fs19.statSync(cwd);
|
|
6347
|
+
if (!stat4.isDirectory()) cwd = os7.homedir();
|
|
6348
|
+
} catch {
|
|
6349
|
+
cwd = os7.homedir();
|
|
6350
|
+
}
|
|
6351
|
+
}
|
|
6301
6352
|
const handle = pty.spawn(command, args, {
|
|
6302
6353
|
name: "xterm-256color",
|
|
6303
6354
|
cols: options.cols,
|
|
6304
6355
|
rows: options.rows,
|
|
6305
|
-
cwd
|
|
6356
|
+
cwd,
|
|
6306
6357
|
env: options.env
|
|
6307
6358
|
});
|
|
6308
6359
|
return new NodePtyRuntimeTransport(handle);
|
|
@@ -6311,33 +6362,39 @@ var init_pty_transport = __esm({
|
|
|
6311
6362
|
}
|
|
6312
6363
|
});
|
|
6313
6364
|
|
|
6314
|
-
// ../../oss/packages/
|
|
6315
|
-
|
|
6316
|
-
__export(provider_cli_adapter_exports, {
|
|
6317
|
-
ProviderCliAdapter: () => ProviderCliAdapter,
|
|
6318
|
-
normalizeCliProviderForRuntime: () => normalizeCliProviderForRuntime
|
|
6319
|
-
});
|
|
6320
|
-
function stripAnsi(str) {
|
|
6321
|
-
return str.replace(/\x1B\][^\x07]*\x07/g, "").replace(/\x1B\][\s\S]*?\x1B\\/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B\[\d*[A-HJKSTfG]/g, " ").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "").replace(/ +/g, " ");
|
|
6322
|
-
}
|
|
6323
|
-
function stripTerminalNoise(str) {
|
|
6324
|
-
return String(str || "").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/g, "").replace(/(^|[\s([])(?:\??\d{1,4}(?:;\d{1,4})*[A-Za-z])(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:\[\??\d{1,4}(?:;\d{1,4})*[A-Za-z])(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:\d{1,4};\?)(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:\d+\$r[0-9;\" ]*[A-Za-z]?)(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:>\|[A-Za-z0-9_.:-]+(?:\([^)]*\))?)(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:[A-Z]\d(?:\s+[A-Z]\d)+)(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:\d+;[^\s)\]]+)(?=$|[\s)\]])/g, "$1").replace(/\r+/g, "\n").replace(/[ \t]+\n/g, "\n").replace(/\n{3,}/g, "\n\n").replace(/ {2,}/g, " ");
|
|
6325
|
-
}
|
|
6326
|
-
function sanitizeTerminalText(str) {
|
|
6327
|
-
return stripTerminalNoise(stripAnsi(str));
|
|
6328
|
-
}
|
|
6329
|
-
function applyPreferredTerminalColorEnv(env) {
|
|
6330
|
-
if (env.NO_COLOR) return;
|
|
6331
|
-
if (!env.TERM || env.TERM === "xterm-color") {
|
|
6332
|
-
env.TERM = "xterm-256color";
|
|
6333
|
-
}
|
|
6334
|
-
if (!env.COLORTERM) env.COLORTERM = "truecolor";
|
|
6365
|
+
// ../../oss/packages/session-host-core/dist/index.mjs
|
|
6366
|
+
function getDefaultSessionHostEndpoint(appName = "adhdev") {
|
|
6335
6367
|
if (process.platform === "win32") {
|
|
6336
|
-
|
|
6337
|
-
|
|
6368
|
+
return {
|
|
6369
|
+
kind: "pipe",
|
|
6370
|
+
path: `\\\\.\\pipe\\${appName}-session-host`
|
|
6371
|
+
};
|
|
6338
6372
|
}
|
|
6373
|
+
return {
|
|
6374
|
+
kind: "unix",
|
|
6375
|
+
path: path22.join(os8.tmpdir(), `${appName}-session-host.sock`)
|
|
6376
|
+
};
|
|
6377
|
+
}
|
|
6378
|
+
function serializeEnvelope(envelope) {
|
|
6379
|
+
return `${JSON.stringify(envelope)}
|
|
6380
|
+
`;
|
|
6381
|
+
}
|
|
6382
|
+
function createLineParser(onEnvelope) {
|
|
6383
|
+
let buffer = "";
|
|
6384
|
+
return (chunk) => {
|
|
6385
|
+
buffer += chunk.toString();
|
|
6386
|
+
let newlineIndex = buffer.indexOf("\n");
|
|
6387
|
+
while (newlineIndex >= 0) {
|
|
6388
|
+
const rawLine = buffer.slice(0, newlineIndex).trim();
|
|
6389
|
+
buffer = buffer.slice(newlineIndex + 1);
|
|
6390
|
+
if (rawLine) {
|
|
6391
|
+
onEnvelope(JSON.parse(rawLine));
|
|
6392
|
+
}
|
|
6393
|
+
newlineIndex = buffer.indexOf("\n");
|
|
6394
|
+
}
|
|
6395
|
+
};
|
|
6339
6396
|
}
|
|
6340
|
-
function
|
|
6397
|
+
function sanitizeSpawnEnv(baseEnv, overrides) {
|
|
6341
6398
|
const env = {};
|
|
6342
6399
|
const source = { ...baseEnv, ...overrides || {} };
|
|
6343
6400
|
for (const [key, value] of Object.entries(source)) {
|
|
@@ -6349,9 +6406,185 @@ function buildCliSpawnEnv(baseEnv, overrides) {
|
|
|
6349
6406
|
delete env[key];
|
|
6350
6407
|
}
|
|
6351
6408
|
}
|
|
6352
|
-
|
|
6409
|
+
applyTerminalColorEnv(env);
|
|
6353
6410
|
return env;
|
|
6354
6411
|
}
|
|
6412
|
+
function applyTerminalColorEnv(env) {
|
|
6413
|
+
if (env.NO_COLOR) return;
|
|
6414
|
+
if (!env.TERM || env.TERM === "xterm-color") {
|
|
6415
|
+
env.TERM = "xterm-256color";
|
|
6416
|
+
}
|
|
6417
|
+
if (!env.COLORTERM) env.COLORTERM = "truecolor";
|
|
6418
|
+
if (process.platform === "win32") {
|
|
6419
|
+
if (!env.FORCE_COLOR) env.FORCE_COLOR = "1";
|
|
6420
|
+
if (!env.CLICOLOR) env.CLICOLOR = "1";
|
|
6421
|
+
}
|
|
6422
|
+
}
|
|
6423
|
+
function ensureNodePtySpawnHelperPermissions(logFn) {
|
|
6424
|
+
if (os22.platform() === "win32") return;
|
|
6425
|
+
try {
|
|
6426
|
+
const fs19 = __require("fs");
|
|
6427
|
+
const ptyDir = path32.resolve(path32.dirname(__require.resolve("node-pty")), "..");
|
|
6428
|
+
const platformArch = `${os22.platform()}-${os22.arch()}`;
|
|
6429
|
+
const helper = path32.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
6430
|
+
if (fs19.existsSync(helper)) {
|
|
6431
|
+
const stat4 = fs19.statSync(helper);
|
|
6432
|
+
if (!(stat4.mode & 73)) {
|
|
6433
|
+
fs19.chmodSync(helper, stat4.mode | 493);
|
|
6434
|
+
logFn?.(`Fixed spawn-helper permissions: ${helper}`);
|
|
6435
|
+
}
|
|
6436
|
+
}
|
|
6437
|
+
} catch {
|
|
6438
|
+
}
|
|
6439
|
+
}
|
|
6440
|
+
var os8, path22, net, import_crypto3, os22, path32, __require, SessionHostClient;
|
|
6441
|
+
var init_dist = __esm({
|
|
6442
|
+
"../../oss/packages/session-host-core/dist/index.mjs"() {
|
|
6443
|
+
"use strict";
|
|
6444
|
+
os8 = __toESM(require("os"), 1);
|
|
6445
|
+
path22 = __toESM(require("path"), 1);
|
|
6446
|
+
net = __toESM(require("net"), 1);
|
|
6447
|
+
import_crypto3 = require("crypto");
|
|
6448
|
+
os22 = __toESM(require("os"), 1);
|
|
6449
|
+
path32 = __toESM(require("path"), 1);
|
|
6450
|
+
__require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
6451
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
6452
|
+
}) : x)(function(x) {
|
|
6453
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6454
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6455
|
+
});
|
|
6456
|
+
SessionHostClient = class {
|
|
6457
|
+
endpoint;
|
|
6458
|
+
socket = null;
|
|
6459
|
+
requestWaiters = /* @__PURE__ */ new Map();
|
|
6460
|
+
eventListeners = /* @__PURE__ */ new Set();
|
|
6461
|
+
constructor(options = {}) {
|
|
6462
|
+
this.endpoint = options.endpoint || getDefaultSessionHostEndpoint(options.appName || "adhdev");
|
|
6463
|
+
}
|
|
6464
|
+
async connect() {
|
|
6465
|
+
if (this.socket && !this.socket.destroyed) return;
|
|
6466
|
+
if (this.socket) {
|
|
6467
|
+
try {
|
|
6468
|
+
this.socket.destroy();
|
|
6469
|
+
} catch {
|
|
6470
|
+
}
|
|
6471
|
+
this.socket = null;
|
|
6472
|
+
}
|
|
6473
|
+
const socket = net.createConnection(this.endpoint.path);
|
|
6474
|
+
this.socket = socket;
|
|
6475
|
+
socket.on("data", createLineParser((envelope) => {
|
|
6476
|
+
if (envelope.kind === "response") {
|
|
6477
|
+
const waiter = this.requestWaiters.get(envelope.requestId);
|
|
6478
|
+
if (waiter) {
|
|
6479
|
+
this.requestWaiters.delete(envelope.requestId);
|
|
6480
|
+
waiter.resolve(envelope.response);
|
|
6481
|
+
}
|
|
6482
|
+
return;
|
|
6483
|
+
}
|
|
6484
|
+
if (envelope.kind === "event") {
|
|
6485
|
+
for (const listener of this.eventListeners) listener(envelope.event);
|
|
6486
|
+
}
|
|
6487
|
+
}));
|
|
6488
|
+
socket.on("error", (error48) => {
|
|
6489
|
+
for (const waiter of this.requestWaiters.values()) {
|
|
6490
|
+
waiter.reject(error48);
|
|
6491
|
+
}
|
|
6492
|
+
this.requestWaiters.clear();
|
|
6493
|
+
if (this.socket === socket) {
|
|
6494
|
+
this.socket = null;
|
|
6495
|
+
}
|
|
6496
|
+
try {
|
|
6497
|
+
socket.destroy();
|
|
6498
|
+
} catch {
|
|
6499
|
+
}
|
|
6500
|
+
});
|
|
6501
|
+
await new Promise((resolve22, reject) => {
|
|
6502
|
+
socket.once("connect", () => resolve22());
|
|
6503
|
+
socket.once("error", reject);
|
|
6504
|
+
});
|
|
6505
|
+
}
|
|
6506
|
+
onEvent(listener) {
|
|
6507
|
+
this.eventListeners.add(listener);
|
|
6508
|
+
return () => {
|
|
6509
|
+
this.eventListeners.delete(listener);
|
|
6510
|
+
};
|
|
6511
|
+
}
|
|
6512
|
+
async request(request) {
|
|
6513
|
+
await this.connect();
|
|
6514
|
+
if (!this.socket) throw new Error("Session host socket unavailable");
|
|
6515
|
+
const requestId = (0, import_crypto3.randomUUID)();
|
|
6516
|
+
const envelope = {
|
|
6517
|
+
kind: "request",
|
|
6518
|
+
requestId,
|
|
6519
|
+
request
|
|
6520
|
+
};
|
|
6521
|
+
const response = await new Promise((resolve22, reject) => {
|
|
6522
|
+
const timeout = setTimeout(() => {
|
|
6523
|
+
this.requestWaiters.delete(requestId);
|
|
6524
|
+
reject(new Error(`Session host request timed out after 30s (${request.type})`));
|
|
6525
|
+
}, 3e4);
|
|
6526
|
+
this.requestWaiters.set(requestId, {
|
|
6527
|
+
resolve: (value) => {
|
|
6528
|
+
clearTimeout(timeout);
|
|
6529
|
+
resolve22(value);
|
|
6530
|
+
},
|
|
6531
|
+
reject: (error48) => {
|
|
6532
|
+
clearTimeout(timeout);
|
|
6533
|
+
reject(error48);
|
|
6534
|
+
}
|
|
6535
|
+
});
|
|
6536
|
+
this.socket?.write(serializeEnvelope(envelope));
|
|
6537
|
+
});
|
|
6538
|
+
return response;
|
|
6539
|
+
}
|
|
6540
|
+
async close() {
|
|
6541
|
+
if (!this.socket) return;
|
|
6542
|
+
const socket = this.socket;
|
|
6543
|
+
this.socket = null;
|
|
6544
|
+
for (const waiter of this.requestWaiters.values()) {
|
|
6545
|
+
waiter.reject(new Error("Session host client closed"));
|
|
6546
|
+
}
|
|
6547
|
+
this.requestWaiters.clear();
|
|
6548
|
+
await new Promise((resolve22) => {
|
|
6549
|
+
let settled = false;
|
|
6550
|
+
const done = () => {
|
|
6551
|
+
if (settled) return;
|
|
6552
|
+
settled = true;
|
|
6553
|
+
resolve22();
|
|
6554
|
+
};
|
|
6555
|
+
socket.once("close", done);
|
|
6556
|
+
socket.end();
|
|
6557
|
+
socket.destroy();
|
|
6558
|
+
setTimeout(done, 50);
|
|
6559
|
+
});
|
|
6560
|
+
}
|
|
6561
|
+
};
|
|
6562
|
+
}
|
|
6563
|
+
});
|
|
6564
|
+
|
|
6565
|
+
// ../../oss/packages/daemon-core/src/cli-adapters/spawn-env.ts
|
|
6566
|
+
var init_spawn_env = __esm({
|
|
6567
|
+
"../../oss/packages/daemon-core/src/cli-adapters/spawn-env.ts"() {
|
|
6568
|
+
"use strict";
|
|
6569
|
+
init_dist();
|
|
6570
|
+
}
|
|
6571
|
+
});
|
|
6572
|
+
|
|
6573
|
+
// ../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts
|
|
6574
|
+
var provider_cli_adapter_exports = {};
|
|
6575
|
+
__export(provider_cli_adapter_exports, {
|
|
6576
|
+
ProviderCliAdapter: () => ProviderCliAdapter,
|
|
6577
|
+
normalizeCliProviderForRuntime: () => normalizeCliProviderForRuntime
|
|
6578
|
+
});
|
|
6579
|
+
function stripAnsi(str) {
|
|
6580
|
+
return str.replace(/\x1B\][^\x07]*\x07/g, "").replace(/\x1B\][\s\S]*?\x1B\\/g, "").replace(/\x1B[P^_X][\s\S]*?(?:\x07|\x1B\\)/g, "").replace(/\x1B\[\d*[A-HJKSTfG]/g, " ").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "").replace(/ +/g, " ");
|
|
6581
|
+
}
|
|
6582
|
+
function stripTerminalNoise(str) {
|
|
6583
|
+
return String(str || "").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/g, "").replace(/(^|[\s([])(?:\??\d{1,4}(?:;\d{1,4})*[A-Za-z])(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:\[\??\d{1,4}(?:;\d{1,4})*[A-Za-z])(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:\d{1,4};\?)(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:\d+\$r[0-9;\" ]*[A-Za-z]?)(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:>\|[A-Za-z0-9_.:-]+(?:\([^)]*\))?)(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:[A-Z]\d(?:\s+[A-Z]\d)+)(?=$|[\s)\]])/g, "$1").replace(/(^|[\s([])(?:\d+;[^\s)\]]+)(?=$|[\s)\]])/g, "$1").replace(/\r+/g, "\n").replace(/[ \t]+\n/g, "\n").replace(/\n{3,}/g, "\n\n").replace(/ {2,}/g, " ");
|
|
6584
|
+
}
|
|
6585
|
+
function sanitizeTerminalText(str) {
|
|
6586
|
+
return stripTerminalNoise(stripAnsi(str));
|
|
6587
|
+
}
|
|
6355
6588
|
function computeTerminalQueryTail(buffer) {
|
|
6356
6589
|
const prefixes = ["\x1B[6n", "\x1B[?6n"];
|
|
6357
6590
|
const maxLength = prefixes.reduce((n, value) => Math.max(n, value.length), 0) - 1;
|
|
@@ -6365,7 +6598,7 @@ function computeTerminalQueryTail(buffer) {
|
|
|
6365
6598
|
return "";
|
|
6366
6599
|
}
|
|
6367
6600
|
function findBinary(name) {
|
|
6368
|
-
const isWin =
|
|
6601
|
+
const isWin = os9.platform() === "win32";
|
|
6369
6602
|
try {
|
|
6370
6603
|
const cmd = isWin ? `where ${name}` : `which ${name}`;
|
|
6371
6604
|
return (0, import_child_process4.execSync)(cmd, { encoding: "utf-8", timeout: 5e3, stdio: ["pipe", "pipe", "pipe"] }).trim().split("\n")[0].trim();
|
|
@@ -6413,7 +6646,7 @@ function looksLikeMachOOrElf(filePath) {
|
|
|
6413
6646
|
}
|
|
6414
6647
|
function shSingleQuote(arg) {
|
|
6415
6648
|
if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
|
|
6416
|
-
if (
|
|
6649
|
+
if (os9.platform() === "win32") {
|
|
6417
6650
|
return `"${arg.replace(/"/g, '""')}"`;
|
|
6418
6651
|
}
|
|
6419
6652
|
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
@@ -6480,37 +6713,24 @@ function normalizeCliProviderForRuntime(raw) {
|
|
|
6480
6713
|
}
|
|
6481
6714
|
};
|
|
6482
6715
|
}
|
|
6483
|
-
var
|
|
6716
|
+
var os9, path7, import_child_process4, pty2, buildCliSpawnEnv, ProviderCliAdapter;
|
|
6484
6717
|
var init_provider_cli_adapter = __esm({
|
|
6485
6718
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
|
|
6486
6719
|
"use strict";
|
|
6487
|
-
|
|
6720
|
+
os9 = __toESM(require("os"));
|
|
6488
6721
|
path7 = __toESM(require("path"));
|
|
6489
6722
|
import_child_process4 = require("child_process");
|
|
6490
6723
|
init_logger();
|
|
6491
6724
|
init_terminal_screen();
|
|
6492
6725
|
init_pty_transport();
|
|
6726
|
+
init_spawn_env();
|
|
6493
6727
|
try {
|
|
6494
6728
|
pty2 = require("node-pty");
|
|
6495
|
-
|
|
6496
|
-
try {
|
|
6497
|
-
const fs19 = require("fs");
|
|
6498
|
-
const ptyDir = path7.resolve(path7.dirname(require.resolve("node-pty")), "..");
|
|
6499
|
-
const platformArch = `${os7.platform()}-${os7.arch()}`;
|
|
6500
|
-
const helper = path7.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
6501
|
-
if (fs19.existsSync(helper)) {
|
|
6502
|
-
const stat4 = fs19.statSync(helper);
|
|
6503
|
-
if (!(stat4.mode & 73)) {
|
|
6504
|
-
fs19.chmodSync(helper, stat4.mode | 493);
|
|
6505
|
-
LOG.info("CLI", "[node-pty] Fixed spawn-helper permissions");
|
|
6506
|
-
}
|
|
6507
|
-
}
|
|
6508
|
-
} catch {
|
|
6509
|
-
}
|
|
6510
|
-
}
|
|
6729
|
+
ensureNodePtySpawnHelperPermissions((msg) => LOG.info("CLI", msg));
|
|
6511
6730
|
} catch {
|
|
6512
6731
|
LOG.error("CLI", "[ProviderCliAdapter] node-pty not found. Terminal features disabled.");
|
|
6513
6732
|
}
|
|
6733
|
+
buildCliSpawnEnv = sanitizeSpawnEnv;
|
|
6514
6734
|
ProviderCliAdapter = class _ProviderCliAdapter {
|
|
6515
6735
|
constructor(provider, workingDir, extraArgs = [], transportFactory = new NodePtyTransportFactory()) {
|
|
6516
6736
|
this.extraArgs = extraArgs;
|
|
@@ -6518,7 +6738,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
6518
6738
|
this.transportFactory = transportFactory;
|
|
6519
6739
|
this.cliType = provider.type;
|
|
6520
6740
|
this.cliName = provider.name;
|
|
6521
|
-
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/,
|
|
6741
|
+
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os9.homedir()) : workingDir;
|
|
6522
6742
|
const t = provider.timeouts || {};
|
|
6523
6743
|
this.timeouts = {
|
|
6524
6744
|
ptyFlush: t.ptyFlush ?? 50,
|
|
@@ -6825,7 +7045,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
6825
7045
|
if (this.ptyProcess) return;
|
|
6826
7046
|
const { spawn: spawnConfig } = this.provider;
|
|
6827
7047
|
const binaryPath = findBinary(spawnConfig.command);
|
|
6828
|
-
const isWin =
|
|
7048
|
+
const isWin = os9.platform() === "win32";
|
|
6829
7049
|
const allArgs = [...spawnConfig.args, ...this.extraArgs];
|
|
6830
7050
|
LOG.info("CLI", `[${this.cliType}] Spawning in ${this.workingDir}`);
|
|
6831
7051
|
this.resetTraceSession();
|
|
@@ -6877,6 +7097,12 @@ var init_provider_cli_adapter = __esm({
|
|
|
6877
7097
|
shellArgs = ["-l", "-c", fullCmd];
|
|
6878
7098
|
this.ptyProcess = this.transportFactory.spawn(shellCmd, shellArgs, ptyOpts);
|
|
6879
7099
|
} else {
|
|
7100
|
+
if (isWin) {
|
|
7101
|
+
const hint = /error code 267|ERROR_DIRECTORY/i.test(msg) ? " (working directory does not exist or is not a directory)" : /error code 740|elevation/i.test(msg) ? " (requires administrator privileges)" : /error code 2|ENOENT|not found/i.test(msg) ? ` (executable not found: ${shellCmd})` : "";
|
|
7102
|
+
if (hint) {
|
|
7103
|
+
throw new Error(`Failed to spawn CLI${hint}: ${msg}`);
|
|
7104
|
+
}
|
|
7105
|
+
}
|
|
6880
7106
|
throw err;
|
|
6881
7107
|
}
|
|
6882
7108
|
}
|
|
@@ -7629,7 +7855,8 @@ ${data.message || ""}`.trim();
|
|
|
7629
7855
|
const payload = stopCommand.endsWith("\r") || stopCommand.endsWith("\n") ? stopCommand : `${stopCommand}${this.sendKey}`;
|
|
7630
7856
|
this.ptyProcess.write(payload);
|
|
7631
7857
|
};
|
|
7632
|
-
|
|
7858
|
+
const interruptGraceMs = typeof resume.interruptGraceMs === "number" ? Math.max(100, resume.interruptGraceMs) : 500;
|
|
7859
|
+
if (wasProcessing) setTimeout(writeCommand, interruptGraceMs);
|
|
7633
7860
|
else writeCommand();
|
|
7634
7861
|
} else {
|
|
7635
7862
|
this.ptyProcess.write("");
|
|
@@ -7674,6 +7901,18 @@ ${data.message || ""}`.trim();
|
|
|
7674
7901
|
clearTimeout(this.submitRetryTimer);
|
|
7675
7902
|
this.submitRetryTimer = null;
|
|
7676
7903
|
}
|
|
7904
|
+
if (this.responseTimeout) {
|
|
7905
|
+
clearTimeout(this.responseTimeout);
|
|
7906
|
+
this.responseTimeout = null;
|
|
7907
|
+
}
|
|
7908
|
+
if (this.idleTimeout) {
|
|
7909
|
+
clearTimeout(this.idleTimeout);
|
|
7910
|
+
this.idleTimeout = null;
|
|
7911
|
+
}
|
|
7912
|
+
if (this.pendingScriptStatusTimer) {
|
|
7913
|
+
clearTimeout(this.pendingScriptStatusTimer);
|
|
7914
|
+
this.pendingScriptStatusTimer = null;
|
|
7915
|
+
}
|
|
7677
7916
|
if (this.pendingOutputParseTimer) {
|
|
7678
7917
|
clearTimeout(this.pendingOutputParseTimer);
|
|
7679
7918
|
this.pendingOutputParseTimer = null;
|
|
@@ -7715,6 +7954,18 @@ ${data.message || ""}`.trim();
|
|
|
7715
7954
|
clearTimeout(this.submitRetryTimer);
|
|
7716
7955
|
this.submitRetryTimer = null;
|
|
7717
7956
|
}
|
|
7957
|
+
if (this.responseTimeout) {
|
|
7958
|
+
clearTimeout(this.responseTimeout);
|
|
7959
|
+
this.responseTimeout = null;
|
|
7960
|
+
}
|
|
7961
|
+
if (this.idleTimeout) {
|
|
7962
|
+
clearTimeout(this.idleTimeout);
|
|
7963
|
+
this.idleTimeout = null;
|
|
7964
|
+
}
|
|
7965
|
+
if (this.pendingScriptStatusTimer) {
|
|
7966
|
+
clearTimeout(this.pendingScriptStatusTimer);
|
|
7967
|
+
this.pendingScriptStatusTimer = null;
|
|
7968
|
+
}
|
|
7718
7969
|
if (this.pendingOutputParseTimer) {
|
|
7719
7970
|
clearTimeout(this.pendingOutputParseTimer);
|
|
7720
7971
|
this.pendingOutputParseTimer = null;
|
|
@@ -7909,11 +8160,11 @@ function getDatabaseSync() {
|
|
|
7909
8160
|
}
|
|
7910
8161
|
return CachedDatabaseSync;
|
|
7911
8162
|
}
|
|
7912
|
-
var
|
|
8163
|
+
var os10, path8, crypto3, fs5, import_node_module, CachedDatabaseSync, CliProviderInstance;
|
|
7913
8164
|
var init_cli_provider_instance = __esm({
|
|
7914
8165
|
"../../oss/packages/daemon-core/src/providers/cli-provider-instance.ts"() {
|
|
7915
8166
|
"use strict";
|
|
7916
|
-
|
|
8167
|
+
os10 = __toESM(require("os"));
|
|
7917
8168
|
path8 = __toESM(require("path"));
|
|
7918
8169
|
crypto3 = __toESM(require("crypto"));
|
|
7919
8170
|
fs5 = __toESM(require("fs"));
|
|
@@ -7994,17 +8245,60 @@ var init_cli_provider_instance = __esm({
|
|
|
7994
8245
|
async onTick() {
|
|
7995
8246
|
if (this.providerSessionId) return;
|
|
7996
8247
|
let probedSessionId = null;
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8248
|
+
const probeConfig = this.provider.sessionProbe;
|
|
8249
|
+
if (probeConfig) {
|
|
8250
|
+
probedSessionId = this.probeSessionIdFromConfig(probeConfig);
|
|
8251
|
+
} else {
|
|
8252
|
+
if (this.type === "opencode-cli") {
|
|
8253
|
+
probedSessionId = this.probeSessionIdFromConfig({
|
|
8254
|
+
dbPath: "~/.local/share/opencode/opencode.db",
|
|
8255
|
+
query: "select id from session where directory in ({dirs}) and time_created >= ? and time_archived is null order by time_updated desc limit 1",
|
|
8256
|
+
timestampFormat: "unix_ms"
|
|
8257
|
+
});
|
|
8258
|
+
} else if (this.type === "codex-cli") {
|
|
8259
|
+
probedSessionId = this.probeSessionIdFromConfig({
|
|
8260
|
+
dbPath: "~/.codex/state_5.sqlite",
|
|
8261
|
+
query: "select id from threads where cwd in ({dirs}) and created_at >= ? and archived = 0 order by created_at desc limit 1",
|
|
8262
|
+
timestampFormat: "unix_s"
|
|
8263
|
+
});
|
|
8264
|
+
} else if (this.type === "goose-cli") {
|
|
8265
|
+
probedSessionId = this.probeSessionIdFromConfig({
|
|
8266
|
+
dbPath: "~/.local/share/goose/sessions/sessions.db",
|
|
8267
|
+
query: "select id from sessions where working_dir in ({dirs}) and created_at >= ? order by updated_at desc limit 1",
|
|
8268
|
+
timestampFormat: "iso"
|
|
8269
|
+
});
|
|
8270
|
+
}
|
|
8003
8271
|
}
|
|
8004
8272
|
if (probedSessionId) {
|
|
8005
8273
|
this.promoteProviderSessionId(probedSessionId);
|
|
8006
8274
|
}
|
|
8007
8275
|
}
|
|
8276
|
+
/**
|
|
8277
|
+
* Generic session ID probe using declarative ProviderSessionProbe config.
|
|
8278
|
+
* Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
|
|
8279
|
+
*/
|
|
8280
|
+
probeSessionIdFromConfig(probe) {
|
|
8281
|
+
const resolvedDbPath = probe.dbPath.replace(/^~/, os10.homedir());
|
|
8282
|
+
if (!fs5.existsSync(resolvedDbPath)) return null;
|
|
8283
|
+
const directories = this.getProbeDirectories();
|
|
8284
|
+
const minCreatedAt = Math.max(0, this.startedAt - 6e4);
|
|
8285
|
+
const tsFormat = probe.timestampFormat || "unix_ms";
|
|
8286
|
+
let timestampParam;
|
|
8287
|
+
if (tsFormat === "unix_s") {
|
|
8288
|
+
timestampParam = Math.floor(minCreatedAt / 1e3);
|
|
8289
|
+
} else if (tsFormat === "iso") {
|
|
8290
|
+
timestampParam = new Date(minCreatedAt).toISOString().slice(0, 19).replace("T", " ");
|
|
8291
|
+
} else {
|
|
8292
|
+
timestampParam = minCreatedAt;
|
|
8293
|
+
}
|
|
8294
|
+
const placeholders = this.buildSqlPlaceholderList(directories.length);
|
|
8295
|
+
const query = probe.query.replace("{dirs}", placeholders);
|
|
8296
|
+
try {
|
|
8297
|
+
return this.querySqliteText(resolvedDbPath, query, [...directories, timestampParam]);
|
|
8298
|
+
} catch {
|
|
8299
|
+
return null;
|
|
8300
|
+
}
|
|
8301
|
+
}
|
|
8008
8302
|
getState() {
|
|
8009
8303
|
const adapterStatus = this.adapter.getStatus();
|
|
8010
8304
|
const parsedStatus = this.adapter.getScriptParsedStatus?.() || null;
|
|
@@ -8302,34 +8596,6 @@ var init_cli_provider_instance = __esm({
|
|
|
8302
8596
|
});
|
|
8303
8597
|
LOG.info("CLI", `[${this.type}] discovered provider session id: ${nextSessionId}`);
|
|
8304
8598
|
}
|
|
8305
|
-
probeOpenCodeSessionId() {
|
|
8306
|
-
const dbPath = path8.join(os8.homedir(), ".local", "share", "opencode", "opencode.db");
|
|
8307
|
-
if (!fs5.existsSync(dbPath)) return null;
|
|
8308
|
-
const minCreatedAt = Math.max(0, this.startedAt - 6e4);
|
|
8309
|
-
const directories = this.getProbeDirectories();
|
|
8310
|
-
const query = `select id from session where directory in (${this.buildSqlPlaceholderList(directories.length)}) and time_created >= ? and time_archived is null order by time_updated desc limit 1;`;
|
|
8311
|
-
return this.querySqliteText(dbPath, query, [...directories, minCreatedAt]);
|
|
8312
|
-
}
|
|
8313
|
-
probeCodexSessionId() {
|
|
8314
|
-
const dbPath = path8.join(os8.homedir(), ".codex", "state_5.sqlite");
|
|
8315
|
-
if (!fs5.existsSync(dbPath)) return null;
|
|
8316
|
-
const minCreatedAt = Math.max(0, Math.floor((this.startedAt - 6e4) / 1e3));
|
|
8317
|
-
const directories = this.getProbeDirectories();
|
|
8318
|
-
const query = `select id from threads where cwd in (${this.buildSqlPlaceholderList(directories.length)}) and created_at >= ? and archived = 0 order by created_at desc limit 1;`;
|
|
8319
|
-
return this.querySqliteText(dbPath, query, [...directories, minCreatedAt]);
|
|
8320
|
-
}
|
|
8321
|
-
probeGooseSessionId() {
|
|
8322
|
-
const dbPath = path8.join(os8.homedir(), ".local", "share", "goose", "sessions", "sessions.db");
|
|
8323
|
-
if (!fs5.existsSync(dbPath)) return null;
|
|
8324
|
-
const minCreatedAtIso = new Date(Math.max(0, this.startedAt - 6e4)).toISOString().slice(0, 19).replace("T", " ");
|
|
8325
|
-
const directories = this.getProbeDirectories();
|
|
8326
|
-
const query = `select id from sessions where working_dir in (${this.buildSqlPlaceholderList(directories.length)}) and created_at >= ? order by updated_at desc limit 1;`;
|
|
8327
|
-
try {
|
|
8328
|
-
return this.querySqliteText(dbPath, query, [...directories, minCreatedAtIso]);
|
|
8329
|
-
} catch {
|
|
8330
|
-
return null;
|
|
8331
|
-
}
|
|
8332
|
-
}
|
|
8333
8599
|
getProbeDirectories() {
|
|
8334
8600
|
const dirs = /* @__PURE__ */ new Set();
|
|
8335
8601
|
const addDir = (value) => {
|
|
@@ -25688,11 +25954,11 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
|
|
|
25688
25954
|
launchMode: "new"
|
|
25689
25955
|
};
|
|
25690
25956
|
}
|
|
25691
|
-
var
|
|
25957
|
+
var os11, path9, crypto4, import_chalk, chalkApi, DaemonCliManager;
|
|
25692
25958
|
var init_cli_manager = __esm({
|
|
25693
25959
|
"../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
|
|
25694
25960
|
"use strict";
|
|
25695
|
-
|
|
25961
|
+
os11 = __toESM(require("os"));
|
|
25696
25962
|
path9 = __toESM(require("path"));
|
|
25697
25963
|
crypto4 = __toESM(require("crypto"));
|
|
25698
25964
|
import_chalk = __toESM(require("chalk"));
|
|
@@ -25844,7 +26110,7 @@ var init_cli_manager = __esm({
|
|
|
25844
26110
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
25845
26111
|
const trimmed = (workingDir || "").trim();
|
|
25846
26112
|
if (!trimmed) throw new Error("working directory required");
|
|
25847
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/,
|
|
26113
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os11.homedir()) : path9.resolve(trimmed);
|
|
25848
26114
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
25849
26115
|
const provider = this.providerLoader.getByAlias(cliType);
|
|
25850
26116
|
const key = crypto4.randomUUID();
|
|
@@ -25928,7 +26194,19 @@ ${installInfo}`
|
|
|
25928
26194
|
return { runtimeSessionId: sessionId };
|
|
25929
26195
|
}
|
|
25930
26196
|
const cliInfo = await detectCLI(cliType, this.providerLoader);
|
|
25931
|
-
if (!cliInfo)
|
|
26197
|
+
if (!cliInfo) {
|
|
26198
|
+
const installHint = provider?.install || "";
|
|
26199
|
+
const displayName = provider?.displayName || provider?.name || cliType;
|
|
26200
|
+
const spawnCmd = provider?.spawn?.command || cliType;
|
|
26201
|
+
throw new Error(
|
|
26202
|
+
`${displayName} is not installed.
|
|
26203
|
+
Command '${spawnCmd}' not found on PATH.
|
|
26204
|
+
` + (installHint ? `
|
|
26205
|
+
${installHint}
|
|
26206
|
+
` : "") + `
|
|
26207
|
+
Run 'adhdev doctor' for detailed diagnostics.`
|
|
26208
|
+
);
|
|
26209
|
+
}
|
|
25932
26210
|
console.log(colorize("yellow", ` \u26A1 Starting CLI ${cliType} in ${resolvedDir}...`));
|
|
25933
26211
|
if (provider) {
|
|
25934
26212
|
console.log(colorize("cyan", ` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
|
|
@@ -26244,8 +26522,9 @@ ${installInfo}`
|
|
|
26244
26522
|
const dir = rdir.path;
|
|
26245
26523
|
if (!cliType) throw new Error("cliType required");
|
|
26246
26524
|
const found = this.findAdapter(cliType, { instanceKey: args?.targetSessionId, dir });
|
|
26525
|
+
const prevCliArgs = found ? found.adapter.extraArgs : void 0;
|
|
26247
26526
|
if (found) await this.stopSession(found.key);
|
|
26248
|
-
await this.startSession(cliType, dir);
|
|
26527
|
+
await this.startSession(cliType, dir, args?.cliArgs || prevCliArgs, args?.initialModel);
|
|
26249
26528
|
return { success: true, restarted: true };
|
|
26250
26529
|
}
|
|
26251
26530
|
case "agent_command": {
|
|
@@ -28029,13 +28308,13 @@ var init_chokidar = __esm({
|
|
|
28029
28308
|
});
|
|
28030
28309
|
|
|
28031
28310
|
// ../../oss/packages/daemon-core/src/providers/provider-loader.ts
|
|
28032
|
-
var fs6, path10,
|
|
28311
|
+
var fs6, path10, os12, ProviderLoader;
|
|
28033
28312
|
var init_provider_loader = __esm({
|
|
28034
28313
|
"../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
|
|
28035
28314
|
"use strict";
|
|
28036
28315
|
fs6 = __toESM(require("fs"));
|
|
28037
28316
|
path10 = __toESM(require("path"));
|
|
28038
|
-
|
|
28317
|
+
os12 = __toESM(require("os"));
|
|
28039
28318
|
init_chokidar();
|
|
28040
28319
|
init_ide_detector();
|
|
28041
28320
|
init_logger();
|
|
@@ -28056,7 +28335,7 @@ var init_provider_loader = __esm({
|
|
|
28056
28335
|
static META_FILE = ".meta.json";
|
|
28057
28336
|
constructor(options) {
|
|
28058
28337
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
28059
|
-
const defaultProvidersDir = path10.join(
|
|
28338
|
+
const defaultProvidersDir = path10.join(os12.homedir(), ".adhdev", "providers");
|
|
28060
28339
|
if (options?.userDir) {
|
|
28061
28340
|
this.userDir = options.userDir;
|
|
28062
28341
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
@@ -28656,8 +28935,8 @@ var init_provider_loader = __esm({
|
|
|
28656
28935
|
return { updated: false };
|
|
28657
28936
|
}
|
|
28658
28937
|
this.log("Downloading latest providers from GitHub...");
|
|
28659
|
-
const tmpTar = path10.join(
|
|
28660
|
-
const tmpExtract = path10.join(
|
|
28938
|
+
const tmpTar = path10.join(os12.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
28939
|
+
const tmpExtract = path10.join(os12.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
28661
28940
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
28662
28941
|
fs6.mkdirSync(tmpExtract, { recursive: true });
|
|
28663
28942
|
execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
@@ -29091,7 +29370,7 @@ async function findFreePort(ports) {
|
|
|
29091
29370
|
}
|
|
29092
29371
|
function checkPortFree(port) {
|
|
29093
29372
|
return new Promise((resolve14) => {
|
|
29094
|
-
const server =
|
|
29373
|
+
const server = net2.createServer();
|
|
29095
29374
|
server.unref();
|
|
29096
29375
|
server.on("error", () => resolve14(false));
|
|
29097
29376
|
server.listen(port, "127.0.0.1", () => {
|
|
@@ -29123,7 +29402,7 @@ async function isCdpActive(port) {
|
|
|
29123
29402
|
});
|
|
29124
29403
|
}
|
|
29125
29404
|
async function killIdeProcess(ideId) {
|
|
29126
|
-
const plat =
|
|
29405
|
+
const plat = os13.platform();
|
|
29127
29406
|
const appName = getMacAppIdentifiers()[ideId];
|
|
29128
29407
|
const winProcesses = getWinProcessNames()[ideId];
|
|
29129
29408
|
try {
|
|
@@ -29182,7 +29461,7 @@ async function killIdeProcess(ideId) {
|
|
|
29182
29461
|
}
|
|
29183
29462
|
}
|
|
29184
29463
|
function isIdeRunning(ideId) {
|
|
29185
|
-
const plat =
|
|
29464
|
+
const plat = os13.platform();
|
|
29186
29465
|
try {
|
|
29187
29466
|
if (plat === "darwin") {
|
|
29188
29467
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -29218,7 +29497,7 @@ function isIdeRunning(ideId) {
|
|
|
29218
29497
|
}
|
|
29219
29498
|
}
|
|
29220
29499
|
function detectCurrentWorkspace(ideId) {
|
|
29221
|
-
const plat =
|
|
29500
|
+
const plat = os13.platform();
|
|
29222
29501
|
if (plat === "darwin") {
|
|
29223
29502
|
try {
|
|
29224
29503
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -29238,7 +29517,7 @@ function detectCurrentWorkspace(ideId) {
|
|
|
29238
29517
|
const appName = appNameMap[ideId];
|
|
29239
29518
|
if (appName) {
|
|
29240
29519
|
const storagePath = path11.join(
|
|
29241
|
-
process.env.APPDATA || path11.join(
|
|
29520
|
+
process.env.APPDATA || path11.join(os13.homedir(), "AppData", "Roaming"),
|
|
29242
29521
|
appName,
|
|
29243
29522
|
"storage.json"
|
|
29244
29523
|
);
|
|
@@ -29260,7 +29539,7 @@ function detectCurrentWorkspace(ideId) {
|
|
|
29260
29539
|
return void 0;
|
|
29261
29540
|
}
|
|
29262
29541
|
async function launchWithCdp(options = {}) {
|
|
29263
|
-
const
|
|
29542
|
+
const platform11 = os13.platform();
|
|
29264
29543
|
let targetIde;
|
|
29265
29544
|
const ides = await detectIDEs();
|
|
29266
29545
|
if (options.ideId) {
|
|
@@ -29329,9 +29608,9 @@ async function launchWithCdp(options = {}) {
|
|
|
29329
29608
|
}
|
|
29330
29609
|
const port = await findFreePort(portPair);
|
|
29331
29610
|
try {
|
|
29332
|
-
if (
|
|
29611
|
+
if (platform11 === "darwin") {
|
|
29333
29612
|
await launchMacOS(targetIde, port, workspace, options.newWindow);
|
|
29334
|
-
} else if (
|
|
29613
|
+
} else if (platform11 === "win32") {
|
|
29335
29614
|
await launchWindows(targetIde, port, workspace, options.newWindow);
|
|
29336
29615
|
} else {
|
|
29337
29616
|
await launchLinux(targetIde, port, workspace, options.newWindow);
|
|
@@ -29404,13 +29683,13 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
29404
29683
|
function getAvailableIdeIds() {
|
|
29405
29684
|
return getProviderLoader().getAvailableIdeTypes();
|
|
29406
29685
|
}
|
|
29407
|
-
var import_child_process6,
|
|
29686
|
+
var import_child_process6, net2, os13, path11, _providerLoader;
|
|
29408
29687
|
var init_launch = __esm({
|
|
29409
29688
|
"../../oss/packages/daemon-core/src/launch.ts"() {
|
|
29410
29689
|
"use strict";
|
|
29411
29690
|
import_child_process6 = require("child_process");
|
|
29412
|
-
|
|
29413
|
-
|
|
29691
|
+
net2 = __toESM(require("net"));
|
|
29692
|
+
os13 = __toESM(require("os"));
|
|
29414
29693
|
path11 = __toESM(require("path"));
|
|
29415
29694
|
init_ide_detector();
|
|
29416
29695
|
init_provider_loader();
|
|
@@ -29523,14 +29802,14 @@ function getRecentCommands(count = 50) {
|
|
|
29523
29802
|
return [];
|
|
29524
29803
|
}
|
|
29525
29804
|
}
|
|
29526
|
-
var fs7, path12,
|
|
29805
|
+
var fs7, path12, os14, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
|
|
29527
29806
|
var init_command_log = __esm({
|
|
29528
29807
|
"../../oss/packages/daemon-core/src/logging/command-log.ts"() {
|
|
29529
29808
|
"use strict";
|
|
29530
29809
|
fs7 = __toESM(require("fs"));
|
|
29531
29810
|
path12 = __toESM(require("path"));
|
|
29532
|
-
|
|
29533
|
-
LOG_DIR2 = process.platform === "win32" ? path12.join(process.env.LOCALAPPDATA || process.env.APPDATA || path12.join(
|
|
29811
|
+
os14 = __toESM(require("os"));
|
|
29812
|
+
LOG_DIR2 = process.platform === "win32" ? path12.join(process.env.LOCALAPPDATA || process.env.APPDATA || path12.join(os14.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path12.join(os14.homedir(), "Library", "Logs", "adhdev") : path12.join(os14.homedir(), ".local", "share", "adhdev", "logs");
|
|
29534
29813
|
MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
29535
29814
|
MAX_DAYS = 7;
|
|
29536
29815
|
try {
|
|
@@ -29671,16 +29950,16 @@ function buildStatusSnapshot(options) {
|
|
|
29671
29950
|
version: options.version,
|
|
29672
29951
|
daemonMode: options.daemonMode,
|
|
29673
29952
|
machine: {
|
|
29674
|
-
hostname:
|
|
29675
|
-
platform:
|
|
29676
|
-
arch:
|
|
29677
|
-
cpus:
|
|
29953
|
+
hostname: os15.hostname(),
|
|
29954
|
+
platform: os15.platform(),
|
|
29955
|
+
arch: os15.arch(),
|
|
29956
|
+
cpus: os15.cpus().length,
|
|
29678
29957
|
totalMem: memSnap.totalMem,
|
|
29679
29958
|
freeMem: memSnap.freeMem,
|
|
29680
29959
|
availableMem: memSnap.availableMem,
|
|
29681
|
-
loadavg:
|
|
29682
|
-
uptime:
|
|
29683
|
-
release:
|
|
29960
|
+
loadavg: os15.loadavg(),
|
|
29961
|
+
uptime: os15.uptime(),
|
|
29962
|
+
release: os15.release()
|
|
29684
29963
|
},
|
|
29685
29964
|
machineNickname: options.machineNickname ?? cfg.machineNickname ?? null,
|
|
29686
29965
|
timestamp: options.timestamp ?? Date.now(),
|
|
@@ -29695,11 +29974,11 @@ function buildStatusSnapshot(options) {
|
|
|
29695
29974
|
availableProviders: buildAvailableProviders(options.providerLoader)
|
|
29696
29975
|
};
|
|
29697
29976
|
}
|
|
29698
|
-
var
|
|
29977
|
+
var os15, READ_DEBUG_ENABLED;
|
|
29699
29978
|
var init_snapshot = __esm({
|
|
29700
29979
|
"../../oss/packages/daemon-core/src/status/snapshot.ts"() {
|
|
29701
29980
|
"use strict";
|
|
29702
|
-
|
|
29981
|
+
os15 = __toESM(require("os"));
|
|
29703
29982
|
init_config();
|
|
29704
29983
|
init_recent_activity();
|
|
29705
29984
|
init_workspaces();
|
|
@@ -29713,7 +29992,7 @@ var init_snapshot = __esm({
|
|
|
29713
29992
|
|
|
29714
29993
|
// ../../oss/packages/daemon-core/src/commands/upgrade-helper.ts
|
|
29715
29994
|
function getUpgradeLogPath() {
|
|
29716
|
-
const home =
|
|
29995
|
+
const home = os16.homedir();
|
|
29717
29996
|
const dir = path13.join(home, ".adhdev");
|
|
29718
29997
|
fs8.mkdirSync(dir, { recursive: true });
|
|
29719
29998
|
return path13.join(dir, "daemon-upgrade.log");
|
|
@@ -29753,7 +30032,7 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
29753
30032
|
}
|
|
29754
30033
|
}
|
|
29755
30034
|
function stopSessionHostProcesses(appName) {
|
|
29756
|
-
const pidFile = path13.join(
|
|
30035
|
+
const pidFile = path13.join(os16.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
29757
30036
|
try {
|
|
29758
30037
|
if (fs8.existsSync(pidFile)) {
|
|
29759
30038
|
const pid = Number.parseInt(fs8.readFileSync(pidFile, "utf8").trim(), 10);
|
|
@@ -29782,7 +30061,7 @@ function stopSessionHostProcesses(appName) {
|
|
|
29782
30061
|
}
|
|
29783
30062
|
}
|
|
29784
30063
|
function removeDaemonPidFile() {
|
|
29785
|
-
const pidFile = path13.join(
|
|
30064
|
+
const pidFile = path13.join(os16.homedir(), ".adhdev", "daemon.pid");
|
|
29786
30065
|
try {
|
|
29787
30066
|
fs8.unlinkSync(pidFile);
|
|
29788
30067
|
} catch {
|
|
@@ -29887,14 +30166,14 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
|
|
|
29887
30166
|
process.exit(1);
|
|
29888
30167
|
}
|
|
29889
30168
|
}
|
|
29890
|
-
var import_child_process7, import_child_process8, fs8,
|
|
30169
|
+
var import_child_process7, import_child_process8, fs8, os16, path13, UPGRADE_HELPER_ENV;
|
|
29891
30170
|
var init_upgrade_helper = __esm({
|
|
29892
30171
|
"../../oss/packages/daemon-core/src/commands/upgrade-helper.ts"() {
|
|
29893
30172
|
"use strict";
|
|
29894
30173
|
import_child_process7 = require("child_process");
|
|
29895
30174
|
import_child_process8 = require("child_process");
|
|
29896
30175
|
fs8 = __toESM(require("fs"));
|
|
29897
|
-
|
|
30176
|
+
os16 = __toESM(require("os"));
|
|
29898
30177
|
path13 = __toESM(require("path"));
|
|
29899
30178
|
UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
29900
30179
|
}
|
|
@@ -31418,7 +31697,7 @@ function getVersion(binary, versionCommand) {
|
|
|
31418
31697
|
function checkPathExists2(paths) {
|
|
31419
31698
|
for (const p of paths) {
|
|
31420
31699
|
if (p.includes("*")) {
|
|
31421
|
-
const home =
|
|
31700
|
+
const home = os17.homedir();
|
|
31422
31701
|
const resolved = p.replace(/\*/g, home.split(path14.sep).pop() || "");
|
|
31423
31702
|
if (fs10.existsSync(resolved)) return resolved;
|
|
31424
31703
|
} else {
|
|
@@ -31493,16 +31772,16 @@ async function detectAllVersions(loader, archive) {
|
|
|
31493
31772
|
}
|
|
31494
31773
|
return results;
|
|
31495
31774
|
}
|
|
31496
|
-
var fs10, path14,
|
|
31775
|
+
var fs10, path14, os17, import_child_process9, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
|
|
31497
31776
|
var init_version_archive = __esm({
|
|
31498
31777
|
"../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
|
|
31499
31778
|
"use strict";
|
|
31500
31779
|
fs10 = __toESM(require("fs"));
|
|
31501
31780
|
path14 = __toESM(require("path"));
|
|
31502
|
-
|
|
31781
|
+
os17 = __toESM(require("os"));
|
|
31503
31782
|
import_child_process9 = require("child_process");
|
|
31504
31783
|
import_os3 = require("os");
|
|
31505
|
-
ARCHIVE_PATH = path14.join(
|
|
31784
|
+
ARCHIVE_PATH = path14.join(os17.homedir(), ".adhdev", "version-history.json");
|
|
31506
31785
|
MAX_ENTRIES_PER_PROVIDER = 20;
|
|
31507
31786
|
VersionArchive = class {
|
|
31508
31787
|
history = {};
|
|
@@ -34019,7 +34298,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
34019
34298
|
});
|
|
34020
34299
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
34021
34300
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
34022
|
-
const tmpDir = path17.join(
|
|
34301
|
+
const tmpDir = path17.join(os18.tmpdir(), "adhdev-autoimpl");
|
|
34023
34302
|
if (!fs13.existsSync(tmpDir)) fs13.mkdirSync(tmpDir, { recursive: true });
|
|
34024
34303
|
const promptFile = path17.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
34025
34304
|
fs13.writeFileSync(promptFile, prompt, "utf-8");
|
|
@@ -34173,7 +34452,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
34173
34452
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
34174
34453
|
const baseArgs = [...spawn5.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
34175
34454
|
let shellCmd;
|
|
34176
|
-
const isWin =
|
|
34455
|
+
const isWin = os18.platform() === "win32";
|
|
34177
34456
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
34178
34457
|
if (command === "claude") {
|
|
34179
34458
|
const args = [...baseArgs, "--dangerously-skip-permissions"];
|
|
@@ -34217,7 +34496,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
34217
34496
|
try {
|
|
34218
34497
|
const pty3 = require("node-pty");
|
|
34219
34498
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
34220
|
-
const isWin2 =
|
|
34499
|
+
const isWin2 = os18.platform() === "win32";
|
|
34221
34500
|
child = pty3.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
34222
34501
|
name: "xterm-256color",
|
|
34223
34502
|
cols: 120,
|
|
@@ -35124,13 +35403,13 @@ data: ${JSON.stringify(msg.data)}
|
|
|
35124
35403
|
}
|
|
35125
35404
|
}
|
|
35126
35405
|
}
|
|
35127
|
-
var fs13, path17,
|
|
35406
|
+
var fs13, path17, os18;
|
|
35128
35407
|
var init_dev_auto_implement = __esm({
|
|
35129
35408
|
"../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
|
|
35130
35409
|
"use strict";
|
|
35131
35410
|
fs13 = __toESM(require("fs"));
|
|
35132
35411
|
path17 = __toESM(require("path"));
|
|
35133
|
-
|
|
35412
|
+
os18 = __toESM(require("os"));
|
|
35134
35413
|
init_dev_server();
|
|
35135
35414
|
init_dev_cli_debug();
|
|
35136
35415
|
}
|
|
@@ -36651,141 +36930,6 @@ data: ${JSON.stringify(msg.data)}
|
|
|
36651
36930
|
}
|
|
36652
36931
|
});
|
|
36653
36932
|
|
|
36654
|
-
// ../../oss/packages/session-host-core/dist/index.mjs
|
|
36655
|
-
function getDefaultSessionHostEndpoint(appName = "adhdev") {
|
|
36656
|
-
if (process.platform === "win32") {
|
|
36657
|
-
return {
|
|
36658
|
-
kind: "pipe",
|
|
36659
|
-
path: `\\\\.\\pipe\\${appName}-session-host`
|
|
36660
|
-
};
|
|
36661
|
-
}
|
|
36662
|
-
return {
|
|
36663
|
-
kind: "unix",
|
|
36664
|
-
path: path22.join(os17.tmpdir(), `${appName}-session-host.sock`)
|
|
36665
|
-
};
|
|
36666
|
-
}
|
|
36667
|
-
function serializeEnvelope(envelope) {
|
|
36668
|
-
return `${JSON.stringify(envelope)}
|
|
36669
|
-
`;
|
|
36670
|
-
}
|
|
36671
|
-
function createLineParser(onEnvelope) {
|
|
36672
|
-
let buffer = "";
|
|
36673
|
-
return (chunk) => {
|
|
36674
|
-
buffer += chunk.toString();
|
|
36675
|
-
let newlineIndex = buffer.indexOf("\n");
|
|
36676
|
-
while (newlineIndex >= 0) {
|
|
36677
|
-
const rawLine = buffer.slice(0, newlineIndex).trim();
|
|
36678
|
-
buffer = buffer.slice(newlineIndex + 1);
|
|
36679
|
-
if (rawLine) {
|
|
36680
|
-
onEnvelope(JSON.parse(rawLine));
|
|
36681
|
-
}
|
|
36682
|
-
newlineIndex = buffer.indexOf("\n");
|
|
36683
|
-
}
|
|
36684
|
-
};
|
|
36685
|
-
}
|
|
36686
|
-
var os17, path22, net2, import_crypto3, SessionHostClient;
|
|
36687
|
-
var init_dist = __esm({
|
|
36688
|
-
"../../oss/packages/session-host-core/dist/index.mjs"() {
|
|
36689
|
-
"use strict";
|
|
36690
|
-
os17 = __toESM(require("os"), 1);
|
|
36691
|
-
path22 = __toESM(require("path"), 1);
|
|
36692
|
-
net2 = __toESM(require("net"), 1);
|
|
36693
|
-
import_crypto3 = require("crypto");
|
|
36694
|
-
SessionHostClient = class {
|
|
36695
|
-
endpoint;
|
|
36696
|
-
socket = null;
|
|
36697
|
-
requestWaiters = /* @__PURE__ */ new Map();
|
|
36698
|
-
eventListeners = /* @__PURE__ */ new Set();
|
|
36699
|
-
constructor(options = {}) {
|
|
36700
|
-
this.endpoint = options.endpoint || getDefaultSessionHostEndpoint(options.appName || "adhdev");
|
|
36701
|
-
}
|
|
36702
|
-
async connect() {
|
|
36703
|
-
if (this.socket && !this.socket.destroyed) return;
|
|
36704
|
-
const socket = net2.createConnection(this.endpoint.path);
|
|
36705
|
-
this.socket = socket;
|
|
36706
|
-
socket.on("data", createLineParser((envelope) => {
|
|
36707
|
-
if (envelope.kind === "response") {
|
|
36708
|
-
const waiter = this.requestWaiters.get(envelope.requestId);
|
|
36709
|
-
if (waiter) {
|
|
36710
|
-
this.requestWaiters.delete(envelope.requestId);
|
|
36711
|
-
waiter.resolve(envelope.response);
|
|
36712
|
-
}
|
|
36713
|
-
return;
|
|
36714
|
-
}
|
|
36715
|
-
if (envelope.kind === "event") {
|
|
36716
|
-
for (const listener of this.eventListeners) listener(envelope.event);
|
|
36717
|
-
}
|
|
36718
|
-
}));
|
|
36719
|
-
socket.on("error", (error48) => {
|
|
36720
|
-
for (const waiter of this.requestWaiters.values()) {
|
|
36721
|
-
waiter.reject(error48);
|
|
36722
|
-
}
|
|
36723
|
-
this.requestWaiters.clear();
|
|
36724
|
-
});
|
|
36725
|
-
await new Promise((resolve14, reject) => {
|
|
36726
|
-
socket.once("connect", () => resolve14());
|
|
36727
|
-
socket.once("error", reject);
|
|
36728
|
-
});
|
|
36729
|
-
}
|
|
36730
|
-
onEvent(listener) {
|
|
36731
|
-
this.eventListeners.add(listener);
|
|
36732
|
-
return () => {
|
|
36733
|
-
this.eventListeners.delete(listener);
|
|
36734
|
-
};
|
|
36735
|
-
}
|
|
36736
|
-
async request(request) {
|
|
36737
|
-
await this.connect();
|
|
36738
|
-
if (!this.socket) throw new Error("Session host socket unavailable");
|
|
36739
|
-
const requestId = (0, import_crypto3.randomUUID)();
|
|
36740
|
-
const envelope = {
|
|
36741
|
-
kind: "request",
|
|
36742
|
-
requestId,
|
|
36743
|
-
request
|
|
36744
|
-
};
|
|
36745
|
-
const response = await new Promise((resolve14, reject) => {
|
|
36746
|
-
const timeout = setTimeout(() => {
|
|
36747
|
-
this.requestWaiters.delete(requestId);
|
|
36748
|
-
reject(new Error(`Session host request timed out after 30s (${request.type})`));
|
|
36749
|
-
}, 3e4);
|
|
36750
|
-
this.requestWaiters.set(requestId, {
|
|
36751
|
-
resolve: (value) => {
|
|
36752
|
-
clearTimeout(timeout);
|
|
36753
|
-
resolve14(value);
|
|
36754
|
-
},
|
|
36755
|
-
reject: (error48) => {
|
|
36756
|
-
clearTimeout(timeout);
|
|
36757
|
-
reject(error48);
|
|
36758
|
-
}
|
|
36759
|
-
});
|
|
36760
|
-
this.socket?.write(serializeEnvelope(envelope));
|
|
36761
|
-
});
|
|
36762
|
-
return response;
|
|
36763
|
-
}
|
|
36764
|
-
async close() {
|
|
36765
|
-
if (!this.socket) return;
|
|
36766
|
-
const socket = this.socket;
|
|
36767
|
-
this.socket = null;
|
|
36768
|
-
for (const waiter of this.requestWaiters.values()) {
|
|
36769
|
-
waiter.reject(new Error("Session host client closed"));
|
|
36770
|
-
}
|
|
36771
|
-
this.requestWaiters.clear();
|
|
36772
|
-
await new Promise((resolve14) => {
|
|
36773
|
-
let settled = false;
|
|
36774
|
-
const done = () => {
|
|
36775
|
-
if (settled) return;
|
|
36776
|
-
settled = true;
|
|
36777
|
-
resolve14();
|
|
36778
|
-
};
|
|
36779
|
-
socket.once("close", done);
|
|
36780
|
-
socket.end();
|
|
36781
|
-
socket.destroy();
|
|
36782
|
-
setTimeout(done, 50);
|
|
36783
|
-
});
|
|
36784
|
-
}
|
|
36785
|
-
};
|
|
36786
|
-
}
|
|
36787
|
-
});
|
|
36788
|
-
|
|
36789
36933
|
// ../../oss/packages/daemon-core/src/cli-adapters/session-host-transport.ts
|
|
36790
36934
|
var SessionHostRuntimeTransport, SessionHostPtyTransportFactory;
|
|
36791
36935
|
var init_session_host_transport = __esm({
|
|
@@ -38242,17 +38386,17 @@ function canPeerUsePrivilegedShareCommand(commandType, permission) {
|
|
|
38242
38386
|
return false;
|
|
38243
38387
|
}
|
|
38244
38388
|
}
|
|
38245
|
-
var fs15, path19,
|
|
38389
|
+
var fs15, path19, os19, import_node_module2, esmRequire, logFile, log, logDebug, DaemonP2PSender;
|
|
38246
38390
|
var init_daemon_p2p = __esm({
|
|
38247
38391
|
"src/daemon-p2p.ts"() {
|
|
38248
38392
|
"use strict";
|
|
38249
38393
|
fs15 = __toESM(require("fs"));
|
|
38250
38394
|
init_src();
|
|
38251
38395
|
path19 = __toESM(require("path"));
|
|
38252
|
-
|
|
38396
|
+
os19 = __toESM(require("os"));
|
|
38253
38397
|
import_node_module2 = require("module");
|
|
38254
38398
|
esmRequire = (0, import_node_module2.createRequire)(__filename);
|
|
38255
|
-
logFile = path19.join(
|
|
38399
|
+
logFile = path19.join(os19.tmpdir(), "adhdev_daemon_p2p.log");
|
|
38256
38400
|
log = (msg) => {
|
|
38257
38401
|
LOG.info("P2P", `[${(/* @__PURE__ */ new Date()).toISOString()}] [P2P] ${msg}`);
|
|
38258
38402
|
};
|
|
@@ -38315,9 +38459,9 @@ var init_daemon_p2p = __esm({
|
|
|
38315
38459
|
log(`node-datachannel not found: ${e?.message}
|
|
38316
38460
|
${e?.stack || ""}`);
|
|
38317
38461
|
}
|
|
38318
|
-
const
|
|
38462
|
+
const platform11 = process.platform;
|
|
38319
38463
|
const arch3 = process.arch;
|
|
38320
|
-
const prebuildKey = `${
|
|
38464
|
+
const prebuildKey = `${platform11}-${arch3}`;
|
|
38321
38465
|
try {
|
|
38322
38466
|
const candidates = [
|
|
38323
38467
|
path19.join(__dirname, "node_modules", "node-datachannel"),
|
|
@@ -41040,7 +41184,7 @@ var require_sharp = __commonJS({
|
|
|
41040
41184
|
if (sharp) {
|
|
41041
41185
|
module2.exports = sharp;
|
|
41042
41186
|
} else {
|
|
41043
|
-
const [isLinux2, isMacOs, isWindows2] = ["linux", "darwin", "win32"].map((
|
|
41187
|
+
const [isLinux2, isMacOs, isWindows2] = ["linux", "darwin", "win32"].map((os24) => runtimePlatform.startsWith(os24));
|
|
41044
41188
|
const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
|
41045
41189
|
errors.forEach((err) => {
|
|
41046
41190
|
if (err.code !== "MODULE_NOT_FOUND") {
|
|
@@ -41057,15 +41201,15 @@ var require_sharp = __commonJS({
|
|
|
41057
41201
|
` Requires ${expected}`
|
|
41058
41202
|
);
|
|
41059
41203
|
} else if (prebuiltPlatforms.includes(runtimePlatform)) {
|
|
41060
|
-
const [
|
|
41061
|
-
const libc =
|
|
41204
|
+
const [os24, cpu] = runtimePlatform.split("-");
|
|
41205
|
+
const libc = os24.endsWith("musl") ? " --libc=musl" : "";
|
|
41062
41206
|
help.push(
|
|
41063
41207
|
"- Ensure optional dependencies can be installed:",
|
|
41064
41208
|
" npm install --include=optional sharp",
|
|
41065
41209
|
"- Ensure your package manager supports multi-platform installation:",
|
|
41066
41210
|
" See https://sharp.pixelplumbing.com/install#cross-platform",
|
|
41067
41211
|
"- Add platform-specific dependencies:",
|
|
41068
|
-
` npm install --os=${
|
|
41212
|
+
` npm install --os=${os24.replace("musl", "")}${libc} --cpu=${cpu} sharp`
|
|
41069
41213
|
);
|
|
41070
41214
|
} else {
|
|
41071
41215
|
help.push(
|
|
@@ -45806,24 +45950,7 @@ __export(session_host_exports, {
|
|
|
45806
45950
|
stopSessionHost: () => stopSessionHost
|
|
45807
45951
|
});
|
|
45808
45952
|
function buildSessionHostEnv(baseEnv) {
|
|
45809
|
-
const env =
|
|
45810
|
-
for (const [key, value] of Object.entries(baseEnv)) {
|
|
45811
|
-
if (typeof value !== "string") continue;
|
|
45812
|
-
env[key] = value;
|
|
45813
|
-
}
|
|
45814
|
-
for (const key of Object.keys(env)) {
|
|
45815
|
-
if (key === "INIT_CWD" || 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_")) {
|
|
45816
|
-
delete env[key];
|
|
45817
|
-
}
|
|
45818
|
-
}
|
|
45819
|
-
if (!env.NO_COLOR) {
|
|
45820
|
-
if (!env.TERM || env.TERM === "xterm-color") env.TERM = "xterm-256color";
|
|
45821
|
-
if (!env.COLORTERM) env.COLORTERM = "truecolor";
|
|
45822
|
-
if (process.platform === "win32") {
|
|
45823
|
-
if (!env.FORCE_COLOR) env.FORCE_COLOR = "1";
|
|
45824
|
-
if (!env.CLICOLOR) env.CLICOLOR = "1";
|
|
45825
|
-
}
|
|
45826
|
-
}
|
|
45953
|
+
const env = sanitizeSpawnEnv(baseEnv);
|
|
45827
45954
|
env.ADHDEV_SESSION_HOST_NAME = SESSION_HOST_APP_NAME;
|
|
45828
45955
|
return env;
|
|
45829
45956
|
}
|
|
@@ -45840,7 +45967,7 @@ function resolveSessionHostEntry() {
|
|
|
45840
45967
|
return require.resolve("@adhdev/session-host-daemon");
|
|
45841
45968
|
}
|
|
45842
45969
|
function getSessionHostPidFile() {
|
|
45843
|
-
return path20.join(
|
|
45970
|
+
return path20.join(os20.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
|
|
45844
45971
|
}
|
|
45845
45972
|
function getSessionHostStatusPaths() {
|
|
45846
45973
|
return {
|
|
@@ -45870,6 +45997,35 @@ function killPid2(pid) {
|
|
|
45870
45997
|
return false;
|
|
45871
45998
|
}
|
|
45872
45999
|
}
|
|
46000
|
+
function getWindowsProcessCommandLine(pid) {
|
|
46001
|
+
const pidFilter = `ProcessId=${pid}`;
|
|
46002
|
+
try {
|
|
46003
|
+
const wmicOut = (0, import_child_process11.execFileSync)("wmic", [
|
|
46004
|
+
"process",
|
|
46005
|
+
"where",
|
|
46006
|
+
pidFilter,
|
|
46007
|
+
"get",
|
|
46008
|
+
"CommandLine"
|
|
46009
|
+
], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"] });
|
|
46010
|
+
const text = wmicOut.trim();
|
|
46011
|
+
if (text) return text;
|
|
46012
|
+
} catch {
|
|
46013
|
+
}
|
|
46014
|
+
try {
|
|
46015
|
+
const psOut = (0, import_child_process11.execFileSync)("powershell.exe", [
|
|
46016
|
+
"-NoProfile",
|
|
46017
|
+
"-NonInteractive",
|
|
46018
|
+
"-ExecutionPolicy",
|
|
46019
|
+
"Bypass",
|
|
46020
|
+
"-Command",
|
|
46021
|
+
`(Get-CimInstance Win32_Process -Filter "${pidFilter}").CommandLine`
|
|
46022
|
+
], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] });
|
|
46023
|
+
const text = psOut.trim();
|
|
46024
|
+
if (text) return text;
|
|
46025
|
+
} catch {
|
|
46026
|
+
}
|
|
46027
|
+
return null;
|
|
46028
|
+
}
|
|
45873
46029
|
function stopSessionHost() {
|
|
45874
46030
|
let stopped = false;
|
|
45875
46031
|
const pidFile = getSessionHostPidFile();
|
|
@@ -45887,7 +46043,26 @@ function stopSessionHost() {
|
|
|
45887
46043
|
} catch {
|
|
45888
46044
|
}
|
|
45889
46045
|
}
|
|
45890
|
-
if (process.platform
|
|
46046
|
+
if (process.platform === "win32") {
|
|
46047
|
+
try {
|
|
46048
|
+
const raw = (0, import_child_process11.execFileSync)("tasklist", ["/FO", "CSV", "/NH", "/FI", "IMAGENAME eq node.exe"], {
|
|
46049
|
+
encoding: "utf8",
|
|
46050
|
+
timeout: 5e3,
|
|
46051
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
46052
|
+
}).trim();
|
|
46053
|
+
for (const line of raw.split(/\r?\n/)) {
|
|
46054
|
+
const match = line.match(/^"node\.exe","(\d+)"/i);
|
|
46055
|
+
if (!match) continue;
|
|
46056
|
+
const candidatePid = Number.parseInt(match[1], 10);
|
|
46057
|
+
if (!Number.isFinite(candidatePid) || candidatePid === process.pid) continue;
|
|
46058
|
+
const commandLine = getWindowsProcessCommandLine(candidatePid);
|
|
46059
|
+
if (commandLine?.includes("session-host-daemon")) {
|
|
46060
|
+
stopped = killPid2(candidatePid) || stopped;
|
|
46061
|
+
}
|
|
46062
|
+
}
|
|
46063
|
+
} catch {
|
|
46064
|
+
}
|
|
46065
|
+
} else {
|
|
45891
46066
|
try {
|
|
45892
46067
|
const raw = (0, import_child_process11.execFileSync)("pgrep", ["-f", "session-host-daemon"], { encoding: "utf8" }).trim();
|
|
45893
46068
|
for (const line of raw.split("\n")) {
|
|
@@ -45904,13 +46079,20 @@ function stopSessionHost() {
|
|
|
45904
46079
|
async function ensureSessionHostReady2() {
|
|
45905
46080
|
const spawnHost = () => {
|
|
45906
46081
|
const entry = resolveSessionHostEntry();
|
|
46082
|
+
const logDir = path20.join(os20.homedir(), ".adhdev", "logs");
|
|
46083
|
+
fs16.mkdirSync(logDir, { recursive: true });
|
|
46084
|
+
const logFd = fs16.openSync(path20.join(logDir, "session-host.log"), "a");
|
|
45907
46085
|
const child = (0, import_child_process11.spawn)(process.execPath, [entry], {
|
|
45908
46086
|
detached: true,
|
|
45909
|
-
stdio: "ignore",
|
|
46087
|
+
stdio: ["ignore", logFd, logFd],
|
|
45910
46088
|
windowsHide: true,
|
|
45911
46089
|
env: buildSessionHostEnv(process.env)
|
|
45912
46090
|
});
|
|
45913
46091
|
child.unref();
|
|
46092
|
+
try {
|
|
46093
|
+
fs16.closeSync(logFd);
|
|
46094
|
+
} catch {
|
|
46095
|
+
}
|
|
45914
46096
|
};
|
|
45915
46097
|
try {
|
|
45916
46098
|
return await ensureSessionHostReady({
|
|
@@ -45961,13 +46143,13 @@ async function probeSessionHostStatus() {
|
|
|
45961
46143
|
};
|
|
45962
46144
|
}
|
|
45963
46145
|
}
|
|
45964
|
-
var import_child_process11, fs16,
|
|
46146
|
+
var import_child_process11, fs16, os20, path20, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
|
|
45965
46147
|
var init_session_host = __esm({
|
|
45966
46148
|
"src/session-host.ts"() {
|
|
45967
46149
|
"use strict";
|
|
45968
46150
|
import_child_process11 = require("child_process");
|
|
45969
46151
|
fs16 = __toESM(require("fs"));
|
|
45970
|
-
|
|
46152
|
+
os20 = __toESM(require("os"));
|
|
45971
46153
|
path20 = __toESM(require("path"));
|
|
45972
46154
|
init_src();
|
|
45973
46155
|
init_dist();
|
|
@@ -46012,7 +46194,7 @@ __export(adhdev_daemon_exports, {
|
|
|
46012
46194
|
stopDaemon: () => stopDaemon
|
|
46013
46195
|
});
|
|
46014
46196
|
function getDaemonPidFile() {
|
|
46015
|
-
const dir = path21.join(
|
|
46197
|
+
const dir = path21.join(os21.homedir(), ".adhdev");
|
|
46016
46198
|
if (!fs17.existsSync(dir)) fs17.mkdirSync(dir, { recursive: true });
|
|
46017
46199
|
return path21.join(dir, "daemon.pid");
|
|
46018
46200
|
}
|
|
@@ -46060,7 +46242,7 @@ function stopDaemon() {
|
|
|
46060
46242
|
return false;
|
|
46061
46243
|
}
|
|
46062
46244
|
}
|
|
46063
|
-
var
|
|
46245
|
+
var os21, fs17, path21, import_http, import_ws3, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
|
|
46064
46246
|
var init_adhdev_daemon = __esm({
|
|
46065
46247
|
"src/adhdev-daemon.ts"() {
|
|
46066
46248
|
"use strict";
|
|
@@ -46070,14 +46252,14 @@ var init_adhdev_daemon = __esm({
|
|
|
46070
46252
|
init_screenshot_controller();
|
|
46071
46253
|
init_session_host();
|
|
46072
46254
|
init_dist();
|
|
46073
|
-
|
|
46255
|
+
os21 = __toESM(require("os"));
|
|
46074
46256
|
fs17 = __toESM(require("fs"));
|
|
46075
46257
|
path21 = __toESM(require("path"));
|
|
46076
46258
|
import_http = require("http");
|
|
46077
46259
|
import_ws3 = require("ws");
|
|
46078
46260
|
import_chalk2 = __toESM(require("chalk"));
|
|
46079
46261
|
init_version();
|
|
46080
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.
|
|
46262
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.13" });
|
|
46081
46263
|
DANGEROUS_PATTERNS = [
|
|
46082
46264
|
/\brm\s+(-[a-z]*f|-[a-z]*r|--force|--recursive)/i,
|
|
46083
46265
|
/\bsudo\b/i,
|
|
@@ -46214,8 +46396,8 @@ ${err?.stack || ""}`);
|
|
|
46214
46396
|
cliInfo: {
|
|
46215
46397
|
type: "adhdev-daemon",
|
|
46216
46398
|
version: pkgVersion,
|
|
46217
|
-
platform:
|
|
46218
|
-
hostname:
|
|
46399
|
+
platform: os21.platform(),
|
|
46400
|
+
hostname: os21.hostname(),
|
|
46219
46401
|
machineId: config2.machineId,
|
|
46220
46402
|
instanceId
|
|
46221
46403
|
}
|
|
@@ -46824,16 +47006,16 @@ async function loginFlow() {
|
|
|
46824
47006
|
let verificationUrl;
|
|
46825
47007
|
try {
|
|
46826
47008
|
const config2 = loadConfig();
|
|
46827
|
-
const
|
|
47009
|
+
const os24 = await import("os");
|
|
46828
47010
|
const res = await fetch(`${SERVER_URL}/auth/cli/init`, {
|
|
46829
47011
|
method: "POST",
|
|
46830
47012
|
headers: { "Content-Type": "application/json" },
|
|
46831
47013
|
body: JSON.stringify({
|
|
46832
47014
|
clientMachineId: config2.machineId,
|
|
46833
47015
|
registeredMachineId: config2.registeredMachineId,
|
|
46834
|
-
hostname:
|
|
46835
|
-
platform:
|
|
46836
|
-
arch:
|
|
47016
|
+
hostname: os24.hostname(),
|
|
47017
|
+
platform: os24.platform(),
|
|
47018
|
+
arch: os24.arch()
|
|
46837
47019
|
})
|
|
46838
47020
|
});
|
|
46839
47021
|
if (!res.ok) {
|
|
@@ -46934,10 +47116,10 @@ async function startDaemonFlow() {
|
|
|
46934
47116
|
const { execSync: execSync7 } = await import("child_process");
|
|
46935
47117
|
const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
46936
47118
|
const logPath = getCurrentDaemonLogPath2();
|
|
46937
|
-
const
|
|
46938
|
-
const
|
|
47119
|
+
const os24 = await import("os");
|
|
47120
|
+
const platform11 = os24.platform();
|
|
46939
47121
|
try {
|
|
46940
|
-
if (
|
|
47122
|
+
if (platform11 === "win32") {
|
|
46941
47123
|
execSync7("start /B adhdev daemon >NUL 2>&1", {
|
|
46942
47124
|
timeout: 3e3,
|
|
46943
47125
|
stdio: "ignore",
|
|
@@ -47703,9 +47885,10 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
47703
47885
|
var import_chalk6 = __toESM(require("chalk"));
|
|
47704
47886
|
var import_child_process12 = require("child_process");
|
|
47705
47887
|
var fs18 = __toESM(require("fs"));
|
|
47706
|
-
var
|
|
47888
|
+
var os23 = __toESM(require("os"));
|
|
47707
47889
|
var path23 = __toESM(require("path"));
|
|
47708
47890
|
init_src();
|
|
47891
|
+
init_session_host();
|
|
47709
47892
|
function resolvePackageRoot() {
|
|
47710
47893
|
return path23.resolve(__dirname, "..", "..");
|
|
47711
47894
|
}
|
|
@@ -47754,8 +47937,8 @@ function readLogHints(logPath) {
|
|
|
47754
47937
|
function buildBrowseProbeChecks() {
|
|
47755
47938
|
const probes = process.platform === "win32" ? [
|
|
47756
47939
|
process.env.SystemDrive ? `${process.env.SystemDrive.replace(/[\\/]+$/, "")}\\` : "C:\\",
|
|
47757
|
-
|
|
47758
|
-
] : ["/",
|
|
47940
|
+
os23.homedir()
|
|
47941
|
+
] : ["/", os23.homedir()];
|
|
47759
47942
|
return probes.map((probePath, index) => {
|
|
47760
47943
|
try {
|
|
47761
47944
|
const entries = fs18.readdirSync(probePath, { withFileTypes: true });
|
|
@@ -47810,25 +47993,71 @@ function registerDoctorCommands(program2, pkgVersion3) {
|
|
|
47810
47993
|
label: "sharp",
|
|
47811
47994
|
ok: Boolean(resolveModuleFromPackage("sharp", packageRoot)),
|
|
47812
47995
|
detail: resolveModuleFromPackage("sharp", packageRoot) || "module not found",
|
|
47813
|
-
fatal:
|
|
47996
|
+
fatal: false
|
|
47814
47997
|
},
|
|
47815
47998
|
{
|
|
47816
47999
|
label: nativeSharpPackage,
|
|
47817
48000
|
ok: Boolean(resolveModuleFromPackage(nativeSharpPackage, packageRoot)),
|
|
47818
48001
|
detail: resolveModuleFromPackage(nativeSharpPackage, packageRoot) || "module not found",
|
|
47819
|
-
fatal:
|
|
48002
|
+
fatal: false
|
|
47820
48003
|
},
|
|
47821
48004
|
...buildBrowseProbeChecks()
|
|
47822
48005
|
];
|
|
48006
|
+
try {
|
|
48007
|
+
const sessionHostPid = getSessionHostPid();
|
|
48008
|
+
const probe = await probeSessionHostStatus();
|
|
48009
|
+
checks.push({
|
|
48010
|
+
label: "Session host PID",
|
|
48011
|
+
ok: !!sessionHostPid,
|
|
48012
|
+
detail: sessionHostPid ? `PID ${sessionHostPid} (${probe.pidFile})` : `no PID file (${probe.pidFile})`
|
|
48013
|
+
});
|
|
48014
|
+
checks.push({
|
|
48015
|
+
label: "Session host IPC",
|
|
48016
|
+
ok: probe.reachable,
|
|
48017
|
+
detail: probe.reachable ? `reachable (${probe.runtimeCount} runtime(s), ${probe.endpoint.kind}:${probe.endpoint.path})` : `unreachable (${probe.endpoint.kind}:${probe.endpoint.path})`
|
|
48018
|
+
});
|
|
48019
|
+
} catch (e) {
|
|
48020
|
+
checks.push({
|
|
48021
|
+
label: "Session host",
|
|
48022
|
+
ok: false,
|
|
48023
|
+
detail: `probe failed: ${e?.message || String(e)}`
|
|
48024
|
+
});
|
|
48025
|
+
}
|
|
48026
|
+
try {
|
|
48027
|
+
const termScreenMod = require("@adhdev/daemon-core/cli-adapters/terminal-screen.js");
|
|
48028
|
+
if (typeof termScreenMod?.getTerminalBackendRuntimeStatus === "function") {
|
|
48029
|
+
const backendStatus = termScreenMod.getTerminalBackendRuntimeStatus();
|
|
48030
|
+
checks.push({
|
|
48031
|
+
label: "Terminal backend",
|
|
48032
|
+
ok: true,
|
|
48033
|
+
detail: `${backendStatus.backend} (preference=${backendStatus.preference}, ghostty=${backendStatus.ghosttyAvailable})`
|
|
48034
|
+
});
|
|
48035
|
+
}
|
|
48036
|
+
} catch {
|
|
48037
|
+
}
|
|
48038
|
+
try {
|
|
48039
|
+
const providerLoader = new ProviderLoader();
|
|
48040
|
+
const cliResults = await detectCLIs(providerLoader);
|
|
48041
|
+
for (const cli of cliResults) {
|
|
48042
|
+
checks.push({
|
|
48043
|
+
label: `CLI: ${cli.displayName}`,
|
|
48044
|
+
ok: cli.installed,
|
|
48045
|
+
detail: cli.installed ? `${cli.path || cli.command} (v${cli.version || "unknown"})` : `not found (command: ${cli.command})`
|
|
48046
|
+
});
|
|
48047
|
+
}
|
|
48048
|
+
} catch {
|
|
48049
|
+
}
|
|
47823
48050
|
const failures = checks.filter((check2) => !check2.ok && check2.fatal);
|
|
47824
48051
|
const warnings = checks.filter((check2) => !check2.ok && !check2.fatal);
|
|
47825
48052
|
const logHints = readLogHints(logPath);
|
|
48053
|
+
const sessionHostLogPath = path23.join(os23.homedir(), ".adhdev", "logs", "session-host.log");
|
|
47826
48054
|
console.log(import_chalk6.default.bold("\n\u{1FA7A} ADHDev Doctor\n"));
|
|
47827
48055
|
console.log(import_chalk6.default.gray(` Version: ${pkgVersion3}`));
|
|
47828
48056
|
console.log(import_chalk6.default.gray(` Platform: ${process.platform} ${process.arch}`));
|
|
47829
48057
|
console.log(import_chalk6.default.gray(` Node: ${process.version}`));
|
|
47830
|
-
console.log(import_chalk6.default.gray(` Home: ${
|
|
48058
|
+
console.log(import_chalk6.default.gray(` Home: ${os23.homedir()}`));
|
|
47831
48059
|
console.log(import_chalk6.default.gray(` Log file: ${logPath}`));
|
|
48060
|
+
console.log(import_chalk6.default.gray(` SH log: ${sessionHostLogPath}`));
|
|
47832
48061
|
console.log();
|
|
47833
48062
|
for (const check2 of checks) {
|
|
47834
48063
|
console.log(formatCheck(check2));
|
|
@@ -48085,8 +48314,8 @@ function registerProviderCommands(program2) {
|
|
|
48085
48314
|
if (category === "ide") {
|
|
48086
48315
|
const fs19 = await import("fs");
|
|
48087
48316
|
const path24 = await import("path");
|
|
48088
|
-
const
|
|
48089
|
-
if (
|
|
48317
|
+
const os24 = await import("os");
|
|
48318
|
+
if (os24.platform() === "darwin") {
|
|
48090
48319
|
while (true) {
|
|
48091
48320
|
const p = (await rl.question(`macOS Application Path (e.g. /Applications/${defaultName}.app): `)).trim() || `/Applications/${defaultName}.app`;
|
|
48092
48321
|
if (p === "skip") break;
|
|
@@ -48100,7 +48329,7 @@ function registerProviderCommands(program2) {
|
|
|
48100
48329
|
processNames["darwin"] = path24.basename(p, ".app");
|
|
48101
48330
|
break;
|
|
48102
48331
|
}
|
|
48103
|
-
} else if (
|
|
48332
|
+
} else if (os24.platform() === "win32") {
|
|
48104
48333
|
while (true) {
|
|
48105
48334
|
const p = (await rl.question(`Windows Executable Path (e.g. C:\\Program Files\\${defaultName}\\${defaultName}.exe): `)).trim();
|
|
48106
48335
|
if (!p || p === "skip") break;
|