adhdev 0.8.7 → 0.8.9
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 +473 -174
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +1241 -434
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/vendor/session-host-daemon/index.js +55 -22
- package/vendor/session-host-daemon/index.js.map +1 -1
- package/vendor/session-host-daemon/index.mjs +55 -22
- package/vendor/session-host-daemon/index.mjs.map +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -748,6 +748,12 @@ function getLogLevel() {
|
|
|
748
748
|
function getDateStr() {
|
|
749
749
|
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
750
750
|
}
|
|
751
|
+
function getDaemonLogDir() {
|
|
752
|
+
return LOG_DIR;
|
|
753
|
+
}
|
|
754
|
+
function getCurrentDaemonLogPath(date5 = /* @__PURE__ */ new Date()) {
|
|
755
|
+
return path4.join(LOG_DIR, `daemon-${date5.toISOString().slice(0, 10)}.log`);
|
|
756
|
+
}
|
|
751
757
|
function checkDateRotation() {
|
|
752
758
|
const today = getDateStr();
|
|
753
759
|
if (today !== currentDate) {
|
|
@@ -37677,6 +37683,8 @@ __export(src_exports, {
|
|
|
37677
37683
|
forwardAgentStreamsToIdeInstance: () => forwardAgentStreamsToIdeInstance,
|
|
37678
37684
|
getAIExtensions: () => getAIExtensions,
|
|
37679
37685
|
getAvailableIdeIds: () => getAvailableIdeIds,
|
|
37686
|
+
getCurrentDaemonLogPath: () => getCurrentDaemonLogPath,
|
|
37687
|
+
getDaemonLogDir: () => getDaemonLogDir,
|
|
37680
37688
|
getHostMemorySnapshot: () => getHostMemorySnapshot,
|
|
37681
37689
|
getLogLevel: () => getLogLevel,
|
|
37682
37690
|
getRecentActivity: () => getRecentActivity,
|
|
@@ -37763,6 +37771,136 @@ var init_src = __esm({
|
|
|
37763
37771
|
}
|
|
37764
37772
|
});
|
|
37765
37773
|
|
|
37774
|
+
// src/cli/cdp-utils.ts
|
|
37775
|
+
var cdp_utils_exports = {};
|
|
37776
|
+
__export(cdp_utils_exports, {
|
|
37777
|
+
directCdpEval: () => directCdpEval,
|
|
37778
|
+
sendDaemonCommand: () => sendDaemonCommand
|
|
37779
|
+
});
|
|
37780
|
+
async function sendDaemonCommand(cmd, args = {}, port = 19222) {
|
|
37781
|
+
const WebSocket4 = (await import("ws")).default;
|
|
37782
|
+
const { DAEMON_WS_PATH: DAEMON_WS_PATH2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
37783
|
+
return new Promise((resolve13, reject) => {
|
|
37784
|
+
const wsUrl = `ws://127.0.0.1:${port}${DAEMON_WS_PATH2 || "/daemon"}`;
|
|
37785
|
+
const ws = new WebSocket4(wsUrl);
|
|
37786
|
+
const requestId = `cli-${Date.now()}`;
|
|
37787
|
+
let commandSent = false;
|
|
37788
|
+
const timeout = setTimeout(() => {
|
|
37789
|
+
ws.close();
|
|
37790
|
+
reject(new Error("Timeout: no response from daemon after 15s"));
|
|
37791
|
+
}, 15e3);
|
|
37792
|
+
const sendCommand = () => {
|
|
37793
|
+
if (commandSent) return;
|
|
37794
|
+
commandSent = true;
|
|
37795
|
+
ws.send(JSON.stringify({
|
|
37796
|
+
type: "ext:command",
|
|
37797
|
+
payload: { command: cmd, args, requestId }
|
|
37798
|
+
}));
|
|
37799
|
+
};
|
|
37800
|
+
ws.on("open", () => {
|
|
37801
|
+
ws.send(JSON.stringify({
|
|
37802
|
+
type: "ext:register",
|
|
37803
|
+
payload: {
|
|
37804
|
+
ideType: "cli-debug",
|
|
37805
|
+
ideVersion: "1.0.0",
|
|
37806
|
+
extensionVersion: "1.0.0",
|
|
37807
|
+
instanceId: `cli-debug-${Date.now()}`,
|
|
37808
|
+
machineId: "cli",
|
|
37809
|
+
workspaceFolders: []
|
|
37810
|
+
}
|
|
37811
|
+
}));
|
|
37812
|
+
setTimeout(() => sendCommand(), 200);
|
|
37813
|
+
});
|
|
37814
|
+
ws.on("message", (data) => {
|
|
37815
|
+
try {
|
|
37816
|
+
const msg = JSON.parse(data.toString());
|
|
37817
|
+
if (msg.type === "daemon:welcome") {
|
|
37818
|
+
sendCommand();
|
|
37819
|
+
return;
|
|
37820
|
+
}
|
|
37821
|
+
if (msg.type === "ext:command_result" && msg.payload?.requestId === requestId || msg.type === "daemon:command_result" || msg.type === "command_result") {
|
|
37822
|
+
clearTimeout(timeout);
|
|
37823
|
+
ws.close();
|
|
37824
|
+
resolve13(msg.payload?.result || msg.payload || msg);
|
|
37825
|
+
}
|
|
37826
|
+
} catch {
|
|
37827
|
+
}
|
|
37828
|
+
});
|
|
37829
|
+
ws.on("error", (e) => {
|
|
37830
|
+
clearTimeout(timeout);
|
|
37831
|
+
reject(new Error(
|
|
37832
|
+
`Cannot connect to local daemon IPC at port ${port}: ${e.message}
|
|
37833
|
+
This command needs a running local daemon with IPC enabled. Start with: adhdev daemon`
|
|
37834
|
+
));
|
|
37835
|
+
});
|
|
37836
|
+
ws.on("close", () => {
|
|
37837
|
+
clearTimeout(timeout);
|
|
37838
|
+
});
|
|
37839
|
+
});
|
|
37840
|
+
}
|
|
37841
|
+
async function directCdpEval(expression, port = 9222) {
|
|
37842
|
+
const http3 = await import("http");
|
|
37843
|
+
const targets = await new Promise((resolve13, reject) => {
|
|
37844
|
+
http3.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
37845
|
+
let data = "";
|
|
37846
|
+
res.on("data", (c) => data += c);
|
|
37847
|
+
res.on("end", () => {
|
|
37848
|
+
try {
|
|
37849
|
+
resolve13(JSON.parse(data));
|
|
37850
|
+
} catch {
|
|
37851
|
+
reject(new Error("Invalid JSON"));
|
|
37852
|
+
}
|
|
37853
|
+
});
|
|
37854
|
+
}).on("error", (e) => reject(new Error(`Cannot reach CDP at port ${port}: ${e.message}`)));
|
|
37855
|
+
});
|
|
37856
|
+
const isNonMain = (title) => !title || /extension-output|ADHDev CDP|Debug Console|Output\s*$|Launchpad/i.test(title);
|
|
37857
|
+
const pages = targets.filter((t) => (t.type === "page" || t.type === "Page") && t.webSocketDebuggerUrl);
|
|
37858
|
+
const mainPages = pages.filter((t) => !isNonMain(t.title || ""));
|
|
37859
|
+
const target = (mainPages.length > 0 ? mainPages[0] : pages[0]) || targets[0];
|
|
37860
|
+
if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target found");
|
|
37861
|
+
const WebSocket4 = (await import("ws")).default;
|
|
37862
|
+
return new Promise((resolve13, reject) => {
|
|
37863
|
+
const ws = new WebSocket4(target.webSocketDebuggerUrl);
|
|
37864
|
+
const timeout = setTimeout(() => {
|
|
37865
|
+
ws.close();
|
|
37866
|
+
reject(new Error("CDP timeout"));
|
|
37867
|
+
}, 15e3);
|
|
37868
|
+
let id = 1;
|
|
37869
|
+
ws.on("open", () => {
|
|
37870
|
+
const stripped = expression.replace(/\/\*[\s\S]*?\*\//g, "").trimStart();
|
|
37871
|
+
const isAsync = stripped.startsWith("(async");
|
|
37872
|
+
ws.send(JSON.stringify({
|
|
37873
|
+
id: id++,
|
|
37874
|
+
method: "Runtime.evaluate",
|
|
37875
|
+
params: { expression, returnByValue: true, awaitPromise: isAsync }
|
|
37876
|
+
}));
|
|
37877
|
+
});
|
|
37878
|
+
ws.on("message", (data) => {
|
|
37879
|
+
const msg = JSON.parse(data.toString());
|
|
37880
|
+
if (msg.id) {
|
|
37881
|
+
clearTimeout(timeout);
|
|
37882
|
+
ws.close();
|
|
37883
|
+
if (msg.result?.result?.value !== void 0) {
|
|
37884
|
+
resolve13(msg.result.result.value);
|
|
37885
|
+
} else if (msg.result?.exceptionDetails) {
|
|
37886
|
+
reject(new Error(msg.result.exceptionDetails.text));
|
|
37887
|
+
} else {
|
|
37888
|
+
resolve13(msg.result);
|
|
37889
|
+
}
|
|
37890
|
+
}
|
|
37891
|
+
});
|
|
37892
|
+
ws.on("error", (e) => {
|
|
37893
|
+
clearTimeout(timeout);
|
|
37894
|
+
reject(new Error(`CDP connection failed: ${e.message}`));
|
|
37895
|
+
});
|
|
37896
|
+
});
|
|
37897
|
+
}
|
|
37898
|
+
var init_cdp_utils = __esm({
|
|
37899
|
+
"src/cli/cdp-utils.ts"() {
|
|
37900
|
+
"use strict";
|
|
37901
|
+
}
|
|
37902
|
+
});
|
|
37903
|
+
|
|
37766
37904
|
// src/server-connection.ts
|
|
37767
37905
|
var import_ws2, ServerConnection;
|
|
37768
37906
|
var init_server_connection = __esm({
|
|
@@ -39048,7 +39186,10 @@ var init_screenshot_controller = __esm({
|
|
|
39048
39186
|
var session_host_exports = {};
|
|
39049
39187
|
__export(session_host_exports, {
|
|
39050
39188
|
ensureSessionHostReady: () => ensureSessionHostReady2,
|
|
39189
|
+
getSessionHostPid: () => getSessionHostPid,
|
|
39190
|
+
getSessionHostStatusPaths: () => getSessionHostStatusPaths,
|
|
39051
39191
|
listHostedCliRuntimes: () => listHostedCliRuntimes2,
|
|
39192
|
+
probeSessionHostStatus: () => probeSessionHostStatus,
|
|
39052
39193
|
stopSessionHost: () => stopSessionHost
|
|
39053
39194
|
});
|
|
39054
39195
|
function buildSessionHostEnv(baseEnv) {
|
|
@@ -39080,6 +39221,22 @@ function resolveSessionHostEntry() {
|
|
|
39080
39221
|
function getSessionHostPidFile() {
|
|
39081
39222
|
return path20.join(os20.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
|
|
39082
39223
|
}
|
|
39224
|
+
function getSessionHostStatusPaths() {
|
|
39225
|
+
return {
|
|
39226
|
+
pidFile: getSessionHostPidFile(),
|
|
39227
|
+
endpoint: getDefaultSessionHostEndpoint(SESSION_HOST_APP_NAME)
|
|
39228
|
+
};
|
|
39229
|
+
}
|
|
39230
|
+
function getSessionHostPid() {
|
|
39231
|
+
try {
|
|
39232
|
+
const pidFile = getSessionHostPidFile();
|
|
39233
|
+
if (!fs16.existsSync(pidFile)) return null;
|
|
39234
|
+
const pid = Number.parseInt(fs16.readFileSync(pidFile, "utf8").trim(), 10);
|
|
39235
|
+
return Number.isFinite(pid) ? pid : null;
|
|
39236
|
+
} catch {
|
|
39237
|
+
return null;
|
|
39238
|
+
}
|
|
39239
|
+
}
|
|
39083
39240
|
function killPid2(pid) {
|
|
39084
39241
|
try {
|
|
39085
39242
|
if (process.platform === "win32") {
|
|
@@ -39156,6 +39313,33 @@ async function ensureSessionHostReady2() {
|
|
|
39156
39313
|
async function listHostedCliRuntimes2(endpoint) {
|
|
39157
39314
|
return listHostedCliRuntimes(endpoint);
|
|
39158
39315
|
}
|
|
39316
|
+
async function probeSessionHostStatus() {
|
|
39317
|
+
const { pidFile, endpoint } = getSessionHostStatusPaths();
|
|
39318
|
+
const pid = getSessionHostPid();
|
|
39319
|
+
const client = new SessionHostClient({ endpoint });
|
|
39320
|
+
try {
|
|
39321
|
+
await client.connect();
|
|
39322
|
+
await client.close();
|
|
39323
|
+
const runtimes = await listHostedCliRuntimes(endpoint);
|
|
39324
|
+
return {
|
|
39325
|
+
pid,
|
|
39326
|
+
pidFile,
|
|
39327
|
+
endpoint,
|
|
39328
|
+
reachable: true,
|
|
39329
|
+
runtimeCount: runtimes.length
|
|
39330
|
+
};
|
|
39331
|
+
} catch {
|
|
39332
|
+
await client.close().catch(() => {
|
|
39333
|
+
});
|
|
39334
|
+
return {
|
|
39335
|
+
pid,
|
|
39336
|
+
pidFile,
|
|
39337
|
+
endpoint,
|
|
39338
|
+
reachable: false,
|
|
39339
|
+
runtimeCount: 0
|
|
39340
|
+
};
|
|
39341
|
+
}
|
|
39342
|
+
}
|
|
39159
39343
|
var import_child_process11, fs16, os20, path20, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
|
|
39160
39344
|
var init_session_host = __esm({
|
|
39161
39345
|
"src/session-host.ts"() {
|
|
@@ -39165,6 +39349,7 @@ var init_session_host = __esm({
|
|
|
39165
39349
|
os20 = __toESM(require("os"));
|
|
39166
39350
|
path20 = __toESM(require("path"));
|
|
39167
39351
|
init_src();
|
|
39352
|
+
init_dist();
|
|
39168
39353
|
SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
|
|
39169
39354
|
SESSION_HOST_START_TIMEOUT_MS = 15e3;
|
|
39170
39355
|
}
|
|
@@ -39174,6 +39359,7 @@ var init_session_host = __esm({
|
|
|
39174
39359
|
var adhdev_daemon_exports = {};
|
|
39175
39360
|
__export(adhdev_daemon_exports, {
|
|
39176
39361
|
AdhdevDaemon: () => AdhdevDaemon,
|
|
39362
|
+
getDaemonPid: () => getDaemonPid,
|
|
39177
39363
|
isDaemonRunning: () => isDaemonRunning,
|
|
39178
39364
|
stopDaemon: () => stopDaemon
|
|
39179
39365
|
});
|
|
@@ -39203,6 +39389,16 @@ function isDaemonRunning() {
|
|
|
39203
39389
|
return false;
|
|
39204
39390
|
}
|
|
39205
39391
|
}
|
|
39392
|
+
function getDaemonPid() {
|
|
39393
|
+
const pidFile = getDaemonPidFile();
|
|
39394
|
+
try {
|
|
39395
|
+
if (!fs17.existsSync(pidFile)) return null;
|
|
39396
|
+
const pid = parseInt(fs17.readFileSync(pidFile, "utf-8").trim(), 10);
|
|
39397
|
+
return Number.isFinite(pid) ? pid : null;
|
|
39398
|
+
} catch {
|
|
39399
|
+
return null;
|
|
39400
|
+
}
|
|
39401
|
+
}
|
|
39206
39402
|
function stopDaemon() {
|
|
39207
39403
|
const pidFile = getDaemonPidFile();
|
|
39208
39404
|
try {
|
|
@@ -39216,7 +39412,7 @@ function stopDaemon() {
|
|
|
39216
39412
|
return false;
|
|
39217
39413
|
}
|
|
39218
39414
|
}
|
|
39219
|
-
var os21, fs17, path21, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
|
|
39415
|
+
var os21, fs17, path21, import_http, import_ws3, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
|
|
39220
39416
|
var init_adhdev_daemon = __esm({
|
|
39221
39417
|
"src/adhdev-daemon.ts"() {
|
|
39222
39418
|
"use strict";
|
|
@@ -39229,8 +39425,10 @@ var init_adhdev_daemon = __esm({
|
|
|
39229
39425
|
os21 = __toESM(require("os"));
|
|
39230
39426
|
fs17 = __toESM(require("fs"));
|
|
39231
39427
|
path21 = __toESM(require("path"));
|
|
39428
|
+
import_http = require("http");
|
|
39429
|
+
import_ws3 = require("ws");
|
|
39232
39430
|
import_chalk2 = __toESM(require("chalk"));
|
|
39233
|
-
pkgVersion = "0.8.
|
|
39431
|
+
pkgVersion = "0.8.9";
|
|
39234
39432
|
if (pkgVersion === "unknown") {
|
|
39235
39433
|
try {
|
|
39236
39434
|
const possiblePaths = [
|
|
@@ -39263,6 +39461,9 @@ var init_adhdev_daemon = __esm({
|
|
|
39263
39461
|
/\b:\/\)\s*\{/
|
|
39264
39462
|
];
|
|
39265
39463
|
AdhdevDaemon = class {
|
|
39464
|
+
localHttpServer = null;
|
|
39465
|
+
localWss = null;
|
|
39466
|
+
localClients = /* @__PURE__ */ new Set();
|
|
39266
39467
|
serverConn = null;
|
|
39267
39468
|
p2p = null;
|
|
39268
39469
|
screenshotController = null;
|
|
@@ -39290,11 +39491,7 @@ var init_adhdev_daemon = __esm({
|
|
|
39290
39491
|
return mode === "chat" || mode === "terminal";
|
|
39291
39492
|
}
|
|
39292
39493
|
async start(options = {}) {
|
|
39293
|
-
|
|
39294
|
-
const { installGlobalInterceptor: installGlobalInterceptor2 } = require("./logging/logger");
|
|
39295
|
-
installGlobalInterceptor2();
|
|
39296
|
-
} catch {
|
|
39297
|
-
}
|
|
39494
|
+
installGlobalInterceptor();
|
|
39298
39495
|
process.on("uncaughtException", (err) => {
|
|
39299
39496
|
LOG.error("Daemon", `Uncaught exception: ${err?.message}
|
|
39300
39497
|
${err?.stack || ""}`);
|
|
@@ -39370,6 +39567,7 @@ ${err?.stack || ""}`);
|
|
|
39370
39567
|
}
|
|
39371
39568
|
});
|
|
39372
39569
|
await this.components.cliManager.restoreHostedSessions();
|
|
39570
|
+
await this.startLocalIpcServer();
|
|
39373
39571
|
this.components.providerLoader.fetchLatest().then(({ updated }) => {
|
|
39374
39572
|
if (updated) {
|
|
39375
39573
|
this.components.providerLoader.reload();
|
|
@@ -39526,6 +39724,7 @@ ${err?.stack || ""}`);
|
|
|
39526
39724
|
const cdpManagers = this.components?.cdpManagers;
|
|
39527
39725
|
const cdpStatus = cdpManagers && cdpManagers.size > 0 ? `\u2705 ${[...cdpManagers.entries()].map(([k, m]) => `${k}:${m.getPort()}`).join(", ")}` : "\u274C not connected";
|
|
39528
39726
|
console.log(` ${import_chalk2.default.bold("CDP:")} ${cdpStatus}`);
|
|
39727
|
+
console.log(` ${import_chalk2.default.bold("IPC:")} ${import_chalk2.default.cyan(`ws://127.0.0.1:${this.localPort}${DAEMON_WS_PATH}`)}`);
|
|
39529
39728
|
console.log(` ${import_chalk2.default.bold("P2P:")} ${this.p2p?.isAvailable ? "\u2705 available" : "\u274C unavailable"}`);
|
|
39530
39729
|
const providerCount = this.components?.providerLoader.getAll().length ?? 0;
|
|
39531
39730
|
console.log(` ${import_chalk2.default.bold("Providers:")} ${providerCount > 0 ? `\u2705 ${providerCount} loaded` : "\u274C not loaded"}`);
|
|
@@ -39642,6 +39841,135 @@ ${err?.stack || ""}`);
|
|
|
39642
39841
|
return { success: false, error: e.message };
|
|
39643
39842
|
}
|
|
39644
39843
|
}
|
|
39844
|
+
async startLocalIpcServer() {
|
|
39845
|
+
if (this.localHttpServer || this.localWss) return;
|
|
39846
|
+
this.localHttpServer = (0, import_http.createServer)((req, res) => {
|
|
39847
|
+
const url2 = req.url || "/";
|
|
39848
|
+
if (req.method === "GET" && url2 === "/health") {
|
|
39849
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
39850
|
+
res.end(JSON.stringify({
|
|
39851
|
+
ok: true,
|
|
39852
|
+
pid: process.pid,
|
|
39853
|
+
wsPath: DAEMON_WS_PATH,
|
|
39854
|
+
port: this.localPort
|
|
39855
|
+
}));
|
|
39856
|
+
return;
|
|
39857
|
+
}
|
|
39858
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
39859
|
+
res.end(JSON.stringify({ error: "Not found" }));
|
|
39860
|
+
});
|
|
39861
|
+
this.localWss = new import_ws3.WebSocketServer({ noServer: true });
|
|
39862
|
+
this.localWss.on("connection", (ws) => this.handleLocalIpcConnection(ws));
|
|
39863
|
+
this.localHttpServer.on("upgrade", (req, socket, head) => {
|
|
39864
|
+
const wsUrl = new URL(req.url || "/", `http://${req.headers.host || "127.0.0.1"}`);
|
|
39865
|
+
if (wsUrl.pathname !== DAEMON_WS_PATH) {
|
|
39866
|
+
socket.write("HTTP/1.1 404 Not Found\r\n\r\n");
|
|
39867
|
+
socket.destroy();
|
|
39868
|
+
return;
|
|
39869
|
+
}
|
|
39870
|
+
this.localWss.handleUpgrade(req, socket, head, (ws) => {
|
|
39871
|
+
this.localWss.emit("connection", ws, req);
|
|
39872
|
+
});
|
|
39873
|
+
});
|
|
39874
|
+
await new Promise((resolve13, reject) => {
|
|
39875
|
+
const cleanup = () => {
|
|
39876
|
+
this.localHttpServer?.off("error", onError);
|
|
39877
|
+
this.localHttpServer?.off("listening", onListening);
|
|
39878
|
+
};
|
|
39879
|
+
const onError = (error48) => {
|
|
39880
|
+
cleanup();
|
|
39881
|
+
reject(error48);
|
|
39882
|
+
};
|
|
39883
|
+
const onListening = () => {
|
|
39884
|
+
cleanup();
|
|
39885
|
+
resolve13();
|
|
39886
|
+
};
|
|
39887
|
+
this.localHttpServer.once("error", onError);
|
|
39888
|
+
this.localHttpServer.once("listening", onListening);
|
|
39889
|
+
this.localHttpServer.listen(this.localPort, "127.0.0.1");
|
|
39890
|
+
});
|
|
39891
|
+
LOG.info("IPC", `Local IPC listening on ws://127.0.0.1:${this.localPort}${DAEMON_WS_PATH}`);
|
|
39892
|
+
}
|
|
39893
|
+
handleLocalIpcConnection(ws) {
|
|
39894
|
+
this.localClients.add(ws);
|
|
39895
|
+
this.sendLocalIpcWelcome(ws);
|
|
39896
|
+
ws.on("message", (raw) => {
|
|
39897
|
+
void this.handleLocalIpcMessage(ws, raw.toString());
|
|
39898
|
+
});
|
|
39899
|
+
ws.on("close", () => {
|
|
39900
|
+
this.localClients.delete(ws);
|
|
39901
|
+
});
|
|
39902
|
+
ws.on("error", () => {
|
|
39903
|
+
this.localClients.delete(ws);
|
|
39904
|
+
});
|
|
39905
|
+
}
|
|
39906
|
+
sendLocalIpcWelcome(ws) {
|
|
39907
|
+
try {
|
|
39908
|
+
const cliAgents = this.components ? this.components.instanceManager.collectAllStates().filter((state) => state?.category === "cli").map((state) => String(state?.instanceId || "")).filter(Boolean) : [];
|
|
39909
|
+
ws.send(JSON.stringify({
|
|
39910
|
+
type: "daemon:welcome",
|
|
39911
|
+
payload: {
|
|
39912
|
+
daemonVersion: pkgVersion,
|
|
39913
|
+
serverConnected: this.serverConn?.isConnected() ?? false,
|
|
39914
|
+
cdpConnected: (this.components?.cdpManagers.size || 0) > 0,
|
|
39915
|
+
localPort: this.localPort,
|
|
39916
|
+
cliAgents
|
|
39917
|
+
}
|
|
39918
|
+
}));
|
|
39919
|
+
} catch (error48) {
|
|
39920
|
+
LOG.warn("IPC", `Failed to send welcome: ${error48?.message || error48}`);
|
|
39921
|
+
}
|
|
39922
|
+
}
|
|
39923
|
+
async handleLocalIpcMessage(ws, raw) {
|
|
39924
|
+
let msg;
|
|
39925
|
+
try {
|
|
39926
|
+
msg = JSON.parse(raw);
|
|
39927
|
+
} catch {
|
|
39928
|
+
return;
|
|
39929
|
+
}
|
|
39930
|
+
if (!msg || typeof msg !== "object") return;
|
|
39931
|
+
if (msg.type === "ext:register") {
|
|
39932
|
+
this.sendLocalIpcWelcome(ws);
|
|
39933
|
+
return;
|
|
39934
|
+
}
|
|
39935
|
+
if (msg.type !== "ext:command") return;
|
|
39936
|
+
const payload = msg.payload && typeof msg.payload === "object" ? msg.payload : {};
|
|
39937
|
+
const command = typeof payload.command === "string" ? payload.command : "";
|
|
39938
|
+
const args = payload.args && typeof payload.args === "object" ? payload.args : {};
|
|
39939
|
+
const requestId = typeof payload.requestId === "string" ? payload.requestId : typeof payload.messageId === "string" ? payload.messageId : `ipc-${Date.now()}`;
|
|
39940
|
+
if (!command) {
|
|
39941
|
+
ws.send(JSON.stringify({
|
|
39942
|
+
type: "ext:command_result",
|
|
39943
|
+
payload: {
|
|
39944
|
+
requestId,
|
|
39945
|
+
success: false,
|
|
39946
|
+
error: "command required"
|
|
39947
|
+
}
|
|
39948
|
+
}));
|
|
39949
|
+
return;
|
|
39950
|
+
}
|
|
39951
|
+
try {
|
|
39952
|
+
const result = await this.components.router.execute(command, args, "ipc");
|
|
39953
|
+
ws.send(JSON.stringify({
|
|
39954
|
+
type: "ext:command_result",
|
|
39955
|
+
payload: {
|
|
39956
|
+
requestId,
|
|
39957
|
+
success: !!result?.success,
|
|
39958
|
+
result,
|
|
39959
|
+
error: result?.success ? void 0 : result?.error
|
|
39960
|
+
}
|
|
39961
|
+
}));
|
|
39962
|
+
} catch (error48) {
|
|
39963
|
+
ws.send(JSON.stringify({
|
|
39964
|
+
type: "ext:command_result",
|
|
39965
|
+
payload: {
|
|
39966
|
+
requestId,
|
|
39967
|
+
success: false,
|
|
39968
|
+
error: error48?.message || String(error48)
|
|
39969
|
+
}
|
|
39970
|
+
}));
|
|
39971
|
+
}
|
|
39972
|
+
}
|
|
39645
39973
|
// ─── executeDaemonCommand / stopIde: Removed — now in DaemonCommandRouter ───
|
|
39646
39974
|
sendResult(msg, success2, extra) {
|
|
39647
39975
|
if (!msg.id) return;
|
|
@@ -39682,6 +40010,23 @@ ${err?.stack || ""}`);
|
|
|
39682
40010
|
this.serverConn?.disconnect();
|
|
39683
40011
|
} catch {
|
|
39684
40012
|
}
|
|
40013
|
+
try {
|
|
40014
|
+
for (const client of this.localClients) {
|
|
40015
|
+
client.close();
|
|
40016
|
+
}
|
|
40017
|
+
this.localClients.clear();
|
|
40018
|
+
this.localWss?.close();
|
|
40019
|
+
this.localWss = null;
|
|
40020
|
+
await new Promise((resolve13) => {
|
|
40021
|
+
if (!this.localHttpServer) {
|
|
40022
|
+
resolve13();
|
|
40023
|
+
return;
|
|
40024
|
+
}
|
|
40025
|
+
this.localHttpServer.close(() => resolve13());
|
|
40026
|
+
this.localHttpServer = null;
|
|
40027
|
+
});
|
|
40028
|
+
} catch {
|
|
40029
|
+
}
|
|
39685
40030
|
removeDaemonPid();
|
|
39686
40031
|
console.log(import_chalk2.default.green(" \u2713 ADHDev Daemon stopped.\n"));
|
|
39687
40032
|
if (exitProcess) {
|
|
@@ -39821,11 +40166,12 @@ async function quickSetup() {
|
|
|
39821
40166
|
console.log(` ${import_chalk3.default.bold("Status:")} ${loginResult ? import_chalk3.default.green("Ready to connect") : import_chalk3.default.yellow("Login required")}`);
|
|
39822
40167
|
console.log();
|
|
39823
40168
|
console.log(import_chalk3.default.gray(" Next steps:"));
|
|
39824
|
-
console.log(import_chalk3.default.gray(` ${loginResult ? "adhdev daemon \u2014 Start the main daemon (
|
|
40169
|
+
console.log(import_chalk3.default.gray(` ${loginResult ? "adhdev daemon \u2014 Start the main daemon (IDE / remote features)" : "adhdev setup \u2014 Sign in to finish setup and enable the daemon"}`));
|
|
39825
40170
|
console.log(import_chalk3.default.gray(" adhdev launch cursor \u2014 Launch Cursor IDE with remote control"));
|
|
39826
40171
|
console.log(import_chalk3.default.gray(" adhdev launch windsurf \u2014 Launch Windsurf IDE with remote control"));
|
|
39827
|
-
console.log(import_chalk3.default.gray(" adhdev
|
|
39828
|
-
console.log(import_chalk3.default.gray(" adhdev launch
|
|
40172
|
+
console.log(import_chalk3.default.gray(" adhdev daemon \u2014 Keep the daemon running for CLI agent launch"));
|
|
40173
|
+
console.log(import_chalk3.default.gray(" adhdev launch gemini \u2014 Start Gemini CLI agent"));
|
|
40174
|
+
console.log(import_chalk3.default.gray(" adhdev launch claude \u2014 Start Claude Code agent"));
|
|
39829
40175
|
console.log(import_chalk3.default.gray(" adhdev status \u2014 Check setup status"));
|
|
39830
40176
|
console.log();
|
|
39831
40177
|
console.log(import_chalk3.default.cyan(" Dashboard: https://adhf.dev/dashboard"));
|
|
@@ -39956,19 +40302,19 @@ async function startDaemonFlow() {
|
|
|
39956
40302
|
const { AdhdevDaemon: AdhdevDaemon2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
39957
40303
|
const daemon = new AdhdevDaemon2();
|
|
39958
40304
|
const { execSync: execSync7 } = await import("child_process");
|
|
40305
|
+
const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
40306
|
+
const logPath = getCurrentDaemonLogPath2();
|
|
39959
40307
|
const os22 = await import("os");
|
|
39960
|
-
const path23 = await import("path");
|
|
39961
|
-
const logPath = path23.join(os22.homedir(), ".adhdev", "daemon.log");
|
|
39962
40308
|
const platform11 = os22.platform();
|
|
39963
40309
|
try {
|
|
39964
40310
|
if (platform11 === "win32") {
|
|
39965
|
-
execSync7(
|
|
40311
|
+
execSync7("start /B adhdev daemon >NUL 2>&1", {
|
|
39966
40312
|
timeout: 3e3,
|
|
39967
40313
|
stdio: "ignore",
|
|
39968
40314
|
shell: "cmd.exe"
|
|
39969
40315
|
});
|
|
39970
40316
|
} else {
|
|
39971
|
-
execSync7(
|
|
40317
|
+
execSync7("nohup adhdev daemon >/dev/null 2>&1 &", {
|
|
39972
40318
|
timeout: 3e3,
|
|
39973
40319
|
stdio: "ignore"
|
|
39974
40320
|
});
|
|
@@ -40016,7 +40362,7 @@ async function installCliOnly() {
|
|
|
40016
40362
|
console.log(import_chalk3.default.gray(" The `adhdev` command lets you:"));
|
|
40017
40363
|
console.log(import_chalk3.default.gray(" \u2022 Start the main daemon (adhdev daemon)"));
|
|
40018
40364
|
console.log(import_chalk3.default.gray(" \u2022 Launch IDE with CDP (adhdev launch <ide>)"));
|
|
40019
|
-
console.log(import_chalk3.default.gray(" \u2022 Start CLI agents (adhdev launch <agent>)"));
|
|
40365
|
+
console.log(import_chalk3.default.gray(" \u2022 Start CLI agents (adhdev daemon && adhdev launch <agent>)"));
|
|
40020
40366
|
console.log(import_chalk3.default.gray(" \u2022 Check setup status (adhdev status)"));
|
|
40021
40367
|
console.log();
|
|
40022
40368
|
if (currentVersion) {
|
|
@@ -40112,124 +40458,6 @@ ${import_chalk3.default.cyan("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u
|
|
|
40112
40458
|
}
|
|
40113
40459
|
});
|
|
40114
40460
|
|
|
40115
|
-
// src/cli/cdp-utils.ts
|
|
40116
|
-
var cdp_utils_exports = {};
|
|
40117
|
-
__export(cdp_utils_exports, {
|
|
40118
|
-
directCdpEval: () => directCdpEval,
|
|
40119
|
-
sendDaemonCommand: () => sendDaemonCommand
|
|
40120
|
-
});
|
|
40121
|
-
async function sendDaemonCommand(cmd, args = {}, port = 19222) {
|
|
40122
|
-
const WebSocket3 = (await import("ws")).default;
|
|
40123
|
-
const { DAEMON_WS_PATH: DAEMON_WS_PATH2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
40124
|
-
return new Promise((resolve13, reject) => {
|
|
40125
|
-
const wsUrl = `ws://127.0.0.1:${port}${DAEMON_WS_PATH2 || "/daemon"}`;
|
|
40126
|
-
const ws = new WebSocket3(wsUrl);
|
|
40127
|
-
const timeout = setTimeout(() => {
|
|
40128
|
-
ws.close();
|
|
40129
|
-
reject(new Error("Timeout: no response from daemon after 15s"));
|
|
40130
|
-
}, 15e3);
|
|
40131
|
-
ws.on("open", () => {
|
|
40132
|
-
ws.send(JSON.stringify({
|
|
40133
|
-
type: "ext:register",
|
|
40134
|
-
payload: {
|
|
40135
|
-
ideType: "cli-debug",
|
|
40136
|
-
ideVersion: "1.0.0",
|
|
40137
|
-
extensionVersion: "1.0.0",
|
|
40138
|
-
instanceId: `cli-debug-${Date.now()}`,
|
|
40139
|
-
machineId: "cli"
|
|
40140
|
-
}
|
|
40141
|
-
}));
|
|
40142
|
-
setTimeout(() => {
|
|
40143
|
-
ws.send(JSON.stringify({
|
|
40144
|
-
type: "ext:command",
|
|
40145
|
-
payload: { command: cmd, args, messageId: `cli-${Date.now()}` }
|
|
40146
|
-
}));
|
|
40147
|
-
}, 200);
|
|
40148
|
-
});
|
|
40149
|
-
ws.on("message", (data) => {
|
|
40150
|
-
try {
|
|
40151
|
-
const msg = JSON.parse(data.toString());
|
|
40152
|
-
if (msg.type === "daemon:command_result" || msg.type === "command_result") {
|
|
40153
|
-
clearTimeout(timeout);
|
|
40154
|
-
ws.close();
|
|
40155
|
-
resolve13(msg.payload?.result || msg.payload || msg);
|
|
40156
|
-
}
|
|
40157
|
-
} catch {
|
|
40158
|
-
}
|
|
40159
|
-
});
|
|
40160
|
-
ws.on("error", (e) => {
|
|
40161
|
-
clearTimeout(timeout);
|
|
40162
|
-
reject(new Error(`Cannot connect to daemon at port ${port}: ${e.message}
|
|
40163
|
-
Is 'adhdev daemon' running?`));
|
|
40164
|
-
});
|
|
40165
|
-
ws.on("close", () => {
|
|
40166
|
-
clearTimeout(timeout);
|
|
40167
|
-
});
|
|
40168
|
-
});
|
|
40169
|
-
}
|
|
40170
|
-
async function directCdpEval(expression, port = 9222) {
|
|
40171
|
-
const http3 = await import("http");
|
|
40172
|
-
const targets = await new Promise((resolve13, reject) => {
|
|
40173
|
-
http3.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
40174
|
-
let data = "";
|
|
40175
|
-
res.on("data", (c) => data += c);
|
|
40176
|
-
res.on("end", () => {
|
|
40177
|
-
try {
|
|
40178
|
-
resolve13(JSON.parse(data));
|
|
40179
|
-
} catch {
|
|
40180
|
-
reject(new Error("Invalid JSON"));
|
|
40181
|
-
}
|
|
40182
|
-
});
|
|
40183
|
-
}).on("error", (e) => reject(new Error(`Cannot reach CDP at port ${port}: ${e.message}`)));
|
|
40184
|
-
});
|
|
40185
|
-
const isNonMain = (title) => !title || /extension-output|ADHDev CDP|Debug Console|Output\s*$|Launchpad/i.test(title);
|
|
40186
|
-
const pages = targets.filter((t) => (t.type === "page" || t.type === "Page") && t.webSocketDebuggerUrl);
|
|
40187
|
-
const mainPages = pages.filter((t) => !isNonMain(t.title || ""));
|
|
40188
|
-
const target = (mainPages.length > 0 ? mainPages[0] : pages[0]) || targets[0];
|
|
40189
|
-
if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target found");
|
|
40190
|
-
const WebSocket3 = (await import("ws")).default;
|
|
40191
|
-
return new Promise((resolve13, reject) => {
|
|
40192
|
-
const ws = new WebSocket3(target.webSocketDebuggerUrl);
|
|
40193
|
-
const timeout = setTimeout(() => {
|
|
40194
|
-
ws.close();
|
|
40195
|
-
reject(new Error("CDP timeout"));
|
|
40196
|
-
}, 15e3);
|
|
40197
|
-
let id = 1;
|
|
40198
|
-
ws.on("open", () => {
|
|
40199
|
-
const stripped = expression.replace(/\/\*[\s\S]*?\*\//g, "").trimStart();
|
|
40200
|
-
const isAsync = stripped.startsWith("(async");
|
|
40201
|
-
ws.send(JSON.stringify({
|
|
40202
|
-
id: id++,
|
|
40203
|
-
method: "Runtime.evaluate",
|
|
40204
|
-
params: { expression, returnByValue: true, awaitPromise: isAsync }
|
|
40205
|
-
}));
|
|
40206
|
-
});
|
|
40207
|
-
ws.on("message", (data) => {
|
|
40208
|
-
const msg = JSON.parse(data.toString());
|
|
40209
|
-
if (msg.id) {
|
|
40210
|
-
clearTimeout(timeout);
|
|
40211
|
-
ws.close();
|
|
40212
|
-
if (msg.result?.result?.value !== void 0) {
|
|
40213
|
-
resolve13(msg.result.result.value);
|
|
40214
|
-
} else if (msg.result?.exceptionDetails) {
|
|
40215
|
-
reject(new Error(msg.result.exceptionDetails.text));
|
|
40216
|
-
} else {
|
|
40217
|
-
resolve13(msg.result);
|
|
40218
|
-
}
|
|
40219
|
-
}
|
|
40220
|
-
});
|
|
40221
|
-
ws.on("error", (e) => {
|
|
40222
|
-
clearTimeout(timeout);
|
|
40223
|
-
reject(new Error(`CDP connection failed: ${e.message}`));
|
|
40224
|
-
});
|
|
40225
|
-
});
|
|
40226
|
-
}
|
|
40227
|
-
var init_cdp_utils = __esm({
|
|
40228
|
-
"src/cli/cdp-utils.ts"() {
|
|
40229
|
-
"use strict";
|
|
40230
|
-
}
|
|
40231
|
-
});
|
|
40232
|
-
|
|
40233
40461
|
// ../../oss/packages/web-core/src/constants/supported.ts
|
|
40234
40462
|
var supported_exports = {};
|
|
40235
40463
|
__export(supported_exports, {
|
|
@@ -40281,12 +40509,13 @@ init_src();
|
|
|
40281
40509
|
|
|
40282
40510
|
// src/cli/setup-commands.ts
|
|
40283
40511
|
var import_chalk4 = __toESM(require("chalk"));
|
|
40512
|
+
init_cdp_utils();
|
|
40284
40513
|
function registerSetupCommands(program2, providerLoader) {
|
|
40285
40514
|
program2.command("setup").description("Run the interactive setup wizard (detect IDEs, login)").option("-f, --force", "Force re-run setup even if already configured").action(async (options) => {
|
|
40286
40515
|
const { runWizard: runWizard2 } = await Promise.resolve().then(() => (init_wizard(), wizard_exports));
|
|
40287
40516
|
await runWizard2({ force: options.force });
|
|
40288
40517
|
});
|
|
40289
|
-
program2.command("launch [target]").description("Launch IDE with CDP or start CLI agent
|
|
40518
|
+
program2.command("launch [target]").description("Launch IDE with CDP or start CLI agent").option("-w, --workspace <path>", "Workspace directory to open").option("-n, --new-window", "Open in a new window").option("-d, --dir <path>", "Working directory for CLI agent", process.cwd()).action(async (targetArg, options) => {
|
|
40290
40519
|
const {
|
|
40291
40520
|
detectIDEs: detectIDEs2,
|
|
40292
40521
|
detectCLIs: detectCLIs2,
|
|
@@ -40301,35 +40530,7 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
40301
40530
|
const spinner2 = ora3.default(`Launching ${targetArg}...`).start();
|
|
40302
40531
|
try {
|
|
40303
40532
|
const { isDaemonRunning: isDaemonRunning2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
40304
|
-
if (isDaemonRunning2()) {
|
|
40305
|
-
const devServerPort = 19280;
|
|
40306
|
-
const body = JSON.stringify({
|
|
40307
|
-
type: cliType,
|
|
40308
|
-
workingDir: require("path").resolve(workingDir)
|
|
40309
|
-
});
|
|
40310
|
-
const res = await fetch(`http://127.0.0.1:${devServerPort}/api/cli/launch`, {
|
|
40311
|
-
method: "POST",
|
|
40312
|
-
headers: { "Content-Type": "application/json" },
|
|
40313
|
-
body
|
|
40314
|
-
});
|
|
40315
|
-
const result = await res.json();
|
|
40316
|
-
spinner2.stop();
|
|
40317
|
-
if (!result?.launched) {
|
|
40318
|
-
console.log(import_chalk4.default.red(`
|
|
40319
|
-
\u2717 ${result?.error || "Launch failed"}
|
|
40320
|
-
`));
|
|
40321
|
-
process.exit(1);
|
|
40322
|
-
}
|
|
40323
|
-
console.log();
|
|
40324
|
-
console.log(import_chalk4.default.bold(` \u{1F680} CLI Agent Launched
|
|
40325
|
-
`));
|
|
40326
|
-
console.log(` ${import_chalk4.default.bold("Agent:")} ${targetArg} (${cliType})`);
|
|
40327
|
-
console.log(` ${import_chalk4.default.bold("Dir:")} ${workingDir}`);
|
|
40328
|
-
console.log(` ${import_chalk4.default.bold("Mode:")} via running daemon`);
|
|
40329
|
-
console.log();
|
|
40330
|
-
console.log(import_chalk4.default.gray(" Open dashboard: https://adhf.dev/dashboard"));
|
|
40331
|
-
console.log();
|
|
40332
|
-
} else {
|
|
40533
|
+
if (!isDaemonRunning2()) {
|
|
40333
40534
|
spinner2.stop();
|
|
40334
40535
|
console.log(import_chalk4.default.yellow(`
|
|
40335
40536
|
\u26A0 Daemon not running. Start with 'adhdev daemon' first.
|
|
@@ -40337,14 +40538,35 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
40337
40538
|
console.log(import_chalk4.default.gray(" Then run: adhdev launch " + targetArg));
|
|
40338
40539
|
process.exit(1);
|
|
40339
40540
|
}
|
|
40541
|
+
const resolvedDir = require("path").resolve(workingDir);
|
|
40542
|
+
const result = await sendDaemonCommand("launch_cli", {
|
|
40543
|
+
cliType,
|
|
40544
|
+
dir: resolvedDir
|
|
40545
|
+
});
|
|
40546
|
+
spinner2.stop();
|
|
40547
|
+
if (!result?.success) {
|
|
40548
|
+
console.log(import_chalk4.default.red(`
|
|
40549
|
+
\u2717 ${result?.error || "Launch failed"}
|
|
40550
|
+
`));
|
|
40551
|
+
process.exit(1);
|
|
40552
|
+
}
|
|
40553
|
+
console.log();
|
|
40554
|
+
console.log(import_chalk4.default.bold(` \u{1F680} CLI Agent Launched
|
|
40555
|
+
`));
|
|
40556
|
+
console.log(` ${import_chalk4.default.bold("Agent:")} ${targetArg} (${cliType})`);
|
|
40557
|
+
console.log(` ${import_chalk4.default.bold("Dir:")} ${result?.dir || resolvedDir}`);
|
|
40558
|
+
console.log(` ${import_chalk4.default.bold("Mode:")} via running daemon`);
|
|
40559
|
+
if (result?.sessionId) {
|
|
40560
|
+
console.log(` ${import_chalk4.default.bold("Session:")} ${result.sessionId}`);
|
|
40561
|
+
}
|
|
40562
|
+
console.log();
|
|
40563
|
+
console.log(import_chalk4.default.gray(" Open dashboard: https://adhf.dev/dashboard"));
|
|
40564
|
+
console.log();
|
|
40340
40565
|
} catch (e) {
|
|
40341
40566
|
spinner2.stop();
|
|
40342
40567
|
console.log(import_chalk4.default.red(`
|
|
40343
40568
|
\u2717 Launch failed: ${e?.message || e}
|
|
40344
40569
|
`));
|
|
40345
|
-
if (e?.cause?.code === "ECONNREFUSED") {
|
|
40346
|
-
console.log(import_chalk4.default.gray(" Is the daemon running with --dev? (adhdev daemon --dev)"));
|
|
40347
|
-
}
|
|
40348
40570
|
process.exit(1);
|
|
40349
40571
|
}
|
|
40350
40572
|
return;
|
|
@@ -40436,6 +40658,8 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
40436
40658
|
});
|
|
40437
40659
|
program2.command("status").description("Show current ADHDev setup status").action(async () => {
|
|
40438
40660
|
const { loadConfig: loadConfig2, detectIDEs: detectIDEs2, detectCLIs: detectCLIs2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
40661
|
+
const { isDaemonRunning: isDaemonRunning2, getDaemonPid: getDaemonPid2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
40662
|
+
const { probeSessionHostStatus: probeSessionHostStatus2 } = await Promise.resolve().then(() => (init_session_host(), session_host_exports));
|
|
40439
40663
|
const config2 = loadConfig2();
|
|
40440
40664
|
const hasMachineSecret = Boolean(config2.machineSecret && config2.machineSecret.trim());
|
|
40441
40665
|
console.log(import_chalk4.default.bold("\n\u{1F9A6} ADHDev Status\n"));
|
|
@@ -40451,11 +40675,12 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
40451
40675
|
return;
|
|
40452
40676
|
}
|
|
40453
40677
|
const ideList = config2.configuredIdes?.length ? config2.configuredIdes : config2.selectedIde ? [config2.selectedIde] : [];
|
|
40678
|
+
const visibleIdeList = ideList.filter((ideId) => ideId !== "daemon");
|
|
40454
40679
|
console.log(` ${import_chalk4.default.bold("Status:")} ${import_chalk4.default.green("\u2713 Configured")}`);
|
|
40455
|
-
if (
|
|
40680
|
+
if (visibleIdeList.length > 0) {
|
|
40456
40681
|
const ides = await detectIDEs2();
|
|
40457
40682
|
console.log(` ${import_chalk4.default.bold("IDEs:")}`);
|
|
40458
|
-
for (const ideId of
|
|
40683
|
+
for (const ideId of visibleIdeList) {
|
|
40459
40684
|
const ide = ides.find((i) => i.id === ideId);
|
|
40460
40685
|
if (ide?.installed) {
|
|
40461
40686
|
const ver = ide.version ? import_chalk4.default.gray(` v${ide.version}`) : "";
|
|
@@ -40464,6 +40689,8 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
40464
40689
|
console.log(` ${import_chalk4.default.yellow("?")} ${ideId}`);
|
|
40465
40690
|
}
|
|
40466
40691
|
}
|
|
40692
|
+
} else {
|
|
40693
|
+
console.log(` ${import_chalk4.default.bold("IDEs:")} ${import_chalk4.default.gray("auto-detect at runtime")}`);
|
|
40467
40694
|
}
|
|
40468
40695
|
const clis = await detectCLIs2(providerLoader);
|
|
40469
40696
|
const installedClis = clis.filter((c) => c.installed);
|
|
@@ -40478,6 +40705,32 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
40478
40705
|
config2.installedExtensions.forEach((ext) => {
|
|
40479
40706
|
console.log(import_chalk4.default.gray(` \u2022 ${ext}`));
|
|
40480
40707
|
});
|
|
40708
|
+
const daemonRunning = isDaemonRunning2();
|
|
40709
|
+
console.log(` ${import_chalk4.default.bold("Daemon:")} ${daemonRunning ? import_chalk4.default.green(`running (PID ${getDaemonPid2() ?? "unknown"})`) : import_chalk4.default.gray("not running")}`);
|
|
40710
|
+
if (daemonRunning) {
|
|
40711
|
+
try {
|
|
40712
|
+
const controller = new AbortController();
|
|
40713
|
+
const timer = setTimeout(() => controller.abort(), 1500);
|
|
40714
|
+
const res = await fetch("http://127.0.0.1:19222/health", { signal: controller.signal });
|
|
40715
|
+
clearTimeout(timer);
|
|
40716
|
+
if (res.ok) {
|
|
40717
|
+
const data = await res.json();
|
|
40718
|
+
console.log(import_chalk4.default.gray(` Local IPC ${data.port}${data.wsPath}`));
|
|
40719
|
+
} else {
|
|
40720
|
+
console.log(import_chalk4.default.gray(" Local IPC unavailable"));
|
|
40721
|
+
}
|
|
40722
|
+
} catch {
|
|
40723
|
+
console.log(import_chalk4.default.gray(" Local IPC unavailable"));
|
|
40724
|
+
}
|
|
40725
|
+
}
|
|
40726
|
+
try {
|
|
40727
|
+
const sessionHost = await probeSessionHostStatus2();
|
|
40728
|
+
const sessionHostLabel = sessionHost.reachable ? `reachable (${sessionHost.runtimeCount} active runtime${sessionHost.runtimeCount === 1 ? "" : "s"})` : "not reachable";
|
|
40729
|
+
console.log(` ${import_chalk4.default.bold("Session Host:")} ${sessionHostLabel}`);
|
|
40730
|
+
console.log(import_chalk4.default.gray(` PID ${sessionHost.pid ?? "unknown"} \u2022 ${sessionHost.endpoint.path}`));
|
|
40731
|
+
} catch {
|
|
40732
|
+
console.log(` ${import_chalk4.default.bold("Session Host:")} ${import_chalk4.default.gray("status unavailable")}`);
|
|
40733
|
+
}
|
|
40481
40734
|
console.log(` ${import_chalk4.default.bold("User:")} ${config2.userEmail || import_chalk4.default.gray("not logged in")}`);
|
|
40482
40735
|
console.log(` ${import_chalk4.default.bold("Server:")} ${config2.serverUrl}`);
|
|
40483
40736
|
console.log(` ${import_chalk4.default.bold("Setup date:")} ${config2.setupDate || "unknown"}`);
|
|
@@ -40630,11 +40883,56 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
40630
40883
|
});
|
|
40631
40884
|
});
|
|
40632
40885
|
hideCommand(program2.command("daemon:status").description("Check ADHDev Daemon status").action(async () => {
|
|
40633
|
-
const { isDaemonRunning: isDaemonRunning2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
40886
|
+
const { isDaemonRunning: isDaemonRunning2, getDaemonPid: getDaemonPid2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
40887
|
+
const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
40888
|
+
const { probeSessionHostStatus: probeSessionHostStatus2 } = await Promise.resolve().then(() => (init_session_host(), session_host_exports));
|
|
40634
40889
|
if (isDaemonRunning2()) {
|
|
40635
40890
|
console.log(import_chalk5.default.green(`
|
|
40636
40891
|
\u2713 ADHDev Daemon is running.
|
|
40637
40892
|
`));
|
|
40893
|
+
console.log(import_chalk5.default.gray(` PID: ${getDaemonPid2() ?? "unknown"}`));
|
|
40894
|
+
console.log(import_chalk5.default.gray(` Logs: ${getCurrentDaemonLogPath2()}`));
|
|
40895
|
+
try {
|
|
40896
|
+
const controller = new AbortController();
|
|
40897
|
+
const timer = setTimeout(() => controller.abort(), 1500);
|
|
40898
|
+
const res = await fetch("http://127.0.0.1:19222/health", { signal: controller.signal });
|
|
40899
|
+
clearTimeout(timer);
|
|
40900
|
+
if (res.ok) {
|
|
40901
|
+
const data = await res.json();
|
|
40902
|
+
console.log(import_chalk5.default.gray(` Local IPC: reachable (ws://127.0.0.1:${data.port}${data.wsPath})`));
|
|
40903
|
+
} else {
|
|
40904
|
+
console.log(import_chalk5.default.gray(" Local IPC: not reachable"));
|
|
40905
|
+
}
|
|
40906
|
+
} catch {
|
|
40907
|
+
console.log(import_chalk5.default.gray(" Local IPC: not reachable"));
|
|
40908
|
+
}
|
|
40909
|
+
try {
|
|
40910
|
+
const sessionHost = await probeSessionHostStatus2();
|
|
40911
|
+
console.log(import_chalk5.default.gray(
|
|
40912
|
+
` SessionHost: ${sessionHost.reachable ? `reachable (${sessionHost.runtimeCount} active runtime${sessionHost.runtimeCount === 1 ? "" : "s"})` : "not reachable"}`
|
|
40913
|
+
));
|
|
40914
|
+
console.log(import_chalk5.default.gray(` Session IPC: ${sessionHost.endpoint.path}`));
|
|
40915
|
+
console.log(import_chalk5.default.gray(` Session PID: ${sessionHost.pid ?? "unknown"}`));
|
|
40916
|
+
} catch {
|
|
40917
|
+
console.log(import_chalk5.default.gray(" SessionHost: status unavailable"));
|
|
40918
|
+
}
|
|
40919
|
+
try {
|
|
40920
|
+
const controller = new AbortController();
|
|
40921
|
+
const timer = setTimeout(() => controller.abort(), 1500);
|
|
40922
|
+
const res = await fetch("http://127.0.0.1:19280/api/status", { signal: controller.signal });
|
|
40923
|
+
clearTimeout(timer);
|
|
40924
|
+
if (res.ok) {
|
|
40925
|
+
const data = await res.json();
|
|
40926
|
+
const cdpCount = data?.cdp ? Object.keys(data.cdp).length : 0;
|
|
40927
|
+
const providerCount = Array.isArray(data?.providers) ? data.providers.length : 0;
|
|
40928
|
+
console.log(import_chalk5.default.gray(` DevServer: reachable (${cdpCount} CDP, ${providerCount} providers)`));
|
|
40929
|
+
} else {
|
|
40930
|
+
console.log(import_chalk5.default.gray(" DevServer: not reachable"));
|
|
40931
|
+
}
|
|
40932
|
+
} catch {
|
|
40933
|
+
console.log(import_chalk5.default.gray(" DevServer: not reachable (run `adhdev daemon --dev` for local debug APIs)"));
|
|
40934
|
+
}
|
|
40935
|
+
console.log();
|
|
40638
40936
|
} else {
|
|
40639
40937
|
console.log(import_chalk5.default.gray(`
|
|
40640
40938
|
\u2717 ADHDev Daemon is not running.`));
|
|
@@ -40680,7 +40978,8 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
40680
40978
|
console.log(import_chalk5.default.green(` \u2713 ADHDev Daemon restarted (PID: ${child.pid})
|
|
40681
40979
|
`));
|
|
40682
40980
|
} else {
|
|
40683
|
-
|
|
40981
|
+
const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
40982
|
+
console.log(import_chalk5.default.red(` \u2717 Daemon failed to start. Check logs: ${getCurrentDaemonLogPath2()}
|
|
40684
40983
|
`));
|
|
40685
40984
|
process.exit(1);
|
|
40686
40985
|
}
|
|
@@ -40945,7 +41244,7 @@ function registerProviderCommands(program2) {
|
|
|
40945
41244
|
}
|
|
40946
41245
|
});
|
|
40947
41246
|
});
|
|
40948
|
-
req.on("error", () => reject(new Error("
|
|
41247
|
+
req.on("error", () => reject(new Error("Provider reload failed: neither daemon IPC nor DevServer is reachable. Start with `adhdev daemon` (or `adhdev daemon --dev` for provider dev APIs).")));
|
|
40949
41248
|
req.write("{}");
|
|
40950
41249
|
req.end();
|
|
40951
41250
|
});
|
|
@@ -41810,8 +42109,8 @@ function registerCdpCommands(program2) {
|
|
|
41810
42109
|
const mainPages = pages.filter((t) => !isNonMain(t.title || ""));
|
|
41811
42110
|
const target = (mainPages.length > 0 ? mainPages[0] : pages[0]) || targets[0];
|
|
41812
42111
|
if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target");
|
|
41813
|
-
const
|
|
41814
|
-
const ws = new
|
|
42112
|
+
const WebSocket4 = (await import("ws")).default;
|
|
42113
|
+
const ws = new WebSocket4(target.webSocketDebuggerUrl);
|
|
41815
42114
|
await new Promise((resolve13, reject) => {
|
|
41816
42115
|
ws.on("open", () => {
|
|
41817
42116
|
ws.send(JSON.stringify({ id: 1, method: "Page.captureScreenshot", params: { format: "jpeg", quality: 50 } }));
|
|
@@ -41882,7 +42181,7 @@ void (async () => {
|
|
|
41882
42181
|
console.log(import_chalk7.default.gray(" adhdev daemon \u2014 Start unified daemon (Required)"));
|
|
41883
42182
|
console.log(import_chalk7.default.gray(" adhdev standalone \u2014 Start standalone local dashboard & daemon"));
|
|
41884
42183
|
console.log(import_chalk7.default.gray(" adhdev launch cursor \u2014 Launch IDE with CDP (e.g. cursor, windsurf)"));
|
|
41885
|
-
console.log(import_chalk7.default.gray(" adhdev launch claude \u2014 Launch CLI agent
|
|
42184
|
+
console.log(import_chalk7.default.gray(" adhdev launch claude \u2014 Launch CLI agent via the running daemon"));
|
|
41886
42185
|
console.log(import_chalk7.default.gray(" adhdev status \u2014 Check current setup"));
|
|
41887
42186
|
console.log(import_chalk7.default.gray(" adhdev update \u2014 Upgrade to latest version"));
|
|
41888
42187
|
console.log();
|