adhdev 0.7.38 → 0.7.39
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 +702 -884
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +658 -838
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -31,6 +31,164 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
31
|
));
|
|
32
32
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
33
|
|
|
34
|
+
// ../../oss/packages/daemon-core/src/config/config.ts
|
|
35
|
+
var config_exports = {};
|
|
36
|
+
__export(config_exports, {
|
|
37
|
+
generateConnectionToken: () => generateConnectionToken,
|
|
38
|
+
generateMachineId: () => generateMachineId,
|
|
39
|
+
getConfigDir: () => getConfigDir,
|
|
40
|
+
isSetupComplete: () => isSetupComplete,
|
|
41
|
+
isStableMachineId: () => isStableMachineId,
|
|
42
|
+
loadConfig: () => loadConfig,
|
|
43
|
+
markSetupComplete: () => markSetupComplete,
|
|
44
|
+
resetConfig: () => resetConfig,
|
|
45
|
+
saveConfig: () => saveConfig,
|
|
46
|
+
updateConfig: () => updateConfig
|
|
47
|
+
});
|
|
48
|
+
function generateMachineId() {
|
|
49
|
+
return `${MACHINE_ID_PREFIX}${(0, import_crypto.randomUUID)().replace(/-/g, "")}`;
|
|
50
|
+
}
|
|
51
|
+
function isStableMachineId(machineId) {
|
|
52
|
+
return typeof machineId === "string" && machineId.startsWith(MACHINE_ID_PREFIX);
|
|
53
|
+
}
|
|
54
|
+
function ensureMachineId(config2) {
|
|
55
|
+
if (isStableMachineId(config2.machineId)) {
|
|
56
|
+
return { config: config2, changed: false };
|
|
57
|
+
}
|
|
58
|
+
const legacyRegisteredMachineId = !config2.registeredMachineId && config2.machineSecret && config2.machineId ? config2.machineId : config2.registeredMachineId;
|
|
59
|
+
return {
|
|
60
|
+
config: {
|
|
61
|
+
...config2,
|
|
62
|
+
machineId: generateMachineId(),
|
|
63
|
+
registeredMachineId: legacyRegisteredMachineId
|
|
64
|
+
},
|
|
65
|
+
changed: true
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function getConfigDir() {
|
|
69
|
+
const dir = (0, import_path.join)((0, import_os.homedir)(), ".adhdev");
|
|
70
|
+
if (!(0, import_fs.existsSync)(dir)) {
|
|
71
|
+
(0, import_fs.mkdirSync)(dir, { recursive: true });
|
|
72
|
+
}
|
|
73
|
+
return dir;
|
|
74
|
+
}
|
|
75
|
+
function getConfigPath() {
|
|
76
|
+
return (0, import_path.join)(getConfigDir(), "config.json");
|
|
77
|
+
}
|
|
78
|
+
function loadConfig() {
|
|
79
|
+
const configPath = getConfigPath();
|
|
80
|
+
if (!(0, import_fs.existsSync)(configPath)) {
|
|
81
|
+
const initialized = ensureMachineId({ ...DEFAULT_CONFIG });
|
|
82
|
+
try {
|
|
83
|
+
saveConfig(initialized.config);
|
|
84
|
+
} catch {
|
|
85
|
+
}
|
|
86
|
+
return initialized.config;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const raw = (0, import_fs.readFileSync)(configPath, "utf-8");
|
|
90
|
+
const parsed = JSON.parse(raw);
|
|
91
|
+
const merged = { ...DEFAULT_CONFIG, ...parsed };
|
|
92
|
+
if (merged.defaultWorkspaceId == null && merged.activeWorkspaceId != null) {
|
|
93
|
+
merged.defaultWorkspaceId = merged.activeWorkspaceId;
|
|
94
|
+
}
|
|
95
|
+
delete merged.activeWorkspaceId;
|
|
96
|
+
const ensured = ensureMachineId(merged);
|
|
97
|
+
const normalized = ensured.config;
|
|
98
|
+
if (ensured.changed) {
|
|
99
|
+
try {
|
|
100
|
+
saveConfig(normalized);
|
|
101
|
+
} catch {
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return normalized;
|
|
105
|
+
} catch {
|
|
106
|
+
const initialized = ensureMachineId({ ...DEFAULT_CONFIG });
|
|
107
|
+
return initialized.config;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function saveConfig(config2) {
|
|
111
|
+
const configPath = getConfigPath();
|
|
112
|
+
const dir = getConfigDir();
|
|
113
|
+
if (!(0, import_fs.existsSync)(dir)) {
|
|
114
|
+
(0, import_fs.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
115
|
+
}
|
|
116
|
+
(0, import_fs.writeFileSync)(configPath, JSON.stringify(config2, null, 2), { encoding: "utf-8", mode: 384 });
|
|
117
|
+
try {
|
|
118
|
+
(0, import_fs.chmodSync)(configPath, 384);
|
|
119
|
+
} catch {
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function updateConfig(updates) {
|
|
123
|
+
const config2 = loadConfig();
|
|
124
|
+
const updated = { ...config2, ...updates };
|
|
125
|
+
saveConfig(updated);
|
|
126
|
+
return updated;
|
|
127
|
+
}
|
|
128
|
+
function markSetupComplete(ideId, extensions) {
|
|
129
|
+
const ideIds = Array.isArray(ideId) ? ideId : [ideId];
|
|
130
|
+
return updateConfig({
|
|
131
|
+
selectedIde: ideIds[0],
|
|
132
|
+
configuredIdes: ideIds,
|
|
133
|
+
installedExtensions: extensions,
|
|
134
|
+
setupCompleted: true,
|
|
135
|
+
setupDate: (/* @__PURE__ */ new Date()).toISOString()
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function isSetupComplete() {
|
|
139
|
+
const config2 = loadConfig();
|
|
140
|
+
return config2.setupCompleted;
|
|
141
|
+
}
|
|
142
|
+
function resetConfig() {
|
|
143
|
+
saveConfig({ ...DEFAULT_CONFIG });
|
|
144
|
+
}
|
|
145
|
+
function generateConnectionToken() {
|
|
146
|
+
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
147
|
+
let token = "db_";
|
|
148
|
+
for (let i = 0; i < 32; i++) {
|
|
149
|
+
token += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
150
|
+
}
|
|
151
|
+
return token;
|
|
152
|
+
}
|
|
153
|
+
var import_os, import_path, import_fs, import_crypto, DEFAULT_CONFIG, MACHINE_ID_PREFIX;
|
|
154
|
+
var init_config = __esm({
|
|
155
|
+
"../../oss/packages/daemon-core/src/config/config.ts"() {
|
|
156
|
+
"use strict";
|
|
157
|
+
import_os = require("os");
|
|
158
|
+
import_path = require("path");
|
|
159
|
+
import_fs = require("fs");
|
|
160
|
+
import_crypto = require("crypto");
|
|
161
|
+
DEFAULT_CONFIG = {
|
|
162
|
+
serverUrl: "https://api.adhf.dev",
|
|
163
|
+
apiToken: null,
|
|
164
|
+
connectionToken: null,
|
|
165
|
+
selectedIde: null,
|
|
166
|
+
configuredIdes: [],
|
|
167
|
+
installedExtensions: [],
|
|
168
|
+
autoConnect: true,
|
|
169
|
+
notifications: true,
|
|
170
|
+
userEmail: null,
|
|
171
|
+
userName: null,
|
|
172
|
+
setupCompleted: false,
|
|
173
|
+
setupDate: null,
|
|
174
|
+
configuredCLIs: [],
|
|
175
|
+
enabledIdes: [],
|
|
176
|
+
workspaces: [],
|
|
177
|
+
defaultWorkspaceId: null,
|
|
178
|
+
recentActivity: [],
|
|
179
|
+
recentSessionReads: {},
|
|
180
|
+
machineNickname: null,
|
|
181
|
+
machineId: void 0,
|
|
182
|
+
machineSecret: null,
|
|
183
|
+
registeredMachineId: void 0,
|
|
184
|
+
providerSettings: {},
|
|
185
|
+
ideSettings: {},
|
|
186
|
+
disableUpstream: false
|
|
187
|
+
};
|
|
188
|
+
MACHINE_ID_PREFIX = "mach_";
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
34
192
|
// ../../oss/packages/daemon-core/src/config/workspaces.ts
|
|
35
193
|
function expandPath(p) {
|
|
36
194
|
const t = (p || "").trim();
|
|
@@ -53,25 +211,6 @@ function defaultWorkspaceLabel(absPath) {
|
|
|
53
211
|
const base = path.basename(absPath) || absPath;
|
|
54
212
|
return base;
|
|
55
213
|
}
|
|
56
|
-
function migrateWorkspacesFromRecent(config2) {
|
|
57
|
-
if (!config2.workspaces) config2.workspaces = [];
|
|
58
|
-
if (config2.workspaces.length > 0) return config2;
|
|
59
|
-
const recent = config2.recentCliWorkspaces || [];
|
|
60
|
-
const now = Date.now();
|
|
61
|
-
for (const raw of recent) {
|
|
62
|
-
const abs = expandPath(raw);
|
|
63
|
-
if (!abs || validateWorkspacePath(abs).ok !== true) continue;
|
|
64
|
-
if (config2.workspaces.some((w) => path.resolve(w.path) === abs)) continue;
|
|
65
|
-
config2.workspaces.push({
|
|
66
|
-
id: (0, import_crypto.randomUUID)(),
|
|
67
|
-
path: abs,
|
|
68
|
-
label: defaultWorkspaceLabel(abs),
|
|
69
|
-
addedAt: now
|
|
70
|
-
});
|
|
71
|
-
if (config2.workspaces.length >= MAX_WORKSPACES) break;
|
|
72
|
-
}
|
|
73
|
-
return config2;
|
|
74
|
-
}
|
|
75
214
|
function getDefaultWorkspacePath(config2) {
|
|
76
215
|
const id = config2.defaultWorkspaceId;
|
|
77
216
|
if (!id) return null;
|
|
@@ -185,7 +324,7 @@ function addWorkspaceEntry(config2, rawPath, label, options) {
|
|
|
185
324
|
return { error: `Maximum ${MAX_WORKSPACES} workspaces` };
|
|
186
325
|
}
|
|
187
326
|
const entry = {
|
|
188
|
-
id: (0,
|
|
327
|
+
id: (0, import_crypto2.randomUUID)(),
|
|
189
328
|
path: abs,
|
|
190
329
|
label: (label || "").trim() || defaultWorkspaceLabel(abs),
|
|
191
330
|
addedAt: Date.now()
|
|
@@ -210,258 +349,15 @@ function setDefaultWorkspaceId(config2, id) {
|
|
|
210
349
|
if (validateWorkspacePath(abs).ok !== true) return { error: "Workspace path is no longer valid" };
|
|
211
350
|
return { config: { ...config2, defaultWorkspaceId: id } };
|
|
212
351
|
}
|
|
213
|
-
var fs, os, path,
|
|
352
|
+
var fs, os, path, import_crypto2, MAX_WORKSPACES;
|
|
214
353
|
var init_workspaces = __esm({
|
|
215
354
|
"../../oss/packages/daemon-core/src/config/workspaces.ts"() {
|
|
216
355
|
"use strict";
|
|
217
356
|
fs = __toESM(require("fs"));
|
|
218
357
|
os = __toESM(require("os"));
|
|
219
358
|
path = __toESM(require("path"));
|
|
220
|
-
import_crypto = require("crypto");
|
|
221
|
-
MAX_WORKSPACES = 50;
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
// ../../oss/packages/daemon-core/src/config/config.ts
|
|
226
|
-
var config_exports = {};
|
|
227
|
-
__export(config_exports, {
|
|
228
|
-
addCliHistory: () => addCliHistory,
|
|
229
|
-
generateConnectionToken: () => generateConnectionToken,
|
|
230
|
-
generateMachineId: () => generateMachineId,
|
|
231
|
-
getConfigDir: () => getConfigDir,
|
|
232
|
-
isSetupComplete: () => isSetupComplete,
|
|
233
|
-
isStableMachineId: () => isStableMachineId,
|
|
234
|
-
loadConfig: () => loadConfig,
|
|
235
|
-
markSetupComplete: () => markSetupComplete,
|
|
236
|
-
resetConfig: () => resetConfig,
|
|
237
|
-
saveConfig: () => saveConfig,
|
|
238
|
-
updateConfig: () => updateConfig
|
|
239
|
-
});
|
|
240
|
-
function generateMachineId() {
|
|
241
|
-
return `${MACHINE_ID_PREFIX}${(0, import_crypto2.randomUUID)().replace(/-/g, "")}`;
|
|
242
|
-
}
|
|
243
|
-
function isStableMachineId(machineId) {
|
|
244
|
-
return typeof machineId === "string" && machineId.startsWith(MACHINE_ID_PREFIX);
|
|
245
|
-
}
|
|
246
|
-
function ensureMachineId(config2) {
|
|
247
|
-
if (isStableMachineId(config2.machineId)) {
|
|
248
|
-
return { config: config2, changed: false };
|
|
249
|
-
}
|
|
250
|
-
const legacyRegisteredMachineId = !config2.registeredMachineId && config2.machineSecret && config2.machineId ? config2.machineId : config2.registeredMachineId;
|
|
251
|
-
return {
|
|
252
|
-
config: {
|
|
253
|
-
...config2,
|
|
254
|
-
machineId: generateMachineId(),
|
|
255
|
-
registeredMachineId: legacyRegisteredMachineId
|
|
256
|
-
},
|
|
257
|
-
changed: true
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
function getConfigDir() {
|
|
261
|
-
const dir = (0, import_path.join)((0, import_os.homedir)(), ".adhdev");
|
|
262
|
-
if (!(0, import_fs.existsSync)(dir)) {
|
|
263
|
-
(0, import_fs.mkdirSync)(dir, { recursive: true });
|
|
264
|
-
}
|
|
265
|
-
return dir;
|
|
266
|
-
}
|
|
267
|
-
function getConfigPath() {
|
|
268
|
-
return (0, import_path.join)(getConfigDir(), "config.json");
|
|
269
|
-
}
|
|
270
|
-
function loadConfig() {
|
|
271
|
-
const configPath = getConfigPath();
|
|
272
|
-
if (!(0, import_fs.existsSync)(configPath)) {
|
|
273
|
-
const initialized = ensureMachineId({ ...DEFAULT_CONFIG });
|
|
274
|
-
try {
|
|
275
|
-
saveConfig(initialized.config);
|
|
276
|
-
} catch {
|
|
277
|
-
}
|
|
278
|
-
return initialized.config;
|
|
279
|
-
}
|
|
280
|
-
try {
|
|
281
|
-
const raw = (0, import_fs.readFileSync)(configPath, "utf-8");
|
|
282
|
-
const parsed = JSON.parse(raw);
|
|
283
|
-
const merged = { ...DEFAULT_CONFIG, ...parsed };
|
|
284
|
-
if (merged.defaultWorkspaceId == null && merged.activeWorkspaceId != null) {
|
|
285
|
-
merged.defaultWorkspaceId = merged.activeWorkspaceId;
|
|
286
|
-
}
|
|
287
|
-
delete merged.activeWorkspaceId;
|
|
288
|
-
const hadStoredWorkspaces = Array.isArray(parsed.workspaces) && parsed.workspaces.length > 0;
|
|
289
|
-
const ensured = ensureMachineId(merged);
|
|
290
|
-
const normalized = ensured.config;
|
|
291
|
-
migrateWorkspacesFromRecent(normalized);
|
|
292
|
-
let configChanged = ensured.changed;
|
|
293
|
-
if (!hadStoredWorkspaces && (normalized.workspaces?.length || 0) > 0) {
|
|
294
|
-
configChanged = true;
|
|
295
|
-
}
|
|
296
|
-
if (configChanged) {
|
|
297
|
-
try {
|
|
298
|
-
saveConfig(normalized);
|
|
299
|
-
} catch {
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
return normalized;
|
|
303
|
-
} catch {
|
|
304
|
-
const initialized = ensureMachineId({ ...DEFAULT_CONFIG });
|
|
305
|
-
return initialized.config;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
function saveConfig(config2) {
|
|
309
|
-
const configPath = getConfigPath();
|
|
310
|
-
const dir = getConfigDir();
|
|
311
|
-
if (!(0, import_fs.existsSync)(dir)) {
|
|
312
|
-
(0, import_fs.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
313
|
-
}
|
|
314
|
-
(0, import_fs.writeFileSync)(configPath, JSON.stringify(config2, null, 2), { encoding: "utf-8", mode: 384 });
|
|
315
|
-
try {
|
|
316
|
-
(0, import_fs.chmodSync)(configPath, 384);
|
|
317
|
-
} catch {
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
function updateConfig(updates) {
|
|
321
|
-
const config2 = loadConfig();
|
|
322
|
-
const updated = { ...config2, ...updates };
|
|
323
|
-
saveConfig(updated);
|
|
324
|
-
return updated;
|
|
325
|
-
}
|
|
326
|
-
function markSetupComplete(ideId, extensions) {
|
|
327
|
-
const ideIds = Array.isArray(ideId) ? ideId : [ideId];
|
|
328
|
-
return updateConfig({
|
|
329
|
-
selectedIde: ideIds[0],
|
|
330
|
-
configuredIdes: ideIds,
|
|
331
|
-
installedExtensions: extensions,
|
|
332
|
-
setupCompleted: true,
|
|
333
|
-
setupDate: (/* @__PURE__ */ new Date()).toISOString()
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
function isSetupComplete() {
|
|
337
|
-
const config2 = loadConfig();
|
|
338
|
-
return config2.setupCompleted;
|
|
339
|
-
}
|
|
340
|
-
function resetConfig() {
|
|
341
|
-
saveConfig({ ...DEFAULT_CONFIG });
|
|
342
|
-
}
|
|
343
|
-
function generateConnectionToken() {
|
|
344
|
-
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
345
|
-
let token = "db_";
|
|
346
|
-
for (let i = 0; i < 32; i++) {
|
|
347
|
-
token += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
348
|
-
}
|
|
349
|
-
return token;
|
|
350
|
-
}
|
|
351
|
-
function addCliHistory(entry) {
|
|
352
|
-
const config2 = loadConfig();
|
|
353
|
-
const history = config2.cliHistory || [];
|
|
354
|
-
const argsKey = (entry.cliArgs || []).join(" ");
|
|
355
|
-
const category = entry.category || "cli";
|
|
356
|
-
const workspaceKey = entry.workspace || "";
|
|
357
|
-
const modelKey = entry.model || "";
|
|
358
|
-
const filtered = history.filter((h) => {
|
|
359
|
-
const hArgsKey = (h.cliArgs || []).join(" ");
|
|
360
|
-
return !((h.category || "cli") === category && h.cliType === entry.cliType && h.dir === entry.dir && hArgsKey === argsKey && (h.workspace || "") === workspaceKey && (h.model || "") === modelKey);
|
|
361
|
-
});
|
|
362
|
-
filtered.unshift({
|
|
363
|
-
...entry,
|
|
364
|
-
category,
|
|
365
|
-
timestamp: Date.now(),
|
|
366
|
-
label: entry.label || (() => {
|
|
367
|
-
const base = `${entry.cliType} \xB7 ${entry.dir.split("/").filter(Boolean).pop() || "root"}`;
|
|
368
|
-
const suffix = [];
|
|
369
|
-
if (entry.workspace && entry.workspace !== entry.dir) suffix.push(entry.workspace.split("/").filter(Boolean).pop() || entry.workspace);
|
|
370
|
-
if (entry.model) suffix.push(`model=${entry.model}`);
|
|
371
|
-
if (argsKey) suffix.push(argsKey);
|
|
372
|
-
if (entry.newWindow) suffix.push("new window");
|
|
373
|
-
return suffix.length > 0 ? `${base} (${suffix.join(" \xB7 ")})` : base;
|
|
374
|
-
})()
|
|
375
|
-
});
|
|
376
|
-
config2.cliHistory = filtered.slice(0, 20);
|
|
377
|
-
saveConfig(config2);
|
|
378
|
-
}
|
|
379
|
-
var import_os, import_path, import_fs, import_crypto2, DEFAULT_CONFIG, MACHINE_ID_PREFIX;
|
|
380
|
-
var init_config = __esm({
|
|
381
|
-
"../../oss/packages/daemon-core/src/config/config.ts"() {
|
|
382
|
-
"use strict";
|
|
383
|
-
import_os = require("os");
|
|
384
|
-
import_path = require("path");
|
|
385
|
-
import_fs = require("fs");
|
|
386
359
|
import_crypto2 = require("crypto");
|
|
387
|
-
|
|
388
|
-
DEFAULT_CONFIG = {
|
|
389
|
-
serverUrl: "https://api.adhf.dev",
|
|
390
|
-
apiToken: null,
|
|
391
|
-
connectionToken: null,
|
|
392
|
-
selectedIde: null,
|
|
393
|
-
configuredIdes: [],
|
|
394
|
-
installedExtensions: [],
|
|
395
|
-
autoConnect: true,
|
|
396
|
-
notifications: true,
|
|
397
|
-
userEmail: null,
|
|
398
|
-
userName: null,
|
|
399
|
-
setupCompleted: false,
|
|
400
|
-
setupDate: null,
|
|
401
|
-
configuredCLIs: [],
|
|
402
|
-
enabledIdes: [],
|
|
403
|
-
recentCliWorkspaces: [],
|
|
404
|
-
workspaces: [],
|
|
405
|
-
defaultWorkspaceId: null,
|
|
406
|
-
recentWorkspaceActivity: [],
|
|
407
|
-
recentActivity: [],
|
|
408
|
-
recentSessionReads: {},
|
|
409
|
-
machineNickname: null,
|
|
410
|
-
machineId: void 0,
|
|
411
|
-
machineSecret: null,
|
|
412
|
-
registeredMachineId: void 0,
|
|
413
|
-
cliHistory: [],
|
|
414
|
-
providerSettings: {},
|
|
415
|
-
ideSettings: {},
|
|
416
|
-
disableUpstream: false
|
|
417
|
-
};
|
|
418
|
-
MACHINE_ID_PREFIX = "mach_";
|
|
419
|
-
}
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
// ../../oss/packages/daemon-core/src/config/workspace-activity.ts
|
|
423
|
-
function normWorkspacePath(p) {
|
|
424
|
-
try {
|
|
425
|
-
return path2.resolve(expandPath(p));
|
|
426
|
-
} catch {
|
|
427
|
-
return path2.resolve(p);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
function appendWorkspaceActivity(config2, rawPath, meta3) {
|
|
431
|
-
const abs = normWorkspacePath(rawPath);
|
|
432
|
-
if (!abs) return config2;
|
|
433
|
-
const prev = config2.recentWorkspaceActivity || [];
|
|
434
|
-
const filtered = prev.filter((e) => normWorkspacePath(e.path) !== abs);
|
|
435
|
-
const entry = {
|
|
436
|
-
path: abs,
|
|
437
|
-
lastUsedAt: Date.now(),
|
|
438
|
-
kind: meta3?.kind,
|
|
439
|
-
agentType: meta3?.agentType
|
|
440
|
-
};
|
|
441
|
-
const recentWorkspaceActivity = [entry, ...filtered].slice(0, MAX_ACTIVITY);
|
|
442
|
-
return { ...config2, recentWorkspaceActivity };
|
|
443
|
-
}
|
|
444
|
-
function getWorkspaceActivity(config2, limit = 20) {
|
|
445
|
-
const list = [...config2.recentWorkspaceActivity || []];
|
|
446
|
-
list.sort((a, b2) => b2.lastUsedAt - a.lastUsedAt);
|
|
447
|
-
return list.slice(0, limit);
|
|
448
|
-
}
|
|
449
|
-
function removeActivityForPath(config2, rawPath) {
|
|
450
|
-
const n = normWorkspacePath(rawPath);
|
|
451
|
-
return {
|
|
452
|
-
...config2,
|
|
453
|
-
recentWorkspaceActivity: (config2.recentWorkspaceActivity || []).filter(
|
|
454
|
-
(e) => normWorkspacePath(e.path) !== n
|
|
455
|
-
)
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
var path2, MAX_ACTIVITY;
|
|
459
|
-
var init_workspace_activity = __esm({
|
|
460
|
-
"../../oss/packages/daemon-core/src/config/workspace-activity.ts"() {
|
|
461
|
-
"use strict";
|
|
462
|
-
path2 = __toESM(require("path"));
|
|
463
|
-
init_workspaces();
|
|
464
|
-
MAX_ACTIVITY = 30;
|
|
360
|
+
MAX_WORKSPACES = 50;
|
|
465
361
|
}
|
|
466
362
|
});
|
|
467
363
|
|
|
@@ -469,9 +365,9 @@ var init_workspace_activity = __esm({
|
|
|
469
365
|
function normalizeWorkspace(workspace) {
|
|
470
366
|
if (!workspace) return "";
|
|
471
367
|
try {
|
|
472
|
-
return
|
|
368
|
+
return path2.resolve(expandPath(workspace));
|
|
473
369
|
} catch {
|
|
474
|
-
return
|
|
370
|
+
return path2.resolve(workspace);
|
|
475
371
|
}
|
|
476
372
|
}
|
|
477
373
|
function buildRecentActivityKey(entry) {
|
|
@@ -487,7 +383,7 @@ function appendRecentActivity(config2, entry) {
|
|
|
487
383
|
const filtered = (config2.recentActivity || []).filter((item) => item.id !== nextEntry.id);
|
|
488
384
|
return {
|
|
489
385
|
...config2,
|
|
490
|
-
recentActivity: [nextEntry, ...filtered].slice(0,
|
|
386
|
+
recentActivity: [nextEntry, ...filtered].slice(0, MAX_ACTIVITY)
|
|
491
387
|
};
|
|
492
388
|
}
|
|
493
389
|
function getRecentActivity(config2, limit = 20) {
|
|
@@ -507,13 +403,13 @@ function markRecentSessionSeen(config2, recentKey, seenAt = Date.now()) {
|
|
|
507
403
|
}
|
|
508
404
|
};
|
|
509
405
|
}
|
|
510
|
-
var
|
|
406
|
+
var path2, MAX_ACTIVITY;
|
|
511
407
|
var init_recent_activity = __esm({
|
|
512
408
|
"../../oss/packages/daemon-core/src/config/recent-activity.ts"() {
|
|
513
409
|
"use strict";
|
|
514
|
-
|
|
410
|
+
path2 = __toESM(require("path"));
|
|
515
411
|
init_workspaces();
|
|
516
|
-
|
|
412
|
+
MAX_ACTIVITY = 30;
|
|
517
413
|
}
|
|
518
414
|
});
|
|
519
415
|
|
|
@@ -628,15 +524,15 @@ function parseVersion(raw) {
|
|
|
628
524
|
return match ? match[1] : raw.split("\n")[0].slice(0, 100);
|
|
629
525
|
}
|
|
630
526
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
631
|
-
return new Promise((
|
|
527
|
+
return new Promise((resolve12) => {
|
|
632
528
|
const child = (0, import_child_process2.exec)(cmd, { encoding: "utf-8", timeout: timeoutMs }, (err, stdout) => {
|
|
633
529
|
if (err || !stdout?.trim()) {
|
|
634
|
-
|
|
530
|
+
resolve12(null);
|
|
635
531
|
} else {
|
|
636
|
-
|
|
532
|
+
resolve12(stdout.trim());
|
|
637
533
|
}
|
|
638
534
|
});
|
|
639
|
-
child.on("error", () =>
|
|
535
|
+
child.on("error", () => resolve12(null));
|
|
640
536
|
});
|
|
641
537
|
}
|
|
642
538
|
async function detectCLIs(providerLoader) {
|
|
@@ -751,7 +647,7 @@ function checkDateRotation() {
|
|
|
751
647
|
const today = getDateStr();
|
|
752
648
|
if (today !== currentDate) {
|
|
753
649
|
currentDate = today;
|
|
754
|
-
currentLogFile =
|
|
650
|
+
currentLogFile = path3.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
755
651
|
cleanOldLogs();
|
|
756
652
|
}
|
|
757
653
|
}
|
|
@@ -765,7 +661,7 @@ function cleanOldLogs() {
|
|
|
765
661
|
const dateMatch = file2.match(/daemon-(\d{4}-\d{2}-\d{2})/);
|
|
766
662
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
767
663
|
try {
|
|
768
|
-
fs2.unlinkSync(
|
|
664
|
+
fs2.unlinkSync(path3.join(LOG_DIR, file2));
|
|
769
665
|
} catch {
|
|
770
666
|
}
|
|
771
667
|
}
|
|
@@ -882,17 +778,17 @@ function installGlobalInterceptor() {
|
|
|
882
778
|
writeToFile(`Log file: ${currentLogFile}`);
|
|
883
779
|
writeToFile(`Log level: ${currentLevel}`);
|
|
884
780
|
}
|
|
885
|
-
var fs2,
|
|
781
|
+
var fs2, path3, os4, LEVEL_NUM, LEVEL_LABEL, currentLevel, LOG_DIR, MAX_LOG_SIZE, MAX_LOG_DAYS, currentDate, currentLogFile, writeCount, RING_BUFFER_SIZE, ringBuffer, origConsoleLog, origConsoleError, origConsoleWarn, LOG, interceptorInstalled, LOG_PATH;
|
|
886
782
|
var init_logger = __esm({
|
|
887
783
|
"../../oss/packages/daemon-core/src/logging/logger.ts"() {
|
|
888
784
|
"use strict";
|
|
889
785
|
fs2 = __toESM(require("fs"));
|
|
890
|
-
|
|
786
|
+
path3 = __toESM(require("path"));
|
|
891
787
|
os4 = __toESM(require("os"));
|
|
892
788
|
LEVEL_NUM = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
893
789
|
LEVEL_LABEL = { debug: "DBG", info: "INF", warn: "WRN", error: "ERR" };
|
|
894
790
|
currentLevel = "info";
|
|
895
|
-
LOG_DIR = process.platform === "win32" ?
|
|
791
|
+
LOG_DIR = process.platform === "win32" ? path3.join(process.env.LOCALAPPDATA || process.env.APPDATA || path3.join(os4.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path3.join(os4.homedir(), "Library", "Logs", "adhdev") : path3.join(os4.homedir(), ".local", "share", "adhdev", "logs");
|
|
896
792
|
MAX_LOG_SIZE = 5 * 1024 * 1024;
|
|
897
793
|
MAX_LOG_DAYS = 7;
|
|
898
794
|
try {
|
|
@@ -900,16 +796,16 @@ var init_logger = __esm({
|
|
|
900
796
|
} catch {
|
|
901
797
|
}
|
|
902
798
|
currentDate = getDateStr();
|
|
903
|
-
currentLogFile =
|
|
799
|
+
currentLogFile = path3.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
904
800
|
cleanOldLogs();
|
|
905
801
|
try {
|
|
906
|
-
const oldLog =
|
|
802
|
+
const oldLog = path3.join(LOG_DIR, "daemon.log");
|
|
907
803
|
if (fs2.existsSync(oldLog)) {
|
|
908
804
|
const stat4 = fs2.statSync(oldLog);
|
|
909
805
|
const oldDate = stat4.mtime.toISOString().slice(0, 10);
|
|
910
|
-
fs2.renameSync(oldLog,
|
|
806
|
+
fs2.renameSync(oldLog, path3.join(LOG_DIR, `daemon-${oldDate}.log`));
|
|
911
807
|
}
|
|
912
|
-
const oldLogBackup =
|
|
808
|
+
const oldLogBackup = path3.join(LOG_DIR, "daemon.log.old");
|
|
913
809
|
if (fs2.existsSync(oldLogBackup)) {
|
|
914
810
|
fs2.unlinkSync(oldLogBackup);
|
|
915
811
|
}
|
|
@@ -941,7 +837,7 @@ var init_logger = __esm({
|
|
|
941
837
|
}
|
|
942
838
|
};
|
|
943
839
|
interceptorInstalled = false;
|
|
944
|
-
LOG_PATH =
|
|
840
|
+
LOG_PATH = path3.join(LOG_DIR, `daemon-${getDateStr()}.log`);
|
|
945
841
|
}
|
|
946
842
|
});
|
|
947
843
|
|
|
@@ -1030,7 +926,7 @@ var init_manager = __esm({
|
|
|
1030
926
|
* Returns multiple entries if multiple IDE windows are open on same port
|
|
1031
927
|
*/
|
|
1032
928
|
static listAllTargets(port) {
|
|
1033
|
-
return new Promise((
|
|
929
|
+
return new Promise((resolve12) => {
|
|
1034
930
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
1035
931
|
let data = "";
|
|
1036
932
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -1046,16 +942,16 @@ var init_manager = __esm({
|
|
|
1046
942
|
(t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
|
|
1047
943
|
);
|
|
1048
944
|
const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
|
|
1049
|
-
|
|
945
|
+
resolve12(mainPages.length > 0 ? mainPages : fallbackPages);
|
|
1050
946
|
} catch {
|
|
1051
|
-
|
|
947
|
+
resolve12([]);
|
|
1052
948
|
}
|
|
1053
949
|
});
|
|
1054
950
|
});
|
|
1055
|
-
req.on("error", () =>
|
|
951
|
+
req.on("error", () => resolve12([]));
|
|
1056
952
|
req.setTimeout(2e3, () => {
|
|
1057
953
|
req.destroy();
|
|
1058
|
-
|
|
954
|
+
resolve12([]);
|
|
1059
955
|
});
|
|
1060
956
|
});
|
|
1061
957
|
}
|
|
@@ -1095,7 +991,7 @@ var init_manager = __esm({
|
|
|
1095
991
|
}
|
|
1096
992
|
}
|
|
1097
993
|
findTargetOnPort(port) {
|
|
1098
|
-
return new Promise((
|
|
994
|
+
return new Promise((resolve12) => {
|
|
1099
995
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
1100
996
|
let data = "";
|
|
1101
997
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -1106,7 +1002,7 @@ var init_manager = __esm({
|
|
|
1106
1002
|
(t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
|
|
1107
1003
|
);
|
|
1108
1004
|
if (pages.length === 0) {
|
|
1109
|
-
|
|
1005
|
+
resolve12(targets.find((t) => t.webSocketDebuggerUrl) || null);
|
|
1110
1006
|
return;
|
|
1111
1007
|
}
|
|
1112
1008
|
const mainPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
|
|
@@ -1116,24 +1012,24 @@ var init_manager = __esm({
|
|
|
1116
1012
|
const specific = list.find((t) => t.id === this._targetId);
|
|
1117
1013
|
if (specific) {
|
|
1118
1014
|
this._pageTitle = specific.title || "";
|
|
1119
|
-
|
|
1015
|
+
resolve12(specific);
|
|
1120
1016
|
} else {
|
|
1121
1017
|
this.log(`[CDP] Target ${this._targetId} not found in page list`);
|
|
1122
|
-
|
|
1018
|
+
resolve12(null);
|
|
1123
1019
|
}
|
|
1124
1020
|
return;
|
|
1125
1021
|
}
|
|
1126
1022
|
this._pageTitle = list[0]?.title || "";
|
|
1127
|
-
|
|
1023
|
+
resolve12(list[0]);
|
|
1128
1024
|
} catch {
|
|
1129
|
-
|
|
1025
|
+
resolve12(null);
|
|
1130
1026
|
}
|
|
1131
1027
|
});
|
|
1132
1028
|
});
|
|
1133
|
-
req.on("error", () =>
|
|
1029
|
+
req.on("error", () => resolve12(null));
|
|
1134
1030
|
req.setTimeout(2e3, () => {
|
|
1135
1031
|
req.destroy();
|
|
1136
|
-
|
|
1032
|
+
resolve12(null);
|
|
1137
1033
|
});
|
|
1138
1034
|
});
|
|
1139
1035
|
}
|
|
@@ -1144,7 +1040,7 @@ var init_manager = __esm({
|
|
|
1144
1040
|
this.extensionProviders = providers;
|
|
1145
1041
|
}
|
|
1146
1042
|
connectToTarget(wsUrl) {
|
|
1147
|
-
return new Promise((
|
|
1043
|
+
return new Promise((resolve12) => {
|
|
1148
1044
|
this.ws = new import_ws.default(wsUrl);
|
|
1149
1045
|
this.ws.on("open", async () => {
|
|
1150
1046
|
this._connected = true;
|
|
@@ -1154,17 +1050,17 @@ var init_manager = __esm({
|
|
|
1154
1050
|
}
|
|
1155
1051
|
this.connectBrowserWs().catch(() => {
|
|
1156
1052
|
});
|
|
1157
|
-
|
|
1053
|
+
resolve12(true);
|
|
1158
1054
|
});
|
|
1159
1055
|
this.ws.on("message", (data) => {
|
|
1160
1056
|
try {
|
|
1161
1057
|
const msg = JSON.parse(data.toString());
|
|
1162
1058
|
if (msg.id && this.pending.has(msg.id)) {
|
|
1163
|
-
const { resolve:
|
|
1059
|
+
const { resolve: resolve13, reject } = this.pending.get(msg.id);
|
|
1164
1060
|
this.pending.delete(msg.id);
|
|
1165
1061
|
this.failureCount = 0;
|
|
1166
1062
|
if (msg.error) reject(new Error(msg.error.message));
|
|
1167
|
-
else
|
|
1063
|
+
else resolve13(msg.result);
|
|
1168
1064
|
} else if (msg.method === "Runtime.executionContextCreated") {
|
|
1169
1065
|
this.contexts.add(msg.params.context.id);
|
|
1170
1066
|
} else if (msg.method === "Runtime.executionContextDestroyed") {
|
|
@@ -1187,7 +1083,7 @@ var init_manager = __esm({
|
|
|
1187
1083
|
this.ws.on("error", (err) => {
|
|
1188
1084
|
this.log(`[CDP] WebSocket error: ${err.message}`);
|
|
1189
1085
|
this._connected = false;
|
|
1190
|
-
|
|
1086
|
+
resolve12(false);
|
|
1191
1087
|
});
|
|
1192
1088
|
});
|
|
1193
1089
|
}
|
|
@@ -1201,7 +1097,7 @@ var init_manager = __esm({
|
|
|
1201
1097
|
return;
|
|
1202
1098
|
}
|
|
1203
1099
|
this.log(`[CDP] Connecting browser WS for target discovery...`);
|
|
1204
|
-
await new Promise((
|
|
1100
|
+
await new Promise((resolve12, reject) => {
|
|
1205
1101
|
this.browserWs = new import_ws.default(browserWsUrl);
|
|
1206
1102
|
this.browserWs.on("open", async () => {
|
|
1207
1103
|
this._browserConnected = true;
|
|
@@ -1211,16 +1107,16 @@ var init_manager = __esm({
|
|
|
1211
1107
|
} catch (e) {
|
|
1212
1108
|
this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
|
|
1213
1109
|
}
|
|
1214
|
-
|
|
1110
|
+
resolve12();
|
|
1215
1111
|
});
|
|
1216
1112
|
this.browserWs.on("message", (data) => {
|
|
1217
1113
|
try {
|
|
1218
1114
|
const msg = JSON.parse(data.toString());
|
|
1219
1115
|
if (msg.id && this.browserPending.has(msg.id)) {
|
|
1220
|
-
const { resolve:
|
|
1116
|
+
const { resolve: resolve13, reject: reject2 } = this.browserPending.get(msg.id);
|
|
1221
1117
|
this.browserPending.delete(msg.id);
|
|
1222
1118
|
if (msg.error) reject2(new Error(msg.error.message));
|
|
1223
|
-
else
|
|
1119
|
+
else resolve13(msg.result);
|
|
1224
1120
|
}
|
|
1225
1121
|
} catch {
|
|
1226
1122
|
}
|
|
@@ -1240,31 +1136,31 @@ var init_manager = __esm({
|
|
|
1240
1136
|
}
|
|
1241
1137
|
}
|
|
1242
1138
|
getBrowserWsUrl() {
|
|
1243
|
-
return new Promise((
|
|
1139
|
+
return new Promise((resolve12) => {
|
|
1244
1140
|
const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
|
|
1245
1141
|
let data = "";
|
|
1246
1142
|
res.on("data", (chunk) => data += chunk.toString());
|
|
1247
1143
|
res.on("end", () => {
|
|
1248
1144
|
try {
|
|
1249
1145
|
const info = JSON.parse(data);
|
|
1250
|
-
|
|
1146
|
+
resolve12(info.webSocketDebuggerUrl || null);
|
|
1251
1147
|
} catch {
|
|
1252
|
-
|
|
1148
|
+
resolve12(null);
|
|
1253
1149
|
}
|
|
1254
1150
|
});
|
|
1255
1151
|
});
|
|
1256
|
-
req.on("error", () =>
|
|
1152
|
+
req.on("error", () => resolve12(null));
|
|
1257
1153
|
req.setTimeout(3e3, () => {
|
|
1258
1154
|
req.destroy();
|
|
1259
|
-
|
|
1155
|
+
resolve12(null);
|
|
1260
1156
|
});
|
|
1261
1157
|
});
|
|
1262
1158
|
}
|
|
1263
1159
|
sendBrowser(method, params = {}, timeoutMs = 15e3) {
|
|
1264
|
-
return new Promise((
|
|
1160
|
+
return new Promise((resolve12, reject) => {
|
|
1265
1161
|
if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
|
|
1266
1162
|
const id = this.browserMsgId++;
|
|
1267
|
-
this.browserPending.set(id, { resolve:
|
|
1163
|
+
this.browserPending.set(id, { resolve: resolve12, reject });
|
|
1268
1164
|
this.browserWs.send(JSON.stringify({ id, method, params }));
|
|
1269
1165
|
setTimeout(() => {
|
|
1270
1166
|
if (this.browserPending.has(id)) {
|
|
@@ -1304,11 +1200,11 @@ var init_manager = __esm({
|
|
|
1304
1200
|
}
|
|
1305
1201
|
// ─── CDP Protocol ────────────────────────────────────────
|
|
1306
1202
|
sendInternal(method, params = {}, timeoutMs = 15e3) {
|
|
1307
|
-
return new Promise((
|
|
1203
|
+
return new Promise((resolve12, reject) => {
|
|
1308
1204
|
if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
|
|
1309
1205
|
if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
|
|
1310
1206
|
const id = this.msgId++;
|
|
1311
|
-
this.pending.set(id, { resolve:
|
|
1207
|
+
this.pending.set(id, { resolve: resolve12, reject });
|
|
1312
1208
|
this.ws.send(JSON.stringify({ id, method, params }));
|
|
1313
1209
|
setTimeout(() => {
|
|
1314
1210
|
if (this.pending.has(id)) {
|
|
@@ -1557,7 +1453,7 @@ var init_manager = __esm({
|
|
|
1557
1453
|
const browserWs = this.browserWs;
|
|
1558
1454
|
let msgId = this.browserMsgId;
|
|
1559
1455
|
const sendWs = (method, params = {}, sessionId) => {
|
|
1560
|
-
return new Promise((
|
|
1456
|
+
return new Promise((resolve12, reject) => {
|
|
1561
1457
|
const mid = msgId++;
|
|
1562
1458
|
this.browserMsgId = msgId;
|
|
1563
1459
|
const handler = (raw) => {
|
|
@@ -1566,7 +1462,7 @@ var init_manager = __esm({
|
|
|
1566
1462
|
if (msg.id === mid) {
|
|
1567
1463
|
browserWs.removeListener("message", handler);
|
|
1568
1464
|
if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
|
|
1569
|
-
else
|
|
1465
|
+
else resolve12(msg.result);
|
|
1570
1466
|
}
|
|
1571
1467
|
} catch {
|
|
1572
1468
|
}
|
|
@@ -1757,14 +1653,14 @@ var init_manager = __esm({
|
|
|
1757
1653
|
if (!ws2 || ws2.readyState !== import_ws.default.OPEN) {
|
|
1758
1654
|
throw new Error("CDP not connected");
|
|
1759
1655
|
}
|
|
1760
|
-
return new Promise((
|
|
1656
|
+
return new Promise((resolve12, reject) => {
|
|
1761
1657
|
const id = getNextId();
|
|
1762
1658
|
pendingMap.set(id, {
|
|
1763
1659
|
resolve: (result) => {
|
|
1764
1660
|
if (result?.result?.subtype === "error") {
|
|
1765
1661
|
reject(new Error(result.result.description));
|
|
1766
1662
|
} else {
|
|
1767
|
-
|
|
1663
|
+
resolve12(result?.result?.value);
|
|
1768
1664
|
}
|
|
1769
1665
|
},
|
|
1770
1666
|
reject
|
|
@@ -1796,10 +1692,10 @@ var init_manager = __esm({
|
|
|
1796
1692
|
throw new Error("CDP not connected");
|
|
1797
1693
|
}
|
|
1798
1694
|
const sendViaSession = (method, params = {}) => {
|
|
1799
|
-
return new Promise((
|
|
1695
|
+
return new Promise((resolve12, reject) => {
|
|
1800
1696
|
const pendingMap = this._browserConnected ? this.browserPending : this.pending;
|
|
1801
1697
|
const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
|
|
1802
|
-
pendingMap.set(id, { resolve:
|
|
1698
|
+
pendingMap.set(id, { resolve: resolve12, reject });
|
|
1803
1699
|
ws2.send(JSON.stringify({ id, sessionId, method, params }));
|
|
1804
1700
|
setTimeout(() => {
|
|
1805
1701
|
if (pendingMap.has(id)) {
|
|
@@ -2526,7 +2422,7 @@ var init_extension_provider_instance = __esm({
|
|
|
2526
2422
|
function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
|
|
2527
2423
|
try {
|
|
2528
2424
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
2529
|
-
const dir =
|
|
2425
|
+
const dir = path4.join(HISTORY_DIR, sanitized);
|
|
2530
2426
|
if (!fs3.existsSync(dir)) return { messages: [], hasMore: false };
|
|
2531
2427
|
const sanitizedInstance = instanceId?.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
2532
2428
|
const files = fs3.readdirSync(dir).filter((f) => {
|
|
@@ -2540,7 +2436,7 @@ function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
|
|
|
2540
2436
|
const needed = offset + limit + 1;
|
|
2541
2437
|
for (const file2 of files) {
|
|
2542
2438
|
if (allMessages.length >= needed) break;
|
|
2543
|
-
const filePath =
|
|
2439
|
+
const filePath = path4.join(dir, file2);
|
|
2544
2440
|
const content = fs3.readFileSync(filePath, "utf-8");
|
|
2545
2441
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
2546
2442
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
@@ -2559,14 +2455,14 @@ function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
|
|
|
2559
2455
|
return { messages: [], hasMore: false };
|
|
2560
2456
|
}
|
|
2561
2457
|
}
|
|
2562
|
-
var fs3,
|
|
2458
|
+
var fs3, path4, os5, HISTORY_DIR, RETAIN_DAYS, ChatHistoryWriter;
|
|
2563
2459
|
var init_chat_history = __esm({
|
|
2564
2460
|
"../../oss/packages/daemon-core/src/config/chat-history.ts"() {
|
|
2565
2461
|
"use strict";
|
|
2566
2462
|
fs3 = __toESM(require("fs"));
|
|
2567
|
-
|
|
2463
|
+
path4 = __toESM(require("path"));
|
|
2568
2464
|
os5 = __toESM(require("os"));
|
|
2569
|
-
HISTORY_DIR =
|
|
2465
|
+
HISTORY_DIR = path4.join(os5.homedir(), ".adhdev", "history");
|
|
2570
2466
|
RETAIN_DAYS = 30;
|
|
2571
2467
|
ChatHistoryWriter = class {
|
|
2572
2468
|
/** Last seen message count per agent (deduplication) */
|
|
@@ -2609,11 +2505,11 @@ var init_chat_history = __esm({
|
|
|
2609
2505
|
});
|
|
2610
2506
|
}
|
|
2611
2507
|
if (newMessages.length === 0) return;
|
|
2612
|
-
const dir =
|
|
2508
|
+
const dir = path4.join(HISTORY_DIR, this.sanitize(agentType));
|
|
2613
2509
|
fs3.mkdirSync(dir, { recursive: true });
|
|
2614
2510
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
2615
2511
|
const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
|
|
2616
|
-
const filePath =
|
|
2512
|
+
const filePath = path4.join(dir, `${filePrefix}${date5}.jsonl`);
|
|
2617
2513
|
const lines = newMessages.map((m) => JSON.stringify(m)).join("\n") + "\n";
|
|
2618
2514
|
fs3.appendFileSync(filePath, lines, "utf-8");
|
|
2619
2515
|
const prevCount = this.lastSeenCounts.get(dedupKey) || 0;
|
|
@@ -2657,11 +2553,11 @@ ${next}`;
|
|
|
2657
2553
|
this.lastSeenTerminal.set(dedupKey, next);
|
|
2658
2554
|
return;
|
|
2659
2555
|
}
|
|
2660
|
-
const dir =
|
|
2556
|
+
const dir = path4.join(HISTORY_DIR, this.sanitize(agentType));
|
|
2661
2557
|
fs3.mkdirSync(dir, { recursive: true });
|
|
2662
2558
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
2663
2559
|
const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
|
|
2664
|
-
const filePath =
|
|
2560
|
+
const filePath = path4.join(dir, `${filePrefix}${date5}.terminal.log`);
|
|
2665
2561
|
fs3.appendFileSync(filePath, delta, "utf-8");
|
|
2666
2562
|
this.lastSeenTerminal.set(dedupKey, next);
|
|
2667
2563
|
if (!this.rotated) {
|
|
@@ -2685,10 +2581,10 @@ ${next}`;
|
|
|
2685
2581
|
const cutoff = Date.now() - RETAIN_DAYS * 24 * 60 * 60 * 1e3;
|
|
2686
2582
|
const agentDirs = fs3.readdirSync(HISTORY_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
2687
2583
|
for (const dir of agentDirs) {
|
|
2688
|
-
const dirPath =
|
|
2584
|
+
const dirPath = path4.join(HISTORY_DIR, dir.name);
|
|
2689
2585
|
const files = fs3.readdirSync(dirPath).filter((f) => f.endsWith(".jsonl") || f.endsWith(".terminal.log"));
|
|
2690
2586
|
for (const file2 of files) {
|
|
2691
|
-
const filePath =
|
|
2587
|
+
const filePath = path4.join(dirPath, file2);
|
|
2692
2588
|
const stat4 = fs3.statSync(filePath);
|
|
2693
2589
|
if (stat4.mtimeMs < cutoff) {
|
|
2694
2590
|
fs3.unlinkSync(filePath);
|
|
@@ -3757,6 +3653,14 @@ function buildSessionEntries(allStates, cdpManagers) {
|
|
|
3757
3653
|
for (const state of acpStates) {
|
|
3758
3654
|
sessions.push(buildAcpSession(state));
|
|
3759
3655
|
}
|
|
3656
|
+
const extensionParentIds = new Set(
|
|
3657
|
+
sessions.filter((session) => session.transport === "cdp-webview" && !!session.parentId).map((session) => session.parentId)
|
|
3658
|
+
);
|
|
3659
|
+
for (const session of sessions) {
|
|
3660
|
+
if (session.transport === "cdp-page" && extensionParentIds.has(session.id)) {
|
|
3661
|
+
session.surfaceHidden = true;
|
|
3662
|
+
}
|
|
3663
|
+
}
|
|
3760
3664
|
return sessions;
|
|
3761
3665
|
}
|
|
3762
3666
|
var IDE_SESSION_CAPABILITIES, EXTENSION_SESSION_CAPABILITIES, PTY_SESSION_CAPABILITIES, ACP_SESSION_CAPABILITIES;
|
|
@@ -4826,11 +4730,11 @@ function resolveSafePath(requestedPath) {
|
|
|
4826
4730
|
const home = os6.homedir();
|
|
4827
4731
|
let resolved;
|
|
4828
4732
|
if (requestedPath.startsWith("~")) {
|
|
4829
|
-
resolved =
|
|
4830
|
-
} else if (
|
|
4733
|
+
resolved = path5.join(home, requestedPath.slice(1));
|
|
4734
|
+
} else if (path5.isAbsolute(requestedPath)) {
|
|
4831
4735
|
resolved = requestedPath;
|
|
4832
4736
|
} else {
|
|
4833
|
-
resolved =
|
|
4737
|
+
resolved = path5.resolve(requestedPath);
|
|
4834
4738
|
}
|
|
4835
4739
|
return resolved;
|
|
4836
4740
|
}
|
|
@@ -4846,7 +4750,7 @@ async function handleFileRead(h, args) {
|
|
|
4846
4750
|
async function handleFileWrite(h, args) {
|
|
4847
4751
|
try {
|
|
4848
4752
|
const filePath = resolveSafePath(args?.path);
|
|
4849
|
-
fs4.mkdirSync(
|
|
4753
|
+
fs4.mkdirSync(path5.dirname(filePath), { recursive: true });
|
|
4850
4754
|
fs4.writeFileSync(filePath, args?.content || "", "utf-8");
|
|
4851
4755
|
return { success: true, path: filePath };
|
|
4852
4756
|
} catch (e) {
|
|
@@ -4860,7 +4764,7 @@ async function handleFileList(h, args) {
|
|
|
4860
4764
|
const files = entries.map((e) => ({
|
|
4861
4765
|
name: e.name,
|
|
4862
4766
|
type: e.isDirectory() ? "directory" : "file",
|
|
4863
|
-
size: e.isFile() ? fs4.statSync(
|
|
4767
|
+
size: e.isFile() ? fs4.statSync(path5.join(dirPath, e.name)).size : void 0
|
|
4864
4768
|
}));
|
|
4865
4769
|
return { success: true, files, path: dirPath };
|
|
4866
4770
|
} catch (e) {
|
|
@@ -4870,12 +4774,12 @@ async function handleFileList(h, args) {
|
|
|
4870
4774
|
async function handleFileListBrowse(h, args) {
|
|
4871
4775
|
return handleFileList(h, args);
|
|
4872
4776
|
}
|
|
4873
|
-
var fs4,
|
|
4777
|
+
var fs4, path5, os6, KEY_TO_VK;
|
|
4874
4778
|
var init_cdp_commands = __esm({
|
|
4875
4779
|
"../../oss/packages/daemon-core/src/commands/cdp-commands.ts"() {
|
|
4876
4780
|
"use strict";
|
|
4877
4781
|
fs4 = __toESM(require("fs"));
|
|
4878
|
-
|
|
4782
|
+
path5 = __toESM(require("path"));
|
|
4879
4783
|
os6 = __toESM(require("os"));
|
|
4880
4784
|
KEY_TO_VK = {
|
|
4881
4785
|
Backspace: 8,
|
|
@@ -5068,13 +4972,12 @@ function handleGetIdeExtensions(h, args) {
|
|
|
5068
4972
|
const loader = h.ctx.providerLoader;
|
|
5069
4973
|
if (!loader) return { success: false, error: "ProviderLoader not initialized" };
|
|
5070
4974
|
const allExtProviders = loader.getByCategory?.("extension") || [];
|
|
5071
|
-
const config2 = loadConfig();
|
|
5072
4975
|
if (ideType) {
|
|
5073
4976
|
const extensions = allExtProviders.map((p) => ({
|
|
5074
4977
|
type: p.type,
|
|
5075
4978
|
name: p.name,
|
|
5076
4979
|
extensionId: p.extensionId,
|
|
5077
|
-
enabled:
|
|
4980
|
+
enabled: loader.getIdeExtensionEnabledState?.(ideType, p.type) === true
|
|
5078
4981
|
}));
|
|
5079
4982
|
return { success: true, ideType, extensions };
|
|
5080
4983
|
}
|
|
@@ -5085,7 +4988,7 @@ function handleGetIdeExtensions(h, args) {
|
|
|
5085
4988
|
type: p.type,
|
|
5086
4989
|
name: p.name,
|
|
5087
4990
|
extensionId: p.extensionId,
|
|
5088
|
-
enabled:
|
|
4991
|
+
enabled: loader.getIdeExtensionEnabledState?.(ide, p.type) === true
|
|
5089
4992
|
}));
|
|
5090
4993
|
}
|
|
5091
4994
|
return { success: true, ideExtensions: result };
|
|
@@ -5108,7 +5011,6 @@ function handleSetIdeExtension(h, args) {
|
|
|
5108
5011
|
var init_stream_commands = __esm({
|
|
5109
5012
|
"../../oss/packages/daemon-core/src/commands/stream-commands.ts"() {
|
|
5110
5013
|
"use strict";
|
|
5111
|
-
init_config();
|
|
5112
5014
|
init_logger();
|
|
5113
5015
|
}
|
|
5114
5016
|
});
|
|
@@ -5121,9 +5023,7 @@ function handleWorkspaceList() {
|
|
|
5121
5023
|
success: true,
|
|
5122
5024
|
workspaces: state.workspaces,
|
|
5123
5025
|
defaultWorkspaceId: state.defaultWorkspaceId,
|
|
5124
|
-
defaultWorkspacePath: state.defaultWorkspacePath
|
|
5125
|
-
legacyRecentPaths: config2.recentCliWorkspaces || [],
|
|
5126
|
-
activity: getWorkspaceActivity(config2, 25)
|
|
5026
|
+
defaultWorkspacePath: state.defaultWorkspacePath
|
|
5127
5027
|
};
|
|
5128
5028
|
}
|
|
5129
5029
|
function handleWorkspaceAdd(args) {
|
|
@@ -5134,10 +5034,9 @@ function handleWorkspaceAdd(args) {
|
|
|
5134
5034
|
const config2 = loadConfig();
|
|
5135
5035
|
const result = addWorkspaceEntry(config2, rawPath, label, { createIfMissing });
|
|
5136
5036
|
if ("error" in result) return { success: false, error: result.error };
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
return { success: true, entry: result.entry, ...state, activity: getWorkspaceActivity(cfg, 25) };
|
|
5037
|
+
saveConfig(result.config);
|
|
5038
|
+
const state = getWorkspaceState(result.config);
|
|
5039
|
+
return { success: true, entry: result.entry, ...state };
|
|
5141
5040
|
}
|
|
5142
5041
|
function handleWorkspaceRemove(args) {
|
|
5143
5042
|
const id = (args?.id || "").trim();
|
|
@@ -5146,13 +5045,9 @@ function handleWorkspaceRemove(args) {
|
|
|
5146
5045
|
const removed = (config2.workspaces || []).find((w) => w.id === id);
|
|
5147
5046
|
const result = removeWorkspaceEntry(config2, id);
|
|
5148
5047
|
if ("error" in result) return { success: false, error: result.error };
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
}
|
|
5153
|
-
saveConfig(cfg);
|
|
5154
|
-
const state = getWorkspaceState(cfg);
|
|
5155
|
-
return { success: true, removedId: id, ...state, activity: getWorkspaceActivity(cfg, 25) };
|
|
5048
|
+
saveConfig(result.config);
|
|
5049
|
+
const state = getWorkspaceState(result.config);
|
|
5050
|
+
return { success: true, removedId: id, ...state };
|
|
5156
5051
|
}
|
|
5157
5052
|
function handleWorkspaceSetDefault(args) {
|
|
5158
5053
|
const clear = args?.clear === true || args?.id === null || args?.id === "";
|
|
@@ -5164,8 +5059,7 @@ function handleWorkspaceSetDefault(args) {
|
|
|
5164
5059
|
const state2 = getWorkspaceState(result2.config);
|
|
5165
5060
|
return {
|
|
5166
5061
|
success: true,
|
|
5167
|
-
...state2
|
|
5168
|
-
activity: getWorkspaceActivity(result2.config, 25)
|
|
5062
|
+
...state2
|
|
5169
5063
|
};
|
|
5170
5064
|
}
|
|
5171
5065
|
const pathArg = args?.path != null && String(args.path).trim() ? String(args.path).trim() : "";
|
|
@@ -5189,21 +5083,15 @@ function handleWorkspaceSetDefault(args) {
|
|
|
5189
5083
|
}
|
|
5190
5084
|
const result = setDefaultWorkspaceId(config2, nextId);
|
|
5191
5085
|
if ("error" in result) return { success: false, error: result.error };
|
|
5192
|
-
|
|
5193
|
-
const
|
|
5194
|
-
|
|
5195
|
-
out = appendWorkspaceActivity(out, ap, { kind: "default" });
|
|
5196
|
-
}
|
|
5197
|
-
saveConfig(out);
|
|
5198
|
-
const state = getWorkspaceState(out);
|
|
5199
|
-
return { success: true, ...state, activity: getWorkspaceActivity(out, 25) };
|
|
5086
|
+
saveConfig(result.config);
|
|
5087
|
+
const state = getWorkspaceState(result.config);
|
|
5088
|
+
return { success: true, ...state };
|
|
5200
5089
|
}
|
|
5201
5090
|
var init_workspace_commands = __esm({
|
|
5202
5091
|
"../../oss/packages/daemon-core/src/commands/workspace-commands.ts"() {
|
|
5203
5092
|
"use strict";
|
|
5204
5093
|
init_config();
|
|
5205
5094
|
init_workspaces();
|
|
5206
|
-
init_workspace_activity();
|
|
5207
5095
|
}
|
|
5208
5096
|
});
|
|
5209
5097
|
|
|
@@ -5282,15 +5170,12 @@ var init_handler = __esm({
|
|
|
5282
5170
|
"use strict";
|
|
5283
5171
|
init_devtools();
|
|
5284
5172
|
init_builders();
|
|
5285
|
-
init_config();
|
|
5286
5173
|
init_chat_history();
|
|
5287
5174
|
init_logger();
|
|
5288
5175
|
init_chat_commands();
|
|
5289
5176
|
init_cdp_commands();
|
|
5290
5177
|
init_stream_commands();
|
|
5291
5178
|
init_workspace_commands();
|
|
5292
|
-
init_workspaces();
|
|
5293
|
-
init_workspace_activity();
|
|
5294
5179
|
COMMAND_DEBUG_LEVELS = /* @__PURE__ */ new Set([
|
|
5295
5180
|
"pty_input",
|
|
5296
5181
|
"pty_resize",
|
|
@@ -5549,22 +5434,7 @@ var init_handler = __esm({
|
|
|
5549
5434
|
return handleFileList(this, args);
|
|
5550
5435
|
case "file_list_browse":
|
|
5551
5436
|
return handleFileListBrowse(this, args);
|
|
5552
|
-
// ─── VSCode API commands (not available) ────
|
|
5553
|
-
case "vscode_command_exec":
|
|
5554
|
-
case "execute_vscode_command": {
|
|
5555
|
-
const resolvedCmd = args?.commandId || args?.command;
|
|
5556
|
-
if (resolvedCmd === "adhdev.captureCdpScreenshot") {
|
|
5557
|
-
return handleScreenshot(this, args);
|
|
5558
|
-
}
|
|
5559
|
-
return { success: false, error: `VSCode command not available: ${resolvedCmd || cmd}` };
|
|
5560
|
-
}
|
|
5561
5437
|
// ─── Workspace cmds ──────────────
|
|
5562
|
-
case "get_recent_workspaces":
|
|
5563
|
-
return this.handleGetRecentWorkspaces(args);
|
|
5564
|
-
case "get_cli_history": {
|
|
5565
|
-
const config2 = loadConfig();
|
|
5566
|
-
return { success: true, history: config2.cliHistory || [] };
|
|
5567
|
-
}
|
|
5568
5438
|
case "workspace_list":
|
|
5569
5439
|
return handleWorkspaceList();
|
|
5570
5440
|
case "workspace_add":
|
|
@@ -5572,7 +5442,6 @@ var init_handler = __esm({
|
|
|
5572
5442
|
case "workspace_remove":
|
|
5573
5443
|
return handleWorkspaceRemove(args);
|
|
5574
5444
|
case "workspace_set_default":
|
|
5575
|
-
case "workspace_set_active":
|
|
5576
5445
|
return handleWorkspaceSetDefault(args);
|
|
5577
5446
|
// ─── Script manage ───────────────────
|
|
5578
5447
|
case "refresh_scripts":
|
|
@@ -5618,19 +5487,6 @@ var init_handler = __esm({
|
|
|
5618
5487
|
}
|
|
5619
5488
|
}
|
|
5620
5489
|
// ─── Misc (kept in handler — too small to extract) ───────
|
|
5621
|
-
async handleGetRecentWorkspaces(_args) {
|
|
5622
|
-
const config2 = loadConfig();
|
|
5623
|
-
const cliRecent = config2.recentCliWorkspaces || [];
|
|
5624
|
-
const ws2 = getWorkspaceState(config2);
|
|
5625
|
-
return {
|
|
5626
|
-
success: true,
|
|
5627
|
-
result: cliRecent,
|
|
5628
|
-
workspaces: ws2.workspaces,
|
|
5629
|
-
defaultWorkspaceId: ws2.defaultWorkspaceId,
|
|
5630
|
-
defaultWorkspacePath: ws2.defaultWorkspacePath,
|
|
5631
|
-
activity: getWorkspaceActivity(config2, 25)
|
|
5632
|
-
};
|
|
5633
|
-
}
|
|
5634
5490
|
async handleRefreshScripts(_args) {
|
|
5635
5491
|
if (this._ctx.providerLoader) {
|
|
5636
5492
|
await this._ctx.providerLoader.fetchLatest().catch(() => {
|
|
@@ -5648,7 +5504,7 @@ var init_handler = __esm({
|
|
|
5648
5504
|
try {
|
|
5649
5505
|
const http3 = await import("http");
|
|
5650
5506
|
const postData = JSON.stringify(body);
|
|
5651
|
-
const result = await new Promise((
|
|
5507
|
+
const result = await new Promise((resolve12, reject) => {
|
|
5652
5508
|
const req = http3.request({
|
|
5653
5509
|
hostname: "127.0.0.1",
|
|
5654
5510
|
port: 19280,
|
|
@@ -5660,9 +5516,9 @@ var init_handler = __esm({
|
|
|
5660
5516
|
res.on("data", (chunk) => data += chunk);
|
|
5661
5517
|
res.on("end", () => {
|
|
5662
5518
|
try {
|
|
5663
|
-
|
|
5519
|
+
resolve12(JSON.parse(data));
|
|
5664
5520
|
} catch {
|
|
5665
|
-
|
|
5521
|
+
resolve12({ raw: data });
|
|
5666
5522
|
}
|
|
5667
5523
|
});
|
|
5668
5524
|
});
|
|
@@ -5680,15 +5536,15 @@ var init_handler = __esm({
|
|
|
5680
5536
|
if (!providerType) return { success: false, error: "providerType required" };
|
|
5681
5537
|
try {
|
|
5682
5538
|
const http3 = await import("http");
|
|
5683
|
-
const result = await new Promise((
|
|
5539
|
+
const result = await new Promise((resolve12, reject) => {
|
|
5684
5540
|
http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
|
|
5685
5541
|
let data = "";
|
|
5686
5542
|
res.on("data", (chunk) => data += chunk);
|
|
5687
5543
|
res.on("end", () => {
|
|
5688
5544
|
try {
|
|
5689
|
-
|
|
5545
|
+
resolve12(JSON.parse(data));
|
|
5690
5546
|
} catch {
|
|
5691
|
-
|
|
5547
|
+
resolve12({ raw: data });
|
|
5692
5548
|
}
|
|
5693
5549
|
});
|
|
5694
5550
|
}).on("error", reject);
|
|
@@ -5702,7 +5558,7 @@ var init_handler = __esm({
|
|
|
5702
5558
|
try {
|
|
5703
5559
|
const http3 = await import("http");
|
|
5704
5560
|
const postData = JSON.stringify(args || {});
|
|
5705
|
-
const result = await new Promise((
|
|
5561
|
+
const result = await new Promise((resolve12, reject) => {
|
|
5706
5562
|
const req = http3.request({
|
|
5707
5563
|
hostname: "127.0.0.1",
|
|
5708
5564
|
port: 19280,
|
|
@@ -5714,9 +5570,9 @@ var init_handler = __esm({
|
|
|
5714
5570
|
res.on("data", (chunk) => data += chunk);
|
|
5715
5571
|
res.on("end", () => {
|
|
5716
5572
|
try {
|
|
5717
|
-
|
|
5573
|
+
resolve12(JSON.parse(data));
|
|
5718
5574
|
} catch {
|
|
5719
|
-
|
|
5575
|
+
resolve12({ raw: data });
|
|
5720
5576
|
}
|
|
5721
5577
|
});
|
|
5722
5578
|
});
|
|
@@ -5837,7 +5693,7 @@ var init_readdirp = __esm({
|
|
|
5837
5693
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
5838
5694
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
5839
5695
|
if (wantBigintFsStats) {
|
|
5840
|
-
this._stat = (
|
|
5696
|
+
this._stat = (path18) => statMethod(path18, { bigint: true });
|
|
5841
5697
|
} else {
|
|
5842
5698
|
this._stat = statMethod;
|
|
5843
5699
|
}
|
|
@@ -5862,8 +5718,8 @@ var init_readdirp = __esm({
|
|
|
5862
5718
|
const par = this.parent;
|
|
5863
5719
|
const fil = par && par.files;
|
|
5864
5720
|
if (fil && fil.length > 0) {
|
|
5865
|
-
const { path:
|
|
5866
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
5721
|
+
const { path: path18, depth } = par;
|
|
5722
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path18));
|
|
5867
5723
|
const awaited = await Promise.all(slice);
|
|
5868
5724
|
for (const entry of awaited) {
|
|
5869
5725
|
if (!entry)
|
|
@@ -5903,20 +5759,20 @@ var init_readdirp = __esm({
|
|
|
5903
5759
|
this.reading = false;
|
|
5904
5760
|
}
|
|
5905
5761
|
}
|
|
5906
|
-
async _exploreDir(
|
|
5762
|
+
async _exploreDir(path18, depth) {
|
|
5907
5763
|
let files;
|
|
5908
5764
|
try {
|
|
5909
|
-
files = await (0, import_promises.readdir)(
|
|
5765
|
+
files = await (0, import_promises.readdir)(path18, this._rdOptions);
|
|
5910
5766
|
} catch (error48) {
|
|
5911
5767
|
this._onError(error48);
|
|
5912
5768
|
}
|
|
5913
|
-
return { files, depth, path:
|
|
5769
|
+
return { files, depth, path: path18 };
|
|
5914
5770
|
}
|
|
5915
|
-
async _formatEntry(dirent,
|
|
5771
|
+
async _formatEntry(dirent, path18) {
|
|
5916
5772
|
let entry;
|
|
5917
5773
|
const basename7 = this._isDirent ? dirent.name : dirent;
|
|
5918
5774
|
try {
|
|
5919
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
5775
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path18, basename7));
|
|
5920
5776
|
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename7 };
|
|
5921
5777
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
5922
5778
|
} catch (err) {
|
|
@@ -5973,16 +5829,16 @@ var init_readdirp = __esm({
|
|
|
5973
5829
|
});
|
|
5974
5830
|
|
|
5975
5831
|
// ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
|
|
5976
|
-
function createFsWatchInstance(
|
|
5832
|
+
function createFsWatchInstance(path18, options, listener, errHandler, emitRaw) {
|
|
5977
5833
|
const handleEvent = (rawEvent, evPath) => {
|
|
5978
|
-
listener(
|
|
5979
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
5980
|
-
if (evPath &&
|
|
5981
|
-
fsWatchBroadcast(sp.resolve(
|
|
5834
|
+
listener(path18);
|
|
5835
|
+
emitRaw(rawEvent, evPath, { watchedPath: path18 });
|
|
5836
|
+
if (evPath && path18 !== evPath) {
|
|
5837
|
+
fsWatchBroadcast(sp.resolve(path18, evPath), KEY_LISTENERS, sp.join(path18, evPath));
|
|
5982
5838
|
}
|
|
5983
5839
|
};
|
|
5984
5840
|
try {
|
|
5985
|
-
return (0, import_node_fs.watch)(
|
|
5841
|
+
return (0, import_node_fs.watch)(path18, {
|
|
5986
5842
|
persistent: options.persistent
|
|
5987
5843
|
}, handleEvent);
|
|
5988
5844
|
} catch (error48) {
|
|
@@ -6331,12 +6187,12 @@ var init_handler2 = __esm({
|
|
|
6331
6187
|
listener(val1, val2, val3);
|
|
6332
6188
|
});
|
|
6333
6189
|
};
|
|
6334
|
-
setFsWatchListener = (
|
|
6190
|
+
setFsWatchListener = (path18, fullPath, options, handlers) => {
|
|
6335
6191
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
6336
6192
|
let cont = FsWatchInstances.get(fullPath);
|
|
6337
6193
|
let watcher;
|
|
6338
6194
|
if (!options.persistent) {
|
|
6339
|
-
watcher = createFsWatchInstance(
|
|
6195
|
+
watcher = createFsWatchInstance(path18, options, listener, errHandler, rawEmitter);
|
|
6340
6196
|
if (!watcher)
|
|
6341
6197
|
return;
|
|
6342
6198
|
return watcher.close.bind(watcher);
|
|
@@ -6347,7 +6203,7 @@ var init_handler2 = __esm({
|
|
|
6347
6203
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
6348
6204
|
} else {
|
|
6349
6205
|
watcher = createFsWatchInstance(
|
|
6350
|
-
|
|
6206
|
+
path18,
|
|
6351
6207
|
options,
|
|
6352
6208
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
6353
6209
|
errHandler,
|
|
@@ -6362,7 +6218,7 @@ var init_handler2 = __esm({
|
|
|
6362
6218
|
cont.watcherUnusable = true;
|
|
6363
6219
|
if (isWindows && error48.code === "EPERM") {
|
|
6364
6220
|
try {
|
|
6365
|
-
const fd = await (0, import_promises2.open)(
|
|
6221
|
+
const fd = await (0, import_promises2.open)(path18, "r");
|
|
6366
6222
|
await fd.close();
|
|
6367
6223
|
broadcastErr(error48);
|
|
6368
6224
|
} catch (err) {
|
|
@@ -6393,7 +6249,7 @@ var init_handler2 = __esm({
|
|
|
6393
6249
|
};
|
|
6394
6250
|
};
|
|
6395
6251
|
FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
6396
|
-
setFsWatchFileListener = (
|
|
6252
|
+
setFsWatchFileListener = (path18, fullPath, options, handlers) => {
|
|
6397
6253
|
const { listener, rawEmitter } = handlers;
|
|
6398
6254
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
6399
6255
|
const copts = cont && cont.options;
|
|
@@ -6415,7 +6271,7 @@ var init_handler2 = __esm({
|
|
|
6415
6271
|
});
|
|
6416
6272
|
const currmtime = curr.mtimeMs;
|
|
6417
6273
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
6418
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
6274
|
+
foreach(cont.listeners, (listener2) => listener2(path18, curr));
|
|
6419
6275
|
}
|
|
6420
6276
|
})
|
|
6421
6277
|
};
|
|
@@ -6445,13 +6301,13 @@ var init_handler2 = __esm({
|
|
|
6445
6301
|
* @param listener on fs change
|
|
6446
6302
|
* @returns closer for the watcher instance
|
|
6447
6303
|
*/
|
|
6448
|
-
_watchWithNodeFs(
|
|
6304
|
+
_watchWithNodeFs(path18, listener) {
|
|
6449
6305
|
const opts = this.fsw.options;
|
|
6450
|
-
const directory = sp.dirname(
|
|
6451
|
-
const basename7 = sp.basename(
|
|
6306
|
+
const directory = sp.dirname(path18);
|
|
6307
|
+
const basename7 = sp.basename(path18);
|
|
6452
6308
|
const parent = this.fsw._getWatchedDir(directory);
|
|
6453
6309
|
parent.add(basename7);
|
|
6454
|
-
const absolutePath = sp.resolve(
|
|
6310
|
+
const absolutePath = sp.resolve(path18);
|
|
6455
6311
|
const options = {
|
|
6456
6312
|
persistent: opts.persistent
|
|
6457
6313
|
};
|
|
@@ -6461,12 +6317,12 @@ var init_handler2 = __esm({
|
|
|
6461
6317
|
if (opts.usePolling) {
|
|
6462
6318
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
6463
6319
|
options.interval = enableBin && isBinaryPath(basename7) ? opts.binaryInterval : opts.interval;
|
|
6464
|
-
closer = setFsWatchFileListener(
|
|
6320
|
+
closer = setFsWatchFileListener(path18, absolutePath, options, {
|
|
6465
6321
|
listener,
|
|
6466
6322
|
rawEmitter: this.fsw._emitRaw
|
|
6467
6323
|
});
|
|
6468
6324
|
} else {
|
|
6469
|
-
closer = setFsWatchListener(
|
|
6325
|
+
closer = setFsWatchListener(path18, absolutePath, options, {
|
|
6470
6326
|
listener,
|
|
6471
6327
|
errHandler: this._boundHandleError,
|
|
6472
6328
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -6488,7 +6344,7 @@ var init_handler2 = __esm({
|
|
|
6488
6344
|
let prevStats = stats;
|
|
6489
6345
|
if (parent.has(basename7))
|
|
6490
6346
|
return;
|
|
6491
|
-
const listener = async (
|
|
6347
|
+
const listener = async (path18, newStats) => {
|
|
6492
6348
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
6493
6349
|
return;
|
|
6494
6350
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -6502,11 +6358,11 @@ var init_handler2 = __esm({
|
|
|
6502
6358
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
6503
6359
|
}
|
|
6504
6360
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
6505
|
-
this.fsw._closeFile(
|
|
6361
|
+
this.fsw._closeFile(path18);
|
|
6506
6362
|
prevStats = newStats2;
|
|
6507
6363
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
6508
6364
|
if (closer2)
|
|
6509
|
-
this.fsw._addPathCloser(
|
|
6365
|
+
this.fsw._addPathCloser(path18, closer2);
|
|
6510
6366
|
} else {
|
|
6511
6367
|
prevStats = newStats2;
|
|
6512
6368
|
}
|
|
@@ -6538,7 +6394,7 @@ var init_handler2 = __esm({
|
|
|
6538
6394
|
* @param item basename of this item
|
|
6539
6395
|
* @returns true if no more processing is needed for this entry.
|
|
6540
6396
|
*/
|
|
6541
|
-
async _handleSymlink(entry, directory,
|
|
6397
|
+
async _handleSymlink(entry, directory, path18, item) {
|
|
6542
6398
|
if (this.fsw.closed) {
|
|
6543
6399
|
return;
|
|
6544
6400
|
}
|
|
@@ -6548,7 +6404,7 @@ var init_handler2 = __esm({
|
|
|
6548
6404
|
this.fsw._incrReadyCount();
|
|
6549
6405
|
let linkPath;
|
|
6550
6406
|
try {
|
|
6551
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
6407
|
+
linkPath = await (0, import_promises2.realpath)(path18);
|
|
6552
6408
|
} catch (e) {
|
|
6553
6409
|
this.fsw._emitReady();
|
|
6554
6410
|
return true;
|
|
@@ -6558,12 +6414,12 @@ var init_handler2 = __esm({
|
|
|
6558
6414
|
if (dir.has(item)) {
|
|
6559
6415
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
6560
6416
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
6561
|
-
this.fsw._emit(EV.CHANGE,
|
|
6417
|
+
this.fsw._emit(EV.CHANGE, path18, entry.stats);
|
|
6562
6418
|
}
|
|
6563
6419
|
} else {
|
|
6564
6420
|
dir.add(item);
|
|
6565
6421
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
6566
|
-
this.fsw._emit(EV.ADD,
|
|
6422
|
+
this.fsw._emit(EV.ADD, path18, entry.stats);
|
|
6567
6423
|
}
|
|
6568
6424
|
this.fsw._emitReady();
|
|
6569
6425
|
return true;
|
|
@@ -6593,9 +6449,9 @@ var init_handler2 = __esm({
|
|
|
6593
6449
|
return;
|
|
6594
6450
|
}
|
|
6595
6451
|
const item = entry.path;
|
|
6596
|
-
let
|
|
6452
|
+
let path18 = sp.join(directory, item);
|
|
6597
6453
|
current.add(item);
|
|
6598
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
6454
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path18, item)) {
|
|
6599
6455
|
return;
|
|
6600
6456
|
}
|
|
6601
6457
|
if (this.fsw.closed) {
|
|
@@ -6604,11 +6460,11 @@ var init_handler2 = __esm({
|
|
|
6604
6460
|
}
|
|
6605
6461
|
if (item === target || !target && !previous.has(item)) {
|
|
6606
6462
|
this.fsw._incrReadyCount();
|
|
6607
|
-
|
|
6608
|
-
this._addToNodeFs(
|
|
6463
|
+
path18 = sp.join(dir, sp.relative(dir, path18));
|
|
6464
|
+
this._addToNodeFs(path18, initialAdd, wh, depth + 1);
|
|
6609
6465
|
}
|
|
6610
6466
|
}).on(EV.ERROR, this._boundHandleError);
|
|
6611
|
-
return new Promise((
|
|
6467
|
+
return new Promise((resolve12, reject) => {
|
|
6612
6468
|
if (!stream)
|
|
6613
6469
|
return reject();
|
|
6614
6470
|
stream.once(STR_END, () => {
|
|
@@ -6617,7 +6473,7 @@ var init_handler2 = __esm({
|
|
|
6617
6473
|
return;
|
|
6618
6474
|
}
|
|
6619
6475
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
6620
|
-
|
|
6476
|
+
resolve12(void 0);
|
|
6621
6477
|
previous.getChildren().filter((item) => {
|
|
6622
6478
|
return item !== directory && !current.has(item);
|
|
6623
6479
|
}).forEach((item) => {
|
|
@@ -6674,13 +6530,13 @@ var init_handler2 = __esm({
|
|
|
6674
6530
|
* @param depth Child path actually targeted for watch
|
|
6675
6531
|
* @param target Child path actually targeted for watch
|
|
6676
6532
|
*/
|
|
6677
|
-
async _addToNodeFs(
|
|
6533
|
+
async _addToNodeFs(path18, initialAdd, priorWh, depth, target) {
|
|
6678
6534
|
const ready = this.fsw._emitReady;
|
|
6679
|
-
if (this.fsw._isIgnored(
|
|
6535
|
+
if (this.fsw._isIgnored(path18) || this.fsw.closed) {
|
|
6680
6536
|
ready();
|
|
6681
6537
|
return false;
|
|
6682
6538
|
}
|
|
6683
|
-
const wh = this.fsw._getWatchHelpers(
|
|
6539
|
+
const wh = this.fsw._getWatchHelpers(path18);
|
|
6684
6540
|
if (priorWh) {
|
|
6685
6541
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
6686
6542
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -6696,8 +6552,8 @@ var init_handler2 = __esm({
|
|
|
6696
6552
|
const follow = this.fsw.options.followSymlinks;
|
|
6697
6553
|
let closer;
|
|
6698
6554
|
if (stats.isDirectory()) {
|
|
6699
|
-
const absPath = sp.resolve(
|
|
6700
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
6555
|
+
const absPath = sp.resolve(path18);
|
|
6556
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path18) : path18;
|
|
6701
6557
|
if (this.fsw.closed)
|
|
6702
6558
|
return;
|
|
6703
6559
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -6707,29 +6563,29 @@ var init_handler2 = __esm({
|
|
|
6707
6563
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
6708
6564
|
}
|
|
6709
6565
|
} else if (stats.isSymbolicLink()) {
|
|
6710
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
6566
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path18) : path18;
|
|
6711
6567
|
if (this.fsw.closed)
|
|
6712
6568
|
return;
|
|
6713
6569
|
const parent = sp.dirname(wh.watchPath);
|
|
6714
6570
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
6715
6571
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
6716
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
6572
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path18, wh, targetPath);
|
|
6717
6573
|
if (this.fsw.closed)
|
|
6718
6574
|
return;
|
|
6719
6575
|
if (targetPath !== void 0) {
|
|
6720
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
6576
|
+
this.fsw._symlinkPaths.set(sp.resolve(path18), targetPath);
|
|
6721
6577
|
}
|
|
6722
6578
|
} else {
|
|
6723
6579
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
6724
6580
|
}
|
|
6725
6581
|
ready();
|
|
6726
6582
|
if (closer)
|
|
6727
|
-
this.fsw._addPathCloser(
|
|
6583
|
+
this.fsw._addPathCloser(path18, closer);
|
|
6728
6584
|
return false;
|
|
6729
6585
|
} catch (error48) {
|
|
6730
6586
|
if (this.fsw._handleError(error48)) {
|
|
6731
6587
|
ready();
|
|
6732
|
-
return
|
|
6588
|
+
return path18;
|
|
6733
6589
|
}
|
|
6734
6590
|
}
|
|
6735
6591
|
}
|
|
@@ -6764,24 +6620,24 @@ function createPattern(matcher) {
|
|
|
6764
6620
|
}
|
|
6765
6621
|
return () => false;
|
|
6766
6622
|
}
|
|
6767
|
-
function normalizePath(
|
|
6768
|
-
if (typeof
|
|
6623
|
+
function normalizePath(path18) {
|
|
6624
|
+
if (typeof path18 !== "string")
|
|
6769
6625
|
throw new Error("string expected");
|
|
6770
|
-
|
|
6771
|
-
|
|
6626
|
+
path18 = sp2.normalize(path18);
|
|
6627
|
+
path18 = path18.replace(/\\/g, "/");
|
|
6772
6628
|
let prepend = false;
|
|
6773
|
-
if (
|
|
6629
|
+
if (path18.startsWith("//"))
|
|
6774
6630
|
prepend = true;
|
|
6775
|
-
|
|
6631
|
+
path18 = path18.replace(DOUBLE_SLASH_RE, "/");
|
|
6776
6632
|
if (prepend)
|
|
6777
|
-
|
|
6778
|
-
return
|
|
6633
|
+
path18 = "/" + path18;
|
|
6634
|
+
return path18;
|
|
6779
6635
|
}
|
|
6780
6636
|
function matchPatterns(patterns, testString, stats) {
|
|
6781
|
-
const
|
|
6637
|
+
const path18 = normalizePath(testString);
|
|
6782
6638
|
for (let index = 0; index < patterns.length; index++) {
|
|
6783
6639
|
const pattern = patterns[index];
|
|
6784
|
-
if (pattern(
|
|
6640
|
+
if (pattern(path18, stats)) {
|
|
6785
6641
|
return true;
|
|
6786
6642
|
}
|
|
6787
6643
|
}
|
|
@@ -6844,19 +6700,19 @@ var init_chokidar = __esm({
|
|
|
6844
6700
|
}
|
|
6845
6701
|
return str;
|
|
6846
6702
|
};
|
|
6847
|
-
normalizePathToUnix = (
|
|
6848
|
-
normalizeIgnored = (cwd = "") => (
|
|
6849
|
-
if (typeof
|
|
6850
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
6703
|
+
normalizePathToUnix = (path18) => toUnix(sp2.normalize(toUnix(path18)));
|
|
6704
|
+
normalizeIgnored = (cwd = "") => (path18) => {
|
|
6705
|
+
if (typeof path18 === "string") {
|
|
6706
|
+
return normalizePathToUnix(sp2.isAbsolute(path18) ? path18 : sp2.join(cwd, path18));
|
|
6851
6707
|
} else {
|
|
6852
|
-
return
|
|
6708
|
+
return path18;
|
|
6853
6709
|
}
|
|
6854
6710
|
};
|
|
6855
|
-
getAbsolutePath = (
|
|
6856
|
-
if (sp2.isAbsolute(
|
|
6857
|
-
return
|
|
6711
|
+
getAbsolutePath = (path18, cwd) => {
|
|
6712
|
+
if (sp2.isAbsolute(path18)) {
|
|
6713
|
+
return path18;
|
|
6858
6714
|
}
|
|
6859
|
-
return sp2.join(cwd,
|
|
6715
|
+
return sp2.join(cwd, path18);
|
|
6860
6716
|
};
|
|
6861
6717
|
EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
6862
6718
|
DirEntry = class {
|
|
@@ -6921,10 +6777,10 @@ var init_chokidar = __esm({
|
|
|
6921
6777
|
dirParts;
|
|
6922
6778
|
followSymlinks;
|
|
6923
6779
|
statMethod;
|
|
6924
|
-
constructor(
|
|
6780
|
+
constructor(path18, follow, fsw) {
|
|
6925
6781
|
this.fsw = fsw;
|
|
6926
|
-
const watchPath =
|
|
6927
|
-
this.path =
|
|
6782
|
+
const watchPath = path18;
|
|
6783
|
+
this.path = path18 = path18.replace(REPLACER_RE, "");
|
|
6928
6784
|
this.watchPath = watchPath;
|
|
6929
6785
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
6930
6786
|
this.dirParts = [];
|
|
@@ -7064,20 +6920,20 @@ var init_chokidar = __esm({
|
|
|
7064
6920
|
this._closePromise = void 0;
|
|
7065
6921
|
let paths = unifyPaths(paths_);
|
|
7066
6922
|
if (cwd) {
|
|
7067
|
-
paths = paths.map((
|
|
7068
|
-
const absPath = getAbsolutePath(
|
|
6923
|
+
paths = paths.map((path18) => {
|
|
6924
|
+
const absPath = getAbsolutePath(path18, cwd);
|
|
7069
6925
|
return absPath;
|
|
7070
6926
|
});
|
|
7071
6927
|
}
|
|
7072
|
-
paths.forEach((
|
|
7073
|
-
this._removeIgnoredPath(
|
|
6928
|
+
paths.forEach((path18) => {
|
|
6929
|
+
this._removeIgnoredPath(path18);
|
|
7074
6930
|
});
|
|
7075
6931
|
this._userIgnored = void 0;
|
|
7076
6932
|
if (!this._readyCount)
|
|
7077
6933
|
this._readyCount = 0;
|
|
7078
6934
|
this._readyCount += paths.length;
|
|
7079
|
-
Promise.all(paths.map(async (
|
|
7080
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
6935
|
+
Promise.all(paths.map(async (path18) => {
|
|
6936
|
+
const res = await this._nodeFsHandler._addToNodeFs(path18, !_internal, void 0, 0, _origAdd);
|
|
7081
6937
|
if (res)
|
|
7082
6938
|
this._emitReady();
|
|
7083
6939
|
return res;
|
|
@@ -7099,17 +6955,17 @@ var init_chokidar = __esm({
|
|
|
7099
6955
|
return this;
|
|
7100
6956
|
const paths = unifyPaths(paths_);
|
|
7101
6957
|
const { cwd } = this.options;
|
|
7102
|
-
paths.forEach((
|
|
7103
|
-
if (!sp2.isAbsolute(
|
|
6958
|
+
paths.forEach((path18) => {
|
|
6959
|
+
if (!sp2.isAbsolute(path18) && !this._closers.has(path18)) {
|
|
7104
6960
|
if (cwd)
|
|
7105
|
-
|
|
7106
|
-
|
|
6961
|
+
path18 = sp2.join(cwd, path18);
|
|
6962
|
+
path18 = sp2.resolve(path18);
|
|
7107
6963
|
}
|
|
7108
|
-
this._closePath(
|
|
7109
|
-
this._addIgnoredPath(
|
|
7110
|
-
if (this._watched.has(
|
|
6964
|
+
this._closePath(path18);
|
|
6965
|
+
this._addIgnoredPath(path18);
|
|
6966
|
+
if (this._watched.has(path18)) {
|
|
7111
6967
|
this._addIgnoredPath({
|
|
7112
|
-
path:
|
|
6968
|
+
path: path18,
|
|
7113
6969
|
recursive: true
|
|
7114
6970
|
});
|
|
7115
6971
|
}
|
|
@@ -7173,38 +7029,38 @@ var init_chokidar = __esm({
|
|
|
7173
7029
|
* @param stats arguments to be passed with event
|
|
7174
7030
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
7175
7031
|
*/
|
|
7176
|
-
async _emit(event,
|
|
7032
|
+
async _emit(event, path18, stats) {
|
|
7177
7033
|
if (this.closed)
|
|
7178
7034
|
return;
|
|
7179
7035
|
const opts = this.options;
|
|
7180
7036
|
if (isWindows)
|
|
7181
|
-
|
|
7037
|
+
path18 = sp2.normalize(path18);
|
|
7182
7038
|
if (opts.cwd)
|
|
7183
|
-
|
|
7184
|
-
const args = [
|
|
7039
|
+
path18 = sp2.relative(opts.cwd, path18);
|
|
7040
|
+
const args = [path18];
|
|
7185
7041
|
if (stats != null)
|
|
7186
7042
|
args.push(stats);
|
|
7187
7043
|
const awf = opts.awaitWriteFinish;
|
|
7188
7044
|
let pw;
|
|
7189
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
7045
|
+
if (awf && (pw = this._pendingWrites.get(path18))) {
|
|
7190
7046
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
7191
7047
|
return this;
|
|
7192
7048
|
}
|
|
7193
7049
|
if (opts.atomic) {
|
|
7194
7050
|
if (event === EVENTS.UNLINK) {
|
|
7195
|
-
this._pendingUnlinks.set(
|
|
7051
|
+
this._pendingUnlinks.set(path18, [event, ...args]);
|
|
7196
7052
|
setTimeout(() => {
|
|
7197
|
-
this._pendingUnlinks.forEach((entry,
|
|
7053
|
+
this._pendingUnlinks.forEach((entry, path19) => {
|
|
7198
7054
|
this.emit(...entry);
|
|
7199
7055
|
this.emit(EVENTS.ALL, ...entry);
|
|
7200
|
-
this._pendingUnlinks.delete(
|
|
7056
|
+
this._pendingUnlinks.delete(path19);
|
|
7201
7057
|
});
|
|
7202
7058
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
7203
7059
|
return this;
|
|
7204
7060
|
}
|
|
7205
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
7061
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path18)) {
|
|
7206
7062
|
event = EVENTS.CHANGE;
|
|
7207
|
-
this._pendingUnlinks.delete(
|
|
7063
|
+
this._pendingUnlinks.delete(path18);
|
|
7208
7064
|
}
|
|
7209
7065
|
}
|
|
7210
7066
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -7222,16 +7078,16 @@ var init_chokidar = __esm({
|
|
|
7222
7078
|
this.emitWithAll(event, args);
|
|
7223
7079
|
}
|
|
7224
7080
|
};
|
|
7225
|
-
this._awaitWriteFinish(
|
|
7081
|
+
this._awaitWriteFinish(path18, awf.stabilityThreshold, event, awfEmit);
|
|
7226
7082
|
return this;
|
|
7227
7083
|
}
|
|
7228
7084
|
if (event === EVENTS.CHANGE) {
|
|
7229
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
7085
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path18, 50);
|
|
7230
7086
|
if (isThrottled)
|
|
7231
7087
|
return this;
|
|
7232
7088
|
}
|
|
7233
7089
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
7234
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
7090
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path18) : path18;
|
|
7235
7091
|
let stats2;
|
|
7236
7092
|
try {
|
|
7237
7093
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -7262,23 +7118,23 @@ var init_chokidar = __esm({
|
|
|
7262
7118
|
* @param timeout duration of time to suppress duplicate actions
|
|
7263
7119
|
* @returns tracking object or false if action should be suppressed
|
|
7264
7120
|
*/
|
|
7265
|
-
_throttle(actionType,
|
|
7121
|
+
_throttle(actionType, path18, timeout) {
|
|
7266
7122
|
if (!this._throttled.has(actionType)) {
|
|
7267
7123
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
7268
7124
|
}
|
|
7269
7125
|
const action = this._throttled.get(actionType);
|
|
7270
7126
|
if (!action)
|
|
7271
7127
|
throw new Error("invalid throttle");
|
|
7272
|
-
const actionPath = action.get(
|
|
7128
|
+
const actionPath = action.get(path18);
|
|
7273
7129
|
if (actionPath) {
|
|
7274
7130
|
actionPath.count++;
|
|
7275
7131
|
return false;
|
|
7276
7132
|
}
|
|
7277
7133
|
let timeoutObject;
|
|
7278
7134
|
const clear = () => {
|
|
7279
|
-
const item = action.get(
|
|
7135
|
+
const item = action.get(path18);
|
|
7280
7136
|
const count = item ? item.count : 0;
|
|
7281
|
-
action.delete(
|
|
7137
|
+
action.delete(path18);
|
|
7282
7138
|
clearTimeout(timeoutObject);
|
|
7283
7139
|
if (item)
|
|
7284
7140
|
clearTimeout(item.timeoutObject);
|
|
@@ -7286,7 +7142,7 @@ var init_chokidar = __esm({
|
|
|
7286
7142
|
};
|
|
7287
7143
|
timeoutObject = setTimeout(clear, timeout);
|
|
7288
7144
|
const thr = { timeoutObject, clear, count: 0 };
|
|
7289
|
-
action.set(
|
|
7145
|
+
action.set(path18, thr);
|
|
7290
7146
|
return thr;
|
|
7291
7147
|
}
|
|
7292
7148
|
_incrReadyCount() {
|
|
@@ -7300,44 +7156,44 @@ var init_chokidar = __esm({
|
|
|
7300
7156
|
* @param event
|
|
7301
7157
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
7302
7158
|
*/
|
|
7303
|
-
_awaitWriteFinish(
|
|
7159
|
+
_awaitWriteFinish(path18, threshold, event, awfEmit) {
|
|
7304
7160
|
const awf = this.options.awaitWriteFinish;
|
|
7305
7161
|
if (typeof awf !== "object")
|
|
7306
7162
|
return;
|
|
7307
7163
|
const pollInterval = awf.pollInterval;
|
|
7308
7164
|
let timeoutHandler;
|
|
7309
|
-
let fullPath =
|
|
7310
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
7311
|
-
fullPath = sp2.join(this.options.cwd,
|
|
7165
|
+
let fullPath = path18;
|
|
7166
|
+
if (this.options.cwd && !sp2.isAbsolute(path18)) {
|
|
7167
|
+
fullPath = sp2.join(this.options.cwd, path18);
|
|
7312
7168
|
}
|
|
7313
7169
|
const now = /* @__PURE__ */ new Date();
|
|
7314
7170
|
const writes = this._pendingWrites;
|
|
7315
7171
|
function awaitWriteFinishFn(prevStat) {
|
|
7316
7172
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
7317
|
-
if (err || !writes.has(
|
|
7173
|
+
if (err || !writes.has(path18)) {
|
|
7318
7174
|
if (err && err.code !== "ENOENT")
|
|
7319
7175
|
awfEmit(err);
|
|
7320
7176
|
return;
|
|
7321
7177
|
}
|
|
7322
7178
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
7323
7179
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
7324
|
-
writes.get(
|
|
7180
|
+
writes.get(path18).lastChange = now2;
|
|
7325
7181
|
}
|
|
7326
|
-
const pw = writes.get(
|
|
7182
|
+
const pw = writes.get(path18);
|
|
7327
7183
|
const df = now2 - pw.lastChange;
|
|
7328
7184
|
if (df >= threshold) {
|
|
7329
|
-
writes.delete(
|
|
7185
|
+
writes.delete(path18);
|
|
7330
7186
|
awfEmit(void 0, curStat);
|
|
7331
7187
|
} else {
|
|
7332
7188
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
7333
7189
|
}
|
|
7334
7190
|
});
|
|
7335
7191
|
}
|
|
7336
|
-
if (!writes.has(
|
|
7337
|
-
writes.set(
|
|
7192
|
+
if (!writes.has(path18)) {
|
|
7193
|
+
writes.set(path18, {
|
|
7338
7194
|
lastChange: now,
|
|
7339
7195
|
cancelWait: () => {
|
|
7340
|
-
writes.delete(
|
|
7196
|
+
writes.delete(path18);
|
|
7341
7197
|
clearTimeout(timeoutHandler);
|
|
7342
7198
|
return event;
|
|
7343
7199
|
}
|
|
@@ -7348,8 +7204,8 @@ var init_chokidar = __esm({
|
|
|
7348
7204
|
/**
|
|
7349
7205
|
* Determines whether user has asked to ignore this path.
|
|
7350
7206
|
*/
|
|
7351
|
-
_isIgnored(
|
|
7352
|
-
if (this.options.atomic && DOT_RE.test(
|
|
7207
|
+
_isIgnored(path18, stats) {
|
|
7208
|
+
if (this.options.atomic && DOT_RE.test(path18))
|
|
7353
7209
|
return true;
|
|
7354
7210
|
if (!this._userIgnored) {
|
|
7355
7211
|
const { cwd } = this.options;
|
|
@@ -7359,17 +7215,17 @@ var init_chokidar = __esm({
|
|
|
7359
7215
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
7360
7216
|
this._userIgnored = anymatch(list, void 0);
|
|
7361
7217
|
}
|
|
7362
|
-
return this._userIgnored(
|
|
7218
|
+
return this._userIgnored(path18, stats);
|
|
7363
7219
|
}
|
|
7364
|
-
_isntIgnored(
|
|
7365
|
-
return !this._isIgnored(
|
|
7220
|
+
_isntIgnored(path18, stat4) {
|
|
7221
|
+
return !this._isIgnored(path18, stat4);
|
|
7366
7222
|
}
|
|
7367
7223
|
/**
|
|
7368
7224
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
7369
7225
|
* @param path file or directory pattern being watched
|
|
7370
7226
|
*/
|
|
7371
|
-
_getWatchHelpers(
|
|
7372
|
-
return new WatchHelper(
|
|
7227
|
+
_getWatchHelpers(path18) {
|
|
7228
|
+
return new WatchHelper(path18, this.options.followSymlinks, this);
|
|
7373
7229
|
}
|
|
7374
7230
|
// Directory helpers
|
|
7375
7231
|
// -----------------
|
|
@@ -7401,63 +7257,63 @@ var init_chokidar = __esm({
|
|
|
7401
7257
|
* @param item base path of item/directory
|
|
7402
7258
|
*/
|
|
7403
7259
|
_remove(directory, item, isDirectory) {
|
|
7404
|
-
const
|
|
7405
|
-
const fullPath = sp2.resolve(
|
|
7406
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
7407
|
-
if (!this._throttle("remove",
|
|
7260
|
+
const path18 = sp2.join(directory, item);
|
|
7261
|
+
const fullPath = sp2.resolve(path18);
|
|
7262
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path18) || this._watched.has(fullPath);
|
|
7263
|
+
if (!this._throttle("remove", path18, 100))
|
|
7408
7264
|
return;
|
|
7409
7265
|
if (!isDirectory && this._watched.size === 1) {
|
|
7410
7266
|
this.add(directory, item, true);
|
|
7411
7267
|
}
|
|
7412
|
-
const wp = this._getWatchedDir(
|
|
7268
|
+
const wp = this._getWatchedDir(path18);
|
|
7413
7269
|
const nestedDirectoryChildren = wp.getChildren();
|
|
7414
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
7270
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path18, nested));
|
|
7415
7271
|
const parent = this._getWatchedDir(directory);
|
|
7416
7272
|
const wasTracked = parent.has(item);
|
|
7417
7273
|
parent.remove(item);
|
|
7418
7274
|
if (this._symlinkPaths.has(fullPath)) {
|
|
7419
7275
|
this._symlinkPaths.delete(fullPath);
|
|
7420
7276
|
}
|
|
7421
|
-
let relPath =
|
|
7277
|
+
let relPath = path18;
|
|
7422
7278
|
if (this.options.cwd)
|
|
7423
|
-
relPath = sp2.relative(this.options.cwd,
|
|
7279
|
+
relPath = sp2.relative(this.options.cwd, path18);
|
|
7424
7280
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
7425
7281
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
7426
7282
|
if (event === EVENTS.ADD)
|
|
7427
7283
|
return;
|
|
7428
7284
|
}
|
|
7429
|
-
this._watched.delete(
|
|
7285
|
+
this._watched.delete(path18);
|
|
7430
7286
|
this._watched.delete(fullPath);
|
|
7431
7287
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
7432
|
-
if (wasTracked && !this._isIgnored(
|
|
7433
|
-
this._emit(eventName,
|
|
7434
|
-
this._closePath(
|
|
7288
|
+
if (wasTracked && !this._isIgnored(path18))
|
|
7289
|
+
this._emit(eventName, path18);
|
|
7290
|
+
this._closePath(path18);
|
|
7435
7291
|
}
|
|
7436
7292
|
/**
|
|
7437
7293
|
* Closes all watchers for a path
|
|
7438
7294
|
*/
|
|
7439
|
-
_closePath(
|
|
7440
|
-
this._closeFile(
|
|
7441
|
-
const dir = sp2.dirname(
|
|
7442
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
7295
|
+
_closePath(path18) {
|
|
7296
|
+
this._closeFile(path18);
|
|
7297
|
+
const dir = sp2.dirname(path18);
|
|
7298
|
+
this._getWatchedDir(dir).remove(sp2.basename(path18));
|
|
7443
7299
|
}
|
|
7444
7300
|
/**
|
|
7445
7301
|
* Closes only file-specific watchers
|
|
7446
7302
|
*/
|
|
7447
|
-
_closeFile(
|
|
7448
|
-
const closers = this._closers.get(
|
|
7303
|
+
_closeFile(path18) {
|
|
7304
|
+
const closers = this._closers.get(path18);
|
|
7449
7305
|
if (!closers)
|
|
7450
7306
|
return;
|
|
7451
7307
|
closers.forEach((closer) => closer());
|
|
7452
|
-
this._closers.delete(
|
|
7308
|
+
this._closers.delete(path18);
|
|
7453
7309
|
}
|
|
7454
|
-
_addPathCloser(
|
|
7310
|
+
_addPathCloser(path18, closer) {
|
|
7455
7311
|
if (!closer)
|
|
7456
7312
|
return;
|
|
7457
|
-
let list = this._closers.get(
|
|
7313
|
+
let list = this._closers.get(path18);
|
|
7458
7314
|
if (!list) {
|
|
7459
7315
|
list = [];
|
|
7460
|
-
this._closers.set(
|
|
7316
|
+
this._closers.set(path18, list);
|
|
7461
7317
|
}
|
|
7462
7318
|
list.push(closer);
|
|
7463
7319
|
}
|
|
@@ -7483,12 +7339,12 @@ var init_chokidar = __esm({
|
|
|
7483
7339
|
});
|
|
7484
7340
|
|
|
7485
7341
|
// ../../oss/packages/daemon-core/src/providers/provider-loader.ts
|
|
7486
|
-
var fs5,
|
|
7342
|
+
var fs5, path6, os7, ProviderLoader;
|
|
7487
7343
|
var init_provider_loader = __esm({
|
|
7488
7344
|
"../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
|
|
7489
7345
|
"use strict";
|
|
7490
7346
|
fs5 = __toESM(require("fs"));
|
|
7491
|
-
|
|
7347
|
+
path6 = __toESM(require("path"));
|
|
7492
7348
|
os7 = __toESM(require("os"));
|
|
7493
7349
|
init_chokidar();
|
|
7494
7350
|
init_ide_detector();
|
|
@@ -7510,12 +7366,12 @@ var init_provider_loader = __esm({
|
|
|
7510
7366
|
static META_FILE = ".meta.json";
|
|
7511
7367
|
constructor(options) {
|
|
7512
7368
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
7513
|
-
const defaultProvidersDir =
|
|
7369
|
+
const defaultProvidersDir = path6.join(os7.homedir(), ".adhdev", "providers");
|
|
7514
7370
|
if (options?.userDir) {
|
|
7515
7371
|
this.userDir = options.userDir;
|
|
7516
7372
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
7517
7373
|
} else {
|
|
7518
|
-
const localRepoPath =
|
|
7374
|
+
const localRepoPath = path6.resolve(__dirname, "../../../../../adhdev-providers");
|
|
7519
7375
|
if (fs5.existsSync(localRepoPath)) {
|
|
7520
7376
|
this.userDir = localRepoPath;
|
|
7521
7377
|
this.log(`Auto-detected local public repository: ${this.userDir} (Dev workspace speedup)`);
|
|
@@ -7524,7 +7380,7 @@ var init_provider_loader = __esm({
|
|
|
7524
7380
|
this.log(`Using default user providers directory: ${this.userDir}`);
|
|
7525
7381
|
}
|
|
7526
7382
|
}
|
|
7527
|
-
this.upstreamDir =
|
|
7383
|
+
this.upstreamDir = path6.join(defaultProvidersDir, ".upstream");
|
|
7528
7384
|
this.disableUpstream = options?.disableUpstream ?? false;
|
|
7529
7385
|
}
|
|
7530
7386
|
log(msg) {
|
|
@@ -7554,7 +7410,7 @@ var init_provider_loader = __esm({
|
|
|
7554
7410
|
* Canonical provider directory shape for a given root.
|
|
7555
7411
|
*/
|
|
7556
7412
|
getProviderDir(root, category, type) {
|
|
7557
|
-
return
|
|
7413
|
+
return path6.join(root, category, type);
|
|
7558
7414
|
}
|
|
7559
7415
|
/**
|
|
7560
7416
|
* Canonical user override directory for a provider.
|
|
@@ -7581,7 +7437,7 @@ var init_provider_loader = __esm({
|
|
|
7581
7437
|
resolveProviderFile(type, ...segments) {
|
|
7582
7438
|
const dir = this.findProviderDirInternal(type);
|
|
7583
7439
|
if (!dir) return null;
|
|
7584
|
-
return
|
|
7440
|
+
return path6.join(dir, ...segments);
|
|
7585
7441
|
}
|
|
7586
7442
|
/**
|
|
7587
7443
|
* Load all providers (3-tier priority)
|
|
@@ -7619,7 +7475,7 @@ var init_provider_loader = __esm({
|
|
|
7619
7475
|
if (!fs5.existsSync(this.upstreamDir)) return false;
|
|
7620
7476
|
try {
|
|
7621
7477
|
return fs5.readdirSync(this.upstreamDir).some(
|
|
7622
|
-
(d) => fs5.statSync(
|
|
7478
|
+
(d) => fs5.statSync(path6.join(this.upstreamDir, d)).isDirectory()
|
|
7623
7479
|
);
|
|
7624
7480
|
} catch {
|
|
7625
7481
|
return false;
|
|
@@ -7704,16 +7560,23 @@ var init_provider_loader = __esm({
|
|
|
7704
7560
|
isEnabled(type, ideType) {
|
|
7705
7561
|
if (!ideType) return true;
|
|
7706
7562
|
try {
|
|
7707
|
-
|
|
7708
|
-
const config2 = loadConfig2();
|
|
7709
|
-
const baseIdeType = ideType.split("_")[0];
|
|
7710
|
-
const val = config2.ideSettings?.[baseIdeType]?.extensions?.[type]?.enabled;
|
|
7711
|
-
return val === true;
|
|
7563
|
+
return this.getIdeExtensionEnabledState(ideType, type);
|
|
7712
7564
|
} catch {
|
|
7713
7565
|
return false;
|
|
7714
7566
|
}
|
|
7715
7567
|
}
|
|
7716
7568
|
/**
|
|
7569
|
+
* Resolve per-IDE extension enabled state using the same normalization
|
|
7570
|
+
* that runtime attach/remove uses.
|
|
7571
|
+
*/
|
|
7572
|
+
getIdeExtensionEnabledState(ideType, extensionType) {
|
|
7573
|
+
const { loadConfig: loadConfig2 } = (init_config(), __toCommonJS(config_exports));
|
|
7574
|
+
const config2 = loadConfig2();
|
|
7575
|
+
const baseIdeType = ideType.split("_")[0];
|
|
7576
|
+
const val = config2.ideSettings?.[baseIdeType]?.extensions?.[extensionType]?.enabled;
|
|
7577
|
+
return val === true;
|
|
7578
|
+
}
|
|
7579
|
+
/**
|
|
7717
7580
|
* Save IDE extension enabled setting
|
|
7718
7581
|
*/
|
|
7719
7582
|
setIdeExtensionEnabled(ideType, extensionType, enabled) {
|
|
@@ -7911,14 +7774,14 @@ var init_provider_loader = __esm({
|
|
|
7911
7774
|
this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
|
|
7912
7775
|
return null;
|
|
7913
7776
|
}
|
|
7914
|
-
const dir =
|
|
7777
|
+
const dir = path6.join(providerDir, scriptDir);
|
|
7915
7778
|
if (!fs5.existsSync(dir)) {
|
|
7916
7779
|
this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
7917
7780
|
return null;
|
|
7918
7781
|
}
|
|
7919
7782
|
const cached2 = this.scriptsCache.get(dir);
|
|
7920
7783
|
if (cached2) return cached2;
|
|
7921
|
-
const scriptsJs =
|
|
7784
|
+
const scriptsJs = path6.join(dir, "scripts.js");
|
|
7922
7785
|
if (fs5.existsSync(scriptsJs)) {
|
|
7923
7786
|
try {
|
|
7924
7787
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -7957,7 +7820,7 @@ var init_provider_loader = __esm({
|
|
|
7957
7820
|
});
|
|
7958
7821
|
const handleChange = (filePath) => {
|
|
7959
7822
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
7960
|
-
this.log(`File changed: ${
|
|
7823
|
+
this.log(`File changed: ${path6.basename(filePath)}, reloading...`);
|
|
7961
7824
|
this.reload();
|
|
7962
7825
|
}
|
|
7963
7826
|
};
|
|
@@ -8012,7 +7875,7 @@ var init_provider_loader = __esm({
|
|
|
8012
7875
|
}
|
|
8013
7876
|
const https = require("https");
|
|
8014
7877
|
const { execSync: execSync7 } = require("child_process");
|
|
8015
|
-
const metaPath =
|
|
7878
|
+
const metaPath = path6.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
8016
7879
|
let prevEtag = "";
|
|
8017
7880
|
let prevTimestamp = 0;
|
|
8018
7881
|
try {
|
|
@@ -8029,7 +7892,7 @@ var init_provider_loader = __esm({
|
|
|
8029
7892
|
return { updated: false };
|
|
8030
7893
|
}
|
|
8031
7894
|
try {
|
|
8032
|
-
const etag = await new Promise((
|
|
7895
|
+
const etag = await new Promise((resolve12, reject) => {
|
|
8033
7896
|
const options = {
|
|
8034
7897
|
method: "HEAD",
|
|
8035
7898
|
hostname: "github.com",
|
|
@@ -8047,7 +7910,7 @@ var init_provider_loader = __esm({
|
|
|
8047
7910
|
headers: { "User-Agent": "adhdev-launcher" },
|
|
8048
7911
|
timeout: 1e4
|
|
8049
7912
|
}, (res2) => {
|
|
8050
|
-
|
|
7913
|
+
resolve12(res2.headers.etag || res2.headers["last-modified"] || "");
|
|
8051
7914
|
});
|
|
8052
7915
|
req2.on("error", reject);
|
|
8053
7916
|
req2.on("timeout", () => {
|
|
@@ -8056,7 +7919,7 @@ var init_provider_loader = __esm({
|
|
|
8056
7919
|
});
|
|
8057
7920
|
req2.end();
|
|
8058
7921
|
} else {
|
|
8059
|
-
|
|
7922
|
+
resolve12(res.headers.etag || res.headers["last-modified"] || "");
|
|
8060
7923
|
}
|
|
8061
7924
|
});
|
|
8062
7925
|
req.on("error", reject);
|
|
@@ -8072,17 +7935,17 @@ var init_provider_loader = __esm({
|
|
|
8072
7935
|
return { updated: false };
|
|
8073
7936
|
}
|
|
8074
7937
|
this.log("Downloading latest providers from GitHub...");
|
|
8075
|
-
const tmpTar =
|
|
8076
|
-
const tmpExtract =
|
|
7938
|
+
const tmpTar = path6.join(os7.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
7939
|
+
const tmpExtract = path6.join(os7.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
8077
7940
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
8078
7941
|
fs5.mkdirSync(tmpExtract, { recursive: true });
|
|
8079
7942
|
execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
8080
7943
|
const extracted = fs5.readdirSync(tmpExtract);
|
|
8081
7944
|
const rootDir = extracted.find(
|
|
8082
|
-
(d) => fs5.statSync(
|
|
7945
|
+
(d) => fs5.statSync(path6.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
8083
7946
|
);
|
|
8084
7947
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
8085
|
-
const sourceDir =
|
|
7948
|
+
const sourceDir = path6.join(tmpExtract, rootDir);
|
|
8086
7949
|
const backupDir = this.upstreamDir + ".bak";
|
|
8087
7950
|
if (fs5.existsSync(this.upstreamDir)) {
|
|
8088
7951
|
if (fs5.existsSync(backupDir)) fs5.rmSync(backupDir, { recursive: true, force: true });
|
|
@@ -8120,7 +7983,7 @@ var init_provider_loader = __esm({
|
|
|
8120
7983
|
downloadFile(url2, destPath) {
|
|
8121
7984
|
const https = require("https");
|
|
8122
7985
|
const http3 = require("http");
|
|
8123
|
-
return new Promise((
|
|
7986
|
+
return new Promise((resolve12, reject) => {
|
|
8124
7987
|
const doRequest = (reqUrl, redirectCount = 0) => {
|
|
8125
7988
|
if (redirectCount > 5) {
|
|
8126
7989
|
reject(new Error("Too many redirects"));
|
|
@@ -8140,7 +8003,7 @@ var init_provider_loader = __esm({
|
|
|
8140
8003
|
res.pipe(ws2);
|
|
8141
8004
|
ws2.on("finish", () => {
|
|
8142
8005
|
ws2.close();
|
|
8143
|
-
|
|
8006
|
+
resolve12();
|
|
8144
8007
|
});
|
|
8145
8008
|
ws2.on("error", reject);
|
|
8146
8009
|
});
|
|
@@ -8157,8 +8020,8 @@ var init_provider_loader = __esm({
|
|
|
8157
8020
|
copyDirRecursive(src, dest) {
|
|
8158
8021
|
fs5.mkdirSync(dest, { recursive: true });
|
|
8159
8022
|
for (const entry of fs5.readdirSync(src, { withFileTypes: true })) {
|
|
8160
|
-
const srcPath =
|
|
8161
|
-
const destPath =
|
|
8023
|
+
const srcPath = path6.join(src, entry.name);
|
|
8024
|
+
const destPath = path6.join(dest, entry.name);
|
|
8162
8025
|
if (entry.isDirectory()) {
|
|
8163
8026
|
this.copyDirRecursive(srcPath, destPath);
|
|
8164
8027
|
} else {
|
|
@@ -8169,7 +8032,7 @@ var init_provider_loader = __esm({
|
|
|
8169
8032
|
/** .meta.json save */
|
|
8170
8033
|
writeMeta(metaPath, etag, timestamp) {
|
|
8171
8034
|
try {
|
|
8172
|
-
fs5.mkdirSync(
|
|
8035
|
+
fs5.mkdirSync(path6.dirname(metaPath), { recursive: true });
|
|
8173
8036
|
fs5.writeFileSync(metaPath, JSON.stringify({
|
|
8174
8037
|
etag,
|
|
8175
8038
|
timestamp,
|
|
@@ -8186,7 +8049,7 @@ var init_provider_loader = __esm({
|
|
|
8186
8049
|
const scan = (d) => {
|
|
8187
8050
|
try {
|
|
8188
8051
|
for (const entry of fs5.readdirSync(d, { withFileTypes: true })) {
|
|
8189
|
-
if (entry.isDirectory()) scan(
|
|
8052
|
+
if (entry.isDirectory()) scan(path6.join(d, entry.name));
|
|
8190
8053
|
else if (entry.name === "provider.json") count++;
|
|
8191
8054
|
}
|
|
8192
8055
|
} catch {
|
|
@@ -8285,17 +8148,17 @@ var init_provider_loader = __esm({
|
|
|
8285
8148
|
for (const root of searchRoots) {
|
|
8286
8149
|
if (!fs5.existsSync(root)) continue;
|
|
8287
8150
|
const candidate = this.getProviderDir(root, cat, type);
|
|
8288
|
-
if (fs5.existsSync(
|
|
8289
|
-
const catDir =
|
|
8151
|
+
if (fs5.existsSync(path6.join(candidate, "provider.json"))) return candidate;
|
|
8152
|
+
const catDir = path6.join(root, cat);
|
|
8290
8153
|
if (fs5.existsSync(catDir)) {
|
|
8291
8154
|
try {
|
|
8292
8155
|
for (const entry of fs5.readdirSync(catDir, { withFileTypes: true })) {
|
|
8293
8156
|
if (!entry.isDirectory()) continue;
|
|
8294
|
-
const jsonPath =
|
|
8157
|
+
const jsonPath = path6.join(catDir, entry.name, "provider.json");
|
|
8295
8158
|
if (fs5.existsSync(jsonPath)) {
|
|
8296
8159
|
try {
|
|
8297
8160
|
const data = JSON.parse(fs5.readFileSync(jsonPath, "utf-8"));
|
|
8298
|
-
if (data.type === type) return
|
|
8161
|
+
if (data.type === type) return path6.join(catDir, entry.name);
|
|
8299
8162
|
} catch {
|
|
8300
8163
|
}
|
|
8301
8164
|
}
|
|
@@ -8312,7 +8175,7 @@ var init_provider_loader = __esm({
|
|
|
8312
8175
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
8313
8176
|
*/
|
|
8314
8177
|
buildScriptWrappersFromDir(dir) {
|
|
8315
|
-
const scriptsJs =
|
|
8178
|
+
const scriptsJs = path6.join(dir, "scripts.js");
|
|
8316
8179
|
if (fs5.existsSync(scriptsJs)) {
|
|
8317
8180
|
try {
|
|
8318
8181
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -8326,7 +8189,7 @@ var init_provider_loader = __esm({
|
|
|
8326
8189
|
for (const file2 of fs5.readdirSync(dir)) {
|
|
8327
8190
|
if (!file2.endsWith(".js")) continue;
|
|
8328
8191
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
8329
|
-
const filePath =
|
|
8192
|
+
const filePath = path6.join(dir, file2);
|
|
8330
8193
|
result[scriptName] = (...args) => {
|
|
8331
8194
|
try {
|
|
8332
8195
|
let content = fs5.readFileSync(filePath, "utf-8");
|
|
@@ -8386,7 +8249,7 @@ var init_provider_loader = __esm({
|
|
|
8386
8249
|
}
|
|
8387
8250
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
8388
8251
|
if (hasJson) {
|
|
8389
|
-
const jsonPath =
|
|
8252
|
+
const jsonPath = path6.join(d, "provider.json");
|
|
8390
8253
|
try {
|
|
8391
8254
|
const raw = fs5.readFileSync(jsonPath, "utf-8");
|
|
8392
8255
|
const mod = JSON.parse(raw);
|
|
@@ -8399,7 +8262,7 @@ var init_provider_loader = __esm({
|
|
|
8399
8262
|
delete mod.extensionIdPattern_flags;
|
|
8400
8263
|
}
|
|
8401
8264
|
const hasCompatibility = Array.isArray(mod.compatibility);
|
|
8402
|
-
const scriptsPath =
|
|
8265
|
+
const scriptsPath = path6.join(d, "scripts.js");
|
|
8403
8266
|
if (!hasCompatibility && fs5.existsSync(scriptsPath)) {
|
|
8404
8267
|
try {
|
|
8405
8268
|
delete require.cache[require.resolve(scriptsPath)];
|
|
@@ -8425,7 +8288,7 @@ var init_provider_loader = __esm({
|
|
|
8425
8288
|
if (!entry.isDirectory()) continue;
|
|
8426
8289
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
8427
8290
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
8428
|
-
scan(
|
|
8291
|
+
scan(path6.join(d, entry.name));
|
|
8429
8292
|
}
|
|
8430
8293
|
}
|
|
8431
8294
|
};
|
|
@@ -8506,17 +8369,17 @@ async function findFreePort(ports) {
|
|
|
8506
8369
|
throw new Error("No free port found");
|
|
8507
8370
|
}
|
|
8508
8371
|
function checkPortFree(port) {
|
|
8509
|
-
return new Promise((
|
|
8372
|
+
return new Promise((resolve12) => {
|
|
8510
8373
|
const server = net.createServer();
|
|
8511
8374
|
server.unref();
|
|
8512
|
-
server.on("error", () =>
|
|
8375
|
+
server.on("error", () => resolve12(false));
|
|
8513
8376
|
server.listen(port, "127.0.0.1", () => {
|
|
8514
|
-
server.close(() =>
|
|
8377
|
+
server.close(() => resolve12(true));
|
|
8515
8378
|
});
|
|
8516
8379
|
});
|
|
8517
8380
|
}
|
|
8518
8381
|
async function isCdpActive(port) {
|
|
8519
|
-
return new Promise((
|
|
8382
|
+
return new Promise((resolve12) => {
|
|
8520
8383
|
const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
|
|
8521
8384
|
timeout: 2e3
|
|
8522
8385
|
}, (res) => {
|
|
@@ -8525,16 +8388,16 @@ async function isCdpActive(port) {
|
|
|
8525
8388
|
res.on("end", () => {
|
|
8526
8389
|
try {
|
|
8527
8390
|
const info = JSON.parse(data);
|
|
8528
|
-
|
|
8391
|
+
resolve12(!!info["WebKit-Version"] || !!info["Browser"]);
|
|
8529
8392
|
} catch {
|
|
8530
|
-
|
|
8393
|
+
resolve12(false);
|
|
8531
8394
|
}
|
|
8532
8395
|
});
|
|
8533
8396
|
});
|
|
8534
|
-
req.on("error", () =>
|
|
8397
|
+
req.on("error", () => resolve12(false));
|
|
8535
8398
|
req.on("timeout", () => {
|
|
8536
8399
|
req.destroy();
|
|
8537
|
-
|
|
8400
|
+
resolve12(false);
|
|
8538
8401
|
});
|
|
8539
8402
|
});
|
|
8540
8403
|
}
|
|
@@ -8653,8 +8516,8 @@ function detectCurrentWorkspace(ideId) {
|
|
|
8653
8516
|
const appNameMap = getMacAppIdentifiers();
|
|
8654
8517
|
const appName = appNameMap[ideId];
|
|
8655
8518
|
if (appName) {
|
|
8656
|
-
const storagePath =
|
|
8657
|
-
process.env.APPDATA ||
|
|
8519
|
+
const storagePath = path7.join(
|
|
8520
|
+
process.env.APPDATA || path7.join(os8.homedir(), "AppData", "Roaming"),
|
|
8658
8521
|
appName,
|
|
8659
8522
|
"storage.json"
|
|
8660
8523
|
);
|
|
@@ -8820,14 +8683,14 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
8820
8683
|
function getAvailableIdeIds() {
|
|
8821
8684
|
return getProviderLoader().getAvailableIdeTypes();
|
|
8822
8685
|
}
|
|
8823
|
-
var import_child_process4, net, os8,
|
|
8686
|
+
var import_child_process4, net, os8, path7, _providerLoader;
|
|
8824
8687
|
var init_launch = __esm({
|
|
8825
8688
|
"../../oss/packages/daemon-core/src/launch.ts"() {
|
|
8826
8689
|
"use strict";
|
|
8827
8690
|
import_child_process4 = require("child_process");
|
|
8828
8691
|
net = __toESM(require("net"));
|
|
8829
8692
|
os8 = __toESM(require("os"));
|
|
8830
|
-
|
|
8693
|
+
path7 = __toESM(require("path"));
|
|
8831
8694
|
init_ide_detector();
|
|
8832
8695
|
init_provider_loader();
|
|
8833
8696
|
_providerLoader = null;
|
|
@@ -8858,7 +8721,7 @@ function checkRotation() {
|
|
|
8858
8721
|
const today = getDateStr2();
|
|
8859
8722
|
if (today !== currentDate2) {
|
|
8860
8723
|
currentDate2 = today;
|
|
8861
|
-
currentFile =
|
|
8724
|
+
currentFile = path8.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
8862
8725
|
cleanOldFiles();
|
|
8863
8726
|
}
|
|
8864
8727
|
}
|
|
@@ -8872,7 +8735,7 @@ function cleanOldFiles() {
|
|
|
8872
8735
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
8873
8736
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
8874
8737
|
try {
|
|
8875
|
-
fs6.unlinkSync(
|
|
8738
|
+
fs6.unlinkSync(path8.join(LOG_DIR2, file2));
|
|
8876
8739
|
} catch {
|
|
8877
8740
|
}
|
|
8878
8741
|
}
|
|
@@ -8939,14 +8802,14 @@ function getRecentCommands(count = 50) {
|
|
|
8939
8802
|
return [];
|
|
8940
8803
|
}
|
|
8941
8804
|
}
|
|
8942
|
-
var fs6,
|
|
8805
|
+
var fs6, path8, os9, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
|
|
8943
8806
|
var init_command_log = __esm({
|
|
8944
8807
|
"../../oss/packages/daemon-core/src/logging/command-log.ts"() {
|
|
8945
8808
|
"use strict";
|
|
8946
8809
|
fs6 = __toESM(require("fs"));
|
|
8947
|
-
|
|
8810
|
+
path8 = __toESM(require("path"));
|
|
8948
8811
|
os9 = __toESM(require("os"));
|
|
8949
|
-
LOG_DIR2 = process.platform === "win32" ?
|
|
8812
|
+
LOG_DIR2 = process.platform === "win32" ? path8.join(process.env.LOCALAPPDATA || process.env.APPDATA || path8.join(os9.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path8.join(os9.homedir(), "Library", "Logs", "adhdev") : path8.join(os9.homedir(), ".local", "share", "adhdev", "logs");
|
|
8950
8813
|
MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
8951
8814
|
MAX_DAYS = 7;
|
|
8952
8815
|
try {
|
|
@@ -8965,7 +8828,7 @@ var init_command_log = __esm({
|
|
|
8965
8828
|
"text"
|
|
8966
8829
|
]);
|
|
8967
8830
|
currentDate2 = getDateStr2();
|
|
8968
|
-
currentFile =
|
|
8831
|
+
currentFile = path8.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
8969
8832
|
writeCount2 = 0;
|
|
8970
8833
|
SKIP_COMMANDS = /* @__PURE__ */ new Set([
|
|
8971
8834
|
"heartbeat",
|
|
@@ -8985,8 +8848,6 @@ var init_router = __esm({
|
|
|
8985
8848
|
init_launch();
|
|
8986
8849
|
init_config();
|
|
8987
8850
|
init_workspaces();
|
|
8988
|
-
init_workspace_activity();
|
|
8989
|
-
init_config();
|
|
8990
8851
|
init_recent_activity();
|
|
8991
8852
|
init_ide_detector();
|
|
8992
8853
|
init_logger();
|
|
@@ -9118,18 +8979,6 @@ var init_router = __esm({
|
|
|
9118
8979
|
};
|
|
9119
8980
|
LOG.info("LaunchIDE", `target=${ideKey || "auto"}`);
|
|
9120
8981
|
const result = await launchWithCdp(launchArgs);
|
|
9121
|
-
if (result.success && (result.ideId || ideKey)) {
|
|
9122
|
-
try {
|
|
9123
|
-
addCliHistory({
|
|
9124
|
-
category: "ide",
|
|
9125
|
-
cliType: result.ideId || ideKey,
|
|
9126
|
-
dir: resolvedWorkspace || "",
|
|
9127
|
-
workspace: resolvedWorkspace || "",
|
|
9128
|
-
newWindow: args?.newWindow === true
|
|
9129
|
-
});
|
|
9130
|
-
} catch {
|
|
9131
|
-
}
|
|
9132
|
-
}
|
|
9133
8982
|
if (result.success && result.port && result.ideId && !this.deps.cdpManagers.has(result.ideId)) {
|
|
9134
8983
|
const logFn = this.deps.getCdpLogFn ? this.deps.getCdpLogFn(result.ideId) : LOG.forComponent(`CDP:${result.ideId}`).asLogFn();
|
|
9135
8984
|
const provider = this.deps.providerLoader.getMeta(result.ideId);
|
|
@@ -9146,11 +8995,7 @@ var init_router = __esm({
|
|
|
9146
8995
|
this.deps.onIdeConnected?.();
|
|
9147
8996
|
if (result.success && resolvedWorkspace) {
|
|
9148
8997
|
try {
|
|
9149
|
-
|
|
9150
|
-
kind: "ide",
|
|
9151
|
-
agentType: result.ideId
|
|
9152
|
-
});
|
|
9153
|
-
next = appendRecentActivity(next, {
|
|
8998
|
+
const next = appendRecentActivity(loadConfig(), {
|
|
9154
8999
|
kind: "ide",
|
|
9155
9000
|
providerType: result.ideId || ideKey,
|
|
9156
9001
|
providerName: result.ideId || ideKey,
|
|
@@ -9228,9 +9073,9 @@ var init_router = __esm({
|
|
|
9228
9073
|
setTimeout(() => {
|
|
9229
9074
|
LOG.info("Upgrade", "Restarting daemon with new version...");
|
|
9230
9075
|
try {
|
|
9231
|
-
const
|
|
9076
|
+
const path18 = require("path");
|
|
9232
9077
|
const fs16 = require("fs");
|
|
9233
|
-
const pidFile =
|
|
9078
|
+
const pidFile = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
|
|
9234
9079
|
if (fs16.existsSync(pidFile)) fs16.unlinkSync(pidFile);
|
|
9235
9080
|
} catch {
|
|
9236
9081
|
}
|
|
@@ -18717,7 +18562,9 @@ function getUnreadState(hasContentChange, status, lastUsedAt, lastSeenAt, lastRo
|
|
|
18717
18562
|
return { unread, inboxBucket: unread ? "task_complete" : "idle" };
|
|
18718
18563
|
}
|
|
18719
18564
|
function buildRecentSessions(sessions, recentActivity, readState) {
|
|
18720
|
-
const
|
|
18565
|
+
const visibleKeys = /* @__PURE__ */ new Set();
|
|
18566
|
+
const hiddenKeys = /* @__PURE__ */ new Set();
|
|
18567
|
+
const live = sessions.filter((session) => !session.surfaceHidden && session.status !== "stopped").map((session) => {
|
|
18721
18568
|
const kind = getSessionKind(session);
|
|
18722
18569
|
const recentKey = buildRecentActivityKey({
|
|
18723
18570
|
kind,
|
|
@@ -18747,11 +18594,21 @@ function buildRecentSessions(sessions, recentActivity, readState) {
|
|
|
18747
18594
|
lastUsedAt,
|
|
18748
18595
|
unread,
|
|
18749
18596
|
lastSeenAt,
|
|
18750
|
-
inboxBucket
|
|
18597
|
+
inboxBucket,
|
|
18598
|
+
surfaceHidden: false
|
|
18751
18599
|
};
|
|
18752
18600
|
});
|
|
18753
|
-
const
|
|
18754
|
-
|
|
18601
|
+
for (const item of live) {
|
|
18602
|
+
visibleKeys.add(`${item.kind}:${item.providerType}:${item.workspace || ""}`);
|
|
18603
|
+
}
|
|
18604
|
+
for (const session of sessions) {
|
|
18605
|
+
if (!session.surfaceHidden) continue;
|
|
18606
|
+
hiddenKeys.add(`${getSessionKind(session)}:${session.providerType}:${session.workspace || ""}`);
|
|
18607
|
+
}
|
|
18608
|
+
const persisted = recentActivity.filter((item) => {
|
|
18609
|
+
const key = `${item.kind}:${item.providerType}:${item.workspace || ""}`;
|
|
18610
|
+
return !visibleKeys.has(key) && !hiddenKeys.has(key);
|
|
18611
|
+
}).map((item) => {
|
|
18755
18612
|
const lastSeenAt = readState[item.id] || 0;
|
|
18756
18613
|
const unread = item.lastUsedAt > lastSeenAt;
|
|
18757
18614
|
return {
|
|
@@ -18767,7 +18624,8 @@ function buildRecentSessions(sessions, recentActivity, readState) {
|
|
|
18767
18624
|
lastUsedAt: item.lastUsedAt,
|
|
18768
18625
|
unread,
|
|
18769
18626
|
lastSeenAt,
|
|
18770
|
-
inboxBucket: unread ? "task_complete" : "idle"
|
|
18627
|
+
inboxBucket: unread ? "task_complete" : "idle",
|
|
18628
|
+
surfaceHidden: false
|
|
18771
18629
|
};
|
|
18772
18630
|
});
|
|
18773
18631
|
return [...live, ...persisted].sort((a, b2) => b2.lastUsedAt - a.lastUsedAt).slice(0, 12);
|
|
@@ -18791,7 +18649,7 @@ function buildStatusSnapshot(options) {
|
|
|
18791
18649
|
});
|
|
18792
18650
|
const lastSeenAt = getRecentSessionSeenAt(cfg, recentKey);
|
|
18793
18651
|
const lastUsedAt = getSessionLastUsedAt(session);
|
|
18794
|
-
const { unread, inboxBucket } = getUnreadState(
|
|
18652
|
+
const { unread, inboxBucket } = session.surfaceHidden ? { unread: false, inboxBucket: "idle" } : getUnreadState(
|
|
18795
18653
|
getSessionMessageUpdatedAt(session) > 0,
|
|
18796
18654
|
session.status,
|
|
18797
18655
|
lastUsedAt,
|
|
@@ -18828,7 +18686,6 @@ function buildStatusSnapshot(options) {
|
|
|
18828
18686
|
workspaces: wsState.workspaces,
|
|
18829
18687
|
defaultWorkspaceId: wsState.defaultWorkspaceId,
|
|
18830
18688
|
defaultWorkspacePath: wsState.defaultWorkspacePath,
|
|
18831
|
-
workspaceActivity: getWorkspaceActivity(cfg, 15),
|
|
18832
18689
|
recentSessions: buildRecentSessions(sessions, recentActivity, readState),
|
|
18833
18690
|
terminalBackend,
|
|
18834
18691
|
availableProviders: buildAvailableProviders(options.providerLoader)
|
|
@@ -18842,7 +18699,6 @@ var init_snapshot = __esm({
|
|
|
18842
18699
|
init_config();
|
|
18843
18700
|
init_recent_activity();
|
|
18844
18701
|
init_workspaces();
|
|
18845
|
-
init_workspace_activity();
|
|
18846
18702
|
init_host_memory();
|
|
18847
18703
|
init_terminal_screen();
|
|
18848
18704
|
init_builders();
|
|
@@ -19008,6 +18864,7 @@ var init_reporter = __esm({
|
|
|
19008
18864
|
unread: session.unread,
|
|
19009
18865
|
lastSeenAt: session.lastSeenAt,
|
|
19010
18866
|
inboxBucket: session.inboxBucket,
|
|
18867
|
+
surfaceHidden: session.surfaceHidden,
|
|
19011
18868
|
controlValues: session.controlValues,
|
|
19012
18869
|
providerControls: session.providerControls,
|
|
19013
18870
|
acpConfigOptions: session.acpConfigOptions,
|
|
@@ -19125,7 +18982,7 @@ function findBinary(name) {
|
|
|
19125
18982
|
}
|
|
19126
18983
|
}
|
|
19127
18984
|
function isScriptBinary(binaryPath) {
|
|
19128
|
-
if (!
|
|
18985
|
+
if (!path9.isAbsolute(binaryPath)) return false;
|
|
19129
18986
|
try {
|
|
19130
18987
|
const fs16 = require("fs");
|
|
19131
18988
|
const resolved = fs16.realpathSync(binaryPath);
|
|
@@ -19141,7 +18998,7 @@ function isScriptBinary(binaryPath) {
|
|
|
19141
18998
|
}
|
|
19142
18999
|
}
|
|
19143
19000
|
function looksLikeMachOOrElf(filePath) {
|
|
19144
|
-
if (!
|
|
19001
|
+
if (!path9.isAbsolute(filePath)) return false;
|
|
19145
19002
|
try {
|
|
19146
19003
|
const fs16 = require("fs");
|
|
19147
19004
|
const resolved = fs16.realpathSync(filePath);
|
|
@@ -19255,12 +19112,12 @@ function normalizeCliProviderForRuntime(raw) {
|
|
|
19255
19112
|
}
|
|
19256
19113
|
};
|
|
19257
19114
|
}
|
|
19258
|
-
var os13,
|
|
19115
|
+
var os13, path9, import_child_process5, pty2, ProviderCliAdapter;
|
|
19259
19116
|
var init_provider_cli_adapter = __esm({
|
|
19260
19117
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
|
|
19261
19118
|
"use strict";
|
|
19262
19119
|
os13 = __toESM(require("os"));
|
|
19263
|
-
|
|
19120
|
+
path9 = __toESM(require("path"));
|
|
19264
19121
|
import_child_process5 = require("child_process");
|
|
19265
19122
|
init_logger();
|
|
19266
19123
|
init_terminal_screen();
|
|
@@ -19270,9 +19127,9 @@ var init_provider_cli_adapter = __esm({
|
|
|
19270
19127
|
if (os13.platform() !== "win32") {
|
|
19271
19128
|
try {
|
|
19272
19129
|
const fs16 = require("fs");
|
|
19273
|
-
const ptyDir =
|
|
19130
|
+
const ptyDir = path9.resolve(path9.dirname(require.resolve("node-pty")), "..");
|
|
19274
19131
|
const platformArch = `${os13.platform()}-${os13.arch()}`;
|
|
19275
|
-
const helper =
|
|
19132
|
+
const helper = path9.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
19276
19133
|
if (fs16.existsSync(helper)) {
|
|
19277
19134
|
const stat4 = fs16.statSync(helper);
|
|
19278
19135
|
if (!(stat4.mode & 73)) {
|
|
@@ -19461,7 +19318,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
19461
19318
|
LOG.info("CLI", `[${this.cliType}] Spawning in ${this.workingDir}`);
|
|
19462
19319
|
let shellCmd;
|
|
19463
19320
|
let shellArgs;
|
|
19464
|
-
const useShellUnix = !isWin && (!!spawnConfig.shell || !
|
|
19321
|
+
const useShellUnix = !isWin && (!!spawnConfig.shell || !path9.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
19465
19322
|
const useShell = isWin ? !!spawnConfig.shell : useShellUnix;
|
|
19466
19323
|
if (useShell) {
|
|
19467
19324
|
if (!spawnConfig.shell && !isWin) {
|
|
@@ -19886,7 +19743,7 @@ ${data.message || ""}`.trim();
|
|
|
19886
19743
|
if (this.startupParseGate) {
|
|
19887
19744
|
const deadline = Date.now() + 1e4;
|
|
19888
19745
|
while (this.startupParseGate && Date.now() < deadline) {
|
|
19889
|
-
await new Promise((
|
|
19746
|
+
await new Promise((resolve12) => setTimeout(resolve12, 50));
|
|
19890
19747
|
}
|
|
19891
19748
|
}
|
|
19892
19749
|
if (!this.ready) throw new Error(`${this.cliName} not ready (status: ${this.currentStatus})`);
|
|
@@ -20054,17 +19911,17 @@ ${data.message || ""}`.trim();
|
|
|
20054
19911
|
}
|
|
20055
19912
|
}
|
|
20056
19913
|
waitForStopped(timeoutMs) {
|
|
20057
|
-
return new Promise((
|
|
19914
|
+
return new Promise((resolve12) => {
|
|
20058
19915
|
const startedAt = Date.now();
|
|
20059
19916
|
const timer = setInterval(() => {
|
|
20060
19917
|
if (!this.ptyProcess || this.currentStatus === "stopped") {
|
|
20061
19918
|
clearInterval(timer);
|
|
20062
|
-
|
|
19919
|
+
resolve12(true);
|
|
20063
19920
|
return;
|
|
20064
19921
|
}
|
|
20065
19922
|
if (Date.now() - startedAt >= timeoutMs) {
|
|
20066
19923
|
clearInterval(timer);
|
|
20067
|
-
|
|
19924
|
+
resolve12(false);
|
|
20068
19925
|
}
|
|
20069
19926
|
}, 100);
|
|
20070
19927
|
});
|
|
@@ -20753,10 +20610,10 @@ function mergeDefs(...defs) {
|
|
|
20753
20610
|
function cloneDef(schema) {
|
|
20754
20611
|
return mergeDefs(schema._zod.def);
|
|
20755
20612
|
}
|
|
20756
|
-
function getElementAtPath(obj,
|
|
20757
|
-
if (!
|
|
20613
|
+
function getElementAtPath(obj, path18) {
|
|
20614
|
+
if (!path18)
|
|
20758
20615
|
return obj;
|
|
20759
|
-
return
|
|
20616
|
+
return path18.reduce((acc, key) => acc?.[key], obj);
|
|
20760
20617
|
}
|
|
20761
20618
|
function promiseAllObject(promisesObj) {
|
|
20762
20619
|
const keys = Object.keys(promisesObj);
|
|
@@ -21068,11 +20925,11 @@ function aborted(x, startIndex = 0) {
|
|
|
21068
20925
|
}
|
|
21069
20926
|
return false;
|
|
21070
20927
|
}
|
|
21071
|
-
function prefixIssues(
|
|
20928
|
+
function prefixIssues(path18, issues) {
|
|
21072
20929
|
return issues.map((iss) => {
|
|
21073
20930
|
var _a2;
|
|
21074
20931
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
21075
|
-
iss.path.unshift(
|
|
20932
|
+
iss.path.unshift(path18);
|
|
21076
20933
|
return iss;
|
|
21077
20934
|
});
|
|
21078
20935
|
}
|
|
@@ -21315,7 +21172,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
21315
21172
|
}
|
|
21316
21173
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
21317
21174
|
const result = { errors: [] };
|
|
21318
|
-
const processError = (error49,
|
|
21175
|
+
const processError = (error49, path18 = []) => {
|
|
21319
21176
|
var _a2, _b;
|
|
21320
21177
|
for (const issue2 of error49.issues) {
|
|
21321
21178
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -21325,7 +21182,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
21325
21182
|
} else if (issue2.code === "invalid_element") {
|
|
21326
21183
|
processError({ issues: issue2.issues }, issue2.path);
|
|
21327
21184
|
} else {
|
|
21328
|
-
const fullpath = [...
|
|
21185
|
+
const fullpath = [...path18, ...issue2.path];
|
|
21329
21186
|
if (fullpath.length === 0) {
|
|
21330
21187
|
result.errors.push(mapper(issue2));
|
|
21331
21188
|
continue;
|
|
@@ -21357,8 +21214,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
21357
21214
|
}
|
|
21358
21215
|
function toDotPath(_path) {
|
|
21359
21216
|
const segs = [];
|
|
21360
|
-
const
|
|
21361
|
-
for (const seg of
|
|
21217
|
+
const path18 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
21218
|
+
for (const seg of path18) {
|
|
21362
21219
|
if (typeof seg === "number")
|
|
21363
21220
|
segs.push(`[${seg}]`);
|
|
21364
21221
|
else if (typeof seg === "symbol")
|
|
@@ -34122,13 +33979,13 @@ function resolveRef(ref, ctx) {
|
|
|
34122
33979
|
if (!ref.startsWith("#")) {
|
|
34123
33980
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
34124
33981
|
}
|
|
34125
|
-
const
|
|
34126
|
-
if (
|
|
33982
|
+
const path18 = ref.slice(1).split("/").filter(Boolean);
|
|
33983
|
+
if (path18.length === 0) {
|
|
34127
33984
|
return ctx.rootSchema;
|
|
34128
33985
|
}
|
|
34129
33986
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
34130
|
-
if (
|
|
34131
|
-
const key =
|
|
33987
|
+
if (path18[0] === defsKey) {
|
|
33988
|
+
const key = path18[1];
|
|
34132
33989
|
if (!key || !ctx.defs[key]) {
|
|
34133
33990
|
throw new Error(`Reference not found: ${ref}`);
|
|
34134
33991
|
}
|
|
@@ -36555,8 +36412,8 @@ var init_acp = __esm({
|
|
|
36555
36412
|
this.#requestHandler = requestHandler;
|
|
36556
36413
|
this.#notificationHandler = notificationHandler;
|
|
36557
36414
|
this.#stream = stream;
|
|
36558
|
-
this.#closedPromise = new Promise((
|
|
36559
|
-
this.#abortController.signal.addEventListener("abort", () =>
|
|
36415
|
+
this.#closedPromise = new Promise((resolve12) => {
|
|
36416
|
+
this.#abortController.signal.addEventListener("abort", () => resolve12());
|
|
36560
36417
|
});
|
|
36561
36418
|
this.#receive();
|
|
36562
36419
|
}
|
|
@@ -36705,8 +36562,8 @@ var init_acp = __esm({
|
|
|
36705
36562
|
}
|
|
36706
36563
|
async sendRequest(method, params) {
|
|
36707
36564
|
const id = this.#nextRequestId++;
|
|
36708
|
-
const responsePromise = new Promise((
|
|
36709
|
-
this.#pendingResponses.set(id, { resolve:
|
|
36565
|
+
const responsePromise = new Promise((resolve12, reject) => {
|
|
36566
|
+
this.#pendingResponses.set(id, { resolve: resolve12, reject });
|
|
36710
36567
|
});
|
|
36711
36568
|
await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
|
|
36712
36569
|
return responsePromise;
|
|
@@ -37246,13 +37103,13 @@ var init_acp_provider_instance = __esm({
|
|
|
37246
37103
|
}
|
|
37247
37104
|
this.currentStatus = "waiting_approval";
|
|
37248
37105
|
this.detectStatusTransition();
|
|
37249
|
-
const approved = await new Promise((
|
|
37250
|
-
this.permissionResolvers.push(
|
|
37106
|
+
const approved = await new Promise((resolve12) => {
|
|
37107
|
+
this.permissionResolvers.push(resolve12);
|
|
37251
37108
|
setTimeout(() => {
|
|
37252
|
-
const idx = this.permissionResolvers.indexOf(
|
|
37109
|
+
const idx = this.permissionResolvers.indexOf(resolve12);
|
|
37253
37110
|
if (idx >= 0) {
|
|
37254
37111
|
this.permissionResolvers.splice(idx, 1);
|
|
37255
|
-
|
|
37112
|
+
resolve12(false);
|
|
37256
37113
|
}
|
|
37257
37114
|
}, 3e5);
|
|
37258
37115
|
});
|
|
@@ -37714,19 +37571,18 @@ function colorize(color, text) {
|
|
|
37714
37571
|
const fn2 = chalkApi?.[color];
|
|
37715
37572
|
return typeof fn2 === "function" ? fn2(text) : text;
|
|
37716
37573
|
}
|
|
37717
|
-
var os14,
|
|
37574
|
+
var os14, path10, crypto4, import_chalk, chalkApi, DaemonCliManager;
|
|
37718
37575
|
var init_cli_manager = __esm({
|
|
37719
37576
|
"../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
|
|
37720
37577
|
"use strict";
|
|
37721
37578
|
os14 = __toESM(require("os"));
|
|
37722
|
-
|
|
37579
|
+
path10 = __toESM(require("path"));
|
|
37723
37580
|
crypto4 = __toESM(require("crypto"));
|
|
37724
37581
|
import_chalk = __toESM(require("chalk"));
|
|
37725
37582
|
init_provider_cli_adapter();
|
|
37726
37583
|
init_cli_detector();
|
|
37727
37584
|
init_config();
|
|
37728
37585
|
init_workspaces();
|
|
37729
|
-
init_workspace_activity();
|
|
37730
37586
|
init_recent_activity();
|
|
37731
37587
|
init_cli_provider_instance();
|
|
37732
37588
|
init_acp_provider_instance();
|
|
@@ -37745,24 +37601,6 @@ var init_cli_manager = __esm({
|
|
|
37745
37601
|
const hash2 = require("crypto").createHash("md5").update(require("path").resolve(dir)).digest("hex").slice(0, 8);
|
|
37746
37602
|
return `${cliType}_${hash2}`;
|
|
37747
37603
|
}
|
|
37748
|
-
persistRecentDir(cliType, dir) {
|
|
37749
|
-
try {
|
|
37750
|
-
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
37751
|
-
const provider = this.providerLoader.getByAlias(cliType);
|
|
37752
|
-
const actKind = provider?.category === "acp" ? "acp" : "cli";
|
|
37753
|
-
let next = loadConfig();
|
|
37754
|
-
console.log(colorize("cyan", ` \u{1F4C2} Saving recent workspace: ${dir}`));
|
|
37755
|
-
const recent = next.recentCliWorkspaces || [];
|
|
37756
|
-
if (!recent.includes(dir)) {
|
|
37757
|
-
next = { ...next, recentCliWorkspaces: [dir, ...recent].slice(0, 10) };
|
|
37758
|
-
}
|
|
37759
|
-
next = appendWorkspaceActivity(next, dir, { kind: actKind, agentType: normalizedType });
|
|
37760
|
-
saveConfig(next);
|
|
37761
|
-
console.log(colorize("green", ` \u2713 Recent workspace saved: ${dir}`));
|
|
37762
|
-
} catch (e) {
|
|
37763
|
-
console.error(colorize("red", ` \u2717 Failed to save recent workspace: ${e}`));
|
|
37764
|
-
}
|
|
37765
|
-
}
|
|
37766
37604
|
persistRecentActivity(entry) {
|
|
37767
37605
|
try {
|
|
37768
37606
|
saveConfig(appendRecentActivity(loadConfig(), entry));
|
|
@@ -37852,7 +37690,7 @@ var init_cli_manager = __esm({
|
|
|
37852
37690
|
async startSession(cliType, workingDir, cliArgs, initialModel) {
|
|
37853
37691
|
const trimmed = (workingDir || "").trim();
|
|
37854
37692
|
if (!trimmed) throw new Error("working directory required");
|
|
37855
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os14.homedir()) :
|
|
37693
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os14.homedir()) : path10.resolve(trimmed);
|
|
37856
37694
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
37857
37695
|
const provider = this.providerLoader.getByAlias(cliType);
|
|
37858
37696
|
const key = crypto4.randomUUID();
|
|
@@ -37923,11 +37761,6 @@ ${installInfo}`
|
|
|
37923
37761
|
LOG.warn("CLI", `[ACP] Initial model set failed: ${e?.message}`);
|
|
37924
37762
|
}
|
|
37925
37763
|
}
|
|
37926
|
-
try {
|
|
37927
|
-
addCliHistory({ category: "acp", cliType: normalizedType, dir: resolvedDir, workspace: resolvedDir, cliArgs, model: initialModel });
|
|
37928
|
-
} catch (e) {
|
|
37929
|
-
LOG.warn("CLI", `ACP history save failed: ${e?.message}`);
|
|
37930
|
-
}
|
|
37931
37764
|
this.persistRecentActivity({
|
|
37932
37765
|
kind: "acp",
|
|
37933
37766
|
providerType: normalizedType,
|
|
@@ -37994,11 +37827,6 @@ ${installInfo}`
|
|
|
37994
37827
|
this.adapters.set(key, adapter);
|
|
37995
37828
|
console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
|
|
37996
37829
|
}
|
|
37997
|
-
try {
|
|
37998
|
-
addCliHistory({ category: "cli", cliType, dir: resolvedDir, workspace: resolvedDir, cliArgs, model: initialModel });
|
|
37999
|
-
} catch (e) {
|
|
38000
|
-
LOG.warn("CLI", `CLI history save failed: ${e?.message}`);
|
|
38001
|
-
}
|
|
38002
37830
|
this.persistRecentActivity({
|
|
38003
37831
|
kind: "cli",
|
|
38004
37832
|
providerType: normalizedType,
|
|
@@ -38151,7 +37979,6 @@ ${installInfo}`
|
|
|
38151
37979
|
newKey = k;
|
|
38152
37980
|
}
|
|
38153
37981
|
}
|
|
38154
|
-
this.persistRecentDir(cliType, dir);
|
|
38155
37982
|
return { success: true, cliType, dir, id: newKey, launchSource };
|
|
38156
37983
|
}
|
|
38157
37984
|
case "stop_cli": {
|
|
@@ -38194,7 +38021,6 @@ ${installInfo}`
|
|
|
38194
38021
|
const found = this.findAdapter(cliType, { instanceKey: args?.targetSessionId, dir });
|
|
38195
38022
|
if (found) await this.stopSession(found.key);
|
|
38196
38023
|
await this.startSession(cliType, dir);
|
|
38197
|
-
this.persistRecentDir(cliType, dir);
|
|
38198
38024
|
return { success: true, restarted: true };
|
|
38199
38025
|
}
|
|
38200
38026
|
case "agent_command": {
|
|
@@ -39108,7 +38934,7 @@ function checkPathExists2(paths) {
|
|
|
39108
38934
|
for (const p of paths) {
|
|
39109
38935
|
if (p.includes("*")) {
|
|
39110
38936
|
const home = os15.homedir();
|
|
39111
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
38937
|
+
const resolved = p.replace(/\*/g, home.split(path11.sep).pop() || "");
|
|
39112
38938
|
if (fs9.existsSync(resolved)) return resolved;
|
|
39113
38939
|
} else {
|
|
39114
38940
|
if (fs9.existsSync(p)) return p;
|
|
@@ -39118,7 +38944,7 @@ function checkPathExists2(paths) {
|
|
|
39118
38944
|
}
|
|
39119
38945
|
function getMacAppVersion(appPath) {
|
|
39120
38946
|
if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
39121
|
-
const plistPath =
|
|
38947
|
+
const plistPath = path11.join(appPath, "Contents", "Info.plist");
|
|
39122
38948
|
if (!fs9.existsSync(plistPath)) return null;
|
|
39123
38949
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
39124
38950
|
return raw || null;
|
|
@@ -39145,7 +38971,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
39145
38971
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
39146
38972
|
let resolvedBin = cliBin;
|
|
39147
38973
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
39148
|
-
const bundled =
|
|
38974
|
+
const bundled = path11.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
39149
38975
|
if (provider.cli && fs9.existsSync(bundled)) resolvedBin = bundled;
|
|
39150
38976
|
}
|
|
39151
38977
|
info.installed = !!(appPath || resolvedBin);
|
|
@@ -39182,16 +39008,16 @@ async function detectAllVersions(loader, archive) {
|
|
|
39182
39008
|
}
|
|
39183
39009
|
return results;
|
|
39184
39010
|
}
|
|
39185
|
-
var fs9,
|
|
39011
|
+
var fs9, path11, os15, import_child_process7, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
|
|
39186
39012
|
var init_version_archive = __esm({
|
|
39187
39013
|
"../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
|
|
39188
39014
|
"use strict";
|
|
39189
39015
|
fs9 = __toESM(require("fs"));
|
|
39190
|
-
|
|
39016
|
+
path11 = __toESM(require("path"));
|
|
39191
39017
|
os15 = __toESM(require("os"));
|
|
39192
39018
|
import_child_process7 = require("child_process");
|
|
39193
39019
|
import_os3 = require("os");
|
|
39194
|
-
ARCHIVE_PATH =
|
|
39020
|
+
ARCHIVE_PATH = path11.join(os15.homedir(), ".adhdev", "version-history.json");
|
|
39195
39021
|
MAX_ENTRIES_PER_PROVIDER = 20;
|
|
39196
39022
|
VersionArchive = class {
|
|
39197
39023
|
history = {};
|
|
@@ -39238,7 +39064,7 @@ var init_version_archive = __esm({
|
|
|
39238
39064
|
}
|
|
39239
39065
|
save() {
|
|
39240
39066
|
try {
|
|
39241
|
-
fs9.mkdirSync(
|
|
39067
|
+
fs9.mkdirSync(path11.dirname(ARCHIVE_PATH), { recursive: true });
|
|
39242
39068
|
fs9.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
39243
39069
|
} catch {
|
|
39244
39070
|
}
|
|
@@ -39759,17 +39585,17 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
39759
39585
|
return;
|
|
39760
39586
|
}
|
|
39761
39587
|
let scriptsPath = "";
|
|
39762
|
-
const directScripts =
|
|
39588
|
+
const directScripts = path12.join(dir, "scripts.js");
|
|
39763
39589
|
if (fs10.existsSync(directScripts)) {
|
|
39764
39590
|
scriptsPath = directScripts;
|
|
39765
39591
|
} else {
|
|
39766
|
-
const scriptsDir =
|
|
39592
|
+
const scriptsDir = path12.join(dir, "scripts");
|
|
39767
39593
|
if (fs10.existsSync(scriptsDir)) {
|
|
39768
39594
|
const versions = fs10.readdirSync(scriptsDir).filter((d) => {
|
|
39769
|
-
return fs10.statSync(
|
|
39595
|
+
return fs10.statSync(path12.join(scriptsDir, d)).isDirectory();
|
|
39770
39596
|
}).sort().reverse();
|
|
39771
39597
|
for (const ver of versions) {
|
|
39772
|
-
const p =
|
|
39598
|
+
const p = path12.join(scriptsDir, ver, "scripts.js");
|
|
39773
39599
|
if (fs10.existsSync(p)) {
|
|
39774
39600
|
scriptsPath = p;
|
|
39775
39601
|
break;
|
|
@@ -40585,12 +40411,12 @@ async function handleDomContext(ctx, type, req, res) {
|
|
|
40585
40411
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
40586
40412
|
}
|
|
40587
40413
|
}
|
|
40588
|
-
var fs10,
|
|
40414
|
+
var fs10, path12;
|
|
40589
40415
|
var init_dev_cdp_handlers = __esm({
|
|
40590
40416
|
"../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
|
|
40591
40417
|
"use strict";
|
|
40592
40418
|
fs10 = __toESM(require("fs"));
|
|
40593
|
-
|
|
40419
|
+
path12 = __toESM(require("path"));
|
|
40594
40420
|
init_logger();
|
|
40595
40421
|
}
|
|
40596
40422
|
});
|
|
@@ -40855,22 +40681,22 @@ function getLatestScriptVersionDir(scriptsDir) {
|
|
|
40855
40681
|
if (!fs11.existsSync(scriptsDir)) return null;
|
|
40856
40682
|
const versions = fs11.readdirSync(scriptsDir).filter((d) => {
|
|
40857
40683
|
try {
|
|
40858
|
-
return fs11.statSync(
|
|
40684
|
+
return fs11.statSync(path13.join(scriptsDir, d)).isDirectory();
|
|
40859
40685
|
} catch {
|
|
40860
40686
|
return false;
|
|
40861
40687
|
}
|
|
40862
40688
|
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
40863
40689
|
if (versions.length === 0) return null;
|
|
40864
|
-
return
|
|
40690
|
+
return path13.join(scriptsDir, versions[0]);
|
|
40865
40691
|
}
|
|
40866
40692
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
40867
|
-
const canonicalUserDir =
|
|
40868
|
-
const desiredDir = requestedDir ?
|
|
40869
|
-
const upstreamRoot =
|
|
40870
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
40693
|
+
const canonicalUserDir = path13.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
40694
|
+
const desiredDir = requestedDir ? path13.resolve(requestedDir) : canonicalUserDir;
|
|
40695
|
+
const upstreamRoot = path13.resolve(ctx.providerLoader.getUpstreamDir());
|
|
40696
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path13.sep}`)) {
|
|
40871
40697
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
40872
40698
|
}
|
|
40873
|
-
if (
|
|
40699
|
+
if (path13.basename(desiredDir) !== type) {
|
|
40874
40700
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
40875
40701
|
}
|
|
40876
40702
|
const sourceDir = ctx.findProviderDir(type);
|
|
@@ -40878,11 +40704,11 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
40878
40704
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
40879
40705
|
}
|
|
40880
40706
|
if (!fs11.existsSync(desiredDir)) {
|
|
40881
|
-
fs11.mkdirSync(
|
|
40707
|
+
fs11.mkdirSync(path13.dirname(desiredDir), { recursive: true });
|
|
40882
40708
|
fs11.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
40883
40709
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
40884
40710
|
}
|
|
40885
|
-
const providerJson =
|
|
40711
|
+
const providerJson = path13.join(desiredDir, "provider.json");
|
|
40886
40712
|
if (!fs11.existsSync(providerJson)) {
|
|
40887
40713
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
40888
40714
|
}
|
|
@@ -40905,13 +40731,13 @@ function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
|
40905
40731
|
const refDir = ctx.findProviderDir(referenceType);
|
|
40906
40732
|
if (!refDir || !fs11.existsSync(refDir)) return {};
|
|
40907
40733
|
const referenceScripts = {};
|
|
40908
|
-
const scriptsDir =
|
|
40734
|
+
const scriptsDir = path13.join(refDir, "scripts");
|
|
40909
40735
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
40910
40736
|
if (!latestDir) return referenceScripts;
|
|
40911
40737
|
for (const file2 of fs11.readdirSync(latestDir)) {
|
|
40912
40738
|
if (!file2.endsWith(".js")) continue;
|
|
40913
40739
|
try {
|
|
40914
|
-
referenceScripts[file2] = fs11.readFileSync(
|
|
40740
|
+
referenceScripts[file2] = fs11.readFileSync(path13.join(latestDir, file2), "utf-8");
|
|
40915
40741
|
} catch {
|
|
40916
40742
|
}
|
|
40917
40743
|
}
|
|
@@ -40962,9 +40788,9 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
40962
40788
|
});
|
|
40963
40789
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
40964
40790
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference);
|
|
40965
|
-
const tmpDir =
|
|
40791
|
+
const tmpDir = path13.join(os16.tmpdir(), "adhdev-autoimpl");
|
|
40966
40792
|
if (!fs11.existsSync(tmpDir)) fs11.mkdirSync(tmpDir, { recursive: true });
|
|
40967
|
-
const promptFile =
|
|
40793
|
+
const promptFile = path13.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
40968
40794
|
fs11.writeFileSync(promptFile, prompt, "utf-8");
|
|
40969
40795
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
40970
40796
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
@@ -41335,7 +41161,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41335
41161
|
setMode: "set_mode.js"
|
|
41336
41162
|
};
|
|
41337
41163
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
41338
|
-
const scriptsDir =
|
|
41164
|
+
const scriptsDir = path13.join(providerDir, "scripts");
|
|
41339
41165
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
41340
41166
|
if (latestScriptsDir) {
|
|
41341
41167
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -41346,7 +41172,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41346
41172
|
for (const file2 of fs11.readdirSync(latestScriptsDir)) {
|
|
41347
41173
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
41348
41174
|
try {
|
|
41349
|
-
const content = fs11.readFileSync(
|
|
41175
|
+
const content = fs11.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
|
|
41350
41176
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
41351
41177
|
lines.push("```javascript");
|
|
41352
41178
|
lines.push(content);
|
|
@@ -41363,7 +41189,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41363
41189
|
lines.push("");
|
|
41364
41190
|
for (const file2 of refFiles) {
|
|
41365
41191
|
try {
|
|
41366
|
-
const content = fs11.readFileSync(
|
|
41192
|
+
const content = fs11.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
|
|
41367
41193
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
41368
41194
|
lines.push("```javascript");
|
|
41369
41195
|
lines.push(content);
|
|
@@ -41404,10 +41230,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41404
41230
|
lines.push("");
|
|
41405
41231
|
}
|
|
41406
41232
|
}
|
|
41407
|
-
const docsDir =
|
|
41233
|
+
const docsDir = path13.join(providerDir, "../../docs");
|
|
41408
41234
|
const loadGuide = (name) => {
|
|
41409
41235
|
try {
|
|
41410
|
-
const p =
|
|
41236
|
+
const p = path13.join(docsDir, name);
|
|
41411
41237
|
if (fs11.existsSync(p)) return fs11.readFileSync(p, "utf-8");
|
|
41412
41238
|
} catch {
|
|
41413
41239
|
}
|
|
@@ -41581,7 +41407,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41581
41407
|
parseApproval: "parse_approval.js"
|
|
41582
41408
|
};
|
|
41583
41409
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
41584
|
-
const scriptsDir =
|
|
41410
|
+
const scriptsDir = path13.join(providerDir, "scripts");
|
|
41585
41411
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
41586
41412
|
if (latestScriptsDir) {
|
|
41587
41413
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -41593,7 +41419,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41593
41419
|
if (!file2.endsWith(".js")) continue;
|
|
41594
41420
|
if (!targetFileNames.has(file2)) continue;
|
|
41595
41421
|
try {
|
|
41596
|
-
const content = fs11.readFileSync(
|
|
41422
|
+
const content = fs11.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
|
|
41597
41423
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
41598
41424
|
lines.push("```javascript");
|
|
41599
41425
|
lines.push(content);
|
|
@@ -41609,7 +41435,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41609
41435
|
lines.push("");
|
|
41610
41436
|
for (const file2 of refFiles) {
|
|
41611
41437
|
try {
|
|
41612
|
-
const content = fs11.readFileSync(
|
|
41438
|
+
const content = fs11.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
|
|
41613
41439
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
41614
41440
|
lines.push("```javascript");
|
|
41615
41441
|
lines.push(content);
|
|
@@ -41642,10 +41468,10 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41642
41468
|
lines.push("");
|
|
41643
41469
|
}
|
|
41644
41470
|
}
|
|
41645
|
-
const docsDir =
|
|
41471
|
+
const docsDir = path13.join(providerDir, "../../docs");
|
|
41646
41472
|
const loadGuide = (name) => {
|
|
41647
41473
|
try {
|
|
41648
|
-
const p =
|
|
41474
|
+
const p = path13.join(docsDir, name);
|
|
41649
41475
|
if (fs11.existsSync(p)) return fs11.readFileSync(p, "utf-8");
|
|
41650
41476
|
} catch {
|
|
41651
41477
|
}
|
|
@@ -41809,25 +41635,25 @@ data: ${JSON.stringify(msg.data)}
|
|
|
41809
41635
|
}
|
|
41810
41636
|
}
|
|
41811
41637
|
}
|
|
41812
|
-
var fs11,
|
|
41638
|
+
var fs11, path13, os16;
|
|
41813
41639
|
var init_dev_auto_implement = __esm({
|
|
41814
41640
|
"../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
|
|
41815
41641
|
"use strict";
|
|
41816
41642
|
fs11 = __toESM(require("fs"));
|
|
41817
|
-
|
|
41643
|
+
path13 = __toESM(require("path"));
|
|
41818
41644
|
os16 = __toESM(require("os"));
|
|
41819
41645
|
init_dev_server();
|
|
41820
41646
|
}
|
|
41821
41647
|
});
|
|
41822
41648
|
|
|
41823
41649
|
// ../../oss/packages/daemon-core/src/daemon/dev-server.ts
|
|
41824
|
-
var http2, fs12,
|
|
41650
|
+
var http2, fs12, path14, DEV_SERVER_PORT, DevServer;
|
|
41825
41651
|
var init_dev_server = __esm({
|
|
41826
41652
|
"../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
|
|
41827
41653
|
"use strict";
|
|
41828
41654
|
http2 = __toESM(require("http"));
|
|
41829
41655
|
fs12 = __toESM(require("fs"));
|
|
41830
|
-
|
|
41656
|
+
path14 = __toESM(require("path"));
|
|
41831
41657
|
init_scaffold_template();
|
|
41832
41658
|
init_version_archive();
|
|
41833
41659
|
init_logger();
|
|
@@ -41926,8 +41752,8 @@ var init_dev_server = __esm({
|
|
|
41926
41752
|
}
|
|
41927
41753
|
getEndpointList() {
|
|
41928
41754
|
return this.routes.map((r) => {
|
|
41929
|
-
const
|
|
41930
|
-
return `${r.method.padEnd(5)} ${
|
|
41755
|
+
const path18 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
41756
|
+
return `${r.method.padEnd(5)} ${path18}`;
|
|
41931
41757
|
});
|
|
41932
41758
|
}
|
|
41933
41759
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -41958,15 +41784,15 @@ var init_dev_server = __esm({
|
|
|
41958
41784
|
this.json(res, 500, { error: e.message });
|
|
41959
41785
|
}
|
|
41960
41786
|
});
|
|
41961
|
-
return new Promise((
|
|
41787
|
+
return new Promise((resolve12, reject) => {
|
|
41962
41788
|
this.server.listen(port, "127.0.0.1", () => {
|
|
41963
41789
|
this.log(`Dev server listening on http://127.0.0.1:${port}`);
|
|
41964
|
-
|
|
41790
|
+
resolve12();
|
|
41965
41791
|
});
|
|
41966
41792
|
this.server.on("error", (e) => {
|
|
41967
41793
|
if (e.code === "EADDRINUSE") {
|
|
41968
41794
|
this.log(`Port ${port} in use, skipping dev server`);
|
|
41969
|
-
|
|
41795
|
+
resolve12();
|
|
41970
41796
|
} else {
|
|
41971
41797
|
reject(e);
|
|
41972
41798
|
}
|
|
@@ -42049,20 +41875,20 @@ var init_dev_server = __esm({
|
|
|
42049
41875
|
child.stderr?.on("data", (d) => {
|
|
42050
41876
|
stderr += d.toString().slice(0, 2e3);
|
|
42051
41877
|
});
|
|
42052
|
-
await new Promise((
|
|
41878
|
+
await new Promise((resolve12) => {
|
|
42053
41879
|
const timer = setTimeout(() => {
|
|
42054
41880
|
child.kill();
|
|
42055
|
-
|
|
41881
|
+
resolve12();
|
|
42056
41882
|
}, 3e3);
|
|
42057
41883
|
child.on("exit", () => {
|
|
42058
41884
|
clearTimeout(timer);
|
|
42059
|
-
|
|
41885
|
+
resolve12();
|
|
42060
41886
|
});
|
|
42061
41887
|
child.stdout?.once("data", () => {
|
|
42062
41888
|
setTimeout(() => {
|
|
42063
41889
|
child.kill();
|
|
42064
41890
|
clearTimeout(timer);
|
|
42065
|
-
|
|
41891
|
+
resolve12();
|
|
42066
41892
|
}, 500);
|
|
42067
41893
|
});
|
|
42068
41894
|
});
|
|
@@ -42209,12 +42035,12 @@ var init_dev_server = __esm({
|
|
|
42209
42035
|
// ─── DevConsole SPA ───
|
|
42210
42036
|
getConsoleDistDir() {
|
|
42211
42037
|
const candidates = [
|
|
42212
|
-
|
|
42213
|
-
|
|
42214
|
-
|
|
42038
|
+
path14.resolve(__dirname, "../../web-devconsole/dist"),
|
|
42039
|
+
path14.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
42040
|
+
path14.join(process.cwd(), "packages/web-devconsole/dist")
|
|
42215
42041
|
];
|
|
42216
42042
|
for (const dir of candidates) {
|
|
42217
|
-
if (fs12.existsSync(
|
|
42043
|
+
if (fs12.existsSync(path14.join(dir, "index.html"))) return dir;
|
|
42218
42044
|
}
|
|
42219
42045
|
return null;
|
|
42220
42046
|
}
|
|
@@ -42224,7 +42050,7 @@ var init_dev_server = __esm({
|
|
|
42224
42050
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
42225
42051
|
return;
|
|
42226
42052
|
}
|
|
42227
|
-
const htmlPath =
|
|
42053
|
+
const htmlPath = path14.join(distDir, "index.html");
|
|
42228
42054
|
try {
|
|
42229
42055
|
const html = fs12.readFileSync(htmlPath, "utf-8");
|
|
42230
42056
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
@@ -42249,15 +42075,15 @@ var init_dev_server = __esm({
|
|
|
42249
42075
|
this.json(res, 404, { error: "Not found" });
|
|
42250
42076
|
return;
|
|
42251
42077
|
}
|
|
42252
|
-
const safePath =
|
|
42253
|
-
const filePath =
|
|
42078
|
+
const safePath = path14.normalize(pathname).replace(/^\.\.\//, "");
|
|
42079
|
+
const filePath = path14.join(distDir, safePath);
|
|
42254
42080
|
if (!filePath.startsWith(distDir)) {
|
|
42255
42081
|
this.json(res, 403, { error: "Forbidden" });
|
|
42256
42082
|
return;
|
|
42257
42083
|
}
|
|
42258
42084
|
try {
|
|
42259
42085
|
const content = fs12.readFileSync(filePath);
|
|
42260
|
-
const ext =
|
|
42086
|
+
const ext = path14.extname(filePath);
|
|
42261
42087
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
42262
42088
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
42263
42089
|
res.end(content);
|
|
@@ -42370,9 +42196,9 @@ var init_dev_server = __esm({
|
|
|
42370
42196
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
42371
42197
|
if (entry.isDirectory()) {
|
|
42372
42198
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
42373
|
-
scan(
|
|
42199
|
+
scan(path14.join(d, entry.name), rel);
|
|
42374
42200
|
} else {
|
|
42375
|
-
const stat4 = fs12.statSync(
|
|
42201
|
+
const stat4 = fs12.statSync(path14.join(d, entry.name));
|
|
42376
42202
|
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
42377
42203
|
}
|
|
42378
42204
|
}
|
|
@@ -42395,7 +42221,7 @@ var init_dev_server = __esm({
|
|
|
42395
42221
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
42396
42222
|
return;
|
|
42397
42223
|
}
|
|
42398
|
-
const fullPath =
|
|
42224
|
+
const fullPath = path14.resolve(dir, path14.normalize(filePath));
|
|
42399
42225
|
if (!fullPath.startsWith(dir)) {
|
|
42400
42226
|
this.json(res, 403, { error: "Forbidden" });
|
|
42401
42227
|
return;
|
|
@@ -42420,14 +42246,14 @@ var init_dev_server = __esm({
|
|
|
42420
42246
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
42421
42247
|
return;
|
|
42422
42248
|
}
|
|
42423
|
-
const fullPath =
|
|
42249
|
+
const fullPath = path14.resolve(dir, path14.normalize(filePath));
|
|
42424
42250
|
if (!fullPath.startsWith(dir)) {
|
|
42425
42251
|
this.json(res, 403, { error: "Forbidden" });
|
|
42426
42252
|
return;
|
|
42427
42253
|
}
|
|
42428
42254
|
try {
|
|
42429
42255
|
if (fs12.existsSync(fullPath)) fs12.copyFileSync(fullPath, fullPath + ".bak");
|
|
42430
|
-
fs12.mkdirSync(
|
|
42256
|
+
fs12.mkdirSync(path14.dirname(fullPath), { recursive: true });
|
|
42431
42257
|
fs12.writeFileSync(fullPath, content, "utf-8");
|
|
42432
42258
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
42433
42259
|
this.providerLoader.reload();
|
|
@@ -42444,7 +42270,7 @@ var init_dev_server = __esm({
|
|
|
42444
42270
|
return;
|
|
42445
42271
|
}
|
|
42446
42272
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
42447
|
-
const p =
|
|
42273
|
+
const p = path14.join(dir, name);
|
|
42448
42274
|
if (fs12.existsSync(p)) {
|
|
42449
42275
|
const source = fs12.readFileSync(p, "utf-8");
|
|
42450
42276
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
@@ -42465,8 +42291,8 @@ var init_dev_server = __esm({
|
|
|
42465
42291
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
42466
42292
|
return;
|
|
42467
42293
|
}
|
|
42468
|
-
const target = fs12.existsSync(
|
|
42469
|
-
const targetPath =
|
|
42294
|
+
const target = fs12.existsSync(path14.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
42295
|
+
const targetPath = path14.join(dir, target);
|
|
42470
42296
|
try {
|
|
42471
42297
|
if (fs12.existsSync(targetPath)) fs12.copyFileSync(targetPath, targetPath + ".bak");
|
|
42472
42298
|
fs12.writeFileSync(targetPath, source, "utf-8");
|
|
@@ -42571,14 +42397,14 @@ var init_dev_server = __esm({
|
|
|
42571
42397
|
child.stderr?.on("data", (d) => {
|
|
42572
42398
|
stderr += d.toString();
|
|
42573
42399
|
});
|
|
42574
|
-
await new Promise((
|
|
42400
|
+
await new Promise((resolve12) => {
|
|
42575
42401
|
const timer = setTimeout(() => {
|
|
42576
42402
|
child.kill();
|
|
42577
|
-
|
|
42403
|
+
resolve12();
|
|
42578
42404
|
}, timeout);
|
|
42579
42405
|
child.on("exit", () => {
|
|
42580
42406
|
clearTimeout(timer);
|
|
42581
|
-
|
|
42407
|
+
resolve12();
|
|
42582
42408
|
});
|
|
42583
42409
|
});
|
|
42584
42410
|
const elapsed = Date.now() - start;
|
|
@@ -42626,7 +42452,7 @@ var init_dev_server = __esm({
|
|
|
42626
42452
|
}
|
|
42627
42453
|
let targetDir;
|
|
42628
42454
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
42629
|
-
const jsonPath =
|
|
42455
|
+
const jsonPath = path14.join(targetDir, "provider.json");
|
|
42630
42456
|
if (fs12.existsSync(jsonPath)) {
|
|
42631
42457
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
42632
42458
|
return;
|
|
@@ -42638,8 +42464,8 @@ var init_dev_server = __esm({
|
|
|
42638
42464
|
const createdFiles = ["provider.json"];
|
|
42639
42465
|
if (result.files) {
|
|
42640
42466
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
42641
|
-
const fullPath =
|
|
42642
|
-
fs12.mkdirSync(
|
|
42467
|
+
const fullPath = path14.join(targetDir, relPath);
|
|
42468
|
+
fs12.mkdirSync(path14.dirname(fullPath), { recursive: true });
|
|
42643
42469
|
fs12.writeFileSync(fullPath, content, "utf-8");
|
|
42644
42470
|
createdFiles.push(relPath);
|
|
42645
42471
|
}
|
|
@@ -42692,22 +42518,22 @@ var init_dev_server = __esm({
|
|
|
42692
42518
|
if (!fs12.existsSync(scriptsDir)) return null;
|
|
42693
42519
|
const versions = fs12.readdirSync(scriptsDir).filter((d) => {
|
|
42694
42520
|
try {
|
|
42695
|
-
return fs12.statSync(
|
|
42521
|
+
return fs12.statSync(path14.join(scriptsDir, d)).isDirectory();
|
|
42696
42522
|
} catch {
|
|
42697
42523
|
return false;
|
|
42698
42524
|
}
|
|
42699
42525
|
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
42700
42526
|
if (versions.length === 0) return null;
|
|
42701
|
-
return
|
|
42527
|
+
return path14.join(scriptsDir, versions[0]);
|
|
42702
42528
|
}
|
|
42703
42529
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
42704
|
-
const canonicalUserDir =
|
|
42705
|
-
const desiredDir = requestedDir ?
|
|
42706
|
-
const upstreamRoot =
|
|
42707
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
42530
|
+
const canonicalUserDir = path14.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
42531
|
+
const desiredDir = requestedDir ? path14.resolve(requestedDir) : canonicalUserDir;
|
|
42532
|
+
const upstreamRoot = path14.resolve(this.providerLoader.getUpstreamDir());
|
|
42533
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path14.sep}`)) {
|
|
42708
42534
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
42709
42535
|
}
|
|
42710
|
-
if (
|
|
42536
|
+
if (path14.basename(desiredDir) !== type) {
|
|
42711
42537
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
42712
42538
|
}
|
|
42713
42539
|
const sourceDir = this.findProviderDir(type);
|
|
@@ -42715,11 +42541,11 @@ var init_dev_server = __esm({
|
|
|
42715
42541
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
42716
42542
|
}
|
|
42717
42543
|
if (!fs12.existsSync(desiredDir)) {
|
|
42718
|
-
fs12.mkdirSync(
|
|
42544
|
+
fs12.mkdirSync(path14.dirname(desiredDir), { recursive: true });
|
|
42719
42545
|
fs12.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
42720
42546
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
42721
42547
|
}
|
|
42722
|
-
const providerJson =
|
|
42548
|
+
const providerJson = path14.join(desiredDir, "provider.json");
|
|
42723
42549
|
if (!fs12.existsSync(providerJson)) {
|
|
42724
42550
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
42725
42551
|
}
|
|
@@ -42767,7 +42593,7 @@ var init_dev_server = __esm({
|
|
|
42767
42593
|
setMode: "set_mode.js"
|
|
42768
42594
|
};
|
|
42769
42595
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
42770
|
-
const scriptsDir =
|
|
42596
|
+
const scriptsDir = path14.join(providerDir, "scripts");
|
|
42771
42597
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
42772
42598
|
if (latestScriptsDir) {
|
|
42773
42599
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -42778,7 +42604,7 @@ var init_dev_server = __esm({
|
|
|
42778
42604
|
for (const file2 of fs12.readdirSync(latestScriptsDir)) {
|
|
42779
42605
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
42780
42606
|
try {
|
|
42781
|
-
const content = fs12.readFileSync(
|
|
42607
|
+
const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
42782
42608
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
42783
42609
|
lines.push("```javascript");
|
|
42784
42610
|
lines.push(content);
|
|
@@ -42795,7 +42621,7 @@ var init_dev_server = __esm({
|
|
|
42795
42621
|
lines.push("");
|
|
42796
42622
|
for (const file2 of refFiles) {
|
|
42797
42623
|
try {
|
|
42798
|
-
const content = fs12.readFileSync(
|
|
42624
|
+
const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
42799
42625
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
42800
42626
|
lines.push("```javascript");
|
|
42801
42627
|
lines.push(content);
|
|
@@ -42836,10 +42662,10 @@ var init_dev_server = __esm({
|
|
|
42836
42662
|
lines.push("");
|
|
42837
42663
|
}
|
|
42838
42664
|
}
|
|
42839
|
-
const docsDir =
|
|
42665
|
+
const docsDir = path14.join(providerDir, "../../docs");
|
|
42840
42666
|
const loadGuide = (name) => {
|
|
42841
42667
|
try {
|
|
42842
|
-
const p =
|
|
42668
|
+
const p = path14.join(docsDir, name);
|
|
42843
42669
|
if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
|
|
42844
42670
|
} catch {
|
|
42845
42671
|
}
|
|
@@ -43013,7 +42839,7 @@ var init_dev_server = __esm({
|
|
|
43013
42839
|
parseApproval: "parse_approval.js"
|
|
43014
42840
|
};
|
|
43015
42841
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
43016
|
-
const scriptsDir =
|
|
42842
|
+
const scriptsDir = path14.join(providerDir, "scripts");
|
|
43017
42843
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
43018
42844
|
if (latestScriptsDir) {
|
|
43019
42845
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -43025,7 +42851,7 @@ var init_dev_server = __esm({
|
|
|
43025
42851
|
if (!file2.endsWith(".js")) continue;
|
|
43026
42852
|
if (!targetFileNames.has(file2)) continue;
|
|
43027
42853
|
try {
|
|
43028
|
-
const content = fs12.readFileSync(
|
|
42854
|
+
const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
43029
42855
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
43030
42856
|
lines.push("```javascript");
|
|
43031
42857
|
lines.push(content);
|
|
@@ -43041,7 +42867,7 @@ var init_dev_server = __esm({
|
|
|
43041
42867
|
lines.push("");
|
|
43042
42868
|
for (const file2 of refFiles) {
|
|
43043
42869
|
try {
|
|
43044
|
-
const content = fs12.readFileSync(
|
|
42870
|
+
const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
43045
42871
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
43046
42872
|
lines.push("```javascript");
|
|
43047
42873
|
lines.push(content);
|
|
@@ -43074,10 +42900,10 @@ var init_dev_server = __esm({
|
|
|
43074
42900
|
lines.push("");
|
|
43075
42901
|
}
|
|
43076
42902
|
}
|
|
43077
|
-
const docsDir =
|
|
42903
|
+
const docsDir = path14.join(providerDir, "../../docs");
|
|
43078
42904
|
const loadGuide = (name) => {
|
|
43079
42905
|
try {
|
|
43080
|
-
const p =
|
|
42906
|
+
const p = path14.join(docsDir, name);
|
|
43081
42907
|
if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
|
|
43082
42908
|
} catch {
|
|
43083
42909
|
}
|
|
@@ -43234,14 +43060,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
43234
43060
|
res.end(JSON.stringify(data, null, 2));
|
|
43235
43061
|
}
|
|
43236
43062
|
async readBody(req) {
|
|
43237
|
-
return new Promise((
|
|
43063
|
+
return new Promise((resolve12) => {
|
|
43238
43064
|
let body = "";
|
|
43239
43065
|
req.on("data", (chunk) => body += chunk);
|
|
43240
43066
|
req.on("end", () => {
|
|
43241
43067
|
try {
|
|
43242
|
-
|
|
43068
|
+
resolve12(JSON.parse(body));
|
|
43243
43069
|
} catch {
|
|
43244
|
-
|
|
43070
|
+
resolve12({});
|
|
43245
43071
|
}
|
|
43246
43072
|
});
|
|
43247
43073
|
});
|
|
@@ -43365,8 +43191,8 @@ var init_dist = __esm({
|
|
|
43365
43191
|
}
|
|
43366
43192
|
this.requestWaiters.clear();
|
|
43367
43193
|
});
|
|
43368
|
-
await new Promise((
|
|
43369
|
-
socket.once("connect", () =>
|
|
43194
|
+
await new Promise((resolve12, reject) => {
|
|
43195
|
+
socket.once("connect", () => resolve12());
|
|
43370
43196
|
socket.once("error", reject);
|
|
43371
43197
|
});
|
|
43372
43198
|
}
|
|
@@ -43385,7 +43211,7 @@ var init_dist = __esm({
|
|
|
43385
43211
|
requestId,
|
|
43386
43212
|
request
|
|
43387
43213
|
};
|
|
43388
|
-
const response = await new Promise((
|
|
43214
|
+
const response = await new Promise((resolve12, reject) => {
|
|
43389
43215
|
const timeout = setTimeout(() => {
|
|
43390
43216
|
this.requestWaiters.delete(requestId);
|
|
43391
43217
|
reject(new Error(`Session host request timed out after 30s (${request.type})`));
|
|
@@ -43393,7 +43219,7 @@ var init_dist = __esm({
|
|
|
43393
43219
|
this.requestWaiters.set(requestId, {
|
|
43394
43220
|
resolve: (value) => {
|
|
43395
43221
|
clearTimeout(timeout);
|
|
43396
|
-
|
|
43222
|
+
resolve12(value);
|
|
43397
43223
|
},
|
|
43398
43224
|
reject: (error48) => {
|
|
43399
43225
|
clearTimeout(timeout);
|
|
@@ -43412,12 +43238,12 @@ var init_dist = __esm({
|
|
|
43412
43238
|
waiter.reject(new Error("Session host client closed"));
|
|
43413
43239
|
}
|
|
43414
43240
|
this.requestWaiters.clear();
|
|
43415
|
-
await new Promise((
|
|
43241
|
+
await new Promise((resolve12) => {
|
|
43416
43242
|
let settled = false;
|
|
43417
43243
|
const done = () => {
|
|
43418
43244
|
if (settled) return;
|
|
43419
43245
|
settled = true;
|
|
43420
|
-
|
|
43246
|
+
resolve12();
|
|
43421
43247
|
};
|
|
43422
43248
|
socket.once("close", done);
|
|
43423
43249
|
socket.end();
|
|
@@ -43794,7 +43620,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
|
|
|
43794
43620
|
const deadline = Date.now() + timeoutMs;
|
|
43795
43621
|
while (Date.now() < deadline) {
|
|
43796
43622
|
if (await canConnect(endpoint)) return;
|
|
43797
|
-
await new Promise((
|
|
43623
|
+
await new Promise((resolve12) => setTimeout(resolve12, STARTUP_POLL_MS));
|
|
43798
43624
|
}
|
|
43799
43625
|
throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
|
|
43800
43626
|
}
|
|
@@ -43884,10 +43710,10 @@ async function installExtension(ide, extension) {
|
|
|
43884
43710
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
43885
43711
|
const fs16 = await import("fs");
|
|
43886
43712
|
fs16.writeFileSync(vsixPath, buffer);
|
|
43887
|
-
return new Promise((
|
|
43713
|
+
return new Promise((resolve12) => {
|
|
43888
43714
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
43889
43715
|
(0, import_child_process8.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
43890
|
-
|
|
43716
|
+
resolve12({
|
|
43891
43717
|
extensionId: extension.id,
|
|
43892
43718
|
marketplaceId: extension.marketplaceId,
|
|
43893
43719
|
success: !error48,
|
|
@@ -43900,11 +43726,11 @@ async function installExtension(ide, extension) {
|
|
|
43900
43726
|
} catch (e) {
|
|
43901
43727
|
}
|
|
43902
43728
|
}
|
|
43903
|
-
return new Promise((
|
|
43729
|
+
return new Promise((resolve12) => {
|
|
43904
43730
|
const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
|
|
43905
43731
|
(0, import_child_process8.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
|
|
43906
43732
|
if (error48) {
|
|
43907
|
-
|
|
43733
|
+
resolve12({
|
|
43908
43734
|
extensionId: extension.id,
|
|
43909
43735
|
marketplaceId: extension.marketplaceId,
|
|
43910
43736
|
success: false,
|
|
@@ -43912,7 +43738,7 @@ async function installExtension(ide, extension) {
|
|
|
43912
43738
|
error: stderr || error48.message
|
|
43913
43739
|
});
|
|
43914
43740
|
} else {
|
|
43915
|
-
|
|
43741
|
+
resolve12({
|
|
43916
43742
|
extensionId: extension.id,
|
|
43917
43743
|
marketplaceId: extension.marketplaceId,
|
|
43918
43744
|
success: true,
|
|
@@ -44322,7 +44148,6 @@ __export(src_exports, {
|
|
|
44322
44148
|
ProviderLoader: () => ProviderLoader,
|
|
44323
44149
|
SessionHostPtyTransportFactory: () => SessionHostPtyTransportFactory,
|
|
44324
44150
|
VersionArchive: () => VersionArchive,
|
|
44325
|
-
addCliHistory: () => addCliHistory,
|
|
44326
44151
|
appendRecentActivity: () => appendRecentActivity,
|
|
44327
44152
|
buildSessionEntries: () => buildSessionEntries,
|
|
44328
44153
|
buildStatusSnapshot: () => buildStatusSnapshot,
|
|
@@ -44340,7 +44165,6 @@ __export(src_exports, {
|
|
|
44340
44165
|
getRecentActivity: () => getRecentActivity,
|
|
44341
44166
|
getRecentCommands: () => getRecentCommands,
|
|
44342
44167
|
getRecentLogs: () => getRecentLogs,
|
|
44343
|
-
getWorkspaceActivity: () => getWorkspaceActivity,
|
|
44344
44168
|
getWorkspaceState: () => getWorkspaceState,
|
|
44345
44169
|
hasCdpManager: () => hasCdpManager,
|
|
44346
44170
|
initDaemonComponents: () => initDaemonComponents,
|
|
@@ -44377,7 +44201,6 @@ var init_src = __esm({
|
|
|
44377
44201
|
"use strict";
|
|
44378
44202
|
init_config();
|
|
44379
44203
|
init_workspaces();
|
|
44380
|
-
init_workspace_activity();
|
|
44381
44204
|
init_recent_activity();
|
|
44382
44205
|
init_ide_detector();
|
|
44383
44206
|
init_cli_detector();
|
|
@@ -44610,9 +44433,9 @@ var init_server_connection = __esm({
|
|
|
44610
44433
|
LOG.info("Server", `[ServerConn] Run 'adhdev setup' to re-authenticate.`);
|
|
44611
44434
|
this.setState("disconnected");
|
|
44612
44435
|
try {
|
|
44613
|
-
const
|
|
44436
|
+
const path18 = require("path");
|
|
44614
44437
|
const fs16 = require("fs");
|
|
44615
|
-
const configPath =
|
|
44438
|
+
const configPath = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "config.json");
|
|
44616
44439
|
if (fs16.existsSync(configPath)) {
|
|
44617
44440
|
fs16.unlinkSync(configPath);
|
|
44618
44441
|
LOG.info("Server", `[ServerConn] Config file removed. Re-run 'adhdev setup'.`);
|
|
@@ -44723,17 +44546,17 @@ function canPeerUsePrivilegedShareCommand(commandType, permission) {
|
|
|
44723
44546
|
return false;
|
|
44724
44547
|
}
|
|
44725
44548
|
}
|
|
44726
|
-
var fs13,
|
|
44549
|
+
var fs13, path15, os18, import_node_module, esmRequire, logFile, log, logDebug, DaemonP2PSender;
|
|
44727
44550
|
var init_daemon_p2p = __esm({
|
|
44728
44551
|
"src/daemon-p2p.ts"() {
|
|
44729
44552
|
"use strict";
|
|
44730
44553
|
fs13 = __toESM(require("fs"));
|
|
44731
44554
|
init_src();
|
|
44732
|
-
|
|
44555
|
+
path15 = __toESM(require("path"));
|
|
44733
44556
|
os18 = __toESM(require("os"));
|
|
44734
44557
|
import_node_module = require("module");
|
|
44735
44558
|
esmRequire = (0, import_node_module.createRequire)(__filename);
|
|
44736
|
-
logFile =
|
|
44559
|
+
logFile = path15.join(os18.tmpdir(), "adhdev_daemon_p2p.log");
|
|
44737
44560
|
log = (msg) => {
|
|
44738
44561
|
LOG.info("P2P", `[${(/* @__PURE__ */ new Date()).toISOString()}] [P2P] ${msg}`);
|
|
44739
44562
|
};
|
|
@@ -44801,15 +44624,15 @@ ${e?.stack || ""}`);
|
|
|
44801
44624
|
const prebuildKey = `${platform11}-${arch3}`;
|
|
44802
44625
|
try {
|
|
44803
44626
|
const candidates = [
|
|
44804
|
-
|
|
44805
|
-
|
|
44806
|
-
|
|
44627
|
+
path15.join(__dirname, "node_modules", "node-datachannel"),
|
|
44628
|
+
path15.join(__dirname, "..", "node_modules", "node-datachannel"),
|
|
44629
|
+
path15.join(__dirname, "..", "..", "node_modules", "node-datachannel")
|
|
44807
44630
|
];
|
|
44808
44631
|
for (const candidate of candidates) {
|
|
44809
|
-
const prebuildPath =
|
|
44632
|
+
const prebuildPath = path15.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
|
|
44810
44633
|
if (fs13.existsSync(prebuildPath)) {
|
|
44811
|
-
const targetDir =
|
|
44812
|
-
const targetPath =
|
|
44634
|
+
const targetDir = path15.join(candidate, "build", "Release");
|
|
44635
|
+
const targetPath = path15.join(targetDir, "node_datachannel.node");
|
|
44813
44636
|
fs13.mkdirSync(targetDir, { recursive: true });
|
|
44814
44637
|
fs13.copyFileSync(prebuildPath, targetPath);
|
|
44815
44638
|
try {
|
|
@@ -44885,7 +44708,7 @@ ${e?.stack || ""}`);
|
|
|
44885
44708
|
async fetchTurnCredentials() {
|
|
44886
44709
|
try {
|
|
44887
44710
|
const serverUrl = process.env.ADHDEV_SERVER_URL || "https://api.adhf.dev";
|
|
44888
|
-
const configPath =
|
|
44711
|
+
const configPath = path15.join(os18.homedir(), ".adhdev", "config.json");
|
|
44889
44712
|
let token = "";
|
|
44890
44713
|
try {
|
|
44891
44714
|
const config2 = JSON.parse(fs13.readFileSync(configPath, "utf-8"));
|
|
@@ -44893,13 +44716,13 @@ ${e?.stack || ""}`);
|
|
|
44893
44716
|
} catch {
|
|
44894
44717
|
}
|
|
44895
44718
|
const http3 = esmRequire("https");
|
|
44896
|
-
const data = await new Promise((
|
|
44719
|
+
const data = await new Promise((resolve12, reject) => {
|
|
44897
44720
|
const req = http3.get(`${serverUrl}/api/v1/turn/credentials`, {
|
|
44898
44721
|
headers: { "Authorization": `Bearer ${token}` }
|
|
44899
44722
|
}, (res) => {
|
|
44900
44723
|
let d = "";
|
|
44901
44724
|
res.on("data", (c) => d += c);
|
|
44902
|
-
res.on("end", () =>
|
|
44725
|
+
res.on("end", () => resolve12(d));
|
|
44903
44726
|
});
|
|
44904
44727
|
req.on("error", reject);
|
|
44905
44728
|
req.setTimeout(5e3, () => {
|
|
@@ -45712,8 +45535,8 @@ __export(session_host_exports, {
|
|
|
45712
45535
|
});
|
|
45713
45536
|
function resolveSessionHostEntry() {
|
|
45714
45537
|
const packagedCandidates = [
|
|
45715
|
-
|
|
45716
|
-
|
|
45538
|
+
path16.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
45539
|
+
path16.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
45717
45540
|
];
|
|
45718
45541
|
for (const candidate of packagedCandidates) {
|
|
45719
45542
|
if (fs14.existsSync(candidate)) {
|
|
@@ -45723,7 +45546,7 @@ function resolveSessionHostEntry() {
|
|
|
45723
45546
|
return require.resolve("@adhdev/session-host-daemon");
|
|
45724
45547
|
}
|
|
45725
45548
|
function getSessionHostPidFile() {
|
|
45726
|
-
return
|
|
45549
|
+
return path16.join(os19.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
|
|
45727
45550
|
}
|
|
45728
45551
|
function killPid(pid) {
|
|
45729
45552
|
try {
|
|
@@ -45789,14 +45612,14 @@ async function ensureSessionHostReady2() {
|
|
|
45789
45612
|
async function listHostedCliRuntimes2(endpoint) {
|
|
45790
45613
|
return listHostedCliRuntimes(endpoint);
|
|
45791
45614
|
}
|
|
45792
|
-
var import_child_process9, fs14, os19,
|
|
45615
|
+
var import_child_process9, fs14, os19, path16, SESSION_HOST_APP_NAME;
|
|
45793
45616
|
var init_session_host = __esm({
|
|
45794
45617
|
"src/session-host.ts"() {
|
|
45795
45618
|
"use strict";
|
|
45796
45619
|
import_child_process9 = require("child_process");
|
|
45797
45620
|
fs14 = __toESM(require("fs"));
|
|
45798
45621
|
os19 = __toESM(require("os"));
|
|
45799
|
-
|
|
45622
|
+
path16 = __toESM(require("path"));
|
|
45800
45623
|
init_src();
|
|
45801
45624
|
SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
|
|
45802
45625
|
}
|
|
@@ -45810,9 +45633,9 @@ __export(adhdev_daemon_exports, {
|
|
|
45810
45633
|
stopDaemon: () => stopDaemon
|
|
45811
45634
|
});
|
|
45812
45635
|
function getDaemonPidFile() {
|
|
45813
|
-
const dir =
|
|
45636
|
+
const dir = path17.join(os20.homedir(), ".adhdev");
|
|
45814
45637
|
if (!fs15.existsSync(dir)) fs15.mkdirSync(dir, { recursive: true });
|
|
45815
|
-
return
|
|
45638
|
+
return path17.join(dir, "daemon.pid");
|
|
45816
45639
|
}
|
|
45817
45640
|
function writeDaemonPid(pid) {
|
|
45818
45641
|
fs15.writeFileSync(getDaemonPidFile(), String(pid), "utf-8");
|
|
@@ -45848,7 +45671,7 @@ function stopDaemon() {
|
|
|
45848
45671
|
return false;
|
|
45849
45672
|
}
|
|
45850
45673
|
}
|
|
45851
|
-
var os20, fs15,
|
|
45674
|
+
var os20, fs15, path17, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
|
|
45852
45675
|
var init_adhdev_daemon = __esm({
|
|
45853
45676
|
"src/adhdev-daemon.ts"() {
|
|
45854
45677
|
"use strict";
|
|
@@ -45860,14 +45683,14 @@ var init_adhdev_daemon = __esm({
|
|
|
45860
45683
|
init_dist();
|
|
45861
45684
|
os20 = __toESM(require("os"));
|
|
45862
45685
|
fs15 = __toESM(require("fs"));
|
|
45863
|
-
|
|
45686
|
+
path17 = __toESM(require("path"));
|
|
45864
45687
|
import_chalk2 = __toESM(require("chalk"));
|
|
45865
|
-
pkgVersion = "0.7.
|
|
45688
|
+
pkgVersion = "0.7.39";
|
|
45866
45689
|
if (pkgVersion === "unknown") {
|
|
45867
45690
|
try {
|
|
45868
45691
|
const possiblePaths = [
|
|
45869
|
-
|
|
45870
|
-
|
|
45692
|
+
path17.join(__dirname, "..", "package.json"),
|
|
45693
|
+
path17.join(__dirname, "package.json")
|
|
45871
45694
|
];
|
|
45872
45695
|
for (const p of possiblePaths) {
|
|
45873
45696
|
try {
|
|
@@ -46225,11 +46048,6 @@ ${err?.stack || ""}`);
|
|
|
46225
46048
|
});
|
|
46226
46049
|
}
|
|
46227
46050
|
}
|
|
46228
|
-
case "get_cli_history": {
|
|
46229
|
-
const config2 = loadConfig();
|
|
46230
|
-
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd: cmdType, source: "p2p", success: true, durationMs: Date.now() - cmdStart });
|
|
46231
|
-
return { success: true, history: config2.cliHistory || [] };
|
|
46232
|
-
}
|
|
46233
46051
|
case "set_machine_nickname": {
|
|
46234
46052
|
const nickname = data.nickname?.trim() || null;
|
|
46235
46053
|
const config2 = loadConfig();
|
|
@@ -46547,8 +46365,8 @@ async function startDaemonFlow() {
|
|
|
46547
46365
|
const daemon = new AdhdevDaemon2();
|
|
46548
46366
|
const { execSync: execSync7 } = await import("child_process");
|
|
46549
46367
|
const os21 = await import("os");
|
|
46550
|
-
const
|
|
46551
|
-
const logPath =
|
|
46368
|
+
const path18 = await import("path");
|
|
46369
|
+
const logPath = path18.join(os21.homedir(), ".adhdev", "daemon.log");
|
|
46552
46370
|
const platform11 = os21.platform();
|
|
46553
46371
|
try {
|
|
46554
46372
|
if (platform11 === "win32") {
|
|
@@ -46711,7 +46529,7 @@ __export(cdp_utils_exports, {
|
|
|
46711
46529
|
async function sendDaemonCommand(cmd, args = {}, port = 19222) {
|
|
46712
46530
|
const WebSocket3 = (await import("ws")).default;
|
|
46713
46531
|
const { DAEMON_WS_PATH: DAEMON_WS_PATH2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
46714
|
-
return new Promise((
|
|
46532
|
+
return new Promise((resolve12, reject) => {
|
|
46715
46533
|
const wsUrl = `ws://127.0.0.1:${port}${DAEMON_WS_PATH2 || "/daemon"}`;
|
|
46716
46534
|
const ws2 = new WebSocket3(wsUrl);
|
|
46717
46535
|
const timeout = setTimeout(() => {
|
|
@@ -46742,7 +46560,7 @@ async function sendDaemonCommand(cmd, args = {}, port = 19222) {
|
|
|
46742
46560
|
if (msg.type === "daemon:command_result" || msg.type === "command_result") {
|
|
46743
46561
|
clearTimeout(timeout);
|
|
46744
46562
|
ws2.close();
|
|
46745
|
-
|
|
46563
|
+
resolve12(msg.payload?.result || msg.payload || msg);
|
|
46746
46564
|
}
|
|
46747
46565
|
} catch {
|
|
46748
46566
|
}
|
|
@@ -46759,13 +46577,13 @@ Is 'adhdev daemon' running?`));
|
|
|
46759
46577
|
}
|
|
46760
46578
|
async function directCdpEval(expression, port = 9222) {
|
|
46761
46579
|
const http3 = await import("http");
|
|
46762
|
-
const targets = await new Promise((
|
|
46580
|
+
const targets = await new Promise((resolve12, reject) => {
|
|
46763
46581
|
http3.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
46764
46582
|
let data = "";
|
|
46765
46583
|
res.on("data", (c) => data += c);
|
|
46766
46584
|
res.on("end", () => {
|
|
46767
46585
|
try {
|
|
46768
|
-
|
|
46586
|
+
resolve12(JSON.parse(data));
|
|
46769
46587
|
} catch {
|
|
46770
46588
|
reject(new Error("Invalid JSON"));
|
|
46771
46589
|
}
|
|
@@ -46778,7 +46596,7 @@ async function directCdpEval(expression, port = 9222) {
|
|
|
46778
46596
|
const target = (mainPages.length > 0 ? mainPages[0] : pages[0]) || targets[0];
|
|
46779
46597
|
if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target found");
|
|
46780
46598
|
const WebSocket3 = (await import("ws")).default;
|
|
46781
|
-
return new Promise((
|
|
46599
|
+
return new Promise((resolve12, reject) => {
|
|
46782
46600
|
const ws2 = new WebSocket3(target.webSocketDebuggerUrl);
|
|
46783
46601
|
const timeout = setTimeout(() => {
|
|
46784
46602
|
ws2.close();
|
|
@@ -46800,11 +46618,11 @@ async function directCdpEval(expression, port = 9222) {
|
|
|
46800
46618
|
clearTimeout(timeout);
|
|
46801
46619
|
ws2.close();
|
|
46802
46620
|
if (msg.result?.result?.value !== void 0) {
|
|
46803
|
-
|
|
46621
|
+
resolve12(msg.result.result.value);
|
|
46804
46622
|
} else if (msg.result?.exceptionDetails) {
|
|
46805
46623
|
reject(new Error(msg.result.exceptionDetails.text));
|
|
46806
46624
|
} else {
|
|
46807
|
-
|
|
46625
|
+
resolve12(msg.result);
|
|
46808
46626
|
}
|
|
46809
46627
|
}
|
|
46810
46628
|
});
|
|
@@ -47466,7 +47284,7 @@ function registerProviderCommands(program2) {
|
|
|
47466
47284
|
} catch {
|
|
47467
47285
|
try {
|
|
47468
47286
|
const http3 = await import("http");
|
|
47469
|
-
const result = await new Promise((
|
|
47287
|
+
const result = await new Promise((resolve12, reject) => {
|
|
47470
47288
|
const req = http3.request({
|
|
47471
47289
|
hostname: "127.0.0.1",
|
|
47472
47290
|
port: 19280,
|
|
@@ -47478,9 +47296,9 @@ function registerProviderCommands(program2) {
|
|
|
47478
47296
|
res.on("data", (c) => data += c);
|
|
47479
47297
|
res.on("end", () => {
|
|
47480
47298
|
try {
|
|
47481
|
-
|
|
47299
|
+
resolve12(JSON.parse(data));
|
|
47482
47300
|
} catch {
|
|
47483
|
-
|
|
47301
|
+
resolve12({ raw: data });
|
|
47484
47302
|
}
|
|
47485
47303
|
});
|
|
47486
47304
|
});
|
|
@@ -47541,7 +47359,7 @@ function registerProviderCommands(program2) {
|
|
|
47541
47359
|
let processNames = {};
|
|
47542
47360
|
if (category === "ide") {
|
|
47543
47361
|
const fs16 = await import("fs");
|
|
47544
|
-
const
|
|
47362
|
+
const path18 = await import("path");
|
|
47545
47363
|
const os21 = await import("os");
|
|
47546
47364
|
if (os21.platform() === "darwin") {
|
|
47547
47365
|
while (true) {
|
|
@@ -47554,7 +47372,7 @@ function registerProviderCommands(program2) {
|
|
|
47554
47372
|
}
|
|
47555
47373
|
console.log(import_chalk6.default.green(` \u2713 Path verified: ${p}`));
|
|
47556
47374
|
osPaths["darwin"] = [p];
|
|
47557
|
-
processNames["darwin"] =
|
|
47375
|
+
processNames["darwin"] = path18.basename(p, ".app");
|
|
47558
47376
|
break;
|
|
47559
47377
|
}
|
|
47560
47378
|
} else if (os21.platform() === "win32") {
|
|
@@ -47568,7 +47386,7 @@ function registerProviderCommands(program2) {
|
|
|
47568
47386
|
}
|
|
47569
47387
|
console.log(import_chalk6.default.green(` \u2713 Path verified: ${p}`));
|
|
47570
47388
|
osPaths["win32"] = [p];
|
|
47571
|
-
processNames["win32"] =
|
|
47389
|
+
processNames["win32"] = path18.basename(p, ".exe");
|
|
47572
47390
|
break;
|
|
47573
47391
|
}
|
|
47574
47392
|
}
|
|
@@ -47582,12 +47400,12 @@ function registerProviderCommands(program2) {
|
|
|
47582
47400
|
console.log(import_chalk6.default.yellow("Invalid port number."));
|
|
47583
47401
|
continue;
|
|
47584
47402
|
}
|
|
47585
|
-
const isFree = await new Promise((
|
|
47403
|
+
const isFree = await new Promise((resolve12) => {
|
|
47586
47404
|
const server = net3.createServer();
|
|
47587
47405
|
server.unref();
|
|
47588
|
-
server.on("error", () =>
|
|
47406
|
+
server.on("error", () => resolve12(false));
|
|
47589
47407
|
server.listen(port, "127.0.0.1", () => {
|
|
47590
|
-
server.close(() =>
|
|
47408
|
+
server.close(() => resolve12(true));
|
|
47591
47409
|
});
|
|
47592
47410
|
});
|
|
47593
47411
|
if (!isFree) {
|
|
@@ -47602,7 +47420,7 @@ function registerProviderCommands(program2) {
|
|
|
47602
47420
|
rl.close();
|
|
47603
47421
|
const location = options.builtin ? "builtin" : "user";
|
|
47604
47422
|
const http3 = await import("http");
|
|
47605
|
-
const result = await new Promise((
|
|
47423
|
+
const result = await new Promise((resolve12, reject) => {
|
|
47606
47424
|
const postData = JSON.stringify({ type, name, category, location, cdpPorts, osPaths, processNames });
|
|
47607
47425
|
const req = http3.request({
|
|
47608
47426
|
hostname: "127.0.0.1",
|
|
@@ -47615,9 +47433,9 @@ function registerProviderCommands(program2) {
|
|
|
47615
47433
|
res.on("data", (c) => data += c);
|
|
47616
47434
|
res.on("end", () => {
|
|
47617
47435
|
try {
|
|
47618
|
-
|
|
47436
|
+
resolve12(JSON.parse(data));
|
|
47619
47437
|
} catch {
|
|
47620
|
-
|
|
47438
|
+
resolve12({ raw: data });
|
|
47621
47439
|
}
|
|
47622
47440
|
});
|
|
47623
47441
|
});
|
|
@@ -47815,7 +47633,7 @@ function registerProviderCommands(program2) {
|
|
|
47815
47633
|
...userComment ? { comment: userComment } : {},
|
|
47816
47634
|
reference
|
|
47817
47635
|
});
|
|
47818
|
-
const startResult = await new Promise((
|
|
47636
|
+
const startResult = await new Promise((resolve12, reject) => {
|
|
47819
47637
|
const req = http3.request({
|
|
47820
47638
|
hostname: "127.0.0.1",
|
|
47821
47639
|
port: 19280,
|
|
@@ -47827,9 +47645,9 @@ function registerProviderCommands(program2) {
|
|
|
47827
47645
|
res.on("data", (c) => data += c);
|
|
47828
47646
|
res.on("end", () => {
|
|
47829
47647
|
try {
|
|
47830
|
-
|
|
47648
|
+
resolve12(JSON.parse(data));
|
|
47831
47649
|
} catch {
|
|
47832
|
-
|
|
47650
|
+
resolve12({ raw: data });
|
|
47833
47651
|
}
|
|
47834
47652
|
});
|
|
47835
47653
|
});
|
|
@@ -47855,7 +47673,7 @@ function registerProviderCommands(program2) {
|
|
|
47855
47673
|
fsMock.writeFileSync(logFile2, `=== Auto-Impl Started ===
|
|
47856
47674
|
`);
|
|
47857
47675
|
console.log(import_chalk6.default.gray(` Agent logs: ${logFile2}`));
|
|
47858
|
-
await new Promise((
|
|
47676
|
+
await new Promise((resolve12, reject) => {
|
|
47859
47677
|
http3.get(`http://127.0.0.1:19280${startResult.sseUrl}`, (res) => {
|
|
47860
47678
|
let buffer = "";
|
|
47861
47679
|
res.on("data", (chunk) => {
|
|
@@ -47892,7 +47710,7 @@ function registerProviderCommands(program2) {
|
|
|
47892
47710
|
if (currentData.success === false) {
|
|
47893
47711
|
reject(new Error(`Agent failed to implement scripts properly (exit: ${currentData.exitCode})`));
|
|
47894
47712
|
} else {
|
|
47895
|
-
|
|
47713
|
+
resolve12();
|
|
47896
47714
|
}
|
|
47897
47715
|
} else if (currentEvent === "error") {
|
|
47898
47716
|
fsMock.appendFileSync(logFile2, `
|
|
@@ -47903,7 +47721,7 @@ function registerProviderCommands(program2) {
|
|
|
47903
47721
|
}
|
|
47904
47722
|
}
|
|
47905
47723
|
});
|
|
47906
|
-
res.on("end",
|
|
47724
|
+
res.on("end", resolve12);
|
|
47907
47725
|
}).on("error", reject);
|
|
47908
47726
|
});
|
|
47909
47727
|
console.log(import_chalk6.default.green(`
|
|
@@ -47962,7 +47780,7 @@ function registerProviderCommands(program2) {
|
|
|
47962
47780
|
ideType: type,
|
|
47963
47781
|
params: options.param ? { text: options.param, sessionId: options.param, buttonText: options.param } : {}
|
|
47964
47782
|
});
|
|
47965
|
-
const result = await new Promise((
|
|
47783
|
+
const result = await new Promise((resolve12, reject) => {
|
|
47966
47784
|
const req = http3.request({
|
|
47967
47785
|
hostname: "127.0.0.1",
|
|
47968
47786
|
port: 19280,
|
|
@@ -47974,9 +47792,9 @@ function registerProviderCommands(program2) {
|
|
|
47974
47792
|
res.on("data", (c) => data += c);
|
|
47975
47793
|
res.on("end", () => {
|
|
47976
47794
|
try {
|
|
47977
|
-
|
|
47795
|
+
resolve12(JSON.parse(data));
|
|
47978
47796
|
} catch {
|
|
47979
|
-
|
|
47797
|
+
resolve12({ raw: data });
|
|
47980
47798
|
}
|
|
47981
47799
|
});
|
|
47982
47800
|
});
|
|
@@ -48012,15 +47830,15 @@ function registerProviderCommands(program2) {
|
|
|
48012
47830
|
provider.command("source <type>").description("View source code of a provider").action(async (type) => {
|
|
48013
47831
|
try {
|
|
48014
47832
|
const http3 = await import("http");
|
|
48015
|
-
const result = await new Promise((
|
|
47833
|
+
const result = await new Promise((resolve12, reject) => {
|
|
48016
47834
|
http3.get(`http://127.0.0.1:19280/api/providers/${type}/source`, (res) => {
|
|
48017
47835
|
let data = "";
|
|
48018
47836
|
res.on("data", (c) => data += c);
|
|
48019
47837
|
res.on("end", () => {
|
|
48020
47838
|
try {
|
|
48021
|
-
|
|
47839
|
+
resolve12(JSON.parse(data));
|
|
48022
47840
|
} catch {
|
|
48023
|
-
|
|
47841
|
+
resolve12({ raw: data });
|
|
48024
47842
|
}
|
|
48025
47843
|
});
|
|
48026
47844
|
}).on("error", () => {
|
|
@@ -48066,7 +47884,7 @@ function registerProviderCommands(program2) {
|
|
|
48066
47884
|
try {
|
|
48067
47885
|
const http3 = await import("http");
|
|
48068
47886
|
const postData = JSON.stringify({ script: "readChat", params: {} });
|
|
48069
|
-
const result = await new Promise((
|
|
47887
|
+
const result = await new Promise((resolve12, reject) => {
|
|
48070
47888
|
const req = http3.request({
|
|
48071
47889
|
hostname: "127.0.0.1",
|
|
48072
47890
|
port: 19280,
|
|
@@ -48078,9 +47896,9 @@ function registerProviderCommands(program2) {
|
|
|
48078
47896
|
res2.on("data", (c) => data += c);
|
|
48079
47897
|
res2.on("end", () => {
|
|
48080
47898
|
try {
|
|
48081
|
-
|
|
47899
|
+
resolve12(JSON.parse(data));
|
|
48082
47900
|
} catch {
|
|
48083
|
-
|
|
47901
|
+
resolve12({ raw: data });
|
|
48084
47902
|
}
|
|
48085
47903
|
});
|
|
48086
47904
|
});
|
|
@@ -48321,13 +48139,13 @@ function registerCdpCommands(program2) {
|
|
|
48321
48139
|
cdp.command("screenshot").description("Capture IDE screenshot").option("-p, --port <port>", "CDP port", "9222").option("-o, --output <file>", "Output file path", "/tmp/cdp_screenshot.jpg").action(async (options) => {
|
|
48322
48140
|
try {
|
|
48323
48141
|
const http3 = await import("http");
|
|
48324
|
-
const targets = await new Promise((
|
|
48142
|
+
const targets = await new Promise((resolve12, reject) => {
|
|
48325
48143
|
http3.get(`http://127.0.0.1:${options.port}/json`, (res) => {
|
|
48326
48144
|
let data = "";
|
|
48327
48145
|
res.on("data", (c) => data += c);
|
|
48328
48146
|
res.on("end", () => {
|
|
48329
48147
|
try {
|
|
48330
|
-
|
|
48148
|
+
resolve12(JSON.parse(data));
|
|
48331
48149
|
} catch {
|
|
48332
48150
|
reject(new Error("Invalid JSON"));
|
|
48333
48151
|
}
|
|
@@ -48341,7 +48159,7 @@ function registerCdpCommands(program2) {
|
|
|
48341
48159
|
if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target");
|
|
48342
48160
|
const WebSocket3 = (await import("ws")).default;
|
|
48343
48161
|
const ws2 = new WebSocket3(target.webSocketDebuggerUrl);
|
|
48344
|
-
await new Promise((
|
|
48162
|
+
await new Promise((resolve12, reject) => {
|
|
48345
48163
|
ws2.on("open", () => {
|
|
48346
48164
|
ws2.send(JSON.stringify({ id: 1, method: "Page.captureScreenshot", params: { format: "jpeg", quality: 50 } }));
|
|
48347
48165
|
});
|
|
@@ -48354,7 +48172,7 @@ function registerCdpCommands(program2) {
|
|
|
48354
48172
|
\u2713 Screenshot saved to ${options.output}
|
|
48355
48173
|
`));
|
|
48356
48174
|
ws2.close();
|
|
48357
|
-
|
|
48175
|
+
resolve12();
|
|
48358
48176
|
}
|
|
48359
48177
|
});
|
|
48360
48178
|
ws2.on("error", (e) => reject(e));
|