adhdev 0.9.49 → 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 +861 -763
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +799 -701
- 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,10 +7708,57 @@ 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) {
|
|
7756
|
+
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
7757
|
+
if (!targetSessionId && !h.currentSession) {
|
|
7758
|
+
return { success: false, error: "No targetSessionId specified \u2014 cannot route command" };
|
|
7759
|
+
}
|
|
7712
7760
|
const provider = h.getProvider(args?.agentType);
|
|
7713
7761
|
const transport = getTargetTransport(h, provider);
|
|
7714
|
-
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
7715
7762
|
const providerType = provider?.type || getCurrentProviderType(h, args?.agentType || "");
|
|
7716
7763
|
const adapter = isCliLikeTransport(transport) ? getTargetedCliAdapter(h, args, provider?.type) : null;
|
|
7717
7764
|
const targetInstance = getTargetInstance(h, args);
|
|
@@ -7816,6 +7863,20 @@ async function handleGetChatDebugBundle(h, args) {
|
|
|
7816
7863
|
recentDebugTrace: getRecentDebugTrace({ limit: 120 })
|
|
7817
7864
|
};
|
|
7818
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
|
+
}
|
|
7819
7880
|
return {
|
|
7820
7881
|
success: true,
|
|
7821
7882
|
bundle,
|
|
@@ -8795,10 +8856,14 @@ async function handleResolveAction(h, args) {
|
|
|
8795
8856
|
}
|
|
8796
8857
|
return { success: false, error: "resolveAction script not available for this provider" };
|
|
8797
8858
|
}
|
|
8798
|
-
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;
|
|
8799
8860
|
var init_chat_commands = __esm({
|
|
8800
8861
|
"../../oss/packages/daemon-core/src/commands/chat-commands.ts"() {
|
|
8801
8862
|
"use strict";
|
|
8863
|
+
fs4 = __toESM(require("fs"));
|
|
8864
|
+
os6 = __toESM(require("os"));
|
|
8865
|
+
path8 = __toESM(require("path"));
|
|
8866
|
+
import_node_crypto = require("crypto");
|
|
8802
8867
|
init_contracts();
|
|
8803
8868
|
init_provider_input_support();
|
|
8804
8869
|
init_read_chat_contract();
|
|
@@ -9039,27 +9104,27 @@ function normalizeWindowsRequestedPath(requestedPath) {
|
|
|
9039
9104
|
function resolveSafePath(requestedPath) {
|
|
9040
9105
|
const rawPath = typeof requestedPath === "string" ? requestedPath.trim() : "";
|
|
9041
9106
|
const inputPath = rawPath || ".";
|
|
9042
|
-
const home =
|
|
9107
|
+
const home = os7.homedir();
|
|
9043
9108
|
if (inputPath.startsWith("~")) {
|
|
9044
|
-
return
|
|
9109
|
+
return path9.resolve(path9.join(home, inputPath.slice(1)));
|
|
9045
9110
|
}
|
|
9046
9111
|
if (process.platform === "win32") {
|
|
9047
9112
|
const normalized = normalizeWindowsRequestedPath(inputPath);
|
|
9048
|
-
if (
|
|
9049
|
-
return
|
|
9113
|
+
if (path9.win32.isAbsolute(normalized)) {
|
|
9114
|
+
return path9.win32.normalize(normalized);
|
|
9050
9115
|
}
|
|
9051
|
-
return
|
|
9116
|
+
return path9.win32.resolve(normalized);
|
|
9052
9117
|
}
|
|
9053
|
-
if (
|
|
9054
|
-
return
|
|
9118
|
+
if (path9.isAbsolute(inputPath)) {
|
|
9119
|
+
return path9.normalize(inputPath);
|
|
9055
9120
|
}
|
|
9056
|
-
return
|
|
9121
|
+
return path9.resolve(inputPath);
|
|
9057
9122
|
}
|
|
9058
9123
|
function listDirectoryEntriesSafe(dirPath) {
|
|
9059
|
-
const entries =
|
|
9124
|
+
const entries = fs5.readdirSync(dirPath, { withFileTypes: true });
|
|
9060
9125
|
const files = [];
|
|
9061
9126
|
for (const entry of entries) {
|
|
9062
|
-
const entryPath =
|
|
9127
|
+
const entryPath = path9.join(dirPath, entry.name);
|
|
9063
9128
|
try {
|
|
9064
9129
|
if (entry.isDirectory()) {
|
|
9065
9130
|
files.push({ name: entry.name, type: "directory" });
|
|
@@ -9068,14 +9133,14 @@ function listDirectoryEntriesSafe(dirPath) {
|
|
|
9068
9133
|
if (entry.isFile()) {
|
|
9069
9134
|
let size;
|
|
9070
9135
|
try {
|
|
9071
|
-
size =
|
|
9136
|
+
size = fs5.statSync(entryPath).size;
|
|
9072
9137
|
} catch {
|
|
9073
9138
|
size = void 0;
|
|
9074
9139
|
}
|
|
9075
9140
|
files.push({ name: entry.name, type: "file", size });
|
|
9076
9141
|
continue;
|
|
9077
9142
|
}
|
|
9078
|
-
const stat4 =
|
|
9143
|
+
const stat4 = fs5.statSync(entryPath);
|
|
9079
9144
|
files.push({
|
|
9080
9145
|
name: entry.name,
|
|
9081
9146
|
type: stat4.isDirectory() ? "directory" : "file",
|
|
@@ -9093,7 +9158,7 @@ function listWindowsDriveEntries(excludePath) {
|
|
|
9093
9158
|
const letter = String.fromCharCode(code);
|
|
9094
9159
|
const root = `${letter}:\\`;
|
|
9095
9160
|
try {
|
|
9096
|
-
if (!
|
|
9161
|
+
if (!fs5.existsSync(root)) continue;
|
|
9097
9162
|
if (excluded && root.toLowerCase() === excluded) continue;
|
|
9098
9163
|
drives.push({ name: `${letter}:`, type: "directory", path: root });
|
|
9099
9164
|
} catch {
|
|
@@ -9104,7 +9169,7 @@ function listWindowsDriveEntries(excludePath) {
|
|
|
9104
9169
|
async function handleFileRead(h, args) {
|
|
9105
9170
|
try {
|
|
9106
9171
|
const filePath = resolveSafePath(args?.path);
|
|
9107
|
-
const content =
|
|
9172
|
+
const content = fs5.readFileSync(filePath, "utf-8");
|
|
9108
9173
|
return { success: true, content, path: filePath };
|
|
9109
9174
|
} catch (e) {
|
|
9110
9175
|
return { success: false, error: e.message };
|
|
@@ -9113,8 +9178,8 @@ async function handleFileRead(h, args) {
|
|
|
9113
9178
|
async function handleFileWrite(h, args) {
|
|
9114
9179
|
try {
|
|
9115
9180
|
const filePath = resolveSafePath(args?.path);
|
|
9116
|
-
|
|
9117
|
-
|
|
9181
|
+
fs5.mkdirSync(path9.dirname(filePath), { recursive: true });
|
|
9182
|
+
fs5.writeFileSync(filePath, args?.content || "", "utf-8");
|
|
9118
9183
|
return { success: true, path: filePath };
|
|
9119
9184
|
} catch (e) {
|
|
9120
9185
|
return { success: false, error: e.message };
|
|
@@ -9146,13 +9211,13 @@ async function handleFileListBrowse(h, args) {
|
|
|
9146
9211
|
return { success: false, error: e.message };
|
|
9147
9212
|
}
|
|
9148
9213
|
}
|
|
9149
|
-
var
|
|
9214
|
+
var fs5, path9, os7, KEY_TO_VK;
|
|
9150
9215
|
var init_cdp_commands = __esm({
|
|
9151
9216
|
"../../oss/packages/daemon-core/src/commands/cdp-commands.ts"() {
|
|
9152
9217
|
"use strict";
|
|
9153
|
-
|
|
9154
|
-
|
|
9155
|
-
|
|
9218
|
+
fs5 = __toESM(require("fs"));
|
|
9219
|
+
path9 = __toESM(require("path"));
|
|
9220
|
+
os7 = __toESM(require("os"));
|
|
9156
9221
|
KEY_TO_VK = {
|
|
9157
9222
|
Backspace: 8,
|
|
9158
9223
|
Tab: 9,
|
|
@@ -10037,6 +10102,7 @@ var init_handler = __esm({
|
|
|
10037
10102
|
this.logCommandStart(cmd, args);
|
|
10038
10103
|
const sessionScopedCommands = /* @__PURE__ */ new Set([
|
|
10039
10104
|
"read_chat",
|
|
10105
|
+
"get_chat_debug_bundle",
|
|
10040
10106
|
"send_chat",
|
|
10041
10107
|
"list_chats",
|
|
10042
10108
|
"new_chat",
|
|
@@ -11092,7 +11158,7 @@ function getDefaultSessionHostEndpoint(appName = "adhdev") {
|
|
|
11092
11158
|
}
|
|
11093
11159
|
return {
|
|
11094
11160
|
kind: "unix",
|
|
11095
|
-
path: path22.join(
|
|
11161
|
+
path: path22.join(os9.tmpdir(), `${appName}-session-host.sock`)
|
|
11096
11162
|
};
|
|
11097
11163
|
}
|
|
11098
11164
|
function serializeEnvelope(envelope) {
|
|
@@ -11145,25 +11211,25 @@ function applyTerminalColorEnv(env3) {
|
|
|
11145
11211
|
function ensureNodePtySpawnHelperPermissions(logFn) {
|
|
11146
11212
|
if (os22.platform() === "win32") return;
|
|
11147
11213
|
try {
|
|
11148
|
-
const
|
|
11214
|
+
const fs20 = __require("fs");
|
|
11149
11215
|
const ptyDir = path32.resolve(path32.dirname(__require.resolve("node-pty")), "..");
|
|
11150
11216
|
const platformArch = `${os22.platform()}-${os22.arch()}`;
|
|
11151
11217
|
const helper = path32.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
11152
|
-
if (
|
|
11153
|
-
const stat4 =
|
|
11218
|
+
if (fs20.existsSync(helper)) {
|
|
11219
|
+
const stat4 = fs20.statSync(helper);
|
|
11154
11220
|
if (!(stat4.mode & 73)) {
|
|
11155
|
-
|
|
11221
|
+
fs20.chmodSync(helper, stat4.mode | 493);
|
|
11156
11222
|
logFn?.(`Fixed spawn-helper permissions: ${helper}`);
|
|
11157
11223
|
}
|
|
11158
11224
|
}
|
|
11159
11225
|
} catch {
|
|
11160
11226
|
}
|
|
11161
11227
|
}
|
|
11162
|
-
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;
|
|
11163
11229
|
var init_dist = __esm({
|
|
11164
11230
|
"../../oss/packages/session-host-core/dist/index.mjs"() {
|
|
11165
11231
|
"use strict";
|
|
11166
|
-
|
|
11232
|
+
os9 = __toESM(require("os"), 1);
|
|
11167
11233
|
path22 = __toESM(require("path"), 1);
|
|
11168
11234
|
net = __toESM(require("net"), 1);
|
|
11169
11235
|
import_crypto3 = require("crypto");
|
|
@@ -11306,11 +11372,11 @@ function loadNodePty() {
|
|
|
11306
11372
|
}
|
|
11307
11373
|
return cachedPty;
|
|
11308
11374
|
}
|
|
11309
|
-
var
|
|
11375
|
+
var os10, cachedPty, NodePtyRuntimeTransport, NodePtyTransportFactory;
|
|
11310
11376
|
var init_pty_transport = __esm({
|
|
11311
11377
|
"../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts"() {
|
|
11312
11378
|
"use strict";
|
|
11313
|
-
|
|
11379
|
+
os10 = __toESM(require("os"));
|
|
11314
11380
|
init_spawn_env();
|
|
11315
11381
|
NodePtyRuntimeTransport = class {
|
|
11316
11382
|
constructor(handle) {
|
|
@@ -11347,11 +11413,11 @@ var init_pty_transport = __esm({
|
|
|
11347
11413
|
let cwd = options.cwd;
|
|
11348
11414
|
if (cwd) {
|
|
11349
11415
|
try {
|
|
11350
|
-
const
|
|
11351
|
-
const stat4 =
|
|
11352
|
-
if (!stat4.isDirectory()) cwd =
|
|
11416
|
+
const fs20 = require("fs");
|
|
11417
|
+
const stat4 = fs20.statSync(cwd);
|
|
11418
|
+
if (!stat4.isDirectory()) cwd = os10.homedir();
|
|
11353
11419
|
} catch {
|
|
11354
|
-
cwd =
|
|
11420
|
+
cwd = os10.homedir();
|
|
11355
11421
|
}
|
|
11356
11422
|
}
|
|
11357
11423
|
const handle = pty.spawn(command, args, {
|
|
@@ -11431,11 +11497,11 @@ function buildCliScreenSnapshot(text) {
|
|
|
11431
11497
|
function findBinary(name) {
|
|
11432
11498
|
const trimmed = String(name || "").trim();
|
|
11433
11499
|
if (!trimmed) return trimmed;
|
|
11434
|
-
const expanded = trimmed.startsWith("~") ?
|
|
11435
|
-
if (
|
|
11436
|
-
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);
|
|
11437
11503
|
}
|
|
11438
|
-
const isWin =
|
|
11504
|
+
const isWin = os11.platform() === "win32";
|
|
11439
11505
|
try {
|
|
11440
11506
|
const cmd = isWin ? `where ${trimmed}` : `which ${trimmed}`;
|
|
11441
11507
|
return (0, import_child_process4.execSync)(cmd, {
|
|
@@ -11449,14 +11515,14 @@ function findBinary(name) {
|
|
|
11449
11515
|
}
|
|
11450
11516
|
}
|
|
11451
11517
|
function isScriptBinary(binaryPath) {
|
|
11452
|
-
if (!
|
|
11518
|
+
if (!path10.isAbsolute(binaryPath)) return false;
|
|
11453
11519
|
try {
|
|
11454
|
-
const
|
|
11455
|
-
const resolved =
|
|
11520
|
+
const fs20 = require("fs");
|
|
11521
|
+
const resolved = fs20.realpathSync(binaryPath);
|
|
11456
11522
|
const head = Buffer.alloc(8);
|
|
11457
|
-
const fd =
|
|
11458
|
-
|
|
11459
|
-
|
|
11523
|
+
const fd = fs20.openSync(resolved, "r");
|
|
11524
|
+
fs20.readSync(fd, head, 0, 8, 0);
|
|
11525
|
+
fs20.closeSync(fd);
|
|
11460
11526
|
let i = 0;
|
|
11461
11527
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
11462
11528
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -11465,14 +11531,14 @@ function isScriptBinary(binaryPath) {
|
|
|
11465
11531
|
}
|
|
11466
11532
|
}
|
|
11467
11533
|
function looksLikeMachOOrElf(filePath) {
|
|
11468
|
-
if (!
|
|
11534
|
+
if (!path10.isAbsolute(filePath)) return false;
|
|
11469
11535
|
try {
|
|
11470
|
-
const
|
|
11471
|
-
const resolved =
|
|
11536
|
+
const fs20 = require("fs");
|
|
11537
|
+
const resolved = fs20.realpathSync(filePath);
|
|
11472
11538
|
const buf = Buffer.alloc(8);
|
|
11473
|
-
const fd =
|
|
11474
|
-
|
|
11475
|
-
|
|
11539
|
+
const fd = fs20.openSync(resolved, "r");
|
|
11540
|
+
fs20.readSync(fd, buf, 0, 8, 0);
|
|
11541
|
+
fs20.closeSync(fd);
|
|
11476
11542
|
let i = 0;
|
|
11477
11543
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
11478
11544
|
const b = buf.subarray(i);
|
|
@@ -11488,7 +11554,7 @@ function looksLikeMachOOrElf(filePath) {
|
|
|
11488
11554
|
}
|
|
11489
11555
|
function shSingleQuote(arg) {
|
|
11490
11556
|
if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
|
|
11491
|
-
if (
|
|
11557
|
+
if (os11.platform() === "win32") {
|
|
11492
11558
|
return `"${arg.replace(/"/g, '""')}"`;
|
|
11493
11559
|
}
|
|
11494
11560
|
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
@@ -11615,12 +11681,12 @@ function normalizeCliProviderForRuntime(raw) {
|
|
|
11615
11681
|
}
|
|
11616
11682
|
};
|
|
11617
11683
|
}
|
|
11618
|
-
var
|
|
11684
|
+
var os11, path10, import_child_process4, buildCliSpawnEnv, COMMON_COMPARABLE_WRAP_WORDS;
|
|
11619
11685
|
var init_provider_cli_shared = __esm({
|
|
11620
11686
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-shared.ts"() {
|
|
11621
11687
|
"use strict";
|
|
11622
|
-
|
|
11623
|
-
|
|
11688
|
+
os11 = __toESM(require("os"));
|
|
11689
|
+
path10 = __toESM(require("path"));
|
|
11624
11690
|
import_child_process4 = require("child_process");
|
|
11625
11691
|
init_spawn_env();
|
|
11626
11692
|
buildCliSpawnEnv = sanitizeSpawnEnv;
|
|
@@ -11933,13 +11999,13 @@ function resolveCliSpawnPlan(options) {
|
|
|
11933
11999
|
const { spawn: spawnConfig } = provider;
|
|
11934
12000
|
const configuredCommand = typeof runtimeSettings.executablePath === "string" && runtimeSettings.executablePath.trim() ? runtimeSettings.executablePath.trim() : spawnConfig.command;
|
|
11935
12001
|
const binaryPath = findBinary(configuredCommand);
|
|
11936
|
-
const isWin =
|
|
12002
|
+
const isWin = os12.platform() === "win32";
|
|
11937
12003
|
const allArgs = [...spawnConfig.args, ...extraArgs];
|
|
11938
12004
|
let shellCmd;
|
|
11939
12005
|
let shellArgs;
|
|
11940
|
-
const useShellUnix = !isWin && (!!spawnConfig.shell || !
|
|
12006
|
+
const useShellUnix = !isWin && (!!spawnConfig.shell || !path11.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
11941
12007
|
const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
|
|
11942
|
-
const useShellWin = !!spawnConfig.shell || isCmdShim || !
|
|
12008
|
+
const useShellWin = !!spawnConfig.shell || isCmdShim || !path11.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
|
|
11943
12009
|
const useShell = isWin ? useShellWin : useShellUnix;
|
|
11944
12010
|
if (useShell) {
|
|
11945
12011
|
shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
|
|
@@ -12015,12 +12081,12 @@ function respondToCliTerminalQueries(options) {
|
|
|
12015
12081
|
}
|
|
12016
12082
|
return "";
|
|
12017
12083
|
}
|
|
12018
|
-
var
|
|
12084
|
+
var os12, path11;
|
|
12019
12085
|
var init_provider_cli_runtime = __esm({
|
|
12020
12086
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-runtime.ts"() {
|
|
12021
12087
|
"use strict";
|
|
12022
|
-
|
|
12023
|
-
|
|
12088
|
+
os12 = __toESM(require("os"));
|
|
12089
|
+
path11 = __toESM(require("path"));
|
|
12024
12090
|
init_dist();
|
|
12025
12091
|
init_provider_cli_shared();
|
|
12026
12092
|
}
|
|
@@ -12142,11 +12208,11 @@ function trimLastAssistantEchoForCliMessages(messages, prompt2) {
|
|
|
12142
12208
|
return;
|
|
12143
12209
|
}
|
|
12144
12210
|
}
|
|
12145
|
-
var
|
|
12211
|
+
var os13, COMMITTED_ACTIVITY_PREFIX_BLOCK_RE, ProviderCliAdapter;
|
|
12146
12212
|
var init_provider_cli_adapter = __esm({
|
|
12147
12213
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
|
|
12148
12214
|
"use strict";
|
|
12149
|
-
|
|
12215
|
+
os13 = __toESM(require("os"));
|
|
12150
12216
|
init_logger();
|
|
12151
12217
|
init_debug_config();
|
|
12152
12218
|
init_terminal_screen();
|
|
@@ -12166,7 +12232,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
12166
12232
|
this.transportFactory = transportFactory;
|
|
12167
12233
|
this.cliType = provider.type;
|
|
12168
12234
|
this.cliName = provider.name;
|
|
12169
|
-
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/,
|
|
12235
|
+
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os13.homedir()) : workingDir;
|
|
12170
12236
|
const resolvedConfig = resolveCliAdapterConfig(provider);
|
|
12171
12237
|
this.timeouts = resolvedConfig.timeouts;
|
|
12172
12238
|
this.approvalKeys = resolvedConfig.approvalKeys;
|
|
@@ -14549,7 +14615,7 @@ function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages
|
|
|
14549
14615
|
}
|
|
14550
14616
|
function getDatabaseSync() {
|
|
14551
14617
|
if (CachedDatabaseSync) return CachedDatabaseSync;
|
|
14552
|
-
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"));
|
|
14553
14619
|
const sqliteModule = requireFn(`node:${"sqlite"}`);
|
|
14554
14620
|
CachedDatabaseSync = sqliteModule.DatabaseSync;
|
|
14555
14621
|
if (!CachedDatabaseSync) {
|
|
@@ -14591,14 +14657,14 @@ async function waitForCliAdapterReady(adapter, options) {
|
|
|
14591
14657
|
}
|
|
14592
14658
|
throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
|
|
14593
14659
|
}
|
|
14594
|
-
var
|
|
14660
|
+
var os14, path12, crypto3, fs6, import_node_module, CachedDatabaseSync, CliProviderInstance;
|
|
14595
14661
|
var init_cli_provider_instance = __esm({
|
|
14596
14662
|
"../../oss/packages/daemon-core/src/providers/cli-provider-instance.ts"() {
|
|
14597
14663
|
"use strict";
|
|
14598
|
-
|
|
14599
|
-
|
|
14664
|
+
os14 = __toESM(require("os"));
|
|
14665
|
+
path12 = __toESM(require("path"));
|
|
14600
14666
|
crypto3 = __toESM(require("crypto"));
|
|
14601
|
-
|
|
14667
|
+
fs6 = __toESM(require("fs"));
|
|
14602
14668
|
import_node_module = require("module");
|
|
14603
14669
|
init_contracts();
|
|
14604
14670
|
init_provider_input_support();
|
|
@@ -14721,10 +14787,10 @@ var init_cli_provider_instance = __esm({
|
|
|
14721
14787
|
* Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
|
|
14722
14788
|
*/
|
|
14723
14789
|
probeSessionIdFromConfig(probe) {
|
|
14724
|
-
const resolvedDbPath = probe.dbPath.replace(/^~/,
|
|
14790
|
+
const resolvedDbPath = probe.dbPath.replace(/^~/, os14.homedir());
|
|
14725
14791
|
const now = Date.now();
|
|
14726
14792
|
if (this.cachedSqliteDbMissingUntil > now) return null;
|
|
14727
|
-
if (!
|
|
14793
|
+
if (!fs6.existsSync(resolvedDbPath)) {
|
|
14728
14794
|
this.cachedSqliteDbMissingUntil = now + 1e4;
|
|
14729
14795
|
return null;
|
|
14730
14796
|
}
|
|
@@ -15456,7 +15522,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
15456
15522
|
};
|
|
15457
15523
|
addDir(this.workingDir);
|
|
15458
15524
|
try {
|
|
15459
|
-
addDir(
|
|
15525
|
+
addDir(fs6.realpathSync.native(this.workingDir));
|
|
15460
15526
|
} catch {
|
|
15461
15527
|
}
|
|
15462
15528
|
return Array.from(dirs);
|
|
@@ -15747,10 +15813,10 @@ function mergeDefs(...defs) {
|
|
|
15747
15813
|
function cloneDef(schema) {
|
|
15748
15814
|
return mergeDefs(schema._zod.def);
|
|
15749
15815
|
}
|
|
15750
|
-
function getElementAtPath(obj,
|
|
15751
|
-
if (!
|
|
15816
|
+
function getElementAtPath(obj, path29) {
|
|
15817
|
+
if (!path29)
|
|
15752
15818
|
return obj;
|
|
15753
|
-
return
|
|
15819
|
+
return path29.reduce((acc, key) => acc?.[key], obj);
|
|
15754
15820
|
}
|
|
15755
15821
|
function promiseAllObject(promisesObj) {
|
|
15756
15822
|
const keys = Object.keys(promisesObj);
|
|
@@ -16062,11 +16128,11 @@ function aborted(x, startIndex = 0) {
|
|
|
16062
16128
|
}
|
|
16063
16129
|
return false;
|
|
16064
16130
|
}
|
|
16065
|
-
function prefixIssues(
|
|
16131
|
+
function prefixIssues(path29, issues) {
|
|
16066
16132
|
return issues.map((iss) => {
|
|
16067
16133
|
var _a2;
|
|
16068
16134
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
16069
|
-
iss.path.unshift(
|
|
16135
|
+
iss.path.unshift(path29);
|
|
16070
16136
|
return iss;
|
|
16071
16137
|
});
|
|
16072
16138
|
}
|
|
@@ -16309,7 +16375,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
16309
16375
|
}
|
|
16310
16376
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
16311
16377
|
const result = { errors: [] };
|
|
16312
|
-
const processError = (error49,
|
|
16378
|
+
const processError = (error49, path29 = []) => {
|
|
16313
16379
|
var _a2, _b;
|
|
16314
16380
|
for (const issue2 of error49.issues) {
|
|
16315
16381
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -16319,7 +16385,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
16319
16385
|
} else if (issue2.code === "invalid_element") {
|
|
16320
16386
|
processError({ issues: issue2.issues }, issue2.path);
|
|
16321
16387
|
} else {
|
|
16322
|
-
const fullpath = [...
|
|
16388
|
+
const fullpath = [...path29, ...issue2.path];
|
|
16323
16389
|
if (fullpath.length === 0) {
|
|
16324
16390
|
result.errors.push(mapper(issue2));
|
|
16325
16391
|
continue;
|
|
@@ -16351,8 +16417,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
16351
16417
|
}
|
|
16352
16418
|
function toDotPath(_path) {
|
|
16353
16419
|
const segs = [];
|
|
16354
|
-
const
|
|
16355
|
-
for (const seg of
|
|
16420
|
+
const path29 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
16421
|
+
for (const seg of path29) {
|
|
16356
16422
|
if (typeof seg === "number")
|
|
16357
16423
|
segs.push(`[${seg}]`);
|
|
16358
16424
|
else if (typeof seg === "symbol")
|
|
@@ -29116,13 +29182,13 @@ function resolveRef(ref, ctx) {
|
|
|
29116
29182
|
if (!ref.startsWith("#")) {
|
|
29117
29183
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
29118
29184
|
}
|
|
29119
|
-
const
|
|
29120
|
-
if (
|
|
29185
|
+
const path29 = ref.slice(1).split("/").filter(Boolean);
|
|
29186
|
+
if (path29.length === 0) {
|
|
29121
29187
|
return ctx.rootSchema;
|
|
29122
29188
|
}
|
|
29123
29189
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
29124
|
-
if (
|
|
29125
|
-
const key =
|
|
29190
|
+
if (path29[0] === defsKey) {
|
|
29191
|
+
const key = path29[1];
|
|
29126
29192
|
if (!key || !ctx.defs[key]) {
|
|
29127
29193
|
throw new Error(`Reference not found: ${ref}`);
|
|
29128
29194
|
}
|
|
@@ -32968,11 +33034,11 @@ var init_hosted_runtime_restore = __esm({
|
|
|
32968
33034
|
// ../../oss/packages/daemon-core/src/commands/cli-manager.ts
|
|
32969
33035
|
function isExplicitCommand(command) {
|
|
32970
33036
|
const trimmed = command.trim();
|
|
32971
|
-
return
|
|
33037
|
+
return path13.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
|
|
32972
33038
|
}
|
|
32973
33039
|
function expandExecutable(command) {
|
|
32974
33040
|
const trimmed = command.trim();
|
|
32975
|
-
return trimmed.startsWith("~") ?
|
|
33041
|
+
return trimmed.startsWith("~") ? path13.join(os15.homedir(), trimmed.slice(1)) : trimmed;
|
|
32976
33042
|
}
|
|
32977
33043
|
function commandExists(command) {
|
|
32978
33044
|
const trimmed = command.trim();
|
|
@@ -33109,12 +33175,12 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
|
|
|
33109
33175
|
launchMode: "new"
|
|
33110
33176
|
};
|
|
33111
33177
|
}
|
|
33112
|
-
var
|
|
33178
|
+
var os15, path13, crypto4, import_fs5, import_child_process6, chalkModule, chalkApi, DaemonCliManager;
|
|
33113
33179
|
var init_cli_manager = __esm({
|
|
33114
33180
|
"../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
|
|
33115
33181
|
"use strict";
|
|
33116
|
-
|
|
33117
|
-
|
|
33182
|
+
os15 = __toESM(require("os"));
|
|
33183
|
+
path13 = __toESM(require("path"));
|
|
33118
33184
|
crypto4 = __toESM(require("crypto"));
|
|
33119
33185
|
import_fs5 = require("fs");
|
|
33120
33186
|
import_child_process6 = require("child_process");
|
|
@@ -33277,7 +33343,7 @@ var init_cli_manager = __esm({
|
|
|
33277
33343
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
33278
33344
|
const trimmed = (workingDir || "").trim();
|
|
33279
33345
|
if (!trimmed) throw new Error("working directory required");
|
|
33280
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/,
|
|
33346
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os15.homedir()) : path13.resolve(trimmed);
|
|
33281
33347
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
33282
33348
|
const rawProvider = this.providerLoader.getByAlias(cliType);
|
|
33283
33349
|
const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
|
|
@@ -33880,7 +33946,7 @@ var init_readdirp = __esm({
|
|
|
33880
33946
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
33881
33947
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
33882
33948
|
if (wantBigintFsStats) {
|
|
33883
|
-
this._stat = (
|
|
33949
|
+
this._stat = (path29) => statMethod(path29, { bigint: true });
|
|
33884
33950
|
} else {
|
|
33885
33951
|
this._stat = statMethod;
|
|
33886
33952
|
}
|
|
@@ -33905,8 +33971,8 @@ var init_readdirp = __esm({
|
|
|
33905
33971
|
const par = this.parent;
|
|
33906
33972
|
const fil = par && par.files;
|
|
33907
33973
|
if (fil && fil.length > 0) {
|
|
33908
|
-
const { path:
|
|
33909
|
-
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));
|
|
33910
33976
|
const awaited = await Promise.all(slice);
|
|
33911
33977
|
for (const entry of awaited) {
|
|
33912
33978
|
if (!entry)
|
|
@@ -33946,20 +34012,20 @@ var init_readdirp = __esm({
|
|
|
33946
34012
|
this.reading = false;
|
|
33947
34013
|
}
|
|
33948
34014
|
}
|
|
33949
|
-
async _exploreDir(
|
|
34015
|
+
async _exploreDir(path29, depth) {
|
|
33950
34016
|
let files;
|
|
33951
34017
|
try {
|
|
33952
|
-
files = await (0, import_promises.readdir)(
|
|
34018
|
+
files = await (0, import_promises.readdir)(path29, this._rdOptions);
|
|
33953
34019
|
} catch (error48) {
|
|
33954
34020
|
this._onError(error48);
|
|
33955
34021
|
}
|
|
33956
|
-
return { files, depth, path:
|
|
34022
|
+
return { files, depth, path: path29 };
|
|
33957
34023
|
}
|
|
33958
|
-
async _formatEntry(dirent,
|
|
34024
|
+
async _formatEntry(dirent, path29) {
|
|
33959
34025
|
let entry;
|
|
33960
34026
|
const basename9 = this._isDirent ? dirent.name : dirent;
|
|
33961
34027
|
try {
|
|
33962
|
-
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));
|
|
33963
34029
|
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename9 };
|
|
33964
34030
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
33965
34031
|
} catch (err) {
|
|
@@ -34016,16 +34082,16 @@ var init_readdirp = __esm({
|
|
|
34016
34082
|
});
|
|
34017
34083
|
|
|
34018
34084
|
// ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
|
|
34019
|
-
function createFsWatchInstance(
|
|
34085
|
+
function createFsWatchInstance(path29, options, listener, errHandler, emitRaw) {
|
|
34020
34086
|
const handleEvent = (rawEvent, evPath) => {
|
|
34021
|
-
listener(
|
|
34022
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
34023
|
-
if (evPath &&
|
|
34024
|
-
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));
|
|
34025
34091
|
}
|
|
34026
34092
|
};
|
|
34027
34093
|
try {
|
|
34028
|
-
return (0, import_node_fs.watch)(
|
|
34094
|
+
return (0, import_node_fs.watch)(path29, {
|
|
34029
34095
|
persistent: options.persistent
|
|
34030
34096
|
}, handleEvent);
|
|
34031
34097
|
} catch (error48) {
|
|
@@ -34374,12 +34440,12 @@ var init_handler2 = __esm({
|
|
|
34374
34440
|
listener(val1, val2, val3);
|
|
34375
34441
|
});
|
|
34376
34442
|
};
|
|
34377
|
-
setFsWatchListener = (
|
|
34443
|
+
setFsWatchListener = (path29, fullPath, options, handlers) => {
|
|
34378
34444
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
34379
34445
|
let cont = FsWatchInstances.get(fullPath);
|
|
34380
34446
|
let watcher;
|
|
34381
34447
|
if (!options.persistent) {
|
|
34382
|
-
watcher = createFsWatchInstance(
|
|
34448
|
+
watcher = createFsWatchInstance(path29, options, listener, errHandler, rawEmitter);
|
|
34383
34449
|
if (!watcher)
|
|
34384
34450
|
return;
|
|
34385
34451
|
return watcher.close.bind(watcher);
|
|
@@ -34390,7 +34456,7 @@ var init_handler2 = __esm({
|
|
|
34390
34456
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
34391
34457
|
} else {
|
|
34392
34458
|
watcher = createFsWatchInstance(
|
|
34393
|
-
|
|
34459
|
+
path29,
|
|
34394
34460
|
options,
|
|
34395
34461
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
34396
34462
|
errHandler,
|
|
@@ -34405,7 +34471,7 @@ var init_handler2 = __esm({
|
|
|
34405
34471
|
cont.watcherUnusable = true;
|
|
34406
34472
|
if (isWindows && error48.code === "EPERM") {
|
|
34407
34473
|
try {
|
|
34408
|
-
const fd = await (0, import_promises2.open)(
|
|
34474
|
+
const fd = await (0, import_promises2.open)(path29, "r");
|
|
34409
34475
|
await fd.close();
|
|
34410
34476
|
broadcastErr(error48);
|
|
34411
34477
|
} catch (err) {
|
|
@@ -34436,7 +34502,7 @@ var init_handler2 = __esm({
|
|
|
34436
34502
|
};
|
|
34437
34503
|
};
|
|
34438
34504
|
FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
34439
|
-
setFsWatchFileListener = (
|
|
34505
|
+
setFsWatchFileListener = (path29, fullPath, options, handlers) => {
|
|
34440
34506
|
const { listener, rawEmitter } = handlers;
|
|
34441
34507
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
34442
34508
|
const copts = cont && cont.options;
|
|
@@ -34458,7 +34524,7 @@ var init_handler2 = __esm({
|
|
|
34458
34524
|
});
|
|
34459
34525
|
const currmtime = curr.mtimeMs;
|
|
34460
34526
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
34461
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
34527
|
+
foreach(cont.listeners, (listener2) => listener2(path29, curr));
|
|
34462
34528
|
}
|
|
34463
34529
|
})
|
|
34464
34530
|
};
|
|
@@ -34488,13 +34554,13 @@ var init_handler2 = __esm({
|
|
|
34488
34554
|
* @param listener on fs change
|
|
34489
34555
|
* @returns closer for the watcher instance
|
|
34490
34556
|
*/
|
|
34491
|
-
_watchWithNodeFs(
|
|
34557
|
+
_watchWithNodeFs(path29, listener) {
|
|
34492
34558
|
const opts = this.fsw.options;
|
|
34493
|
-
const directory = sp.dirname(
|
|
34494
|
-
const basename9 = sp.basename(
|
|
34559
|
+
const directory = sp.dirname(path29);
|
|
34560
|
+
const basename9 = sp.basename(path29);
|
|
34495
34561
|
const parent = this.fsw._getWatchedDir(directory);
|
|
34496
34562
|
parent.add(basename9);
|
|
34497
|
-
const absolutePath = sp.resolve(
|
|
34563
|
+
const absolutePath = sp.resolve(path29);
|
|
34498
34564
|
const options = {
|
|
34499
34565
|
persistent: opts.persistent
|
|
34500
34566
|
};
|
|
@@ -34504,12 +34570,12 @@ var init_handler2 = __esm({
|
|
|
34504
34570
|
if (opts.usePolling) {
|
|
34505
34571
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
34506
34572
|
options.interval = enableBin && isBinaryPath(basename9) ? opts.binaryInterval : opts.interval;
|
|
34507
|
-
closer = setFsWatchFileListener(
|
|
34573
|
+
closer = setFsWatchFileListener(path29, absolutePath, options, {
|
|
34508
34574
|
listener,
|
|
34509
34575
|
rawEmitter: this.fsw._emitRaw
|
|
34510
34576
|
});
|
|
34511
34577
|
} else {
|
|
34512
|
-
closer = setFsWatchListener(
|
|
34578
|
+
closer = setFsWatchListener(path29, absolutePath, options, {
|
|
34513
34579
|
listener,
|
|
34514
34580
|
errHandler: this._boundHandleError,
|
|
34515
34581
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -34531,7 +34597,7 @@ var init_handler2 = __esm({
|
|
|
34531
34597
|
let prevStats = stats;
|
|
34532
34598
|
if (parent.has(basename9))
|
|
34533
34599
|
return;
|
|
34534
|
-
const listener = async (
|
|
34600
|
+
const listener = async (path29, newStats) => {
|
|
34535
34601
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
34536
34602
|
return;
|
|
34537
34603
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -34545,11 +34611,11 @@ var init_handler2 = __esm({
|
|
|
34545
34611
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
34546
34612
|
}
|
|
34547
34613
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
34548
|
-
this.fsw._closeFile(
|
|
34614
|
+
this.fsw._closeFile(path29);
|
|
34549
34615
|
prevStats = newStats2;
|
|
34550
34616
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
34551
34617
|
if (closer2)
|
|
34552
|
-
this.fsw._addPathCloser(
|
|
34618
|
+
this.fsw._addPathCloser(path29, closer2);
|
|
34553
34619
|
} else {
|
|
34554
34620
|
prevStats = newStats2;
|
|
34555
34621
|
}
|
|
@@ -34581,7 +34647,7 @@ var init_handler2 = __esm({
|
|
|
34581
34647
|
* @param item basename of this item
|
|
34582
34648
|
* @returns true if no more processing is needed for this entry.
|
|
34583
34649
|
*/
|
|
34584
|
-
async _handleSymlink(entry, directory,
|
|
34650
|
+
async _handleSymlink(entry, directory, path29, item) {
|
|
34585
34651
|
if (this.fsw.closed) {
|
|
34586
34652
|
return;
|
|
34587
34653
|
}
|
|
@@ -34591,7 +34657,7 @@ var init_handler2 = __esm({
|
|
|
34591
34657
|
this.fsw._incrReadyCount();
|
|
34592
34658
|
let linkPath;
|
|
34593
34659
|
try {
|
|
34594
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
34660
|
+
linkPath = await (0, import_promises2.realpath)(path29);
|
|
34595
34661
|
} catch (e) {
|
|
34596
34662
|
this.fsw._emitReady();
|
|
34597
34663
|
return true;
|
|
@@ -34601,12 +34667,12 @@ var init_handler2 = __esm({
|
|
|
34601
34667
|
if (dir.has(item)) {
|
|
34602
34668
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
34603
34669
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
34604
|
-
this.fsw._emit(EV.CHANGE,
|
|
34670
|
+
this.fsw._emit(EV.CHANGE, path29, entry.stats);
|
|
34605
34671
|
}
|
|
34606
34672
|
} else {
|
|
34607
34673
|
dir.add(item);
|
|
34608
34674
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
34609
|
-
this.fsw._emit(EV.ADD,
|
|
34675
|
+
this.fsw._emit(EV.ADD, path29, entry.stats);
|
|
34610
34676
|
}
|
|
34611
34677
|
this.fsw._emitReady();
|
|
34612
34678
|
return true;
|
|
@@ -34636,9 +34702,9 @@ var init_handler2 = __esm({
|
|
|
34636
34702
|
return;
|
|
34637
34703
|
}
|
|
34638
34704
|
const item = entry.path;
|
|
34639
|
-
let
|
|
34705
|
+
let path29 = sp.join(directory, item);
|
|
34640
34706
|
current.add(item);
|
|
34641
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
34707
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path29, item)) {
|
|
34642
34708
|
return;
|
|
34643
34709
|
}
|
|
34644
34710
|
if (this.fsw.closed) {
|
|
@@ -34647,8 +34713,8 @@ var init_handler2 = __esm({
|
|
|
34647
34713
|
}
|
|
34648
34714
|
if (item === target || !target && !previous.has(item)) {
|
|
34649
34715
|
this.fsw._incrReadyCount();
|
|
34650
|
-
|
|
34651
|
-
this._addToNodeFs(
|
|
34716
|
+
path29 = sp.join(dir, sp.relative(dir, path29));
|
|
34717
|
+
this._addToNodeFs(path29, initialAdd, wh, depth + 1);
|
|
34652
34718
|
}
|
|
34653
34719
|
}).on(EV.ERROR, this._boundHandleError);
|
|
34654
34720
|
return new Promise((resolve16, reject) => {
|
|
@@ -34717,13 +34783,13 @@ var init_handler2 = __esm({
|
|
|
34717
34783
|
* @param depth Child path actually targeted for watch
|
|
34718
34784
|
* @param target Child path actually targeted for watch
|
|
34719
34785
|
*/
|
|
34720
|
-
async _addToNodeFs(
|
|
34786
|
+
async _addToNodeFs(path29, initialAdd, priorWh, depth, target) {
|
|
34721
34787
|
const ready = this.fsw._emitReady;
|
|
34722
|
-
if (this.fsw._isIgnored(
|
|
34788
|
+
if (this.fsw._isIgnored(path29) || this.fsw.closed) {
|
|
34723
34789
|
ready();
|
|
34724
34790
|
return false;
|
|
34725
34791
|
}
|
|
34726
|
-
const wh = this.fsw._getWatchHelpers(
|
|
34792
|
+
const wh = this.fsw._getWatchHelpers(path29);
|
|
34727
34793
|
if (priorWh) {
|
|
34728
34794
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
34729
34795
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -34739,8 +34805,8 @@ var init_handler2 = __esm({
|
|
|
34739
34805
|
const follow = this.fsw.options.followSymlinks;
|
|
34740
34806
|
let closer;
|
|
34741
34807
|
if (stats.isDirectory()) {
|
|
34742
|
-
const absPath = sp.resolve(
|
|
34743
|
-
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;
|
|
34744
34810
|
if (this.fsw.closed)
|
|
34745
34811
|
return;
|
|
34746
34812
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -34750,29 +34816,29 @@ var init_handler2 = __esm({
|
|
|
34750
34816
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
34751
34817
|
}
|
|
34752
34818
|
} else if (stats.isSymbolicLink()) {
|
|
34753
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
34819
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path29) : path29;
|
|
34754
34820
|
if (this.fsw.closed)
|
|
34755
34821
|
return;
|
|
34756
34822
|
const parent = sp.dirname(wh.watchPath);
|
|
34757
34823
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
34758
34824
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
34759
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
34825
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path29, wh, targetPath);
|
|
34760
34826
|
if (this.fsw.closed)
|
|
34761
34827
|
return;
|
|
34762
34828
|
if (targetPath !== void 0) {
|
|
34763
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
34829
|
+
this.fsw._symlinkPaths.set(sp.resolve(path29), targetPath);
|
|
34764
34830
|
}
|
|
34765
34831
|
} else {
|
|
34766
34832
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
34767
34833
|
}
|
|
34768
34834
|
ready();
|
|
34769
34835
|
if (closer)
|
|
34770
|
-
this.fsw._addPathCloser(
|
|
34836
|
+
this.fsw._addPathCloser(path29, closer);
|
|
34771
34837
|
return false;
|
|
34772
34838
|
} catch (error48) {
|
|
34773
34839
|
if (this.fsw._handleError(error48)) {
|
|
34774
34840
|
ready();
|
|
34775
|
-
return
|
|
34841
|
+
return path29;
|
|
34776
34842
|
}
|
|
34777
34843
|
}
|
|
34778
34844
|
}
|
|
@@ -34807,24 +34873,24 @@ function createPattern(matcher) {
|
|
|
34807
34873
|
}
|
|
34808
34874
|
return () => false;
|
|
34809
34875
|
}
|
|
34810
|
-
function normalizePath(
|
|
34811
|
-
if (typeof
|
|
34876
|
+
function normalizePath(path29) {
|
|
34877
|
+
if (typeof path29 !== "string")
|
|
34812
34878
|
throw new Error("string expected");
|
|
34813
|
-
|
|
34814
|
-
|
|
34879
|
+
path29 = sp2.normalize(path29);
|
|
34880
|
+
path29 = path29.replace(/\\/g, "/");
|
|
34815
34881
|
let prepend = false;
|
|
34816
|
-
if (
|
|
34882
|
+
if (path29.startsWith("//"))
|
|
34817
34883
|
prepend = true;
|
|
34818
|
-
|
|
34884
|
+
path29 = path29.replace(DOUBLE_SLASH_RE, "/");
|
|
34819
34885
|
if (prepend)
|
|
34820
|
-
|
|
34821
|
-
return
|
|
34886
|
+
path29 = "/" + path29;
|
|
34887
|
+
return path29;
|
|
34822
34888
|
}
|
|
34823
34889
|
function matchPatterns(patterns, testString, stats) {
|
|
34824
|
-
const
|
|
34890
|
+
const path29 = normalizePath(testString);
|
|
34825
34891
|
for (let index = 0; index < patterns.length; index++) {
|
|
34826
34892
|
const pattern = patterns[index];
|
|
34827
|
-
if (pattern(
|
|
34893
|
+
if (pattern(path29, stats)) {
|
|
34828
34894
|
return true;
|
|
34829
34895
|
}
|
|
34830
34896
|
}
|
|
@@ -34887,19 +34953,19 @@ var init_chokidar = __esm({
|
|
|
34887
34953
|
}
|
|
34888
34954
|
return str;
|
|
34889
34955
|
};
|
|
34890
|
-
normalizePathToUnix = (
|
|
34891
|
-
normalizeIgnored = (cwd = "") => (
|
|
34892
|
-
if (typeof
|
|
34893
|
-
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));
|
|
34894
34960
|
} else {
|
|
34895
|
-
return
|
|
34961
|
+
return path29;
|
|
34896
34962
|
}
|
|
34897
34963
|
};
|
|
34898
|
-
getAbsolutePath = (
|
|
34899
|
-
if (sp2.isAbsolute(
|
|
34900
|
-
return
|
|
34964
|
+
getAbsolutePath = (path29, cwd) => {
|
|
34965
|
+
if (sp2.isAbsolute(path29)) {
|
|
34966
|
+
return path29;
|
|
34901
34967
|
}
|
|
34902
|
-
return sp2.join(cwd,
|
|
34968
|
+
return sp2.join(cwd, path29);
|
|
34903
34969
|
};
|
|
34904
34970
|
EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
34905
34971
|
DirEntry = class {
|
|
@@ -34964,10 +35030,10 @@ var init_chokidar = __esm({
|
|
|
34964
35030
|
dirParts;
|
|
34965
35031
|
followSymlinks;
|
|
34966
35032
|
statMethod;
|
|
34967
|
-
constructor(
|
|
35033
|
+
constructor(path29, follow, fsw) {
|
|
34968
35034
|
this.fsw = fsw;
|
|
34969
|
-
const watchPath =
|
|
34970
|
-
this.path =
|
|
35035
|
+
const watchPath = path29;
|
|
35036
|
+
this.path = path29 = path29.replace(REPLACER_RE, "");
|
|
34971
35037
|
this.watchPath = watchPath;
|
|
34972
35038
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
34973
35039
|
this.dirParts = [];
|
|
@@ -35107,20 +35173,20 @@ var init_chokidar = __esm({
|
|
|
35107
35173
|
this._closePromise = void 0;
|
|
35108
35174
|
let paths = unifyPaths(paths_);
|
|
35109
35175
|
if (cwd) {
|
|
35110
|
-
paths = paths.map((
|
|
35111
|
-
const absPath = getAbsolutePath(
|
|
35176
|
+
paths = paths.map((path29) => {
|
|
35177
|
+
const absPath = getAbsolutePath(path29, cwd);
|
|
35112
35178
|
return absPath;
|
|
35113
35179
|
});
|
|
35114
35180
|
}
|
|
35115
|
-
paths.forEach((
|
|
35116
|
-
this._removeIgnoredPath(
|
|
35181
|
+
paths.forEach((path29) => {
|
|
35182
|
+
this._removeIgnoredPath(path29);
|
|
35117
35183
|
});
|
|
35118
35184
|
this._userIgnored = void 0;
|
|
35119
35185
|
if (!this._readyCount)
|
|
35120
35186
|
this._readyCount = 0;
|
|
35121
35187
|
this._readyCount += paths.length;
|
|
35122
|
-
Promise.all(paths.map(async (
|
|
35123
|
-
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);
|
|
35124
35190
|
if (res)
|
|
35125
35191
|
this._emitReady();
|
|
35126
35192
|
return res;
|
|
@@ -35142,17 +35208,17 @@ var init_chokidar = __esm({
|
|
|
35142
35208
|
return this;
|
|
35143
35209
|
const paths = unifyPaths(paths_);
|
|
35144
35210
|
const { cwd } = this.options;
|
|
35145
|
-
paths.forEach((
|
|
35146
|
-
if (!sp2.isAbsolute(
|
|
35211
|
+
paths.forEach((path29) => {
|
|
35212
|
+
if (!sp2.isAbsolute(path29) && !this._closers.has(path29)) {
|
|
35147
35213
|
if (cwd)
|
|
35148
|
-
|
|
35149
|
-
|
|
35214
|
+
path29 = sp2.join(cwd, path29);
|
|
35215
|
+
path29 = sp2.resolve(path29);
|
|
35150
35216
|
}
|
|
35151
|
-
this._closePath(
|
|
35152
|
-
this._addIgnoredPath(
|
|
35153
|
-
if (this._watched.has(
|
|
35217
|
+
this._closePath(path29);
|
|
35218
|
+
this._addIgnoredPath(path29);
|
|
35219
|
+
if (this._watched.has(path29)) {
|
|
35154
35220
|
this._addIgnoredPath({
|
|
35155
|
-
path:
|
|
35221
|
+
path: path29,
|
|
35156
35222
|
recursive: true
|
|
35157
35223
|
});
|
|
35158
35224
|
}
|
|
@@ -35216,38 +35282,38 @@ var init_chokidar = __esm({
|
|
|
35216
35282
|
* @param stats arguments to be passed with event
|
|
35217
35283
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
35218
35284
|
*/
|
|
35219
|
-
async _emit(event,
|
|
35285
|
+
async _emit(event, path29, stats) {
|
|
35220
35286
|
if (this.closed)
|
|
35221
35287
|
return;
|
|
35222
35288
|
const opts = this.options;
|
|
35223
35289
|
if (isWindows)
|
|
35224
|
-
|
|
35290
|
+
path29 = sp2.normalize(path29);
|
|
35225
35291
|
if (opts.cwd)
|
|
35226
|
-
|
|
35227
|
-
const args = [
|
|
35292
|
+
path29 = sp2.relative(opts.cwd, path29);
|
|
35293
|
+
const args = [path29];
|
|
35228
35294
|
if (stats != null)
|
|
35229
35295
|
args.push(stats);
|
|
35230
35296
|
const awf = opts.awaitWriteFinish;
|
|
35231
35297
|
let pw;
|
|
35232
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
35298
|
+
if (awf && (pw = this._pendingWrites.get(path29))) {
|
|
35233
35299
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
35234
35300
|
return this;
|
|
35235
35301
|
}
|
|
35236
35302
|
if (opts.atomic) {
|
|
35237
35303
|
if (event === EVENTS.UNLINK) {
|
|
35238
|
-
this._pendingUnlinks.set(
|
|
35304
|
+
this._pendingUnlinks.set(path29, [event, ...args]);
|
|
35239
35305
|
setTimeout(() => {
|
|
35240
|
-
this._pendingUnlinks.forEach((entry,
|
|
35306
|
+
this._pendingUnlinks.forEach((entry, path30) => {
|
|
35241
35307
|
this.emit(...entry);
|
|
35242
35308
|
this.emit(EVENTS.ALL, ...entry);
|
|
35243
|
-
this._pendingUnlinks.delete(
|
|
35309
|
+
this._pendingUnlinks.delete(path30);
|
|
35244
35310
|
});
|
|
35245
35311
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
35246
35312
|
return this;
|
|
35247
35313
|
}
|
|
35248
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
35314
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path29)) {
|
|
35249
35315
|
event = EVENTS.CHANGE;
|
|
35250
|
-
this._pendingUnlinks.delete(
|
|
35316
|
+
this._pendingUnlinks.delete(path29);
|
|
35251
35317
|
}
|
|
35252
35318
|
}
|
|
35253
35319
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -35265,16 +35331,16 @@ var init_chokidar = __esm({
|
|
|
35265
35331
|
this.emitWithAll(event, args);
|
|
35266
35332
|
}
|
|
35267
35333
|
};
|
|
35268
|
-
this._awaitWriteFinish(
|
|
35334
|
+
this._awaitWriteFinish(path29, awf.stabilityThreshold, event, awfEmit);
|
|
35269
35335
|
return this;
|
|
35270
35336
|
}
|
|
35271
35337
|
if (event === EVENTS.CHANGE) {
|
|
35272
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
35338
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path29, 50);
|
|
35273
35339
|
if (isThrottled)
|
|
35274
35340
|
return this;
|
|
35275
35341
|
}
|
|
35276
35342
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
35277
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
35343
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path29) : path29;
|
|
35278
35344
|
let stats2;
|
|
35279
35345
|
try {
|
|
35280
35346
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -35305,23 +35371,23 @@ var init_chokidar = __esm({
|
|
|
35305
35371
|
* @param timeout duration of time to suppress duplicate actions
|
|
35306
35372
|
* @returns tracking object or false if action should be suppressed
|
|
35307
35373
|
*/
|
|
35308
|
-
_throttle(actionType,
|
|
35374
|
+
_throttle(actionType, path29, timeout) {
|
|
35309
35375
|
if (!this._throttled.has(actionType)) {
|
|
35310
35376
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
35311
35377
|
}
|
|
35312
35378
|
const action = this._throttled.get(actionType);
|
|
35313
35379
|
if (!action)
|
|
35314
35380
|
throw new Error("invalid throttle");
|
|
35315
|
-
const actionPath = action.get(
|
|
35381
|
+
const actionPath = action.get(path29);
|
|
35316
35382
|
if (actionPath) {
|
|
35317
35383
|
actionPath.count++;
|
|
35318
35384
|
return false;
|
|
35319
35385
|
}
|
|
35320
35386
|
let timeoutObject;
|
|
35321
35387
|
const clear = () => {
|
|
35322
|
-
const item = action.get(
|
|
35388
|
+
const item = action.get(path29);
|
|
35323
35389
|
const count = item ? item.count : 0;
|
|
35324
|
-
action.delete(
|
|
35390
|
+
action.delete(path29);
|
|
35325
35391
|
clearTimeout(timeoutObject);
|
|
35326
35392
|
if (item)
|
|
35327
35393
|
clearTimeout(item.timeoutObject);
|
|
@@ -35329,7 +35395,7 @@ var init_chokidar = __esm({
|
|
|
35329
35395
|
};
|
|
35330
35396
|
timeoutObject = setTimeout(clear, timeout);
|
|
35331
35397
|
const thr = { timeoutObject, clear, count: 0 };
|
|
35332
|
-
action.set(
|
|
35398
|
+
action.set(path29, thr);
|
|
35333
35399
|
return thr;
|
|
35334
35400
|
}
|
|
35335
35401
|
_incrReadyCount() {
|
|
@@ -35343,44 +35409,44 @@ var init_chokidar = __esm({
|
|
|
35343
35409
|
* @param event
|
|
35344
35410
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
35345
35411
|
*/
|
|
35346
|
-
_awaitWriteFinish(
|
|
35412
|
+
_awaitWriteFinish(path29, threshold, event, awfEmit) {
|
|
35347
35413
|
const awf = this.options.awaitWriteFinish;
|
|
35348
35414
|
if (typeof awf !== "object")
|
|
35349
35415
|
return;
|
|
35350
35416
|
const pollInterval = awf.pollInterval;
|
|
35351
35417
|
let timeoutHandler;
|
|
35352
|
-
let fullPath =
|
|
35353
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
35354
|
-
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);
|
|
35355
35421
|
}
|
|
35356
35422
|
const now = /* @__PURE__ */ new Date();
|
|
35357
35423
|
const writes = this._pendingWrites;
|
|
35358
35424
|
function awaitWriteFinishFn(prevStat) {
|
|
35359
35425
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
35360
|
-
if (err || !writes.has(
|
|
35426
|
+
if (err || !writes.has(path29)) {
|
|
35361
35427
|
if (err && err.code !== "ENOENT")
|
|
35362
35428
|
awfEmit(err);
|
|
35363
35429
|
return;
|
|
35364
35430
|
}
|
|
35365
35431
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
35366
35432
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
35367
|
-
writes.get(
|
|
35433
|
+
writes.get(path29).lastChange = now2;
|
|
35368
35434
|
}
|
|
35369
|
-
const pw = writes.get(
|
|
35435
|
+
const pw = writes.get(path29);
|
|
35370
35436
|
const df = now2 - pw.lastChange;
|
|
35371
35437
|
if (df >= threshold) {
|
|
35372
|
-
writes.delete(
|
|
35438
|
+
writes.delete(path29);
|
|
35373
35439
|
awfEmit(void 0, curStat);
|
|
35374
35440
|
} else {
|
|
35375
35441
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
35376
35442
|
}
|
|
35377
35443
|
});
|
|
35378
35444
|
}
|
|
35379
|
-
if (!writes.has(
|
|
35380
|
-
writes.set(
|
|
35445
|
+
if (!writes.has(path29)) {
|
|
35446
|
+
writes.set(path29, {
|
|
35381
35447
|
lastChange: now,
|
|
35382
35448
|
cancelWait: () => {
|
|
35383
|
-
writes.delete(
|
|
35449
|
+
writes.delete(path29);
|
|
35384
35450
|
clearTimeout(timeoutHandler);
|
|
35385
35451
|
return event;
|
|
35386
35452
|
}
|
|
@@ -35391,8 +35457,8 @@ var init_chokidar = __esm({
|
|
|
35391
35457
|
/**
|
|
35392
35458
|
* Determines whether user has asked to ignore this path.
|
|
35393
35459
|
*/
|
|
35394
|
-
_isIgnored(
|
|
35395
|
-
if (this.options.atomic && DOT_RE.test(
|
|
35460
|
+
_isIgnored(path29, stats) {
|
|
35461
|
+
if (this.options.atomic && DOT_RE.test(path29))
|
|
35396
35462
|
return true;
|
|
35397
35463
|
if (!this._userIgnored) {
|
|
35398
35464
|
const { cwd } = this.options;
|
|
@@ -35402,17 +35468,17 @@ var init_chokidar = __esm({
|
|
|
35402
35468
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
35403
35469
|
this._userIgnored = anymatch(list, void 0);
|
|
35404
35470
|
}
|
|
35405
|
-
return this._userIgnored(
|
|
35471
|
+
return this._userIgnored(path29, stats);
|
|
35406
35472
|
}
|
|
35407
|
-
_isntIgnored(
|
|
35408
|
-
return !this._isIgnored(
|
|
35473
|
+
_isntIgnored(path29, stat4) {
|
|
35474
|
+
return !this._isIgnored(path29, stat4);
|
|
35409
35475
|
}
|
|
35410
35476
|
/**
|
|
35411
35477
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
35412
35478
|
* @param path file or directory pattern being watched
|
|
35413
35479
|
*/
|
|
35414
|
-
_getWatchHelpers(
|
|
35415
|
-
return new WatchHelper(
|
|
35480
|
+
_getWatchHelpers(path29) {
|
|
35481
|
+
return new WatchHelper(path29, this.options.followSymlinks, this);
|
|
35416
35482
|
}
|
|
35417
35483
|
// Directory helpers
|
|
35418
35484
|
// -----------------
|
|
@@ -35444,63 +35510,63 @@ var init_chokidar = __esm({
|
|
|
35444
35510
|
* @param item base path of item/directory
|
|
35445
35511
|
*/
|
|
35446
35512
|
_remove(directory, item, isDirectory) {
|
|
35447
|
-
const
|
|
35448
|
-
const fullPath = sp2.resolve(
|
|
35449
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
35450
|
-
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))
|
|
35451
35517
|
return;
|
|
35452
35518
|
if (!isDirectory && this._watched.size === 1) {
|
|
35453
35519
|
this.add(directory, item, true);
|
|
35454
35520
|
}
|
|
35455
|
-
const wp = this._getWatchedDir(
|
|
35521
|
+
const wp = this._getWatchedDir(path29);
|
|
35456
35522
|
const nestedDirectoryChildren = wp.getChildren();
|
|
35457
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
35523
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path29, nested));
|
|
35458
35524
|
const parent = this._getWatchedDir(directory);
|
|
35459
35525
|
const wasTracked = parent.has(item);
|
|
35460
35526
|
parent.remove(item);
|
|
35461
35527
|
if (this._symlinkPaths.has(fullPath)) {
|
|
35462
35528
|
this._symlinkPaths.delete(fullPath);
|
|
35463
35529
|
}
|
|
35464
|
-
let relPath =
|
|
35530
|
+
let relPath = path29;
|
|
35465
35531
|
if (this.options.cwd)
|
|
35466
|
-
relPath = sp2.relative(this.options.cwd,
|
|
35532
|
+
relPath = sp2.relative(this.options.cwd, path29);
|
|
35467
35533
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
35468
35534
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
35469
35535
|
if (event === EVENTS.ADD)
|
|
35470
35536
|
return;
|
|
35471
35537
|
}
|
|
35472
|
-
this._watched.delete(
|
|
35538
|
+
this._watched.delete(path29);
|
|
35473
35539
|
this._watched.delete(fullPath);
|
|
35474
35540
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
35475
|
-
if (wasTracked && !this._isIgnored(
|
|
35476
|
-
this._emit(eventName,
|
|
35477
|
-
this._closePath(
|
|
35541
|
+
if (wasTracked && !this._isIgnored(path29))
|
|
35542
|
+
this._emit(eventName, path29);
|
|
35543
|
+
this._closePath(path29);
|
|
35478
35544
|
}
|
|
35479
35545
|
/**
|
|
35480
35546
|
* Closes all watchers for a path
|
|
35481
35547
|
*/
|
|
35482
|
-
_closePath(
|
|
35483
|
-
this._closeFile(
|
|
35484
|
-
const dir = sp2.dirname(
|
|
35485
|
-
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));
|
|
35486
35552
|
}
|
|
35487
35553
|
/**
|
|
35488
35554
|
* Closes only file-specific watchers
|
|
35489
35555
|
*/
|
|
35490
|
-
_closeFile(
|
|
35491
|
-
const closers = this._closers.get(
|
|
35556
|
+
_closeFile(path29) {
|
|
35557
|
+
const closers = this._closers.get(path29);
|
|
35492
35558
|
if (!closers)
|
|
35493
35559
|
return;
|
|
35494
35560
|
closers.forEach((closer) => closer());
|
|
35495
|
-
this._closers.delete(
|
|
35561
|
+
this._closers.delete(path29);
|
|
35496
35562
|
}
|
|
35497
|
-
_addPathCloser(
|
|
35563
|
+
_addPathCloser(path29, closer) {
|
|
35498
35564
|
if (!closer)
|
|
35499
35565
|
return;
|
|
35500
|
-
let list = this._closers.get(
|
|
35566
|
+
let list = this._closers.get(path29);
|
|
35501
35567
|
if (!list) {
|
|
35502
35568
|
list = [];
|
|
35503
|
-
this._closers.set(
|
|
35569
|
+
this._closers.set(path29, list);
|
|
35504
35570
|
}
|
|
35505
35571
|
list.push(closer);
|
|
35506
35572
|
}
|
|
@@ -35761,13 +35827,13 @@ var init_provider_schema = __esm({
|
|
|
35761
35827
|
});
|
|
35762
35828
|
|
|
35763
35829
|
// ../../oss/packages/daemon-core/src/providers/provider-loader.ts
|
|
35764
|
-
var
|
|
35830
|
+
var fs7, path14, os16, ProviderLoader;
|
|
35765
35831
|
var init_provider_loader = __esm({
|
|
35766
35832
|
"../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
|
|
35767
35833
|
"use strict";
|
|
35768
|
-
|
|
35769
|
-
|
|
35770
|
-
|
|
35834
|
+
fs7 = __toESM(require("fs"));
|
|
35835
|
+
path14 = __toESM(require("path"));
|
|
35836
|
+
os16 = __toESM(require("os"));
|
|
35771
35837
|
init_chokidar();
|
|
35772
35838
|
init_ide_detector();
|
|
35773
35839
|
init_logger();
|
|
@@ -35801,9 +35867,9 @@ var init_provider_loader = __esm({
|
|
|
35801
35867
|
static siblingStderrLogged = /* @__PURE__ */ new Set();
|
|
35802
35868
|
static looksLikeProviderRoot(candidate) {
|
|
35803
35869
|
try {
|
|
35804
|
-
if (!
|
|
35870
|
+
if (!fs7.existsSync(candidate) || !fs7.statSync(candidate).isDirectory()) return false;
|
|
35805
35871
|
return ["ide", "extension", "cli", "acp"].some(
|
|
35806
|
-
(category) =>
|
|
35872
|
+
(category) => fs7.existsSync(path14.join(candidate, category))
|
|
35807
35873
|
);
|
|
35808
35874
|
} catch {
|
|
35809
35875
|
return false;
|
|
@@ -35811,20 +35877,20 @@ var init_provider_loader = __esm({
|
|
|
35811
35877
|
}
|
|
35812
35878
|
static hasProviderRootMarker(candidate) {
|
|
35813
35879
|
try {
|
|
35814
|
-
return
|
|
35880
|
+
return fs7.existsSync(path14.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
|
|
35815
35881
|
} catch {
|
|
35816
35882
|
return false;
|
|
35817
35883
|
}
|
|
35818
35884
|
}
|
|
35819
35885
|
detectDefaultUserDir() {
|
|
35820
|
-
const fallback2 =
|
|
35886
|
+
const fallback2 = path14.join(os16.homedir(), ".adhdev", "providers");
|
|
35821
35887
|
const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
|
|
35822
35888
|
const visited = /* @__PURE__ */ new Set();
|
|
35823
35889
|
for (const start of this.probeStarts) {
|
|
35824
|
-
let current =
|
|
35890
|
+
let current = path14.resolve(start);
|
|
35825
35891
|
while (!visited.has(current)) {
|
|
35826
35892
|
visited.add(current);
|
|
35827
|
-
const siblingCandidate =
|
|
35893
|
+
const siblingCandidate = path14.join(path14.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
|
|
35828
35894
|
if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
|
|
35829
35895
|
const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
|
|
35830
35896
|
if (envOptIn || hasMarker) {
|
|
@@ -35846,7 +35912,7 @@ var init_provider_loader = __esm({
|
|
|
35846
35912
|
return { path: siblingCandidate, source };
|
|
35847
35913
|
}
|
|
35848
35914
|
}
|
|
35849
|
-
const parent =
|
|
35915
|
+
const parent = path14.dirname(current);
|
|
35850
35916
|
if (parent === current) break;
|
|
35851
35917
|
current = parent;
|
|
35852
35918
|
}
|
|
@@ -35856,11 +35922,11 @@ var init_provider_loader = __esm({
|
|
|
35856
35922
|
constructor(options) {
|
|
35857
35923
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
35858
35924
|
this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
|
|
35859
|
-
this.defaultProvidersDir =
|
|
35925
|
+
this.defaultProvidersDir = path14.join(os16.homedir(), ".adhdev", "providers");
|
|
35860
35926
|
const detected = this.detectDefaultUserDir();
|
|
35861
35927
|
this.userDir = detected.path;
|
|
35862
35928
|
this.userDirSource = detected.source;
|
|
35863
|
-
this.upstreamDir =
|
|
35929
|
+
this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
|
|
35864
35930
|
this.disableUpstream = false;
|
|
35865
35931
|
this.applySourceConfig({
|
|
35866
35932
|
userDir: options?.userDir,
|
|
@@ -35919,7 +35985,7 @@ var init_provider_loader = __esm({
|
|
|
35919
35985
|
this.userDir = detected.path;
|
|
35920
35986
|
this.userDirSource = detected.source;
|
|
35921
35987
|
}
|
|
35922
|
-
this.upstreamDir =
|
|
35988
|
+
this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
|
|
35923
35989
|
this.disableUpstream = this.sourceMode === "no-upstream";
|
|
35924
35990
|
if (this.explicitProviderDir) {
|
|
35925
35991
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
@@ -35933,7 +35999,7 @@ var init_provider_loader = __esm({
|
|
|
35933
35999
|
* Canonical provider directory shape for a given root.
|
|
35934
36000
|
*/
|
|
35935
36001
|
getProviderDir(root, category, type) {
|
|
35936
|
-
return
|
|
36002
|
+
return path14.join(root, category, type);
|
|
35937
36003
|
}
|
|
35938
36004
|
/**
|
|
35939
36005
|
* Canonical user override directory for a provider.
|
|
@@ -35960,7 +36026,7 @@ var init_provider_loader = __esm({
|
|
|
35960
36026
|
resolveProviderFile(type, ...segments) {
|
|
35961
36027
|
const dir = this.findProviderDirInternal(type);
|
|
35962
36028
|
if (!dir) return null;
|
|
35963
|
-
return
|
|
36029
|
+
return path14.join(dir, ...segments);
|
|
35964
36030
|
}
|
|
35965
36031
|
/**
|
|
35966
36032
|
* Load all providers (3-tier priority)
|
|
@@ -35973,7 +36039,7 @@ var init_provider_loader = __esm({
|
|
|
35973
36039
|
this.providers.clear();
|
|
35974
36040
|
this.providerAvailability.clear();
|
|
35975
36041
|
let upstreamCount = 0;
|
|
35976
|
-
if (!this.disableUpstream &&
|
|
36042
|
+
if (!this.disableUpstream && fs7.existsSync(this.upstreamDir)) {
|
|
35977
36043
|
upstreamCount = this.loadDir(this.upstreamDir);
|
|
35978
36044
|
if (upstreamCount > 0) {
|
|
35979
36045
|
this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
|
|
@@ -35981,7 +36047,7 @@ var init_provider_loader = __esm({
|
|
|
35981
36047
|
} else if (this.disableUpstream) {
|
|
35982
36048
|
this.log("Upstream loading disabled (sourceMode=no-upstream)");
|
|
35983
36049
|
}
|
|
35984
|
-
if (
|
|
36050
|
+
if (fs7.existsSync(this.userDir)) {
|
|
35985
36051
|
const userCount = this.loadDir(this.userDir, [".upstream"]);
|
|
35986
36052
|
if (userCount > 0) {
|
|
35987
36053
|
this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
|
|
@@ -35996,10 +36062,10 @@ var init_provider_loader = __esm({
|
|
|
35996
36062
|
* Check if upstream directory exists and has providers.
|
|
35997
36063
|
*/
|
|
35998
36064
|
hasUpstream() {
|
|
35999
|
-
if (!
|
|
36065
|
+
if (!fs7.existsSync(this.upstreamDir)) return false;
|
|
36000
36066
|
try {
|
|
36001
|
-
return
|
|
36002
|
-
(d) =>
|
|
36067
|
+
return fs7.readdirSync(this.upstreamDir).some(
|
|
36068
|
+
(d) => fs7.statSync(path14.join(this.upstreamDir, d)).isDirectory()
|
|
36003
36069
|
);
|
|
36004
36070
|
} catch {
|
|
36005
36071
|
return false;
|
|
@@ -36496,8 +36562,8 @@ var init_provider_loader = __esm({
|
|
|
36496
36562
|
resolved._resolvedScriptDir = entry.scriptDir;
|
|
36497
36563
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
36498
36564
|
if (providerDir) {
|
|
36499
|
-
const fullDir =
|
|
36500
|
-
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;
|
|
36501
36567
|
}
|
|
36502
36568
|
matched = true;
|
|
36503
36569
|
}
|
|
@@ -36512,8 +36578,8 @@ var init_provider_loader = __esm({
|
|
|
36512
36578
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
36513
36579
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
36514
36580
|
if (providerDir) {
|
|
36515
|
-
const fullDir =
|
|
36516
|
-
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;
|
|
36517
36583
|
}
|
|
36518
36584
|
}
|
|
36519
36585
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -36530,8 +36596,8 @@ var init_provider_loader = __esm({
|
|
|
36530
36596
|
resolved._resolvedScriptDir = dirOverride;
|
|
36531
36597
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
36532
36598
|
if (providerDir) {
|
|
36533
|
-
const fullDir =
|
|
36534
|
-
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;
|
|
36535
36601
|
}
|
|
36536
36602
|
}
|
|
36537
36603
|
} else if (override.scripts) {
|
|
@@ -36547,8 +36613,8 @@ var init_provider_loader = __esm({
|
|
|
36547
36613
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
36548
36614
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
36549
36615
|
if (providerDir) {
|
|
36550
|
-
const fullDir =
|
|
36551
|
-
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;
|
|
36552
36618
|
}
|
|
36553
36619
|
}
|
|
36554
36620
|
}
|
|
@@ -36580,15 +36646,15 @@ var init_provider_loader = __esm({
|
|
|
36580
36646
|
this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
|
|
36581
36647
|
return null;
|
|
36582
36648
|
}
|
|
36583
|
-
const dir =
|
|
36584
|
-
if (!
|
|
36649
|
+
const dir = path14.join(providerDir, scriptDir);
|
|
36650
|
+
if (!fs7.existsSync(dir)) {
|
|
36585
36651
|
this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
36586
36652
|
return null;
|
|
36587
36653
|
}
|
|
36588
36654
|
const cached2 = this.scriptsCache.get(dir);
|
|
36589
36655
|
if (cached2) return cached2;
|
|
36590
|
-
const scriptsJs =
|
|
36591
|
-
if (
|
|
36656
|
+
const scriptsJs = path14.join(dir, "scripts.js");
|
|
36657
|
+
if (fs7.existsSync(scriptsJs)) {
|
|
36592
36658
|
try {
|
|
36593
36659
|
delete require.cache[require.resolve(scriptsJs)];
|
|
36594
36660
|
const loaded = require(scriptsJs);
|
|
@@ -36609,9 +36675,9 @@ var init_provider_loader = __esm({
|
|
|
36609
36675
|
watch() {
|
|
36610
36676
|
this.stopWatch();
|
|
36611
36677
|
const watchDir = (dir) => {
|
|
36612
|
-
if (!
|
|
36678
|
+
if (!fs7.existsSync(dir)) {
|
|
36613
36679
|
try {
|
|
36614
|
-
|
|
36680
|
+
fs7.mkdirSync(dir, { recursive: true });
|
|
36615
36681
|
} catch {
|
|
36616
36682
|
return;
|
|
36617
36683
|
}
|
|
@@ -36629,7 +36695,7 @@ var init_provider_loader = __esm({
|
|
|
36629
36695
|
return;
|
|
36630
36696
|
}
|
|
36631
36697
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
36632
|
-
this.log(`File changed: ${
|
|
36698
|
+
this.log(`File changed: ${path14.basename(filePath)}, reloading...`);
|
|
36633
36699
|
this.reload();
|
|
36634
36700
|
}
|
|
36635
36701
|
};
|
|
@@ -36684,12 +36750,12 @@ var init_provider_loader = __esm({
|
|
|
36684
36750
|
}
|
|
36685
36751
|
const https = require("https");
|
|
36686
36752
|
const { execSync: execSync7 } = require("child_process");
|
|
36687
|
-
const metaPath =
|
|
36753
|
+
const metaPath = path14.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
36688
36754
|
let prevEtag = "";
|
|
36689
36755
|
let prevTimestamp = 0;
|
|
36690
36756
|
try {
|
|
36691
|
-
if (
|
|
36692
|
-
const meta3 = JSON.parse(
|
|
36757
|
+
if (fs7.existsSync(metaPath)) {
|
|
36758
|
+
const meta3 = JSON.parse(fs7.readFileSync(metaPath, "utf-8"));
|
|
36693
36759
|
prevEtag = meta3.etag || "";
|
|
36694
36760
|
prevTimestamp = meta3.timestamp || 0;
|
|
36695
36761
|
}
|
|
@@ -36744,39 +36810,39 @@ var init_provider_loader = __esm({
|
|
|
36744
36810
|
return { updated: false };
|
|
36745
36811
|
}
|
|
36746
36812
|
this.log("Downloading latest providers from GitHub...");
|
|
36747
|
-
const tmpTar =
|
|
36748
|
-
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()}`);
|
|
36749
36815
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
36750
|
-
|
|
36816
|
+
fs7.mkdirSync(tmpExtract, { recursive: true });
|
|
36751
36817
|
execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
36752
|
-
const extracted =
|
|
36818
|
+
const extracted = fs7.readdirSync(tmpExtract);
|
|
36753
36819
|
const rootDir = extracted.find(
|
|
36754
|
-
(d) =>
|
|
36820
|
+
(d) => fs7.statSync(path14.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
36755
36821
|
);
|
|
36756
36822
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
36757
|
-
const sourceDir =
|
|
36823
|
+
const sourceDir = path14.join(tmpExtract, rootDir);
|
|
36758
36824
|
const backupDir = this.upstreamDir + ".bak";
|
|
36759
|
-
if (
|
|
36760
|
-
if (
|
|
36761
|
-
|
|
36825
|
+
if (fs7.existsSync(this.upstreamDir)) {
|
|
36826
|
+
if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
|
|
36827
|
+
fs7.renameSync(this.upstreamDir, backupDir);
|
|
36762
36828
|
}
|
|
36763
36829
|
try {
|
|
36764
36830
|
this.copyDirRecursive(sourceDir, this.upstreamDir);
|
|
36765
36831
|
this.writeMeta(metaPath, etag || `ts-${Date.now()}`, Date.now());
|
|
36766
|
-
if (
|
|
36832
|
+
if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
|
|
36767
36833
|
} catch (e) {
|
|
36768
|
-
if (
|
|
36769
|
-
if (
|
|
36770
|
-
|
|
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);
|
|
36771
36837
|
}
|
|
36772
36838
|
throw e;
|
|
36773
36839
|
}
|
|
36774
36840
|
try {
|
|
36775
|
-
|
|
36841
|
+
fs7.rmSync(tmpTar, { force: true });
|
|
36776
36842
|
} catch {
|
|
36777
36843
|
}
|
|
36778
36844
|
try {
|
|
36779
|
-
|
|
36845
|
+
fs7.rmSync(tmpExtract, { recursive: true, force: true });
|
|
36780
36846
|
} catch {
|
|
36781
36847
|
}
|
|
36782
36848
|
const upstreamCount = this.countProviders(this.upstreamDir);
|
|
@@ -36808,7 +36874,7 @@ var init_provider_loader = __esm({
|
|
|
36808
36874
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
36809
36875
|
return;
|
|
36810
36876
|
}
|
|
36811
|
-
const ws =
|
|
36877
|
+
const ws = fs7.createWriteStream(destPath);
|
|
36812
36878
|
res.pipe(ws);
|
|
36813
36879
|
ws.on("finish", () => {
|
|
36814
36880
|
ws.close();
|
|
@@ -36827,22 +36893,22 @@ var init_provider_loader = __esm({
|
|
|
36827
36893
|
}
|
|
36828
36894
|
/** Recursive directory copy */
|
|
36829
36895
|
copyDirRecursive(src, dest) {
|
|
36830
|
-
|
|
36831
|
-
for (const entry of
|
|
36832
|
-
const srcPath =
|
|
36833
|
-
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);
|
|
36834
36900
|
if (entry.isDirectory()) {
|
|
36835
36901
|
this.copyDirRecursive(srcPath, destPath);
|
|
36836
36902
|
} else {
|
|
36837
|
-
|
|
36903
|
+
fs7.copyFileSync(srcPath, destPath);
|
|
36838
36904
|
}
|
|
36839
36905
|
}
|
|
36840
36906
|
}
|
|
36841
36907
|
/** .meta.json save */
|
|
36842
36908
|
writeMeta(metaPath, etag, timestamp) {
|
|
36843
36909
|
try {
|
|
36844
|
-
|
|
36845
|
-
|
|
36910
|
+
fs7.mkdirSync(path14.dirname(metaPath), { recursive: true });
|
|
36911
|
+
fs7.writeFileSync(metaPath, JSON.stringify({
|
|
36846
36912
|
etag,
|
|
36847
36913
|
timestamp,
|
|
36848
36914
|
lastCheck: new Date(timestamp).toISOString(),
|
|
@@ -36853,12 +36919,12 @@ var init_provider_loader = __esm({
|
|
|
36853
36919
|
}
|
|
36854
36920
|
/** Count provider files (provider.js or provider.json) */
|
|
36855
36921
|
countProviders(dir) {
|
|
36856
|
-
if (!
|
|
36922
|
+
if (!fs7.existsSync(dir)) return 0;
|
|
36857
36923
|
let count = 0;
|
|
36858
36924
|
const scan = (d) => {
|
|
36859
36925
|
try {
|
|
36860
|
-
for (const entry of
|
|
36861
|
-
if (entry.isDirectory()) scan(
|
|
36926
|
+
for (const entry of fs7.readdirSync(d, { withFileTypes: true })) {
|
|
36927
|
+
if (entry.isDirectory()) scan(path14.join(d, entry.name));
|
|
36862
36928
|
else if (entry.name === "provider.json") count++;
|
|
36863
36929
|
}
|
|
36864
36930
|
} catch {
|
|
@@ -37084,19 +37150,19 @@ var init_provider_loader = __esm({
|
|
|
37084
37150
|
const cat = provider.category;
|
|
37085
37151
|
const searchRoots = this.getProviderRoots();
|
|
37086
37152
|
for (const root of searchRoots) {
|
|
37087
|
-
if (!
|
|
37153
|
+
if (!fs7.existsSync(root)) continue;
|
|
37088
37154
|
const candidate = this.getProviderDir(root, cat, type);
|
|
37089
|
-
if (
|
|
37090
|
-
const catDir =
|
|
37091
|
-
if (
|
|
37155
|
+
if (fs7.existsSync(path14.join(candidate, "provider.json"))) return candidate;
|
|
37156
|
+
const catDir = path14.join(root, cat);
|
|
37157
|
+
if (fs7.existsSync(catDir)) {
|
|
37092
37158
|
try {
|
|
37093
|
-
for (const entry of
|
|
37159
|
+
for (const entry of fs7.readdirSync(catDir, { withFileTypes: true })) {
|
|
37094
37160
|
if (!entry.isDirectory()) continue;
|
|
37095
|
-
const jsonPath =
|
|
37096
|
-
if (
|
|
37161
|
+
const jsonPath = path14.join(catDir, entry.name, "provider.json");
|
|
37162
|
+
if (fs7.existsSync(jsonPath)) {
|
|
37097
37163
|
try {
|
|
37098
|
-
const data = JSON.parse(
|
|
37099
|
-
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);
|
|
37100
37166
|
} catch {
|
|
37101
37167
|
}
|
|
37102
37168
|
}
|
|
@@ -37113,8 +37179,8 @@ var init_provider_loader = __esm({
|
|
|
37113
37179
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
37114
37180
|
*/
|
|
37115
37181
|
buildScriptWrappersFromDir(dir) {
|
|
37116
|
-
const scriptsJs =
|
|
37117
|
-
if (
|
|
37182
|
+
const scriptsJs = path14.join(dir, "scripts.js");
|
|
37183
|
+
if (fs7.existsSync(scriptsJs)) {
|
|
37118
37184
|
try {
|
|
37119
37185
|
delete require.cache[require.resolve(scriptsJs)];
|
|
37120
37186
|
return require(scriptsJs);
|
|
@@ -37124,13 +37190,13 @@ var init_provider_loader = __esm({
|
|
|
37124
37190
|
const toCamel = (name) => name.replace(/_([a-z])/g, (_2, c) => c.toUpperCase());
|
|
37125
37191
|
const result = {};
|
|
37126
37192
|
try {
|
|
37127
|
-
for (const file2 of
|
|
37193
|
+
for (const file2 of fs7.readdirSync(dir)) {
|
|
37128
37194
|
if (!file2.endsWith(".js")) continue;
|
|
37129
37195
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
37130
|
-
const filePath =
|
|
37196
|
+
const filePath = path14.join(dir, file2);
|
|
37131
37197
|
result[scriptName] = (...args) => {
|
|
37132
37198
|
try {
|
|
37133
|
-
let content =
|
|
37199
|
+
let content = fs7.readFileSync(filePath, "utf-8");
|
|
37134
37200
|
if (args[0] && typeof args[0] === "object") {
|
|
37135
37201
|
for (const [key, val] of Object.entries(args[0])) {
|
|
37136
37202
|
let v = val;
|
|
@@ -37176,20 +37242,20 @@ var init_provider_loader = __esm({
|
|
|
37176
37242
|
* Structure: dir/category/agent-name/provider.{json,js}
|
|
37177
37243
|
*/
|
|
37178
37244
|
loadDir(dir, excludeDirs) {
|
|
37179
|
-
if (!
|
|
37245
|
+
if (!fs7.existsSync(dir)) return 0;
|
|
37180
37246
|
let count = 0;
|
|
37181
37247
|
const scan = (d) => {
|
|
37182
37248
|
let entries;
|
|
37183
37249
|
try {
|
|
37184
|
-
entries =
|
|
37250
|
+
entries = fs7.readdirSync(d, { withFileTypes: true });
|
|
37185
37251
|
} catch {
|
|
37186
37252
|
return;
|
|
37187
37253
|
}
|
|
37188
37254
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
37189
37255
|
if (hasJson) {
|
|
37190
|
-
const jsonPath =
|
|
37256
|
+
const jsonPath = path14.join(d, "provider.json");
|
|
37191
37257
|
try {
|
|
37192
|
-
const raw =
|
|
37258
|
+
const raw = fs7.readFileSync(jsonPath, "utf-8");
|
|
37193
37259
|
const mod = JSON.parse(raw);
|
|
37194
37260
|
if (typeof mod.extensionIdPattern === "string") {
|
|
37195
37261
|
const flags = mod.extensionIdPattern_flags || "";
|
|
@@ -37208,8 +37274,8 @@ var init_provider_loader = __esm({
|
|
|
37208
37274
|
this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
|
|
37209
37275
|
} else {
|
|
37210
37276
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
37211
|
-
const scriptsPath =
|
|
37212
|
-
if (!hasCompatibility &&
|
|
37277
|
+
const scriptsPath = path14.join(d, "scripts.js");
|
|
37278
|
+
if (!hasCompatibility && fs7.existsSync(scriptsPath)) {
|
|
37213
37279
|
try {
|
|
37214
37280
|
delete require.cache[require.resolve(scriptsPath)];
|
|
37215
37281
|
const scripts = require(scriptsPath);
|
|
@@ -37234,7 +37300,7 @@ var init_provider_loader = __esm({
|
|
|
37234
37300
|
if (!entry.isDirectory()) continue;
|
|
37235
37301
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
37236
37302
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
37237
|
-
scan(
|
|
37303
|
+
scan(path14.join(d, entry.name));
|
|
37238
37304
|
}
|
|
37239
37305
|
}
|
|
37240
37306
|
};
|
|
@@ -37430,7 +37496,7 @@ async function isCdpActive(port) {
|
|
|
37430
37496
|
});
|
|
37431
37497
|
}
|
|
37432
37498
|
async function killIdeProcess(ideId) {
|
|
37433
|
-
const plat =
|
|
37499
|
+
const plat = os17.platform();
|
|
37434
37500
|
const appName = getMacAppIdentifiers()[ideId];
|
|
37435
37501
|
const winProcesses = getWinProcessNames()[ideId];
|
|
37436
37502
|
try {
|
|
@@ -37491,7 +37557,7 @@ async function killIdeProcess(ideId) {
|
|
|
37491
37557
|
}
|
|
37492
37558
|
}
|
|
37493
37559
|
function isIdeRunning(ideId) {
|
|
37494
|
-
const plat =
|
|
37560
|
+
const plat = os17.platform();
|
|
37495
37561
|
try {
|
|
37496
37562
|
if (plat === "darwin") {
|
|
37497
37563
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -37546,7 +37612,7 @@ function isIdeRunning(ideId) {
|
|
|
37546
37612
|
}
|
|
37547
37613
|
}
|
|
37548
37614
|
function detectCurrentWorkspace(ideId) {
|
|
37549
|
-
const plat =
|
|
37615
|
+
const plat = os17.platform();
|
|
37550
37616
|
if (plat === "darwin") {
|
|
37551
37617
|
try {
|
|
37552
37618
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -37561,17 +37627,17 @@ function detectCurrentWorkspace(ideId) {
|
|
|
37561
37627
|
}
|
|
37562
37628
|
} else if (plat === "win32") {
|
|
37563
37629
|
try {
|
|
37564
|
-
const
|
|
37630
|
+
const fs20 = require("fs");
|
|
37565
37631
|
const appNameMap = getMacAppIdentifiers();
|
|
37566
37632
|
const appName = appNameMap[ideId];
|
|
37567
37633
|
if (appName) {
|
|
37568
|
-
const storagePath =
|
|
37569
|
-
process.env.APPDATA ||
|
|
37634
|
+
const storagePath = path15.join(
|
|
37635
|
+
process.env.APPDATA || path15.join(os17.homedir(), "AppData", "Roaming"),
|
|
37570
37636
|
appName,
|
|
37571
37637
|
"storage.json"
|
|
37572
37638
|
);
|
|
37573
|
-
if (
|
|
37574
|
-
const data = JSON.parse(
|
|
37639
|
+
if (fs20.existsSync(storagePath)) {
|
|
37640
|
+
const data = JSON.parse(fs20.readFileSync(storagePath, "utf-8"));
|
|
37575
37641
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
37576
37642
|
if (workspaces.length > 0) {
|
|
37577
37643
|
const recent = workspaces[0];
|
|
@@ -37588,7 +37654,7 @@ function detectCurrentWorkspace(ideId) {
|
|
|
37588
37654
|
return void 0;
|
|
37589
37655
|
}
|
|
37590
37656
|
async function launchWithCdp(options = {}) {
|
|
37591
|
-
const platform12 =
|
|
37657
|
+
const platform12 = os17.platform();
|
|
37592
37658
|
let targetIde;
|
|
37593
37659
|
const ides = await detectIDEs(getProviderLoader());
|
|
37594
37660
|
if (options.ideId) {
|
|
@@ -37737,14 +37803,14 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
37737
37803
|
function getAvailableIdeIds() {
|
|
37738
37804
|
return getProviderLoader().getAvailableIdeTypes();
|
|
37739
37805
|
}
|
|
37740
|
-
var import_child_process7, net2,
|
|
37806
|
+
var import_child_process7, net2, os17, path15, _providerLoader;
|
|
37741
37807
|
var init_launch = __esm({
|
|
37742
37808
|
"../../oss/packages/daemon-core/src/launch.ts"() {
|
|
37743
37809
|
"use strict";
|
|
37744
37810
|
import_child_process7 = require("child_process");
|
|
37745
37811
|
net2 = __toESM(require("net"));
|
|
37746
|
-
|
|
37747
|
-
|
|
37812
|
+
os17 = __toESM(require("os"));
|
|
37813
|
+
path15 = __toESM(require("path"));
|
|
37748
37814
|
init_ide_detector();
|
|
37749
37815
|
init_provider_loader();
|
|
37750
37816
|
init_macos_app_process();
|
|
@@ -37776,13 +37842,13 @@ function checkRotation() {
|
|
|
37776
37842
|
const today = getDateStr2();
|
|
37777
37843
|
if (today !== currentDate2) {
|
|
37778
37844
|
currentDate2 = today;
|
|
37779
|
-
currentFile =
|
|
37845
|
+
currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
37780
37846
|
cleanOldFiles();
|
|
37781
37847
|
}
|
|
37782
37848
|
}
|
|
37783
37849
|
function cleanOldFiles() {
|
|
37784
37850
|
try {
|
|
37785
|
-
const files =
|
|
37851
|
+
const files = fs8.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
|
|
37786
37852
|
const cutoff = /* @__PURE__ */ new Date();
|
|
37787
37853
|
cutoff.setDate(cutoff.getDate() - MAX_DAYS);
|
|
37788
37854
|
const cutoffStr = cutoff.toISOString().slice(0, 10);
|
|
@@ -37790,7 +37856,7 @@ function cleanOldFiles() {
|
|
|
37790
37856
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
37791
37857
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
37792
37858
|
try {
|
|
37793
|
-
|
|
37859
|
+
fs8.unlinkSync(path16.join(LOG_DIR2, file2));
|
|
37794
37860
|
} catch {
|
|
37795
37861
|
}
|
|
37796
37862
|
}
|
|
@@ -37800,14 +37866,14 @@ function cleanOldFiles() {
|
|
|
37800
37866
|
}
|
|
37801
37867
|
function checkSize() {
|
|
37802
37868
|
try {
|
|
37803
|
-
const stat4 =
|
|
37869
|
+
const stat4 = fs8.statSync(currentFile);
|
|
37804
37870
|
if (stat4.size > MAX_FILE_SIZE) {
|
|
37805
37871
|
const backup = currentFile.replace(".jsonl", ".1.jsonl");
|
|
37806
37872
|
try {
|
|
37807
|
-
|
|
37873
|
+
fs8.unlinkSync(backup);
|
|
37808
37874
|
} catch {
|
|
37809
37875
|
}
|
|
37810
|
-
|
|
37876
|
+
fs8.renameSync(currentFile, backup);
|
|
37811
37877
|
}
|
|
37812
37878
|
} catch {
|
|
37813
37879
|
}
|
|
@@ -37832,14 +37898,14 @@ function logCommand(entry) {
|
|
|
37832
37898
|
...entry.error ? { err: entry.error } : {},
|
|
37833
37899
|
...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
|
|
37834
37900
|
});
|
|
37835
|
-
|
|
37901
|
+
fs8.appendFileSync(currentFile, line + "\n");
|
|
37836
37902
|
} catch {
|
|
37837
37903
|
}
|
|
37838
37904
|
}
|
|
37839
37905
|
function getRecentCommands(count = 50) {
|
|
37840
37906
|
try {
|
|
37841
|
-
if (!
|
|
37842
|
-
const content =
|
|
37907
|
+
if (!fs8.existsSync(currentFile)) return [];
|
|
37908
|
+
const content = fs8.readFileSync(currentFile, "utf-8");
|
|
37843
37909
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
37844
37910
|
return lines.slice(-count).map((line) => {
|
|
37845
37911
|
try {
|
|
@@ -37862,18 +37928,18 @@ function getRecentCommands(count = 50) {
|
|
|
37862
37928
|
return [];
|
|
37863
37929
|
}
|
|
37864
37930
|
}
|
|
37865
|
-
var
|
|
37931
|
+
var fs8, path16, os18, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
|
|
37866
37932
|
var init_command_log = __esm({
|
|
37867
37933
|
"../../oss/packages/daemon-core/src/logging/command-log.ts"() {
|
|
37868
37934
|
"use strict";
|
|
37869
|
-
|
|
37870
|
-
|
|
37871
|
-
|
|
37872
|
-
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");
|
|
37873
37939
|
MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
37874
37940
|
MAX_DAYS = 7;
|
|
37875
37941
|
try {
|
|
37876
|
-
|
|
37942
|
+
fs8.mkdirSync(LOG_DIR2, { recursive: true });
|
|
37877
37943
|
} catch {
|
|
37878
37944
|
}
|
|
37879
37945
|
SENSITIVE_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -37888,7 +37954,7 @@ var init_command_log = __esm({
|
|
|
37888
37954
|
"text"
|
|
37889
37955
|
]);
|
|
37890
37956
|
currentDate2 = getDateStr2();
|
|
37891
|
-
currentFile =
|
|
37957
|
+
currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
37892
37958
|
writeCount2 = 0;
|
|
37893
37959
|
SKIP_COMMANDS = /* @__PURE__ */ new Set([
|
|
37894
37960
|
"heartbeat",
|
|
@@ -37952,8 +38018,8 @@ function buildAvailableProviders(providerLoader) {
|
|
|
37952
38018
|
}
|
|
37953
38019
|
function buildMachineInfo(profile = "full") {
|
|
37954
38020
|
const base = {
|
|
37955
|
-
hostname:
|
|
37956
|
-
platform:
|
|
38021
|
+
hostname: os19.hostname(),
|
|
38022
|
+
platform: os19.platform()
|
|
37957
38023
|
};
|
|
37958
38024
|
if (profile === "live") {
|
|
37959
38025
|
return base;
|
|
@@ -37962,23 +38028,23 @@ function buildMachineInfo(profile = "full") {
|
|
|
37962
38028
|
const memSnap2 = getHostMemorySnapshot();
|
|
37963
38029
|
return {
|
|
37964
38030
|
...base,
|
|
37965
|
-
arch:
|
|
37966
|
-
cpus:
|
|
38031
|
+
arch: os19.arch(),
|
|
38032
|
+
cpus: os19.cpus().length,
|
|
37967
38033
|
totalMem: memSnap2.totalMem,
|
|
37968
|
-
release:
|
|
38034
|
+
release: os19.release()
|
|
37969
38035
|
};
|
|
37970
38036
|
}
|
|
37971
38037
|
const memSnap = getHostMemorySnapshot();
|
|
37972
38038
|
return {
|
|
37973
38039
|
...base,
|
|
37974
|
-
arch:
|
|
37975
|
-
cpus:
|
|
38040
|
+
arch: os19.arch(),
|
|
38041
|
+
cpus: os19.cpus().length,
|
|
37976
38042
|
totalMem: memSnap.totalMem,
|
|
37977
38043
|
freeMem: memSnap.freeMem,
|
|
37978
38044
|
availableMem: memSnap.availableMem,
|
|
37979
|
-
loadavg:
|
|
37980
|
-
uptime:
|
|
37981
|
-
release:
|
|
38045
|
+
loadavg: os19.loadavg(),
|
|
38046
|
+
uptime: os19.uptime(),
|
|
38047
|
+
release: os19.release()
|
|
37982
38048
|
};
|
|
37983
38049
|
}
|
|
37984
38050
|
function parseMessageTime(value) {
|
|
@@ -38201,11 +38267,11 @@ function buildStatusSnapshot(options) {
|
|
|
38201
38267
|
}
|
|
38202
38268
|
};
|
|
38203
38269
|
}
|
|
38204
|
-
var
|
|
38270
|
+
var os19, READ_DEBUG_ENABLED, recentReadDebugSignatureBySession;
|
|
38205
38271
|
var init_snapshot = __esm({
|
|
38206
38272
|
"../../oss/packages/daemon-core/src/status/snapshot.ts"() {
|
|
38207
38273
|
"use strict";
|
|
38208
|
-
|
|
38274
|
+
os19 = __toESM(require("os"));
|
|
38209
38275
|
init_config();
|
|
38210
38276
|
init_state_store();
|
|
38211
38277
|
init_recent_activity();
|
|
@@ -38223,37 +38289,37 @@ var init_snapshot = __esm({
|
|
|
38223
38289
|
|
|
38224
38290
|
// ../../oss/packages/daemon-core/src/commands/upgrade-helper.ts
|
|
38225
38291
|
function getUpgradeLogPath() {
|
|
38226
|
-
const home =
|
|
38227
|
-
const dir =
|
|
38228
|
-
|
|
38229
|
-
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");
|
|
38230
38296
|
}
|
|
38231
38297
|
function appendUpgradeLog(message) {
|
|
38232
38298
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
38233
38299
|
`;
|
|
38234
38300
|
try {
|
|
38235
|
-
|
|
38301
|
+
fs9.appendFileSync(getUpgradeLogPath(), line, "utf8");
|
|
38236
38302
|
} catch {
|
|
38237
38303
|
}
|
|
38238
38304
|
}
|
|
38239
38305
|
function resolveSiblingNpmInvocation(nodeExecutable, platform12 = process.platform) {
|
|
38240
|
-
const binDir =
|
|
38306
|
+
const binDir = path17.dirname(nodeExecutable);
|
|
38241
38307
|
if (platform12 === "win32") {
|
|
38242
|
-
const npmCliPath =
|
|
38243
|
-
if (
|
|
38308
|
+
const npmCliPath = path17.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
38309
|
+
if (fs9.existsSync(npmCliPath)) {
|
|
38244
38310
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
|
|
38245
38311
|
}
|
|
38246
38312
|
for (const candidate of ["npm.exe", "npm"]) {
|
|
38247
|
-
const candidatePath =
|
|
38248
|
-
if (
|
|
38313
|
+
const candidatePath = path17.join(binDir, candidate);
|
|
38314
|
+
if (fs9.existsSync(candidatePath)) {
|
|
38249
38315
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
|
|
38250
38316
|
}
|
|
38251
38317
|
}
|
|
38252
38318
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
|
|
38253
38319
|
}
|
|
38254
38320
|
for (const candidate of ["npm"]) {
|
|
38255
|
-
const candidatePath =
|
|
38256
|
-
if (
|
|
38321
|
+
const candidatePath = path17.join(binDir, candidate);
|
|
38322
|
+
if (fs9.existsSync(candidatePath)) {
|
|
38257
38323
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
|
|
38258
38324
|
}
|
|
38259
38325
|
}
|
|
@@ -38263,22 +38329,22 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
|
38263
38329
|
if (!currentCliPath) return null;
|
|
38264
38330
|
let resolvedPath = currentCliPath;
|
|
38265
38331
|
try {
|
|
38266
|
-
resolvedPath =
|
|
38332
|
+
resolvedPath = fs9.realpathSync.native(currentCliPath);
|
|
38267
38333
|
} catch {
|
|
38268
38334
|
}
|
|
38269
38335
|
let currentDir = resolvedPath;
|
|
38270
38336
|
try {
|
|
38271
|
-
if (
|
|
38272
|
-
currentDir =
|
|
38337
|
+
if (fs9.statSync(resolvedPath).isFile()) {
|
|
38338
|
+
currentDir = path17.dirname(resolvedPath);
|
|
38273
38339
|
}
|
|
38274
38340
|
} catch {
|
|
38275
|
-
currentDir =
|
|
38341
|
+
currentDir = path17.dirname(resolvedPath);
|
|
38276
38342
|
}
|
|
38277
38343
|
while (true) {
|
|
38278
|
-
const packageJsonPath =
|
|
38344
|
+
const packageJsonPath = path17.join(currentDir, "package.json");
|
|
38279
38345
|
try {
|
|
38280
|
-
if (
|
|
38281
|
-
const parsed = JSON.parse(
|
|
38346
|
+
if (fs9.existsSync(packageJsonPath)) {
|
|
38347
|
+
const parsed = JSON.parse(fs9.readFileSync(packageJsonPath, "utf8"));
|
|
38282
38348
|
if (parsed?.name === packageName) {
|
|
38283
38349
|
const normalized = currentDir.replace(/\\/g, "/");
|
|
38284
38350
|
return normalized.includes("/node_modules/") ? currentDir : null;
|
|
@@ -38286,7 +38352,7 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
|
38286
38352
|
}
|
|
38287
38353
|
} catch {
|
|
38288
38354
|
}
|
|
38289
|
-
const parentDir =
|
|
38355
|
+
const parentDir = path17.dirname(currentDir);
|
|
38290
38356
|
if (parentDir === currentDir) {
|
|
38291
38357
|
return null;
|
|
38292
38358
|
}
|
|
@@ -38294,13 +38360,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
|
38294
38360
|
}
|
|
38295
38361
|
}
|
|
38296
38362
|
function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
|
|
38297
|
-
const nodeModulesDir = packageName.startsWith("@") ?
|
|
38298
|
-
if (
|
|
38363
|
+
const nodeModulesDir = packageName.startsWith("@") ? path17.dirname(path17.dirname(packageRoot)) : path17.dirname(packageRoot);
|
|
38364
|
+
if (path17.basename(nodeModulesDir) !== "node_modules") {
|
|
38299
38365
|
return null;
|
|
38300
38366
|
}
|
|
38301
|
-
const maybeLibDir =
|
|
38302
|
-
if (
|
|
38303
|
-
return
|
|
38367
|
+
const maybeLibDir = path17.dirname(nodeModulesDir);
|
|
38368
|
+
if (path17.basename(maybeLibDir) === "lib") {
|
|
38369
|
+
return path17.dirname(maybeLibDir);
|
|
38304
38370
|
}
|
|
38305
38371
|
return maybeLibDir;
|
|
38306
38372
|
}
|
|
@@ -38415,10 +38481,10 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
38415
38481
|
}
|
|
38416
38482
|
}
|
|
38417
38483
|
function stopSessionHostProcesses(appName) {
|
|
38418
|
-
const pidFile =
|
|
38484
|
+
const pidFile = path17.join(os20.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
38419
38485
|
try {
|
|
38420
|
-
if (
|
|
38421
|
-
const pid = Number.parseInt(
|
|
38486
|
+
if (fs9.existsSync(pidFile)) {
|
|
38487
|
+
const pid = Number.parseInt(fs9.readFileSync(pidFile, "utf8").trim(), 10);
|
|
38422
38488
|
if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
|
|
38423
38489
|
killPid(pid);
|
|
38424
38490
|
}
|
|
@@ -38426,15 +38492,15 @@ function stopSessionHostProcesses(appName) {
|
|
|
38426
38492
|
} catch {
|
|
38427
38493
|
} finally {
|
|
38428
38494
|
try {
|
|
38429
|
-
|
|
38495
|
+
fs9.unlinkSync(pidFile);
|
|
38430
38496
|
} catch {
|
|
38431
38497
|
}
|
|
38432
38498
|
}
|
|
38433
38499
|
}
|
|
38434
38500
|
function removeDaemonPidFile() {
|
|
38435
|
-
const pidFile =
|
|
38501
|
+
const pidFile = path17.join(os20.homedir(), ".adhdev", "daemon.pid");
|
|
38436
38502
|
try {
|
|
38437
|
-
|
|
38503
|
+
fs9.unlinkSync(pidFile);
|
|
38438
38504
|
} catch {
|
|
38439
38505
|
}
|
|
38440
38506
|
}
|
|
@@ -38443,7 +38509,7 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
|
|
|
38443
38509
|
const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
38444
38510
|
if (!npmRoot) return;
|
|
38445
38511
|
const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
38446
|
-
const binDir = process.platform === "win32" ? npmPrefix :
|
|
38512
|
+
const binDir = process.platform === "win32" ? npmPrefix : path17.join(npmPrefix, "bin");
|
|
38447
38513
|
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
38448
38514
|
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
38449
38515
|
if (pkgName === "@adhdev/daemon-standalone") {
|
|
@@ -38451,25 +38517,25 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
|
|
|
38451
38517
|
}
|
|
38452
38518
|
if (pkgName.startsWith("@")) {
|
|
38453
38519
|
const [scope, name] = pkgName.split("/");
|
|
38454
|
-
const scopeDir =
|
|
38455
|
-
if (!
|
|
38456
|
-
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)) {
|
|
38457
38523
|
if (!entry.startsWith(`.${name}-`)) continue;
|
|
38458
|
-
|
|
38459
|
-
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)}`);
|
|
38460
38526
|
}
|
|
38461
38527
|
} else {
|
|
38462
|
-
for (const entry of
|
|
38528
|
+
for (const entry of fs9.readdirSync(npmRoot)) {
|
|
38463
38529
|
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
38464
|
-
|
|
38465
|
-
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)}`);
|
|
38466
38532
|
}
|
|
38467
38533
|
}
|
|
38468
|
-
if (
|
|
38469
|
-
for (const entry of
|
|
38534
|
+
if (fs9.existsSync(binDir)) {
|
|
38535
|
+
for (const entry of fs9.readdirSync(binDir)) {
|
|
38470
38536
|
if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
38471
|
-
|
|
38472
|
-
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)}`);
|
|
38473
38539
|
}
|
|
38474
38540
|
}
|
|
38475
38541
|
}
|
|
@@ -38552,15 +38618,15 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
|
|
|
38552
38618
|
process.exit(1);
|
|
38553
38619
|
}
|
|
38554
38620
|
}
|
|
38555
|
-
var import_child_process8, import_child_process9,
|
|
38621
|
+
var import_child_process8, import_child_process9, fs9, os20, path17, UPGRADE_HELPER_ENV;
|
|
38556
38622
|
var init_upgrade_helper = __esm({
|
|
38557
38623
|
"../../oss/packages/daemon-core/src/commands/upgrade-helper.ts"() {
|
|
38558
38624
|
"use strict";
|
|
38559
38625
|
import_child_process8 = require("child_process");
|
|
38560
38626
|
import_child_process9 = require("child_process");
|
|
38561
|
-
|
|
38562
|
-
|
|
38563
|
-
|
|
38627
|
+
fs9 = __toESM(require("fs"));
|
|
38628
|
+
os20 = __toESM(require("os"));
|
|
38629
|
+
path17 = __toESM(require("path"));
|
|
38564
38630
|
UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
38565
38631
|
}
|
|
38566
38632
|
});
|
|
@@ -38647,7 +38713,7 @@ function summarizeSessionHostPruneResult(result) {
|
|
|
38647
38713
|
keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : void 0
|
|
38648
38714
|
};
|
|
38649
38715
|
}
|
|
38650
|
-
var
|
|
38716
|
+
var fs10, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
|
|
38651
38717
|
var init_router = __esm({
|
|
38652
38718
|
"../../oss/packages/daemon-core/src/commands/router.ts"() {
|
|
38653
38719
|
"use strict";
|
|
@@ -38672,7 +38738,7 @@ var init_router = __esm({
|
|
|
38672
38738
|
init_snapshot();
|
|
38673
38739
|
init_snapshot();
|
|
38674
38740
|
init_upgrade_helper();
|
|
38675
|
-
|
|
38741
|
+
fs10 = __toESM(require("fs"));
|
|
38676
38742
|
CHAT_COMMANDS = [
|
|
38677
38743
|
"send_chat",
|
|
38678
38744
|
"new_chat",
|
|
@@ -38827,8 +38893,8 @@ var init_router = __esm({
|
|
|
38827
38893
|
if (sinceTs > 0) {
|
|
38828
38894
|
return { success: true, logs: [], totalBuffered: 0 };
|
|
38829
38895
|
}
|
|
38830
|
-
if (
|
|
38831
|
-
const content =
|
|
38896
|
+
if (fs10.existsSync(LOG_PATH)) {
|
|
38897
|
+
const content = fs10.readFileSync(LOG_PATH, "utf-8");
|
|
38832
38898
|
const allLines = content.split("\n");
|
|
38833
38899
|
const recent = allLines.slice(-count).join("\n");
|
|
38834
38900
|
return { success: true, logs: recent, totalLines: allLines.length };
|
|
@@ -38970,6 +39036,8 @@ var init_router = __esm({
|
|
|
38970
39036
|
const wantsAll = args?.all === true;
|
|
38971
39037
|
const offset = wantsAll ? 0 : Math.max(0, Number(args?.offset) || 0);
|
|
38972
39038
|
const limit = wantsAll ? Number.MAX_SAFE_INTEGER : Math.max(1, Math.min(100, Number(args?.limit) || 30));
|
|
39039
|
+
const requestedWorkspace = typeof args?.workspace === "string" ? args.workspace.trim() : "";
|
|
39040
|
+
const requestedProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : typeof args?.activeProviderSessionId === "string" ? args.activeProviderSessionId.trim() : "";
|
|
38973
39041
|
const providerMeta = this.deps.providerLoader.resolve?.(providerType) || this.deps.providerLoader.getMeta(providerType);
|
|
38974
39042
|
const { sessions: historySessions, hasMore, source } = listProviderHistorySessions(providerType, {
|
|
38975
39043
|
canonicalHistory: providerMeta?.canonicalHistory,
|
|
@@ -38989,6 +39057,7 @@ var init_router = __esm({
|
|
|
38989
39057
|
sessions: historySessions.map((session) => {
|
|
38990
39058
|
const saved = savedSessionById.get(session.historySessionId);
|
|
38991
39059
|
const recent = recentSessionById.get(session.historySessionId);
|
|
39060
|
+
const workspace = saved?.workspace || recent?.workspace || session.workspace || (requestedWorkspace && requestedProviderSessionId === session.historySessionId ? requestedWorkspace : void 0);
|
|
38992
39061
|
return {
|
|
38993
39062
|
id: session.historySessionId,
|
|
38994
39063
|
providerSessionId: session.historySessionId,
|
|
@@ -38996,13 +39065,13 @@ var init_router = __esm({
|
|
|
38996
39065
|
providerName: saved?.providerName || recent?.providerName || providerType,
|
|
38997
39066
|
kind: saved?.kind || recent?.kind || kind,
|
|
38998
39067
|
title: saved?.title || recent?.title || session.sessionTitle || session.preview || providerType,
|
|
38999
|
-
workspace
|
|
39068
|
+
workspace,
|
|
39000
39069
|
summaryMetadata: saved?.summaryMetadata || recent?.summaryMetadata,
|
|
39001
39070
|
preview: session.preview,
|
|
39002
39071
|
messageCount: session.messageCount,
|
|
39003
39072
|
firstMessageAt: session.firstMessageAt,
|
|
39004
39073
|
lastMessageAt: session.lastMessageAt,
|
|
39005
|
-
canResume: !!
|
|
39074
|
+
canResume: !!workspace && canResumeById,
|
|
39006
39075
|
historySource: session.source,
|
|
39007
39076
|
sourcePath: session.sourcePath,
|
|
39008
39077
|
sourceMtimeMs: session.sourceMtimeMs
|
|
@@ -41103,19 +41172,19 @@ function getVersion(binary, versionCommand) {
|
|
|
41103
41172
|
function checkPathExists2(paths) {
|
|
41104
41173
|
for (const p of paths) {
|
|
41105
41174
|
if (p.includes("*")) {
|
|
41106
|
-
const home =
|
|
41107
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
41108
|
-
if (
|
|
41175
|
+
const home = os21.homedir();
|
|
41176
|
+
const resolved = p.replace(/\*/g, home.split(path18.sep).pop() || "");
|
|
41177
|
+
if (fs11.existsSync(resolved)) return resolved;
|
|
41109
41178
|
} else {
|
|
41110
|
-
if (
|
|
41179
|
+
if (fs11.existsSync(p)) return p;
|
|
41111
41180
|
}
|
|
41112
41181
|
}
|
|
41113
41182
|
return null;
|
|
41114
41183
|
}
|
|
41115
41184
|
function getMacAppVersion(appPath) {
|
|
41116
41185
|
if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
41117
|
-
const plistPath =
|
|
41118
|
-
if (!
|
|
41186
|
+
const plistPath = path18.join(appPath, "Contents", "Info.plist");
|
|
41187
|
+
if (!fs11.existsSync(plistPath)) return null;
|
|
41119
41188
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
41120
41189
|
return raw || null;
|
|
41121
41190
|
}
|
|
@@ -41140,8 +41209,8 @@ async function detectAllVersions(loader, archive) {
|
|
|
41140
41209
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
41141
41210
|
let resolvedBin = cliBin;
|
|
41142
41211
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
41143
|
-
const bundled =
|
|
41144
|
-
if (provider.cli &&
|
|
41212
|
+
const bundled = path18.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
41213
|
+
if (provider.cli && fs11.existsSync(bundled)) resolvedBin = bundled;
|
|
41145
41214
|
}
|
|
41146
41215
|
info.installed = !!(appPath || resolvedBin);
|
|
41147
41216
|
info.path = appPath || null;
|
|
@@ -41177,16 +41246,16 @@ async function detectAllVersions(loader, archive) {
|
|
|
41177
41246
|
}
|
|
41178
41247
|
return results;
|
|
41179
41248
|
}
|
|
41180
|
-
var
|
|
41249
|
+
var fs11, path18, os21, import_child_process10, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
|
|
41181
41250
|
var init_version_archive = __esm({
|
|
41182
41251
|
"../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
|
|
41183
41252
|
"use strict";
|
|
41184
|
-
|
|
41185
|
-
|
|
41186
|
-
|
|
41253
|
+
fs11 = __toESM(require("fs"));
|
|
41254
|
+
path18 = __toESM(require("path"));
|
|
41255
|
+
os21 = __toESM(require("os"));
|
|
41187
41256
|
import_child_process10 = require("child_process");
|
|
41188
41257
|
import_os3 = require("os");
|
|
41189
|
-
ARCHIVE_PATH =
|
|
41258
|
+
ARCHIVE_PATH = path18.join(os21.homedir(), ".adhdev", "version-history.json");
|
|
41190
41259
|
MAX_ENTRIES_PER_PROVIDER = 20;
|
|
41191
41260
|
VersionArchive = class {
|
|
41192
41261
|
history = {};
|
|
@@ -41195,8 +41264,8 @@ var init_version_archive = __esm({
|
|
|
41195
41264
|
}
|
|
41196
41265
|
load() {
|
|
41197
41266
|
try {
|
|
41198
|
-
if (
|
|
41199
|
-
this.history = JSON.parse(
|
|
41267
|
+
if (fs11.existsSync(ARCHIVE_PATH)) {
|
|
41268
|
+
this.history = JSON.parse(fs11.readFileSync(ARCHIVE_PATH, "utf-8"));
|
|
41200
41269
|
}
|
|
41201
41270
|
} catch {
|
|
41202
41271
|
this.history = {};
|
|
@@ -41233,8 +41302,8 @@ var init_version_archive = __esm({
|
|
|
41233
41302
|
}
|
|
41234
41303
|
save() {
|
|
41235
41304
|
try {
|
|
41236
|
-
|
|
41237
|
-
|
|
41305
|
+
fs11.mkdirSync(path18.dirname(ARCHIVE_PATH), { recursive: true });
|
|
41306
|
+
fs11.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
41238
41307
|
} catch {
|
|
41239
41308
|
}
|
|
41240
41309
|
}
|
|
@@ -41768,18 +41837,18 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
41768
41837
|
return;
|
|
41769
41838
|
}
|
|
41770
41839
|
let scriptsPath = "";
|
|
41771
|
-
const directScripts =
|
|
41772
|
-
if (
|
|
41840
|
+
const directScripts = path19.join(dir, "scripts.js");
|
|
41841
|
+
if (fs12.existsSync(directScripts)) {
|
|
41773
41842
|
scriptsPath = directScripts;
|
|
41774
41843
|
} else {
|
|
41775
|
-
const scriptsDir =
|
|
41776
|
-
if (
|
|
41777
|
-
const versions =
|
|
41778
|
-
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();
|
|
41779
41848
|
}).sort().reverse();
|
|
41780
41849
|
for (const ver of versions) {
|
|
41781
|
-
const p =
|
|
41782
|
-
if (
|
|
41850
|
+
const p = path19.join(scriptsDir, ver, "scripts.js");
|
|
41851
|
+
if (fs12.existsSync(p)) {
|
|
41783
41852
|
scriptsPath = p;
|
|
41784
41853
|
break;
|
|
41785
41854
|
}
|
|
@@ -41791,7 +41860,7 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
41791
41860
|
return;
|
|
41792
41861
|
}
|
|
41793
41862
|
try {
|
|
41794
|
-
const source =
|
|
41863
|
+
const source = fs12.readFileSync(scriptsPath, "utf-8");
|
|
41795
41864
|
const hints = {};
|
|
41796
41865
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
41797
41866
|
let match;
|
|
@@ -42604,12 +42673,12 @@ async function handleDomContext(ctx, type, req, res) {
|
|
|
42604
42673
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
42605
42674
|
}
|
|
42606
42675
|
}
|
|
42607
|
-
var
|
|
42676
|
+
var fs12, path19;
|
|
42608
42677
|
var init_dev_cdp_handlers = __esm({
|
|
42609
42678
|
"../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
|
|
42610
42679
|
"use strict";
|
|
42611
|
-
|
|
42612
|
-
|
|
42680
|
+
fs12 = __toESM(require("fs"));
|
|
42681
|
+
path19 = __toESM(require("path"));
|
|
42613
42682
|
init_logger();
|
|
42614
42683
|
}
|
|
42615
42684
|
});
|
|
@@ -42624,15 +42693,15 @@ function getCliFixtureDir(ctx, type) {
|
|
|
42624
42693
|
if (!providerDir) {
|
|
42625
42694
|
throw new Error(`Provider directory not found for '${type}'`);
|
|
42626
42695
|
}
|
|
42627
|
-
return
|
|
42696
|
+
return path20.join(providerDir, "fixtures");
|
|
42628
42697
|
}
|
|
42629
42698
|
function readCliFixture(ctx, type, name) {
|
|
42630
42699
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
42631
|
-
const filePath =
|
|
42632
|
-
if (!
|
|
42700
|
+
const filePath = path20.join(fixtureDir, `${name}.json`);
|
|
42701
|
+
if (!fs13.existsSync(filePath)) {
|
|
42633
42702
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
42634
42703
|
}
|
|
42635
|
-
return JSON.parse(
|
|
42704
|
+
return JSON.parse(fs13.readFileSync(filePath, "utf-8"));
|
|
42636
42705
|
}
|
|
42637
42706
|
function getExerciseTranscriptText(result) {
|
|
42638
42707
|
const parts = [];
|
|
@@ -43368,7 +43437,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
43368
43437
|
return;
|
|
43369
43438
|
}
|
|
43370
43439
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
43371
|
-
|
|
43440
|
+
fs13.mkdirSync(fixtureDir, { recursive: true });
|
|
43372
43441
|
const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
|
|
43373
43442
|
const result = await runCliExerciseInternal(ctx, { ...request, type });
|
|
43374
43443
|
const fixture = {
|
|
@@ -43395,8 +43464,8 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
43395
43464
|
},
|
|
43396
43465
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
43397
43466
|
};
|
|
43398
|
-
const filePath =
|
|
43399
|
-
|
|
43467
|
+
const filePath = path20.join(fixtureDir, `${name}.json`);
|
|
43468
|
+
fs13.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
43400
43469
|
ctx.json(res, 200, {
|
|
43401
43470
|
saved: true,
|
|
43402
43471
|
name,
|
|
@@ -43414,14 +43483,14 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
43414
43483
|
async function handleCliFixtureList(ctx, type, _req, res) {
|
|
43415
43484
|
try {
|
|
43416
43485
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
43417
|
-
if (!
|
|
43486
|
+
if (!fs13.existsSync(fixtureDir)) {
|
|
43418
43487
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
43419
43488
|
return;
|
|
43420
43489
|
}
|
|
43421
|
-
const fixtures =
|
|
43422
|
-
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);
|
|
43423
43492
|
try {
|
|
43424
|
-
const raw = JSON.parse(
|
|
43493
|
+
const raw = JSON.parse(fs13.readFileSync(fullPath, "utf-8"));
|
|
43425
43494
|
return {
|
|
43426
43495
|
name: raw.name || file2.replace(/\.json$/i, ""),
|
|
43427
43496
|
path: fullPath,
|
|
@@ -43552,12 +43621,12 @@ async function handleCliRaw(ctx, req, res) {
|
|
|
43552
43621
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
43553
43622
|
}
|
|
43554
43623
|
}
|
|
43555
|
-
var
|
|
43624
|
+
var fs13, path20;
|
|
43556
43625
|
var init_dev_cli_debug = __esm({
|
|
43557
43626
|
"../../oss/packages/daemon-core/src/daemon/dev-cli-debug.ts"() {
|
|
43558
43627
|
"use strict";
|
|
43559
|
-
|
|
43560
|
-
|
|
43628
|
+
fs13 = __toESM(require("fs"));
|
|
43629
|
+
path20 = __toESM(require("path"));
|
|
43561
43630
|
}
|
|
43562
43631
|
});
|
|
43563
43632
|
|
|
@@ -43607,38 +43676,38 @@ function resolveAutoImplReference(ctx, category, requestedReference, targetType)
|
|
|
43607
43676
|
return fallback2?.type || null;
|
|
43608
43677
|
}
|
|
43609
43678
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
43610
|
-
if (!
|
|
43611
|
-
const versions =
|
|
43679
|
+
if (!fs14.existsSync(scriptsDir)) return null;
|
|
43680
|
+
const versions = fs14.readdirSync(scriptsDir).filter((d) => {
|
|
43612
43681
|
try {
|
|
43613
|
-
return
|
|
43682
|
+
return fs14.statSync(path21.join(scriptsDir, d)).isDirectory();
|
|
43614
43683
|
} catch {
|
|
43615
43684
|
return false;
|
|
43616
43685
|
}
|
|
43617
43686
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
43618
43687
|
if (versions.length === 0) return null;
|
|
43619
|
-
return
|
|
43688
|
+
return path21.join(scriptsDir, versions[0]);
|
|
43620
43689
|
}
|
|
43621
43690
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
43622
|
-
const canonicalUserDir =
|
|
43623
|
-
const desiredDir = requestedDir ?
|
|
43624
|
-
const upstreamRoot =
|
|
43625
|
-
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}`)) {
|
|
43626
43695
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
43627
43696
|
}
|
|
43628
|
-
if (
|
|
43697
|
+
if (path21.basename(desiredDir) !== type) {
|
|
43629
43698
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
43630
43699
|
}
|
|
43631
43700
|
const sourceDir = ctx.findProviderDir(type);
|
|
43632
43701
|
if (!sourceDir) {
|
|
43633
43702
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
43634
43703
|
}
|
|
43635
|
-
if (!
|
|
43636
|
-
|
|
43637
|
-
|
|
43704
|
+
if (!fs14.existsSync(desiredDir)) {
|
|
43705
|
+
fs14.mkdirSync(path21.dirname(desiredDir), { recursive: true });
|
|
43706
|
+
fs14.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
43638
43707
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
43639
43708
|
}
|
|
43640
|
-
const providerJson =
|
|
43641
|
-
if (!
|
|
43709
|
+
const providerJson = path21.join(desiredDir, "provider.json");
|
|
43710
|
+
if (!fs14.existsSync(providerJson)) {
|
|
43642
43711
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
43643
43712
|
}
|
|
43644
43713
|
return { dir: desiredDir };
|
|
@@ -43646,15 +43715,15 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
43646
43715
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
43647
43716
|
if (!referenceType) return {};
|
|
43648
43717
|
const refDir = ctx.findProviderDir(referenceType);
|
|
43649
|
-
if (!refDir || !
|
|
43718
|
+
if (!refDir || !fs14.existsSync(refDir)) return {};
|
|
43650
43719
|
const referenceScripts = {};
|
|
43651
|
-
const scriptsDir =
|
|
43720
|
+
const scriptsDir = path21.join(refDir, "scripts");
|
|
43652
43721
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
43653
43722
|
if (!latestDir) return referenceScripts;
|
|
43654
|
-
for (const file2 of
|
|
43723
|
+
for (const file2 of fs14.readdirSync(latestDir)) {
|
|
43655
43724
|
if (!file2.endsWith(".js")) continue;
|
|
43656
43725
|
try {
|
|
43657
|
-
referenceScripts[file2] =
|
|
43726
|
+
referenceScripts[file2] = fs14.readFileSync(path21.join(latestDir, file2), "utf-8");
|
|
43658
43727
|
} catch {
|
|
43659
43728
|
}
|
|
43660
43729
|
}
|
|
@@ -43762,16 +43831,16 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
43762
43831
|
});
|
|
43763
43832
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
43764
43833
|
const prompt2 = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
43765
|
-
const tmpDir =
|
|
43766
|
-
if (!
|
|
43767
|
-
const promptFile =
|
|
43768
|
-
|
|
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");
|
|
43769
43838
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt2.length} chars)`);
|
|
43770
43839
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
43771
43840
|
const spawn6 = agentProvider?.spawn;
|
|
43772
43841
|
if (!spawn6?.command) {
|
|
43773
43842
|
try {
|
|
43774
|
-
|
|
43843
|
+
fs14.unlinkSync(promptFile);
|
|
43775
43844
|
} catch {
|
|
43776
43845
|
}
|
|
43777
43846
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -43873,7 +43942,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
43873
43942
|
} catch {
|
|
43874
43943
|
}
|
|
43875
43944
|
try {
|
|
43876
|
-
|
|
43945
|
+
fs14.unlinkSync(promptFile);
|
|
43877
43946
|
} catch {
|
|
43878
43947
|
}
|
|
43879
43948
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -43917,7 +43986,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
43917
43986
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
43918
43987
|
const baseArgs = [...spawn6.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
43919
43988
|
let shellCmd;
|
|
43920
|
-
const isWin =
|
|
43989
|
+
const isWin = os23.platform() === "win32";
|
|
43921
43990
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
43922
43991
|
const promptMode = autoImpl?.promptMode ?? "stdin";
|
|
43923
43992
|
const extraArgs = autoImpl?.extraArgs ?? [];
|
|
@@ -43956,7 +44025,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
43956
44025
|
try {
|
|
43957
44026
|
const pty = require("node-pty");
|
|
43958
44027
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
43959
|
-
const isWin2 =
|
|
44028
|
+
const isWin2 = os23.platform() === "win32";
|
|
43960
44029
|
child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
43961
44030
|
name: "xterm-256color",
|
|
43962
44031
|
cols: 120,
|
|
@@ -44099,7 +44168,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
44099
44168
|
}
|
|
44100
44169
|
});
|
|
44101
44170
|
try {
|
|
44102
|
-
|
|
44171
|
+
fs14.unlinkSync(promptFile);
|
|
44103
44172
|
} catch {
|
|
44104
44173
|
}
|
|
44105
44174
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -44196,7 +44265,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
44196
44265
|
setMode: "set_mode.js"
|
|
44197
44266
|
};
|
|
44198
44267
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
44199
|
-
const scriptsDir =
|
|
44268
|
+
const scriptsDir = path21.join(providerDir, "scripts");
|
|
44200
44269
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
44201
44270
|
if (latestScriptsDir) {
|
|
44202
44271
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -44204,10 +44273,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
44204
44273
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
44205
44274
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
44206
44275
|
lines.push("");
|
|
44207
|
-
for (const file2 of
|
|
44276
|
+
for (const file2 of fs14.readdirSync(latestScriptsDir)) {
|
|
44208
44277
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
44209
44278
|
try {
|
|
44210
|
-
const content =
|
|
44279
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
44211
44280
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
44212
44281
|
lines.push("```javascript");
|
|
44213
44282
|
lines.push(content);
|
|
@@ -44217,14 +44286,14 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
44217
44286
|
}
|
|
44218
44287
|
}
|
|
44219
44288
|
}
|
|
44220
|
-
const refFiles =
|
|
44289
|
+
const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
44221
44290
|
if (refFiles.length > 0) {
|
|
44222
44291
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
44223
44292
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
44224
44293
|
lines.push("");
|
|
44225
44294
|
for (const file2 of refFiles) {
|
|
44226
44295
|
try {
|
|
44227
|
-
const content =
|
|
44296
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
44228
44297
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
44229
44298
|
lines.push("```javascript");
|
|
44230
44299
|
lines.push(content);
|
|
@@ -44265,11 +44334,11 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
44265
44334
|
lines.push("");
|
|
44266
44335
|
}
|
|
44267
44336
|
}
|
|
44268
|
-
const docsDir =
|
|
44337
|
+
const docsDir = path21.join(providerDir, "../../docs");
|
|
44269
44338
|
const loadGuide = (name) => {
|
|
44270
44339
|
try {
|
|
44271
|
-
const p =
|
|
44272
|
-
if (
|
|
44340
|
+
const p = path21.join(docsDir, name);
|
|
44341
|
+
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
44273
44342
|
} catch {
|
|
44274
44343
|
}
|
|
44275
44344
|
return null;
|
|
@@ -44505,7 +44574,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
44505
44574
|
parseApproval: "parse_approval.js"
|
|
44506
44575
|
};
|
|
44507
44576
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
44508
|
-
const scriptsDir =
|
|
44577
|
+
const scriptsDir = path21.join(providerDir, "scripts");
|
|
44509
44578
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
44510
44579
|
if (latestScriptsDir) {
|
|
44511
44580
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -44513,11 +44582,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
44513
44582
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
44514
44583
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
44515
44584
|
lines.push("");
|
|
44516
|
-
for (const file2 of
|
|
44585
|
+
for (const file2 of fs14.readdirSync(latestScriptsDir)) {
|
|
44517
44586
|
if (!file2.endsWith(".js")) continue;
|
|
44518
44587
|
if (!targetFileNames.has(file2)) continue;
|
|
44519
44588
|
try {
|
|
44520
|
-
const content =
|
|
44589
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
44521
44590
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
44522
44591
|
lines.push("```javascript");
|
|
44523
44592
|
lines.push(content);
|
|
@@ -44526,14 +44595,14 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
44526
44595
|
} catch {
|
|
44527
44596
|
}
|
|
44528
44597
|
}
|
|
44529
|
-
const refFiles =
|
|
44598
|
+
const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
44530
44599
|
if (refFiles.length > 0) {
|
|
44531
44600
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
44532
44601
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
44533
44602
|
lines.push("");
|
|
44534
44603
|
for (const file2 of refFiles) {
|
|
44535
44604
|
try {
|
|
44536
|
-
const content =
|
|
44605
|
+
const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
|
|
44537
44606
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
44538
44607
|
lines.push("```javascript");
|
|
44539
44608
|
lines.push(content);
|
|
@@ -44566,11 +44635,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
44566
44635
|
lines.push("");
|
|
44567
44636
|
}
|
|
44568
44637
|
}
|
|
44569
|
-
const docsDir =
|
|
44638
|
+
const docsDir = path21.join(providerDir, "../../docs");
|
|
44570
44639
|
const loadGuide = (name) => {
|
|
44571
44640
|
try {
|
|
44572
|
-
const p =
|
|
44573
|
-
if (
|
|
44641
|
+
const p = path21.join(docsDir, name);
|
|
44642
|
+
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
44574
44643
|
} catch {
|
|
44575
44644
|
}
|
|
44576
44645
|
return null;
|
|
@@ -44881,13 +44950,13 @@ data: ${JSON.stringify(msg.data)}
|
|
|
44881
44950
|
}
|
|
44882
44951
|
}
|
|
44883
44952
|
}
|
|
44884
|
-
var
|
|
44953
|
+
var fs14, path21, os23;
|
|
44885
44954
|
var init_dev_auto_implement = __esm({
|
|
44886
44955
|
"../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
|
|
44887
44956
|
"use strict";
|
|
44888
|
-
|
|
44889
|
-
|
|
44890
|
-
|
|
44957
|
+
fs14 = __toESM(require("fs"));
|
|
44958
|
+
path21 = __toESM(require("path"));
|
|
44959
|
+
os23 = __toESM(require("os"));
|
|
44891
44960
|
init_dev_server();
|
|
44892
44961
|
init_dev_cli_debug();
|
|
44893
44962
|
}
|
|
@@ -44926,13 +44995,13 @@ function toProviderListEntry(provider) {
|
|
|
44926
44995
|
}
|
|
44927
44996
|
return base;
|
|
44928
44997
|
}
|
|
44929
|
-
var http2,
|
|
44998
|
+
var http2, fs15, path23, DEV_SERVER_PORT, DevServer;
|
|
44930
44999
|
var init_dev_server = __esm({
|
|
44931
45000
|
"../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
|
|
44932
45001
|
"use strict";
|
|
44933
45002
|
http2 = __toESM(require("http"));
|
|
44934
|
-
|
|
44935
|
-
|
|
45003
|
+
fs15 = __toESM(require("fs"));
|
|
45004
|
+
path23 = __toESM(require("path"));
|
|
44936
45005
|
init_provider_schema();
|
|
44937
45006
|
init_config();
|
|
44938
45007
|
init_provider_source_config();
|
|
@@ -45045,8 +45114,8 @@ var init_dev_server = __esm({
|
|
|
45045
45114
|
}
|
|
45046
45115
|
getEndpointList() {
|
|
45047
45116
|
return this.routes.map((r) => {
|
|
45048
|
-
const
|
|
45049
|
-
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}`;
|
|
45050
45119
|
});
|
|
45051
45120
|
}
|
|
45052
45121
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -45334,12 +45403,12 @@ var init_dev_server = __esm({
|
|
|
45334
45403
|
// ─── DevConsole SPA ───
|
|
45335
45404
|
getConsoleDistDir() {
|
|
45336
45405
|
const candidates = [
|
|
45337
|
-
|
|
45338
|
-
|
|
45339
|
-
|
|
45406
|
+
path23.resolve(__dirname, "../../web-devconsole/dist"),
|
|
45407
|
+
path23.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
45408
|
+
path23.join(process.cwd(), "packages/web-devconsole/dist")
|
|
45340
45409
|
];
|
|
45341
45410
|
for (const dir of candidates) {
|
|
45342
|
-
if (
|
|
45411
|
+
if (fs15.existsSync(path23.join(dir, "index.html"))) return dir;
|
|
45343
45412
|
}
|
|
45344
45413
|
return null;
|
|
45345
45414
|
}
|
|
@@ -45349,9 +45418,9 @@ var init_dev_server = __esm({
|
|
|
45349
45418
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
45350
45419
|
return;
|
|
45351
45420
|
}
|
|
45352
|
-
const htmlPath =
|
|
45421
|
+
const htmlPath = path23.join(distDir, "index.html");
|
|
45353
45422
|
try {
|
|
45354
|
-
const html =
|
|
45423
|
+
const html = fs15.readFileSync(htmlPath, "utf-8");
|
|
45355
45424
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
45356
45425
|
res.end(html);
|
|
45357
45426
|
} catch (e) {
|
|
@@ -45374,15 +45443,15 @@ var init_dev_server = __esm({
|
|
|
45374
45443
|
this.json(res, 404, { error: "Not found" });
|
|
45375
45444
|
return;
|
|
45376
45445
|
}
|
|
45377
|
-
const safePath =
|
|
45378
|
-
const filePath =
|
|
45446
|
+
const safePath = path23.normalize(pathname).replace(/^\.\.\//, "");
|
|
45447
|
+
const filePath = path23.join(distDir, safePath);
|
|
45379
45448
|
if (!filePath.startsWith(distDir)) {
|
|
45380
45449
|
this.json(res, 403, { error: "Forbidden" });
|
|
45381
45450
|
return;
|
|
45382
45451
|
}
|
|
45383
45452
|
try {
|
|
45384
|
-
const content =
|
|
45385
|
-
const ext =
|
|
45453
|
+
const content = fs15.readFileSync(filePath);
|
|
45454
|
+
const ext = path23.extname(filePath);
|
|
45386
45455
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
45387
45456
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
45388
45457
|
res.end(content);
|
|
@@ -45490,14 +45559,14 @@ var init_dev_server = __esm({
|
|
|
45490
45559
|
const files = [];
|
|
45491
45560
|
const scan = (d, prefix) => {
|
|
45492
45561
|
try {
|
|
45493
|
-
for (const entry of
|
|
45562
|
+
for (const entry of fs15.readdirSync(d, { withFileTypes: true })) {
|
|
45494
45563
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
45495
45564
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
45496
45565
|
if (entry.isDirectory()) {
|
|
45497
45566
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
45498
|
-
scan(
|
|
45567
|
+
scan(path23.join(d, entry.name), rel);
|
|
45499
45568
|
} else {
|
|
45500
|
-
const stat4 =
|
|
45569
|
+
const stat4 = fs15.statSync(path23.join(d, entry.name));
|
|
45501
45570
|
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
45502
45571
|
}
|
|
45503
45572
|
}
|
|
@@ -45520,16 +45589,16 @@ var init_dev_server = __esm({
|
|
|
45520
45589
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
45521
45590
|
return;
|
|
45522
45591
|
}
|
|
45523
|
-
const fullPath =
|
|
45592
|
+
const fullPath = path23.resolve(dir, path23.normalize(filePath));
|
|
45524
45593
|
if (!fullPath.startsWith(dir)) {
|
|
45525
45594
|
this.json(res, 403, { error: "Forbidden" });
|
|
45526
45595
|
return;
|
|
45527
45596
|
}
|
|
45528
|
-
if (!
|
|
45597
|
+
if (!fs15.existsSync(fullPath) || fs15.statSync(fullPath).isDirectory()) {
|
|
45529
45598
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
45530
45599
|
return;
|
|
45531
45600
|
}
|
|
45532
|
-
const content =
|
|
45601
|
+
const content = fs15.readFileSync(fullPath, "utf-8");
|
|
45533
45602
|
this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
|
|
45534
45603
|
}
|
|
45535
45604
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -45545,15 +45614,15 @@ var init_dev_server = __esm({
|
|
|
45545
45614
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
45546
45615
|
return;
|
|
45547
45616
|
}
|
|
45548
|
-
const fullPath =
|
|
45617
|
+
const fullPath = path23.resolve(dir, path23.normalize(filePath));
|
|
45549
45618
|
if (!fullPath.startsWith(dir)) {
|
|
45550
45619
|
this.json(res, 403, { error: "Forbidden" });
|
|
45551
45620
|
return;
|
|
45552
45621
|
}
|
|
45553
45622
|
try {
|
|
45554
|
-
if (
|
|
45555
|
-
|
|
45556
|
-
|
|
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");
|
|
45557
45626
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
45558
45627
|
this.providerLoader.reload();
|
|
45559
45628
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -45569,9 +45638,9 @@ var init_dev_server = __esm({
|
|
|
45569
45638
|
return;
|
|
45570
45639
|
}
|
|
45571
45640
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
45572
|
-
const p =
|
|
45573
|
-
if (
|
|
45574
|
-
const source =
|
|
45641
|
+
const p = path23.join(dir, name);
|
|
45642
|
+
if (fs15.existsSync(p)) {
|
|
45643
|
+
const source = fs15.readFileSync(p, "utf-8");
|
|
45575
45644
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
45576
45645
|
return;
|
|
45577
45646
|
}
|
|
@@ -45590,11 +45659,11 @@ var init_dev_server = __esm({
|
|
|
45590
45659
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
45591
45660
|
return;
|
|
45592
45661
|
}
|
|
45593
|
-
const target =
|
|
45594
|
-
const targetPath =
|
|
45662
|
+
const target = fs15.existsSync(path23.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
45663
|
+
const targetPath = path23.join(dir, target);
|
|
45595
45664
|
try {
|
|
45596
|
-
if (
|
|
45597
|
-
|
|
45665
|
+
if (fs15.existsSync(targetPath)) fs15.copyFileSync(targetPath, targetPath + ".bak");
|
|
45666
|
+
fs15.writeFileSync(targetPath, source, "utf-8");
|
|
45598
45667
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
45599
45668
|
this.providerLoader.reload();
|
|
45600
45669
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -45738,21 +45807,21 @@ var init_dev_server = __esm({
|
|
|
45738
45807
|
}
|
|
45739
45808
|
let targetDir;
|
|
45740
45809
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
45741
|
-
const jsonPath =
|
|
45742
|
-
if (
|
|
45810
|
+
const jsonPath = path23.join(targetDir, "provider.json");
|
|
45811
|
+
if (fs15.existsSync(jsonPath)) {
|
|
45743
45812
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
45744
45813
|
return;
|
|
45745
45814
|
}
|
|
45746
45815
|
try {
|
|
45747
45816
|
const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
|
|
45748
|
-
|
|
45749
|
-
|
|
45817
|
+
fs15.mkdirSync(targetDir, { recursive: true });
|
|
45818
|
+
fs15.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
45750
45819
|
const createdFiles = ["provider.json"];
|
|
45751
45820
|
if (result.files) {
|
|
45752
45821
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
45753
|
-
const fullPath =
|
|
45754
|
-
|
|
45755
|
-
|
|
45822
|
+
const fullPath = path23.join(targetDir, relPath);
|
|
45823
|
+
fs15.mkdirSync(path23.dirname(fullPath), { recursive: true });
|
|
45824
|
+
fs15.writeFileSync(fullPath, content, "utf-8");
|
|
45756
45825
|
createdFiles.push(relPath);
|
|
45757
45826
|
}
|
|
45758
45827
|
}
|
|
@@ -45801,38 +45870,38 @@ var init_dev_server = __esm({
|
|
|
45801
45870
|
}
|
|
45802
45871
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
45803
45872
|
getLatestScriptVersionDir(scriptsDir) {
|
|
45804
|
-
if (!
|
|
45805
|
-
const versions =
|
|
45873
|
+
if (!fs15.existsSync(scriptsDir)) return null;
|
|
45874
|
+
const versions = fs15.readdirSync(scriptsDir).filter((d) => {
|
|
45806
45875
|
try {
|
|
45807
|
-
return
|
|
45876
|
+
return fs15.statSync(path23.join(scriptsDir, d)).isDirectory();
|
|
45808
45877
|
} catch {
|
|
45809
45878
|
return false;
|
|
45810
45879
|
}
|
|
45811
45880
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
45812
45881
|
if (versions.length === 0) return null;
|
|
45813
|
-
return
|
|
45882
|
+
return path23.join(scriptsDir, versions[0]);
|
|
45814
45883
|
}
|
|
45815
45884
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
45816
|
-
const canonicalUserDir =
|
|
45817
|
-
const desiredDir = requestedDir ?
|
|
45818
|
-
const upstreamRoot =
|
|
45819
|
-
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}`)) {
|
|
45820
45889
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
45821
45890
|
}
|
|
45822
|
-
if (
|
|
45891
|
+
if (path23.basename(desiredDir) !== type) {
|
|
45823
45892
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
45824
45893
|
}
|
|
45825
45894
|
const sourceDir = this.findProviderDir(type);
|
|
45826
45895
|
if (!sourceDir) {
|
|
45827
45896
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
45828
45897
|
}
|
|
45829
|
-
if (!
|
|
45830
|
-
|
|
45831
|
-
|
|
45898
|
+
if (!fs15.existsSync(desiredDir)) {
|
|
45899
|
+
fs15.mkdirSync(path23.dirname(desiredDir), { recursive: true });
|
|
45900
|
+
fs15.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
45832
45901
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
45833
45902
|
}
|
|
45834
|
-
const providerJson =
|
|
45835
|
-
if (!
|
|
45903
|
+
const providerJson = path23.join(desiredDir, "provider.json");
|
|
45904
|
+
if (!fs15.existsSync(providerJson)) {
|
|
45836
45905
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
45837
45906
|
}
|
|
45838
45907
|
return { dir: desiredDir };
|
|
@@ -45867,7 +45936,7 @@ var init_dev_server = __esm({
|
|
|
45867
45936
|
setMode: "set_mode.js"
|
|
45868
45937
|
};
|
|
45869
45938
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
45870
|
-
const scriptsDir =
|
|
45939
|
+
const scriptsDir = path23.join(providerDir, "scripts");
|
|
45871
45940
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
45872
45941
|
if (latestScriptsDir) {
|
|
45873
45942
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -45875,10 +45944,10 @@ var init_dev_server = __esm({
|
|
|
45875
45944
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
45876
45945
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
45877
45946
|
lines.push("");
|
|
45878
|
-
for (const file2 of
|
|
45947
|
+
for (const file2 of fs15.readdirSync(latestScriptsDir)) {
|
|
45879
45948
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
45880
45949
|
try {
|
|
45881
|
-
const content =
|
|
45950
|
+
const content = fs15.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
45882
45951
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
45883
45952
|
lines.push("```javascript");
|
|
45884
45953
|
lines.push(content);
|
|
@@ -45888,14 +45957,14 @@ var init_dev_server = __esm({
|
|
|
45888
45957
|
}
|
|
45889
45958
|
}
|
|
45890
45959
|
}
|
|
45891
|
-
const refFiles =
|
|
45960
|
+
const refFiles = fs15.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
45892
45961
|
if (refFiles.length > 0) {
|
|
45893
45962
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
45894
45963
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
45895
45964
|
lines.push("");
|
|
45896
45965
|
for (const file2 of refFiles) {
|
|
45897
45966
|
try {
|
|
45898
|
-
const content =
|
|
45967
|
+
const content = fs15.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
45899
45968
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
45900
45969
|
lines.push("```javascript");
|
|
45901
45970
|
lines.push(content);
|
|
@@ -45936,11 +46005,11 @@ var init_dev_server = __esm({
|
|
|
45936
46005
|
lines.push("");
|
|
45937
46006
|
}
|
|
45938
46007
|
}
|
|
45939
|
-
const docsDir =
|
|
46008
|
+
const docsDir = path23.join(providerDir, "../../docs");
|
|
45940
46009
|
const loadGuide = (name) => {
|
|
45941
46010
|
try {
|
|
45942
|
-
const p =
|
|
45943
|
-
if (
|
|
46011
|
+
const p = path23.join(docsDir, name);
|
|
46012
|
+
if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
|
|
45944
46013
|
} catch {
|
|
45945
46014
|
}
|
|
45946
46015
|
return null;
|
|
@@ -46113,7 +46182,7 @@ var init_dev_server = __esm({
|
|
|
46113
46182
|
parseApproval: "parse_approval.js"
|
|
46114
46183
|
};
|
|
46115
46184
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
46116
|
-
const scriptsDir =
|
|
46185
|
+
const scriptsDir = path23.join(providerDir, "scripts");
|
|
46117
46186
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
46118
46187
|
if (latestScriptsDir) {
|
|
46119
46188
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -46121,11 +46190,11 @@ var init_dev_server = __esm({
|
|
|
46121
46190
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
46122
46191
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
46123
46192
|
lines.push("");
|
|
46124
|
-
for (const file2 of
|
|
46193
|
+
for (const file2 of fs15.readdirSync(latestScriptsDir)) {
|
|
46125
46194
|
if (!file2.endsWith(".js")) continue;
|
|
46126
46195
|
if (!targetFileNames.has(file2)) continue;
|
|
46127
46196
|
try {
|
|
46128
|
-
const content =
|
|
46197
|
+
const content = fs15.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
46129
46198
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
46130
46199
|
lines.push("```javascript");
|
|
46131
46200
|
lines.push(content);
|
|
@@ -46134,14 +46203,14 @@ var init_dev_server = __esm({
|
|
|
46134
46203
|
} catch {
|
|
46135
46204
|
}
|
|
46136
46205
|
}
|
|
46137
|
-
const refFiles =
|
|
46206
|
+
const refFiles = fs15.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
46138
46207
|
if (refFiles.length > 0) {
|
|
46139
46208
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
46140
46209
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
46141
46210
|
lines.push("");
|
|
46142
46211
|
for (const file2 of refFiles) {
|
|
46143
46212
|
try {
|
|
46144
|
-
const content =
|
|
46213
|
+
const content = fs15.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
46145
46214
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
46146
46215
|
lines.push("```javascript");
|
|
46147
46216
|
lines.push(content);
|
|
@@ -46174,11 +46243,11 @@ var init_dev_server = __esm({
|
|
|
46174
46243
|
lines.push("");
|
|
46175
46244
|
}
|
|
46176
46245
|
}
|
|
46177
|
-
const docsDir =
|
|
46246
|
+
const docsDir = path23.join(providerDir, "../../docs");
|
|
46178
46247
|
const loadGuide = (name) => {
|
|
46179
46248
|
try {
|
|
46180
|
-
const p =
|
|
46181
|
-
if (
|
|
46249
|
+
const p = path23.join(docsDir, name);
|
|
46250
|
+
if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
|
|
46182
46251
|
} catch {
|
|
46183
46252
|
}
|
|
46184
46253
|
return null;
|
|
@@ -46988,8 +47057,8 @@ async function installExtension(ide, extension) {
|
|
|
46988
47057
|
const res = await fetch(extension.vsixUrl);
|
|
46989
47058
|
if (res.ok) {
|
|
46990
47059
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
46991
|
-
const
|
|
46992
|
-
|
|
47060
|
+
const fs20 = await import("fs");
|
|
47061
|
+
fs20.writeFileSync(vsixPath, buffer);
|
|
46993
47062
|
return new Promise((resolve16) => {
|
|
46994
47063
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
46995
47064
|
(0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
@@ -48410,12 +48479,14 @@ var init_data_channel_router = __esm({
|
|
|
48410
48479
|
});
|
|
48411
48480
|
|
|
48412
48481
|
// src/daemon-p2p/screenshot-sender.ts
|
|
48413
|
-
var CHUNK_SIZE, ScreenshotSender;
|
|
48482
|
+
var CHUNK_SIZE, MAX_INLINE_JSON_MESSAGE_BYTES, JSON_CHUNK_PAYLOAD_CHARS2, ScreenshotSender;
|
|
48414
48483
|
var init_screenshot_sender = __esm({
|
|
48415
48484
|
"src/daemon-p2p/screenshot-sender.ts"() {
|
|
48416
48485
|
"use strict";
|
|
48417
48486
|
init_log();
|
|
48418
48487
|
CHUNK_SIZE = 6e4;
|
|
48488
|
+
MAX_INLINE_JSON_MESSAGE_BYTES = 6e4;
|
|
48489
|
+
JSON_CHUNK_PAYLOAD_CHARS2 = 16e3;
|
|
48419
48490
|
ScreenshotSender = class {
|
|
48420
48491
|
_ssDebugDone = false;
|
|
48421
48492
|
sendStatus(peers, status) {
|
|
@@ -48454,16 +48525,43 @@ var init_screenshot_sender = __esm({
|
|
|
48454
48525
|
}
|
|
48455
48526
|
sendTopicUpdateToPeer(peer, update) {
|
|
48456
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
|
+
}
|
|
48457
48535
|
try {
|
|
48458
|
-
peer.dataChannel.sendMessage(
|
|
48459
|
-
type: "topic_update",
|
|
48460
|
-
update
|
|
48461
|
-
}));
|
|
48536
|
+
peer.dataChannel.sendMessage(json2);
|
|
48462
48537
|
return true;
|
|
48463
48538
|
} catch {
|
|
48464
48539
|
return false;
|
|
48465
48540
|
}
|
|
48466
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
|
+
}
|
|
48467
48565
|
/** Broadcast runtime session output to all connected peers */
|
|
48468
48566
|
broadcastSessionOutput(peers, sessionId, data) {
|
|
48469
48567
|
const msg = JSON.stringify({ type: "session_output", sessionId, data });
|
|
@@ -48894,12 +48992,12 @@ var init_peer_connection_manager = __esm({
|
|
|
48894
48992
|
});
|
|
48895
48993
|
|
|
48896
48994
|
// src/daemon-p2p/index.ts
|
|
48897
|
-
var
|
|
48995
|
+
var fs16, path24, import_node_module2, esmRequire, DaemonP2PSender;
|
|
48898
48996
|
var init_daemon_p2p = __esm({
|
|
48899
48997
|
"src/daemon-p2p/index.ts"() {
|
|
48900
48998
|
"use strict";
|
|
48901
|
-
|
|
48902
|
-
|
|
48999
|
+
fs16 = __toESM(require("fs"));
|
|
49000
|
+
path24 = __toESM(require("path"));
|
|
48903
49001
|
import_node_module2 = require("module");
|
|
48904
49002
|
init_src();
|
|
48905
49003
|
init_data_channel_router();
|
|
@@ -48978,17 +49076,17 @@ ${e?.stack || ""}`);
|
|
|
48978
49076
|
const prebuildKey = `${platform12}-${arch3}`;
|
|
48979
49077
|
try {
|
|
48980
49078
|
const candidates = [
|
|
48981
|
-
|
|
48982
|
-
|
|
48983
|
-
|
|
49079
|
+
path24.join(__dirname, "node_modules", "node-datachannel"),
|
|
49080
|
+
path24.join(__dirname, "..", "node_modules", "node-datachannel"),
|
|
49081
|
+
path24.join(__dirname, "..", "..", "node_modules", "node-datachannel")
|
|
48984
49082
|
];
|
|
48985
49083
|
for (const candidate of candidates) {
|
|
48986
|
-
const prebuildPath =
|
|
48987
|
-
if (
|
|
48988
|
-
const targetDir =
|
|
48989
|
-
const targetPath =
|
|
48990
|
-
|
|
48991
|
-
|
|
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);
|
|
48992
49090
|
try {
|
|
48993
49091
|
delete esmRequire.cache[esmRequire.resolve("node-datachannel")];
|
|
48994
49092
|
} catch {
|
|
@@ -49355,27 +49453,27 @@ var require_process = __commonJS({
|
|
|
49355
49453
|
var require_filesystem = __commonJS({
|
|
49356
49454
|
"../../node_modules/detect-libc/lib/filesystem.js"(exports2, module2) {
|
|
49357
49455
|
"use strict";
|
|
49358
|
-
var
|
|
49456
|
+
var fs20 = require("fs");
|
|
49359
49457
|
var LDD_PATH = "/usr/bin/ldd";
|
|
49360
49458
|
var SELF_PATH = "/proc/self/exe";
|
|
49361
49459
|
var MAX_LENGTH = 2048;
|
|
49362
|
-
var readFileSync19 = (
|
|
49363
|
-
const fd =
|
|
49460
|
+
var readFileSync19 = (path29) => {
|
|
49461
|
+
const fd = fs20.openSync(path29, "r");
|
|
49364
49462
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
49365
|
-
const bytesRead =
|
|
49366
|
-
|
|
49463
|
+
const bytesRead = fs20.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
49464
|
+
fs20.close(fd, () => {
|
|
49367
49465
|
});
|
|
49368
49466
|
return buffer.subarray(0, bytesRead);
|
|
49369
49467
|
};
|
|
49370
|
-
var readFile = (
|
|
49371
|
-
|
|
49468
|
+
var readFile = (path29) => new Promise((resolve16, reject) => {
|
|
49469
|
+
fs20.open(path29, "r", (err, fd) => {
|
|
49372
49470
|
if (err) {
|
|
49373
49471
|
reject(err);
|
|
49374
49472
|
} else {
|
|
49375
49473
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
49376
|
-
|
|
49474
|
+
fs20.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
|
|
49377
49475
|
resolve16(buffer.subarray(0, bytesRead));
|
|
49378
|
-
|
|
49476
|
+
fs20.close(fd, () => {
|
|
49379
49477
|
});
|
|
49380
49478
|
});
|
|
49381
49479
|
}
|
|
@@ -49487,11 +49585,11 @@ var require_detect_libc = __commonJS({
|
|
|
49487
49585
|
}
|
|
49488
49586
|
return null;
|
|
49489
49587
|
};
|
|
49490
|
-
var familyFromInterpreterPath = (
|
|
49491
|
-
if (
|
|
49492
|
-
if (
|
|
49588
|
+
var familyFromInterpreterPath = (path29) => {
|
|
49589
|
+
if (path29) {
|
|
49590
|
+
if (path29.includes("/ld-musl-")) {
|
|
49493
49591
|
return MUSL;
|
|
49494
|
-
} else if (
|
|
49592
|
+
} else if (path29.includes("/ld-linux-")) {
|
|
49495
49593
|
return GLIBC;
|
|
49496
49594
|
}
|
|
49497
49595
|
}
|
|
@@ -49538,8 +49636,8 @@ var require_detect_libc = __commonJS({
|
|
|
49538
49636
|
cachedFamilyInterpreter = null;
|
|
49539
49637
|
try {
|
|
49540
49638
|
const selfContent = await readFile(SELF_PATH);
|
|
49541
|
-
const
|
|
49542
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
49639
|
+
const path29 = interpreterPath(selfContent);
|
|
49640
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path29);
|
|
49543
49641
|
} catch (e) {
|
|
49544
49642
|
}
|
|
49545
49643
|
return cachedFamilyInterpreter;
|
|
@@ -49551,8 +49649,8 @@ var require_detect_libc = __commonJS({
|
|
|
49551
49649
|
cachedFamilyInterpreter = null;
|
|
49552
49650
|
try {
|
|
49553
49651
|
const selfContent = readFileSync19(SELF_PATH);
|
|
49554
|
-
const
|
|
49555
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
49652
|
+
const path29 = interpreterPath(selfContent);
|
|
49653
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path29);
|
|
49556
49654
|
} catch (e) {
|
|
49557
49655
|
}
|
|
49558
49656
|
return cachedFamilyInterpreter;
|
|
@@ -51271,18 +51369,18 @@ var require_sharp = __commonJS({
|
|
|
51271
51369
|
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
51272
51370
|
"@img/sharp-wasm32/sharp.node"
|
|
51273
51371
|
];
|
|
51274
|
-
var
|
|
51372
|
+
var path29;
|
|
51275
51373
|
var sharp;
|
|
51276
51374
|
var errors = [];
|
|
51277
|
-
for (
|
|
51375
|
+
for (path29 of paths) {
|
|
51278
51376
|
try {
|
|
51279
|
-
sharp = require(
|
|
51377
|
+
sharp = require(path29);
|
|
51280
51378
|
break;
|
|
51281
51379
|
} catch (err) {
|
|
51282
51380
|
errors.push(err);
|
|
51283
51381
|
}
|
|
51284
51382
|
}
|
|
51285
|
-
if (sharp &&
|
|
51383
|
+
if (sharp && path29.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
|
|
51286
51384
|
const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
|
|
51287
51385
|
err.code = "Unsupported CPU";
|
|
51288
51386
|
errors.push(err);
|
|
@@ -51291,7 +51389,7 @@ var require_sharp = __commonJS({
|
|
|
51291
51389
|
if (sharp) {
|
|
51292
51390
|
module2.exports = sharp;
|
|
51293
51391
|
} else {
|
|
51294
|
-
const [isLinux2, isMacOs, isWindows2] = ["linux", "darwin", "win32"].map((
|
|
51392
|
+
const [isLinux2, isMacOs, isWindows2] = ["linux", "darwin", "win32"].map((os29) => runtimePlatform.startsWith(os29));
|
|
51295
51393
|
const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
|
51296
51394
|
errors.forEach((err) => {
|
|
51297
51395
|
if (err.code !== "MODULE_NOT_FOUND") {
|
|
@@ -51308,15 +51406,15 @@ var require_sharp = __commonJS({
|
|
|
51308
51406
|
` Requires ${expected}`
|
|
51309
51407
|
);
|
|
51310
51408
|
} else if (prebuiltPlatforms.includes(runtimePlatform)) {
|
|
51311
|
-
const [
|
|
51312
|
-
const libc =
|
|
51409
|
+
const [os29, cpu] = runtimePlatform.split("-");
|
|
51410
|
+
const libc = os29.endsWith("musl") ? " --libc=musl" : "";
|
|
51313
51411
|
help.push(
|
|
51314
51412
|
"- Ensure optional dependencies can be installed:",
|
|
51315
51413
|
" npm install --include=optional sharp",
|
|
51316
51414
|
"- Ensure your package manager supports multi-platform installation:",
|
|
51317
51415
|
" See https://sharp.pixelplumbing.com/install#cross-platform",
|
|
51318
51416
|
"- Add platform-specific dependencies:",
|
|
51319
|
-
` npm install --os=${
|
|
51417
|
+
` npm install --os=${os29.replace("musl", "")}${libc} --cpu=${cpu} sharp`
|
|
51320
51418
|
);
|
|
51321
51419
|
} else {
|
|
51322
51420
|
help.push(
|
|
@@ -54191,15 +54289,15 @@ var require_color = __commonJS({
|
|
|
54191
54289
|
};
|
|
54192
54290
|
}
|
|
54193
54291
|
function wrapConversion(toModel, graph) {
|
|
54194
|
-
const
|
|
54292
|
+
const path29 = [graph[toModel].parent, toModel];
|
|
54195
54293
|
let fn = conversions_default[graph[toModel].parent][toModel];
|
|
54196
54294
|
let cur = graph[toModel].parent;
|
|
54197
54295
|
while (graph[cur].parent) {
|
|
54198
|
-
|
|
54296
|
+
path29.unshift(graph[cur].parent);
|
|
54199
54297
|
fn = link(conversions_default[graph[cur].parent][cur], fn);
|
|
54200
54298
|
cur = graph[cur].parent;
|
|
54201
54299
|
}
|
|
54202
|
-
fn.conversion =
|
|
54300
|
+
fn.conversion = path29;
|
|
54203
54301
|
return fn;
|
|
54204
54302
|
}
|
|
54205
54303
|
function route(fromModel) {
|
|
@@ -54816,7 +54914,7 @@ var require_channel = __commonJS({
|
|
|
54816
54914
|
var require_output = __commonJS({
|
|
54817
54915
|
"../../node_modules/sharp/lib/output.js"(exports2, module2) {
|
|
54818
54916
|
"use strict";
|
|
54819
|
-
var
|
|
54917
|
+
var path29 = require("path");
|
|
54820
54918
|
var is = require_is();
|
|
54821
54919
|
var sharp = require_sharp();
|
|
54822
54920
|
var formats = /* @__PURE__ */ new Map([
|
|
@@ -54847,9 +54945,9 @@ var require_output = __commonJS({
|
|
|
54847
54945
|
let err;
|
|
54848
54946
|
if (!is.string(fileOut)) {
|
|
54849
54947
|
err = new Error("Missing output file path");
|
|
54850
|
-
} 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)) {
|
|
54851
54949
|
err = new Error("Cannot use same file for input and output");
|
|
54852
|
-
} else if (jp2Regex.test(
|
|
54950
|
+
} else if (jp2Regex.test(path29.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
|
|
54853
54951
|
err = errJp2Save();
|
|
54854
54952
|
}
|
|
54855
54953
|
if (err) {
|
|
@@ -56123,21 +56221,21 @@ function quarantineLegacyStandaloneSessions(options) {
|
|
|
56123
56221
|
if (shouldSkipForExplicitOverride(env3)) {
|
|
56124
56222
|
return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
|
|
56125
56223
|
}
|
|
56126
|
-
const homeDir = options.homeDir ||
|
|
56224
|
+
const homeDir = options.homeDir || os24.homedir();
|
|
56127
56225
|
const now = options.now || (() => /* @__PURE__ */ new Date());
|
|
56128
56226
|
const isPidRunning = options.isPidRunning || defaultPidRunning;
|
|
56129
|
-
const runtimesDir =
|
|
56130
|
-
if (!
|
|
56227
|
+
const runtimesDir = path25.join(homeDir, ".adhdev", "session-host", options.appName, "runtimes");
|
|
56228
|
+
if (!fs17.existsSync(runtimesDir)) {
|
|
56131
56229
|
return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
|
|
56132
56230
|
}
|
|
56133
|
-
const candidates =
|
|
56231
|
+
const candidates = fs17.readdirSync(runtimesDir).filter((name) => name.endsWith(".json")).map((name) => path25.join(runtimesDir, name));
|
|
56134
56232
|
let movedCount = 0;
|
|
56135
56233
|
let skippedActiveCount = 0;
|
|
56136
56234
|
let backupDir = null;
|
|
56137
56235
|
for (const sourcePath of candidates) {
|
|
56138
56236
|
let parsed;
|
|
56139
56237
|
try {
|
|
56140
|
-
parsed = JSON.parse(
|
|
56238
|
+
parsed = JSON.parse(fs17.readFileSync(sourcePath, "utf8"));
|
|
56141
56239
|
} catch {
|
|
56142
56240
|
continue;
|
|
56143
56241
|
}
|
|
@@ -56148,26 +56246,26 @@ function quarantineLegacyStandaloneSessions(options) {
|
|
|
56148
56246
|
continue;
|
|
56149
56247
|
}
|
|
56150
56248
|
if (!backupDir) {
|
|
56151
|
-
backupDir =
|
|
56249
|
+
backupDir = path25.join(
|
|
56152
56250
|
homeDir,
|
|
56153
56251
|
".adhdev",
|
|
56154
56252
|
"session-host-backups",
|
|
56155
56253
|
`legacy-standalone-${options.appName}-${formatTimestamp(now())}`
|
|
56156
56254
|
);
|
|
56157
|
-
|
|
56255
|
+
fs17.mkdirSync(path25.join(backupDir, "runtimes"), { recursive: true });
|
|
56158
56256
|
}
|
|
56159
|
-
|
|
56257
|
+
fs17.renameSync(sourcePath, path25.join(backupDir, "runtimes", path25.basename(sourcePath)));
|
|
56160
56258
|
movedCount += 1;
|
|
56161
56259
|
}
|
|
56162
56260
|
return { movedCount, skippedActiveCount, backupDir };
|
|
56163
56261
|
}
|
|
56164
|
-
var
|
|
56262
|
+
var fs17, os24, path25, LEGACY_STANDALONE_MANAGER_TAG;
|
|
56165
56263
|
var init_session_host_hygiene = __esm({
|
|
56166
56264
|
"src/session-host-hygiene.ts"() {
|
|
56167
56265
|
"use strict";
|
|
56168
|
-
|
|
56169
|
-
|
|
56170
|
-
|
|
56266
|
+
fs17 = __toESM(require("fs"));
|
|
56267
|
+
os24 = __toESM(require("os"));
|
|
56268
|
+
path25 = __toESM(require("path"));
|
|
56171
56269
|
init_src();
|
|
56172
56270
|
LEGACY_STANDALONE_MANAGER_TAG = "adhdev-standalone";
|
|
56173
56271
|
}
|
|
@@ -56181,18 +56279,18 @@ function buildSessionHostEnv(baseEnv) {
|
|
|
56181
56279
|
}
|
|
56182
56280
|
function resolveSessionHostEntry() {
|
|
56183
56281
|
const packagedCandidates = [
|
|
56184
|
-
|
|
56185
|
-
|
|
56282
|
+
path26.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
56283
|
+
path26.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
56186
56284
|
];
|
|
56187
56285
|
for (const candidate of packagedCandidates) {
|
|
56188
|
-
if (
|
|
56286
|
+
if (fs18.existsSync(candidate)) {
|
|
56189
56287
|
return candidate;
|
|
56190
56288
|
}
|
|
56191
56289
|
}
|
|
56192
56290
|
return require.resolve("@adhdev/session-host-daemon");
|
|
56193
56291
|
}
|
|
56194
56292
|
function getSessionHostPidFile() {
|
|
56195
|
-
return
|
|
56293
|
+
return path26.join(os25.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
|
|
56196
56294
|
}
|
|
56197
56295
|
function killPid2(pid) {
|
|
56198
56296
|
try {
|
|
@@ -56258,8 +56356,8 @@ function stopManagedSessionHostProcess() {
|
|
|
56258
56356
|
let stopped = false;
|
|
56259
56357
|
const pidFile = getSessionHostPidFile();
|
|
56260
56358
|
try {
|
|
56261
|
-
if (
|
|
56262
|
-
const pid = Number.parseInt(
|
|
56359
|
+
if (fs18.existsSync(pidFile)) {
|
|
56360
|
+
const pid = Number.parseInt(fs18.readFileSync(pidFile, "utf8").trim(), 10);
|
|
56263
56361
|
if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid2(pid)) {
|
|
56264
56362
|
stopped = killPid2(pid) || stopped;
|
|
56265
56363
|
}
|
|
@@ -56267,7 +56365,7 @@ function stopManagedSessionHostProcess() {
|
|
|
56267
56365
|
} catch {
|
|
56268
56366
|
} finally {
|
|
56269
56367
|
try {
|
|
56270
|
-
|
|
56368
|
+
fs18.unlinkSync(pidFile);
|
|
56271
56369
|
} catch {
|
|
56272
56370
|
}
|
|
56273
56371
|
}
|
|
@@ -56295,9 +56393,9 @@ async function ensureSessionHostReady2() {
|
|
|
56295
56393
|
}
|
|
56296
56394
|
const spawnHost = () => {
|
|
56297
56395
|
const entry = resolveSessionHostEntry();
|
|
56298
|
-
const logDir =
|
|
56299
|
-
|
|
56300
|
-
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");
|
|
56301
56399
|
const child = (0, import_child_process12.spawn)(process.execPath, [entry], {
|
|
56302
56400
|
detached: true,
|
|
56303
56401
|
stdio: ["ignore", logFd, logFd],
|
|
@@ -56306,7 +56404,7 @@ async function ensureSessionHostReady2() {
|
|
|
56306
56404
|
});
|
|
56307
56405
|
child.unref();
|
|
56308
56406
|
try {
|
|
56309
|
-
|
|
56407
|
+
fs18.closeSync(logFd);
|
|
56310
56408
|
} catch {
|
|
56311
56409
|
}
|
|
56312
56410
|
};
|
|
@@ -56332,14 +56430,14 @@ async function ensureSessionHostReady2() {
|
|
|
56332
56430
|
async function listHostedCliRuntimes2(endpoint) {
|
|
56333
56431
|
return listHostedCliRuntimes(endpoint);
|
|
56334
56432
|
}
|
|
56335
|
-
var import_child_process12,
|
|
56433
|
+
var import_child_process12, fs18, os25, path26, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
|
|
56336
56434
|
var init_session_host = __esm({
|
|
56337
56435
|
"src/session-host.ts"() {
|
|
56338
56436
|
"use strict";
|
|
56339
56437
|
import_child_process12 = require("child_process");
|
|
56340
|
-
|
|
56341
|
-
|
|
56342
|
-
|
|
56438
|
+
fs18 = __toESM(require("fs"));
|
|
56439
|
+
os25 = __toESM(require("os"));
|
|
56440
|
+
path26 = __toESM(require("path"));
|
|
56343
56441
|
init_src();
|
|
56344
56442
|
init_dist();
|
|
56345
56443
|
init_session_host_hygiene();
|
|
@@ -57117,22 +57215,22 @@ function resolveDaemonPort(ref = {}) {
|
|
|
57117
57215
|
return Number.isFinite(ref.port) && Number(ref.port) > 0 ? Number(ref.port) : DEFAULT_DAEMON_PORT;
|
|
57118
57216
|
}
|
|
57119
57217
|
function getDaemonPidFile(ref = {}) {
|
|
57120
|
-
const dir =
|
|
57121
|
-
if (!
|
|
57218
|
+
const dir = path27.join(ref.homeDir || os27.homedir(), ".adhdev");
|
|
57219
|
+
if (!fs19.existsSync(dir)) fs19.mkdirSync(dir, { recursive: true });
|
|
57122
57220
|
const port = resolveDaemonPort(ref);
|
|
57123
|
-
return
|
|
57221
|
+
return path27.join(dir, port === DEFAULT_DAEMON_PORT ? "daemon.pid" : `daemon-${port}.pid`);
|
|
57124
57222
|
}
|
|
57125
57223
|
function writeDaemonPid(pid, ref = {}) {
|
|
57126
57224
|
const pidFile = getDaemonPidFile(ref);
|
|
57127
57225
|
try {
|
|
57128
|
-
|
|
57226
|
+
fs19.writeFileSync(pidFile, String(pid), { encoding: "utf-8", flag: "wx" });
|
|
57129
57227
|
} catch {
|
|
57130
|
-
|
|
57228
|
+
fs19.writeFileSync(pidFile, String(pid), "utf-8");
|
|
57131
57229
|
}
|
|
57132
57230
|
}
|
|
57133
57231
|
function removeDaemonPid(ref = {}) {
|
|
57134
57232
|
try {
|
|
57135
|
-
|
|
57233
|
+
fs19.unlinkSync(getDaemonPidFile(ref));
|
|
57136
57234
|
} catch (e) {
|
|
57137
57235
|
}
|
|
57138
57236
|
}
|
|
@@ -57159,8 +57257,8 @@ function isDaemonRunning(ref = {}) {
|
|
|
57159
57257
|
}
|
|
57160
57258
|
const pidFile = getDaemonPidFile(ref);
|
|
57161
57259
|
try {
|
|
57162
|
-
if (!
|
|
57163
|
-
const pid = parseInt(
|
|
57260
|
+
if (!fs19.existsSync(pidFile)) return false;
|
|
57261
|
+
const pid = parseInt(fs19.readFileSync(pidFile, "utf-8").trim());
|
|
57164
57262
|
process.kill(pid, 0);
|
|
57165
57263
|
if (!isAdhdevProcess(pid)) {
|
|
57166
57264
|
removeDaemonPid(ref);
|
|
@@ -57237,8 +57335,8 @@ function getDaemonHealthPid(ref = {}) {
|
|
|
57237
57335
|
function getDaemonPid(ref = {}) {
|
|
57238
57336
|
const pidFile = getDaemonPidFile(ref);
|
|
57239
57337
|
try {
|
|
57240
|
-
if (
|
|
57241
|
-
const pid = parseInt(
|
|
57338
|
+
if (fs19.existsSync(pidFile)) {
|
|
57339
|
+
const pid = parseInt(fs19.readFileSync(pidFile, "utf-8").trim(), 10);
|
|
57242
57340
|
if (Number.isFinite(pid)) return pid;
|
|
57243
57341
|
}
|
|
57244
57342
|
} catch {
|
|
@@ -57249,8 +57347,8 @@ function stopDaemon(ref = {}) {
|
|
|
57249
57347
|
const pidFile = getDaemonPidFile(ref);
|
|
57250
57348
|
let pid = null;
|
|
57251
57349
|
try {
|
|
57252
|
-
if (
|
|
57253
|
-
const pidFromFile = parseInt(
|
|
57350
|
+
if (fs19.existsSync(pidFile)) {
|
|
57351
|
+
const pidFromFile = parseInt(fs19.readFileSync(pidFile, "utf-8").trim(), 10);
|
|
57254
57352
|
if (Number.isFinite(pidFromFile)) pid = pidFromFile;
|
|
57255
57353
|
}
|
|
57256
57354
|
} catch {
|
|
@@ -57269,7 +57367,7 @@ function stopDaemon(ref = {}) {
|
|
|
57269
57367
|
return false;
|
|
57270
57368
|
}
|
|
57271
57369
|
}
|
|
57272
|
-
var
|
|
57370
|
+
var os27, fs19, path27, import_http, import_child_process13, import_ws3, pkgVersion, AdhdevDaemon;
|
|
57273
57371
|
var init_adhdev_daemon = __esm({
|
|
57274
57372
|
"src/adhdev-daemon.ts"() {
|
|
57275
57373
|
"use strict";
|
|
@@ -57281,9 +57379,9 @@ var init_adhdev_daemon = __esm({
|
|
|
57281
57379
|
init_startup_restore_policy();
|
|
57282
57380
|
init_dist();
|
|
57283
57381
|
init_session_host_controller();
|
|
57284
|
-
|
|
57285
|
-
|
|
57286
|
-
|
|
57382
|
+
os27 = __toESM(require("os"));
|
|
57383
|
+
fs19 = __toESM(require("fs"));
|
|
57384
|
+
path27 = __toESM(require("path"));
|
|
57287
57385
|
import_http = require("http");
|
|
57288
57386
|
import_child_process13 = require("child_process");
|
|
57289
57387
|
import_ws3 = require("ws");
|
|
@@ -57291,7 +57389,7 @@ var init_adhdev_daemon = __esm({
|
|
|
57291
57389
|
init_version();
|
|
57292
57390
|
init_src();
|
|
57293
57391
|
init_runtime_defaults();
|
|
57294
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.
|
|
57392
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.51" });
|
|
57295
57393
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
57296
57394
|
localHttpServer = null;
|
|
57297
57395
|
localWss = null;
|
|
@@ -57815,8 +57913,8 @@ ${err?.stack || ""}`);
|
|
|
57815
57913
|
cliInfo: {
|
|
57816
57914
|
type: "adhdev-daemon",
|
|
57817
57915
|
version: pkgVersion,
|
|
57818
|
-
platform:
|
|
57819
|
-
hostname:
|
|
57916
|
+
platform: os27.platform(),
|
|
57917
|
+
hostname: os27.hostname(),
|
|
57820
57918
|
machineId: config2.machineId,
|
|
57821
57919
|
instanceId
|
|
57822
57920
|
}
|
|
@@ -69754,15 +69852,15 @@ var require_route = __commonJS({
|
|
|
69754
69852
|
};
|
|
69755
69853
|
}
|
|
69756
69854
|
function wrapConversion(toModel, graph) {
|
|
69757
|
-
const
|
|
69855
|
+
const path29 = [graph[toModel].parent, toModel];
|
|
69758
69856
|
let fn = conversions[graph[toModel].parent][toModel];
|
|
69759
69857
|
let cur = graph[toModel].parent;
|
|
69760
69858
|
while (graph[cur].parent) {
|
|
69761
|
-
|
|
69859
|
+
path29.unshift(graph[cur].parent);
|
|
69762
69860
|
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
69763
69861
|
cur = graph[cur].parent;
|
|
69764
69862
|
}
|
|
69765
|
-
fn.conversion =
|
|
69863
|
+
fn.conversion = path29;
|
|
69766
69864
|
return fn;
|
|
69767
69865
|
}
|
|
69768
69866
|
module2.exports = function(fromModel) {
|
|
@@ -70159,7 +70257,7 @@ var require_has_flag = __commonJS({
|
|
|
70159
70257
|
var require_supports_color = __commonJS({
|
|
70160
70258
|
"../../node_modules/supports-color/index.js"(exports2, module2) {
|
|
70161
70259
|
"use strict";
|
|
70162
|
-
var
|
|
70260
|
+
var os29 = require("os");
|
|
70163
70261
|
var tty3 = require("tty");
|
|
70164
70262
|
var hasFlag3 = require_has_flag();
|
|
70165
70263
|
var { env: env3 } = process;
|
|
@@ -70207,7 +70305,7 @@ var require_supports_color = __commonJS({
|
|
|
70207
70305
|
return min;
|
|
70208
70306
|
}
|
|
70209
70307
|
if (process.platform === "win32") {
|
|
70210
|
-
const osRelease =
|
|
70308
|
+
const osRelease = os29.release().split(".");
|
|
70211
70309
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
70212
70310
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
70213
70311
|
}
|
|
@@ -73060,7 +73158,7 @@ var require_buffer_list = __commonJS({
|
|
|
73060
73158
|
}
|
|
73061
73159
|
}, {
|
|
73062
73160
|
key: "join",
|
|
73063
|
-
value: function
|
|
73161
|
+
value: function join31(s) {
|
|
73064
73162
|
if (this.length === 0) return "";
|
|
73065
73163
|
var p = this.head;
|
|
73066
73164
|
var ret = "" + p.data;
|
|
@@ -83183,10 +83281,10 @@ var require_lib2 = __commonJS({
|
|
|
83183
83281
|
exports2.analyse = analyse;
|
|
83184
83282
|
var detectFile = (filepath, opts = {}) => new Promise((resolve16, reject) => {
|
|
83185
83283
|
let fd;
|
|
83186
|
-
const
|
|
83284
|
+
const fs20 = (0, node_1.default)();
|
|
83187
83285
|
const handler = (err, buffer) => {
|
|
83188
83286
|
if (fd) {
|
|
83189
|
-
|
|
83287
|
+
fs20.closeSync(fd);
|
|
83190
83288
|
}
|
|
83191
83289
|
if (err) {
|
|
83192
83290
|
reject(err);
|
|
@@ -83198,9 +83296,9 @@ var require_lib2 = __commonJS({
|
|
|
83198
83296
|
};
|
|
83199
83297
|
const sampleSize = (opts === null || opts === void 0 ? void 0 : opts.sampleSize) || 0;
|
|
83200
83298
|
if (sampleSize > 0) {
|
|
83201
|
-
fd =
|
|
83299
|
+
fd = fs20.openSync(filepath, "r");
|
|
83202
83300
|
let sample = Buffer.allocUnsafe(sampleSize);
|
|
83203
|
-
|
|
83301
|
+
fs20.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
|
|
83204
83302
|
if (err) {
|
|
83205
83303
|
handler(err, null);
|
|
83206
83304
|
} else {
|
|
@@ -83212,22 +83310,22 @@ var require_lib2 = __commonJS({
|
|
|
83212
83310
|
});
|
|
83213
83311
|
return;
|
|
83214
83312
|
}
|
|
83215
|
-
|
|
83313
|
+
fs20.readFile(filepath, handler);
|
|
83216
83314
|
});
|
|
83217
83315
|
exports2.detectFile = detectFile;
|
|
83218
83316
|
var detectFileSync = (filepath, opts = {}) => {
|
|
83219
|
-
const
|
|
83317
|
+
const fs20 = (0, node_1.default)();
|
|
83220
83318
|
if (opts && opts.sampleSize) {
|
|
83221
|
-
const fd =
|
|
83319
|
+
const fd = fs20.openSync(filepath, "r");
|
|
83222
83320
|
let sample = Buffer.allocUnsafe(opts.sampleSize);
|
|
83223
|
-
const bytesRead =
|
|
83321
|
+
const bytesRead = fs20.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
|
|
83224
83322
|
if (bytesRead < opts.sampleSize) {
|
|
83225
83323
|
sample = sample.subarray(0, bytesRead);
|
|
83226
83324
|
}
|
|
83227
|
-
|
|
83325
|
+
fs20.closeSync(fd);
|
|
83228
83326
|
return (0, exports2.detect)(sample);
|
|
83229
83327
|
}
|
|
83230
|
-
return (0, exports2.detect)(
|
|
83328
|
+
return (0, exports2.detect)(fs20.readFileSync(filepath));
|
|
83231
83329
|
};
|
|
83232
83330
|
exports2.detectFileSync = detectFileSync;
|
|
83233
83331
|
exports2.default = {
|
|
@@ -87119,7 +87217,7 @@ function splitStringBySpace(str) {
|
|
|
87119
87217
|
}
|
|
87120
87218
|
return pieces;
|
|
87121
87219
|
}
|
|
87122
|
-
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;
|
|
87123
87221
|
var init_esm2 = __esm({
|
|
87124
87222
|
"../../node_modules/@inquirer/external-editor/dist/esm/index.js"() {
|
|
87125
87223
|
"use strict";
|
|
@@ -87128,7 +87226,7 @@ var init_esm2 = __esm({
|
|
|
87128
87226
|
import_fs7 = require("fs");
|
|
87129
87227
|
import_node_path2 = __toESM(require("path"), 1);
|
|
87130
87228
|
import_node_os4 = __toESM(require("os"), 1);
|
|
87131
|
-
|
|
87229
|
+
import_node_crypto2 = require("crypto");
|
|
87132
87230
|
import_iconv_lite = __toESM(require_lib3(), 1);
|
|
87133
87231
|
init_CreateFileError();
|
|
87134
87232
|
init_LaunchEditorError();
|
|
@@ -87187,7 +87285,7 @@ var init_esm2 = __esm({
|
|
|
87187
87285
|
createTemporaryFile() {
|
|
87188
87286
|
try {
|
|
87189
87287
|
const baseDir = this.fileOptions.dir ?? import_node_os4.default.tmpdir();
|
|
87190
|
-
const id = (0,
|
|
87288
|
+
const id = (0, import_node_crypto2.randomUUID)();
|
|
87191
87289
|
const prefix = sanitizeAffix(this.fileOptions.prefix);
|
|
87192
87290
|
const postfix = sanitizeAffix(this.fileOptions.postfix);
|
|
87193
87291
|
const filename = `${prefix}${id}${postfix}`;
|
|
@@ -87632,9 +87730,9 @@ var init_prompt = __esm({
|
|
|
87632
87730
|
init_utils();
|
|
87633
87731
|
init_baseUI();
|
|
87634
87732
|
_ = {
|
|
87635
|
-
set: (obj,
|
|
87733
|
+
set: (obj, path29 = "", value) => {
|
|
87636
87734
|
let pointer = obj;
|
|
87637
|
-
|
|
87735
|
+
path29.split(".").forEach((key, index, arr) => {
|
|
87638
87736
|
if (key === "__proto__" || key === "constructor") return;
|
|
87639
87737
|
if (index === arr.length - 1) {
|
|
87640
87738
|
pointer[key] = value;
|
|
@@ -87644,8 +87742,8 @@ var init_prompt = __esm({
|
|
|
87644
87742
|
pointer = pointer[key];
|
|
87645
87743
|
});
|
|
87646
87744
|
},
|
|
87647
|
-
get: (obj,
|
|
87648
|
-
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(
|
|
87649
87747
|
// @ts-expect-error implicit any on res[key]
|
|
87650
87748
|
(res, key) => res !== null && res !== void 0 ? res[key] : res,
|
|
87651
87749
|
obj
|
|
@@ -89110,15 +89208,15 @@ async function loginFlow() {
|
|
|
89110
89208
|
let verificationUrl;
|
|
89111
89209
|
try {
|
|
89112
89210
|
const config2 = loadConfig();
|
|
89113
|
-
const
|
|
89211
|
+
const os29 = await import("os");
|
|
89114
89212
|
const res = await fetch(`${SERVER_URL}/auth/cli/init`, {
|
|
89115
89213
|
method: "POST",
|
|
89116
89214
|
headers: { "Content-Type": "application/json" },
|
|
89117
89215
|
body: JSON.stringify({
|
|
89118
89216
|
clientMachineId: config2.machineId,
|
|
89119
|
-
hostname:
|
|
89120
|
-
platform:
|
|
89121
|
-
arch:
|
|
89217
|
+
hostname: os29.hostname(),
|
|
89218
|
+
platform: os29.platform(),
|
|
89219
|
+
arch: os29.arch()
|
|
89122
89220
|
})
|
|
89123
89221
|
});
|
|
89124
89222
|
if (!res.ok) {
|
|
@@ -89223,8 +89321,8 @@ async function startDaemonFlow() {
|
|
|
89223
89321
|
const { execSync: execSync7 } = await import("child_process");
|
|
89224
89322
|
const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
89225
89323
|
const logPath = getCurrentDaemonLogPath2();
|
|
89226
|
-
const
|
|
89227
|
-
const platform12 =
|
|
89324
|
+
const os29 = await import("os");
|
|
89325
|
+
const platform12 = os29.platform();
|
|
89228
89326
|
try {
|
|
89229
89327
|
if (platform12 === "win32") {
|
|
89230
89328
|
execSync7("start /B adhdev daemon >NUL 2>&1", {
|