adhdev 0.9.50 → 0.9.51
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 +851 -760
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +789 -698
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -890,17 +890,17 @@ function checkPathExists(paths) {
|
|
|
890
890
|
return null;
|
|
891
891
|
}
|
|
892
892
|
async function detectIDEs(providerLoader) {
|
|
893
|
-
const
|
|
893
|
+
const os29 = (0, import_os2.platform)();
|
|
894
894
|
const results = [];
|
|
895
895
|
for (const def of getMergedDefinitions()) {
|
|
896
896
|
const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
|
|
897
|
-
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[
|
|
897
|
+
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os29] || []) || []);
|
|
898
898
|
let resolvedCli = cliPath;
|
|
899
|
-
if (!resolvedCli && appPath &&
|
|
899
|
+
if (!resolvedCli && appPath && os29 === "darwin") {
|
|
900
900
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
901
901
|
if ((0, import_fs3.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
902
902
|
}
|
|
903
|
-
if (!resolvedCli && appPath &&
|
|
903
|
+
if (!resolvedCli && appPath && os29 === "win32") {
|
|
904
904
|
const { dirname: dirname10 } = await import("path");
|
|
905
905
|
const appDir = dirname10(appPath);
|
|
906
906
|
const candidates = [
|
|
@@ -917,7 +917,7 @@ async function detectIDEs(providerLoader) {
|
|
|
917
917
|
}
|
|
918
918
|
}
|
|
919
919
|
}
|
|
920
|
-
const installed =
|
|
920
|
+
const installed = os29 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
|
|
921
921
|
const version2 = resolvedCli ? getIdeVersion(resolvedCli) : null;
|
|
922
922
|
results.push({
|
|
923
923
|
id: def.id,
|
|
@@ -7708,6 +7708,50 @@ function buildDebugBundleText(bundle) {
|
|
|
7708
7708
|
"```"
|
|
7709
7709
|
].join("\n");
|
|
7710
7710
|
}
|
|
7711
|
+
function getChatDebugBundleDir() {
|
|
7712
|
+
const override = typeof process.env.ADHDEV_DEBUG_BUNDLE_DIR === "string" ? process.env.ADHDEV_DEBUG_BUNDLE_DIR.trim() : "";
|
|
7713
|
+
return override || path8.join(os6.homedir(), ".adhdev", "debug-bundles", "chat");
|
|
7714
|
+
}
|
|
7715
|
+
function safeBundleIdSegment(value, fallback2) {
|
|
7716
|
+
const normalized = String(value || fallback2).trim().replace(/[^A-Za-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
|
|
7717
|
+
return normalized || fallback2;
|
|
7718
|
+
}
|
|
7719
|
+
function createChatDebugBundleId(targetSessionId) {
|
|
7720
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:.]/g, "").replace("T", "T").replace("Z", "Z");
|
|
7721
|
+
const sessionSegment = safeBundleIdSegment(targetSessionId, "unknown-session");
|
|
7722
|
+
return `chat-debug-${timestamp}-${sessionSegment}-${(0, import_node_crypto.randomUUID)().slice(0, 8)}`;
|
|
7723
|
+
}
|
|
7724
|
+
function buildChatDebugBundleSummary(bundle) {
|
|
7725
|
+
const target = bundle.target && typeof bundle.target === "object" ? bundle.target : {};
|
|
7726
|
+
const readChat = bundle.readChat && typeof bundle.readChat === "object" ? bundle.readChat : {};
|
|
7727
|
+
const cli = bundle.cli && typeof bundle.cli === "object" ? bundle.cli : null;
|
|
7728
|
+
const frontend = bundle.frontend && typeof bundle.frontend === "object" ? bundle.frontend : null;
|
|
7729
|
+
return {
|
|
7730
|
+
createdAt: bundle.createdAt,
|
|
7731
|
+
targetSessionId: target.targetSessionId,
|
|
7732
|
+
providerType: target.providerType,
|
|
7733
|
+
transport: target.transport,
|
|
7734
|
+
readChatSuccess: readChat.success,
|
|
7735
|
+
readChatStatus: readChat.status,
|
|
7736
|
+
readChatTotalMessages: readChat.totalMessages,
|
|
7737
|
+
cliStatus: cli?.status,
|
|
7738
|
+
cliMessageCount: cli?.messageCount,
|
|
7739
|
+
hasFrontendSnapshot: !!frontend
|
|
7740
|
+
};
|
|
7741
|
+
}
|
|
7742
|
+
function storeChatDebugBundleOnDaemon(bundle, targetSessionId) {
|
|
7743
|
+
const bundleId = createChatDebugBundleId(targetSessionId);
|
|
7744
|
+
const dir = getChatDebugBundleDir();
|
|
7745
|
+
fs4.mkdirSync(dir, { recursive: true });
|
|
7746
|
+
const savedPath = path8.join(dir, `${bundleId}.json`);
|
|
7747
|
+
const json2 = `${JSON.stringify(bundle, null, 2)}
|
|
7748
|
+
`;
|
|
7749
|
+
fs4.writeFileSync(savedPath, json2, { encoding: "utf8", mode: 384 });
|
|
7750
|
+
return { bundleId, savedPath, sizeBytes: Buffer.byteLength(json2, "utf8") };
|
|
7751
|
+
}
|
|
7752
|
+
function isDaemonFileDebugDelivery(args) {
|
|
7753
|
+
return args?.delivery === "daemon_file" || args?.delivery === "file";
|
|
7754
|
+
}
|
|
7711
7755
|
async function handleGetChatDebugBundle(h, args) {
|
|
7712
7756
|
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
7713
7757
|
if (!targetSessionId && !h.currentSession) {
|
|
@@ -7819,6 +7863,20 @@ async function handleGetChatDebugBundle(h, args) {
|
|
|
7819
7863
|
recentDebugTrace: getRecentDebugTrace({ limit: 120 })
|
|
7820
7864
|
};
|
|
7821
7865
|
const bundle = sanitizeDebugBundleValue(rawBundle);
|
|
7866
|
+
if (isDaemonFileDebugDelivery(args)) {
|
|
7867
|
+
const summary = buildChatDebugBundleSummary(bundle);
|
|
7868
|
+
const stored = storeChatDebugBundleOnDaemon(bundle, targetSessionId || String(summary.targetSessionId || "unknown-session"));
|
|
7869
|
+
LOG.info("Command", `[get_chat_debug_bundle] saved daemon_file bundle id=${stored.bundleId} path=${stored.savedPath} sizeBytes=${stored.sizeBytes} targetSessionId=${summary.targetSessionId || ""} providerType=${summary.providerType || ""} transport=${summary.transport || ""}`);
|
|
7870
|
+
return {
|
|
7871
|
+
success: true,
|
|
7872
|
+
delivery: "daemon_file",
|
|
7873
|
+
bundleId: stored.bundleId,
|
|
7874
|
+
savedPath: stored.savedPath,
|
|
7875
|
+
sizeBytes: stored.sizeBytes,
|
|
7876
|
+
createdAt: bundle.createdAt,
|
|
7877
|
+
summary
|
|
7878
|
+
};
|
|
7879
|
+
}
|
|
7822
7880
|
return {
|
|
7823
7881
|
success: true,
|
|
7824
7882
|
bundle,
|
|
@@ -8798,10 +8856,14 @@ async function handleResolveAction(h, args) {
|
|
|
8798
8856
|
}
|
|
8799
8857
|
return { success: false, error: "resolveAction script not available for this provider" };
|
|
8800
8858
|
}
|
|
8801
|
-
var RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN;
|
|
8859
|
+
var fs4, os6, path8, import_node_crypto, RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN;
|
|
8802
8860
|
var init_chat_commands = __esm({
|
|
8803
8861
|
"../../oss/packages/daemon-core/src/commands/chat-commands.ts"() {
|
|
8804
8862
|
"use strict";
|
|
8863
|
+
fs4 = __toESM(require("fs"));
|
|
8864
|
+
os6 = __toESM(require("os"));
|
|
8865
|
+
path8 = __toESM(require("path"));
|
|
8866
|
+
import_node_crypto = require("crypto");
|
|
8805
8867
|
init_contracts();
|
|
8806
8868
|
init_provider_input_support();
|
|
8807
8869
|
init_read_chat_contract();
|
|
@@ -9042,27 +9104,27 @@ function normalizeWindowsRequestedPath(requestedPath) {
|
|
|
9042
9104
|
function resolveSafePath(requestedPath) {
|
|
9043
9105
|
const rawPath = typeof requestedPath === "string" ? requestedPath.trim() : "";
|
|
9044
9106
|
const inputPath = rawPath || ".";
|
|
9045
|
-
const home =
|
|
9107
|
+
const home = os7.homedir();
|
|
9046
9108
|
if (inputPath.startsWith("~")) {
|
|
9047
|
-
return
|
|
9109
|
+
return path9.resolve(path9.join(home, inputPath.slice(1)));
|
|
9048
9110
|
}
|
|
9049
9111
|
if (process.platform === "win32") {
|
|
9050
9112
|
const normalized = normalizeWindowsRequestedPath(inputPath);
|
|
9051
|
-
if (
|
|
9052
|
-
return
|
|
9113
|
+
if (path9.win32.isAbsolute(normalized)) {
|
|
9114
|
+
return path9.win32.normalize(normalized);
|
|
9053
9115
|
}
|
|
9054
|
-
return
|
|
9116
|
+
return path9.win32.resolve(normalized);
|
|
9055
9117
|
}
|
|
9056
|
-
if (
|
|
9057
|
-
return
|
|
9118
|
+
if (path9.isAbsolute(inputPath)) {
|
|
9119
|
+
return path9.normalize(inputPath);
|
|
9058
9120
|
}
|
|
9059
|
-
return
|
|
9121
|
+
return path9.resolve(inputPath);
|
|
9060
9122
|
}
|
|
9061
9123
|
function listDirectoryEntriesSafe(dirPath) {
|
|
9062
|
-
const entries =
|
|
9124
|
+
const entries = fs5.readdirSync(dirPath, { withFileTypes: true });
|
|
9063
9125
|
const files = [];
|
|
9064
9126
|
for (const entry of entries) {
|
|
9065
|
-
const entryPath =
|
|
9127
|
+
const entryPath = path9.join(dirPath, entry.name);
|
|
9066
9128
|
try {
|
|
9067
9129
|
if (entry.isDirectory()) {
|
|
9068
9130
|
files.push({ name: entry.name, type: "directory" });
|
|
@@ -9071,14 +9133,14 @@ function listDirectoryEntriesSafe(dirPath) {
|
|
|
9071
9133
|
if (entry.isFile()) {
|
|
9072
9134
|
let size;
|
|
9073
9135
|
try {
|
|
9074
|
-
size =
|
|
9136
|
+
size = fs5.statSync(entryPath).size;
|
|
9075
9137
|
} catch {
|
|
9076
9138
|
size = void 0;
|
|
9077
9139
|
}
|
|
9078
9140
|
files.push({ name: entry.name, type: "file", size });
|
|
9079
9141
|
continue;
|
|
9080
9142
|
}
|
|
9081
|
-
const stat4 =
|
|
9143
|
+
const stat4 = fs5.statSync(entryPath);
|
|
9082
9144
|
files.push({
|
|
9083
9145
|
name: entry.name,
|
|
9084
9146
|
type: stat4.isDirectory() ? "directory" : "file",
|
|
@@ -9096,7 +9158,7 @@ function listWindowsDriveEntries(excludePath) {
|
|
|
9096
9158
|
const letter = String.fromCharCode(code);
|
|
9097
9159
|
const root = `${letter}:\\`;
|
|
9098
9160
|
try {
|
|
9099
|
-
if (!
|
|
9161
|
+
if (!fs5.existsSync(root)) continue;
|
|
9100
9162
|
if (excluded && root.toLowerCase() === excluded) continue;
|
|
9101
9163
|
drives.push({ name: `${letter}:`, type: "directory", path: root });
|
|
9102
9164
|
} catch {
|
|
@@ -9107,7 +9169,7 @@ function listWindowsDriveEntries(excludePath) {
|
|
|
9107
9169
|
async function handleFileRead(h, args) {
|
|
9108
9170
|
try {
|
|
9109
9171
|
const filePath = resolveSafePath(args?.path);
|
|
9110
|
-
const content =
|
|
9172
|
+
const content = fs5.readFileSync(filePath, "utf-8");
|
|
9111
9173
|
return { success: true, content, path: filePath };
|
|
9112
9174
|
} catch (e) {
|
|
9113
9175
|
return { success: false, error: e.message };
|
|
@@ -9116,8 +9178,8 @@ async function handleFileRead(h, args) {
|
|
|
9116
9178
|
async function handleFileWrite(h, args) {
|
|
9117
9179
|
try {
|
|
9118
9180
|
const filePath = resolveSafePath(args?.path);
|
|
9119
|
-
|
|
9120
|
-
|
|
9181
|
+
fs5.mkdirSync(path9.dirname(filePath), { recursive: true });
|
|
9182
|
+
fs5.writeFileSync(filePath, args?.content || "", "utf-8");
|
|
9121
9183
|
return { success: true, path: filePath };
|
|
9122
9184
|
} catch (e) {
|
|
9123
9185
|
return { success: false, error: e.message };
|
|
@@ -9149,13 +9211,13 @@ async function handleFileListBrowse(h, args) {
|
|
|
9149
9211
|
return { success: false, error: e.message };
|
|
9150
9212
|
}
|
|
9151
9213
|
}
|
|
9152
|
-
var
|
|
9214
|
+
var fs5, path9, os7, KEY_TO_VK;
|
|
9153
9215
|
var init_cdp_commands = __esm({
|
|
9154
9216
|
"../../oss/packages/daemon-core/src/commands/cdp-commands.ts"() {
|
|
9155
9217
|
"use strict";
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
|
|
9218
|
+
fs5 = __toESM(require("fs"));
|
|
9219
|
+
path9 = __toESM(require("path"));
|
|
9220
|
+
os7 = __toESM(require("os"));
|
|
9159
9221
|
KEY_TO_VK = {
|
|
9160
9222
|
Backspace: 8,
|
|
9161
9223
|
Tab: 9,
|
|
@@ -11096,7 +11158,7 @@ function getDefaultSessionHostEndpoint(appName = "adhdev") {
|
|
|
11096
11158
|
}
|
|
11097
11159
|
return {
|
|
11098
11160
|
kind: "unix",
|
|
11099
|
-
path: path22.join(
|
|
11161
|
+
path: path22.join(os9.tmpdir(), `${appName}-session-host.sock`)
|
|
11100
11162
|
};
|
|
11101
11163
|
}
|
|
11102
11164
|
function serializeEnvelope(envelope) {
|
|
@@ -11149,25 +11211,25 @@ function applyTerminalColorEnv(env3) {
|
|
|
11149
11211
|
function ensureNodePtySpawnHelperPermissions(logFn) {
|
|
11150
11212
|
if (os22.platform() === "win32") return;
|
|
11151
11213
|
try {
|
|
11152
|
-
const
|
|
11214
|
+
const fs20 = __require("fs");
|
|
11153
11215
|
const ptyDir = path32.resolve(path32.dirname(__require.resolve("node-pty")), "..");
|
|
11154
11216
|
const platformArch = `${os22.platform()}-${os22.arch()}`;
|
|
11155
11217
|
const helper = path32.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
11156
|
-
if (
|
|
11157
|
-
const stat4 =
|
|
11218
|
+
if (fs20.existsSync(helper)) {
|
|
11219
|
+
const stat4 = fs20.statSync(helper);
|
|
11158
11220
|
if (!(stat4.mode & 73)) {
|
|
11159
|
-
|
|
11221
|
+
fs20.chmodSync(helper, stat4.mode | 493);
|
|
11160
11222
|
logFn?.(`Fixed spawn-helper permissions: ${helper}`);
|
|
11161
11223
|
}
|
|
11162
11224
|
}
|
|
11163
11225
|
} catch {
|
|
11164
11226
|
}
|
|
11165
11227
|
}
|
|
11166
|
-
var
|
|
11228
|
+
var os9, path22, net, import_crypto3, os22, path32, __require, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, DEFAULT_SESSION_HOST_COLS, DEFAULT_SESSION_HOST_ROWS, SessionHostClient;
|
|
11167
11229
|
var init_dist = __esm({
|
|
11168
11230
|
"../../oss/packages/session-host-core/dist/index.mjs"() {
|
|
11169
11231
|
"use strict";
|
|
11170
|
-
|
|
11232
|
+
os9 = __toESM(require("os"), 1);
|
|
11171
11233
|
path22 = __toESM(require("path"), 1);
|
|
11172
11234
|
net = __toESM(require("net"), 1);
|
|
11173
11235
|
import_crypto3 = require("crypto");
|
|
@@ -11310,11 +11372,11 @@ function loadNodePty() {
|
|
|
11310
11372
|
}
|
|
11311
11373
|
return cachedPty;
|
|
11312
11374
|
}
|
|
11313
|
-
var
|
|
11375
|
+
var os10, cachedPty, NodePtyRuntimeTransport, NodePtyTransportFactory;
|
|
11314
11376
|
var init_pty_transport = __esm({
|
|
11315
11377
|
"../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts"() {
|
|
11316
11378
|
"use strict";
|
|
11317
|
-
|
|
11379
|
+
os10 = __toESM(require("os"));
|
|
11318
11380
|
init_spawn_env();
|
|
11319
11381
|
NodePtyRuntimeTransport = class {
|
|
11320
11382
|
constructor(handle) {
|
|
@@ -11351,11 +11413,11 @@ var init_pty_transport = __esm({
|
|
|
11351
11413
|
let cwd = options.cwd;
|
|
11352
11414
|
if (cwd) {
|
|
11353
11415
|
try {
|
|
11354
|
-
const
|
|
11355
|
-
const stat4 =
|
|
11356
|
-
if (!stat4.isDirectory()) cwd =
|
|
11416
|
+
const fs20 = require("fs");
|
|
11417
|
+
const stat4 = fs20.statSync(cwd);
|
|
11418
|
+
if (!stat4.isDirectory()) cwd = os10.homedir();
|
|
11357
11419
|
} catch {
|
|
11358
|
-
cwd =
|
|
11420
|
+
cwd = os10.homedir();
|
|
11359
11421
|
}
|
|
11360
11422
|
}
|
|
11361
11423
|
const handle = pty.spawn(command, args, {
|
|
@@ -11435,11 +11497,11 @@ function buildCliScreenSnapshot(text) {
|
|
|
11435
11497
|
function findBinary(name) {
|
|
11436
11498
|
const trimmed = String(name || "").trim();
|
|
11437
11499
|
if (!trimmed) return trimmed;
|
|
11438
|
-
const expanded = trimmed.startsWith("~") ?
|
|
11439
|
-
if (
|
|
11440
|
-
return
|
|
11500
|
+
const expanded = trimmed.startsWith("~") ? path10.join(os11.homedir(), trimmed.slice(1)) : trimmed;
|
|
11501
|
+
if (path10.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
|
|
11502
|
+
return path10.isAbsolute(expanded) ? expanded : path10.resolve(expanded);
|
|
11441
11503
|
}
|
|
11442
|
-
const isWin =
|
|
11504
|
+
const isWin = os11.platform() === "win32";
|
|
11443
11505
|
try {
|
|
11444
11506
|
const cmd = isWin ? `where ${trimmed}` : `which ${trimmed}`;
|
|
11445
11507
|
return (0, import_child_process4.execSync)(cmd, {
|
|
@@ -11453,14 +11515,14 @@ function findBinary(name) {
|
|
|
11453
11515
|
}
|
|
11454
11516
|
}
|
|
11455
11517
|
function isScriptBinary(binaryPath) {
|
|
11456
|
-
if (!
|
|
11518
|
+
if (!path10.isAbsolute(binaryPath)) return false;
|
|
11457
11519
|
try {
|
|
11458
|
-
const
|
|
11459
|
-
const resolved =
|
|
11520
|
+
const fs20 = require("fs");
|
|
11521
|
+
const resolved = fs20.realpathSync(binaryPath);
|
|
11460
11522
|
const head = Buffer.alloc(8);
|
|
11461
|
-
const fd =
|
|
11462
|
-
|
|
11463
|
-
|
|
11523
|
+
const fd = fs20.openSync(resolved, "r");
|
|
11524
|
+
fs20.readSync(fd, head, 0, 8, 0);
|
|
11525
|
+
fs20.closeSync(fd);
|
|
11464
11526
|
let i = 0;
|
|
11465
11527
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
11466
11528
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -11469,14 +11531,14 @@ function isScriptBinary(binaryPath) {
|
|
|
11469
11531
|
}
|
|
11470
11532
|
}
|
|
11471
11533
|
function looksLikeMachOOrElf(filePath) {
|
|
11472
|
-
if (!
|
|
11534
|
+
if (!path10.isAbsolute(filePath)) return false;
|
|
11473
11535
|
try {
|
|
11474
|
-
const
|
|
11475
|
-
const resolved =
|
|
11536
|
+
const fs20 = require("fs");
|
|
11537
|
+
const resolved = fs20.realpathSync(filePath);
|
|
11476
11538
|
const buf = Buffer.alloc(8);
|
|
11477
|
-
const fd =
|
|
11478
|
-
|
|
11479
|
-
|
|
11539
|
+
const fd = fs20.openSync(resolved, "r");
|
|
11540
|
+
fs20.readSync(fd, buf, 0, 8, 0);
|
|
11541
|
+
fs20.closeSync(fd);
|
|
11480
11542
|
let i = 0;
|
|
11481
11543
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
11482
11544
|
const b = buf.subarray(i);
|
|
@@ -11492,7 +11554,7 @@ function looksLikeMachOOrElf(filePath) {
|
|
|
11492
11554
|
}
|
|
11493
11555
|
function shSingleQuote(arg) {
|
|
11494
11556
|
if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
|
|
11495
|
-
if (
|
|
11557
|
+
if (os11.platform() === "win32") {
|
|
11496
11558
|
return `"${arg.replace(/"/g, '""')}"`;
|
|
11497
11559
|
}
|
|
11498
11560
|
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
@@ -11619,12 +11681,12 @@ function normalizeCliProviderForRuntime(raw) {
|
|
|
11619
11681
|
}
|
|
11620
11682
|
};
|
|
11621
11683
|
}
|
|
11622
|
-
var
|
|
11684
|
+
var os11, path10, import_child_process4, buildCliSpawnEnv, COMMON_COMPARABLE_WRAP_WORDS;
|
|
11623
11685
|
var init_provider_cli_shared = __esm({
|
|
11624
11686
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-shared.ts"() {
|
|
11625
11687
|
"use strict";
|
|
11626
|
-
|
|
11627
|
-
|
|
11688
|
+
os11 = __toESM(require("os"));
|
|
11689
|
+
path10 = __toESM(require("path"));
|
|
11628
11690
|
import_child_process4 = require("child_process");
|
|
11629
11691
|
init_spawn_env();
|
|
11630
11692
|
buildCliSpawnEnv = sanitizeSpawnEnv;
|
|
@@ -11937,13 +11999,13 @@ function resolveCliSpawnPlan(options) {
|
|
|
11937
11999
|
const { spawn: spawnConfig } = provider;
|
|
11938
12000
|
const configuredCommand = typeof runtimeSettings.executablePath === "string" && runtimeSettings.executablePath.trim() ? runtimeSettings.executablePath.trim() : spawnConfig.command;
|
|
11939
12001
|
const binaryPath = findBinary(configuredCommand);
|
|
11940
|
-
const isWin =
|
|
12002
|
+
const isWin = os12.platform() === "win32";
|
|
11941
12003
|
const allArgs = [...spawnConfig.args, ...extraArgs];
|
|
11942
12004
|
let shellCmd;
|
|
11943
12005
|
let shellArgs;
|
|
11944
|
-
const useShellUnix = !isWin && (!!spawnConfig.shell || !
|
|
12006
|
+
const useShellUnix = !isWin && (!!spawnConfig.shell || !path11.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
11945
12007
|
const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
|
|
11946
|
-
const useShellWin = !!spawnConfig.shell || isCmdShim || !
|
|
12008
|
+
const useShellWin = !!spawnConfig.shell || isCmdShim || !path11.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
|
|
11947
12009
|
const useShell = isWin ? useShellWin : useShellUnix;
|
|
11948
12010
|
if (useShell) {
|
|
11949
12011
|
shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
|
|
@@ -12019,12 +12081,12 @@ function respondToCliTerminalQueries(options) {
|
|
|
12019
12081
|
}
|
|
12020
12082
|
return "";
|
|
12021
12083
|
}
|
|
12022
|
-
var
|
|
12084
|
+
var os12, path11;
|
|
12023
12085
|
var init_provider_cli_runtime = __esm({
|
|
12024
12086
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-runtime.ts"() {
|
|
12025
12087
|
"use strict";
|
|
12026
|
-
|
|
12027
|
-
|
|
12088
|
+
os12 = __toESM(require("os"));
|
|
12089
|
+
path11 = __toESM(require("path"));
|
|
12028
12090
|
init_dist();
|
|
12029
12091
|
init_provider_cli_shared();
|
|
12030
12092
|
}
|
|
@@ -12146,11 +12208,11 @@ function trimLastAssistantEchoForCliMessages(messages, prompt2) {
|
|
|
12146
12208
|
return;
|
|
12147
12209
|
}
|
|
12148
12210
|
}
|
|
12149
|
-
var
|
|
12211
|
+
var os13, COMMITTED_ACTIVITY_PREFIX_BLOCK_RE, ProviderCliAdapter;
|
|
12150
12212
|
var init_provider_cli_adapter = __esm({
|
|
12151
12213
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
|
|
12152
12214
|
"use strict";
|
|
12153
|
-
|
|
12215
|
+
os13 = __toESM(require("os"));
|
|
12154
12216
|
init_logger();
|
|
12155
12217
|
init_debug_config();
|
|
12156
12218
|
init_terminal_screen();
|
|
@@ -12170,7 +12232,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
12170
12232
|
this.transportFactory = transportFactory;
|
|
12171
12233
|
this.cliType = provider.type;
|
|
12172
12234
|
this.cliName = provider.name;
|
|
12173
|
-
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/,
|
|
12235
|
+
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os13.homedir()) : workingDir;
|
|
12174
12236
|
const resolvedConfig = resolveCliAdapterConfig(provider);
|
|
12175
12237
|
this.timeouts = resolvedConfig.timeouts;
|
|
12176
12238
|
this.approvalKeys = resolvedConfig.approvalKeys;
|
|
@@ -14553,7 +14615,7 @@ function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages
|
|
|
14553
14615
|
}
|
|
14554
14616
|
function getDatabaseSync() {
|
|
14555
14617
|
if (CachedDatabaseSync) return CachedDatabaseSync;
|
|
14556
|
-
const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(
|
|
14618
|
+
const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path12.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
|
|
14557
14619
|
const sqliteModule = requireFn(`node:${"sqlite"}`);
|
|
14558
14620
|
CachedDatabaseSync = sqliteModule.DatabaseSync;
|
|
14559
14621
|
if (!CachedDatabaseSync) {
|
|
@@ -14595,14 +14657,14 @@ async function waitForCliAdapterReady(adapter, options) {
|
|
|
14595
14657
|
}
|
|
14596
14658
|
throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
|
|
14597
14659
|
}
|
|
14598
|
-
var
|
|
14660
|
+
var os14, path12, crypto3, fs6, import_node_module, CachedDatabaseSync, CliProviderInstance;
|
|
14599
14661
|
var init_cli_provider_instance = __esm({
|
|
14600
14662
|
"../../oss/packages/daemon-core/src/providers/cli-provider-instance.ts"() {
|
|
14601
14663
|
"use strict";
|
|
14602
|
-
|
|
14603
|
-
|
|
14664
|
+
os14 = __toESM(require("os"));
|
|
14665
|
+
path12 = __toESM(require("path"));
|
|
14604
14666
|
crypto3 = __toESM(require("crypto"));
|
|
14605
|
-
|
|
14667
|
+
fs6 = __toESM(require("fs"));
|
|
14606
14668
|
import_node_module = require("module");
|
|
14607
14669
|
init_contracts();
|
|
14608
14670
|
init_provider_input_support();
|
|
@@ -14725,10 +14787,10 @@ var init_cli_provider_instance = __esm({
|
|
|
14725
14787
|
* Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
|
|
14726
14788
|
*/
|
|
14727
14789
|
probeSessionIdFromConfig(probe) {
|
|
14728
|
-
const resolvedDbPath = probe.dbPath.replace(/^~/,
|
|
14790
|
+
const resolvedDbPath = probe.dbPath.replace(/^~/, os14.homedir());
|
|
14729
14791
|
const now = Date.now();
|
|
14730
14792
|
if (this.cachedSqliteDbMissingUntil > now) return null;
|
|
14731
|
-
if (!
|
|
14793
|
+
if (!fs6.existsSync(resolvedDbPath)) {
|
|
14732
14794
|
this.cachedSqliteDbMissingUntil = now + 1e4;
|
|
14733
14795
|
return null;
|
|
14734
14796
|
}
|
|
@@ -15460,7 +15522,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
15460
15522
|
};
|
|
15461
15523
|
addDir(this.workingDir);
|
|
15462
15524
|
try {
|
|
15463
|
-
addDir(
|
|
15525
|
+
addDir(fs6.realpathSync.native(this.workingDir));
|
|
15464
15526
|
} catch {
|
|
15465
15527
|
}
|
|
15466
15528
|
return Array.from(dirs);
|
|
@@ -15751,10 +15813,10 @@ function mergeDefs(...defs) {
|
|
|
15751
15813
|
function cloneDef(schema) {
|
|
15752
15814
|
return mergeDefs(schema._zod.def);
|
|
15753
15815
|
}
|
|
15754
|
-
function getElementAtPath(obj,
|
|
15755
|
-
if (!
|
|
15816
|
+
function getElementAtPath(obj, path29) {
|
|
15817
|
+
if (!path29)
|
|
15756
15818
|
return obj;
|
|
15757
|
-
return
|
|
15819
|
+
return path29.reduce((acc, key) => acc?.[key], obj);
|
|
15758
15820
|
}
|
|
15759
15821
|
function promiseAllObject(promisesObj) {
|
|
15760
15822
|
const keys = Object.keys(promisesObj);
|
|
@@ -16066,11 +16128,11 @@ function aborted(x, startIndex = 0) {
|
|
|
16066
16128
|
}
|
|
16067
16129
|
return false;
|
|
16068
16130
|
}
|
|
16069
|
-
function prefixIssues(
|
|
16131
|
+
function prefixIssues(path29, issues) {
|
|
16070
16132
|
return issues.map((iss) => {
|
|
16071
16133
|
var _a2;
|
|
16072
16134
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
16073
|
-
iss.path.unshift(
|
|
16135
|
+
iss.path.unshift(path29);
|
|
16074
16136
|
return iss;
|
|
16075
16137
|
});
|
|
16076
16138
|
}
|
|
@@ -16313,7 +16375,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
16313
16375
|
}
|
|
16314
16376
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
16315
16377
|
const result = { errors: [] };
|
|
16316
|
-
const processError = (error49,
|
|
16378
|
+
const processError = (error49, path29 = []) => {
|
|
16317
16379
|
var _a2, _b;
|
|
16318
16380
|
for (const issue2 of error49.issues) {
|
|
16319
16381
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -16323,7 +16385,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
16323
16385
|
} else if (issue2.code === "invalid_element") {
|
|
16324
16386
|
processError({ issues: issue2.issues }, issue2.path);
|
|
16325
16387
|
} else {
|
|
16326
|
-
const fullpath = [...
|
|
16388
|
+
const fullpath = [...path29, ...issue2.path];
|
|
16327
16389
|
if (fullpath.length === 0) {
|
|
16328
16390
|
result.errors.push(mapper(issue2));
|
|
16329
16391
|
continue;
|
|
@@ -16355,8 +16417,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
16355
16417
|
}
|
|
16356
16418
|
function toDotPath(_path) {
|
|
16357
16419
|
const segs = [];
|
|
16358
|
-
const
|
|
16359
|
-
for (const seg of
|
|
16420
|
+
const path29 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
16421
|
+
for (const seg of path29) {
|
|
16360
16422
|
if (typeof seg === "number")
|
|
16361
16423
|
segs.push(`[${seg}]`);
|
|
16362
16424
|
else if (typeof seg === "symbol")
|
|
@@ -29120,13 +29182,13 @@ function resolveRef(ref, ctx) {
|
|
|
29120
29182
|
if (!ref.startsWith("#")) {
|
|
29121
29183
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
29122
29184
|
}
|
|
29123
|
-
const
|
|
29124
|
-
if (
|
|
29185
|
+
const path29 = ref.slice(1).split("/").filter(Boolean);
|
|
29186
|
+
if (path29.length === 0) {
|
|
29125
29187
|
return ctx.rootSchema;
|
|
29126
29188
|
}
|
|
29127
29189
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
29128
|
-
if (
|
|
29129
|
-
const key =
|
|
29190
|
+
if (path29[0] === defsKey) {
|
|
29191
|
+
const key = path29[1];
|
|
29130
29192
|
if (!key || !ctx.defs[key]) {
|
|
29131
29193
|
throw new Error(`Reference not found: ${ref}`);
|
|
29132
29194
|
}
|
|
@@ -32972,11 +33034,11 @@ var init_hosted_runtime_restore = __esm({
|
|
|
32972
33034
|
// ../../oss/packages/daemon-core/src/commands/cli-manager.ts
|
|
32973
33035
|
function isExplicitCommand(command) {
|
|
32974
33036
|
const trimmed = command.trim();
|
|
32975
|
-
return
|
|
33037
|
+
return path13.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
|
|
32976
33038
|
}
|
|
32977
33039
|
function expandExecutable(command) {
|
|
32978
33040
|
const trimmed = command.trim();
|
|
32979
|
-
return trimmed.startsWith("~") ?
|
|
33041
|
+
return trimmed.startsWith("~") ? path13.join(os15.homedir(), trimmed.slice(1)) : trimmed;
|
|
32980
33042
|
}
|
|
32981
33043
|
function commandExists(command) {
|
|
32982
33044
|
const trimmed = command.trim();
|
|
@@ -33113,12 +33175,12 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
|
|
|
33113
33175
|
launchMode: "new"
|
|
33114
33176
|
};
|
|
33115
33177
|
}
|
|
33116
|
-
var
|
|
33178
|
+
var os15, path13, crypto4, import_fs5, import_child_process6, chalkModule, chalkApi, DaemonCliManager;
|
|
33117
33179
|
var init_cli_manager = __esm({
|
|
33118
33180
|
"../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
|
|
33119
33181
|
"use strict";
|
|
33120
|
-
|
|
33121
|
-
|
|
33182
|
+
os15 = __toESM(require("os"));
|
|
33183
|
+
path13 = __toESM(require("path"));
|
|
33122
33184
|
crypto4 = __toESM(require("crypto"));
|
|
33123
33185
|
import_fs5 = require("fs");
|
|
33124
33186
|
import_child_process6 = require("child_process");
|
|
@@ -33281,7 +33343,7 @@ var init_cli_manager = __esm({
|
|
|
33281
33343
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
33282
33344
|
const trimmed = (workingDir || "").trim();
|
|
33283
33345
|
if (!trimmed) throw new Error("working directory required");
|
|
33284
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/,
|
|
33346
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os15.homedir()) : path13.resolve(trimmed);
|
|
33285
33347
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
33286
33348
|
const rawProvider = this.providerLoader.getByAlias(cliType);
|
|
33287
33349
|
const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
|
|
@@ -33884,7 +33946,7 @@ var init_readdirp = __esm({
|
|
|
33884
33946
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
33885
33947
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
33886
33948
|
if (wantBigintFsStats) {
|
|
33887
|
-
this._stat = (
|
|
33949
|
+
this._stat = (path29) => statMethod(path29, { bigint: true });
|
|
33888
33950
|
} else {
|
|
33889
33951
|
this._stat = statMethod;
|
|
33890
33952
|
}
|
|
@@ -33909,8 +33971,8 @@ var init_readdirp = __esm({
|
|
|
33909
33971
|
const par = this.parent;
|
|
33910
33972
|
const fil = par && par.files;
|
|
33911
33973
|
if (fil && fil.length > 0) {
|
|
33912
|
-
const { path:
|
|
33913
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
33974
|
+
const { path: path29, depth } = par;
|
|
33975
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path29));
|
|
33914
33976
|
const awaited = await Promise.all(slice);
|
|
33915
33977
|
for (const entry of awaited) {
|
|
33916
33978
|
if (!entry)
|
|
@@ -33950,20 +34012,20 @@ var init_readdirp = __esm({
|
|
|
33950
34012
|
this.reading = false;
|
|
33951
34013
|
}
|
|
33952
34014
|
}
|
|
33953
|
-
async _exploreDir(
|
|
34015
|
+
async _exploreDir(path29, depth) {
|
|
33954
34016
|
let files;
|
|
33955
34017
|
try {
|
|
33956
|
-
files = await (0, import_promises.readdir)(
|
|
34018
|
+
files = await (0, import_promises.readdir)(path29, this._rdOptions);
|
|
33957
34019
|
} catch (error48) {
|
|
33958
34020
|
this._onError(error48);
|
|
33959
34021
|
}
|
|
33960
|
-
return { files, depth, path:
|
|
34022
|
+
return { files, depth, path: path29 };
|
|
33961
34023
|
}
|
|
33962
|
-
async _formatEntry(dirent,
|
|
34024
|
+
async _formatEntry(dirent, path29) {
|
|
33963
34025
|
let entry;
|
|
33964
34026
|
const basename9 = this._isDirent ? dirent.name : dirent;
|
|
33965
34027
|
try {
|
|
33966
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
34028
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path29, basename9));
|
|
33967
34029
|
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename9 };
|
|
33968
34030
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
33969
34031
|
} catch (err) {
|
|
@@ -34020,16 +34082,16 @@ var init_readdirp = __esm({
|
|
|
34020
34082
|
});
|
|
34021
34083
|
|
|
34022
34084
|
// ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
|
|
34023
|
-
function createFsWatchInstance(
|
|
34085
|
+
function createFsWatchInstance(path29, options, listener, errHandler, emitRaw) {
|
|
34024
34086
|
const handleEvent = (rawEvent, evPath) => {
|
|
34025
|
-
listener(
|
|
34026
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
34027
|
-
if (evPath &&
|
|
34028
|
-
fsWatchBroadcast(sp.resolve(
|
|
34087
|
+
listener(path29);
|
|
34088
|
+
emitRaw(rawEvent, evPath, { watchedPath: path29 });
|
|
34089
|
+
if (evPath && path29 !== evPath) {
|
|
34090
|
+
fsWatchBroadcast(sp.resolve(path29, evPath), KEY_LISTENERS, sp.join(path29, evPath));
|
|
34029
34091
|
}
|
|
34030
34092
|
};
|
|
34031
34093
|
try {
|
|
34032
|
-
return (0, import_node_fs.watch)(
|
|
34094
|
+
return (0, import_node_fs.watch)(path29, {
|
|
34033
34095
|
persistent: options.persistent
|
|
34034
34096
|
}, handleEvent);
|
|
34035
34097
|
} catch (error48) {
|
|
@@ -34378,12 +34440,12 @@ var init_handler2 = __esm({
|
|
|
34378
34440
|
listener(val1, val2, val3);
|
|
34379
34441
|
});
|
|
34380
34442
|
};
|
|
34381
|
-
setFsWatchListener = (
|
|
34443
|
+
setFsWatchListener = (path29, fullPath, options, handlers) => {
|
|
34382
34444
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
34383
34445
|
let cont = FsWatchInstances.get(fullPath);
|
|
34384
34446
|
let watcher;
|
|
34385
34447
|
if (!options.persistent) {
|
|
34386
|
-
watcher = createFsWatchInstance(
|
|
34448
|
+
watcher = createFsWatchInstance(path29, options, listener, errHandler, rawEmitter);
|
|
34387
34449
|
if (!watcher)
|
|
34388
34450
|
return;
|
|
34389
34451
|
return watcher.close.bind(watcher);
|
|
@@ -34394,7 +34456,7 @@ var init_handler2 = __esm({
|
|
|
34394
34456
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
34395
34457
|
} else {
|
|
34396
34458
|
watcher = createFsWatchInstance(
|
|
34397
|
-
|
|
34459
|
+
path29,
|
|
34398
34460
|
options,
|
|
34399
34461
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
34400
34462
|
errHandler,
|
|
@@ -34409,7 +34471,7 @@ var init_handler2 = __esm({
|
|
|
34409
34471
|
cont.watcherUnusable = true;
|
|
34410
34472
|
if (isWindows && error48.code === "EPERM") {
|
|
34411
34473
|
try {
|
|
34412
|
-
const fd = await (0, import_promises2.open)(
|
|
34474
|
+
const fd = await (0, import_promises2.open)(path29, "r");
|
|
34413
34475
|
await fd.close();
|
|
34414
34476
|
broadcastErr(error48);
|
|
34415
34477
|
} catch (err) {
|
|
@@ -34440,7 +34502,7 @@ var init_handler2 = __esm({
|
|
|
34440
34502
|
};
|
|
34441
34503
|
};
|
|
34442
34504
|
FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
34443
|
-
setFsWatchFileListener = (
|
|
34505
|
+
setFsWatchFileListener = (path29, fullPath, options, handlers) => {
|
|
34444
34506
|
const { listener, rawEmitter } = handlers;
|
|
34445
34507
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
34446
34508
|
const copts = cont && cont.options;
|
|
@@ -34462,7 +34524,7 @@ var init_handler2 = __esm({
|
|
|
34462
34524
|
});
|
|
34463
34525
|
const currmtime = curr.mtimeMs;
|
|
34464
34526
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
34465
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
34527
|
+
foreach(cont.listeners, (listener2) => listener2(path29, curr));
|
|
34466
34528
|
}
|
|
34467
34529
|
})
|
|
34468
34530
|
};
|
|
@@ -34492,13 +34554,13 @@ var init_handler2 = __esm({
|
|
|
34492
34554
|
* @param listener on fs change
|
|
34493
34555
|
* @returns closer for the watcher instance
|
|
34494
34556
|
*/
|
|
34495
|
-
_watchWithNodeFs(
|
|
34557
|
+
_watchWithNodeFs(path29, listener) {
|
|
34496
34558
|
const opts = this.fsw.options;
|
|
34497
|
-
const directory = sp.dirname(
|
|
34498
|
-
const basename9 = sp.basename(
|
|
34559
|
+
const directory = sp.dirname(path29);
|
|
34560
|
+
const basename9 = sp.basename(path29);
|
|
34499
34561
|
const parent = this.fsw._getWatchedDir(directory);
|
|
34500
34562
|
parent.add(basename9);
|
|
34501
|
-
const absolutePath = sp.resolve(
|
|
34563
|
+
const absolutePath = sp.resolve(path29);
|
|
34502
34564
|
const options = {
|
|
34503
34565
|
persistent: opts.persistent
|
|
34504
34566
|
};
|
|
@@ -34508,12 +34570,12 @@ var init_handler2 = __esm({
|
|
|
34508
34570
|
if (opts.usePolling) {
|
|
34509
34571
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
34510
34572
|
options.interval = enableBin && isBinaryPath(basename9) ? opts.binaryInterval : opts.interval;
|
|
34511
|
-
closer = setFsWatchFileListener(
|
|
34573
|
+
closer = setFsWatchFileListener(path29, absolutePath, options, {
|
|
34512
34574
|
listener,
|
|
34513
34575
|
rawEmitter: this.fsw._emitRaw
|
|
34514
34576
|
});
|
|
34515
34577
|
} else {
|
|
34516
|
-
closer = setFsWatchListener(
|
|
34578
|
+
closer = setFsWatchListener(path29, absolutePath, options, {
|
|
34517
34579
|
listener,
|
|
34518
34580
|
errHandler: this._boundHandleError,
|
|
34519
34581
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -34535,7 +34597,7 @@ var init_handler2 = __esm({
|
|
|
34535
34597
|
let prevStats = stats;
|
|
34536
34598
|
if (parent.has(basename9))
|
|
34537
34599
|
return;
|
|
34538
|
-
const listener = async (
|
|
34600
|
+
const listener = async (path29, newStats) => {
|
|
34539
34601
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
34540
34602
|
return;
|
|
34541
34603
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -34549,11 +34611,11 @@ var init_handler2 = __esm({
|
|
|
34549
34611
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
34550
34612
|
}
|
|
34551
34613
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
34552
|
-
this.fsw._closeFile(
|
|
34614
|
+
this.fsw._closeFile(path29);
|
|
34553
34615
|
prevStats = newStats2;
|
|
34554
34616
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
34555
34617
|
if (closer2)
|
|
34556
|
-
this.fsw._addPathCloser(
|
|
34618
|
+
this.fsw._addPathCloser(path29, closer2);
|
|
34557
34619
|
} else {
|
|
34558
34620
|
prevStats = newStats2;
|
|
34559
34621
|
}
|
|
@@ -34585,7 +34647,7 @@ var init_handler2 = __esm({
|
|
|
34585
34647
|
* @param item basename of this item
|
|
34586
34648
|
* @returns true if no more processing is needed for this entry.
|
|
34587
34649
|
*/
|
|
34588
|
-
async _handleSymlink(entry, directory,
|
|
34650
|
+
async _handleSymlink(entry, directory, path29, item) {
|
|
34589
34651
|
if (this.fsw.closed) {
|
|
34590
34652
|
return;
|
|
34591
34653
|
}
|
|
@@ -34595,7 +34657,7 @@ var init_handler2 = __esm({
|
|
|
34595
34657
|
this.fsw._incrReadyCount();
|
|
34596
34658
|
let linkPath;
|
|
34597
34659
|
try {
|
|
34598
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
34660
|
+
linkPath = await (0, import_promises2.realpath)(path29);
|
|
34599
34661
|
} catch (e) {
|
|
34600
34662
|
this.fsw._emitReady();
|
|
34601
34663
|
return true;
|
|
@@ -34605,12 +34667,12 @@ var init_handler2 = __esm({
|
|
|
34605
34667
|
if (dir.has(item)) {
|
|
34606
34668
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
34607
34669
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
34608
|
-
this.fsw._emit(EV.CHANGE,
|
|
34670
|
+
this.fsw._emit(EV.CHANGE, path29, entry.stats);
|
|
34609
34671
|
}
|
|
34610
34672
|
} else {
|
|
34611
34673
|
dir.add(item);
|
|
34612
34674
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
34613
|
-
this.fsw._emit(EV.ADD,
|
|
34675
|
+
this.fsw._emit(EV.ADD, path29, entry.stats);
|
|
34614
34676
|
}
|
|
34615
34677
|
this.fsw._emitReady();
|
|
34616
34678
|
return true;
|
|
@@ -34640,9 +34702,9 @@ var init_handler2 = __esm({
|
|
|
34640
34702
|
return;
|
|
34641
34703
|
}
|
|
34642
34704
|
const item = entry.path;
|
|
34643
|
-
let
|
|
34705
|
+
let path29 = sp.join(directory, item);
|
|
34644
34706
|
current.add(item);
|
|
34645
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
34707
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path29, item)) {
|
|
34646
34708
|
return;
|
|
34647
34709
|
}
|
|
34648
34710
|
if (this.fsw.closed) {
|
|
@@ -34651,8 +34713,8 @@ var init_handler2 = __esm({
|
|
|
34651
34713
|
}
|
|
34652
34714
|
if (item === target || !target && !previous.has(item)) {
|
|
34653
34715
|
this.fsw._incrReadyCount();
|
|
34654
|
-
|
|
34655
|
-
this._addToNodeFs(
|
|
34716
|
+
path29 = sp.join(dir, sp.relative(dir, path29));
|
|
34717
|
+
this._addToNodeFs(path29, initialAdd, wh, depth + 1);
|
|
34656
34718
|
}
|
|
34657
34719
|
}).on(EV.ERROR, this._boundHandleError);
|
|
34658
34720
|
return new Promise((resolve16, reject) => {
|
|
@@ -34721,13 +34783,13 @@ var init_handler2 = __esm({
|
|
|
34721
34783
|
* @param depth Child path actually targeted for watch
|
|
34722
34784
|
* @param target Child path actually targeted for watch
|
|
34723
34785
|
*/
|
|
34724
|
-
async _addToNodeFs(
|
|
34786
|
+
async _addToNodeFs(path29, initialAdd, priorWh, depth, target) {
|
|
34725
34787
|
const ready = this.fsw._emitReady;
|
|
34726
|
-
if (this.fsw._isIgnored(
|
|
34788
|
+
if (this.fsw._isIgnored(path29) || this.fsw.closed) {
|
|
34727
34789
|
ready();
|
|
34728
34790
|
return false;
|
|
34729
34791
|
}
|
|
34730
|
-
const wh = this.fsw._getWatchHelpers(
|
|
34792
|
+
const wh = this.fsw._getWatchHelpers(path29);
|
|
34731
34793
|
if (priorWh) {
|
|
34732
34794
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
34733
34795
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -34743,8 +34805,8 @@ var init_handler2 = __esm({
|
|
|
34743
34805
|
const follow = this.fsw.options.followSymlinks;
|
|
34744
34806
|
let closer;
|
|
34745
34807
|
if (stats.isDirectory()) {
|
|
34746
|
-
const absPath = sp.resolve(
|
|
34747
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
34808
|
+
const absPath = sp.resolve(path29);
|
|
34809
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path29) : path29;
|
|
34748
34810
|
if (this.fsw.closed)
|
|
34749
34811
|
return;
|
|
34750
34812
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -34754,29 +34816,29 @@ var init_handler2 = __esm({
|
|
|
34754
34816
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
34755
34817
|
}
|
|
34756
34818
|
} else if (stats.isSymbolicLink()) {
|
|
34757
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
34819
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path29) : path29;
|
|
34758
34820
|
if (this.fsw.closed)
|
|
34759
34821
|
return;
|
|
34760
34822
|
const parent = sp.dirname(wh.watchPath);
|
|
34761
34823
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
34762
34824
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
34763
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
34825
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path29, wh, targetPath);
|
|
34764
34826
|
if (this.fsw.closed)
|
|
34765
34827
|
return;
|
|
34766
34828
|
if (targetPath !== void 0) {
|
|
34767
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
34829
|
+
this.fsw._symlinkPaths.set(sp.resolve(path29), targetPath);
|
|
34768
34830
|
}
|
|
34769
34831
|
} else {
|
|
34770
34832
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
34771
34833
|
}
|
|
34772
34834
|
ready();
|
|
34773
34835
|
if (closer)
|
|
34774
|
-
this.fsw._addPathCloser(
|
|
34836
|
+
this.fsw._addPathCloser(path29, closer);
|
|
34775
34837
|
return false;
|
|
34776
34838
|
} catch (error48) {
|
|
34777
34839
|
if (this.fsw._handleError(error48)) {
|
|
34778
34840
|
ready();
|
|
34779
|
-
return
|
|
34841
|
+
return path29;
|
|
34780
34842
|
}
|
|
34781
34843
|
}
|
|
34782
34844
|
}
|
|
@@ -34811,24 +34873,24 @@ function createPattern(matcher) {
|
|
|
34811
34873
|
}
|
|
34812
34874
|
return () => false;
|
|
34813
34875
|
}
|
|
34814
|
-
function normalizePath(
|
|
34815
|
-
if (typeof
|
|
34876
|
+
function normalizePath(path29) {
|
|
34877
|
+
if (typeof path29 !== "string")
|
|
34816
34878
|
throw new Error("string expected");
|
|
34817
|
-
|
|
34818
|
-
|
|
34879
|
+
path29 = sp2.normalize(path29);
|
|
34880
|
+
path29 = path29.replace(/\\/g, "/");
|
|
34819
34881
|
let prepend = false;
|
|
34820
|
-
if (
|
|
34882
|
+
if (path29.startsWith("//"))
|
|
34821
34883
|
prepend = true;
|
|
34822
|
-
|
|
34884
|
+
path29 = path29.replace(DOUBLE_SLASH_RE, "/");
|
|
34823
34885
|
if (prepend)
|
|
34824
|
-
|
|
34825
|
-
return
|
|
34886
|
+
path29 = "/" + path29;
|
|
34887
|
+
return path29;
|
|
34826
34888
|
}
|
|
34827
34889
|
function matchPatterns(patterns, testString, stats) {
|
|
34828
|
-
const
|
|
34890
|
+
const path29 = normalizePath(testString);
|
|
34829
34891
|
for (let index = 0; index < patterns.length; index++) {
|
|
34830
34892
|
const pattern = patterns[index];
|
|
34831
|
-
if (pattern(
|
|
34893
|
+
if (pattern(path29, stats)) {
|
|
34832
34894
|
return true;
|
|
34833
34895
|
}
|
|
34834
34896
|
}
|
|
@@ -34891,19 +34953,19 @@ var init_chokidar = __esm({
|
|
|
34891
34953
|
}
|
|
34892
34954
|
return str;
|
|
34893
34955
|
};
|
|
34894
|
-
normalizePathToUnix = (
|
|
34895
|
-
normalizeIgnored = (cwd = "") => (
|
|
34896
|
-
if (typeof
|
|
34897
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
34956
|
+
normalizePathToUnix = (path29) => toUnix(sp2.normalize(toUnix(path29)));
|
|
34957
|
+
normalizeIgnored = (cwd = "") => (path29) => {
|
|
34958
|
+
if (typeof path29 === "string") {
|
|
34959
|
+
return normalizePathToUnix(sp2.isAbsolute(path29) ? path29 : sp2.join(cwd, path29));
|
|
34898
34960
|
} else {
|
|
34899
|
-
return
|
|
34961
|
+
return path29;
|
|
34900
34962
|
}
|
|
34901
34963
|
};
|
|
34902
|
-
getAbsolutePath = (
|
|
34903
|
-
if (sp2.isAbsolute(
|
|
34904
|
-
return
|
|
34964
|
+
getAbsolutePath = (path29, cwd) => {
|
|
34965
|
+
if (sp2.isAbsolute(path29)) {
|
|
34966
|
+
return path29;
|
|
34905
34967
|
}
|
|
34906
|
-
return sp2.join(cwd,
|
|
34968
|
+
return sp2.join(cwd, path29);
|
|
34907
34969
|
};
|
|
34908
34970
|
EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
34909
34971
|
DirEntry = class {
|
|
@@ -34968,10 +35030,10 @@ var init_chokidar = __esm({
|
|
|
34968
35030
|
dirParts;
|
|
34969
35031
|
followSymlinks;
|
|
34970
35032
|
statMethod;
|
|
34971
|
-
constructor(
|
|
35033
|
+
constructor(path29, follow, fsw) {
|
|
34972
35034
|
this.fsw = fsw;
|
|
34973
|
-
const watchPath =
|
|
34974
|
-
this.path =
|
|
35035
|
+
const watchPath = path29;
|
|
35036
|
+
this.path = path29 = path29.replace(REPLACER_RE, "");
|
|
34975
35037
|
this.watchPath = watchPath;
|
|
34976
35038
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
34977
35039
|
this.dirParts = [];
|
|
@@ -35111,20 +35173,20 @@ var init_chokidar = __esm({
|
|
|
35111
35173
|
this._closePromise = void 0;
|
|
35112
35174
|
let paths = unifyPaths(paths_);
|
|
35113
35175
|
if (cwd) {
|
|
35114
|
-
paths = paths.map((
|
|
35115
|
-
const absPath = getAbsolutePath(
|
|
35176
|
+
paths = paths.map((path29) => {
|
|
35177
|
+
const absPath = getAbsolutePath(path29, cwd);
|
|
35116
35178
|
return absPath;
|
|
35117
35179
|
});
|
|
35118
35180
|
}
|
|
35119
|
-
paths.forEach((
|
|
35120
|
-
this._removeIgnoredPath(
|
|
35181
|
+
paths.forEach((path29) => {
|
|
35182
|
+
this._removeIgnoredPath(path29);
|
|
35121
35183
|
});
|
|
35122
35184
|
this._userIgnored = void 0;
|
|
35123
35185
|
if (!this._readyCount)
|
|
35124
35186
|
this._readyCount = 0;
|
|
35125
35187
|
this._readyCount += paths.length;
|
|
35126
|
-
Promise.all(paths.map(async (
|
|
35127
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
35188
|
+
Promise.all(paths.map(async (path29) => {
|
|
35189
|
+
const res = await this._nodeFsHandler._addToNodeFs(path29, !_internal, void 0, 0, _origAdd);
|
|
35128
35190
|
if (res)
|
|
35129
35191
|
this._emitReady();
|
|
35130
35192
|
return res;
|
|
@@ -35146,17 +35208,17 @@ var init_chokidar = __esm({
|
|
|
35146
35208
|
return this;
|
|
35147
35209
|
const paths = unifyPaths(paths_);
|
|
35148
35210
|
const { cwd } = this.options;
|
|
35149
|
-
paths.forEach((
|
|
35150
|
-
if (!sp2.isAbsolute(
|
|
35211
|
+
paths.forEach((path29) => {
|
|
35212
|
+
if (!sp2.isAbsolute(path29) && !this._closers.has(path29)) {
|
|
35151
35213
|
if (cwd)
|
|
35152
|
-
|
|
35153
|
-
|
|
35214
|
+
path29 = sp2.join(cwd, path29);
|
|
35215
|
+
path29 = sp2.resolve(path29);
|
|
35154
35216
|
}
|
|
35155
|
-
this._closePath(
|
|
35156
|
-
this._addIgnoredPath(
|
|
35157
|
-
if (this._watched.has(
|
|
35217
|
+
this._closePath(path29);
|
|
35218
|
+
this._addIgnoredPath(path29);
|
|
35219
|
+
if (this._watched.has(path29)) {
|
|
35158
35220
|
this._addIgnoredPath({
|
|
35159
|
-
path:
|
|
35221
|
+
path: path29,
|
|
35160
35222
|
recursive: true
|
|
35161
35223
|
});
|
|
35162
35224
|
}
|
|
@@ -35220,38 +35282,38 @@ var init_chokidar = __esm({
|
|
|
35220
35282
|
* @param stats arguments to be passed with event
|
|
35221
35283
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
35222
35284
|
*/
|
|
35223
|
-
async _emit(event,
|
|
35285
|
+
async _emit(event, path29, stats) {
|
|
35224
35286
|
if (this.closed)
|
|
35225
35287
|
return;
|
|
35226
35288
|
const opts = this.options;
|
|
35227
35289
|
if (isWindows)
|
|
35228
|
-
|
|
35290
|
+
path29 = sp2.normalize(path29);
|
|
35229
35291
|
if (opts.cwd)
|
|
35230
|
-
|
|
35231
|
-
const args = [
|
|
35292
|
+
path29 = sp2.relative(opts.cwd, path29);
|
|
35293
|
+
const args = [path29];
|
|
35232
35294
|
if (stats != null)
|
|
35233
35295
|
args.push(stats);
|
|
35234
35296
|
const awf = opts.awaitWriteFinish;
|
|
35235
35297
|
let pw;
|
|
35236
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
35298
|
+
if (awf && (pw = this._pendingWrites.get(path29))) {
|
|
35237
35299
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
35238
35300
|
return this;
|
|
35239
35301
|
}
|
|
35240
35302
|
if (opts.atomic) {
|
|
35241
35303
|
if (event === EVENTS.UNLINK) {
|
|
35242
|
-
this._pendingUnlinks.set(
|
|
35304
|
+
this._pendingUnlinks.set(path29, [event, ...args]);
|
|
35243
35305
|
setTimeout(() => {
|
|
35244
|
-
this._pendingUnlinks.forEach((entry,
|
|
35306
|
+
this._pendingUnlinks.forEach((entry, path30) => {
|
|
35245
35307
|
this.emit(...entry);
|
|
35246
35308
|
this.emit(EVENTS.ALL, ...entry);
|
|
35247
|
-
this._pendingUnlinks.delete(
|
|
35309
|
+
this._pendingUnlinks.delete(path30);
|
|
35248
35310
|
});
|
|
35249
35311
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
35250
35312
|
return this;
|
|
35251
35313
|
}
|
|
35252
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
35314
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path29)) {
|
|
35253
35315
|
event = EVENTS.CHANGE;
|
|
35254
|
-
this._pendingUnlinks.delete(
|
|
35316
|
+
this._pendingUnlinks.delete(path29);
|
|
35255
35317
|
}
|
|
35256
35318
|
}
|
|
35257
35319
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -35269,16 +35331,16 @@ var init_chokidar = __esm({
|
|
|
35269
35331
|
this.emitWithAll(event, args);
|
|
35270
35332
|
}
|
|
35271
35333
|
};
|
|
35272
|
-
this._awaitWriteFinish(
|
|
35334
|
+
this._awaitWriteFinish(path29, awf.stabilityThreshold, event, awfEmit);
|
|
35273
35335
|
return this;
|
|
35274
35336
|
}
|
|
35275
35337
|
if (event === EVENTS.CHANGE) {
|
|
35276
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
35338
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path29, 50);
|
|
35277
35339
|
if (isThrottled)
|
|
35278
35340
|
return this;
|
|
35279
35341
|
}
|
|
35280
35342
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
35281
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
35343
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path29) : path29;
|
|
35282
35344
|
let stats2;
|
|
35283
35345
|
try {
|
|
35284
35346
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -35309,23 +35371,23 @@ var init_chokidar = __esm({
|
|
|
35309
35371
|
* @param timeout duration of time to suppress duplicate actions
|
|
35310
35372
|
* @returns tracking object or false if action should be suppressed
|
|
35311
35373
|
*/
|
|
35312
|
-
_throttle(actionType,
|
|
35374
|
+
_throttle(actionType, path29, timeout) {
|
|
35313
35375
|
if (!this._throttled.has(actionType)) {
|
|
35314
35376
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
35315
35377
|
}
|
|
35316
35378
|
const action = this._throttled.get(actionType);
|
|
35317
35379
|
if (!action)
|
|
35318
35380
|
throw new Error("invalid throttle");
|
|
35319
|
-
const actionPath = action.get(
|
|
35381
|
+
const actionPath = action.get(path29);
|
|
35320
35382
|
if (actionPath) {
|
|
35321
35383
|
actionPath.count++;
|
|
35322
35384
|
return false;
|
|
35323
35385
|
}
|
|
35324
35386
|
let timeoutObject;
|
|
35325
35387
|
const clear = () => {
|
|
35326
|
-
const item = action.get(
|
|
35388
|
+
const item = action.get(path29);
|
|
35327
35389
|
const count = item ? item.count : 0;
|
|
35328
|
-
action.delete(
|
|
35390
|
+
action.delete(path29);
|
|
35329
35391
|
clearTimeout(timeoutObject);
|
|
35330
35392
|
if (item)
|
|
35331
35393
|
clearTimeout(item.timeoutObject);
|
|
@@ -35333,7 +35395,7 @@ var init_chokidar = __esm({
|
|
|
35333
35395
|
};
|
|
35334
35396
|
timeoutObject = setTimeout(clear, timeout);
|
|
35335
35397
|
const thr = { timeoutObject, clear, count: 0 };
|
|
35336
|
-
action.set(
|
|
35398
|
+
action.set(path29, thr);
|
|
35337
35399
|
return thr;
|
|
35338
35400
|
}
|
|
35339
35401
|
_incrReadyCount() {
|
|
@@ -35347,44 +35409,44 @@ var init_chokidar = __esm({
|
|
|
35347
35409
|
* @param event
|
|
35348
35410
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
35349
35411
|
*/
|
|
35350
|
-
_awaitWriteFinish(
|
|
35412
|
+
_awaitWriteFinish(path29, threshold, event, awfEmit) {
|
|
35351
35413
|
const awf = this.options.awaitWriteFinish;
|
|
35352
35414
|
if (typeof awf !== "object")
|
|
35353
35415
|
return;
|
|
35354
35416
|
const pollInterval = awf.pollInterval;
|
|
35355
35417
|
let timeoutHandler;
|
|
35356
|
-
let fullPath =
|
|
35357
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
35358
|
-
fullPath = sp2.join(this.options.cwd,
|
|
35418
|
+
let fullPath = path29;
|
|
35419
|
+
if (this.options.cwd && !sp2.isAbsolute(path29)) {
|
|
35420
|
+
fullPath = sp2.join(this.options.cwd, path29);
|
|
35359
35421
|
}
|
|
35360
35422
|
const now = /* @__PURE__ */ new Date();
|
|
35361
35423
|
const writes = this._pendingWrites;
|
|
35362
35424
|
function awaitWriteFinishFn(prevStat) {
|
|
35363
35425
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
35364
|
-
if (err || !writes.has(
|
|
35426
|
+
if (err || !writes.has(path29)) {
|
|
35365
35427
|
if (err && err.code !== "ENOENT")
|
|
35366
35428
|
awfEmit(err);
|
|
35367
35429
|
return;
|
|
35368
35430
|
}
|
|
35369
35431
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
35370
35432
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
35371
|
-
writes.get(
|
|
35433
|
+
writes.get(path29).lastChange = now2;
|
|
35372
35434
|
}
|
|
35373
|
-
const pw = writes.get(
|
|
35435
|
+
const pw = writes.get(path29);
|
|
35374
35436
|
const df = now2 - pw.lastChange;
|
|
35375
35437
|
if (df >= threshold) {
|
|
35376
|
-
writes.delete(
|
|
35438
|
+
writes.delete(path29);
|
|
35377
35439
|
awfEmit(void 0, curStat);
|
|
35378
35440
|
} else {
|
|
35379
35441
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
35380
35442
|
}
|
|
35381
35443
|
});
|
|
35382
35444
|
}
|
|
35383
|
-
if (!writes.has(
|
|
35384
|
-
writes.set(
|
|
35445
|
+
if (!writes.has(path29)) {
|
|
35446
|
+
writes.set(path29, {
|
|
35385
35447
|
lastChange: now,
|
|
35386
35448
|
cancelWait: () => {
|
|
35387
|
-
writes.delete(
|
|
35449
|
+
writes.delete(path29);
|
|
35388
35450
|
clearTimeout(timeoutHandler);
|
|
35389
35451
|
return event;
|
|
35390
35452
|
}
|
|
@@ -35395,8 +35457,8 @@ var init_chokidar = __esm({
|
|
|
35395
35457
|
/**
|
|
35396
35458
|
* Determines whether user has asked to ignore this path.
|
|
35397
35459
|
*/
|
|
35398
|
-
_isIgnored(
|
|
35399
|
-
if (this.options.atomic && DOT_RE.test(
|
|
35460
|
+
_isIgnored(path29, stats) {
|
|
35461
|
+
if (this.options.atomic && DOT_RE.test(path29))
|
|
35400
35462
|
return true;
|
|
35401
35463
|
if (!this._userIgnored) {
|
|
35402
35464
|
const { cwd } = this.options;
|
|
@@ -35406,17 +35468,17 @@ var init_chokidar = __esm({
|
|
|
35406
35468
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
35407
35469
|
this._userIgnored = anymatch(list, void 0);
|
|
35408
35470
|
}
|
|
35409
|
-
return this._userIgnored(
|
|
35471
|
+
return this._userIgnored(path29, stats);
|
|
35410
35472
|
}
|
|
35411
|
-
_isntIgnored(
|
|
35412
|
-
return !this._isIgnored(
|
|
35473
|
+
_isntIgnored(path29, stat4) {
|
|
35474
|
+
return !this._isIgnored(path29, stat4);
|
|
35413
35475
|
}
|
|
35414
35476
|
/**
|
|
35415
35477
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
35416
35478
|
* @param path file or directory pattern being watched
|
|
35417
35479
|
*/
|
|
35418
|
-
_getWatchHelpers(
|
|
35419
|
-
return new WatchHelper(
|
|
35480
|
+
_getWatchHelpers(path29) {
|
|
35481
|
+
return new WatchHelper(path29, this.options.followSymlinks, this);
|
|
35420
35482
|
}
|
|
35421
35483
|
// Directory helpers
|
|
35422
35484
|
// -----------------
|
|
@@ -35448,63 +35510,63 @@ var init_chokidar = __esm({
|
|
|
35448
35510
|
* @param item base path of item/directory
|
|
35449
35511
|
*/
|
|
35450
35512
|
_remove(directory, item, isDirectory) {
|
|
35451
|
-
const
|
|
35452
|
-
const fullPath = sp2.resolve(
|
|
35453
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
35454
|
-
if (!this._throttle("remove",
|
|
35513
|
+
const path29 = sp2.join(directory, item);
|
|
35514
|
+
const fullPath = sp2.resolve(path29);
|
|
35515
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path29) || this._watched.has(fullPath);
|
|
35516
|
+
if (!this._throttle("remove", path29, 100))
|
|
35455
35517
|
return;
|
|
35456
35518
|
if (!isDirectory && this._watched.size === 1) {
|
|
35457
35519
|
this.add(directory, item, true);
|
|
35458
35520
|
}
|
|
35459
|
-
const wp = this._getWatchedDir(
|
|
35521
|
+
const wp = this._getWatchedDir(path29);
|
|
35460
35522
|
const nestedDirectoryChildren = wp.getChildren();
|
|
35461
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
35523
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path29, nested));
|
|
35462
35524
|
const parent = this._getWatchedDir(directory);
|
|
35463
35525
|
const wasTracked = parent.has(item);
|
|
35464
35526
|
parent.remove(item);
|
|
35465
35527
|
if (this._symlinkPaths.has(fullPath)) {
|
|
35466
35528
|
this._symlinkPaths.delete(fullPath);
|
|
35467
35529
|
}
|
|
35468
|
-
let relPath =
|
|
35530
|
+
let relPath = path29;
|
|
35469
35531
|
if (this.options.cwd)
|
|
35470
|
-
relPath = sp2.relative(this.options.cwd,
|
|
35532
|
+
relPath = sp2.relative(this.options.cwd, path29);
|
|
35471
35533
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
35472
35534
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
35473
35535
|
if (event === EVENTS.ADD)
|
|
35474
35536
|
return;
|
|
35475
35537
|
}
|
|
35476
|
-
this._watched.delete(
|
|
35538
|
+
this._watched.delete(path29);
|
|
35477
35539
|
this._watched.delete(fullPath);
|
|
35478
35540
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
35479
|
-
if (wasTracked && !this._isIgnored(
|
|
35480
|
-
this._emit(eventName,
|
|
35481
|
-
this._closePath(
|
|
35541
|
+
if (wasTracked && !this._isIgnored(path29))
|
|
35542
|
+
this._emit(eventName, path29);
|
|
35543
|
+
this._closePath(path29);
|
|
35482
35544
|
}
|
|
35483
35545
|
/**
|
|
35484
35546
|
* Closes all watchers for a path
|
|
35485
35547
|
*/
|
|
35486
|
-
_closePath(
|
|
35487
|
-
this._closeFile(
|
|
35488
|
-
const dir = sp2.dirname(
|
|
35489
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
35548
|
+
_closePath(path29) {
|
|
35549
|
+
this._closeFile(path29);
|
|
35550
|
+
const dir = sp2.dirname(path29);
|
|
35551
|
+
this._getWatchedDir(dir).remove(sp2.basename(path29));
|
|
35490
35552
|
}
|
|
35491
35553
|
/**
|
|
35492
35554
|
* Closes only file-specific watchers
|
|
35493
35555
|
*/
|
|
35494
|
-
_closeFile(
|
|
35495
|
-
const closers = this._closers.get(
|
|
35556
|
+
_closeFile(path29) {
|
|
35557
|
+
const closers = this._closers.get(path29);
|
|
35496
35558
|
if (!closers)
|
|
35497
35559
|
return;
|
|
35498
35560
|
closers.forEach((closer) => closer());
|
|
35499
|
-
this._closers.delete(
|
|
35561
|
+
this._closers.delete(path29);
|
|
35500
35562
|
}
|
|
35501
|
-
_addPathCloser(
|
|
35563
|
+
_addPathCloser(path29, closer) {
|
|
35502
35564
|
if (!closer)
|
|
35503
35565
|
return;
|
|
35504
|
-
let list = this._closers.get(
|
|
35566
|
+
let list = this._closers.get(path29);
|
|
35505
35567
|
if (!list) {
|
|
35506
35568
|
list = [];
|
|
35507
|
-
this._closers.set(
|
|
35569
|
+
this._closers.set(path29, list);
|
|
35508
35570
|
}
|
|
35509
35571
|
list.push(closer);
|
|
35510
35572
|
}
|
|
@@ -35765,13 +35827,13 @@ var init_provider_schema = __esm({
|
|
|
35765
35827
|
});
|
|
35766
35828
|
|
|
35767
35829
|
// ../../oss/packages/daemon-core/src/providers/provider-loader.ts
|
|
35768
|
-
var
|
|
35830
|
+
var fs7, path14, os16, ProviderLoader;
|
|
35769
35831
|
var init_provider_loader = __esm({
|
|
35770
35832
|
"../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
|
|
35771
35833
|
"use strict";
|
|
35772
|
-
|
|
35773
|
-
|
|
35774
|
-
|
|
35834
|
+
fs7 = __toESM(require("fs"));
|
|
35835
|
+
path14 = __toESM(require("path"));
|
|
35836
|
+
os16 = __toESM(require("os"));
|
|
35775
35837
|
init_chokidar();
|
|
35776
35838
|
init_ide_detector();
|
|
35777
35839
|
init_logger();
|
|
@@ -35805,9 +35867,9 @@ var init_provider_loader = __esm({
|
|
|
35805
35867
|
static siblingStderrLogged = /* @__PURE__ */ new Set();
|
|
35806
35868
|
static looksLikeProviderRoot(candidate) {
|
|
35807
35869
|
try {
|
|
35808
|
-
if (!
|
|
35870
|
+
if (!fs7.existsSync(candidate) || !fs7.statSync(candidate).isDirectory()) return false;
|
|
35809
35871
|
return ["ide", "extension", "cli", "acp"].some(
|
|
35810
|
-
(category) =>
|
|
35872
|
+
(category) => fs7.existsSync(path14.join(candidate, category))
|
|
35811
35873
|
);
|
|
35812
35874
|
} catch {
|
|
35813
35875
|
return false;
|
|
@@ -35815,20 +35877,20 @@ var init_provider_loader = __esm({
|
|
|
35815
35877
|
}
|
|
35816
35878
|
static hasProviderRootMarker(candidate) {
|
|
35817
35879
|
try {
|
|
35818
|
-
return
|
|
35880
|
+
return fs7.existsSync(path14.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
|
|
35819
35881
|
} catch {
|
|
35820
35882
|
return false;
|
|
35821
35883
|
}
|
|
35822
35884
|
}
|
|
35823
35885
|
detectDefaultUserDir() {
|
|
35824
|
-
const fallback2 =
|
|
35886
|
+
const fallback2 = path14.join(os16.homedir(), ".adhdev", "providers");
|
|
35825
35887
|
const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
|
|
35826
35888
|
const visited = /* @__PURE__ */ new Set();
|
|
35827
35889
|
for (const start of this.probeStarts) {
|
|
35828
|
-
let current =
|
|
35890
|
+
let current = path14.resolve(start);
|
|
35829
35891
|
while (!visited.has(current)) {
|
|
35830
35892
|
visited.add(current);
|
|
35831
|
-
const siblingCandidate =
|
|
35893
|
+
const siblingCandidate = path14.join(path14.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
|
|
35832
35894
|
if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
|
|
35833
35895
|
const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
|
|
35834
35896
|
if (envOptIn || hasMarker) {
|
|
@@ -35850,7 +35912,7 @@ var init_provider_loader = __esm({
|
|
|
35850
35912
|
return { path: siblingCandidate, source };
|
|
35851
35913
|
}
|
|
35852
35914
|
}
|
|
35853
|
-
const parent =
|
|
35915
|
+
const parent = path14.dirname(current);
|
|
35854
35916
|
if (parent === current) break;
|
|
35855
35917
|
current = parent;
|
|
35856
35918
|
}
|
|
@@ -35860,11 +35922,11 @@ var init_provider_loader = __esm({
|
|
|
35860
35922
|
constructor(options) {
|
|
35861
35923
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
35862
35924
|
this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
|
|
35863
|
-
this.defaultProvidersDir =
|
|
35925
|
+
this.defaultProvidersDir = path14.join(os16.homedir(), ".adhdev", "providers");
|
|
35864
35926
|
const detected = this.detectDefaultUserDir();
|
|
35865
35927
|
this.userDir = detected.path;
|
|
35866
35928
|
this.userDirSource = detected.source;
|
|
35867
|
-
this.upstreamDir =
|
|
35929
|
+
this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
|
|
35868
35930
|
this.disableUpstream = false;
|
|
35869
35931
|
this.applySourceConfig({
|
|
35870
35932
|
userDir: options?.userDir,
|
|
@@ -35923,7 +35985,7 @@ var init_provider_loader = __esm({
|
|
|
35923
35985
|
this.userDir = detected.path;
|
|
35924
35986
|
this.userDirSource = detected.source;
|
|
35925
35987
|
}
|
|
35926
|
-
this.upstreamDir =
|
|
35988
|
+
this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
|
|
35927
35989
|
this.disableUpstream = this.sourceMode === "no-upstream";
|
|
35928
35990
|
if (this.explicitProviderDir) {
|
|
35929
35991
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
@@ -35937,7 +35999,7 @@ var init_provider_loader = __esm({
|
|
|
35937
35999
|
* Canonical provider directory shape for a given root.
|
|
35938
36000
|
*/
|
|
35939
36001
|
getProviderDir(root, category, type) {
|
|
35940
|
-
return
|
|
36002
|
+
return path14.join(root, category, type);
|
|
35941
36003
|
}
|
|
35942
36004
|
/**
|
|
35943
36005
|
* Canonical user override directory for a provider.
|
|
@@ -35964,7 +36026,7 @@ var init_provider_loader = __esm({
|
|
|
35964
36026
|
resolveProviderFile(type, ...segments) {
|
|
35965
36027
|
const dir = this.findProviderDirInternal(type);
|
|
35966
36028
|
if (!dir) return null;
|
|
35967
|
-
return
|
|
36029
|
+
return path14.join(dir, ...segments);
|
|
35968
36030
|
}
|
|
35969
36031
|
/**
|
|
35970
36032
|
* Load all providers (3-tier priority)
|
|
@@ -35977,7 +36039,7 @@ var init_provider_loader = __esm({
|
|
|
35977
36039
|
this.providers.clear();
|
|
35978
36040
|
this.providerAvailability.clear();
|
|
35979
36041
|
let upstreamCount = 0;
|
|
35980
|
-
if (!this.disableUpstream &&
|
|
36042
|
+
if (!this.disableUpstream && fs7.existsSync(this.upstreamDir)) {
|
|
35981
36043
|
upstreamCount = this.loadDir(this.upstreamDir);
|
|
35982
36044
|
if (upstreamCount > 0) {
|
|
35983
36045
|
this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
|
|
@@ -35985,7 +36047,7 @@ var init_provider_loader = __esm({
|
|
|
35985
36047
|
} else if (this.disableUpstream) {
|
|
35986
36048
|
this.log("Upstream loading disabled (sourceMode=no-upstream)");
|
|
35987
36049
|
}
|
|
35988
|
-
if (
|
|
36050
|
+
if (fs7.existsSync(this.userDir)) {
|
|
35989
36051
|
const userCount = this.loadDir(this.userDir, [".upstream"]);
|
|
35990
36052
|
if (userCount > 0) {
|
|
35991
36053
|
this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
|
|
@@ -36000,10 +36062,10 @@ var init_provider_loader = __esm({
|
|
|
36000
36062
|
* Check if upstream directory exists and has providers.
|
|
36001
36063
|
*/
|
|
36002
36064
|
hasUpstream() {
|
|
36003
|
-
if (!
|
|
36065
|
+
if (!fs7.existsSync(this.upstreamDir)) return false;
|
|
36004
36066
|
try {
|
|
36005
|
-
return
|
|
36006
|
-
(d) =>
|
|
36067
|
+
return fs7.readdirSync(this.upstreamDir).some(
|
|
36068
|
+
(d) => fs7.statSync(path14.join(this.upstreamDir, d)).isDirectory()
|
|
36007
36069
|
);
|
|
36008
36070
|
} catch {
|
|
36009
36071
|
return false;
|
|
@@ -36500,8 +36562,8 @@ var init_provider_loader = __esm({
|
|
|
36500
36562
|
resolved._resolvedScriptDir = entry.scriptDir;
|
|
36501
36563
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
36502
36564
|
if (providerDir) {
|
|
36503
|
-
const fullDir =
|
|
36504
|
-
resolved._resolvedScriptsPath =
|
|
36565
|
+
const fullDir = path14.join(providerDir, entry.scriptDir);
|
|
36566
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
36505
36567
|
}
|
|
36506
36568
|
matched = true;
|
|
36507
36569
|
}
|
|
@@ -36516,8 +36578,8 @@ var init_provider_loader = __esm({
|
|
|
36516
36578
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
36517
36579
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
36518
36580
|
if (providerDir) {
|
|
36519
|
-
const fullDir =
|
|
36520
|
-
resolved._resolvedScriptsPath =
|
|
36581
|
+
const fullDir = path14.join(providerDir, base.defaultScriptDir);
|
|
36582
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
36521
36583
|
}
|
|
36522
36584
|
}
|
|
36523
36585
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -36534,8 +36596,8 @@ var init_provider_loader = __esm({
|
|
|
36534
36596
|
resolved._resolvedScriptDir = dirOverride;
|
|
36535
36597
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
36536
36598
|
if (providerDir) {
|
|
36537
|
-
const fullDir =
|
|
36538
|
-
resolved._resolvedScriptsPath =
|
|
36599
|
+
const fullDir = path14.join(providerDir, dirOverride);
|
|
36600
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
36539
36601
|
}
|
|
36540
36602
|
}
|
|
36541
36603
|
} else if (override.scripts) {
|
|
@@ -36551,8 +36613,8 @@ var init_provider_loader = __esm({
|
|
|
36551
36613
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
36552
36614
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
36553
36615
|
if (providerDir) {
|
|
36554
|
-
const fullDir =
|
|
36555
|
-
resolved._resolvedScriptsPath =
|
|
36616
|
+
const fullDir = path14.join(providerDir, base.defaultScriptDir);
|
|
36617
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
|
|
36556
36618
|
}
|
|
36557
36619
|
}
|
|
36558
36620
|
}
|
|
@@ -36584,15 +36646,15 @@ var init_provider_loader = __esm({
|
|
|
36584
36646
|
this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
|
|
36585
36647
|
return null;
|
|
36586
36648
|
}
|
|
36587
|
-
const dir =
|
|
36588
|
-
if (!
|
|
36649
|
+
const dir = path14.join(providerDir, scriptDir);
|
|
36650
|
+
if (!fs7.existsSync(dir)) {
|
|
36589
36651
|
this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
36590
36652
|
return null;
|
|
36591
36653
|
}
|
|
36592
36654
|
const cached2 = this.scriptsCache.get(dir);
|
|
36593
36655
|
if (cached2) return cached2;
|
|
36594
|
-
const scriptsJs =
|
|
36595
|
-
if (
|
|
36656
|
+
const scriptsJs = path14.join(dir, "scripts.js");
|
|
36657
|
+
if (fs7.existsSync(scriptsJs)) {
|
|
36596
36658
|
try {
|
|
36597
36659
|
delete require.cache[require.resolve(scriptsJs)];
|
|
36598
36660
|
const loaded = require(scriptsJs);
|
|
@@ -36613,9 +36675,9 @@ var init_provider_loader = __esm({
|
|
|
36613
36675
|
watch() {
|
|
36614
36676
|
this.stopWatch();
|
|
36615
36677
|
const watchDir = (dir) => {
|
|
36616
|
-
if (!
|
|
36678
|
+
if (!fs7.existsSync(dir)) {
|
|
36617
36679
|
try {
|
|
36618
|
-
|
|
36680
|
+
fs7.mkdirSync(dir, { recursive: true });
|
|
36619
36681
|
} catch {
|
|
36620
36682
|
return;
|
|
36621
36683
|
}
|
|
@@ -36633,7 +36695,7 @@ var init_provider_loader = __esm({
|
|
|
36633
36695
|
return;
|
|
36634
36696
|
}
|
|
36635
36697
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
36636
|
-
this.log(`File changed: ${
|
|
36698
|
+
this.log(`File changed: ${path14.basename(filePath)}, reloading...`);
|
|
36637
36699
|
this.reload();
|
|
36638
36700
|
}
|
|
36639
36701
|
};
|
|
@@ -36688,12 +36750,12 @@ var init_provider_loader = __esm({
|
|
|
36688
36750
|
}
|
|
36689
36751
|
const https = require("https");
|
|
36690
36752
|
const { execSync: execSync7 } = require("child_process");
|
|
36691
|
-
const metaPath =
|
|
36753
|
+
const metaPath = path14.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
36692
36754
|
let prevEtag = "";
|
|
36693
36755
|
let prevTimestamp = 0;
|
|
36694
36756
|
try {
|
|
36695
|
-
if (
|
|
36696
|
-
const meta3 = JSON.parse(
|
|
36757
|
+
if (fs7.existsSync(metaPath)) {
|
|
36758
|
+
const meta3 = JSON.parse(fs7.readFileSync(metaPath, "utf-8"));
|
|
36697
36759
|
prevEtag = meta3.etag || "";
|
|
36698
36760
|
prevTimestamp = meta3.timestamp || 0;
|
|
36699
36761
|
}
|
|
@@ -36748,39 +36810,39 @@ var init_provider_loader = __esm({
|
|
|
36748
36810
|
return { updated: false };
|
|
36749
36811
|
}
|
|
36750
36812
|
this.log("Downloading latest providers from GitHub...");
|
|
36751
|
-
const tmpTar =
|
|
36752
|
-
const tmpExtract =
|
|
36813
|
+
const tmpTar = path14.join(os16.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
36814
|
+
const tmpExtract = path14.join(os16.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
36753
36815
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
36754
|
-
|
|
36816
|
+
fs7.mkdirSync(tmpExtract, { recursive: true });
|
|
36755
36817
|
execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
36756
|
-
const extracted =
|
|
36818
|
+
const extracted = fs7.readdirSync(tmpExtract);
|
|
36757
36819
|
const rootDir = extracted.find(
|
|
36758
|
-
(d) =>
|
|
36820
|
+
(d) => fs7.statSync(path14.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
36759
36821
|
);
|
|
36760
36822
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
36761
|
-
const sourceDir =
|
|
36823
|
+
const sourceDir = path14.join(tmpExtract, rootDir);
|
|
36762
36824
|
const backupDir = this.upstreamDir + ".bak";
|
|
36763
|
-
if (
|
|
36764
|
-
if (
|
|
36765
|
-
|
|
36825
|
+
if (fs7.existsSync(this.upstreamDir)) {
|
|
36826
|
+
if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
|
|
36827
|
+
fs7.renameSync(this.upstreamDir, backupDir);
|
|
36766
36828
|
}
|
|
36767
36829
|
try {
|
|
36768
36830
|
this.copyDirRecursive(sourceDir, this.upstreamDir);
|
|
36769
36831
|
this.writeMeta(metaPath, etag || `ts-${Date.now()}`, Date.now());
|
|
36770
|
-
if (
|
|
36832
|
+
if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
|
|
36771
36833
|
} catch (e) {
|
|
36772
|
-
if (
|
|
36773
|
-
if (
|
|
36774
|
-
|
|
36834
|
+
if (fs7.existsSync(backupDir)) {
|
|
36835
|
+
if (fs7.existsSync(this.upstreamDir)) fs7.rmSync(this.upstreamDir, { recursive: true, force: true });
|
|
36836
|
+
fs7.renameSync(backupDir, this.upstreamDir);
|
|
36775
36837
|
}
|
|
36776
36838
|
throw e;
|
|
36777
36839
|
}
|
|
36778
36840
|
try {
|
|
36779
|
-
|
|
36841
|
+
fs7.rmSync(tmpTar, { force: true });
|
|
36780
36842
|
} catch {
|
|
36781
36843
|
}
|
|
36782
36844
|
try {
|
|
36783
|
-
|
|
36845
|
+
fs7.rmSync(tmpExtract, { recursive: true, force: true });
|
|
36784
36846
|
} catch {
|
|
36785
36847
|
}
|
|
36786
36848
|
const upstreamCount = this.countProviders(this.upstreamDir);
|
|
@@ -36812,7 +36874,7 @@ var init_provider_loader = __esm({
|
|
|
36812
36874
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
36813
36875
|
return;
|
|
36814
36876
|
}
|
|
36815
|
-
const ws =
|
|
36877
|
+
const ws = fs7.createWriteStream(destPath);
|
|
36816
36878
|
res.pipe(ws);
|
|
36817
36879
|
ws.on("finish", () => {
|
|
36818
36880
|
ws.close();
|
|
@@ -36831,22 +36893,22 @@ var init_provider_loader = __esm({
|
|
|
36831
36893
|
}
|
|
36832
36894
|
/** Recursive directory copy */
|
|
36833
36895
|
copyDirRecursive(src, dest) {
|
|
36834
|
-
|
|
36835
|
-
for (const entry of
|
|
36836
|
-
const srcPath =
|
|
36837
|
-
const destPath =
|
|
36896
|
+
fs7.mkdirSync(dest, { recursive: true });
|
|
36897
|
+
for (const entry of fs7.readdirSync(src, { withFileTypes: true })) {
|
|
36898
|
+
const srcPath = path14.join(src, entry.name);
|
|
36899
|
+
const destPath = path14.join(dest, entry.name);
|
|
36838
36900
|
if (entry.isDirectory()) {
|
|
36839
36901
|
this.copyDirRecursive(srcPath, destPath);
|
|
36840
36902
|
} else {
|
|
36841
|
-
|
|
36903
|
+
fs7.copyFileSync(srcPath, destPath);
|
|
36842
36904
|
}
|
|
36843
36905
|
}
|
|
36844
36906
|
}
|
|
36845
36907
|
/** .meta.json save */
|
|
36846
36908
|
writeMeta(metaPath, etag, timestamp) {
|
|
36847
36909
|
try {
|
|
36848
|
-
|
|
36849
|
-
|
|
36910
|
+
fs7.mkdirSync(path14.dirname(metaPath), { recursive: true });
|
|
36911
|
+
fs7.writeFileSync(metaPath, JSON.stringify({
|
|
36850
36912
|
etag,
|
|
36851
36913
|
timestamp,
|
|
36852
36914
|
lastCheck: new Date(timestamp).toISOString(),
|
|
@@ -36857,12 +36919,12 @@ var init_provider_loader = __esm({
|
|
|
36857
36919
|
}
|
|
36858
36920
|
/** Count provider files (provider.js or provider.json) */
|
|
36859
36921
|
countProviders(dir) {
|
|
36860
|
-
if (!
|
|
36922
|
+
if (!fs7.existsSync(dir)) return 0;
|
|
36861
36923
|
let count = 0;
|
|
36862
36924
|
const scan = (d) => {
|
|
36863
36925
|
try {
|
|
36864
|
-
for (const entry of
|
|
36865
|
-
if (entry.isDirectory()) scan(
|
|
36926
|
+
for (const entry of fs7.readdirSync(d, { withFileTypes: true })) {
|
|
36927
|
+
if (entry.isDirectory()) scan(path14.join(d, entry.name));
|
|
36866
36928
|
else if (entry.name === "provider.json") count++;
|
|
36867
36929
|
}
|
|
36868
36930
|
} catch {
|
|
@@ -37088,19 +37150,19 @@ var init_provider_loader = __esm({
|
|
|
37088
37150
|
const cat = provider.category;
|
|
37089
37151
|
const searchRoots = this.getProviderRoots();
|
|
37090
37152
|
for (const root of searchRoots) {
|
|
37091
|
-
if (!
|
|
37153
|
+
if (!fs7.existsSync(root)) continue;
|
|
37092
37154
|
const candidate = this.getProviderDir(root, cat, type);
|
|
37093
|
-
if (
|
|
37094
|
-
const catDir =
|
|
37095
|
-
if (
|
|
37155
|
+
if (fs7.existsSync(path14.join(candidate, "provider.json"))) return candidate;
|
|
37156
|
+
const catDir = path14.join(root, cat);
|
|
37157
|
+
if (fs7.existsSync(catDir)) {
|
|
37096
37158
|
try {
|
|
37097
|
-
for (const entry of
|
|
37159
|
+
for (const entry of fs7.readdirSync(catDir, { withFileTypes: true })) {
|
|
37098
37160
|
if (!entry.isDirectory()) continue;
|
|
37099
|
-
const jsonPath =
|
|
37100
|
-
if (
|
|
37161
|
+
const jsonPath = path14.join(catDir, entry.name, "provider.json");
|
|
37162
|
+
if (fs7.existsSync(jsonPath)) {
|
|
37101
37163
|
try {
|
|
37102
|
-
const data = JSON.parse(
|
|
37103
|
-
if (data.type === type) return
|
|
37164
|
+
const data = JSON.parse(fs7.readFileSync(jsonPath, "utf-8"));
|
|
37165
|
+
if (data.type === type) return path14.join(catDir, entry.name);
|
|
37104
37166
|
} catch {
|
|
37105
37167
|
}
|
|
37106
37168
|
}
|
|
@@ -37117,8 +37179,8 @@ var init_provider_loader = __esm({
|
|
|
37117
37179
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
37118
37180
|
*/
|
|
37119
37181
|
buildScriptWrappersFromDir(dir) {
|
|
37120
|
-
const scriptsJs =
|
|
37121
|
-
if (
|
|
37182
|
+
const scriptsJs = path14.join(dir, "scripts.js");
|
|
37183
|
+
if (fs7.existsSync(scriptsJs)) {
|
|
37122
37184
|
try {
|
|
37123
37185
|
delete require.cache[require.resolve(scriptsJs)];
|
|
37124
37186
|
return require(scriptsJs);
|
|
@@ -37128,13 +37190,13 @@ var init_provider_loader = __esm({
|
|
|
37128
37190
|
const toCamel = (name) => name.replace(/_([a-z])/g, (_2, c) => c.toUpperCase());
|
|
37129
37191
|
const result = {};
|
|
37130
37192
|
try {
|
|
37131
|
-
for (const file2 of
|
|
37193
|
+
for (const file2 of fs7.readdirSync(dir)) {
|
|
37132
37194
|
if (!file2.endsWith(".js")) continue;
|
|
37133
37195
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
37134
|
-
const filePath =
|
|
37196
|
+
const filePath = path14.join(dir, file2);
|
|
37135
37197
|
result[scriptName] = (...args) => {
|
|
37136
37198
|
try {
|
|
37137
|
-
let content =
|
|
37199
|
+
let content = fs7.readFileSync(filePath, "utf-8");
|
|
37138
37200
|
if (args[0] && typeof args[0] === "object") {
|
|
37139
37201
|
for (const [key, val] of Object.entries(args[0])) {
|
|
37140
37202
|
let v = val;
|
|
@@ -37180,20 +37242,20 @@ var init_provider_loader = __esm({
|
|
|
37180
37242
|
* Structure: dir/category/agent-name/provider.{json,js}
|
|
37181
37243
|
*/
|
|
37182
37244
|
loadDir(dir, excludeDirs) {
|
|
37183
|
-
if (!
|
|
37245
|
+
if (!fs7.existsSync(dir)) return 0;
|
|
37184
37246
|
let count = 0;
|
|
37185
37247
|
const scan = (d) => {
|
|
37186
37248
|
let entries;
|
|
37187
37249
|
try {
|
|
37188
|
-
entries =
|
|
37250
|
+
entries = fs7.readdirSync(d, { withFileTypes: true });
|
|
37189
37251
|
} catch {
|
|
37190
37252
|
return;
|
|
37191
37253
|
}
|
|
37192
37254
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
37193
37255
|
if (hasJson) {
|
|
37194
|
-
const jsonPath =
|
|
37256
|
+
const jsonPath = path14.join(d, "provider.json");
|
|
37195
37257
|
try {
|
|
37196
|
-
const raw =
|
|
37258
|
+
const raw = fs7.readFileSync(jsonPath, "utf-8");
|
|
37197
37259
|
const mod = JSON.parse(raw);
|
|
37198
37260
|
if (typeof mod.extensionIdPattern === "string") {
|
|
37199
37261
|
const flags = mod.extensionIdPattern_flags || "";
|
|
@@ -37212,8 +37274,8 @@ var init_provider_loader = __esm({
|
|
|
37212
37274
|
this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
|
|
37213
37275
|
} else {
|
|
37214
37276
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
37215
|
-
const scriptsPath =
|
|
37216
|
-
if (!hasCompatibility &&
|
|
37277
|
+
const scriptsPath = path14.join(d, "scripts.js");
|
|
37278
|
+
if (!hasCompatibility && fs7.existsSync(scriptsPath)) {
|
|
37217
37279
|
try {
|
|
37218
37280
|
delete require.cache[require.resolve(scriptsPath)];
|
|
37219
37281
|
const scripts = require(scriptsPath);
|
|
@@ -37238,7 +37300,7 @@ var init_provider_loader = __esm({
|
|
|
37238
37300
|
if (!entry.isDirectory()) continue;
|
|
37239
37301
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
37240
37302
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
37241
|
-
scan(
|
|
37303
|
+
scan(path14.join(d, entry.name));
|
|
37242
37304
|
}
|
|
37243
37305
|
}
|
|
37244
37306
|
};
|
|
@@ -37434,7 +37496,7 @@ async function isCdpActive(port) {
|
|
|
37434
37496
|
});
|
|
37435
37497
|
}
|
|
37436
37498
|
async function killIdeProcess(ideId) {
|
|
37437
|
-
const plat =
|
|
37499
|
+
const plat = os17.platform();
|
|
37438
37500
|
const appName = getMacAppIdentifiers()[ideId];
|
|
37439
37501
|
const winProcesses = getWinProcessNames()[ideId];
|
|
37440
37502
|
try {
|
|
@@ -37495,7 +37557,7 @@ async function killIdeProcess(ideId) {
|
|
|
37495
37557
|
}
|
|
37496
37558
|
}
|
|
37497
37559
|
function isIdeRunning(ideId) {
|
|
37498
|
-
const plat =
|
|
37560
|
+
const plat = os17.platform();
|
|
37499
37561
|
try {
|
|
37500
37562
|
if (plat === "darwin") {
|
|
37501
37563
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -37550,7 +37612,7 @@ function isIdeRunning(ideId) {
|
|
|
37550
37612
|
}
|
|
37551
37613
|
}
|
|
37552
37614
|
function detectCurrentWorkspace(ideId) {
|
|
37553
|
-
const plat =
|
|
37615
|
+
const plat = os17.platform();
|
|
37554
37616
|
if (plat === "darwin") {
|
|
37555
37617
|
try {
|
|
37556
37618
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -37565,17 +37627,17 @@ function detectCurrentWorkspace(ideId) {
|
|
|
37565
37627
|
}
|
|
37566
37628
|
} else if (plat === "win32") {
|
|
37567
37629
|
try {
|
|
37568
|
-
const
|
|
37630
|
+
const fs20 = require("fs");
|
|
37569
37631
|
const appNameMap = getMacAppIdentifiers();
|
|
37570
37632
|
const appName = appNameMap[ideId];
|
|
37571
37633
|
if (appName) {
|
|
37572
|
-
const storagePath =
|
|
37573
|
-
process.env.APPDATA ||
|
|
37634
|
+
const storagePath = path15.join(
|
|
37635
|
+
process.env.APPDATA || path15.join(os17.homedir(), "AppData", "Roaming"),
|
|
37574
37636
|
appName,
|
|
37575
37637
|
"storage.json"
|
|
37576
37638
|
);
|
|
37577
|
-
if (
|
|
37578
|
-
const data = JSON.parse(
|
|
37639
|
+
if (fs20.existsSync(storagePath)) {
|
|
37640
|
+
const data = JSON.parse(fs20.readFileSync(storagePath, "utf-8"));
|
|
37579
37641
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
37580
37642
|
if (workspaces.length > 0) {
|
|
37581
37643
|
const recent = workspaces[0];
|
|
@@ -37592,7 +37654,7 @@ function detectCurrentWorkspace(ideId) {
|
|
|
37592
37654
|
return void 0;
|
|
37593
37655
|
}
|
|
37594
37656
|
async function launchWithCdp(options = {}) {
|
|
37595
|
-
const platform12 =
|
|
37657
|
+
const platform12 = os17.platform();
|
|
37596
37658
|
let targetIde;
|
|
37597
37659
|
const ides = await detectIDEs(getProviderLoader());
|
|
37598
37660
|
if (options.ideId) {
|
|
@@ -37741,14 +37803,14 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
37741
37803
|
function getAvailableIdeIds() {
|
|
37742
37804
|
return getProviderLoader().getAvailableIdeTypes();
|
|
37743
37805
|
}
|
|
37744
|
-
var import_child_process7, net2,
|
|
37806
|
+
var import_child_process7, net2, os17, path15, _providerLoader;
|
|
37745
37807
|
var init_launch = __esm({
|
|
37746
37808
|
"../../oss/packages/daemon-core/src/launch.ts"() {
|
|
37747
37809
|
"use strict";
|
|
37748
37810
|
import_child_process7 = require("child_process");
|
|
37749
37811
|
net2 = __toESM(require("net"));
|
|
37750
|
-
|
|
37751
|
-
|
|
37812
|
+
os17 = __toESM(require("os"));
|
|
37813
|
+
path15 = __toESM(require("path"));
|
|
37752
37814
|
init_ide_detector();
|
|
37753
37815
|
init_provider_loader();
|
|
37754
37816
|
init_macos_app_process();
|
|
@@ -37780,13 +37842,13 @@ function checkRotation() {
|
|
|
37780
37842
|
const today = getDateStr2();
|
|
37781
37843
|
if (today !== currentDate2) {
|
|
37782
37844
|
currentDate2 = today;
|
|
37783
|
-
currentFile =
|
|
37845
|
+
currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
37784
37846
|
cleanOldFiles();
|
|
37785
37847
|
}
|
|
37786
37848
|
}
|
|
37787
37849
|
function cleanOldFiles() {
|
|
37788
37850
|
try {
|
|
37789
|
-
const files =
|
|
37851
|
+
const files = fs8.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
|
|
37790
37852
|
const cutoff = /* @__PURE__ */ new Date();
|
|
37791
37853
|
cutoff.setDate(cutoff.getDate() - MAX_DAYS);
|
|
37792
37854
|
const cutoffStr = cutoff.toISOString().slice(0, 10);
|
|
@@ -37794,7 +37856,7 @@ function cleanOldFiles() {
|
|
|
37794
37856
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
37795
37857
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
37796
37858
|
try {
|
|
37797
|
-
|
|
37859
|
+
fs8.unlinkSync(path16.join(LOG_DIR2, file2));
|
|
37798
37860
|
} catch {
|
|
37799
37861
|
}
|
|
37800
37862
|
}
|
|
@@ -37804,14 +37866,14 @@ function cleanOldFiles() {
|
|
|
37804
37866
|
}
|
|
37805
37867
|
function checkSize() {
|
|
37806
37868
|
try {
|
|
37807
|
-
const stat4 =
|
|
37869
|
+
const stat4 = fs8.statSync(currentFile);
|
|
37808
37870
|
if (stat4.size > MAX_FILE_SIZE) {
|
|
37809
37871
|
const backup = currentFile.replace(".jsonl", ".1.jsonl");
|
|
37810
37872
|
try {
|
|
37811
|
-
|
|
37873
|
+
fs8.unlinkSync(backup);
|
|
37812
37874
|
} catch {
|
|
37813
37875
|
}
|
|
37814
|
-
|
|
37876
|
+
fs8.renameSync(currentFile, backup);
|
|
37815
37877
|
}
|
|
37816
37878
|
} catch {
|
|
37817
37879
|
}
|
|
@@ -37836,14 +37898,14 @@ function logCommand(entry) {
|
|
|
37836
37898
|
...entry.error ? { err: entry.error } : {},
|
|
37837
37899
|
...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
|
|
37838
37900
|
});
|
|
37839
|
-
|
|
37901
|
+
fs8.appendFileSync(currentFile, line + "\n");
|
|
37840
37902
|
} catch {
|
|
37841
37903
|
}
|
|
37842
37904
|
}
|
|
37843
37905
|
function getRecentCommands(count = 50) {
|
|
37844
37906
|
try {
|
|
37845
|
-
if (!
|
|
37846
|
-
const content =
|
|
37907
|
+
if (!fs8.existsSync(currentFile)) return [];
|
|
37908
|
+
const content = fs8.readFileSync(currentFile, "utf-8");
|
|
37847
37909
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
37848
37910
|
return lines.slice(-count).map((line) => {
|
|
37849
37911
|
try {
|
|
@@ -37866,18 +37928,18 @@ function getRecentCommands(count = 50) {
|
|
|
37866
37928
|
return [];
|
|
37867
37929
|
}
|
|
37868
37930
|
}
|
|
37869
|
-
var
|
|
37931
|
+
var fs8, path16, os18, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
|
|
37870
37932
|
var init_command_log = __esm({
|
|
37871
37933
|
"../../oss/packages/daemon-core/src/logging/command-log.ts"() {
|
|
37872
37934
|
"use strict";
|
|
37873
|
-
|
|
37874
|
-
|
|
37875
|
-
|
|
37876
|
-
LOG_DIR2 = process.platform === "win32" ?
|
|
37935
|
+
fs8 = __toESM(require("fs"));
|
|
37936
|
+
path16 = __toESM(require("path"));
|
|
37937
|
+
os18 = __toESM(require("os"));
|
|
37938
|
+
LOG_DIR2 = process.platform === "win32" ? path16.join(process.env.LOCALAPPDATA || process.env.APPDATA || path16.join(os18.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path16.join(os18.homedir(), "Library", "Logs", "adhdev") : path16.join(os18.homedir(), ".local", "share", "adhdev", "logs");
|
|
37877
37939
|
MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
37878
37940
|
MAX_DAYS = 7;
|
|
37879
37941
|
try {
|
|
37880
|
-
|
|
37942
|
+
fs8.mkdirSync(LOG_DIR2, { recursive: true });
|
|
37881
37943
|
} catch {
|
|
37882
37944
|
}
|
|
37883
37945
|
SENSITIVE_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -37892,7 +37954,7 @@ var init_command_log = __esm({
|
|
|
37892
37954
|
"text"
|
|
37893
37955
|
]);
|
|
37894
37956
|
currentDate2 = getDateStr2();
|
|
37895
|
-
currentFile =
|
|
37957
|
+
currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
37896
37958
|
writeCount2 = 0;
|
|
37897
37959
|
SKIP_COMMANDS = /* @__PURE__ */ new Set([
|
|
37898
37960
|
"heartbeat",
|
|
@@ -37956,8 +38018,8 @@ function buildAvailableProviders(providerLoader) {
|
|
|
37956
38018
|
}
|
|
37957
38019
|
function buildMachineInfo(profile = "full") {
|
|
37958
38020
|
const base = {
|
|
37959
|
-
hostname:
|
|
37960
|
-
platform:
|
|
38021
|
+
hostname: os19.hostname(),
|
|
38022
|
+
platform: os19.platform()
|
|
37961
38023
|
};
|
|
37962
38024
|
if (profile === "live") {
|
|
37963
38025
|
return base;
|
|
@@ -37966,23 +38028,23 @@ function buildMachineInfo(profile = "full") {
|
|
|
37966
38028
|
const memSnap2 = getHostMemorySnapshot();
|
|
37967
38029
|
return {
|
|
37968
38030
|
...base,
|
|
37969
|
-
arch:
|
|
37970
|
-
cpus:
|
|
38031
|
+
arch: os19.arch(),
|
|
38032
|
+
cpus: os19.cpus().length,
|
|
37971
38033
|
totalMem: memSnap2.totalMem,
|
|
37972
|
-
release:
|
|
38034
|
+
release: os19.release()
|
|
37973
38035
|
};
|
|
37974
38036
|
}
|
|
37975
38037
|
const memSnap = getHostMemorySnapshot();
|
|
37976
38038
|
return {
|
|
37977
38039
|
...base,
|
|
37978
|
-
arch:
|
|
37979
|
-
cpus:
|
|
38040
|
+
arch: os19.arch(),
|
|
38041
|
+
cpus: os19.cpus().length,
|
|
37980
38042
|
totalMem: memSnap.totalMem,
|
|
37981
38043
|
freeMem: memSnap.freeMem,
|
|
37982
38044
|
availableMem: memSnap.availableMem,
|
|
37983
|
-
loadavg:
|
|
37984
|
-
uptime:
|
|
37985
|
-
release:
|
|
38045
|
+
loadavg: os19.loadavg(),
|
|
38046
|
+
uptime: os19.uptime(),
|
|
38047
|
+
release: os19.release()
|
|
37986
38048
|
};
|
|
37987
38049
|
}
|
|
37988
38050
|
function parseMessageTime(value) {
|
|
@@ -38205,11 +38267,11 @@ function buildStatusSnapshot(options) {
|
|
|
38205
38267
|
}
|
|
38206
38268
|
};
|
|
38207
38269
|
}
|
|
38208
|
-
var
|
|
38270
|
+
var os19, READ_DEBUG_ENABLED, recentReadDebugSignatureBySession;
|
|
38209
38271
|
var init_snapshot = __esm({
|
|
38210
38272
|
"../../oss/packages/daemon-core/src/status/snapshot.ts"() {
|
|
38211
38273
|
"use strict";
|
|
38212
|
-
|
|
38274
|
+
os19 = __toESM(require("os"));
|
|
38213
38275
|
init_config();
|
|
38214
38276
|
init_state_store();
|
|
38215
38277
|
init_recent_activity();
|
|
@@ -38227,37 +38289,37 @@ var init_snapshot = __esm({
|
|
|
38227
38289
|
|
|
38228
38290
|
// ../../oss/packages/daemon-core/src/commands/upgrade-helper.ts
|
|
38229
38291
|
function getUpgradeLogPath() {
|
|
38230
|
-
const home =
|
|
38231
|
-
const dir =
|
|
38232
|
-
|
|
38233
|
-
return
|
|
38292
|
+
const home = os20.homedir();
|
|
38293
|
+
const dir = path17.join(home, ".adhdev");
|
|
38294
|
+
fs9.mkdirSync(dir, { recursive: true });
|
|
38295
|
+
return path17.join(dir, "daemon-upgrade.log");
|
|
38234
38296
|
}
|
|
38235
38297
|
function appendUpgradeLog(message) {
|
|
38236
38298
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
38237
38299
|
`;
|
|
38238
38300
|
try {
|
|
38239
|
-
|
|
38301
|
+
fs9.appendFileSync(getUpgradeLogPath(), line, "utf8");
|
|
38240
38302
|
} catch {
|
|
38241
38303
|
}
|
|
38242
38304
|
}
|
|
38243
38305
|
function resolveSiblingNpmInvocation(nodeExecutable, platform12 = process.platform) {
|
|
38244
|
-
const binDir =
|
|
38306
|
+
const binDir = path17.dirname(nodeExecutable);
|
|
38245
38307
|
if (platform12 === "win32") {
|
|
38246
|
-
const npmCliPath =
|
|
38247
|
-
if (
|
|
38308
|
+
const npmCliPath = path17.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
38309
|
+
if (fs9.existsSync(npmCliPath)) {
|
|
38248
38310
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
|
|
38249
38311
|
}
|
|
38250
38312
|
for (const candidate of ["npm.exe", "npm"]) {
|
|
38251
|
-
const candidatePath =
|
|
38252
|
-
if (
|
|
38313
|
+
const candidatePath = path17.join(binDir, candidate);
|
|
38314
|
+
if (fs9.existsSync(candidatePath)) {
|
|
38253
38315
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
|
|
38254
38316
|
}
|
|
38255
38317
|
}
|
|
38256
38318
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
|
|
38257
38319
|
}
|
|
38258
38320
|
for (const candidate of ["npm"]) {
|
|
38259
|
-
const candidatePath =
|
|
38260
|
-
if (
|
|
38321
|
+
const candidatePath = path17.join(binDir, candidate);
|
|
38322
|
+
if (fs9.existsSync(candidatePath)) {
|
|
38261
38323
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
|
|
38262
38324
|
}
|
|
38263
38325
|
}
|
|
@@ -38267,22 +38329,22 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
|
38267
38329
|
if (!currentCliPath) return null;
|
|
38268
38330
|
let resolvedPath = currentCliPath;
|
|
38269
38331
|
try {
|
|
38270
|
-
resolvedPath =
|
|
38332
|
+
resolvedPath = fs9.realpathSync.native(currentCliPath);
|
|
38271
38333
|
} catch {
|
|
38272
38334
|
}
|
|
38273
38335
|
let currentDir = resolvedPath;
|
|
38274
38336
|
try {
|
|
38275
|
-
if (
|
|
38276
|
-
currentDir =
|
|
38337
|
+
if (fs9.statSync(resolvedPath).isFile()) {
|
|
38338
|
+
currentDir = path17.dirname(resolvedPath);
|
|
38277
38339
|
}
|
|
38278
38340
|
} catch {
|
|
38279
|
-
currentDir =
|
|
38341
|
+
currentDir = path17.dirname(resolvedPath);
|
|
38280
38342
|
}
|
|
38281
38343
|
while (true) {
|
|
38282
|
-
const packageJsonPath =
|
|
38344
|
+
const packageJsonPath = path17.join(currentDir, "package.json");
|
|
38283
38345
|
try {
|
|
38284
|
-
if (
|
|
38285
|
-
const parsed = JSON.parse(
|
|
38346
|
+
if (fs9.existsSync(packageJsonPath)) {
|
|
38347
|
+
const parsed = JSON.parse(fs9.readFileSync(packageJsonPath, "utf8"));
|
|
38286
38348
|
if (parsed?.name === packageName) {
|
|
38287
38349
|
const normalized = currentDir.replace(/\\/g, "/");
|
|
38288
38350
|
return normalized.includes("/node_modules/") ? currentDir : null;
|
|
@@ -38290,7 +38352,7 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
|
38290
38352
|
}
|
|
38291
38353
|
} catch {
|
|
38292
38354
|
}
|
|
38293
|
-
const parentDir =
|
|
38355
|
+
const parentDir = path17.dirname(currentDir);
|
|
38294
38356
|
if (parentDir === currentDir) {
|
|
38295
38357
|
return null;
|
|
38296
38358
|
}
|
|
@@ -38298,13 +38360,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
|
38298
38360
|
}
|
|
38299
38361
|
}
|
|
38300
38362
|
function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
|
|
38301
|
-
const nodeModulesDir = packageName.startsWith("@") ?
|
|
38302
|
-
if (
|
|
38363
|
+
const nodeModulesDir = packageName.startsWith("@") ? path17.dirname(path17.dirname(packageRoot)) : path17.dirname(packageRoot);
|
|
38364
|
+
if (path17.basename(nodeModulesDir) !== "node_modules") {
|
|
38303
38365
|
return null;
|
|
38304
38366
|
}
|
|
38305
|
-
const maybeLibDir =
|
|
38306
|
-
if (
|
|
38307
|
-
return
|
|
38367
|
+
const maybeLibDir = path17.dirname(nodeModulesDir);
|
|
38368
|
+
if (path17.basename(maybeLibDir) === "lib") {
|
|
38369
|
+
return path17.dirname(maybeLibDir);
|
|
38308
38370
|
}
|
|
38309
38371
|
return maybeLibDir;
|
|
38310
38372
|
}
|
|
@@ -38419,10 +38481,10 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
38419
38481
|
}
|
|
38420
38482
|
}
|
|
38421
38483
|
function stopSessionHostProcesses(appName) {
|
|
38422
|
-
const pidFile =
|
|
38484
|
+
const pidFile = path17.join(os20.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
38423
38485
|
try {
|
|
38424
|
-
if (
|
|
38425
|
-
const pid = Number.parseInt(
|
|
38486
|
+
if (fs9.existsSync(pidFile)) {
|
|
38487
|
+
const pid = Number.parseInt(fs9.readFileSync(pidFile, "utf8").trim(), 10);
|
|
38426
38488
|
if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
|
|
38427
38489
|
killPid(pid);
|
|
38428
38490
|
}
|
|
@@ -38430,15 +38492,15 @@ function stopSessionHostProcesses(appName) {
|
|
|
38430
38492
|
} catch {
|
|
38431
38493
|
} finally {
|
|
38432
38494
|
try {
|
|
38433
|
-
|
|
38495
|
+
fs9.unlinkSync(pidFile);
|
|
38434
38496
|
} catch {
|
|
38435
38497
|
}
|
|
38436
38498
|
}
|
|
38437
38499
|
}
|
|
38438
38500
|
function removeDaemonPidFile() {
|
|
38439
|
-
const pidFile =
|
|
38501
|
+
const pidFile = path17.join(os20.homedir(), ".adhdev", "daemon.pid");
|
|
38440
38502
|
try {
|
|
38441
|
-
|
|
38503
|
+
fs9.unlinkSync(pidFile);
|
|
38442
38504
|
} catch {
|
|
38443
38505
|
}
|
|
38444
38506
|
}
|
|
@@ -38447,7 +38509,7 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
|
|
|
38447
38509
|
const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
38448
38510
|
if (!npmRoot) return;
|
|
38449
38511
|
const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
38450
|
-
const binDir = process.platform === "win32" ? npmPrefix :
|
|
38512
|
+
const binDir = process.platform === "win32" ? npmPrefix : path17.join(npmPrefix, "bin");
|
|
38451
38513
|
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
38452
38514
|
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
38453
38515
|
if (pkgName === "@adhdev/daemon-standalone") {
|
|
@@ -38455,25 +38517,25 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
|
|
|
38455
38517
|
}
|
|
38456
38518
|
if (pkgName.startsWith("@")) {
|
|
38457
38519
|
const [scope, name] = pkgName.split("/");
|
|
38458
|
-
const scopeDir =
|
|
38459
|
-
if (!
|
|
38460
|
-
for (const entry of
|
|
38520
|
+
const scopeDir = path17.join(npmRoot, scope);
|
|
38521
|
+
if (!fs9.existsSync(scopeDir)) return;
|
|
38522
|
+
for (const entry of fs9.readdirSync(scopeDir)) {
|
|
38461
38523
|
if (!entry.startsWith(`.${name}-`)) continue;
|
|
38462
|
-
|
|
38463
|
-
appendUpgradeLog(`Removed stale scoped staging dir: ${
|
|
38524
|
+
fs9.rmSync(path17.join(scopeDir, entry), { recursive: true, force: true });
|
|
38525
|
+
appendUpgradeLog(`Removed stale scoped staging dir: ${path17.join(scopeDir, entry)}`);
|
|
38464
38526
|
}
|
|
38465
38527
|
} else {
|
|
38466
|
-
for (const entry of
|
|
38528
|
+
for (const entry of fs9.readdirSync(npmRoot)) {
|
|
38467
38529
|
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
38468
|
-
|
|
38469
|
-
appendUpgradeLog(`Removed stale staging dir: ${
|
|
38530
|
+
fs9.rmSync(path17.join(npmRoot, entry), { recursive: true, force: true });
|
|
38531
|
+
appendUpgradeLog(`Removed stale staging dir: ${path17.join(npmRoot, entry)}`);
|
|
38470
38532
|
}
|
|
38471
38533
|
}
|
|
38472
|
-
if (
|
|
38473
|
-
for (const entry of
|
|
38534
|
+
if (fs9.existsSync(binDir)) {
|
|
38535
|
+
for (const entry of fs9.readdirSync(binDir)) {
|
|
38474
38536
|
if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
38475
|
-
|
|
38476
|
-
appendUpgradeLog(`Removed stale bin staging entry: ${
|
|
38537
|
+
fs9.rmSync(path17.join(binDir, entry), { recursive: true, force: true });
|
|
38538
|
+
appendUpgradeLog(`Removed stale bin staging entry: ${path17.join(binDir, entry)}`);
|
|
38477
38539
|
}
|
|
38478
38540
|
}
|
|
38479
38541
|
}
|
|
@@ -38556,15 +38618,15 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
|
|
|
38556
38618
|
process.exit(1);
|
|
38557
38619
|
}
|
|
38558
38620
|
}
|
|
38559
|
-
var import_child_process8, import_child_process9,
|
|
38621
|
+
var import_child_process8, import_child_process9, fs9, os20, path17, UPGRADE_HELPER_ENV;
|
|
38560
38622
|
var init_upgrade_helper = __esm({
|
|
38561
38623
|
"../../oss/packages/daemon-core/src/commands/upgrade-helper.ts"() {
|
|
38562
38624
|
"use strict";
|
|
38563
38625
|
import_child_process8 = require("child_process");
|
|
38564
38626
|
import_child_process9 = require("child_process");
|
|
38565
|
-
|
|
38566
|
-
|
|
38567
|
-
|
|
38627
|
+
fs9 = __toESM(require("fs"));
|
|
38628
|
+
os20 = __toESM(require("os"));
|
|
38629
|
+
path17 = __toESM(require("path"));
|
|
38568
38630
|
UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
38569
38631
|
}
|
|
38570
38632
|
});
|
|
@@ -38651,7 +38713,7 @@ function summarizeSessionHostPruneResult(result) {
|
|
|
38651
38713
|
keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : void 0
|
|
38652
38714
|
};
|
|
38653
38715
|
}
|
|
38654
|
-
var
|
|
38716
|
+
var fs10, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
|
|
38655
38717
|
var init_router = __esm({
|
|
38656
38718
|
"../../oss/packages/daemon-core/src/commands/router.ts"() {
|
|
38657
38719
|
"use strict";
|
|
@@ -38676,7 +38738,7 @@ var init_router = __esm({
|
|
|
38676
38738
|
init_snapshot();
|
|
38677
38739
|
init_snapshot();
|
|
38678
38740
|
init_upgrade_helper();
|
|
38679
|
-
|
|
38741
|
+
fs10 = __toESM(require("fs"));
|
|
38680
38742
|
CHAT_COMMANDS = [
|
|
38681
38743
|
"send_chat",
|
|
38682
38744
|
"new_chat",
|
|
@@ -38831,8 +38893,8 @@ var init_router = __esm({
|
|
|
38831
38893
|
if (sinceTs > 0) {
|
|
38832
38894
|
return { success: true, logs: [], totalBuffered: 0 };
|
|
38833
38895
|
}
|
|
38834
|
-
if (
|
|
38835
|
-
const content =
|
|
38896
|
+
if (fs10.existsSync(LOG_PATH)) {
|
|
38897
|
+
const content = fs10.readFileSync(LOG_PATH, "utf-8");
|
|
38836
38898
|
const allLines = content.split("\n");
|
|
38837
38899
|
const recent = allLines.slice(-count).join("\n");
|
|
38838
38900
|
return { success: true, logs: recent, totalLines: allLines.length };
|
|
@@ -41110,19 +41172,19 @@ function getVersion(binary, versionCommand) {
|
|
|
41110
41172
|
function checkPathExists2(paths) {
|
|
41111
41173
|
for (const p of paths) {
|
|
41112
41174
|
if (p.includes("*")) {
|
|
41113
|
-
const home =
|
|
41114
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
41115
|
-
if (
|
|
41175
|
+
const home = os21.homedir();
|
|
41176
|
+
const resolved = p.replace(/\*/g, home.split(path18.sep).pop() || "");
|
|
41177
|
+
if (fs11.existsSync(resolved)) return resolved;
|
|
41116
41178
|
} else {
|
|
41117
|
-
if (
|
|
41179
|
+
if (fs11.existsSync(p)) return p;
|
|
41118
41180
|
}
|
|
41119
41181
|
}
|
|
41120
41182
|
return null;
|
|
41121
41183
|
}
|
|
41122
41184
|
function getMacAppVersion(appPath) {
|
|
41123
41185
|
if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
41124
|
-
const plistPath =
|
|
41125
|
-
if (!
|
|
41186
|
+
const plistPath = path18.join(appPath, "Contents", "Info.plist");
|
|
41187
|
+
if (!fs11.existsSync(plistPath)) return null;
|
|
41126
41188
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
41127
41189
|
return raw || null;
|
|
41128
41190
|
}
|
|
@@ -41147,8 +41209,8 @@ async function detectAllVersions(loader, archive) {
|
|
|
41147
41209
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
41148
41210
|
let resolvedBin = cliBin;
|
|
41149
41211
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
41150
|
-
const bundled =
|
|
41151
|
-
if (provider.cli &&
|
|
41212
|
+
const bundled = path18.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
41213
|
+
if (provider.cli && fs11.existsSync(bundled)) resolvedBin = bundled;
|
|
41152
41214
|
}
|
|
41153
41215
|
info.installed = !!(appPath || resolvedBin);
|
|
41154
41216
|
info.path = appPath || null;
|
|
@@ -41184,16 +41246,16 @@ async function detectAllVersions(loader, archive) {
|
|
|
41184
41246
|
}
|
|
41185
41247
|
return results;
|
|
41186
41248
|
}
|
|
41187
|
-
var
|
|
41249
|
+
var fs11, path18, os21, import_child_process10, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
|
|
41188
41250
|
var init_version_archive = __esm({
|
|
41189
41251
|
"../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
|
|
41190
41252
|
"use strict";
|
|
41191
|
-
|
|
41192
|
-
|
|
41193
|
-
|
|
41253
|
+
fs11 = __toESM(require("fs"));
|
|
41254
|
+
path18 = __toESM(require("path"));
|
|
41255
|
+
os21 = __toESM(require("os"));
|
|
41194
41256
|
import_child_process10 = require("child_process");
|
|
41195
41257
|
import_os3 = require("os");
|
|
41196
|
-
ARCHIVE_PATH =
|
|
41258
|
+
ARCHIVE_PATH = path18.join(os21.homedir(), ".adhdev", "version-history.json");
|
|
41197
41259
|
MAX_ENTRIES_PER_PROVIDER = 20;
|
|
41198
41260
|
VersionArchive = class {
|
|
41199
41261
|
history = {};
|
|
@@ -41202,8 +41264,8 @@ var init_version_archive = __esm({
|
|
|
41202
41264
|
}
|
|
41203
41265
|
load() {
|
|
41204
41266
|
try {
|
|
41205
|
-
if (
|
|
41206
|
-
this.history = JSON.parse(
|
|
41267
|
+
if (fs11.existsSync(ARCHIVE_PATH)) {
|
|
41268
|
+
this.history = JSON.parse(fs11.readFileSync(ARCHIVE_PATH, "utf-8"));
|
|
41207
41269
|
}
|
|
41208
41270
|
} catch {
|
|
41209
41271
|
this.history = {};
|
|
@@ -41240,8 +41302,8 @@ var init_version_archive = __esm({
|
|
|
41240
41302
|
}
|
|
41241
41303
|
save() {
|
|
41242
41304
|
try {
|
|
41243
|
-
|
|
41244
|
-
|
|
41305
|
+
fs11.mkdirSync(path18.dirname(ARCHIVE_PATH), { recursive: true });
|
|
41306
|
+
fs11.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
41245
41307
|
} catch {
|
|
41246
41308
|
}
|
|
41247
41309
|
}
|
|
@@ -41775,18 +41837,18 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
41775
41837
|
return;
|
|
41776
41838
|
}
|
|
41777
41839
|
let scriptsPath = "";
|
|
41778
|
-
const directScripts =
|
|
41779
|
-
if (
|
|
41840
|
+
const directScripts = path19.join(dir, "scripts.js");
|
|
41841
|
+
if (fs12.existsSync(directScripts)) {
|
|
41780
41842
|
scriptsPath = directScripts;
|
|
41781
41843
|
} else {
|
|
41782
|
-
const scriptsDir =
|
|
41783
|
-
if (
|
|
41784
|
-
const versions =
|
|
41785
|
-
return
|
|
41844
|
+
const scriptsDir = path19.join(dir, "scripts");
|
|
41845
|
+
if (fs12.existsSync(scriptsDir)) {
|
|
41846
|
+
const versions = fs12.readdirSync(scriptsDir).filter((d) => {
|
|
41847
|
+
return fs12.statSync(path19.join(scriptsDir, d)).isDirectory();
|
|
41786
41848
|
}).sort().reverse();
|
|
41787
41849
|
for (const ver of versions) {
|
|
41788
|
-
const p =
|
|
41789
|
-
if (
|
|
41850
|
+
const p = path19.join(scriptsDir, ver, "scripts.js");
|
|
41851
|
+
if (fs12.existsSync(p)) {
|
|
41790
41852
|
scriptsPath = p;
|
|
41791
41853
|
break;
|
|
41792
41854
|
}
|
|
@@ -41798,7 +41860,7 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
41798
41860
|
return;
|
|
41799
41861
|
}
|
|
41800
41862
|
try {
|
|
41801
|
-
const source =
|
|
41863
|
+
const source = fs12.readFileSync(scriptsPath, "utf-8");
|
|
41802
41864
|
const hints = {};
|
|
41803
41865
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
41804
41866
|
let match;
|
|
@@ -42611,12 +42673,12 @@ async function handleDomContext(ctx, type, req, res) {
|
|
|
42611
42673
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
42612
42674
|
}
|
|
42613
42675
|
}
|
|
42614
|
-
var
|
|
42676
|
+
var fs12, path19;
|
|
42615
42677
|
var init_dev_cdp_handlers = __esm({
|
|
42616
42678
|
"../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
|
|
42617
42679
|
"use strict";
|
|
42618
|
-
|
|
42619
|
-
|
|
42680
|
+
fs12 = __toESM(require("fs"));
|
|
42681
|
+
path19 = __toESM(require("path"));
|
|
42620
42682
|
init_logger();
|
|
42621
42683
|
}
|
|
42622
42684
|
});
|
|
@@ -42631,15 +42693,15 @@ function getCliFixtureDir(ctx, type) {
|
|
|
42631
42693
|
if (!providerDir) {
|
|
42632
42694
|
throw new Error(`Provider directory not found for '${type}'`);
|
|
42633
42695
|
}
|
|
42634
|
-
return
|
|
42696
|
+
return path20.join(providerDir, "fixtures");
|
|
42635
42697
|
}
|
|
42636
42698
|
function readCliFixture(ctx, type, name) {
|
|
42637
42699
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
42638
|
-
const filePath =
|
|
42639
|
-
if (!
|
|
42700
|
+
const filePath = path20.join(fixtureDir, `${name}.json`);
|
|
42701
|
+
if (!fs13.existsSync(filePath)) {
|
|
42640
42702
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
42641
42703
|
}
|
|
42642
|
-
return JSON.parse(
|
|
42704
|
+
return JSON.parse(fs13.readFileSync(filePath, "utf-8"));
|
|
42643
42705
|
}
|
|
42644
42706
|
function getExerciseTranscriptText(result) {
|
|
42645
42707
|
const parts = [];
|
|
@@ -43375,7 +43437,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
43375
43437
|
return;
|
|
43376
43438
|
}
|
|
43377
43439
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
43378
|
-
|
|
43440
|
+
fs13.mkdirSync(fixtureDir, { recursive: true });
|
|
43379
43441
|
const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
|
|
43380
43442
|
const result = await runCliExerciseInternal(ctx, { ...request, type });
|
|
43381
43443
|
const fixture = {
|
|
@@ -43402,8 +43464,8 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
43402
43464
|
},
|
|
43403
43465
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
43404
43466
|
};
|
|
43405
|
-
const filePath =
|
|
43406
|
-
|
|
43467
|
+
const filePath = path20.join(fixtureDir, `${name}.json`);
|
|
43468
|
+
fs13.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
43407
43469
|
ctx.json(res, 200, {
|
|
43408
43470
|
saved: true,
|
|
43409
43471
|
name,
|
|
@@ -43421,14 +43483,14 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
43421
43483
|
async function handleCliFixtureList(ctx, type, _req, res) {
|
|
43422
43484
|
try {
|
|
43423
43485
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
43424
|
-
if (!
|
|
43486
|
+
if (!fs13.existsSync(fixtureDir)) {
|
|
43425
43487
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
43426
43488
|
return;
|
|
43427
43489
|
}
|
|
43428
|
-
const fixtures =
|
|
43429
|
-
const fullPath =
|
|
43490
|
+
const fixtures = fs13.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
43491
|
+
const fullPath = path20.join(fixtureDir, file2);
|
|
43430
43492
|
try {
|
|
43431
|
-
const raw = JSON.parse(
|
|
43493
|
+
const raw = JSON.parse(fs13.readFileSync(fullPath, "utf-8"));
|
|
43432
43494
|
return {
|
|
43433
43495
|
name: raw.name || file2.replace(/\.json$/i, ""),
|
|
43434
43496
|
path: fullPath,
|
|
@@ -43559,12 +43621,12 @@ async function handleCliRaw(ctx, req, res) {
|
|
|
43559
43621
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
43560
43622
|
}
|
|
43561
43623
|
}
|
|
43562
|
-
var
|
|
43624
|
+
var fs13, path20;
|
|
43563
43625
|
var init_dev_cli_debug = __esm({
|
|
43564
43626
|
"../../oss/packages/daemon-core/src/daemon/dev-cli-debug.ts"() {
|
|
43565
43627
|
"use strict";
|
|
43566
|
-
|
|
43567
|
-
|
|
43628
|
+
fs13 = __toESM(require("fs"));
|
|
43629
|
+
path20 = __toESM(require("path"));
|
|
43568
43630
|
}
|
|
43569
43631
|
});
|
|
43570
43632
|
|
|
@@ -43614,38 +43676,38 @@ function resolveAutoImplReference(ctx, category, requestedReference, targetType)
|
|
|
43614
43676
|
return fallback2?.type || null;
|
|
43615
43677
|
}
|
|
43616
43678
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
43617
|
-
if (!
|
|
43618
|
-
const versions =
|
|
43679
|
+
if (!fs14.existsSync(scriptsDir)) return null;
|
|
43680
|
+
const versions = fs14.readdirSync(scriptsDir).filter((d) => {
|
|
43619
43681
|
try {
|
|
43620
|
-
return
|
|
43682
|
+
return fs14.statSync(path21.join(scriptsDir, d)).isDirectory();
|
|
43621
43683
|
} catch {
|
|
43622
43684
|
return false;
|
|
43623
43685
|
}
|
|
43624
43686
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
43625
43687
|
if (versions.length === 0) return null;
|
|
43626
|
-
return
|
|
43688
|
+
return path21.join(scriptsDir, versions[0]);
|
|
43627
43689
|
}
|
|
43628
43690
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
43629
|
-
const canonicalUserDir =
|
|
43630
|
-
const desiredDir = requestedDir ?
|
|
43631
|
-
const upstreamRoot =
|
|
43632
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
43691
|
+
const canonicalUserDir = path21.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
43692
|
+
const desiredDir = requestedDir ? path21.resolve(requestedDir) : canonicalUserDir;
|
|
43693
|
+
const upstreamRoot = path21.resolve(ctx.providerLoader.getUpstreamDir());
|
|
43694
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path21.sep}`)) {
|
|
43633
43695
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
43634
43696
|
}
|
|
43635
|
-
if (
|
|
43697
|
+
if (path21.basename(desiredDir) !== type) {
|
|
43636
43698
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
43637
43699
|
}
|
|
43638
43700
|
const sourceDir = ctx.findProviderDir(type);
|
|
43639
43701
|
if (!sourceDir) {
|
|
43640
43702
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
43641
43703
|
}
|
|
43642
|
-
if (!
|
|
43643
|
-
|
|
43644
|
-
|
|
43704
|
+
if (!fs14.existsSync(desiredDir)) {
|
|
43705
|
+
fs14.mkdirSync(path21.dirname(desiredDir), { recursive: true });
|
|
43706
|
+
fs14.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
43645
43707
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
43646
43708
|
}
|
|
43647
|
-
const providerJson =
|
|
43648
|
-
if (!
|
|
43709
|
+
const providerJson = path21.join(desiredDir, "provider.json");
|
|
43710
|
+
if (!fs14.existsSync(providerJson)) {
|
|
43649
43711
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
43650
43712
|
}
|
|
43651
43713
|
return { dir: desiredDir };
|
|
@@ -43653,15 +43715,15 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
43653
43715
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
43654
43716
|
if (!referenceType) return {};
|
|
43655
43717
|
const refDir = ctx.findProviderDir(referenceType);
|
|
43656
|
-
if (!refDir || !
|
|
43718
|
+
if (!refDir || !fs14.existsSync(refDir)) return {};
|
|
43657
43719
|
const referenceScripts = {};
|
|
43658
|
-
const scriptsDir =
|
|
43720
|
+
const scriptsDir = path21.join(refDir, "scripts");
|
|
43659
43721
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
43660
43722
|
if (!latestDir) return referenceScripts;
|
|
43661
|
-
for (const file2 of
|
|
43723
|
+
for (const file2 of fs14.readdirSync(latestDir)) {
|
|
43662
43724
|
if (!file2.endsWith(".js")) continue;
|
|
43663
43725
|
try {
|
|
43664
|
-
referenceScripts[file2] =
|
|
43726
|
+
referenceScripts[file2] = fs14.readFileSync(path21.join(latestDir, file2), "utf-8");
|
|
43665
43727
|
} catch {
|
|
43666
43728
|
}
|
|
43667
43729
|
}
|
|
@@ -43769,16 +43831,16 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
43769
43831
|
});
|
|
43770
43832
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
43771
43833
|
const prompt2 = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
43772
|
-
const tmpDir =
|
|
43773
|
-
if (!
|
|
43774
|
-
const promptFile =
|
|
43775
|
-
|
|
43834
|
+
const tmpDir = path21.join(os23.tmpdir(), "adhdev-autoimpl");
|
|
43835
|
+
if (!fs14.existsSync(tmpDir)) fs14.mkdirSync(tmpDir, { recursive: true });
|
|
43836
|
+
const promptFile = path21.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
43837
|
+
fs14.writeFileSync(promptFile, prompt2, "utf-8");
|
|
43776
43838
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt2.length} chars)`);
|
|
43777
43839
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
43778
43840
|
const spawn6 = agentProvider?.spawn;
|
|
43779
43841
|
if (!spawn6?.command) {
|
|
43780
43842
|
try {
|
|
43781
|
-
|
|
43843
|
+
fs14.unlinkSync(promptFile);
|
|
43782
43844
|
} catch {
|
|
43783
43845
|
}
|
|
43784
43846
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -43880,7 +43942,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
43880
43942
|
} catch {
|
|
43881
43943
|
}
|
|
43882
43944
|
try {
|
|
43883
|
-
|
|
43945
|
+
fs14.unlinkSync(promptFile);
|
|
43884
43946
|
} catch {
|
|
43885
43947
|
}
|
|
43886
43948
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -43924,7 +43986,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
43924
43986
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
43925
43987
|
const baseArgs = [...spawn6.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
43926
43988
|
let shellCmd;
|
|
43927
|
-
const isWin =
|
|
43989
|
+
const isWin = os23.platform() === "win32";
|
|
43928
43990
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
43929
43991
|
const promptMode = autoImpl?.promptMode ?? "stdin";
|
|
43930
43992
|
const extraArgs = autoImpl?.extraArgs ?? [];
|
|
@@ -43963,7 +44025,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
43963
44025
|
try {
|
|
43964
44026
|
const pty = require("node-pty");
|
|
43965
44027
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
43966
|
-
const isWin2 =
|
|
44028
|
+
const isWin2 = os23.platform() === "win32";
|
|
43967
44029
|
child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
43968
44030
|
name: "xterm-256color",
|
|
43969
44031
|
cols: 120,
|
|
@@ -44106,7 +44168,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
44106
44168
|
}
|
|
44107
44169
|
});
|
|
44108
44170
|
try {
|
|
44109
|
-
|
|
44171
|
+
fs14.unlinkSync(promptFile);
|
|
44110
44172
|
} catch {
|
|
44111
44173
|
}
|
|
44112
44174
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -44203,7 +44265,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
44203
44265
|
setMode: "set_mode.js"
|
|
44204
44266
|
};
|
|
44205
44267
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
44206
|
-
const scriptsDir =
|
|
44268
|
+
const scriptsDir = path21.join(providerDir, "scripts");
|
|
44207
44269
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
44208
44270
|
if (latestScriptsDir) {
|
|
44209
44271
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -44211,10 +44273,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
44211
44273
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
44212
44274
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
44213
44275
|
lines.push("");
|
|
44214
|
-
for (const file2 of
|
|
44276
|
+
for (const file2 of fs14.readdirSync(latestScriptsDir)) {
|
|
44215
44277
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
44216
44278
|
try {
|
|
44217
|
-
const content =
|
|
44279
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
44218
44280
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
44219
44281
|
lines.push("```javascript");
|
|
44220
44282
|
lines.push(content);
|
|
@@ -44224,14 +44286,14 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
44224
44286
|
}
|
|
44225
44287
|
}
|
|
44226
44288
|
}
|
|
44227
|
-
const refFiles =
|
|
44289
|
+
const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
44228
44290
|
if (refFiles.length > 0) {
|
|
44229
44291
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
44230
44292
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
44231
44293
|
lines.push("");
|
|
44232
44294
|
for (const file2 of refFiles) {
|
|
44233
44295
|
try {
|
|
44234
|
-
const content =
|
|
44296
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
44235
44297
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
44236
44298
|
lines.push("```javascript");
|
|
44237
44299
|
lines.push(content);
|
|
@@ -44272,11 +44334,11 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
44272
44334
|
lines.push("");
|
|
44273
44335
|
}
|
|
44274
44336
|
}
|
|
44275
|
-
const docsDir =
|
|
44337
|
+
const docsDir = path21.join(providerDir, "../../docs");
|
|
44276
44338
|
const loadGuide = (name) => {
|
|
44277
44339
|
try {
|
|
44278
|
-
const p =
|
|
44279
|
-
if (
|
|
44340
|
+
const p = path21.join(docsDir, name);
|
|
44341
|
+
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
44280
44342
|
} catch {
|
|
44281
44343
|
}
|
|
44282
44344
|
return null;
|
|
@@ -44512,7 +44574,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
44512
44574
|
parseApproval: "parse_approval.js"
|
|
44513
44575
|
};
|
|
44514
44576
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
44515
|
-
const scriptsDir =
|
|
44577
|
+
const scriptsDir = path21.join(providerDir, "scripts");
|
|
44516
44578
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
44517
44579
|
if (latestScriptsDir) {
|
|
44518
44580
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -44520,11 +44582,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
44520
44582
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
44521
44583
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
44522
44584
|
lines.push("");
|
|
44523
|
-
for (const file2 of
|
|
44585
|
+
for (const file2 of fs14.readdirSync(latestScriptsDir)) {
|
|
44524
44586
|
if (!file2.endsWith(".js")) continue;
|
|
44525
44587
|
if (!targetFileNames.has(file2)) continue;
|
|
44526
44588
|
try {
|
|
44527
|
-
const content =
|
|
44589
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
44528
44590
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
44529
44591
|
lines.push("```javascript");
|
|
44530
44592
|
lines.push(content);
|
|
@@ -44533,14 +44595,14 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
44533
44595
|
} catch {
|
|
44534
44596
|
}
|
|
44535
44597
|
}
|
|
44536
|
-
const refFiles =
|
|
44598
|
+
const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
44537
44599
|
if (refFiles.length > 0) {
|
|
44538
44600
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
44539
44601
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
44540
44602
|
lines.push("");
|
|
44541
44603
|
for (const file2 of refFiles) {
|
|
44542
44604
|
try {
|
|
44543
|
-
const content =
|
|
44605
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
44544
44606
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
44545
44607
|
lines.push("```javascript");
|
|
44546
44608
|
lines.push(content);
|
|
@@ -44573,11 +44635,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
44573
44635
|
lines.push("");
|
|
44574
44636
|
}
|
|
44575
44637
|
}
|
|
44576
|
-
const docsDir =
|
|
44638
|
+
const docsDir = path21.join(providerDir, "../../docs");
|
|
44577
44639
|
const loadGuide = (name) => {
|
|
44578
44640
|
try {
|
|
44579
|
-
const p =
|
|
44580
|
-
if (
|
|
44641
|
+
const p = path21.join(docsDir, name);
|
|
44642
|
+
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
44581
44643
|
} catch {
|
|
44582
44644
|
}
|
|
44583
44645
|
return null;
|
|
@@ -44888,13 +44950,13 @@ data: ${JSON.stringify(msg.data)}
|
|
|
44888
44950
|
}
|
|
44889
44951
|
}
|
|
44890
44952
|
}
|
|
44891
|
-
var
|
|
44953
|
+
var fs14, path21, os23;
|
|
44892
44954
|
var init_dev_auto_implement = __esm({
|
|
44893
44955
|
"../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
|
|
44894
44956
|
"use strict";
|
|
44895
|
-
|
|
44896
|
-
|
|
44897
|
-
|
|
44957
|
+
fs14 = __toESM(require("fs"));
|
|
44958
|
+
path21 = __toESM(require("path"));
|
|
44959
|
+
os23 = __toESM(require("os"));
|
|
44898
44960
|
init_dev_server();
|
|
44899
44961
|
init_dev_cli_debug();
|
|
44900
44962
|
}
|
|
@@ -44933,13 +44995,13 @@ function toProviderListEntry(provider) {
|
|
|
44933
44995
|
}
|
|
44934
44996
|
return base;
|
|
44935
44997
|
}
|
|
44936
|
-
var http2,
|
|
44998
|
+
var http2, fs15, path23, DEV_SERVER_PORT, DevServer;
|
|
44937
44999
|
var init_dev_server = __esm({
|
|
44938
45000
|
"../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
|
|
44939
45001
|
"use strict";
|
|
44940
45002
|
http2 = __toESM(require("http"));
|
|
44941
|
-
|
|
44942
|
-
|
|
45003
|
+
fs15 = __toESM(require("fs"));
|
|
45004
|
+
path23 = __toESM(require("path"));
|
|
44943
45005
|
init_provider_schema();
|
|
44944
45006
|
init_config();
|
|
44945
45007
|
init_provider_source_config();
|
|
@@ -45052,8 +45114,8 @@ var init_dev_server = __esm({
|
|
|
45052
45114
|
}
|
|
45053
45115
|
getEndpointList() {
|
|
45054
45116
|
return this.routes.map((r) => {
|
|
45055
|
-
const
|
|
45056
|
-
return `${r.method.padEnd(5)} ${
|
|
45117
|
+
const path29 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
45118
|
+
return `${r.method.padEnd(5)} ${path29}`;
|
|
45057
45119
|
});
|
|
45058
45120
|
}
|
|
45059
45121
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -45341,12 +45403,12 @@ var init_dev_server = __esm({
|
|
|
45341
45403
|
// ─── DevConsole SPA ───
|
|
45342
45404
|
getConsoleDistDir() {
|
|
45343
45405
|
const candidates = [
|
|
45344
|
-
|
|
45345
|
-
|
|
45346
|
-
|
|
45406
|
+
path23.resolve(__dirname, "../../web-devconsole/dist"),
|
|
45407
|
+
path23.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
45408
|
+
path23.join(process.cwd(), "packages/web-devconsole/dist")
|
|
45347
45409
|
];
|
|
45348
45410
|
for (const dir of candidates) {
|
|
45349
|
-
if (
|
|
45411
|
+
if (fs15.existsSync(path23.join(dir, "index.html"))) return dir;
|
|
45350
45412
|
}
|
|
45351
45413
|
return null;
|
|
45352
45414
|
}
|
|
@@ -45356,9 +45418,9 @@ var init_dev_server = __esm({
|
|
|
45356
45418
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
45357
45419
|
return;
|
|
45358
45420
|
}
|
|
45359
|
-
const htmlPath =
|
|
45421
|
+
const htmlPath = path23.join(distDir, "index.html");
|
|
45360
45422
|
try {
|
|
45361
|
-
const html =
|
|
45423
|
+
const html = fs15.readFileSync(htmlPath, "utf-8");
|
|
45362
45424
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
45363
45425
|
res.end(html);
|
|
45364
45426
|
} catch (e) {
|
|
@@ -45381,15 +45443,15 @@ var init_dev_server = __esm({
|
|
|
45381
45443
|
this.json(res, 404, { error: "Not found" });
|
|
45382
45444
|
return;
|
|
45383
45445
|
}
|
|
45384
|
-
const safePath =
|
|
45385
|
-
const filePath =
|
|
45446
|
+
const safePath = path23.normalize(pathname).replace(/^\.\.\//, "");
|
|
45447
|
+
const filePath = path23.join(distDir, safePath);
|
|
45386
45448
|
if (!filePath.startsWith(distDir)) {
|
|
45387
45449
|
this.json(res, 403, { error: "Forbidden" });
|
|
45388
45450
|
return;
|
|
45389
45451
|
}
|
|
45390
45452
|
try {
|
|
45391
|
-
const content =
|
|
45392
|
-
const ext =
|
|
45453
|
+
const content = fs15.readFileSync(filePath);
|
|
45454
|
+
const ext = path23.extname(filePath);
|
|
45393
45455
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
45394
45456
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
45395
45457
|
res.end(content);
|
|
@@ -45497,14 +45559,14 @@ var init_dev_server = __esm({
|
|
|
45497
45559
|
const files = [];
|
|
45498
45560
|
const scan = (d, prefix) => {
|
|
45499
45561
|
try {
|
|
45500
|
-
for (const entry of
|
|
45562
|
+
for (const entry of fs15.readdirSync(d, { withFileTypes: true })) {
|
|
45501
45563
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
45502
45564
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
45503
45565
|
if (entry.isDirectory()) {
|
|
45504
45566
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
45505
|
-
scan(
|
|
45567
|
+
scan(path23.join(d, entry.name), rel);
|
|
45506
45568
|
} else {
|
|
45507
|
-
const stat4 =
|
|
45569
|
+
const stat4 = fs15.statSync(path23.join(d, entry.name));
|
|
45508
45570
|
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
45509
45571
|
}
|
|
45510
45572
|
}
|
|
@@ -45527,16 +45589,16 @@ var init_dev_server = __esm({
|
|
|
45527
45589
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
45528
45590
|
return;
|
|
45529
45591
|
}
|
|
45530
|
-
const fullPath =
|
|
45592
|
+
const fullPath = path23.resolve(dir, path23.normalize(filePath));
|
|
45531
45593
|
if (!fullPath.startsWith(dir)) {
|
|
45532
45594
|
this.json(res, 403, { error: "Forbidden" });
|
|
45533
45595
|
return;
|
|
45534
45596
|
}
|
|
45535
|
-
if (!
|
|
45597
|
+
if (!fs15.existsSync(fullPath) || fs15.statSync(fullPath).isDirectory()) {
|
|
45536
45598
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
45537
45599
|
return;
|
|
45538
45600
|
}
|
|
45539
|
-
const content =
|
|
45601
|
+
const content = fs15.readFileSync(fullPath, "utf-8");
|
|
45540
45602
|
this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
|
|
45541
45603
|
}
|
|
45542
45604
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -45552,15 +45614,15 @@ var init_dev_server = __esm({
|
|
|
45552
45614
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
45553
45615
|
return;
|
|
45554
45616
|
}
|
|
45555
|
-
const fullPath =
|
|
45617
|
+
const fullPath = path23.resolve(dir, path23.normalize(filePath));
|
|
45556
45618
|
if (!fullPath.startsWith(dir)) {
|
|
45557
45619
|
this.json(res, 403, { error: "Forbidden" });
|
|
45558
45620
|
return;
|
|
45559
45621
|
}
|
|
45560
45622
|
try {
|
|
45561
|
-
if (
|
|
45562
|
-
|
|
45563
|
-
|
|
45623
|
+
if (fs15.existsSync(fullPath)) fs15.copyFileSync(fullPath, fullPath + ".bak");
|
|
45624
|
+
fs15.mkdirSync(path23.dirname(fullPath), { recursive: true });
|
|
45625
|
+
fs15.writeFileSync(fullPath, content, "utf-8");
|
|
45564
45626
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
45565
45627
|
this.providerLoader.reload();
|
|
45566
45628
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -45576,9 +45638,9 @@ var init_dev_server = __esm({
|
|
|
45576
45638
|
return;
|
|
45577
45639
|
}
|
|
45578
45640
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
45579
|
-
const p =
|
|
45580
|
-
if (
|
|
45581
|
-
const source =
|
|
45641
|
+
const p = path23.join(dir, name);
|
|
45642
|
+
if (fs15.existsSync(p)) {
|
|
45643
|
+
const source = fs15.readFileSync(p, "utf-8");
|
|
45582
45644
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
45583
45645
|
return;
|
|
45584
45646
|
}
|
|
@@ -45597,11 +45659,11 @@ var init_dev_server = __esm({
|
|
|
45597
45659
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
45598
45660
|
return;
|
|
45599
45661
|
}
|
|
45600
|
-
const target =
|
|
45601
|
-
const targetPath =
|
|
45662
|
+
const target = fs15.existsSync(path23.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
45663
|
+
const targetPath = path23.join(dir, target);
|
|
45602
45664
|
try {
|
|
45603
|
-
if (
|
|
45604
|
-
|
|
45665
|
+
if (fs15.existsSync(targetPath)) fs15.copyFileSync(targetPath, targetPath + ".bak");
|
|
45666
|
+
fs15.writeFileSync(targetPath, source, "utf-8");
|
|
45605
45667
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
45606
45668
|
this.providerLoader.reload();
|
|
45607
45669
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -45745,21 +45807,21 @@ var init_dev_server = __esm({
|
|
|
45745
45807
|
}
|
|
45746
45808
|
let targetDir;
|
|
45747
45809
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
45748
|
-
const jsonPath =
|
|
45749
|
-
if (
|
|
45810
|
+
const jsonPath = path23.join(targetDir, "provider.json");
|
|
45811
|
+
if (fs15.existsSync(jsonPath)) {
|
|
45750
45812
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
45751
45813
|
return;
|
|
45752
45814
|
}
|
|
45753
45815
|
try {
|
|
45754
45816
|
const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
|
|
45755
|
-
|
|
45756
|
-
|
|
45817
|
+
fs15.mkdirSync(targetDir, { recursive: true });
|
|
45818
|
+
fs15.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
45757
45819
|
const createdFiles = ["provider.json"];
|
|
45758
45820
|
if (result.files) {
|
|
45759
45821
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
45760
|
-
const fullPath =
|
|
45761
|
-
|
|
45762
|
-
|
|
45822
|
+
const fullPath = path23.join(targetDir, relPath);
|
|
45823
|
+
fs15.mkdirSync(path23.dirname(fullPath), { recursive: true });
|
|
45824
|
+
fs15.writeFileSync(fullPath, content, "utf-8");
|
|
45763
45825
|
createdFiles.push(relPath);
|
|
45764
45826
|
}
|
|
45765
45827
|
}
|
|
@@ -45808,38 +45870,38 @@ var init_dev_server = __esm({
|
|
|
45808
45870
|
}
|
|
45809
45871
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
45810
45872
|
getLatestScriptVersionDir(scriptsDir) {
|
|
45811
|
-
if (!
|
|
45812
|
-
const versions =
|
|
45873
|
+
if (!fs15.existsSync(scriptsDir)) return null;
|
|
45874
|
+
const versions = fs15.readdirSync(scriptsDir).filter((d) => {
|
|
45813
45875
|
try {
|
|
45814
|
-
return
|
|
45876
|
+
return fs15.statSync(path23.join(scriptsDir, d)).isDirectory();
|
|
45815
45877
|
} catch {
|
|
45816
45878
|
return false;
|
|
45817
45879
|
}
|
|
45818
45880
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
45819
45881
|
if (versions.length === 0) return null;
|
|
45820
|
-
return
|
|
45882
|
+
return path23.join(scriptsDir, versions[0]);
|
|
45821
45883
|
}
|
|
45822
45884
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
45823
|
-
const canonicalUserDir =
|
|
45824
|
-
const desiredDir = requestedDir ?
|
|
45825
|
-
const upstreamRoot =
|
|
45826
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
45885
|
+
const canonicalUserDir = path23.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
45886
|
+
const desiredDir = requestedDir ? path23.resolve(requestedDir) : canonicalUserDir;
|
|
45887
|
+
const upstreamRoot = path23.resolve(this.providerLoader.getUpstreamDir());
|
|
45888
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path23.sep}`)) {
|
|
45827
45889
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
45828
45890
|
}
|
|
45829
|
-
if (
|
|
45891
|
+
if (path23.basename(desiredDir) !== type) {
|
|
45830
45892
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
45831
45893
|
}
|
|
45832
45894
|
const sourceDir = this.findProviderDir(type);
|
|
45833
45895
|
if (!sourceDir) {
|
|
45834
45896
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
45835
45897
|
}
|
|
45836
|
-
if (!
|
|
45837
|
-
|
|
45838
|
-
|
|
45898
|
+
if (!fs15.existsSync(desiredDir)) {
|
|
45899
|
+
fs15.mkdirSync(path23.dirname(desiredDir), { recursive: true });
|
|
45900
|
+
fs15.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
45839
45901
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
45840
45902
|
}
|
|
45841
|
-
const providerJson =
|
|
45842
|
-
if (!
|
|
45903
|
+
const providerJson = path23.join(desiredDir, "provider.json");
|
|
45904
|
+
if (!fs15.existsSync(providerJson)) {
|
|
45843
45905
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
45844
45906
|
}
|
|
45845
45907
|
return { dir: desiredDir };
|
|
@@ -45874,7 +45936,7 @@ var init_dev_server = __esm({
|
|
|
45874
45936
|
setMode: "set_mode.js"
|
|
45875
45937
|
};
|
|
45876
45938
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
45877
|
-
const scriptsDir =
|
|
45939
|
+
const scriptsDir = path23.join(providerDir, "scripts");
|
|
45878
45940
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
45879
45941
|
if (latestScriptsDir) {
|
|
45880
45942
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -45882,10 +45944,10 @@ var init_dev_server = __esm({
|
|
|
45882
45944
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
45883
45945
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
45884
45946
|
lines.push("");
|
|
45885
|
-
for (const file2 of
|
|
45947
|
+
for (const file2 of fs15.readdirSync(latestScriptsDir)) {
|
|
45886
45948
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
45887
45949
|
try {
|
|
45888
|
-
const content =
|
|
45950
|
+
const content = fs15.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
45889
45951
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
45890
45952
|
lines.push("```javascript");
|
|
45891
45953
|
lines.push(content);
|
|
@@ -45895,14 +45957,14 @@ var init_dev_server = __esm({
|
|
|
45895
45957
|
}
|
|
45896
45958
|
}
|
|
45897
45959
|
}
|
|
45898
|
-
const refFiles =
|
|
45960
|
+
const refFiles = fs15.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
45899
45961
|
if (refFiles.length > 0) {
|
|
45900
45962
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
45901
45963
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
45902
45964
|
lines.push("");
|
|
45903
45965
|
for (const file2 of refFiles) {
|
|
45904
45966
|
try {
|
|
45905
|
-
const content =
|
|
45967
|
+
const content = fs15.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
45906
45968
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
45907
45969
|
lines.push("```javascript");
|
|
45908
45970
|
lines.push(content);
|
|
@@ -45943,11 +46005,11 @@ var init_dev_server = __esm({
|
|
|
45943
46005
|
lines.push("");
|
|
45944
46006
|
}
|
|
45945
46007
|
}
|
|
45946
|
-
const docsDir =
|
|
46008
|
+
const docsDir = path23.join(providerDir, "../../docs");
|
|
45947
46009
|
const loadGuide = (name) => {
|
|
45948
46010
|
try {
|
|
45949
|
-
const p =
|
|
45950
|
-
if (
|
|
46011
|
+
const p = path23.join(docsDir, name);
|
|
46012
|
+
if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
|
|
45951
46013
|
} catch {
|
|
45952
46014
|
}
|
|
45953
46015
|
return null;
|
|
@@ -46120,7 +46182,7 @@ var init_dev_server = __esm({
|
|
|
46120
46182
|
parseApproval: "parse_approval.js"
|
|
46121
46183
|
};
|
|
46122
46184
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
46123
|
-
const scriptsDir =
|
|
46185
|
+
const scriptsDir = path23.join(providerDir, "scripts");
|
|
46124
46186
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
46125
46187
|
if (latestScriptsDir) {
|
|
46126
46188
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -46128,11 +46190,11 @@ var init_dev_server = __esm({
|
|
|
46128
46190
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
46129
46191
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
46130
46192
|
lines.push("");
|
|
46131
|
-
for (const file2 of
|
|
46193
|
+
for (const file2 of fs15.readdirSync(latestScriptsDir)) {
|
|
46132
46194
|
if (!file2.endsWith(".js")) continue;
|
|
46133
46195
|
if (!targetFileNames.has(file2)) continue;
|
|
46134
46196
|
try {
|
|
46135
|
-
const content =
|
|
46197
|
+
const content = fs15.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
46136
46198
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
46137
46199
|
lines.push("```javascript");
|
|
46138
46200
|
lines.push(content);
|
|
@@ -46141,14 +46203,14 @@ var init_dev_server = __esm({
|
|
|
46141
46203
|
} catch {
|
|
46142
46204
|
}
|
|
46143
46205
|
}
|
|
46144
|
-
const refFiles =
|
|
46206
|
+
const refFiles = fs15.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
46145
46207
|
if (refFiles.length > 0) {
|
|
46146
46208
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
46147
46209
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
46148
46210
|
lines.push("");
|
|
46149
46211
|
for (const file2 of refFiles) {
|
|
46150
46212
|
try {
|
|
46151
|
-
const content =
|
|
46213
|
+
const content = fs15.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
46152
46214
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
46153
46215
|
lines.push("```javascript");
|
|
46154
46216
|
lines.push(content);
|
|
@@ -46181,11 +46243,11 @@ var init_dev_server = __esm({
|
|
|
46181
46243
|
lines.push("");
|
|
46182
46244
|
}
|
|
46183
46245
|
}
|
|
46184
|
-
const docsDir =
|
|
46246
|
+
const docsDir = path23.join(providerDir, "../../docs");
|
|
46185
46247
|
const loadGuide = (name) => {
|
|
46186
46248
|
try {
|
|
46187
|
-
const p =
|
|
46188
|
-
if (
|
|
46249
|
+
const p = path23.join(docsDir, name);
|
|
46250
|
+
if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
|
|
46189
46251
|
} catch {
|
|
46190
46252
|
}
|
|
46191
46253
|
return null;
|
|
@@ -46995,8 +47057,8 @@ async function installExtension(ide, extension) {
|
|
|
46995
47057
|
const res = await fetch(extension.vsixUrl);
|
|
46996
47058
|
if (res.ok) {
|
|
46997
47059
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
46998
|
-
const
|
|
46999
|
-
|
|
47060
|
+
const fs20 = await import("fs");
|
|
47061
|
+
fs20.writeFileSync(vsixPath, buffer);
|
|
47000
47062
|
return new Promise((resolve16) => {
|
|
47001
47063
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
47002
47064
|
(0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
@@ -48417,12 +48479,14 @@ var init_data_channel_router = __esm({
|
|
|
48417
48479
|
});
|
|
48418
48480
|
|
|
48419
48481
|
// src/daemon-p2p/screenshot-sender.ts
|
|
48420
|
-
var CHUNK_SIZE, ScreenshotSender;
|
|
48482
|
+
var CHUNK_SIZE, MAX_INLINE_JSON_MESSAGE_BYTES, JSON_CHUNK_PAYLOAD_CHARS2, ScreenshotSender;
|
|
48421
48483
|
var init_screenshot_sender = __esm({
|
|
48422
48484
|
"src/daemon-p2p/screenshot-sender.ts"() {
|
|
48423
48485
|
"use strict";
|
|
48424
48486
|
init_log();
|
|
48425
48487
|
CHUNK_SIZE = 6e4;
|
|
48488
|
+
MAX_INLINE_JSON_MESSAGE_BYTES = 6e4;
|
|
48489
|
+
JSON_CHUNK_PAYLOAD_CHARS2 = 16e3;
|
|
48426
48490
|
ScreenshotSender = class {
|
|
48427
48491
|
_ssDebugDone = false;
|
|
48428
48492
|
sendStatus(peers, status) {
|
|
@@ -48461,16 +48525,43 @@ var init_screenshot_sender = __esm({
|
|
|
48461
48525
|
}
|
|
48462
48526
|
sendTopicUpdateToPeer(peer, update) {
|
|
48463
48527
|
if (!peer?.dataChannel || peer.state !== "connected" || !peer.dataChannel.isOpen()) return false;
|
|
48528
|
+
const json2 = JSON.stringify({
|
|
48529
|
+
type: "topic_update",
|
|
48530
|
+
update
|
|
48531
|
+
});
|
|
48532
|
+
if (Buffer.byteLength(json2, "utf8") > MAX_INLINE_JSON_MESSAGE_BYTES) {
|
|
48533
|
+
return this.sendChunkedTopicUpdate(peer, update, json2);
|
|
48534
|
+
}
|
|
48464
48535
|
try {
|
|
48465
|
-
peer.dataChannel.sendMessage(
|
|
48466
|
-
type: "topic_update",
|
|
48467
|
-
update
|
|
48468
|
-
}));
|
|
48536
|
+
peer.dataChannel.sendMessage(json2);
|
|
48469
48537
|
return true;
|
|
48470
48538
|
} catch {
|
|
48471
48539
|
return false;
|
|
48472
48540
|
}
|
|
48473
48541
|
}
|
|
48542
|
+
sendChunkedTopicUpdate(peer, update, json2) {
|
|
48543
|
+
const topic = typeof update?.topic === "string" ? update.topic : "topic_update";
|
|
48544
|
+
const key = typeof update?.key === "string" ? update.key : "";
|
|
48545
|
+
const seq = typeof update?.seq === "number" ? update.seq : Date.now();
|
|
48546
|
+
const chunkId = `${topic}:${key}:${seq}:${Math.random().toString(36).slice(2, 8)}`;
|
|
48547
|
+
const total = Math.ceil(json2.length / JSON_CHUNK_PAYLOAD_CHARS2);
|
|
48548
|
+
logDebug(`topic_update chunked: peer=${peer.peerId || "unknown"} topic=${topic} key=${key || "-"} chars=${json2.length} chunks=${total}`);
|
|
48549
|
+
for (let index = 0; index < total; index += 1) {
|
|
48550
|
+
const chunk = json2.slice(index * JSON_CHUNK_PAYLOAD_CHARS2, (index + 1) * JSON_CHUNK_PAYLOAD_CHARS2);
|
|
48551
|
+
try {
|
|
48552
|
+
peer.dataChannel?.sendMessage(JSON.stringify({
|
|
48553
|
+
type: "topic_update_chunk",
|
|
48554
|
+
chunkId,
|
|
48555
|
+
index,
|
|
48556
|
+
total,
|
|
48557
|
+
data: chunk
|
|
48558
|
+
}));
|
|
48559
|
+
} catch {
|
|
48560
|
+
return false;
|
|
48561
|
+
}
|
|
48562
|
+
}
|
|
48563
|
+
return true;
|
|
48564
|
+
}
|
|
48474
48565
|
/** Broadcast runtime session output to all connected peers */
|
|
48475
48566
|
broadcastSessionOutput(peers, sessionId, data) {
|
|
48476
48567
|
const msg = JSON.stringify({ type: "session_output", sessionId, data });
|
|
@@ -48901,12 +48992,12 @@ var init_peer_connection_manager = __esm({
|
|
|
48901
48992
|
});
|
|
48902
48993
|
|
|
48903
48994
|
// src/daemon-p2p/index.ts
|
|
48904
|
-
var
|
|
48995
|
+
var fs16, path24, import_node_module2, esmRequire, DaemonP2PSender;
|
|
48905
48996
|
var init_daemon_p2p = __esm({
|
|
48906
48997
|
"src/daemon-p2p/index.ts"() {
|
|
48907
48998
|
"use strict";
|
|
48908
|
-
|
|
48909
|
-
|
|
48999
|
+
fs16 = __toESM(require("fs"));
|
|
49000
|
+
path24 = __toESM(require("path"));
|
|
48910
49001
|
import_node_module2 = require("module");
|
|
48911
49002
|
init_src();
|
|
48912
49003
|
init_data_channel_router();
|
|
@@ -48985,17 +49076,17 @@ ${e?.stack || ""}`);
|
|
|
48985
49076
|
const prebuildKey = `${platform12}-${arch3}`;
|
|
48986
49077
|
try {
|
|
48987
49078
|
const candidates = [
|
|
48988
|
-
|
|
48989
|
-
|
|
48990
|
-
|
|
49079
|
+
path24.join(__dirname, "node_modules", "node-datachannel"),
|
|
49080
|
+
path24.join(__dirname, "..", "node_modules", "node-datachannel"),
|
|
49081
|
+
path24.join(__dirname, "..", "..", "node_modules", "node-datachannel")
|
|
48991
49082
|
];
|
|
48992
49083
|
for (const candidate of candidates) {
|
|
48993
|
-
const prebuildPath =
|
|
48994
|
-
if (
|
|
48995
|
-
const targetDir =
|
|
48996
|
-
const targetPath =
|
|
48997
|
-
|
|
48998
|
-
|
|
49084
|
+
const prebuildPath = path24.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
|
|
49085
|
+
if (fs16.existsSync(prebuildPath)) {
|
|
49086
|
+
const targetDir = path24.join(candidate, "build", "Release");
|
|
49087
|
+
const targetPath = path24.join(targetDir, "node_datachannel.node");
|
|
49088
|
+
fs16.mkdirSync(targetDir, { recursive: true });
|
|
49089
|
+
fs16.copyFileSync(prebuildPath, targetPath);
|
|
48999
49090
|
try {
|
|
49000
49091
|
delete esmRequire.cache[esmRequire.resolve("node-datachannel")];
|
|
49001
49092
|
} catch {
|
|
@@ -49362,27 +49453,27 @@ var require_process = __commonJS({
|
|
|
49362
49453
|
var require_filesystem = __commonJS({
|
|
49363
49454
|
"../../node_modules/detect-libc/lib/filesystem.js"(exports2, module2) {
|
|
49364
49455
|
"use strict";
|
|
49365
|
-
var
|
|
49456
|
+
var fs20 = require("fs");
|
|
49366
49457
|
var LDD_PATH = "/usr/bin/ldd";
|
|
49367
49458
|
var SELF_PATH = "/proc/self/exe";
|
|
49368
49459
|
var MAX_LENGTH = 2048;
|
|
49369
|
-
var readFileSync19 = (
|
|
49370
|
-
const fd =
|
|
49460
|
+
var readFileSync19 = (path29) => {
|
|
49461
|
+
const fd = fs20.openSync(path29, "r");
|
|
49371
49462
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
49372
|
-
const bytesRead =
|
|
49373
|
-
|
|
49463
|
+
const bytesRead = fs20.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
49464
|
+
fs20.close(fd, () => {
|
|
49374
49465
|
});
|
|
49375
49466
|
return buffer.subarray(0, bytesRead);
|
|
49376
49467
|
};
|
|
49377
|
-
var readFile = (
|
|
49378
|
-
|
|
49468
|
+
var readFile = (path29) => new Promise((resolve16, reject) => {
|
|
49469
|
+
fs20.open(path29, "r", (err, fd) => {
|
|
49379
49470
|
if (err) {
|
|
49380
49471
|
reject(err);
|
|
49381
49472
|
} else {
|
|
49382
49473
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
49383
|
-
|
|
49474
|
+
fs20.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
|
|
49384
49475
|
resolve16(buffer.subarray(0, bytesRead));
|
|
49385
|
-
|
|
49476
|
+
fs20.close(fd, () => {
|
|
49386
49477
|
});
|
|
49387
49478
|
});
|
|
49388
49479
|
}
|
|
@@ -49494,11 +49585,11 @@ var require_detect_libc = __commonJS({
|
|
|
49494
49585
|
}
|
|
49495
49586
|
return null;
|
|
49496
49587
|
};
|
|
49497
|
-
var familyFromInterpreterPath = (
|
|
49498
|
-
if (
|
|
49499
|
-
if (
|
|
49588
|
+
var familyFromInterpreterPath = (path29) => {
|
|
49589
|
+
if (path29) {
|
|
49590
|
+
if (path29.includes("/ld-musl-")) {
|
|
49500
49591
|
return MUSL;
|
|
49501
|
-
} else if (
|
|
49592
|
+
} else if (path29.includes("/ld-linux-")) {
|
|
49502
49593
|
return GLIBC;
|
|
49503
49594
|
}
|
|
49504
49595
|
}
|
|
@@ -49545,8 +49636,8 @@ var require_detect_libc = __commonJS({
|
|
|
49545
49636
|
cachedFamilyInterpreter = null;
|
|
49546
49637
|
try {
|
|
49547
49638
|
const selfContent = await readFile(SELF_PATH);
|
|
49548
|
-
const
|
|
49549
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
49639
|
+
const path29 = interpreterPath(selfContent);
|
|
49640
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path29);
|
|
49550
49641
|
} catch (e) {
|
|
49551
49642
|
}
|
|
49552
49643
|
return cachedFamilyInterpreter;
|
|
@@ -49558,8 +49649,8 @@ var require_detect_libc = __commonJS({
|
|
|
49558
49649
|
cachedFamilyInterpreter = null;
|
|
49559
49650
|
try {
|
|
49560
49651
|
const selfContent = readFileSync19(SELF_PATH);
|
|
49561
|
-
const
|
|
49562
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
49652
|
+
const path29 = interpreterPath(selfContent);
|
|
49653
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path29);
|
|
49563
49654
|
} catch (e) {
|
|
49564
49655
|
}
|
|
49565
49656
|
return cachedFamilyInterpreter;
|
|
@@ -51278,18 +51369,18 @@ var require_sharp = __commonJS({
|
|
|
51278
51369
|
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
51279
51370
|
"@img/sharp-wasm32/sharp.node"
|
|
51280
51371
|
];
|
|
51281
|
-
var
|
|
51372
|
+
var path29;
|
|
51282
51373
|
var sharp;
|
|
51283
51374
|
var errors = [];
|
|
51284
|
-
for (
|
|
51375
|
+
for (path29 of paths) {
|
|
51285
51376
|
try {
|
|
51286
|
-
sharp = require(
|
|
51377
|
+
sharp = require(path29);
|
|
51287
51378
|
break;
|
|
51288
51379
|
} catch (err) {
|
|
51289
51380
|
errors.push(err);
|
|
51290
51381
|
}
|
|
51291
51382
|
}
|
|
51292
|
-
if (sharp &&
|
|
51383
|
+
if (sharp && path29.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
|
|
51293
51384
|
const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
|
|
51294
51385
|
err.code = "Unsupported CPU";
|
|
51295
51386
|
errors.push(err);
|
|
@@ -51298,7 +51389,7 @@ var require_sharp = __commonJS({
|
|
|
51298
51389
|
if (sharp) {
|
|
51299
51390
|
module2.exports = sharp;
|
|
51300
51391
|
} else {
|
|
51301
|
-
const [isLinux2, isMacOs, isWindows2] = ["linux", "darwin", "win32"].map((
|
|
51392
|
+
const [isLinux2, isMacOs, isWindows2] = ["linux", "darwin", "win32"].map((os29) => runtimePlatform.startsWith(os29));
|
|
51302
51393
|
const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
|
51303
51394
|
errors.forEach((err) => {
|
|
51304
51395
|
if (err.code !== "MODULE_NOT_FOUND") {
|
|
@@ -51315,15 +51406,15 @@ var require_sharp = __commonJS({
|
|
|
51315
51406
|
` Requires ${expected}`
|
|
51316
51407
|
);
|
|
51317
51408
|
} else if (prebuiltPlatforms.includes(runtimePlatform)) {
|
|
51318
|
-
const [
|
|
51319
|
-
const libc =
|
|
51409
|
+
const [os29, cpu] = runtimePlatform.split("-");
|
|
51410
|
+
const libc = os29.endsWith("musl") ? " --libc=musl" : "";
|
|
51320
51411
|
help.push(
|
|
51321
51412
|
"- Ensure optional dependencies can be installed:",
|
|
51322
51413
|
" npm install --include=optional sharp",
|
|
51323
51414
|
"- Ensure your package manager supports multi-platform installation:",
|
|
51324
51415
|
" See https://sharp.pixelplumbing.com/install#cross-platform",
|
|
51325
51416
|
"- Add platform-specific dependencies:",
|
|
51326
|
-
` npm install --os=${
|
|
51417
|
+
` npm install --os=${os29.replace("musl", "")}${libc} --cpu=${cpu} sharp`
|
|
51327
51418
|
);
|
|
51328
51419
|
} else {
|
|
51329
51420
|
help.push(
|
|
@@ -54198,15 +54289,15 @@ var require_color = __commonJS({
|
|
|
54198
54289
|
};
|
|
54199
54290
|
}
|
|
54200
54291
|
function wrapConversion(toModel, graph) {
|
|
54201
|
-
const
|
|
54292
|
+
const path29 = [graph[toModel].parent, toModel];
|
|
54202
54293
|
let fn = conversions_default[graph[toModel].parent][toModel];
|
|
54203
54294
|
let cur = graph[toModel].parent;
|
|
54204
54295
|
while (graph[cur].parent) {
|
|
54205
|
-
|
|
54296
|
+
path29.unshift(graph[cur].parent);
|
|
54206
54297
|
fn = link(conversions_default[graph[cur].parent][cur], fn);
|
|
54207
54298
|
cur = graph[cur].parent;
|
|
54208
54299
|
}
|
|
54209
|
-
fn.conversion =
|
|
54300
|
+
fn.conversion = path29;
|
|
54210
54301
|
return fn;
|
|
54211
54302
|
}
|
|
54212
54303
|
function route(fromModel) {
|
|
@@ -54823,7 +54914,7 @@ var require_channel = __commonJS({
|
|
|
54823
54914
|
var require_output = __commonJS({
|
|
54824
54915
|
"../../node_modules/sharp/lib/output.js"(exports2, module2) {
|
|
54825
54916
|
"use strict";
|
|
54826
|
-
var
|
|
54917
|
+
var path29 = require("path");
|
|
54827
54918
|
var is = require_is();
|
|
54828
54919
|
var sharp = require_sharp();
|
|
54829
54920
|
var formats = /* @__PURE__ */ new Map([
|
|
@@ -54854,9 +54945,9 @@ var require_output = __commonJS({
|
|
|
54854
54945
|
let err;
|
|
54855
54946
|
if (!is.string(fileOut)) {
|
|
54856
54947
|
err = new Error("Missing output file path");
|
|
54857
|
-
} else if (is.string(this.options.input.file) &&
|
|
54948
|
+
} else if (is.string(this.options.input.file) && path29.resolve(this.options.input.file) === path29.resolve(fileOut)) {
|
|
54858
54949
|
err = new Error("Cannot use same file for input and output");
|
|
54859
|
-
} else if (jp2Regex.test(
|
|
54950
|
+
} else if (jp2Regex.test(path29.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
|
|
54860
54951
|
err = errJp2Save();
|
|
54861
54952
|
}
|
|
54862
54953
|
if (err) {
|
|
@@ -56130,21 +56221,21 @@ function quarantineLegacyStandaloneSessions(options) {
|
|
|
56130
56221
|
if (shouldSkipForExplicitOverride(env3)) {
|
|
56131
56222
|
return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
|
|
56132
56223
|
}
|
|
56133
|
-
const homeDir = options.homeDir ||
|
|
56224
|
+
const homeDir = options.homeDir || os24.homedir();
|
|
56134
56225
|
const now = options.now || (() => /* @__PURE__ */ new Date());
|
|
56135
56226
|
const isPidRunning = options.isPidRunning || defaultPidRunning;
|
|
56136
|
-
const runtimesDir =
|
|
56137
|
-
if (!
|
|
56227
|
+
const runtimesDir = path25.join(homeDir, ".adhdev", "session-host", options.appName, "runtimes");
|
|
56228
|
+
if (!fs17.existsSync(runtimesDir)) {
|
|
56138
56229
|
return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
|
|
56139
56230
|
}
|
|
56140
|
-
const candidates =
|
|
56231
|
+
const candidates = fs17.readdirSync(runtimesDir).filter((name) => name.endsWith(".json")).map((name) => path25.join(runtimesDir, name));
|
|
56141
56232
|
let movedCount = 0;
|
|
56142
56233
|
let skippedActiveCount = 0;
|
|
56143
56234
|
let backupDir = null;
|
|
56144
56235
|
for (const sourcePath of candidates) {
|
|
56145
56236
|
let parsed;
|
|
56146
56237
|
try {
|
|
56147
|
-
parsed = JSON.parse(
|
|
56238
|
+
parsed = JSON.parse(fs17.readFileSync(sourcePath, "utf8"));
|
|
56148
56239
|
} catch {
|
|
56149
56240
|
continue;
|
|
56150
56241
|
}
|
|
@@ -56155,26 +56246,26 @@ function quarantineLegacyStandaloneSessions(options) {
|
|
|
56155
56246
|
continue;
|
|
56156
56247
|
}
|
|
56157
56248
|
if (!backupDir) {
|
|
56158
|
-
backupDir =
|
|
56249
|
+
backupDir = path25.join(
|
|
56159
56250
|
homeDir,
|
|
56160
56251
|
".adhdev",
|
|
56161
56252
|
"session-host-backups",
|
|
56162
56253
|
`legacy-standalone-${options.appName}-${formatTimestamp(now())}`
|
|
56163
56254
|
);
|
|
56164
|
-
|
|
56255
|
+
fs17.mkdirSync(path25.join(backupDir, "runtimes"), { recursive: true });
|
|
56165
56256
|
}
|
|
56166
|
-
|
|
56257
|
+
fs17.renameSync(sourcePath, path25.join(backupDir, "runtimes", path25.basename(sourcePath)));
|
|
56167
56258
|
movedCount += 1;
|
|
56168
56259
|
}
|
|
56169
56260
|
return { movedCount, skippedActiveCount, backupDir };
|
|
56170
56261
|
}
|
|
56171
|
-
var
|
|
56262
|
+
var fs17, os24, path25, LEGACY_STANDALONE_MANAGER_TAG;
|
|
56172
56263
|
var init_session_host_hygiene = __esm({
|
|
56173
56264
|
"src/session-host-hygiene.ts"() {
|
|
56174
56265
|
"use strict";
|
|
56175
|
-
|
|
56176
|
-
|
|
56177
|
-
|
|
56266
|
+
fs17 = __toESM(require("fs"));
|
|
56267
|
+
os24 = __toESM(require("os"));
|
|
56268
|
+
path25 = __toESM(require("path"));
|
|
56178
56269
|
init_src();
|
|
56179
56270
|
LEGACY_STANDALONE_MANAGER_TAG = "adhdev-standalone";
|
|
56180
56271
|
}
|
|
@@ -56188,18 +56279,18 @@ function buildSessionHostEnv(baseEnv) {
|
|
|
56188
56279
|
}
|
|
56189
56280
|
function resolveSessionHostEntry() {
|
|
56190
56281
|
const packagedCandidates = [
|
|
56191
|
-
|
|
56192
|
-
|
|
56282
|
+
path26.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
56283
|
+
path26.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
56193
56284
|
];
|
|
56194
56285
|
for (const candidate of packagedCandidates) {
|
|
56195
|
-
if (
|
|
56286
|
+
if (fs18.existsSync(candidate)) {
|
|
56196
56287
|
return candidate;
|
|
56197
56288
|
}
|
|
56198
56289
|
}
|
|
56199
56290
|
return require.resolve("@adhdev/session-host-daemon");
|
|
56200
56291
|
}
|
|
56201
56292
|
function getSessionHostPidFile() {
|
|
56202
|
-
return
|
|
56293
|
+
return path26.join(os25.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
|
|
56203
56294
|
}
|
|
56204
56295
|
function killPid2(pid) {
|
|
56205
56296
|
try {
|
|
@@ -56265,8 +56356,8 @@ function stopManagedSessionHostProcess() {
|
|
|
56265
56356
|
let stopped = false;
|
|
56266
56357
|
const pidFile = getSessionHostPidFile();
|
|
56267
56358
|
try {
|
|
56268
|
-
if (
|
|
56269
|
-
const pid = Number.parseInt(
|
|
56359
|
+
if (fs18.existsSync(pidFile)) {
|
|
56360
|
+
const pid = Number.parseInt(fs18.readFileSync(pidFile, "utf8").trim(), 10);
|
|
56270
56361
|
if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid2(pid)) {
|
|
56271
56362
|
stopped = killPid2(pid) || stopped;
|
|
56272
56363
|
}
|
|
@@ -56274,7 +56365,7 @@ function stopManagedSessionHostProcess() {
|
|
|
56274
56365
|
} catch {
|
|
56275
56366
|
} finally {
|
|
56276
56367
|
try {
|
|
56277
|
-
|
|
56368
|
+
fs18.unlinkSync(pidFile);
|
|
56278
56369
|
} catch {
|
|
56279
56370
|
}
|
|
56280
56371
|
}
|
|
@@ -56302,9 +56393,9 @@ async function ensureSessionHostReady2() {
|
|
|
56302
56393
|
}
|
|
56303
56394
|
const spawnHost = () => {
|
|
56304
56395
|
const entry = resolveSessionHostEntry();
|
|
56305
|
-
const logDir =
|
|
56306
|
-
|
|
56307
|
-
const logFd =
|
|
56396
|
+
const logDir = path26.join(os25.homedir(), ".adhdev", "logs");
|
|
56397
|
+
fs18.mkdirSync(logDir, { recursive: true });
|
|
56398
|
+
const logFd = fs18.openSync(path26.join(logDir, "session-host.log"), "a");
|
|
56308
56399
|
const child = (0, import_child_process12.spawn)(process.execPath, [entry], {
|
|
56309
56400
|
detached: true,
|
|
56310
56401
|
stdio: ["ignore", logFd, logFd],
|
|
@@ -56313,7 +56404,7 @@ async function ensureSessionHostReady2() {
|
|
|
56313
56404
|
});
|
|
56314
56405
|
child.unref();
|
|
56315
56406
|
try {
|
|
56316
|
-
|
|
56407
|
+
fs18.closeSync(logFd);
|
|
56317
56408
|
} catch {
|
|
56318
56409
|
}
|
|
56319
56410
|
};
|
|
@@ -56339,14 +56430,14 @@ async function ensureSessionHostReady2() {
|
|
|
56339
56430
|
async function listHostedCliRuntimes2(endpoint) {
|
|
56340
56431
|
return listHostedCliRuntimes(endpoint);
|
|
56341
56432
|
}
|
|
56342
|
-
var import_child_process12,
|
|
56433
|
+
var import_child_process12, fs18, os25, path26, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
|
|
56343
56434
|
var init_session_host = __esm({
|
|
56344
56435
|
"src/session-host.ts"() {
|
|
56345
56436
|
"use strict";
|
|
56346
56437
|
import_child_process12 = require("child_process");
|
|
56347
|
-
|
|
56348
|
-
|
|
56349
|
-
|
|
56438
|
+
fs18 = __toESM(require("fs"));
|
|
56439
|
+
os25 = __toESM(require("os"));
|
|
56440
|
+
path26 = __toESM(require("path"));
|
|
56350
56441
|
init_src();
|
|
56351
56442
|
init_dist();
|
|
56352
56443
|
init_session_host_hygiene();
|
|
@@ -57124,22 +57215,22 @@ function resolveDaemonPort(ref = {}) {
|
|
|
57124
57215
|
return Number.isFinite(ref.port) && Number(ref.port) > 0 ? Number(ref.port) : DEFAULT_DAEMON_PORT;
|
|
57125
57216
|
}
|
|
57126
57217
|
function getDaemonPidFile(ref = {}) {
|
|
57127
|
-
const dir =
|
|
57128
|
-
if (!
|
|
57218
|
+
const dir = path27.join(ref.homeDir || os27.homedir(), ".adhdev");
|
|
57219
|
+
if (!fs19.existsSync(dir)) fs19.mkdirSync(dir, { recursive: true });
|
|
57129
57220
|
const port = resolveDaemonPort(ref);
|
|
57130
|
-
return
|
|
57221
|
+
return path27.join(dir, port === DEFAULT_DAEMON_PORT ? "daemon.pid" : `daemon-${port}.pid`);
|
|
57131
57222
|
}
|
|
57132
57223
|
function writeDaemonPid(pid, ref = {}) {
|
|
57133
57224
|
const pidFile = getDaemonPidFile(ref);
|
|
57134
57225
|
try {
|
|
57135
|
-
|
|
57226
|
+
fs19.writeFileSync(pidFile, String(pid), { encoding: "utf-8", flag: "wx" });
|
|
57136
57227
|
} catch {
|
|
57137
|
-
|
|
57228
|
+
fs19.writeFileSync(pidFile, String(pid), "utf-8");
|
|
57138
57229
|
}
|
|
57139
57230
|
}
|
|
57140
57231
|
function removeDaemonPid(ref = {}) {
|
|
57141
57232
|
try {
|
|
57142
|
-
|
|
57233
|
+
fs19.unlinkSync(getDaemonPidFile(ref));
|
|
57143
57234
|
} catch (e) {
|
|
57144
57235
|
}
|
|
57145
57236
|
}
|
|
@@ -57166,8 +57257,8 @@ function isDaemonRunning(ref = {}) {
|
|
|
57166
57257
|
}
|
|
57167
57258
|
const pidFile = getDaemonPidFile(ref);
|
|
57168
57259
|
try {
|
|
57169
|
-
if (!
|
|
57170
|
-
const pid = parseInt(
|
|
57260
|
+
if (!fs19.existsSync(pidFile)) return false;
|
|
57261
|
+
const pid = parseInt(fs19.readFileSync(pidFile, "utf-8").trim());
|
|
57171
57262
|
process.kill(pid, 0);
|
|
57172
57263
|
if (!isAdhdevProcess(pid)) {
|
|
57173
57264
|
removeDaemonPid(ref);
|
|
@@ -57244,8 +57335,8 @@ function getDaemonHealthPid(ref = {}) {
|
|
|
57244
57335
|
function getDaemonPid(ref = {}) {
|
|
57245
57336
|
const pidFile = getDaemonPidFile(ref);
|
|
57246
57337
|
try {
|
|
57247
|
-
if (
|
|
57248
|
-
const pid = parseInt(
|
|
57338
|
+
if (fs19.existsSync(pidFile)) {
|
|
57339
|
+
const pid = parseInt(fs19.readFileSync(pidFile, "utf-8").trim(), 10);
|
|
57249
57340
|
if (Number.isFinite(pid)) return pid;
|
|
57250
57341
|
}
|
|
57251
57342
|
} catch {
|
|
@@ -57256,8 +57347,8 @@ function stopDaemon(ref = {}) {
|
|
|
57256
57347
|
const pidFile = getDaemonPidFile(ref);
|
|
57257
57348
|
let pid = null;
|
|
57258
57349
|
try {
|
|
57259
|
-
if (
|
|
57260
|
-
const pidFromFile = parseInt(
|
|
57350
|
+
if (fs19.existsSync(pidFile)) {
|
|
57351
|
+
const pidFromFile = parseInt(fs19.readFileSync(pidFile, "utf-8").trim(), 10);
|
|
57261
57352
|
if (Number.isFinite(pidFromFile)) pid = pidFromFile;
|
|
57262
57353
|
}
|
|
57263
57354
|
} catch {
|
|
@@ -57276,7 +57367,7 @@ function stopDaemon(ref = {}) {
|
|
|
57276
57367
|
return false;
|
|
57277
57368
|
}
|
|
57278
57369
|
}
|
|
57279
|
-
var
|
|
57370
|
+
var os27, fs19, path27, import_http, import_child_process13, import_ws3, pkgVersion, AdhdevDaemon;
|
|
57280
57371
|
var init_adhdev_daemon = __esm({
|
|
57281
57372
|
"src/adhdev-daemon.ts"() {
|
|
57282
57373
|
"use strict";
|
|
@@ -57288,9 +57379,9 @@ var init_adhdev_daemon = __esm({
|
|
|
57288
57379
|
init_startup_restore_policy();
|
|
57289
57380
|
init_dist();
|
|
57290
57381
|
init_session_host_controller();
|
|
57291
|
-
|
|
57292
|
-
|
|
57293
|
-
|
|
57382
|
+
os27 = __toESM(require("os"));
|
|
57383
|
+
fs19 = __toESM(require("fs"));
|
|
57384
|
+
path27 = __toESM(require("path"));
|
|
57294
57385
|
import_http = require("http");
|
|
57295
57386
|
import_child_process13 = require("child_process");
|
|
57296
57387
|
import_ws3 = require("ws");
|
|
@@ -57298,7 +57389,7 @@ var init_adhdev_daemon = __esm({
|
|
|
57298
57389
|
init_version();
|
|
57299
57390
|
init_src();
|
|
57300
57391
|
init_runtime_defaults();
|
|
57301
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.
|
|
57392
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.51" });
|
|
57302
57393
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
57303
57394
|
localHttpServer = null;
|
|
57304
57395
|
localWss = null;
|
|
@@ -57822,8 +57913,8 @@ ${err?.stack || ""}`);
|
|
|
57822
57913
|
cliInfo: {
|
|
57823
57914
|
type: "adhdev-daemon",
|
|
57824
57915
|
version: pkgVersion,
|
|
57825
|
-
platform:
|
|
57826
|
-
hostname:
|
|
57916
|
+
platform: os27.platform(),
|
|
57917
|
+
hostname: os27.hostname(),
|
|
57827
57918
|
machineId: config2.machineId,
|
|
57828
57919
|
instanceId
|
|
57829
57920
|
}
|
|
@@ -69761,15 +69852,15 @@ var require_route = __commonJS({
|
|
|
69761
69852
|
};
|
|
69762
69853
|
}
|
|
69763
69854
|
function wrapConversion(toModel, graph) {
|
|
69764
|
-
const
|
|
69855
|
+
const path29 = [graph[toModel].parent, toModel];
|
|
69765
69856
|
let fn = conversions[graph[toModel].parent][toModel];
|
|
69766
69857
|
let cur = graph[toModel].parent;
|
|
69767
69858
|
while (graph[cur].parent) {
|
|
69768
|
-
|
|
69859
|
+
path29.unshift(graph[cur].parent);
|
|
69769
69860
|
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
69770
69861
|
cur = graph[cur].parent;
|
|
69771
69862
|
}
|
|
69772
|
-
fn.conversion =
|
|
69863
|
+
fn.conversion = path29;
|
|
69773
69864
|
return fn;
|
|
69774
69865
|
}
|
|
69775
69866
|
module2.exports = function(fromModel) {
|
|
@@ -70166,7 +70257,7 @@ var require_has_flag = __commonJS({
|
|
|
70166
70257
|
var require_supports_color = __commonJS({
|
|
70167
70258
|
"../../node_modules/supports-color/index.js"(exports2, module2) {
|
|
70168
70259
|
"use strict";
|
|
70169
|
-
var
|
|
70260
|
+
var os29 = require("os");
|
|
70170
70261
|
var tty3 = require("tty");
|
|
70171
70262
|
var hasFlag3 = require_has_flag();
|
|
70172
70263
|
var { env: env3 } = process;
|
|
@@ -70214,7 +70305,7 @@ var require_supports_color = __commonJS({
|
|
|
70214
70305
|
return min;
|
|
70215
70306
|
}
|
|
70216
70307
|
if (process.platform === "win32") {
|
|
70217
|
-
const osRelease =
|
|
70308
|
+
const osRelease = os29.release().split(".");
|
|
70218
70309
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
70219
70310
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
70220
70311
|
}
|
|
@@ -73067,7 +73158,7 @@ var require_buffer_list = __commonJS({
|
|
|
73067
73158
|
}
|
|
73068
73159
|
}, {
|
|
73069
73160
|
key: "join",
|
|
73070
|
-
value: function
|
|
73161
|
+
value: function join31(s) {
|
|
73071
73162
|
if (this.length === 0) return "";
|
|
73072
73163
|
var p = this.head;
|
|
73073
73164
|
var ret = "" + p.data;
|
|
@@ -83190,10 +83281,10 @@ var require_lib2 = __commonJS({
|
|
|
83190
83281
|
exports2.analyse = analyse;
|
|
83191
83282
|
var detectFile = (filepath, opts = {}) => new Promise((resolve16, reject) => {
|
|
83192
83283
|
let fd;
|
|
83193
|
-
const
|
|
83284
|
+
const fs20 = (0, node_1.default)();
|
|
83194
83285
|
const handler = (err, buffer) => {
|
|
83195
83286
|
if (fd) {
|
|
83196
|
-
|
|
83287
|
+
fs20.closeSync(fd);
|
|
83197
83288
|
}
|
|
83198
83289
|
if (err) {
|
|
83199
83290
|
reject(err);
|
|
@@ -83205,9 +83296,9 @@ var require_lib2 = __commonJS({
|
|
|
83205
83296
|
};
|
|
83206
83297
|
const sampleSize = (opts === null || opts === void 0 ? void 0 : opts.sampleSize) || 0;
|
|
83207
83298
|
if (sampleSize > 0) {
|
|
83208
|
-
fd =
|
|
83299
|
+
fd = fs20.openSync(filepath, "r");
|
|
83209
83300
|
let sample = Buffer.allocUnsafe(sampleSize);
|
|
83210
|
-
|
|
83301
|
+
fs20.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
|
|
83211
83302
|
if (err) {
|
|
83212
83303
|
handler(err, null);
|
|
83213
83304
|
} else {
|
|
@@ -83219,22 +83310,22 @@ var require_lib2 = __commonJS({
|
|
|
83219
83310
|
});
|
|
83220
83311
|
return;
|
|
83221
83312
|
}
|
|
83222
|
-
|
|
83313
|
+
fs20.readFile(filepath, handler);
|
|
83223
83314
|
});
|
|
83224
83315
|
exports2.detectFile = detectFile;
|
|
83225
83316
|
var detectFileSync = (filepath, opts = {}) => {
|
|
83226
|
-
const
|
|
83317
|
+
const fs20 = (0, node_1.default)();
|
|
83227
83318
|
if (opts && opts.sampleSize) {
|
|
83228
|
-
const fd =
|
|
83319
|
+
const fd = fs20.openSync(filepath, "r");
|
|
83229
83320
|
let sample = Buffer.allocUnsafe(opts.sampleSize);
|
|
83230
|
-
const bytesRead =
|
|
83321
|
+
const bytesRead = fs20.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
|
|
83231
83322
|
if (bytesRead < opts.sampleSize) {
|
|
83232
83323
|
sample = sample.subarray(0, bytesRead);
|
|
83233
83324
|
}
|
|
83234
|
-
|
|
83325
|
+
fs20.closeSync(fd);
|
|
83235
83326
|
return (0, exports2.detect)(sample);
|
|
83236
83327
|
}
|
|
83237
|
-
return (0, exports2.detect)(
|
|
83328
|
+
return (0, exports2.detect)(fs20.readFileSync(filepath));
|
|
83238
83329
|
};
|
|
83239
83330
|
exports2.detectFileSync = detectFileSync;
|
|
83240
83331
|
exports2.default = {
|
|
@@ -87126,7 +87217,7 @@ function splitStringBySpace(str) {
|
|
|
87126
87217
|
}
|
|
87127
87218
|
return pieces;
|
|
87128
87219
|
}
|
|
87129
|
-
var import_chardet, import_child_process14, import_fs7, import_node_path2, import_node_os4,
|
|
87220
|
+
var import_chardet, import_child_process14, import_fs7, import_node_path2, import_node_os4, import_node_crypto2, import_iconv_lite, ExternalEditor;
|
|
87130
87221
|
var init_esm2 = __esm({
|
|
87131
87222
|
"../../node_modules/@inquirer/external-editor/dist/esm/index.js"() {
|
|
87132
87223
|
"use strict";
|
|
@@ -87135,7 +87226,7 @@ var init_esm2 = __esm({
|
|
|
87135
87226
|
import_fs7 = require("fs");
|
|
87136
87227
|
import_node_path2 = __toESM(require("path"), 1);
|
|
87137
87228
|
import_node_os4 = __toESM(require("os"), 1);
|
|
87138
|
-
|
|
87229
|
+
import_node_crypto2 = require("crypto");
|
|
87139
87230
|
import_iconv_lite = __toESM(require_lib3(), 1);
|
|
87140
87231
|
init_CreateFileError();
|
|
87141
87232
|
init_LaunchEditorError();
|
|
@@ -87194,7 +87285,7 @@ var init_esm2 = __esm({
|
|
|
87194
87285
|
createTemporaryFile() {
|
|
87195
87286
|
try {
|
|
87196
87287
|
const baseDir = this.fileOptions.dir ?? import_node_os4.default.tmpdir();
|
|
87197
|
-
const id = (0,
|
|
87288
|
+
const id = (0, import_node_crypto2.randomUUID)();
|
|
87198
87289
|
const prefix = sanitizeAffix(this.fileOptions.prefix);
|
|
87199
87290
|
const postfix = sanitizeAffix(this.fileOptions.postfix);
|
|
87200
87291
|
const filename = `${prefix}${id}${postfix}`;
|
|
@@ -87639,9 +87730,9 @@ var init_prompt = __esm({
|
|
|
87639
87730
|
init_utils();
|
|
87640
87731
|
init_baseUI();
|
|
87641
87732
|
_ = {
|
|
87642
|
-
set: (obj,
|
|
87733
|
+
set: (obj, path29 = "", value) => {
|
|
87643
87734
|
let pointer = obj;
|
|
87644
|
-
|
|
87735
|
+
path29.split(".").forEach((key, index, arr) => {
|
|
87645
87736
|
if (key === "__proto__" || key === "constructor") return;
|
|
87646
87737
|
if (index === arr.length - 1) {
|
|
87647
87738
|
pointer[key] = value;
|
|
@@ -87651,8 +87742,8 @@ var init_prompt = __esm({
|
|
|
87651
87742
|
pointer = pointer[key];
|
|
87652
87743
|
});
|
|
87653
87744
|
},
|
|
87654
|
-
get: (obj,
|
|
87655
|
-
const travel = (regexp) => String.prototype.split.call(
|
|
87745
|
+
get: (obj, path29 = "", defaultValue) => {
|
|
87746
|
+
const travel = (regexp) => String.prototype.split.call(path29, regexp).filter(Boolean).reduce(
|
|
87656
87747
|
// @ts-expect-error implicit any on res[key]
|
|
87657
87748
|
(res, key) => res !== null && res !== void 0 ? res[key] : res,
|
|
87658
87749
|
obj
|
|
@@ -89117,15 +89208,15 @@ async function loginFlow() {
|
|
|
89117
89208
|
let verificationUrl;
|
|
89118
89209
|
try {
|
|
89119
89210
|
const config2 = loadConfig();
|
|
89120
|
-
const
|
|
89211
|
+
const os29 = await import("os");
|
|
89121
89212
|
const res = await fetch(`${SERVER_URL}/auth/cli/init`, {
|
|
89122
89213
|
method: "POST",
|
|
89123
89214
|
headers: { "Content-Type": "application/json" },
|
|
89124
89215
|
body: JSON.stringify({
|
|
89125
89216
|
clientMachineId: config2.machineId,
|
|
89126
|
-
hostname:
|
|
89127
|
-
platform:
|
|
89128
|
-
arch:
|
|
89217
|
+
hostname: os29.hostname(),
|
|
89218
|
+
platform: os29.platform(),
|
|
89219
|
+
arch: os29.arch()
|
|
89129
89220
|
})
|
|
89130
89221
|
});
|
|
89131
89222
|
if (!res.ok) {
|
|
@@ -89230,8 +89321,8 @@ async function startDaemonFlow() {
|
|
|
89230
89321
|
const { execSync: execSync7 } = await import("child_process");
|
|
89231
89322
|
const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
89232
89323
|
const logPath = getCurrentDaemonLogPath2();
|
|
89233
|
-
const
|
|
89234
|
-
const platform12 =
|
|
89324
|
+
const os29 = await import("os");
|
|
89325
|
+
const platform12 = os29.platform();
|
|
89235
89326
|
try {
|
|
89236
89327
|
if (platform12 === "win32") {
|
|
89237
89328
|
execSync7("start /B adhdev daemon >NUL 2>&1", {
|