adhdev 0.8.12 → 0.8.14
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 +711 -341
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +545 -331
- 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/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 os23 = (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[os23] || []);
|
|
580
580
|
const installed = !!(cliPath || appPath);
|
|
581
581
|
let resolvedCli = cliPath;
|
|
582
|
-
if (!resolvedCli && appPath &&
|
|
582
|
+
if (!resolvedCli && appPath && os23 === "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 && os23 === "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
|
}
|
|
@@ -5426,8 +5459,24 @@ var init_stream_commands = __esm({
|
|
|
5426
5459
|
});
|
|
5427
5460
|
|
|
5428
5461
|
// ../../oss/packages/daemon-core/src/commands/workspace-commands.ts
|
|
5462
|
+
function loadWorkspaceConfig() {
|
|
5463
|
+
try {
|
|
5464
|
+
return loadConfig();
|
|
5465
|
+
} catch (e) {
|
|
5466
|
+
return { error: `Could not load config: ${e?.message || "unknown error"}` };
|
|
5467
|
+
}
|
|
5468
|
+
}
|
|
5469
|
+
function persistWorkspaceConfig(config2) {
|
|
5470
|
+
try {
|
|
5471
|
+
saveConfig(config2);
|
|
5472
|
+
return { ok: true };
|
|
5473
|
+
} catch (e) {
|
|
5474
|
+
return { error: `Could not save config: ${e?.message || "unknown error"}` };
|
|
5475
|
+
}
|
|
5476
|
+
}
|
|
5429
5477
|
function handleWorkspaceList() {
|
|
5430
|
-
const config2 =
|
|
5478
|
+
const config2 = loadWorkspaceConfig();
|
|
5479
|
+
if ("error" in config2) return { success: false, error: config2.error };
|
|
5431
5480
|
const state = getWorkspaceState(config2);
|
|
5432
5481
|
return {
|
|
5433
5482
|
success: true,
|
|
@@ -5441,31 +5490,37 @@ function handleWorkspaceAdd(args) {
|
|
|
5441
5490
|
const label = (args?.label || "").trim() || void 0;
|
|
5442
5491
|
const createIfMissing = args?.createIfMissing === true;
|
|
5443
5492
|
if (!rawPath) return { success: false, error: "path required" };
|
|
5444
|
-
const config2 =
|
|
5493
|
+
const config2 = loadWorkspaceConfig();
|
|
5494
|
+
if ("error" in config2) return { success: false, error: config2.error };
|
|
5445
5495
|
const result = addWorkspaceEntry(config2, rawPath, label, { createIfMissing });
|
|
5446
5496
|
if ("error" in result) return { success: false, error: result.error };
|
|
5447
|
-
|
|
5497
|
+
const saveResult = persistWorkspaceConfig(result.config);
|
|
5498
|
+
if ("error" in saveResult) return { success: false, error: saveResult.error };
|
|
5448
5499
|
const state = getWorkspaceState(result.config);
|
|
5449
5500
|
return { success: true, entry: result.entry, ...state };
|
|
5450
5501
|
}
|
|
5451
5502
|
function handleWorkspaceRemove(args) {
|
|
5452
5503
|
const id = (args?.id || "").trim();
|
|
5453
5504
|
if (!id) return { success: false, error: "id required" };
|
|
5454
|
-
const config2 =
|
|
5505
|
+
const config2 = loadWorkspaceConfig();
|
|
5506
|
+
if ("error" in config2) return { success: false, error: config2.error };
|
|
5455
5507
|
const removed = (config2.workspaces || []).find((w) => w.id === id);
|
|
5456
5508
|
const result = removeWorkspaceEntry(config2, id);
|
|
5457
5509
|
if ("error" in result) return { success: false, error: result.error };
|
|
5458
|
-
|
|
5510
|
+
const saveResult = persistWorkspaceConfig(result.config);
|
|
5511
|
+
if ("error" in saveResult) return { success: false, error: saveResult.error };
|
|
5459
5512
|
const state = getWorkspaceState(result.config);
|
|
5460
5513
|
return { success: true, removedId: id, ...state };
|
|
5461
5514
|
}
|
|
5462
5515
|
function handleWorkspaceSetDefault(args) {
|
|
5463
5516
|
const clear = args?.clear === true || args?.id === null || args?.id === "";
|
|
5464
5517
|
if (clear) {
|
|
5465
|
-
const config3 =
|
|
5518
|
+
const config3 = loadWorkspaceConfig();
|
|
5519
|
+
if ("error" in config3) return { success: false, error: config3.error };
|
|
5466
5520
|
const result2 = setDefaultWorkspaceId(config3, null);
|
|
5467
5521
|
if ("error" in result2) return { success: false, error: result2.error };
|
|
5468
|
-
|
|
5522
|
+
const saveResult2 = persistWorkspaceConfig(result2.config);
|
|
5523
|
+
if ("error" in saveResult2) return { success: false, error: saveResult2.error };
|
|
5469
5524
|
const state2 = getWorkspaceState(result2.config);
|
|
5470
5525
|
return {
|
|
5471
5526
|
success: true,
|
|
@@ -5477,7 +5532,9 @@ function handleWorkspaceSetDefault(args) {
|
|
|
5477
5532
|
if (!pathArg && !idArg) {
|
|
5478
5533
|
return { success: false, error: "id or path required (or clear: true)" };
|
|
5479
5534
|
}
|
|
5480
|
-
|
|
5535
|
+
const configResult = loadWorkspaceConfig();
|
|
5536
|
+
if ("error" in configResult) return { success: false, error: configResult.error };
|
|
5537
|
+
let config2 = configResult;
|
|
5481
5538
|
let nextId;
|
|
5482
5539
|
if (pathArg) {
|
|
5483
5540
|
let w = findWorkspaceByPath(config2, pathArg);
|
|
@@ -5493,7 +5550,8 @@ function handleWorkspaceSetDefault(args) {
|
|
|
5493
5550
|
}
|
|
5494
5551
|
const result = setDefaultWorkspaceId(config2, nextId);
|
|
5495
5552
|
if ("error" in result) return { success: false, error: result.error };
|
|
5496
|
-
|
|
5553
|
+
const saveResult = persistWorkspaceConfig(result.config);
|
|
5554
|
+
if ("error" in saveResult) return { success: false, error: saveResult.error };
|
|
5497
5555
|
const state = getWorkspaceState(result.config);
|
|
5498
5556
|
return { success: true, ...state };
|
|
5499
5557
|
}
|
|
@@ -6196,6 +6254,13 @@ function logTerminalBackendSelection(preference, ghosttyAvailable, backendKind)
|
|
|
6196
6254
|
const key = `${preference}:${ghosttyAvailable}:${backendKind}`;
|
|
6197
6255
|
if (loggedTerminalBackends.has(key)) return;
|
|
6198
6256
|
loggedTerminalBackends.add(key);
|
|
6257
|
+
if (backendKind === "xterm" && preference !== "xterm" && !ghosttyAvailable) {
|
|
6258
|
+
LOG.warn(
|
|
6259
|
+
"Terminal",
|
|
6260
|
+
`[terminal-screen] ghostty-vt unavailable; using xterm fallback (preference=${preference})`
|
|
6261
|
+
);
|
|
6262
|
+
return;
|
|
6263
|
+
}
|
|
6199
6264
|
LOG.info(
|
|
6200
6265
|
"Terminal",
|
|
6201
6266
|
`[terminal-screen] backend=${backendKind} preference=${preference} ghosttyAvailable=${ghosttyAvailable}`
|
|
@@ -6258,10 +6323,11 @@ var init_terminal_screen = __esm({
|
|
|
6258
6323
|
});
|
|
6259
6324
|
|
|
6260
6325
|
// ../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts
|
|
6261
|
-
var pty, NodePtyRuntimeTransport, NodePtyTransportFactory;
|
|
6326
|
+
var os7, pty, NodePtyRuntimeTransport, NodePtyTransportFactory;
|
|
6262
6327
|
var init_pty_transport = __esm({
|
|
6263
6328
|
"../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts"() {
|
|
6264
6329
|
"use strict";
|
|
6330
|
+
os7 = __toESM(require("os"));
|
|
6265
6331
|
try {
|
|
6266
6332
|
pty = require("node-pty");
|
|
6267
6333
|
} catch {
|
|
@@ -6298,11 +6364,21 @@ var init_pty_transport = __esm({
|
|
|
6298
6364
|
NodePtyTransportFactory = class {
|
|
6299
6365
|
spawn(command, args, options) {
|
|
6300
6366
|
if (!pty) throw new Error("node-pty is not installed");
|
|
6367
|
+
let cwd = options.cwd;
|
|
6368
|
+
if (cwd) {
|
|
6369
|
+
try {
|
|
6370
|
+
const fs18 = require("fs");
|
|
6371
|
+
const stat4 = fs18.statSync(cwd);
|
|
6372
|
+
if (!stat4.isDirectory()) cwd = os7.homedir();
|
|
6373
|
+
} catch {
|
|
6374
|
+
cwd = os7.homedir();
|
|
6375
|
+
}
|
|
6376
|
+
}
|
|
6301
6377
|
const handle = pty.spawn(command, args, {
|
|
6302
6378
|
name: "xterm-256color",
|
|
6303
6379
|
cols: options.cols,
|
|
6304
6380
|
rows: options.rows,
|
|
6305
|
-
cwd
|
|
6381
|
+
cwd,
|
|
6306
6382
|
env: options.env
|
|
6307
6383
|
});
|
|
6308
6384
|
return new NodePtyRuntimeTransport(handle);
|
|
@@ -6311,33 +6387,39 @@ var init_pty_transport = __esm({
|
|
|
6311
6387
|
}
|
|
6312
6388
|
});
|
|
6313
6389
|
|
|
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";
|
|
6390
|
+
// ../../oss/packages/session-host-core/dist/index.mjs
|
|
6391
|
+
function getDefaultSessionHostEndpoint(appName = "adhdev") {
|
|
6335
6392
|
if (process.platform === "win32") {
|
|
6336
|
-
|
|
6337
|
-
|
|
6393
|
+
return {
|
|
6394
|
+
kind: "pipe",
|
|
6395
|
+
path: `\\\\.\\pipe\\${appName}-session-host`
|
|
6396
|
+
};
|
|
6338
6397
|
}
|
|
6398
|
+
return {
|
|
6399
|
+
kind: "unix",
|
|
6400
|
+
path: path22.join(os8.tmpdir(), `${appName}-session-host.sock`)
|
|
6401
|
+
};
|
|
6402
|
+
}
|
|
6403
|
+
function serializeEnvelope(envelope) {
|
|
6404
|
+
return `${JSON.stringify(envelope)}
|
|
6405
|
+
`;
|
|
6339
6406
|
}
|
|
6340
|
-
function
|
|
6407
|
+
function createLineParser(onEnvelope) {
|
|
6408
|
+
let buffer = "";
|
|
6409
|
+
return (chunk) => {
|
|
6410
|
+
buffer += chunk.toString();
|
|
6411
|
+
let newlineIndex = buffer.indexOf("\n");
|
|
6412
|
+
while (newlineIndex >= 0) {
|
|
6413
|
+
const rawLine = buffer.slice(0, newlineIndex).trim();
|
|
6414
|
+
buffer = buffer.slice(newlineIndex + 1);
|
|
6415
|
+
if (rawLine) {
|
|
6416
|
+
onEnvelope(JSON.parse(rawLine));
|
|
6417
|
+
}
|
|
6418
|
+
newlineIndex = buffer.indexOf("\n");
|
|
6419
|
+
}
|
|
6420
|
+
};
|
|
6421
|
+
}
|
|
6422
|
+
function sanitizeSpawnEnv(baseEnv, overrides) {
|
|
6341
6423
|
const env = {};
|
|
6342
6424
|
const source = { ...baseEnv, ...overrides || {} };
|
|
6343
6425
|
for (const [key, value] of Object.entries(source)) {
|
|
@@ -6349,9 +6431,185 @@ function buildCliSpawnEnv(baseEnv, overrides) {
|
|
|
6349
6431
|
delete env[key];
|
|
6350
6432
|
}
|
|
6351
6433
|
}
|
|
6352
|
-
|
|
6434
|
+
applyTerminalColorEnv(env);
|
|
6353
6435
|
return env;
|
|
6354
6436
|
}
|
|
6437
|
+
function applyTerminalColorEnv(env) {
|
|
6438
|
+
if (env.NO_COLOR) return;
|
|
6439
|
+
if (!env.TERM || env.TERM === "xterm-color") {
|
|
6440
|
+
env.TERM = "xterm-256color";
|
|
6441
|
+
}
|
|
6442
|
+
if (!env.COLORTERM) env.COLORTERM = "truecolor";
|
|
6443
|
+
if (process.platform === "win32") {
|
|
6444
|
+
if (!env.FORCE_COLOR) env.FORCE_COLOR = "1";
|
|
6445
|
+
if (!env.CLICOLOR) env.CLICOLOR = "1";
|
|
6446
|
+
}
|
|
6447
|
+
}
|
|
6448
|
+
function ensureNodePtySpawnHelperPermissions(logFn) {
|
|
6449
|
+
if (os22.platform() === "win32") return;
|
|
6450
|
+
try {
|
|
6451
|
+
const fs18 = __require("fs");
|
|
6452
|
+
const ptyDir = path32.resolve(path32.dirname(__require.resolve("node-pty")), "..");
|
|
6453
|
+
const platformArch = `${os22.platform()}-${os22.arch()}`;
|
|
6454
|
+
const helper = path32.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
6455
|
+
if (fs18.existsSync(helper)) {
|
|
6456
|
+
const stat4 = fs18.statSync(helper);
|
|
6457
|
+
if (!(stat4.mode & 73)) {
|
|
6458
|
+
fs18.chmodSync(helper, stat4.mode | 493);
|
|
6459
|
+
logFn?.(`Fixed spawn-helper permissions: ${helper}`);
|
|
6460
|
+
}
|
|
6461
|
+
}
|
|
6462
|
+
} catch {
|
|
6463
|
+
}
|
|
6464
|
+
}
|
|
6465
|
+
var os8, path22, net, import_crypto3, os22, path32, __require, SessionHostClient;
|
|
6466
|
+
var init_dist = __esm({
|
|
6467
|
+
"../../oss/packages/session-host-core/dist/index.mjs"() {
|
|
6468
|
+
"use strict";
|
|
6469
|
+
os8 = __toESM(require("os"), 1);
|
|
6470
|
+
path22 = __toESM(require("path"), 1);
|
|
6471
|
+
net = __toESM(require("net"), 1);
|
|
6472
|
+
import_crypto3 = require("crypto");
|
|
6473
|
+
os22 = __toESM(require("os"), 1);
|
|
6474
|
+
path32 = __toESM(require("path"), 1);
|
|
6475
|
+
__require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
6476
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
6477
|
+
}) : x)(function(x) {
|
|
6478
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6479
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6480
|
+
});
|
|
6481
|
+
SessionHostClient = class {
|
|
6482
|
+
endpoint;
|
|
6483
|
+
socket = null;
|
|
6484
|
+
requestWaiters = /* @__PURE__ */ new Map();
|
|
6485
|
+
eventListeners = /* @__PURE__ */ new Set();
|
|
6486
|
+
constructor(options = {}) {
|
|
6487
|
+
this.endpoint = options.endpoint || getDefaultSessionHostEndpoint(options.appName || "adhdev");
|
|
6488
|
+
}
|
|
6489
|
+
async connect() {
|
|
6490
|
+
if (this.socket && !this.socket.destroyed) return;
|
|
6491
|
+
if (this.socket) {
|
|
6492
|
+
try {
|
|
6493
|
+
this.socket.destroy();
|
|
6494
|
+
} catch {
|
|
6495
|
+
}
|
|
6496
|
+
this.socket = null;
|
|
6497
|
+
}
|
|
6498
|
+
const socket = net.createConnection(this.endpoint.path);
|
|
6499
|
+
this.socket = socket;
|
|
6500
|
+
socket.on("data", createLineParser((envelope) => {
|
|
6501
|
+
if (envelope.kind === "response") {
|
|
6502
|
+
const waiter = this.requestWaiters.get(envelope.requestId);
|
|
6503
|
+
if (waiter) {
|
|
6504
|
+
this.requestWaiters.delete(envelope.requestId);
|
|
6505
|
+
waiter.resolve(envelope.response);
|
|
6506
|
+
}
|
|
6507
|
+
return;
|
|
6508
|
+
}
|
|
6509
|
+
if (envelope.kind === "event") {
|
|
6510
|
+
for (const listener of this.eventListeners) listener(envelope.event);
|
|
6511
|
+
}
|
|
6512
|
+
}));
|
|
6513
|
+
socket.on("error", (error48) => {
|
|
6514
|
+
for (const waiter of this.requestWaiters.values()) {
|
|
6515
|
+
waiter.reject(error48);
|
|
6516
|
+
}
|
|
6517
|
+
this.requestWaiters.clear();
|
|
6518
|
+
if (this.socket === socket) {
|
|
6519
|
+
this.socket = null;
|
|
6520
|
+
}
|
|
6521
|
+
try {
|
|
6522
|
+
socket.destroy();
|
|
6523
|
+
} catch {
|
|
6524
|
+
}
|
|
6525
|
+
});
|
|
6526
|
+
await new Promise((resolve22, reject) => {
|
|
6527
|
+
socket.once("connect", () => resolve22());
|
|
6528
|
+
socket.once("error", reject);
|
|
6529
|
+
});
|
|
6530
|
+
}
|
|
6531
|
+
onEvent(listener) {
|
|
6532
|
+
this.eventListeners.add(listener);
|
|
6533
|
+
return () => {
|
|
6534
|
+
this.eventListeners.delete(listener);
|
|
6535
|
+
};
|
|
6536
|
+
}
|
|
6537
|
+
async request(request) {
|
|
6538
|
+
await this.connect();
|
|
6539
|
+
if (!this.socket) throw new Error("Session host socket unavailable");
|
|
6540
|
+
const requestId = (0, import_crypto3.randomUUID)();
|
|
6541
|
+
const envelope = {
|
|
6542
|
+
kind: "request",
|
|
6543
|
+
requestId,
|
|
6544
|
+
request
|
|
6545
|
+
};
|
|
6546
|
+
const response = await new Promise((resolve22, reject) => {
|
|
6547
|
+
const timeout = setTimeout(() => {
|
|
6548
|
+
this.requestWaiters.delete(requestId);
|
|
6549
|
+
reject(new Error(`Session host request timed out after 30s (${request.type})`));
|
|
6550
|
+
}, 3e4);
|
|
6551
|
+
this.requestWaiters.set(requestId, {
|
|
6552
|
+
resolve: (value) => {
|
|
6553
|
+
clearTimeout(timeout);
|
|
6554
|
+
resolve22(value);
|
|
6555
|
+
},
|
|
6556
|
+
reject: (error48) => {
|
|
6557
|
+
clearTimeout(timeout);
|
|
6558
|
+
reject(error48);
|
|
6559
|
+
}
|
|
6560
|
+
});
|
|
6561
|
+
this.socket?.write(serializeEnvelope(envelope));
|
|
6562
|
+
});
|
|
6563
|
+
return response;
|
|
6564
|
+
}
|
|
6565
|
+
async close() {
|
|
6566
|
+
if (!this.socket) return;
|
|
6567
|
+
const socket = this.socket;
|
|
6568
|
+
this.socket = null;
|
|
6569
|
+
for (const waiter of this.requestWaiters.values()) {
|
|
6570
|
+
waiter.reject(new Error("Session host client closed"));
|
|
6571
|
+
}
|
|
6572
|
+
this.requestWaiters.clear();
|
|
6573
|
+
await new Promise((resolve22) => {
|
|
6574
|
+
let settled = false;
|
|
6575
|
+
const done = () => {
|
|
6576
|
+
if (settled) return;
|
|
6577
|
+
settled = true;
|
|
6578
|
+
resolve22();
|
|
6579
|
+
};
|
|
6580
|
+
socket.once("close", done);
|
|
6581
|
+
socket.end();
|
|
6582
|
+
socket.destroy();
|
|
6583
|
+
setTimeout(done, 50);
|
|
6584
|
+
});
|
|
6585
|
+
}
|
|
6586
|
+
};
|
|
6587
|
+
}
|
|
6588
|
+
});
|
|
6589
|
+
|
|
6590
|
+
// ../../oss/packages/daemon-core/src/cli-adapters/spawn-env.ts
|
|
6591
|
+
var init_spawn_env = __esm({
|
|
6592
|
+
"../../oss/packages/daemon-core/src/cli-adapters/spawn-env.ts"() {
|
|
6593
|
+
"use strict";
|
|
6594
|
+
init_dist();
|
|
6595
|
+
}
|
|
6596
|
+
});
|
|
6597
|
+
|
|
6598
|
+
// ../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts
|
|
6599
|
+
var provider_cli_adapter_exports = {};
|
|
6600
|
+
__export(provider_cli_adapter_exports, {
|
|
6601
|
+
ProviderCliAdapter: () => ProviderCliAdapter,
|
|
6602
|
+
normalizeCliProviderForRuntime: () => normalizeCliProviderForRuntime
|
|
6603
|
+
});
|
|
6604
|
+
function stripAnsi(str) {
|
|
6605
|
+
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, " ");
|
|
6606
|
+
}
|
|
6607
|
+
function stripTerminalNoise(str) {
|
|
6608
|
+
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, " ");
|
|
6609
|
+
}
|
|
6610
|
+
function sanitizeTerminalText(str) {
|
|
6611
|
+
return stripTerminalNoise(stripAnsi(str));
|
|
6612
|
+
}
|
|
6355
6613
|
function computeTerminalQueryTail(buffer) {
|
|
6356
6614
|
const prefixes = ["\x1B[6n", "\x1B[?6n"];
|
|
6357
6615
|
const maxLength = prefixes.reduce((n, value) => Math.max(n, value.length), 0) - 1;
|
|
@@ -6365,7 +6623,7 @@ function computeTerminalQueryTail(buffer) {
|
|
|
6365
6623
|
return "";
|
|
6366
6624
|
}
|
|
6367
6625
|
function findBinary(name) {
|
|
6368
|
-
const isWin =
|
|
6626
|
+
const isWin = os9.platform() === "win32";
|
|
6369
6627
|
try {
|
|
6370
6628
|
const cmd = isWin ? `where ${name}` : `which ${name}`;
|
|
6371
6629
|
return (0, import_child_process4.execSync)(cmd, { encoding: "utf-8", timeout: 5e3, stdio: ["pipe", "pipe", "pipe"] }).trim().split("\n")[0].trim();
|
|
@@ -6413,7 +6671,7 @@ function looksLikeMachOOrElf(filePath) {
|
|
|
6413
6671
|
}
|
|
6414
6672
|
function shSingleQuote(arg) {
|
|
6415
6673
|
if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
|
|
6416
|
-
if (
|
|
6674
|
+
if (os9.platform() === "win32") {
|
|
6417
6675
|
return `"${arg.replace(/"/g, '""')}"`;
|
|
6418
6676
|
}
|
|
6419
6677
|
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
@@ -6480,37 +6738,24 @@ function normalizeCliProviderForRuntime(raw) {
|
|
|
6480
6738
|
}
|
|
6481
6739
|
};
|
|
6482
6740
|
}
|
|
6483
|
-
var
|
|
6741
|
+
var os9, path7, import_child_process4, pty2, buildCliSpawnEnv, ProviderCliAdapter;
|
|
6484
6742
|
var init_provider_cli_adapter = __esm({
|
|
6485
6743
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
|
|
6486
6744
|
"use strict";
|
|
6487
|
-
|
|
6745
|
+
os9 = __toESM(require("os"));
|
|
6488
6746
|
path7 = __toESM(require("path"));
|
|
6489
6747
|
import_child_process4 = require("child_process");
|
|
6490
6748
|
init_logger();
|
|
6491
6749
|
init_terminal_screen();
|
|
6492
6750
|
init_pty_transport();
|
|
6751
|
+
init_spawn_env();
|
|
6493
6752
|
try {
|
|
6494
6753
|
pty2 = require("node-pty");
|
|
6495
|
-
|
|
6496
|
-
try {
|
|
6497
|
-
const fs18 = 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 (fs18.existsSync(helper)) {
|
|
6502
|
-
const stat4 = fs18.statSync(helper);
|
|
6503
|
-
if (!(stat4.mode & 73)) {
|
|
6504
|
-
fs18.chmodSync(helper, stat4.mode | 493);
|
|
6505
|
-
LOG.info("CLI", "[node-pty] Fixed spawn-helper permissions");
|
|
6506
|
-
}
|
|
6507
|
-
}
|
|
6508
|
-
} catch {
|
|
6509
|
-
}
|
|
6510
|
-
}
|
|
6754
|
+
ensureNodePtySpawnHelperPermissions((msg) => LOG.info("CLI", msg));
|
|
6511
6755
|
} catch {
|
|
6512
6756
|
LOG.error("CLI", "[ProviderCliAdapter] node-pty not found. Terminal features disabled.");
|
|
6513
6757
|
}
|
|
6758
|
+
buildCliSpawnEnv = sanitizeSpawnEnv;
|
|
6514
6759
|
ProviderCliAdapter = class _ProviderCliAdapter {
|
|
6515
6760
|
constructor(provider, workingDir, extraArgs = [], transportFactory = new NodePtyTransportFactory()) {
|
|
6516
6761
|
this.extraArgs = extraArgs;
|
|
@@ -6518,7 +6763,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
6518
6763
|
this.transportFactory = transportFactory;
|
|
6519
6764
|
this.cliType = provider.type;
|
|
6520
6765
|
this.cliName = provider.name;
|
|
6521
|
-
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/,
|
|
6766
|
+
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os9.homedir()) : workingDir;
|
|
6522
6767
|
const t = provider.timeouts || {};
|
|
6523
6768
|
this.timeouts = {
|
|
6524
6769
|
ptyFlush: t.ptyFlush ?? 50,
|
|
@@ -6825,7 +7070,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
6825
7070
|
if (this.ptyProcess) return;
|
|
6826
7071
|
const { spawn: spawnConfig } = this.provider;
|
|
6827
7072
|
const binaryPath = findBinary(spawnConfig.command);
|
|
6828
|
-
const isWin =
|
|
7073
|
+
const isWin = os9.platform() === "win32";
|
|
6829
7074
|
const allArgs = [...spawnConfig.args, ...this.extraArgs];
|
|
6830
7075
|
LOG.info("CLI", `[${this.cliType}] Spawning in ${this.workingDir}`);
|
|
6831
7076
|
this.resetTraceSession();
|
|
@@ -6833,13 +7078,16 @@ var init_provider_cli_adapter = __esm({
|
|
|
6833
7078
|
let shellArgs;
|
|
6834
7079
|
const useShellUnix = !isWin && (!!spawnConfig.shell || !path7.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
6835
7080
|
const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
|
|
6836
|
-
const
|
|
7081
|
+
const useShellWin = isCmdShim || !path7.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
|
|
7082
|
+
const useShell = isWin ? useShellWin : useShellUnix;
|
|
6837
7083
|
if (useShell) {
|
|
6838
7084
|
if (!spawnConfig.shell && !isWin) {
|
|
6839
7085
|
LOG.info("CLI", `[${this.cliType}] Using login shell (script shim or non-native binary)`);
|
|
6840
7086
|
}
|
|
6841
7087
|
if (isCmdShim) {
|
|
6842
7088
|
LOG.info("CLI", `[${this.cliType}] Using cmd.exe shell for .cmd/.bat shim: ${binaryPath}`);
|
|
7089
|
+
} else if (isWin) {
|
|
7090
|
+
LOG.info("CLI", `[${this.cliType}] Using cmd.exe shell on Windows: ${binaryPath}`);
|
|
6843
7091
|
}
|
|
6844
7092
|
shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
|
|
6845
7093
|
if (isWin) {
|
|
@@ -6849,6 +7097,9 @@ var init_provider_cli_adapter = __esm({
|
|
|
6849
7097
|
shellArgs = ["-l", "-c", fullCmd];
|
|
6850
7098
|
}
|
|
6851
7099
|
} else {
|
|
7100
|
+
if (isWin && spawnConfig.shell) {
|
|
7101
|
+
LOG.info("CLI", `[${this.cliType}] Spawning Windows binary directly without cmd.exe: ${binaryPath}`);
|
|
7102
|
+
}
|
|
6852
7103
|
shellCmd = binaryPath;
|
|
6853
7104
|
shellArgs = allArgs;
|
|
6854
7105
|
}
|
|
@@ -6877,6 +7128,12 @@ var init_provider_cli_adapter = __esm({
|
|
|
6877
7128
|
shellArgs = ["-l", "-c", fullCmd];
|
|
6878
7129
|
this.ptyProcess = this.transportFactory.spawn(shellCmd, shellArgs, ptyOpts);
|
|
6879
7130
|
} else {
|
|
7131
|
+
if (isWin) {
|
|
7132
|
+
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})` : "";
|
|
7133
|
+
if (hint) {
|
|
7134
|
+
throw new Error(`Failed to spawn CLI${hint}: ${msg}`);
|
|
7135
|
+
}
|
|
7136
|
+
}
|
|
6880
7137
|
throw err;
|
|
6881
7138
|
}
|
|
6882
7139
|
}
|
|
@@ -7629,7 +7886,8 @@ ${data.message || ""}`.trim();
|
|
|
7629
7886
|
const payload = stopCommand.endsWith("\r") || stopCommand.endsWith("\n") ? stopCommand : `${stopCommand}${this.sendKey}`;
|
|
7630
7887
|
this.ptyProcess.write(payload);
|
|
7631
7888
|
};
|
|
7632
|
-
|
|
7889
|
+
const interruptGraceMs = typeof resume.interruptGraceMs === "number" ? Math.max(100, resume.interruptGraceMs) : 500;
|
|
7890
|
+
if (wasProcessing) setTimeout(writeCommand, interruptGraceMs);
|
|
7633
7891
|
else writeCommand();
|
|
7634
7892
|
} else {
|
|
7635
7893
|
this.ptyProcess.write("");
|
|
@@ -7674,6 +7932,18 @@ ${data.message || ""}`.trim();
|
|
|
7674
7932
|
clearTimeout(this.submitRetryTimer);
|
|
7675
7933
|
this.submitRetryTimer = null;
|
|
7676
7934
|
}
|
|
7935
|
+
if (this.responseTimeout) {
|
|
7936
|
+
clearTimeout(this.responseTimeout);
|
|
7937
|
+
this.responseTimeout = null;
|
|
7938
|
+
}
|
|
7939
|
+
if (this.idleTimeout) {
|
|
7940
|
+
clearTimeout(this.idleTimeout);
|
|
7941
|
+
this.idleTimeout = null;
|
|
7942
|
+
}
|
|
7943
|
+
if (this.pendingScriptStatusTimer) {
|
|
7944
|
+
clearTimeout(this.pendingScriptStatusTimer);
|
|
7945
|
+
this.pendingScriptStatusTimer = null;
|
|
7946
|
+
}
|
|
7677
7947
|
if (this.pendingOutputParseTimer) {
|
|
7678
7948
|
clearTimeout(this.pendingOutputParseTimer);
|
|
7679
7949
|
this.pendingOutputParseTimer = null;
|
|
@@ -7715,6 +7985,18 @@ ${data.message || ""}`.trim();
|
|
|
7715
7985
|
clearTimeout(this.submitRetryTimer);
|
|
7716
7986
|
this.submitRetryTimer = null;
|
|
7717
7987
|
}
|
|
7988
|
+
if (this.responseTimeout) {
|
|
7989
|
+
clearTimeout(this.responseTimeout);
|
|
7990
|
+
this.responseTimeout = null;
|
|
7991
|
+
}
|
|
7992
|
+
if (this.idleTimeout) {
|
|
7993
|
+
clearTimeout(this.idleTimeout);
|
|
7994
|
+
this.idleTimeout = null;
|
|
7995
|
+
}
|
|
7996
|
+
if (this.pendingScriptStatusTimer) {
|
|
7997
|
+
clearTimeout(this.pendingScriptStatusTimer);
|
|
7998
|
+
this.pendingScriptStatusTimer = null;
|
|
7999
|
+
}
|
|
7718
8000
|
if (this.pendingOutputParseTimer) {
|
|
7719
8001
|
clearTimeout(this.pendingOutputParseTimer);
|
|
7720
8002
|
this.pendingOutputParseTimer = null;
|
|
@@ -7909,11 +8191,11 @@ function getDatabaseSync() {
|
|
|
7909
8191
|
}
|
|
7910
8192
|
return CachedDatabaseSync;
|
|
7911
8193
|
}
|
|
7912
|
-
var
|
|
8194
|
+
var os10, path8, crypto3, fs5, import_node_module, CachedDatabaseSync, CliProviderInstance;
|
|
7913
8195
|
var init_cli_provider_instance = __esm({
|
|
7914
8196
|
"../../oss/packages/daemon-core/src/providers/cli-provider-instance.ts"() {
|
|
7915
8197
|
"use strict";
|
|
7916
|
-
|
|
8198
|
+
os10 = __toESM(require("os"));
|
|
7917
8199
|
path8 = __toESM(require("path"));
|
|
7918
8200
|
crypto3 = __toESM(require("crypto"));
|
|
7919
8201
|
fs5 = __toESM(require("fs"));
|
|
@@ -7994,17 +8276,60 @@ var init_cli_provider_instance = __esm({
|
|
|
7994
8276
|
async onTick() {
|
|
7995
8277
|
if (this.providerSessionId) return;
|
|
7996
8278
|
let probedSessionId = null;
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8279
|
+
const probeConfig = this.provider.sessionProbe;
|
|
8280
|
+
if (probeConfig) {
|
|
8281
|
+
probedSessionId = this.probeSessionIdFromConfig(probeConfig);
|
|
8282
|
+
} else {
|
|
8283
|
+
if (this.type === "opencode-cli") {
|
|
8284
|
+
probedSessionId = this.probeSessionIdFromConfig({
|
|
8285
|
+
dbPath: "~/.local/share/opencode/opencode.db",
|
|
8286
|
+
query: "select id from session where directory in ({dirs}) and time_created >= ? and time_archived is null order by time_updated desc limit 1",
|
|
8287
|
+
timestampFormat: "unix_ms"
|
|
8288
|
+
});
|
|
8289
|
+
} else if (this.type === "codex-cli") {
|
|
8290
|
+
probedSessionId = this.probeSessionIdFromConfig({
|
|
8291
|
+
dbPath: "~/.codex/state_5.sqlite",
|
|
8292
|
+
query: "select id from threads where cwd in ({dirs}) and created_at >= ? and archived = 0 order by created_at desc limit 1",
|
|
8293
|
+
timestampFormat: "unix_s"
|
|
8294
|
+
});
|
|
8295
|
+
} else if (this.type === "goose-cli") {
|
|
8296
|
+
probedSessionId = this.probeSessionIdFromConfig({
|
|
8297
|
+
dbPath: "~/.local/share/goose/sessions/sessions.db",
|
|
8298
|
+
query: "select id from sessions where working_dir in ({dirs}) and created_at >= ? order by updated_at desc limit 1",
|
|
8299
|
+
timestampFormat: "iso"
|
|
8300
|
+
});
|
|
8301
|
+
}
|
|
8003
8302
|
}
|
|
8004
8303
|
if (probedSessionId) {
|
|
8005
8304
|
this.promoteProviderSessionId(probedSessionId);
|
|
8006
8305
|
}
|
|
8007
8306
|
}
|
|
8307
|
+
/**
|
|
8308
|
+
* Generic session ID probe using declarative ProviderSessionProbe config.
|
|
8309
|
+
* Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
|
|
8310
|
+
*/
|
|
8311
|
+
probeSessionIdFromConfig(probe) {
|
|
8312
|
+
const resolvedDbPath = probe.dbPath.replace(/^~/, os10.homedir());
|
|
8313
|
+
if (!fs5.existsSync(resolvedDbPath)) return null;
|
|
8314
|
+
const directories = this.getProbeDirectories();
|
|
8315
|
+
const minCreatedAt = Math.max(0, this.startedAt - 6e4);
|
|
8316
|
+
const tsFormat = probe.timestampFormat || "unix_ms";
|
|
8317
|
+
let timestampParam;
|
|
8318
|
+
if (tsFormat === "unix_s") {
|
|
8319
|
+
timestampParam = Math.floor(minCreatedAt / 1e3);
|
|
8320
|
+
} else if (tsFormat === "iso") {
|
|
8321
|
+
timestampParam = new Date(minCreatedAt).toISOString().slice(0, 19).replace("T", " ");
|
|
8322
|
+
} else {
|
|
8323
|
+
timestampParam = minCreatedAt;
|
|
8324
|
+
}
|
|
8325
|
+
const placeholders = this.buildSqlPlaceholderList(directories.length);
|
|
8326
|
+
const query = probe.query.replace("{dirs}", placeholders);
|
|
8327
|
+
try {
|
|
8328
|
+
return this.querySqliteText(resolvedDbPath, query, [...directories, timestampParam]);
|
|
8329
|
+
} catch {
|
|
8330
|
+
return null;
|
|
8331
|
+
}
|
|
8332
|
+
}
|
|
8008
8333
|
getState() {
|
|
8009
8334
|
const adapterStatus = this.adapter.getStatus();
|
|
8010
8335
|
const parsedStatus = this.adapter.getScriptParsedStatus?.() || null;
|
|
@@ -8302,34 +8627,6 @@ var init_cli_provider_instance = __esm({
|
|
|
8302
8627
|
});
|
|
8303
8628
|
LOG.info("CLI", `[${this.type}] discovered provider session id: ${nextSessionId}`);
|
|
8304
8629
|
}
|
|
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
8630
|
getProbeDirectories() {
|
|
8334
8631
|
const dirs = /* @__PURE__ */ new Set();
|
|
8335
8632
|
const addDir = (value) => {
|
|
@@ -25688,11 +25985,11 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
|
|
|
25688
25985
|
launchMode: "new"
|
|
25689
25986
|
};
|
|
25690
25987
|
}
|
|
25691
|
-
var
|
|
25988
|
+
var os11, path9, crypto4, import_chalk, chalkApi, DaemonCliManager;
|
|
25692
25989
|
var init_cli_manager = __esm({
|
|
25693
25990
|
"../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
|
|
25694
25991
|
"use strict";
|
|
25695
|
-
|
|
25992
|
+
os11 = __toESM(require("os"));
|
|
25696
25993
|
path9 = __toESM(require("path"));
|
|
25697
25994
|
crypto4 = __toESM(require("crypto"));
|
|
25698
25995
|
import_chalk = __toESM(require("chalk"));
|
|
@@ -25844,7 +26141,7 @@ var init_cli_manager = __esm({
|
|
|
25844
26141
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
25845
26142
|
const trimmed = (workingDir || "").trim();
|
|
25846
26143
|
if (!trimmed) throw new Error("working directory required");
|
|
25847
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/,
|
|
26144
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os11.homedir()) : path9.resolve(trimmed);
|
|
25848
26145
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
25849
26146
|
const provider = this.providerLoader.getByAlias(cliType);
|
|
25850
26147
|
const key = crypto4.randomUUID();
|
|
@@ -25928,7 +26225,19 @@ ${installInfo}`
|
|
|
25928
26225
|
return { runtimeSessionId: sessionId };
|
|
25929
26226
|
}
|
|
25930
26227
|
const cliInfo = await detectCLI(cliType, this.providerLoader);
|
|
25931
|
-
if (!cliInfo)
|
|
26228
|
+
if (!cliInfo) {
|
|
26229
|
+
const installHint = provider?.install || "";
|
|
26230
|
+
const displayName = provider?.displayName || provider?.name || cliType;
|
|
26231
|
+
const spawnCmd = provider?.spawn?.command || cliType;
|
|
26232
|
+
throw new Error(
|
|
26233
|
+
`${displayName} is not installed.
|
|
26234
|
+
Command '${spawnCmd}' not found on PATH.
|
|
26235
|
+
` + (installHint ? `
|
|
26236
|
+
${installHint}
|
|
26237
|
+
` : "") + `
|
|
26238
|
+
Run 'adhdev doctor' for detailed diagnostics.`
|
|
26239
|
+
);
|
|
26240
|
+
}
|
|
25932
26241
|
console.log(colorize("yellow", ` \u26A1 Starting CLI ${cliType} in ${resolvedDir}...`));
|
|
25933
26242
|
if (provider) {
|
|
25934
26243
|
console.log(colorize("cyan", ` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
|
|
@@ -26244,8 +26553,9 @@ ${installInfo}`
|
|
|
26244
26553
|
const dir = rdir.path;
|
|
26245
26554
|
if (!cliType) throw new Error("cliType required");
|
|
26246
26555
|
const found = this.findAdapter(cliType, { instanceKey: args?.targetSessionId, dir });
|
|
26556
|
+
const prevCliArgs = found ? found.adapter.extraArgs : void 0;
|
|
26247
26557
|
if (found) await this.stopSession(found.key);
|
|
26248
|
-
await this.startSession(cliType, dir);
|
|
26558
|
+
await this.startSession(cliType, dir, args?.cliArgs || prevCliArgs, args?.initialModel);
|
|
26249
26559
|
return { success: true, restarted: true };
|
|
26250
26560
|
}
|
|
26251
26561
|
case "agent_command": {
|
|
@@ -28029,13 +28339,13 @@ var init_chokidar = __esm({
|
|
|
28029
28339
|
});
|
|
28030
28340
|
|
|
28031
28341
|
// ../../oss/packages/daemon-core/src/providers/provider-loader.ts
|
|
28032
|
-
var fs6, path10,
|
|
28342
|
+
var fs6, path10, os12, ProviderLoader;
|
|
28033
28343
|
var init_provider_loader = __esm({
|
|
28034
28344
|
"../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
|
|
28035
28345
|
"use strict";
|
|
28036
28346
|
fs6 = __toESM(require("fs"));
|
|
28037
28347
|
path10 = __toESM(require("path"));
|
|
28038
|
-
|
|
28348
|
+
os12 = __toESM(require("os"));
|
|
28039
28349
|
init_chokidar();
|
|
28040
28350
|
init_ide_detector();
|
|
28041
28351
|
init_logger();
|
|
@@ -28056,7 +28366,7 @@ var init_provider_loader = __esm({
|
|
|
28056
28366
|
static META_FILE = ".meta.json";
|
|
28057
28367
|
constructor(options) {
|
|
28058
28368
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
28059
|
-
const defaultProvidersDir = path10.join(
|
|
28369
|
+
const defaultProvidersDir = path10.join(os12.homedir(), ".adhdev", "providers");
|
|
28060
28370
|
if (options?.userDir) {
|
|
28061
28371
|
this.userDir = options.userDir;
|
|
28062
28372
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
@@ -28656,8 +28966,8 @@ var init_provider_loader = __esm({
|
|
|
28656
28966
|
return { updated: false };
|
|
28657
28967
|
}
|
|
28658
28968
|
this.log("Downloading latest providers from GitHub...");
|
|
28659
|
-
const tmpTar = path10.join(
|
|
28660
|
-
const tmpExtract = path10.join(
|
|
28969
|
+
const tmpTar = path10.join(os12.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
28970
|
+
const tmpExtract = path10.join(os12.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
28661
28971
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
28662
28972
|
fs6.mkdirSync(tmpExtract, { recursive: true });
|
|
28663
28973
|
execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
@@ -29091,7 +29401,7 @@ async function findFreePort(ports) {
|
|
|
29091
29401
|
}
|
|
29092
29402
|
function checkPortFree(port) {
|
|
29093
29403
|
return new Promise((resolve13) => {
|
|
29094
|
-
const server =
|
|
29404
|
+
const server = net2.createServer();
|
|
29095
29405
|
server.unref();
|
|
29096
29406
|
server.on("error", () => resolve13(false));
|
|
29097
29407
|
server.listen(port, "127.0.0.1", () => {
|
|
@@ -29123,7 +29433,7 @@ async function isCdpActive(port) {
|
|
|
29123
29433
|
});
|
|
29124
29434
|
}
|
|
29125
29435
|
async function killIdeProcess(ideId) {
|
|
29126
|
-
const plat =
|
|
29436
|
+
const plat = os13.platform();
|
|
29127
29437
|
const appName = getMacAppIdentifiers()[ideId];
|
|
29128
29438
|
const winProcesses = getWinProcessNames()[ideId];
|
|
29129
29439
|
try {
|
|
@@ -29182,7 +29492,7 @@ async function killIdeProcess(ideId) {
|
|
|
29182
29492
|
}
|
|
29183
29493
|
}
|
|
29184
29494
|
function isIdeRunning(ideId) {
|
|
29185
|
-
const plat =
|
|
29495
|
+
const plat = os13.platform();
|
|
29186
29496
|
try {
|
|
29187
29497
|
if (plat === "darwin") {
|
|
29188
29498
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -29218,7 +29528,7 @@ function isIdeRunning(ideId) {
|
|
|
29218
29528
|
}
|
|
29219
29529
|
}
|
|
29220
29530
|
function detectCurrentWorkspace(ideId) {
|
|
29221
|
-
const plat =
|
|
29531
|
+
const plat = os13.platform();
|
|
29222
29532
|
if (plat === "darwin") {
|
|
29223
29533
|
try {
|
|
29224
29534
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -29238,7 +29548,7 @@ function detectCurrentWorkspace(ideId) {
|
|
|
29238
29548
|
const appName = appNameMap[ideId];
|
|
29239
29549
|
if (appName) {
|
|
29240
29550
|
const storagePath = path11.join(
|
|
29241
|
-
process.env.APPDATA || path11.join(
|
|
29551
|
+
process.env.APPDATA || path11.join(os13.homedir(), "AppData", "Roaming"),
|
|
29242
29552
|
appName,
|
|
29243
29553
|
"storage.json"
|
|
29244
29554
|
);
|
|
@@ -29260,7 +29570,7 @@ function detectCurrentWorkspace(ideId) {
|
|
|
29260
29570
|
return void 0;
|
|
29261
29571
|
}
|
|
29262
29572
|
async function launchWithCdp(options = {}) {
|
|
29263
|
-
const
|
|
29573
|
+
const platform11 = os13.platform();
|
|
29264
29574
|
let targetIde;
|
|
29265
29575
|
const ides = await detectIDEs();
|
|
29266
29576
|
if (options.ideId) {
|
|
@@ -29329,9 +29639,9 @@ async function launchWithCdp(options = {}) {
|
|
|
29329
29639
|
}
|
|
29330
29640
|
const port = await findFreePort(portPair);
|
|
29331
29641
|
try {
|
|
29332
|
-
if (
|
|
29642
|
+
if (platform11 === "darwin") {
|
|
29333
29643
|
await launchMacOS(targetIde, port, workspace, options.newWindow);
|
|
29334
|
-
} else if (
|
|
29644
|
+
} else if (platform11 === "win32") {
|
|
29335
29645
|
await launchWindows(targetIde, port, workspace, options.newWindow);
|
|
29336
29646
|
} else {
|
|
29337
29647
|
await launchLinux(targetIde, port, workspace, options.newWindow);
|
|
@@ -29404,13 +29714,13 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
29404
29714
|
function getAvailableIdeIds() {
|
|
29405
29715
|
return getProviderLoader().getAvailableIdeTypes();
|
|
29406
29716
|
}
|
|
29407
|
-
var import_child_process6,
|
|
29717
|
+
var import_child_process6, net2, os13, path11, _providerLoader;
|
|
29408
29718
|
var init_launch = __esm({
|
|
29409
29719
|
"../../oss/packages/daemon-core/src/launch.ts"() {
|
|
29410
29720
|
"use strict";
|
|
29411
29721
|
import_child_process6 = require("child_process");
|
|
29412
|
-
|
|
29413
|
-
|
|
29722
|
+
net2 = __toESM(require("net"));
|
|
29723
|
+
os13 = __toESM(require("os"));
|
|
29414
29724
|
path11 = __toESM(require("path"));
|
|
29415
29725
|
init_ide_detector();
|
|
29416
29726
|
init_provider_loader();
|
|
@@ -29523,14 +29833,14 @@ function getRecentCommands(count = 50) {
|
|
|
29523
29833
|
return [];
|
|
29524
29834
|
}
|
|
29525
29835
|
}
|
|
29526
|
-
var fs7, path12,
|
|
29836
|
+
var fs7, path12, os14, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
|
|
29527
29837
|
var init_command_log = __esm({
|
|
29528
29838
|
"../../oss/packages/daemon-core/src/logging/command-log.ts"() {
|
|
29529
29839
|
"use strict";
|
|
29530
29840
|
fs7 = __toESM(require("fs"));
|
|
29531
29841
|
path12 = __toESM(require("path"));
|
|
29532
|
-
|
|
29533
|
-
LOG_DIR2 = process.platform === "win32" ? path12.join(process.env.LOCALAPPDATA || process.env.APPDATA || path12.join(
|
|
29842
|
+
os14 = __toESM(require("os"));
|
|
29843
|
+
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
29844
|
MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
29535
29845
|
MAX_DAYS = 7;
|
|
29536
29846
|
try {
|
|
@@ -29671,16 +29981,16 @@ function buildStatusSnapshot(options) {
|
|
|
29671
29981
|
version: options.version,
|
|
29672
29982
|
daemonMode: options.daemonMode,
|
|
29673
29983
|
machine: {
|
|
29674
|
-
hostname:
|
|
29675
|
-
platform:
|
|
29676
|
-
arch:
|
|
29677
|
-
cpus:
|
|
29984
|
+
hostname: os15.hostname(),
|
|
29985
|
+
platform: os15.platform(),
|
|
29986
|
+
arch: os15.arch(),
|
|
29987
|
+
cpus: os15.cpus().length,
|
|
29678
29988
|
totalMem: memSnap.totalMem,
|
|
29679
29989
|
freeMem: memSnap.freeMem,
|
|
29680
29990
|
availableMem: memSnap.availableMem,
|
|
29681
|
-
loadavg:
|
|
29682
|
-
uptime:
|
|
29683
|
-
release:
|
|
29991
|
+
loadavg: os15.loadavg(),
|
|
29992
|
+
uptime: os15.uptime(),
|
|
29993
|
+
release: os15.release()
|
|
29684
29994
|
},
|
|
29685
29995
|
machineNickname: options.machineNickname ?? cfg.machineNickname ?? null,
|
|
29686
29996
|
timestamp: options.timestamp ?? Date.now(),
|
|
@@ -29695,11 +30005,11 @@ function buildStatusSnapshot(options) {
|
|
|
29695
30005
|
availableProviders: buildAvailableProviders(options.providerLoader)
|
|
29696
30006
|
};
|
|
29697
30007
|
}
|
|
29698
|
-
var
|
|
30008
|
+
var os15, READ_DEBUG_ENABLED;
|
|
29699
30009
|
var init_snapshot = __esm({
|
|
29700
30010
|
"../../oss/packages/daemon-core/src/status/snapshot.ts"() {
|
|
29701
30011
|
"use strict";
|
|
29702
|
-
|
|
30012
|
+
os15 = __toESM(require("os"));
|
|
29703
30013
|
init_config();
|
|
29704
30014
|
init_recent_activity();
|
|
29705
30015
|
init_workspaces();
|
|
@@ -29713,7 +30023,7 @@ var init_snapshot = __esm({
|
|
|
29713
30023
|
|
|
29714
30024
|
// ../../oss/packages/daemon-core/src/commands/upgrade-helper.ts
|
|
29715
30025
|
function getUpgradeLogPath() {
|
|
29716
|
-
const home =
|
|
30026
|
+
const home = os16.homedir();
|
|
29717
30027
|
const dir = path13.join(home, ".adhdev");
|
|
29718
30028
|
fs8.mkdirSync(dir, { recursive: true });
|
|
29719
30029
|
return path13.join(dir, "daemon-upgrade.log");
|
|
@@ -29753,7 +30063,7 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
29753
30063
|
}
|
|
29754
30064
|
}
|
|
29755
30065
|
function stopSessionHostProcesses(appName) {
|
|
29756
|
-
const pidFile = path13.join(
|
|
30066
|
+
const pidFile = path13.join(os16.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
29757
30067
|
try {
|
|
29758
30068
|
if (fs8.existsSync(pidFile)) {
|
|
29759
30069
|
const pid = Number.parseInt(fs8.readFileSync(pidFile, "utf8").trim(), 10);
|
|
@@ -29782,7 +30092,7 @@ function stopSessionHostProcesses(appName) {
|
|
|
29782
30092
|
}
|
|
29783
30093
|
}
|
|
29784
30094
|
function removeDaemonPidFile() {
|
|
29785
|
-
const pidFile = path13.join(
|
|
30095
|
+
const pidFile = path13.join(os16.homedir(), ".adhdev", "daemon.pid");
|
|
29786
30096
|
try {
|
|
29787
30097
|
fs8.unlinkSync(pidFile);
|
|
29788
30098
|
} catch {
|
|
@@ -29887,14 +30197,14 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
|
|
|
29887
30197
|
process.exit(1);
|
|
29888
30198
|
}
|
|
29889
30199
|
}
|
|
29890
|
-
var import_child_process7, import_child_process8, fs8,
|
|
30200
|
+
var import_child_process7, import_child_process8, fs8, os16, path13, UPGRADE_HELPER_ENV;
|
|
29891
30201
|
var init_upgrade_helper = __esm({
|
|
29892
30202
|
"../../oss/packages/daemon-core/src/commands/upgrade-helper.ts"() {
|
|
29893
30203
|
"use strict";
|
|
29894
30204
|
import_child_process7 = require("child_process");
|
|
29895
30205
|
import_child_process8 = require("child_process");
|
|
29896
30206
|
fs8 = __toESM(require("fs"));
|
|
29897
|
-
|
|
30207
|
+
os16 = __toESM(require("os"));
|
|
29898
30208
|
path13 = __toESM(require("path"));
|
|
29899
30209
|
UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
29900
30210
|
}
|
|
@@ -31418,7 +31728,7 @@ function getVersion(binary, versionCommand) {
|
|
|
31418
31728
|
function checkPathExists2(paths) {
|
|
31419
31729
|
for (const p of paths) {
|
|
31420
31730
|
if (p.includes("*")) {
|
|
31421
|
-
const home =
|
|
31731
|
+
const home = os17.homedir();
|
|
31422
31732
|
const resolved = p.replace(/\*/g, home.split(path14.sep).pop() || "");
|
|
31423
31733
|
if (fs10.existsSync(resolved)) return resolved;
|
|
31424
31734
|
} else {
|
|
@@ -31493,16 +31803,16 @@ async function detectAllVersions(loader, archive) {
|
|
|
31493
31803
|
}
|
|
31494
31804
|
return results;
|
|
31495
31805
|
}
|
|
31496
|
-
var fs10, path14,
|
|
31806
|
+
var fs10, path14, os17, import_child_process9, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
|
|
31497
31807
|
var init_version_archive = __esm({
|
|
31498
31808
|
"../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
|
|
31499
31809
|
"use strict";
|
|
31500
31810
|
fs10 = __toESM(require("fs"));
|
|
31501
31811
|
path14 = __toESM(require("path"));
|
|
31502
|
-
|
|
31812
|
+
os17 = __toESM(require("os"));
|
|
31503
31813
|
import_child_process9 = require("child_process");
|
|
31504
31814
|
import_os3 = require("os");
|
|
31505
|
-
ARCHIVE_PATH = path14.join(
|
|
31815
|
+
ARCHIVE_PATH = path14.join(os17.homedir(), ".adhdev", "version-history.json");
|
|
31506
31816
|
MAX_ENTRIES_PER_PROVIDER = 20;
|
|
31507
31817
|
VersionArchive = class {
|
|
31508
31818
|
history = {};
|
|
@@ -34019,7 +34329,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
34019
34329
|
});
|
|
34020
34330
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
34021
34331
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
34022
|
-
const tmpDir = path17.join(
|
|
34332
|
+
const tmpDir = path17.join(os18.tmpdir(), "adhdev-autoimpl");
|
|
34023
34333
|
if (!fs13.existsSync(tmpDir)) fs13.mkdirSync(tmpDir, { recursive: true });
|
|
34024
34334
|
const promptFile = path17.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
34025
34335
|
fs13.writeFileSync(promptFile, prompt, "utf-8");
|
|
@@ -34173,7 +34483,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
34173
34483
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
34174
34484
|
const baseArgs = [...spawn5.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
34175
34485
|
let shellCmd;
|
|
34176
|
-
const isWin =
|
|
34486
|
+
const isWin = os18.platform() === "win32";
|
|
34177
34487
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
34178
34488
|
if (command === "claude") {
|
|
34179
34489
|
const args = [...baseArgs, "--dangerously-skip-permissions"];
|
|
@@ -34217,7 +34527,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
34217
34527
|
try {
|
|
34218
34528
|
const pty3 = require("node-pty");
|
|
34219
34529
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
34220
|
-
const isWin2 =
|
|
34530
|
+
const isWin2 = os18.platform() === "win32";
|
|
34221
34531
|
child = pty3.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
34222
34532
|
name: "xterm-256color",
|
|
34223
34533
|
cols: 120,
|
|
@@ -35124,13 +35434,13 @@ data: ${JSON.stringify(msg.data)}
|
|
|
35124
35434
|
}
|
|
35125
35435
|
}
|
|
35126
35436
|
}
|
|
35127
|
-
var fs13, path17,
|
|
35437
|
+
var fs13, path17, os18;
|
|
35128
35438
|
var init_dev_auto_implement = __esm({
|
|
35129
35439
|
"../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
|
|
35130
35440
|
"use strict";
|
|
35131
35441
|
fs13 = __toESM(require("fs"));
|
|
35132
35442
|
path17 = __toESM(require("path"));
|
|
35133
|
-
|
|
35443
|
+
os18 = __toESM(require("os"));
|
|
35134
35444
|
init_dev_server();
|
|
35135
35445
|
init_dev_cli_debug();
|
|
35136
35446
|
}
|
|
@@ -36651,141 +36961,6 @@ data: ${JSON.stringify(msg.data)}
|
|
|
36651
36961
|
}
|
|
36652
36962
|
});
|
|
36653
36963
|
|
|
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((resolve13, reject) => {
|
|
36726
|
-
socket.once("connect", () => resolve13());
|
|
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((resolve13, 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
|
-
resolve13(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((resolve13) => {
|
|
36773
|
-
let settled = false;
|
|
36774
|
-
const done = () => {
|
|
36775
|
-
if (settled) return;
|
|
36776
|
-
settled = true;
|
|
36777
|
-
resolve13();
|
|
36778
|
-
};
|
|
36779
|
-
socket.once("close", done);
|
|
36780
|
-
socket.end();
|
|
36781
|
-
socket.destroy();
|
|
36782
|
-
setTimeout(done, 50);
|
|
36783
|
-
});
|
|
36784
|
-
}
|
|
36785
|
-
};
|
|
36786
|
-
}
|
|
36787
|
-
});
|
|
36788
|
-
|
|
36789
36964
|
// ../../oss/packages/daemon-core/src/cli-adapters/session-host-transport.ts
|
|
36790
36965
|
var SessionHostRuntimeTransport, SessionHostPtyTransportFactory;
|
|
36791
36966
|
var init_session_host_transport = __esm({
|
|
@@ -38112,17 +38287,17 @@ function canPeerUsePrivilegedShareCommand(commandType, permission) {
|
|
|
38112
38287
|
return false;
|
|
38113
38288
|
}
|
|
38114
38289
|
}
|
|
38115
|
-
var fs15, path19,
|
|
38290
|
+
var fs15, path19, os19, import_node_module2, esmRequire, logFile, log, logDebug, DaemonP2PSender;
|
|
38116
38291
|
var init_daemon_p2p = __esm({
|
|
38117
38292
|
"src/daemon-p2p.ts"() {
|
|
38118
38293
|
"use strict";
|
|
38119
38294
|
fs15 = __toESM(require("fs"));
|
|
38120
38295
|
init_src();
|
|
38121
38296
|
path19 = __toESM(require("path"));
|
|
38122
|
-
|
|
38297
|
+
os19 = __toESM(require("os"));
|
|
38123
38298
|
import_node_module2 = require("module");
|
|
38124
38299
|
esmRequire = (0, import_node_module2.createRequire)(__filename);
|
|
38125
|
-
logFile = path19.join(
|
|
38300
|
+
logFile = path19.join(os19.tmpdir(), "adhdev_daemon_p2p.log");
|
|
38126
38301
|
log = (msg) => {
|
|
38127
38302
|
LOG.info("P2P", `[${(/* @__PURE__ */ new Date()).toISOString()}] [P2P] ${msg}`);
|
|
38128
38303
|
};
|
|
@@ -38185,9 +38360,9 @@ var init_daemon_p2p = __esm({
|
|
|
38185
38360
|
log(`node-datachannel not found: ${e?.message}
|
|
38186
38361
|
${e?.stack || ""}`);
|
|
38187
38362
|
}
|
|
38188
|
-
const
|
|
38363
|
+
const platform11 = process.platform;
|
|
38189
38364
|
const arch3 = process.arch;
|
|
38190
|
-
const prebuildKey = `${
|
|
38365
|
+
const prebuildKey = `${platform11}-${arch3}`;
|
|
38191
38366
|
try {
|
|
38192
38367
|
const candidates = [
|
|
38193
38368
|
path19.join(__dirname, "node_modules", "node-datachannel"),
|
|
@@ -40910,7 +41085,7 @@ var require_sharp = __commonJS({
|
|
|
40910
41085
|
if (sharp) {
|
|
40911
41086
|
module2.exports = sharp;
|
|
40912
41087
|
} else {
|
|
40913
|
-
const [isLinux2, isMacOs, isWindows2] = ["linux", "darwin", "win32"].map((
|
|
41088
|
+
const [isLinux2, isMacOs, isWindows2] = ["linux", "darwin", "win32"].map((os23) => runtimePlatform.startsWith(os23));
|
|
40914
41089
|
const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
|
40915
41090
|
errors.forEach((err) => {
|
|
40916
41091
|
if (err.code !== "MODULE_NOT_FOUND") {
|
|
@@ -40927,15 +41102,15 @@ var require_sharp = __commonJS({
|
|
|
40927
41102
|
` Requires ${expected}`
|
|
40928
41103
|
);
|
|
40929
41104
|
} else if (prebuiltPlatforms.includes(runtimePlatform)) {
|
|
40930
|
-
const [
|
|
40931
|
-
const libc =
|
|
41105
|
+
const [os23, cpu] = runtimePlatform.split("-");
|
|
41106
|
+
const libc = os23.endsWith("musl") ? " --libc=musl" : "";
|
|
40932
41107
|
help.push(
|
|
40933
41108
|
"- Ensure optional dependencies can be installed:",
|
|
40934
41109
|
" npm install --include=optional sharp",
|
|
40935
41110
|
"- Ensure your package manager supports multi-platform installation:",
|
|
40936
41111
|
" See https://sharp.pixelplumbing.com/install#cross-platform",
|
|
40937
41112
|
"- Add platform-specific dependencies:",
|
|
40938
|
-
` npm install --os=${
|
|
41113
|
+
` npm install --os=${os23.replace("musl", "")}${libc} --cpu=${cpu} sharp`
|
|
40939
41114
|
);
|
|
40940
41115
|
} else {
|
|
40941
41116
|
help.push(
|
|
@@ -45667,24 +45842,7 @@ var init_screenshot_controller = __esm({
|
|
|
45667
45842
|
|
|
45668
45843
|
// src/session-host.ts
|
|
45669
45844
|
function buildSessionHostEnv(baseEnv) {
|
|
45670
|
-
const env =
|
|
45671
|
-
for (const [key, value] of Object.entries(baseEnv)) {
|
|
45672
|
-
if (typeof value !== "string") continue;
|
|
45673
|
-
env[key] = value;
|
|
45674
|
-
}
|
|
45675
|
-
for (const key of Object.keys(env)) {
|
|
45676
|
-
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_")) {
|
|
45677
|
-
delete env[key];
|
|
45678
|
-
}
|
|
45679
|
-
}
|
|
45680
|
-
if (!env.NO_COLOR) {
|
|
45681
|
-
if (!env.TERM || env.TERM === "xterm-color") env.TERM = "xterm-256color";
|
|
45682
|
-
if (!env.COLORTERM) env.COLORTERM = "truecolor";
|
|
45683
|
-
if (process.platform === "win32") {
|
|
45684
|
-
if (!env.FORCE_COLOR) env.FORCE_COLOR = "1";
|
|
45685
|
-
if (!env.CLICOLOR) env.CLICOLOR = "1";
|
|
45686
|
-
}
|
|
45687
|
-
}
|
|
45845
|
+
const env = sanitizeSpawnEnv(baseEnv);
|
|
45688
45846
|
env.ADHDEV_SESSION_HOST_NAME = SESSION_HOST_APP_NAME;
|
|
45689
45847
|
return env;
|
|
45690
45848
|
}
|
|
@@ -45701,12 +45859,12 @@ function resolveSessionHostEntry() {
|
|
|
45701
45859
|
return require.resolve("@adhdev/session-host-daemon");
|
|
45702
45860
|
}
|
|
45703
45861
|
function getSessionHostPidFile() {
|
|
45704
|
-
return path20.join(
|
|
45862
|
+
return path20.join(os20.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
|
|
45705
45863
|
}
|
|
45706
45864
|
function killPid2(pid) {
|
|
45707
45865
|
try {
|
|
45708
45866
|
if (process.platform === "win32") {
|
|
45709
|
-
(0, import_child_process11.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
|
|
45867
|
+
(0, import_child_process11.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
|
|
45710
45868
|
} else {
|
|
45711
45869
|
process.kill(pid, "SIGTERM");
|
|
45712
45870
|
}
|
|
@@ -45715,6 +45873,35 @@ function killPid2(pid) {
|
|
|
45715
45873
|
return false;
|
|
45716
45874
|
}
|
|
45717
45875
|
}
|
|
45876
|
+
function getWindowsProcessCommandLine(pid) {
|
|
45877
|
+
const pidFilter = `ProcessId=${pid}`;
|
|
45878
|
+
try {
|
|
45879
|
+
const wmicOut = (0, import_child_process11.execFileSync)("wmic", [
|
|
45880
|
+
"process",
|
|
45881
|
+
"where",
|
|
45882
|
+
pidFilter,
|
|
45883
|
+
"get",
|
|
45884
|
+
"CommandLine"
|
|
45885
|
+
], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true });
|
|
45886
|
+
const text = wmicOut.trim();
|
|
45887
|
+
if (text) return text;
|
|
45888
|
+
} catch {
|
|
45889
|
+
}
|
|
45890
|
+
try {
|
|
45891
|
+
const psOut = (0, import_child_process11.execFileSync)("powershell.exe", [
|
|
45892
|
+
"-NoProfile",
|
|
45893
|
+
"-NonInteractive",
|
|
45894
|
+
"-ExecutionPolicy",
|
|
45895
|
+
"Bypass",
|
|
45896
|
+
"-Command",
|
|
45897
|
+
`(Get-CimInstance Win32_Process -Filter "${pidFilter}").CommandLine`
|
|
45898
|
+
], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true });
|
|
45899
|
+
const text = psOut.trim();
|
|
45900
|
+
if (text) return text;
|
|
45901
|
+
} catch {
|
|
45902
|
+
}
|
|
45903
|
+
return null;
|
|
45904
|
+
}
|
|
45718
45905
|
function stopSessionHost() {
|
|
45719
45906
|
let stopped = false;
|
|
45720
45907
|
const pidFile = getSessionHostPidFile();
|
|
@@ -45732,7 +45919,27 @@ function stopSessionHost() {
|
|
|
45732
45919
|
} catch {
|
|
45733
45920
|
}
|
|
45734
45921
|
}
|
|
45735
|
-
if (process.platform
|
|
45922
|
+
if (process.platform === "win32") {
|
|
45923
|
+
try {
|
|
45924
|
+
const raw = (0, import_child_process11.execFileSync)("tasklist", ["/FO", "CSV", "/NH", "/FI", "IMAGENAME eq node.exe"], {
|
|
45925
|
+
encoding: "utf8",
|
|
45926
|
+
timeout: 5e3,
|
|
45927
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
45928
|
+
windowsHide: true
|
|
45929
|
+
}).trim();
|
|
45930
|
+
for (const line of raw.split(/\r?\n/)) {
|
|
45931
|
+
const match = line.match(/^"node\.exe","(\d+)"/i);
|
|
45932
|
+
if (!match) continue;
|
|
45933
|
+
const candidatePid = Number.parseInt(match[1], 10);
|
|
45934
|
+
if (!Number.isFinite(candidatePid) || candidatePid === process.pid) continue;
|
|
45935
|
+
const commandLine = getWindowsProcessCommandLine(candidatePid);
|
|
45936
|
+
if (commandLine?.includes("session-host-daemon")) {
|
|
45937
|
+
stopped = killPid2(candidatePid) || stopped;
|
|
45938
|
+
}
|
|
45939
|
+
}
|
|
45940
|
+
} catch {
|
|
45941
|
+
}
|
|
45942
|
+
} else {
|
|
45736
45943
|
try {
|
|
45737
45944
|
const raw = (0, import_child_process11.execFileSync)("pgrep", ["-f", "session-host-daemon"], { encoding: "utf8" }).trim();
|
|
45738
45945
|
for (const line of raw.split("\n")) {
|
|
@@ -45749,13 +45956,20 @@ function stopSessionHost() {
|
|
|
45749
45956
|
async function ensureSessionHostReady2() {
|
|
45750
45957
|
const spawnHost = () => {
|
|
45751
45958
|
const entry = resolveSessionHostEntry();
|
|
45959
|
+
const logDir = path20.join(os20.homedir(), ".adhdev", "logs");
|
|
45960
|
+
fs16.mkdirSync(logDir, { recursive: true });
|
|
45961
|
+
const logFd = fs16.openSync(path20.join(logDir, "session-host.log"), "a");
|
|
45752
45962
|
const child = (0, import_child_process11.spawn)(process.execPath, [entry], {
|
|
45753
45963
|
detached: true,
|
|
45754
|
-
stdio: "ignore",
|
|
45964
|
+
stdio: ["ignore", logFd, logFd],
|
|
45755
45965
|
windowsHide: true,
|
|
45756
45966
|
env: buildSessionHostEnv(process.env)
|
|
45757
45967
|
});
|
|
45758
45968
|
child.unref();
|
|
45969
|
+
try {
|
|
45970
|
+
fs16.closeSync(logFd);
|
|
45971
|
+
} catch {
|
|
45972
|
+
}
|
|
45759
45973
|
};
|
|
45760
45974
|
try {
|
|
45761
45975
|
return await ensureSessionHostReady({
|
|
@@ -45779,13 +45993,13 @@ async function ensureSessionHostReady2() {
|
|
|
45779
45993
|
async function listHostedCliRuntimes2(endpoint) {
|
|
45780
45994
|
return listHostedCliRuntimes(endpoint);
|
|
45781
45995
|
}
|
|
45782
|
-
var import_child_process11, fs16,
|
|
45996
|
+
var import_child_process11, fs16, os20, path20, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
|
|
45783
45997
|
var init_session_host = __esm({
|
|
45784
45998
|
"src/session-host.ts"() {
|
|
45785
45999
|
"use strict";
|
|
45786
46000
|
import_child_process11 = require("child_process");
|
|
45787
46001
|
fs16 = __toESM(require("fs"));
|
|
45788
|
-
|
|
46002
|
+
os20 = __toESM(require("os"));
|
|
45789
46003
|
path20 = __toESM(require("path"));
|
|
45790
46004
|
init_src();
|
|
45791
46005
|
init_dist();
|
|
@@ -45830,7 +46044,7 @@ __export(adhdev_daemon_exports, {
|
|
|
45830
46044
|
stopDaemon: () => stopDaemon
|
|
45831
46045
|
});
|
|
45832
46046
|
function getDaemonPidFile() {
|
|
45833
|
-
const dir = path21.join(
|
|
46047
|
+
const dir = path21.join(os21.homedir(), ".adhdev");
|
|
45834
46048
|
if (!fs17.existsSync(dir)) fs17.mkdirSync(dir, { recursive: true });
|
|
45835
46049
|
return path21.join(dir, "daemon.pid");
|
|
45836
46050
|
}
|
|
@@ -45878,7 +46092,7 @@ function stopDaemon() {
|
|
|
45878
46092
|
return false;
|
|
45879
46093
|
}
|
|
45880
46094
|
}
|
|
45881
|
-
var
|
|
46095
|
+
var os21, fs17, path21, import_http, import_ws3, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
|
|
45882
46096
|
var init_adhdev_daemon = __esm({
|
|
45883
46097
|
"src/adhdev-daemon.ts"() {
|
|
45884
46098
|
"use strict";
|
|
@@ -45888,14 +46102,14 @@ var init_adhdev_daemon = __esm({
|
|
|
45888
46102
|
init_screenshot_controller();
|
|
45889
46103
|
init_session_host();
|
|
45890
46104
|
init_dist();
|
|
45891
|
-
|
|
46105
|
+
os21 = __toESM(require("os"));
|
|
45892
46106
|
fs17 = __toESM(require("fs"));
|
|
45893
46107
|
path21 = __toESM(require("path"));
|
|
45894
46108
|
import_http = require("http");
|
|
45895
46109
|
import_ws3 = require("ws");
|
|
45896
46110
|
import_chalk2 = __toESM(require("chalk"));
|
|
45897
46111
|
init_version();
|
|
45898
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.
|
|
46112
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.14" });
|
|
45899
46113
|
DANGEROUS_PATTERNS = [
|
|
45900
46114
|
/\brm\s+(-[a-z]*f|-[a-z]*r|--force|--recursive)/i,
|
|
45901
46115
|
/\bsudo\b/i,
|
|
@@ -46032,8 +46246,8 @@ ${err?.stack || ""}`);
|
|
|
46032
46246
|
cliInfo: {
|
|
46033
46247
|
type: "adhdev-daemon",
|
|
46034
46248
|
version: pkgVersion,
|
|
46035
|
-
platform:
|
|
46036
|
-
hostname:
|
|
46249
|
+
platform: os21.platform(),
|
|
46250
|
+
hostname: os21.hostname(),
|
|
46037
46251
|
machineId: config2.machineId,
|
|
46038
46252
|
instanceId
|
|
46039
46253
|
}
|
|
@@ -46667,16 +46881,16 @@ async function loginFlow() {
|
|
|
46667
46881
|
let verificationUrl;
|
|
46668
46882
|
try {
|
|
46669
46883
|
const config2 = loadConfig();
|
|
46670
|
-
const
|
|
46884
|
+
const os23 = await import("os");
|
|
46671
46885
|
const res = await fetch(`${SERVER_URL}/auth/cli/init`, {
|
|
46672
46886
|
method: "POST",
|
|
46673
46887
|
headers: { "Content-Type": "application/json" },
|
|
46674
46888
|
body: JSON.stringify({
|
|
46675
46889
|
clientMachineId: config2.machineId,
|
|
46676
46890
|
registeredMachineId: config2.registeredMachineId,
|
|
46677
|
-
hostname:
|
|
46678
|
-
platform:
|
|
46679
|
-
arch:
|
|
46891
|
+
hostname: os23.hostname(),
|
|
46892
|
+
platform: os23.platform(),
|
|
46893
|
+
arch: os23.arch()
|
|
46680
46894
|
})
|
|
46681
46895
|
});
|
|
46682
46896
|
if (!res.ok) {
|
|
@@ -46777,10 +46991,10 @@ async function startDaemonFlow() {
|
|
|
46777
46991
|
const { execSync: execSync7 } = await import("child_process");
|
|
46778
46992
|
const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
46779
46993
|
const logPath = getCurrentDaemonLogPath2();
|
|
46780
|
-
const
|
|
46781
|
-
const
|
|
46994
|
+
const os23 = await import("os");
|
|
46995
|
+
const platform11 = os23.platform();
|
|
46782
46996
|
try {
|
|
46783
|
-
if (
|
|
46997
|
+
if (platform11 === "win32") {
|
|
46784
46998
|
execSync7("start /B adhdev daemon >NUL 2>&1", {
|
|
46785
46999
|
timeout: 3e3,
|
|
46786
47000
|
stdio: "ignore",
|