adhdev 0.7.38 → 0.7.40
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 +1084 -1291
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +1040 -1245
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -31,6 +31,165 @@ 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
|
+
sessionReads: {},
|
|
180
|
+
sessionReadMarkers: {},
|
|
181
|
+
machineNickname: null,
|
|
182
|
+
machineId: void 0,
|
|
183
|
+
machineSecret: null,
|
|
184
|
+
registeredMachineId: void 0,
|
|
185
|
+
providerSettings: {},
|
|
186
|
+
ideSettings: {},
|
|
187
|
+
disableUpstream: false
|
|
188
|
+
};
|
|
189
|
+
MACHINE_ID_PREFIX = "mach_";
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
|
|
34
193
|
// ../../oss/packages/daemon-core/src/config/workspaces.ts
|
|
35
194
|
function expandPath(p) {
|
|
36
195
|
const t = (p || "").trim();
|
|
@@ -53,25 +212,6 @@ function defaultWorkspaceLabel(absPath) {
|
|
|
53
212
|
const base = path.basename(absPath) || absPath;
|
|
54
213
|
return base;
|
|
55
214
|
}
|
|
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
215
|
function getDefaultWorkspacePath(config2) {
|
|
76
216
|
const id = config2.defaultWorkspaceId;
|
|
77
217
|
if (!id) return null;
|
|
@@ -185,7 +325,7 @@ function addWorkspaceEntry(config2, rawPath, label, options) {
|
|
|
185
325
|
return { error: `Maximum ${MAX_WORKSPACES} workspaces` };
|
|
186
326
|
}
|
|
187
327
|
const entry = {
|
|
188
|
-
id: (0,
|
|
328
|
+
id: (0, import_crypto2.randomUUID)(),
|
|
189
329
|
path: abs,
|
|
190
330
|
label: (label || "").trim() || defaultWorkspaceLabel(abs),
|
|
191
331
|
addedAt: Date.now()
|
|
@@ -210,258 +350,15 @@ function setDefaultWorkspaceId(config2, id) {
|
|
|
210
350
|
if (validateWorkspacePath(abs).ok !== true) return { error: "Workspace path is no longer valid" };
|
|
211
351
|
return { config: { ...config2, defaultWorkspaceId: id } };
|
|
212
352
|
}
|
|
213
|
-
var fs, os, path,
|
|
353
|
+
var fs, os, path, import_crypto2, MAX_WORKSPACES;
|
|
214
354
|
var init_workspaces = __esm({
|
|
215
355
|
"../../oss/packages/daemon-core/src/config/workspaces.ts"() {
|
|
216
356
|
"use strict";
|
|
217
357
|
fs = __toESM(require("fs"));
|
|
218
358
|
os = __toESM(require("os"));
|
|
219
359
|
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
360
|
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;
|
|
361
|
+
MAX_WORKSPACES = 50;
|
|
465
362
|
}
|
|
466
363
|
});
|
|
467
364
|
|
|
@@ -469,9 +366,9 @@ var init_workspace_activity = __esm({
|
|
|
469
366
|
function normalizeWorkspace(workspace) {
|
|
470
367
|
if (!workspace) return "";
|
|
471
368
|
try {
|
|
472
|
-
return
|
|
369
|
+
return path2.resolve(expandPath(workspace));
|
|
473
370
|
} catch {
|
|
474
|
-
return
|
|
371
|
+
return path2.resolve(workspace);
|
|
475
372
|
}
|
|
476
373
|
}
|
|
477
374
|
function buildRecentActivityKey(entry) {
|
|
@@ -487,33 +384,42 @@ function appendRecentActivity(config2, entry) {
|
|
|
487
384
|
const filtered = (config2.recentActivity || []).filter((item) => item.id !== nextEntry.id);
|
|
488
385
|
return {
|
|
489
386
|
...config2,
|
|
490
|
-
recentActivity: [nextEntry, ...filtered].slice(0,
|
|
387
|
+
recentActivity: [nextEntry, ...filtered].slice(0, MAX_ACTIVITY)
|
|
491
388
|
};
|
|
492
389
|
}
|
|
493
390
|
function getRecentActivity(config2, limit = 20) {
|
|
494
391
|
return [...config2.recentActivity || []].sort((a, b2) => b2.lastUsedAt - a.lastUsedAt).slice(0, limit);
|
|
495
392
|
}
|
|
496
|
-
function
|
|
497
|
-
return config2.
|
|
393
|
+
function getSessionSeenAt(config2, sessionId) {
|
|
394
|
+
return config2.sessionReads?.[sessionId] || 0;
|
|
498
395
|
}
|
|
499
|
-
function
|
|
500
|
-
|
|
501
|
-
|
|
396
|
+
function getSessionSeenMarker(config2, sessionId) {
|
|
397
|
+
return config2.sessionReadMarkers?.[sessionId] || "";
|
|
398
|
+
}
|
|
399
|
+
function markSessionSeen(config2, sessionId, seenAt = Date.now(), completionMarker) {
|
|
400
|
+
const prev = config2.sessionReads || {};
|
|
401
|
+
const nextSeenAt = Math.max(prev[sessionId] || 0, seenAt);
|
|
402
|
+
const prevMarkers = config2.sessionReadMarkers || {};
|
|
403
|
+
const nextMarker = typeof completionMarker === "string" ? completionMarker : "";
|
|
502
404
|
return {
|
|
503
405
|
...config2,
|
|
504
|
-
|
|
406
|
+
sessionReads: {
|
|
505
407
|
...prev,
|
|
506
|
-
[
|
|
507
|
-
}
|
|
408
|
+
[sessionId]: nextSeenAt
|
|
409
|
+
},
|
|
410
|
+
sessionReadMarkers: nextMarker ? {
|
|
411
|
+
...prevMarkers,
|
|
412
|
+
[sessionId]: nextMarker
|
|
413
|
+
} : prevMarkers
|
|
508
414
|
};
|
|
509
415
|
}
|
|
510
|
-
var
|
|
416
|
+
var path2, MAX_ACTIVITY;
|
|
511
417
|
var init_recent_activity = __esm({
|
|
512
418
|
"../../oss/packages/daemon-core/src/config/recent-activity.ts"() {
|
|
513
419
|
"use strict";
|
|
514
|
-
|
|
420
|
+
path2 = __toESM(require("path"));
|
|
515
421
|
init_workspaces();
|
|
516
|
-
|
|
422
|
+
MAX_ACTIVITY = 30;
|
|
517
423
|
}
|
|
518
424
|
});
|
|
519
425
|
|
|
@@ -628,15 +534,15 @@ function parseVersion(raw) {
|
|
|
628
534
|
return match ? match[1] : raw.split("\n")[0].slice(0, 100);
|
|
629
535
|
}
|
|
630
536
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
631
|
-
return new Promise((
|
|
537
|
+
return new Promise((resolve12) => {
|
|
632
538
|
const child = (0, import_child_process2.exec)(cmd, { encoding: "utf-8", timeout: timeoutMs }, (err, stdout) => {
|
|
633
539
|
if (err || !stdout?.trim()) {
|
|
634
|
-
|
|
540
|
+
resolve12(null);
|
|
635
541
|
} else {
|
|
636
|
-
|
|
542
|
+
resolve12(stdout.trim());
|
|
637
543
|
}
|
|
638
544
|
});
|
|
639
|
-
child.on("error", () =>
|
|
545
|
+
child.on("error", () => resolve12(null));
|
|
640
546
|
});
|
|
641
547
|
}
|
|
642
548
|
async function detectCLIs(providerLoader) {
|
|
@@ -751,7 +657,7 @@ function checkDateRotation() {
|
|
|
751
657
|
const today = getDateStr();
|
|
752
658
|
if (today !== currentDate) {
|
|
753
659
|
currentDate = today;
|
|
754
|
-
currentLogFile =
|
|
660
|
+
currentLogFile = path3.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
755
661
|
cleanOldLogs();
|
|
756
662
|
}
|
|
757
663
|
}
|
|
@@ -765,7 +671,7 @@ function cleanOldLogs() {
|
|
|
765
671
|
const dateMatch = file2.match(/daemon-(\d{4}-\d{2}-\d{2})/);
|
|
766
672
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
767
673
|
try {
|
|
768
|
-
fs2.unlinkSync(
|
|
674
|
+
fs2.unlinkSync(path3.join(LOG_DIR, file2));
|
|
769
675
|
} catch {
|
|
770
676
|
}
|
|
771
677
|
}
|
|
@@ -882,17 +788,17 @@ function installGlobalInterceptor() {
|
|
|
882
788
|
writeToFile(`Log file: ${currentLogFile}`);
|
|
883
789
|
writeToFile(`Log level: ${currentLevel}`);
|
|
884
790
|
}
|
|
885
|
-
var fs2,
|
|
791
|
+
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
792
|
var init_logger = __esm({
|
|
887
793
|
"../../oss/packages/daemon-core/src/logging/logger.ts"() {
|
|
888
794
|
"use strict";
|
|
889
795
|
fs2 = __toESM(require("fs"));
|
|
890
|
-
|
|
796
|
+
path3 = __toESM(require("path"));
|
|
891
797
|
os4 = __toESM(require("os"));
|
|
892
798
|
LEVEL_NUM = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
893
799
|
LEVEL_LABEL = { debug: "DBG", info: "INF", warn: "WRN", error: "ERR" };
|
|
894
800
|
currentLevel = "info";
|
|
895
|
-
LOG_DIR = process.platform === "win32" ?
|
|
801
|
+
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
802
|
MAX_LOG_SIZE = 5 * 1024 * 1024;
|
|
897
803
|
MAX_LOG_DAYS = 7;
|
|
898
804
|
try {
|
|
@@ -900,16 +806,16 @@ var init_logger = __esm({
|
|
|
900
806
|
} catch {
|
|
901
807
|
}
|
|
902
808
|
currentDate = getDateStr();
|
|
903
|
-
currentLogFile =
|
|
809
|
+
currentLogFile = path3.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
904
810
|
cleanOldLogs();
|
|
905
811
|
try {
|
|
906
|
-
const oldLog =
|
|
812
|
+
const oldLog = path3.join(LOG_DIR, "daemon.log");
|
|
907
813
|
if (fs2.existsSync(oldLog)) {
|
|
908
814
|
const stat4 = fs2.statSync(oldLog);
|
|
909
815
|
const oldDate = stat4.mtime.toISOString().slice(0, 10);
|
|
910
|
-
fs2.renameSync(oldLog,
|
|
816
|
+
fs2.renameSync(oldLog, path3.join(LOG_DIR, `daemon-${oldDate}.log`));
|
|
911
817
|
}
|
|
912
|
-
const oldLogBackup =
|
|
818
|
+
const oldLogBackup = path3.join(LOG_DIR, "daemon.log.old");
|
|
913
819
|
if (fs2.existsSync(oldLogBackup)) {
|
|
914
820
|
fs2.unlinkSync(oldLogBackup);
|
|
915
821
|
}
|
|
@@ -941,7 +847,7 @@ var init_logger = __esm({
|
|
|
941
847
|
}
|
|
942
848
|
};
|
|
943
849
|
interceptorInstalled = false;
|
|
944
|
-
LOG_PATH =
|
|
850
|
+
LOG_PATH = path3.join(LOG_DIR, `daemon-${getDateStr()}.log`);
|
|
945
851
|
}
|
|
946
852
|
});
|
|
947
853
|
|
|
@@ -1030,7 +936,7 @@ var init_manager = __esm({
|
|
|
1030
936
|
* Returns multiple entries if multiple IDE windows are open on same port
|
|
1031
937
|
*/
|
|
1032
938
|
static listAllTargets(port) {
|
|
1033
|
-
return new Promise((
|
|
939
|
+
return new Promise((resolve12) => {
|
|
1034
940
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
1035
941
|
let data = "";
|
|
1036
942
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -1046,16 +952,16 @@ var init_manager = __esm({
|
|
|
1046
952
|
(t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
|
|
1047
953
|
);
|
|
1048
954
|
const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
|
|
1049
|
-
|
|
955
|
+
resolve12(mainPages.length > 0 ? mainPages : fallbackPages);
|
|
1050
956
|
} catch {
|
|
1051
|
-
|
|
957
|
+
resolve12([]);
|
|
1052
958
|
}
|
|
1053
959
|
});
|
|
1054
960
|
});
|
|
1055
|
-
req.on("error", () =>
|
|
961
|
+
req.on("error", () => resolve12([]));
|
|
1056
962
|
req.setTimeout(2e3, () => {
|
|
1057
963
|
req.destroy();
|
|
1058
|
-
|
|
964
|
+
resolve12([]);
|
|
1059
965
|
});
|
|
1060
966
|
});
|
|
1061
967
|
}
|
|
@@ -1095,7 +1001,7 @@ var init_manager = __esm({
|
|
|
1095
1001
|
}
|
|
1096
1002
|
}
|
|
1097
1003
|
findTargetOnPort(port) {
|
|
1098
|
-
return new Promise((
|
|
1004
|
+
return new Promise((resolve12) => {
|
|
1099
1005
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
1100
1006
|
let data = "";
|
|
1101
1007
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -1106,7 +1012,7 @@ var init_manager = __esm({
|
|
|
1106
1012
|
(t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
|
|
1107
1013
|
);
|
|
1108
1014
|
if (pages.length === 0) {
|
|
1109
|
-
|
|
1015
|
+
resolve12(targets.find((t) => t.webSocketDebuggerUrl) || null);
|
|
1110
1016
|
return;
|
|
1111
1017
|
}
|
|
1112
1018
|
const mainPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
|
|
@@ -1116,24 +1022,24 @@ var init_manager = __esm({
|
|
|
1116
1022
|
const specific = list.find((t) => t.id === this._targetId);
|
|
1117
1023
|
if (specific) {
|
|
1118
1024
|
this._pageTitle = specific.title || "";
|
|
1119
|
-
|
|
1025
|
+
resolve12(specific);
|
|
1120
1026
|
} else {
|
|
1121
1027
|
this.log(`[CDP] Target ${this._targetId} not found in page list`);
|
|
1122
|
-
|
|
1028
|
+
resolve12(null);
|
|
1123
1029
|
}
|
|
1124
1030
|
return;
|
|
1125
1031
|
}
|
|
1126
1032
|
this._pageTitle = list[0]?.title || "";
|
|
1127
|
-
|
|
1033
|
+
resolve12(list[0]);
|
|
1128
1034
|
} catch {
|
|
1129
|
-
|
|
1035
|
+
resolve12(null);
|
|
1130
1036
|
}
|
|
1131
1037
|
});
|
|
1132
1038
|
});
|
|
1133
|
-
req.on("error", () =>
|
|
1039
|
+
req.on("error", () => resolve12(null));
|
|
1134
1040
|
req.setTimeout(2e3, () => {
|
|
1135
1041
|
req.destroy();
|
|
1136
|
-
|
|
1042
|
+
resolve12(null);
|
|
1137
1043
|
});
|
|
1138
1044
|
});
|
|
1139
1045
|
}
|
|
@@ -1144,7 +1050,7 @@ var init_manager = __esm({
|
|
|
1144
1050
|
this.extensionProviders = providers;
|
|
1145
1051
|
}
|
|
1146
1052
|
connectToTarget(wsUrl) {
|
|
1147
|
-
return new Promise((
|
|
1053
|
+
return new Promise((resolve12) => {
|
|
1148
1054
|
this.ws = new import_ws.default(wsUrl);
|
|
1149
1055
|
this.ws.on("open", async () => {
|
|
1150
1056
|
this._connected = true;
|
|
@@ -1154,17 +1060,17 @@ var init_manager = __esm({
|
|
|
1154
1060
|
}
|
|
1155
1061
|
this.connectBrowserWs().catch(() => {
|
|
1156
1062
|
});
|
|
1157
|
-
|
|
1063
|
+
resolve12(true);
|
|
1158
1064
|
});
|
|
1159
1065
|
this.ws.on("message", (data) => {
|
|
1160
1066
|
try {
|
|
1161
1067
|
const msg = JSON.parse(data.toString());
|
|
1162
1068
|
if (msg.id && this.pending.has(msg.id)) {
|
|
1163
|
-
const { resolve:
|
|
1069
|
+
const { resolve: resolve13, reject } = this.pending.get(msg.id);
|
|
1164
1070
|
this.pending.delete(msg.id);
|
|
1165
1071
|
this.failureCount = 0;
|
|
1166
1072
|
if (msg.error) reject(new Error(msg.error.message));
|
|
1167
|
-
else
|
|
1073
|
+
else resolve13(msg.result);
|
|
1168
1074
|
} else if (msg.method === "Runtime.executionContextCreated") {
|
|
1169
1075
|
this.contexts.add(msg.params.context.id);
|
|
1170
1076
|
} else if (msg.method === "Runtime.executionContextDestroyed") {
|
|
@@ -1187,7 +1093,7 @@ var init_manager = __esm({
|
|
|
1187
1093
|
this.ws.on("error", (err) => {
|
|
1188
1094
|
this.log(`[CDP] WebSocket error: ${err.message}`);
|
|
1189
1095
|
this._connected = false;
|
|
1190
|
-
|
|
1096
|
+
resolve12(false);
|
|
1191
1097
|
});
|
|
1192
1098
|
});
|
|
1193
1099
|
}
|
|
@@ -1201,7 +1107,7 @@ var init_manager = __esm({
|
|
|
1201
1107
|
return;
|
|
1202
1108
|
}
|
|
1203
1109
|
this.log(`[CDP] Connecting browser WS for target discovery...`);
|
|
1204
|
-
await new Promise((
|
|
1110
|
+
await new Promise((resolve12, reject) => {
|
|
1205
1111
|
this.browserWs = new import_ws.default(browserWsUrl);
|
|
1206
1112
|
this.browserWs.on("open", async () => {
|
|
1207
1113
|
this._browserConnected = true;
|
|
@@ -1211,16 +1117,16 @@ var init_manager = __esm({
|
|
|
1211
1117
|
} catch (e) {
|
|
1212
1118
|
this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
|
|
1213
1119
|
}
|
|
1214
|
-
|
|
1120
|
+
resolve12();
|
|
1215
1121
|
});
|
|
1216
1122
|
this.browserWs.on("message", (data) => {
|
|
1217
1123
|
try {
|
|
1218
1124
|
const msg = JSON.parse(data.toString());
|
|
1219
1125
|
if (msg.id && this.browserPending.has(msg.id)) {
|
|
1220
|
-
const { resolve:
|
|
1126
|
+
const { resolve: resolve13, reject: reject2 } = this.browserPending.get(msg.id);
|
|
1221
1127
|
this.browserPending.delete(msg.id);
|
|
1222
1128
|
if (msg.error) reject2(new Error(msg.error.message));
|
|
1223
|
-
else
|
|
1129
|
+
else resolve13(msg.result);
|
|
1224
1130
|
}
|
|
1225
1131
|
} catch {
|
|
1226
1132
|
}
|
|
@@ -1240,31 +1146,31 @@ var init_manager = __esm({
|
|
|
1240
1146
|
}
|
|
1241
1147
|
}
|
|
1242
1148
|
getBrowserWsUrl() {
|
|
1243
|
-
return new Promise((
|
|
1149
|
+
return new Promise((resolve12) => {
|
|
1244
1150
|
const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
|
|
1245
1151
|
let data = "";
|
|
1246
1152
|
res.on("data", (chunk) => data += chunk.toString());
|
|
1247
1153
|
res.on("end", () => {
|
|
1248
1154
|
try {
|
|
1249
1155
|
const info = JSON.parse(data);
|
|
1250
|
-
|
|
1156
|
+
resolve12(info.webSocketDebuggerUrl || null);
|
|
1251
1157
|
} catch {
|
|
1252
|
-
|
|
1158
|
+
resolve12(null);
|
|
1253
1159
|
}
|
|
1254
1160
|
});
|
|
1255
1161
|
});
|
|
1256
|
-
req.on("error", () =>
|
|
1162
|
+
req.on("error", () => resolve12(null));
|
|
1257
1163
|
req.setTimeout(3e3, () => {
|
|
1258
1164
|
req.destroy();
|
|
1259
|
-
|
|
1165
|
+
resolve12(null);
|
|
1260
1166
|
});
|
|
1261
1167
|
});
|
|
1262
1168
|
}
|
|
1263
1169
|
sendBrowser(method, params = {}, timeoutMs = 15e3) {
|
|
1264
|
-
return new Promise((
|
|
1170
|
+
return new Promise((resolve12, reject) => {
|
|
1265
1171
|
if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
|
|
1266
1172
|
const id = this.browserMsgId++;
|
|
1267
|
-
this.browserPending.set(id, { resolve:
|
|
1173
|
+
this.browserPending.set(id, { resolve: resolve12, reject });
|
|
1268
1174
|
this.browserWs.send(JSON.stringify({ id, method, params }));
|
|
1269
1175
|
setTimeout(() => {
|
|
1270
1176
|
if (this.browserPending.has(id)) {
|
|
@@ -1304,11 +1210,11 @@ var init_manager = __esm({
|
|
|
1304
1210
|
}
|
|
1305
1211
|
// ─── CDP Protocol ────────────────────────────────────────
|
|
1306
1212
|
sendInternal(method, params = {}, timeoutMs = 15e3) {
|
|
1307
|
-
return new Promise((
|
|
1213
|
+
return new Promise((resolve12, reject) => {
|
|
1308
1214
|
if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
|
|
1309
1215
|
if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
|
|
1310
1216
|
const id = this.msgId++;
|
|
1311
|
-
this.pending.set(id, { resolve:
|
|
1217
|
+
this.pending.set(id, { resolve: resolve12, reject });
|
|
1312
1218
|
this.ws.send(JSON.stringify({ id, method, params }));
|
|
1313
1219
|
setTimeout(() => {
|
|
1314
1220
|
if (this.pending.has(id)) {
|
|
@@ -1557,7 +1463,7 @@ var init_manager = __esm({
|
|
|
1557
1463
|
const browserWs = this.browserWs;
|
|
1558
1464
|
let msgId = this.browserMsgId;
|
|
1559
1465
|
const sendWs = (method, params = {}, sessionId) => {
|
|
1560
|
-
return new Promise((
|
|
1466
|
+
return new Promise((resolve12, reject) => {
|
|
1561
1467
|
const mid = msgId++;
|
|
1562
1468
|
this.browserMsgId = msgId;
|
|
1563
1469
|
const handler = (raw) => {
|
|
@@ -1566,7 +1472,7 @@ var init_manager = __esm({
|
|
|
1566
1472
|
if (msg.id === mid) {
|
|
1567
1473
|
browserWs.removeListener("message", handler);
|
|
1568
1474
|
if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
|
|
1569
|
-
else
|
|
1475
|
+
else resolve12(msg.result);
|
|
1570
1476
|
}
|
|
1571
1477
|
} catch {
|
|
1572
1478
|
}
|
|
@@ -1757,14 +1663,14 @@ var init_manager = __esm({
|
|
|
1757
1663
|
if (!ws2 || ws2.readyState !== import_ws.default.OPEN) {
|
|
1758
1664
|
throw new Error("CDP not connected");
|
|
1759
1665
|
}
|
|
1760
|
-
return new Promise((
|
|
1666
|
+
return new Promise((resolve12, reject) => {
|
|
1761
1667
|
const id = getNextId();
|
|
1762
1668
|
pendingMap.set(id, {
|
|
1763
1669
|
resolve: (result) => {
|
|
1764
1670
|
if (result?.result?.subtype === "error") {
|
|
1765
1671
|
reject(new Error(result.result.description));
|
|
1766
1672
|
} else {
|
|
1767
|
-
|
|
1673
|
+
resolve12(result?.result?.value);
|
|
1768
1674
|
}
|
|
1769
1675
|
},
|
|
1770
1676
|
reject
|
|
@@ -1796,10 +1702,10 @@ var init_manager = __esm({
|
|
|
1796
1702
|
throw new Error("CDP not connected");
|
|
1797
1703
|
}
|
|
1798
1704
|
const sendViaSession = (method, params = {}) => {
|
|
1799
|
-
return new Promise((
|
|
1705
|
+
return new Promise((resolve12, reject) => {
|
|
1800
1706
|
const pendingMap = this._browserConnected ? this.browserPending : this.pending;
|
|
1801
1707
|
const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
|
|
1802
|
-
pendingMap.set(id, { resolve:
|
|
1708
|
+
pendingMap.set(id, { resolve: resolve12, reject });
|
|
1803
1709
|
ws2.send(JSON.stringify({ id, sessionId, method, params }));
|
|
1804
1710
|
setTimeout(() => {
|
|
1805
1711
|
if (pendingMap.has(id)) {
|
|
@@ -2526,7 +2432,7 @@ var init_extension_provider_instance = __esm({
|
|
|
2526
2432
|
function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
|
|
2527
2433
|
try {
|
|
2528
2434
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
2529
|
-
const dir =
|
|
2435
|
+
const dir = path4.join(HISTORY_DIR, sanitized);
|
|
2530
2436
|
if (!fs3.existsSync(dir)) return { messages: [], hasMore: false };
|
|
2531
2437
|
const sanitizedInstance = instanceId?.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
2532
2438
|
const files = fs3.readdirSync(dir).filter((f) => {
|
|
@@ -2540,7 +2446,7 @@ function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
|
|
|
2540
2446
|
const needed = offset + limit + 1;
|
|
2541
2447
|
for (const file2 of files) {
|
|
2542
2448
|
if (allMessages.length >= needed) break;
|
|
2543
|
-
const filePath =
|
|
2449
|
+
const filePath = path4.join(dir, file2);
|
|
2544
2450
|
const content = fs3.readFileSync(filePath, "utf-8");
|
|
2545
2451
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
2546
2452
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
@@ -2559,14 +2465,14 @@ function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
|
|
|
2559
2465
|
return { messages: [], hasMore: false };
|
|
2560
2466
|
}
|
|
2561
2467
|
}
|
|
2562
|
-
var fs3,
|
|
2468
|
+
var fs3, path4, os5, HISTORY_DIR, RETAIN_DAYS, ChatHistoryWriter;
|
|
2563
2469
|
var init_chat_history = __esm({
|
|
2564
2470
|
"../../oss/packages/daemon-core/src/config/chat-history.ts"() {
|
|
2565
2471
|
"use strict";
|
|
2566
2472
|
fs3 = __toESM(require("fs"));
|
|
2567
|
-
|
|
2473
|
+
path4 = __toESM(require("path"));
|
|
2568
2474
|
os5 = __toESM(require("os"));
|
|
2569
|
-
HISTORY_DIR =
|
|
2475
|
+
HISTORY_DIR = path4.join(os5.homedir(), ".adhdev", "history");
|
|
2570
2476
|
RETAIN_DAYS = 30;
|
|
2571
2477
|
ChatHistoryWriter = class {
|
|
2572
2478
|
/** Last seen message count per agent (deduplication) */
|
|
@@ -2609,11 +2515,11 @@ var init_chat_history = __esm({
|
|
|
2609
2515
|
});
|
|
2610
2516
|
}
|
|
2611
2517
|
if (newMessages.length === 0) return;
|
|
2612
|
-
const dir =
|
|
2518
|
+
const dir = path4.join(HISTORY_DIR, this.sanitize(agentType));
|
|
2613
2519
|
fs3.mkdirSync(dir, { recursive: true });
|
|
2614
2520
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
2615
2521
|
const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
|
|
2616
|
-
const filePath =
|
|
2522
|
+
const filePath = path4.join(dir, `${filePrefix}${date5}.jsonl`);
|
|
2617
2523
|
const lines = newMessages.map((m) => JSON.stringify(m)).join("\n") + "\n";
|
|
2618
2524
|
fs3.appendFileSync(filePath, lines, "utf-8");
|
|
2619
2525
|
const prevCount = this.lastSeenCounts.get(dedupKey) || 0;
|
|
@@ -2657,11 +2563,11 @@ ${next}`;
|
|
|
2657
2563
|
this.lastSeenTerminal.set(dedupKey, next);
|
|
2658
2564
|
return;
|
|
2659
2565
|
}
|
|
2660
|
-
const dir =
|
|
2566
|
+
const dir = path4.join(HISTORY_DIR, this.sanitize(agentType));
|
|
2661
2567
|
fs3.mkdirSync(dir, { recursive: true });
|
|
2662
2568
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
2663
2569
|
const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
|
|
2664
|
-
const filePath =
|
|
2570
|
+
const filePath = path4.join(dir, `${filePrefix}${date5}.terminal.log`);
|
|
2665
2571
|
fs3.appendFileSync(filePath, delta, "utf-8");
|
|
2666
2572
|
this.lastSeenTerminal.set(dedupKey, next);
|
|
2667
2573
|
if (!this.rotated) {
|
|
@@ -2685,10 +2591,10 @@ ${next}`;
|
|
|
2685
2591
|
const cutoff = Date.now() - RETAIN_DAYS * 24 * 60 * 60 * 1e3;
|
|
2686
2592
|
const agentDirs = fs3.readdirSync(HISTORY_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
2687
2593
|
for (const dir of agentDirs) {
|
|
2688
|
-
const dirPath =
|
|
2594
|
+
const dirPath = path4.join(HISTORY_DIR, dir.name);
|
|
2689
2595
|
const files = fs3.readdirSync(dirPath).filter((f) => f.endsWith(".jsonl") || f.endsWith(".terminal.log"));
|
|
2690
2596
|
for (const file2 of files) {
|
|
2691
|
-
const filePath =
|
|
2597
|
+
const filePath = path4.join(dirPath, file2);
|
|
2692
2598
|
const stat4 = fs3.statSync(filePath);
|
|
2693
2599
|
if (stat4.mtimeMs < cutoff) {
|
|
2694
2600
|
fs3.unlinkSync(filePath);
|
|
@@ -3757,6 +3663,14 @@ function buildSessionEntries(allStates, cdpManagers) {
|
|
|
3757
3663
|
for (const state of acpStates) {
|
|
3758
3664
|
sessions.push(buildAcpSession(state));
|
|
3759
3665
|
}
|
|
3666
|
+
const extensionParentIds = new Set(
|
|
3667
|
+
sessions.filter((session) => session.transport === "cdp-webview" && !!session.parentId).map((session) => session.parentId)
|
|
3668
|
+
);
|
|
3669
|
+
for (const session of sessions) {
|
|
3670
|
+
if (session.transport === "cdp-page" && extensionParentIds.has(session.id)) {
|
|
3671
|
+
session.surfaceHidden = true;
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3760
3674
|
return sessions;
|
|
3761
3675
|
}
|
|
3762
3676
|
var IDE_SESSION_CAPABILITIES, EXTENSION_SESSION_CAPABILITIES, PTY_SESSION_CAPABILITIES, ACP_SESSION_CAPABILITIES;
|
|
@@ -4826,11 +4740,11 @@ function resolveSafePath(requestedPath) {
|
|
|
4826
4740
|
const home = os6.homedir();
|
|
4827
4741
|
let resolved;
|
|
4828
4742
|
if (requestedPath.startsWith("~")) {
|
|
4829
|
-
resolved =
|
|
4830
|
-
} else if (
|
|
4743
|
+
resolved = path5.join(home, requestedPath.slice(1));
|
|
4744
|
+
} else if (path5.isAbsolute(requestedPath)) {
|
|
4831
4745
|
resolved = requestedPath;
|
|
4832
4746
|
} else {
|
|
4833
|
-
resolved =
|
|
4747
|
+
resolved = path5.resolve(requestedPath);
|
|
4834
4748
|
}
|
|
4835
4749
|
return resolved;
|
|
4836
4750
|
}
|
|
@@ -4846,7 +4760,7 @@ async function handleFileRead(h, args) {
|
|
|
4846
4760
|
async function handleFileWrite(h, args) {
|
|
4847
4761
|
try {
|
|
4848
4762
|
const filePath = resolveSafePath(args?.path);
|
|
4849
|
-
fs4.mkdirSync(
|
|
4763
|
+
fs4.mkdirSync(path5.dirname(filePath), { recursive: true });
|
|
4850
4764
|
fs4.writeFileSync(filePath, args?.content || "", "utf-8");
|
|
4851
4765
|
return { success: true, path: filePath };
|
|
4852
4766
|
} catch (e) {
|
|
@@ -4860,7 +4774,7 @@ async function handleFileList(h, args) {
|
|
|
4860
4774
|
const files = entries.map((e) => ({
|
|
4861
4775
|
name: e.name,
|
|
4862
4776
|
type: e.isDirectory() ? "directory" : "file",
|
|
4863
|
-
size: e.isFile() ? fs4.statSync(
|
|
4777
|
+
size: e.isFile() ? fs4.statSync(path5.join(dirPath, e.name)).size : void 0
|
|
4864
4778
|
}));
|
|
4865
4779
|
return { success: true, files, path: dirPath };
|
|
4866
4780
|
} catch (e) {
|
|
@@ -4870,12 +4784,12 @@ async function handleFileList(h, args) {
|
|
|
4870
4784
|
async function handleFileListBrowse(h, args) {
|
|
4871
4785
|
return handleFileList(h, args);
|
|
4872
4786
|
}
|
|
4873
|
-
var fs4,
|
|
4787
|
+
var fs4, path5, os6, KEY_TO_VK;
|
|
4874
4788
|
var init_cdp_commands = __esm({
|
|
4875
4789
|
"../../oss/packages/daemon-core/src/commands/cdp-commands.ts"() {
|
|
4876
4790
|
"use strict";
|
|
4877
4791
|
fs4 = __toESM(require("fs"));
|
|
4878
|
-
|
|
4792
|
+
path5 = __toESM(require("path"));
|
|
4879
4793
|
os6 = __toESM(require("os"));
|
|
4880
4794
|
KEY_TO_VK = {
|
|
4881
4795
|
Backspace: 8,
|
|
@@ -5068,13 +4982,12 @@ function handleGetIdeExtensions(h, args) {
|
|
|
5068
4982
|
const loader = h.ctx.providerLoader;
|
|
5069
4983
|
if (!loader) return { success: false, error: "ProviderLoader not initialized" };
|
|
5070
4984
|
const allExtProviders = loader.getByCategory?.("extension") || [];
|
|
5071
|
-
const config2 = loadConfig();
|
|
5072
4985
|
if (ideType) {
|
|
5073
4986
|
const extensions = allExtProviders.map((p) => ({
|
|
5074
4987
|
type: p.type,
|
|
5075
4988
|
name: p.name,
|
|
5076
4989
|
extensionId: p.extensionId,
|
|
5077
|
-
enabled:
|
|
4990
|
+
enabled: loader.getIdeExtensionEnabledState?.(ideType, p.type) === true
|
|
5078
4991
|
}));
|
|
5079
4992
|
return { success: true, ideType, extensions };
|
|
5080
4993
|
}
|
|
@@ -5085,7 +4998,7 @@ function handleGetIdeExtensions(h, args) {
|
|
|
5085
4998
|
type: p.type,
|
|
5086
4999
|
name: p.name,
|
|
5087
5000
|
extensionId: p.extensionId,
|
|
5088
|
-
enabled:
|
|
5001
|
+
enabled: loader.getIdeExtensionEnabledState?.(ide, p.type) === true
|
|
5089
5002
|
}));
|
|
5090
5003
|
}
|
|
5091
5004
|
return { success: true, ideExtensions: result };
|
|
@@ -5108,7 +5021,6 @@ function handleSetIdeExtension(h, args) {
|
|
|
5108
5021
|
var init_stream_commands = __esm({
|
|
5109
5022
|
"../../oss/packages/daemon-core/src/commands/stream-commands.ts"() {
|
|
5110
5023
|
"use strict";
|
|
5111
|
-
init_config();
|
|
5112
5024
|
init_logger();
|
|
5113
5025
|
}
|
|
5114
5026
|
});
|
|
@@ -5121,9 +5033,7 @@ function handleWorkspaceList() {
|
|
|
5121
5033
|
success: true,
|
|
5122
5034
|
workspaces: state.workspaces,
|
|
5123
5035
|
defaultWorkspaceId: state.defaultWorkspaceId,
|
|
5124
|
-
defaultWorkspacePath: state.defaultWorkspacePath
|
|
5125
|
-
legacyRecentPaths: config2.recentCliWorkspaces || [],
|
|
5126
|
-
activity: getWorkspaceActivity(config2, 25)
|
|
5036
|
+
defaultWorkspacePath: state.defaultWorkspacePath
|
|
5127
5037
|
};
|
|
5128
5038
|
}
|
|
5129
5039
|
function handleWorkspaceAdd(args) {
|
|
@@ -5134,10 +5044,9 @@ function handleWorkspaceAdd(args) {
|
|
|
5134
5044
|
const config2 = loadConfig();
|
|
5135
5045
|
const result = addWorkspaceEntry(config2, rawPath, label, { createIfMissing });
|
|
5136
5046
|
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) };
|
|
5047
|
+
saveConfig(result.config);
|
|
5048
|
+
const state = getWorkspaceState(result.config);
|
|
5049
|
+
return { success: true, entry: result.entry, ...state };
|
|
5141
5050
|
}
|
|
5142
5051
|
function handleWorkspaceRemove(args) {
|
|
5143
5052
|
const id = (args?.id || "").trim();
|
|
@@ -5146,13 +5055,9 @@ function handleWorkspaceRemove(args) {
|
|
|
5146
5055
|
const removed = (config2.workspaces || []).find((w) => w.id === id);
|
|
5147
5056
|
const result = removeWorkspaceEntry(config2, id);
|
|
5148
5057
|
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) };
|
|
5058
|
+
saveConfig(result.config);
|
|
5059
|
+
const state = getWorkspaceState(result.config);
|
|
5060
|
+
return { success: true, removedId: id, ...state };
|
|
5156
5061
|
}
|
|
5157
5062
|
function handleWorkspaceSetDefault(args) {
|
|
5158
5063
|
const clear = args?.clear === true || args?.id === null || args?.id === "";
|
|
@@ -5164,8 +5069,7 @@ function handleWorkspaceSetDefault(args) {
|
|
|
5164
5069
|
const state2 = getWorkspaceState(result2.config);
|
|
5165
5070
|
return {
|
|
5166
5071
|
success: true,
|
|
5167
|
-
...state2
|
|
5168
|
-
activity: getWorkspaceActivity(result2.config, 25)
|
|
5072
|
+
...state2
|
|
5169
5073
|
};
|
|
5170
5074
|
}
|
|
5171
5075
|
const pathArg = args?.path != null && String(args.path).trim() ? String(args.path).trim() : "";
|
|
@@ -5189,21 +5093,15 @@ function handleWorkspaceSetDefault(args) {
|
|
|
5189
5093
|
}
|
|
5190
5094
|
const result = setDefaultWorkspaceId(config2, nextId);
|
|
5191
5095
|
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) };
|
|
5096
|
+
saveConfig(result.config);
|
|
5097
|
+
const state = getWorkspaceState(result.config);
|
|
5098
|
+
return { success: true, ...state };
|
|
5200
5099
|
}
|
|
5201
5100
|
var init_workspace_commands = __esm({
|
|
5202
5101
|
"../../oss/packages/daemon-core/src/commands/workspace-commands.ts"() {
|
|
5203
5102
|
"use strict";
|
|
5204
5103
|
init_config();
|
|
5205
5104
|
init_workspaces();
|
|
5206
|
-
init_workspace_activity();
|
|
5207
5105
|
}
|
|
5208
5106
|
});
|
|
5209
5107
|
|
|
@@ -5282,15 +5180,12 @@ var init_handler = __esm({
|
|
|
5282
5180
|
"use strict";
|
|
5283
5181
|
init_devtools();
|
|
5284
5182
|
init_builders();
|
|
5285
|
-
init_config();
|
|
5286
5183
|
init_chat_history();
|
|
5287
5184
|
init_logger();
|
|
5288
5185
|
init_chat_commands();
|
|
5289
5186
|
init_cdp_commands();
|
|
5290
5187
|
init_stream_commands();
|
|
5291
5188
|
init_workspace_commands();
|
|
5292
|
-
init_workspaces();
|
|
5293
|
-
init_workspace_activity();
|
|
5294
5189
|
COMMAND_DEBUG_LEVELS = /* @__PURE__ */ new Set([
|
|
5295
5190
|
"pty_input",
|
|
5296
5191
|
"pty_resize",
|
|
@@ -5549,22 +5444,7 @@ var init_handler = __esm({
|
|
|
5549
5444
|
return handleFileList(this, args);
|
|
5550
5445
|
case "file_list_browse":
|
|
5551
5446
|
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
5447
|
// ─── 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
5448
|
case "workspace_list":
|
|
5569
5449
|
return handleWorkspaceList();
|
|
5570
5450
|
case "workspace_add":
|
|
@@ -5572,7 +5452,6 @@ var init_handler = __esm({
|
|
|
5572
5452
|
case "workspace_remove":
|
|
5573
5453
|
return handleWorkspaceRemove(args);
|
|
5574
5454
|
case "workspace_set_default":
|
|
5575
|
-
case "workspace_set_active":
|
|
5576
5455
|
return handleWorkspaceSetDefault(args);
|
|
5577
5456
|
// ─── Script manage ───────────────────
|
|
5578
5457
|
case "refresh_scripts":
|
|
@@ -5618,19 +5497,6 @@ var init_handler = __esm({
|
|
|
5618
5497
|
}
|
|
5619
5498
|
}
|
|
5620
5499
|
// ─── 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
5500
|
async handleRefreshScripts(_args) {
|
|
5635
5501
|
if (this._ctx.providerLoader) {
|
|
5636
5502
|
await this._ctx.providerLoader.fetchLatest().catch(() => {
|
|
@@ -5648,7 +5514,7 @@ var init_handler = __esm({
|
|
|
5648
5514
|
try {
|
|
5649
5515
|
const http3 = await import("http");
|
|
5650
5516
|
const postData = JSON.stringify(body);
|
|
5651
|
-
const result = await new Promise((
|
|
5517
|
+
const result = await new Promise((resolve12, reject) => {
|
|
5652
5518
|
const req = http3.request({
|
|
5653
5519
|
hostname: "127.0.0.1",
|
|
5654
5520
|
port: 19280,
|
|
@@ -5660,9 +5526,9 @@ var init_handler = __esm({
|
|
|
5660
5526
|
res.on("data", (chunk) => data += chunk);
|
|
5661
5527
|
res.on("end", () => {
|
|
5662
5528
|
try {
|
|
5663
|
-
|
|
5529
|
+
resolve12(JSON.parse(data));
|
|
5664
5530
|
} catch {
|
|
5665
|
-
|
|
5531
|
+
resolve12({ raw: data });
|
|
5666
5532
|
}
|
|
5667
5533
|
});
|
|
5668
5534
|
});
|
|
@@ -5680,15 +5546,15 @@ var init_handler = __esm({
|
|
|
5680
5546
|
if (!providerType) return { success: false, error: "providerType required" };
|
|
5681
5547
|
try {
|
|
5682
5548
|
const http3 = await import("http");
|
|
5683
|
-
const result = await new Promise((
|
|
5549
|
+
const result = await new Promise((resolve12, reject) => {
|
|
5684
5550
|
http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
|
|
5685
5551
|
let data = "";
|
|
5686
5552
|
res.on("data", (chunk) => data += chunk);
|
|
5687
5553
|
res.on("end", () => {
|
|
5688
5554
|
try {
|
|
5689
|
-
|
|
5555
|
+
resolve12(JSON.parse(data));
|
|
5690
5556
|
} catch {
|
|
5691
|
-
|
|
5557
|
+
resolve12({ raw: data });
|
|
5692
5558
|
}
|
|
5693
5559
|
});
|
|
5694
5560
|
}).on("error", reject);
|
|
@@ -5702,7 +5568,7 @@ var init_handler = __esm({
|
|
|
5702
5568
|
try {
|
|
5703
5569
|
const http3 = await import("http");
|
|
5704
5570
|
const postData = JSON.stringify(args || {});
|
|
5705
|
-
const result = await new Promise((
|
|
5571
|
+
const result = await new Promise((resolve12, reject) => {
|
|
5706
5572
|
const req = http3.request({
|
|
5707
5573
|
hostname: "127.0.0.1",
|
|
5708
5574
|
port: 19280,
|
|
@@ -5714,9 +5580,9 @@ var init_handler = __esm({
|
|
|
5714
5580
|
res.on("data", (chunk) => data += chunk);
|
|
5715
5581
|
res.on("end", () => {
|
|
5716
5582
|
try {
|
|
5717
|
-
|
|
5583
|
+
resolve12(JSON.parse(data));
|
|
5718
5584
|
} catch {
|
|
5719
|
-
|
|
5585
|
+
resolve12({ raw: data });
|
|
5720
5586
|
}
|
|
5721
5587
|
});
|
|
5722
5588
|
});
|
|
@@ -5837,7 +5703,7 @@ var init_readdirp = __esm({
|
|
|
5837
5703
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
5838
5704
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
5839
5705
|
if (wantBigintFsStats) {
|
|
5840
|
-
this._stat = (
|
|
5706
|
+
this._stat = (path18) => statMethod(path18, { bigint: true });
|
|
5841
5707
|
} else {
|
|
5842
5708
|
this._stat = statMethod;
|
|
5843
5709
|
}
|
|
@@ -5862,8 +5728,8 @@ var init_readdirp = __esm({
|
|
|
5862
5728
|
const par = this.parent;
|
|
5863
5729
|
const fil = par && par.files;
|
|
5864
5730
|
if (fil && fil.length > 0) {
|
|
5865
|
-
const { path:
|
|
5866
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
5731
|
+
const { path: path18, depth } = par;
|
|
5732
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path18));
|
|
5867
5733
|
const awaited = await Promise.all(slice);
|
|
5868
5734
|
for (const entry of awaited) {
|
|
5869
5735
|
if (!entry)
|
|
@@ -5903,20 +5769,20 @@ var init_readdirp = __esm({
|
|
|
5903
5769
|
this.reading = false;
|
|
5904
5770
|
}
|
|
5905
5771
|
}
|
|
5906
|
-
async _exploreDir(
|
|
5772
|
+
async _exploreDir(path18, depth) {
|
|
5907
5773
|
let files;
|
|
5908
5774
|
try {
|
|
5909
|
-
files = await (0, import_promises.readdir)(
|
|
5775
|
+
files = await (0, import_promises.readdir)(path18, this._rdOptions);
|
|
5910
5776
|
} catch (error48) {
|
|
5911
5777
|
this._onError(error48);
|
|
5912
5778
|
}
|
|
5913
|
-
return { files, depth, path:
|
|
5779
|
+
return { files, depth, path: path18 };
|
|
5914
5780
|
}
|
|
5915
|
-
async _formatEntry(dirent,
|
|
5781
|
+
async _formatEntry(dirent, path18) {
|
|
5916
5782
|
let entry;
|
|
5917
5783
|
const basename7 = this._isDirent ? dirent.name : dirent;
|
|
5918
5784
|
try {
|
|
5919
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
5785
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path18, basename7));
|
|
5920
5786
|
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename7 };
|
|
5921
5787
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
5922
5788
|
} catch (err) {
|
|
@@ -5973,16 +5839,16 @@ var init_readdirp = __esm({
|
|
|
5973
5839
|
});
|
|
5974
5840
|
|
|
5975
5841
|
// ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
|
|
5976
|
-
function createFsWatchInstance(
|
|
5842
|
+
function createFsWatchInstance(path18, options, listener, errHandler, emitRaw) {
|
|
5977
5843
|
const handleEvent = (rawEvent, evPath) => {
|
|
5978
|
-
listener(
|
|
5979
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
5980
|
-
if (evPath &&
|
|
5981
|
-
fsWatchBroadcast(sp.resolve(
|
|
5844
|
+
listener(path18);
|
|
5845
|
+
emitRaw(rawEvent, evPath, { watchedPath: path18 });
|
|
5846
|
+
if (evPath && path18 !== evPath) {
|
|
5847
|
+
fsWatchBroadcast(sp.resolve(path18, evPath), KEY_LISTENERS, sp.join(path18, evPath));
|
|
5982
5848
|
}
|
|
5983
5849
|
};
|
|
5984
5850
|
try {
|
|
5985
|
-
return (0, import_node_fs.watch)(
|
|
5851
|
+
return (0, import_node_fs.watch)(path18, {
|
|
5986
5852
|
persistent: options.persistent
|
|
5987
5853
|
}, handleEvent);
|
|
5988
5854
|
} catch (error48) {
|
|
@@ -6331,12 +6197,12 @@ var init_handler2 = __esm({
|
|
|
6331
6197
|
listener(val1, val2, val3);
|
|
6332
6198
|
});
|
|
6333
6199
|
};
|
|
6334
|
-
setFsWatchListener = (
|
|
6200
|
+
setFsWatchListener = (path18, fullPath, options, handlers) => {
|
|
6335
6201
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
6336
6202
|
let cont = FsWatchInstances.get(fullPath);
|
|
6337
6203
|
let watcher;
|
|
6338
6204
|
if (!options.persistent) {
|
|
6339
|
-
watcher = createFsWatchInstance(
|
|
6205
|
+
watcher = createFsWatchInstance(path18, options, listener, errHandler, rawEmitter);
|
|
6340
6206
|
if (!watcher)
|
|
6341
6207
|
return;
|
|
6342
6208
|
return watcher.close.bind(watcher);
|
|
@@ -6347,7 +6213,7 @@ var init_handler2 = __esm({
|
|
|
6347
6213
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
6348
6214
|
} else {
|
|
6349
6215
|
watcher = createFsWatchInstance(
|
|
6350
|
-
|
|
6216
|
+
path18,
|
|
6351
6217
|
options,
|
|
6352
6218
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
6353
6219
|
errHandler,
|
|
@@ -6362,7 +6228,7 @@ var init_handler2 = __esm({
|
|
|
6362
6228
|
cont.watcherUnusable = true;
|
|
6363
6229
|
if (isWindows && error48.code === "EPERM") {
|
|
6364
6230
|
try {
|
|
6365
|
-
const fd = await (0, import_promises2.open)(
|
|
6231
|
+
const fd = await (0, import_promises2.open)(path18, "r");
|
|
6366
6232
|
await fd.close();
|
|
6367
6233
|
broadcastErr(error48);
|
|
6368
6234
|
} catch (err) {
|
|
@@ -6393,7 +6259,7 @@ var init_handler2 = __esm({
|
|
|
6393
6259
|
};
|
|
6394
6260
|
};
|
|
6395
6261
|
FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
6396
|
-
setFsWatchFileListener = (
|
|
6262
|
+
setFsWatchFileListener = (path18, fullPath, options, handlers) => {
|
|
6397
6263
|
const { listener, rawEmitter } = handlers;
|
|
6398
6264
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
6399
6265
|
const copts = cont && cont.options;
|
|
@@ -6415,7 +6281,7 @@ var init_handler2 = __esm({
|
|
|
6415
6281
|
});
|
|
6416
6282
|
const currmtime = curr.mtimeMs;
|
|
6417
6283
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
6418
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
6284
|
+
foreach(cont.listeners, (listener2) => listener2(path18, curr));
|
|
6419
6285
|
}
|
|
6420
6286
|
})
|
|
6421
6287
|
};
|
|
@@ -6445,13 +6311,13 @@ var init_handler2 = __esm({
|
|
|
6445
6311
|
* @param listener on fs change
|
|
6446
6312
|
* @returns closer for the watcher instance
|
|
6447
6313
|
*/
|
|
6448
|
-
_watchWithNodeFs(
|
|
6314
|
+
_watchWithNodeFs(path18, listener) {
|
|
6449
6315
|
const opts = this.fsw.options;
|
|
6450
|
-
const directory = sp.dirname(
|
|
6451
|
-
const basename7 = sp.basename(
|
|
6316
|
+
const directory = sp.dirname(path18);
|
|
6317
|
+
const basename7 = sp.basename(path18);
|
|
6452
6318
|
const parent = this.fsw._getWatchedDir(directory);
|
|
6453
6319
|
parent.add(basename7);
|
|
6454
|
-
const absolutePath = sp.resolve(
|
|
6320
|
+
const absolutePath = sp.resolve(path18);
|
|
6455
6321
|
const options = {
|
|
6456
6322
|
persistent: opts.persistent
|
|
6457
6323
|
};
|
|
@@ -6461,12 +6327,12 @@ var init_handler2 = __esm({
|
|
|
6461
6327
|
if (opts.usePolling) {
|
|
6462
6328
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
6463
6329
|
options.interval = enableBin && isBinaryPath(basename7) ? opts.binaryInterval : opts.interval;
|
|
6464
|
-
closer = setFsWatchFileListener(
|
|
6330
|
+
closer = setFsWatchFileListener(path18, absolutePath, options, {
|
|
6465
6331
|
listener,
|
|
6466
6332
|
rawEmitter: this.fsw._emitRaw
|
|
6467
6333
|
});
|
|
6468
6334
|
} else {
|
|
6469
|
-
closer = setFsWatchListener(
|
|
6335
|
+
closer = setFsWatchListener(path18, absolutePath, options, {
|
|
6470
6336
|
listener,
|
|
6471
6337
|
errHandler: this._boundHandleError,
|
|
6472
6338
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -6488,7 +6354,7 @@ var init_handler2 = __esm({
|
|
|
6488
6354
|
let prevStats = stats;
|
|
6489
6355
|
if (parent.has(basename7))
|
|
6490
6356
|
return;
|
|
6491
|
-
const listener = async (
|
|
6357
|
+
const listener = async (path18, newStats) => {
|
|
6492
6358
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
6493
6359
|
return;
|
|
6494
6360
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -6502,11 +6368,11 @@ var init_handler2 = __esm({
|
|
|
6502
6368
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
6503
6369
|
}
|
|
6504
6370
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
6505
|
-
this.fsw._closeFile(
|
|
6371
|
+
this.fsw._closeFile(path18);
|
|
6506
6372
|
prevStats = newStats2;
|
|
6507
6373
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
6508
6374
|
if (closer2)
|
|
6509
|
-
this.fsw._addPathCloser(
|
|
6375
|
+
this.fsw._addPathCloser(path18, closer2);
|
|
6510
6376
|
} else {
|
|
6511
6377
|
prevStats = newStats2;
|
|
6512
6378
|
}
|
|
@@ -6538,7 +6404,7 @@ var init_handler2 = __esm({
|
|
|
6538
6404
|
* @param item basename of this item
|
|
6539
6405
|
* @returns true if no more processing is needed for this entry.
|
|
6540
6406
|
*/
|
|
6541
|
-
async _handleSymlink(entry, directory,
|
|
6407
|
+
async _handleSymlink(entry, directory, path18, item) {
|
|
6542
6408
|
if (this.fsw.closed) {
|
|
6543
6409
|
return;
|
|
6544
6410
|
}
|
|
@@ -6548,7 +6414,7 @@ var init_handler2 = __esm({
|
|
|
6548
6414
|
this.fsw._incrReadyCount();
|
|
6549
6415
|
let linkPath;
|
|
6550
6416
|
try {
|
|
6551
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
6417
|
+
linkPath = await (0, import_promises2.realpath)(path18);
|
|
6552
6418
|
} catch (e) {
|
|
6553
6419
|
this.fsw._emitReady();
|
|
6554
6420
|
return true;
|
|
@@ -6558,12 +6424,12 @@ var init_handler2 = __esm({
|
|
|
6558
6424
|
if (dir.has(item)) {
|
|
6559
6425
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
6560
6426
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
6561
|
-
this.fsw._emit(EV.CHANGE,
|
|
6427
|
+
this.fsw._emit(EV.CHANGE, path18, entry.stats);
|
|
6562
6428
|
}
|
|
6563
6429
|
} else {
|
|
6564
6430
|
dir.add(item);
|
|
6565
6431
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
6566
|
-
this.fsw._emit(EV.ADD,
|
|
6432
|
+
this.fsw._emit(EV.ADD, path18, entry.stats);
|
|
6567
6433
|
}
|
|
6568
6434
|
this.fsw._emitReady();
|
|
6569
6435
|
return true;
|
|
@@ -6593,9 +6459,9 @@ var init_handler2 = __esm({
|
|
|
6593
6459
|
return;
|
|
6594
6460
|
}
|
|
6595
6461
|
const item = entry.path;
|
|
6596
|
-
let
|
|
6462
|
+
let path18 = sp.join(directory, item);
|
|
6597
6463
|
current.add(item);
|
|
6598
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
6464
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path18, item)) {
|
|
6599
6465
|
return;
|
|
6600
6466
|
}
|
|
6601
6467
|
if (this.fsw.closed) {
|
|
@@ -6604,11 +6470,11 @@ var init_handler2 = __esm({
|
|
|
6604
6470
|
}
|
|
6605
6471
|
if (item === target || !target && !previous.has(item)) {
|
|
6606
6472
|
this.fsw._incrReadyCount();
|
|
6607
|
-
|
|
6608
|
-
this._addToNodeFs(
|
|
6473
|
+
path18 = sp.join(dir, sp.relative(dir, path18));
|
|
6474
|
+
this._addToNodeFs(path18, initialAdd, wh, depth + 1);
|
|
6609
6475
|
}
|
|
6610
6476
|
}).on(EV.ERROR, this._boundHandleError);
|
|
6611
|
-
return new Promise((
|
|
6477
|
+
return new Promise((resolve12, reject) => {
|
|
6612
6478
|
if (!stream)
|
|
6613
6479
|
return reject();
|
|
6614
6480
|
stream.once(STR_END, () => {
|
|
@@ -6617,7 +6483,7 @@ var init_handler2 = __esm({
|
|
|
6617
6483
|
return;
|
|
6618
6484
|
}
|
|
6619
6485
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
6620
|
-
|
|
6486
|
+
resolve12(void 0);
|
|
6621
6487
|
previous.getChildren().filter((item) => {
|
|
6622
6488
|
return item !== directory && !current.has(item);
|
|
6623
6489
|
}).forEach((item) => {
|
|
@@ -6674,13 +6540,13 @@ var init_handler2 = __esm({
|
|
|
6674
6540
|
* @param depth Child path actually targeted for watch
|
|
6675
6541
|
* @param target Child path actually targeted for watch
|
|
6676
6542
|
*/
|
|
6677
|
-
async _addToNodeFs(
|
|
6543
|
+
async _addToNodeFs(path18, initialAdd, priorWh, depth, target) {
|
|
6678
6544
|
const ready = this.fsw._emitReady;
|
|
6679
|
-
if (this.fsw._isIgnored(
|
|
6545
|
+
if (this.fsw._isIgnored(path18) || this.fsw.closed) {
|
|
6680
6546
|
ready();
|
|
6681
6547
|
return false;
|
|
6682
6548
|
}
|
|
6683
|
-
const wh = this.fsw._getWatchHelpers(
|
|
6549
|
+
const wh = this.fsw._getWatchHelpers(path18);
|
|
6684
6550
|
if (priorWh) {
|
|
6685
6551
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
6686
6552
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -6696,8 +6562,8 @@ var init_handler2 = __esm({
|
|
|
6696
6562
|
const follow = this.fsw.options.followSymlinks;
|
|
6697
6563
|
let closer;
|
|
6698
6564
|
if (stats.isDirectory()) {
|
|
6699
|
-
const absPath = sp.resolve(
|
|
6700
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
6565
|
+
const absPath = sp.resolve(path18);
|
|
6566
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path18) : path18;
|
|
6701
6567
|
if (this.fsw.closed)
|
|
6702
6568
|
return;
|
|
6703
6569
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -6707,29 +6573,29 @@ var init_handler2 = __esm({
|
|
|
6707
6573
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
6708
6574
|
}
|
|
6709
6575
|
} else if (stats.isSymbolicLink()) {
|
|
6710
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
6576
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path18) : path18;
|
|
6711
6577
|
if (this.fsw.closed)
|
|
6712
6578
|
return;
|
|
6713
6579
|
const parent = sp.dirname(wh.watchPath);
|
|
6714
6580
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
6715
6581
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
6716
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
6582
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path18, wh, targetPath);
|
|
6717
6583
|
if (this.fsw.closed)
|
|
6718
6584
|
return;
|
|
6719
6585
|
if (targetPath !== void 0) {
|
|
6720
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
6586
|
+
this.fsw._symlinkPaths.set(sp.resolve(path18), targetPath);
|
|
6721
6587
|
}
|
|
6722
6588
|
} else {
|
|
6723
6589
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
6724
6590
|
}
|
|
6725
6591
|
ready();
|
|
6726
6592
|
if (closer)
|
|
6727
|
-
this.fsw._addPathCloser(
|
|
6593
|
+
this.fsw._addPathCloser(path18, closer);
|
|
6728
6594
|
return false;
|
|
6729
6595
|
} catch (error48) {
|
|
6730
6596
|
if (this.fsw._handleError(error48)) {
|
|
6731
6597
|
ready();
|
|
6732
|
-
return
|
|
6598
|
+
return path18;
|
|
6733
6599
|
}
|
|
6734
6600
|
}
|
|
6735
6601
|
}
|
|
@@ -6764,24 +6630,24 @@ function createPattern(matcher) {
|
|
|
6764
6630
|
}
|
|
6765
6631
|
return () => false;
|
|
6766
6632
|
}
|
|
6767
|
-
function normalizePath(
|
|
6768
|
-
if (typeof
|
|
6633
|
+
function normalizePath(path18) {
|
|
6634
|
+
if (typeof path18 !== "string")
|
|
6769
6635
|
throw new Error("string expected");
|
|
6770
|
-
|
|
6771
|
-
|
|
6636
|
+
path18 = sp2.normalize(path18);
|
|
6637
|
+
path18 = path18.replace(/\\/g, "/");
|
|
6772
6638
|
let prepend = false;
|
|
6773
|
-
if (
|
|
6639
|
+
if (path18.startsWith("//"))
|
|
6774
6640
|
prepend = true;
|
|
6775
|
-
|
|
6641
|
+
path18 = path18.replace(DOUBLE_SLASH_RE, "/");
|
|
6776
6642
|
if (prepend)
|
|
6777
|
-
|
|
6778
|
-
return
|
|
6643
|
+
path18 = "/" + path18;
|
|
6644
|
+
return path18;
|
|
6779
6645
|
}
|
|
6780
6646
|
function matchPatterns(patterns, testString, stats) {
|
|
6781
|
-
const
|
|
6647
|
+
const path18 = normalizePath(testString);
|
|
6782
6648
|
for (let index = 0; index < patterns.length; index++) {
|
|
6783
6649
|
const pattern = patterns[index];
|
|
6784
|
-
if (pattern(
|
|
6650
|
+
if (pattern(path18, stats)) {
|
|
6785
6651
|
return true;
|
|
6786
6652
|
}
|
|
6787
6653
|
}
|
|
@@ -6844,19 +6710,19 @@ var init_chokidar = __esm({
|
|
|
6844
6710
|
}
|
|
6845
6711
|
return str;
|
|
6846
6712
|
};
|
|
6847
|
-
normalizePathToUnix = (
|
|
6848
|
-
normalizeIgnored = (cwd = "") => (
|
|
6849
|
-
if (typeof
|
|
6850
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
6713
|
+
normalizePathToUnix = (path18) => toUnix(sp2.normalize(toUnix(path18)));
|
|
6714
|
+
normalizeIgnored = (cwd = "") => (path18) => {
|
|
6715
|
+
if (typeof path18 === "string") {
|
|
6716
|
+
return normalizePathToUnix(sp2.isAbsolute(path18) ? path18 : sp2.join(cwd, path18));
|
|
6851
6717
|
} else {
|
|
6852
|
-
return
|
|
6718
|
+
return path18;
|
|
6853
6719
|
}
|
|
6854
6720
|
};
|
|
6855
|
-
getAbsolutePath = (
|
|
6856
|
-
if (sp2.isAbsolute(
|
|
6857
|
-
return
|
|
6721
|
+
getAbsolutePath = (path18, cwd) => {
|
|
6722
|
+
if (sp2.isAbsolute(path18)) {
|
|
6723
|
+
return path18;
|
|
6858
6724
|
}
|
|
6859
|
-
return sp2.join(cwd,
|
|
6725
|
+
return sp2.join(cwd, path18);
|
|
6860
6726
|
};
|
|
6861
6727
|
EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
6862
6728
|
DirEntry = class {
|
|
@@ -6921,10 +6787,10 @@ var init_chokidar = __esm({
|
|
|
6921
6787
|
dirParts;
|
|
6922
6788
|
followSymlinks;
|
|
6923
6789
|
statMethod;
|
|
6924
|
-
constructor(
|
|
6790
|
+
constructor(path18, follow, fsw) {
|
|
6925
6791
|
this.fsw = fsw;
|
|
6926
|
-
const watchPath =
|
|
6927
|
-
this.path =
|
|
6792
|
+
const watchPath = path18;
|
|
6793
|
+
this.path = path18 = path18.replace(REPLACER_RE, "");
|
|
6928
6794
|
this.watchPath = watchPath;
|
|
6929
6795
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
6930
6796
|
this.dirParts = [];
|
|
@@ -7064,20 +6930,20 @@ var init_chokidar = __esm({
|
|
|
7064
6930
|
this._closePromise = void 0;
|
|
7065
6931
|
let paths = unifyPaths(paths_);
|
|
7066
6932
|
if (cwd) {
|
|
7067
|
-
paths = paths.map((
|
|
7068
|
-
const absPath = getAbsolutePath(
|
|
6933
|
+
paths = paths.map((path18) => {
|
|
6934
|
+
const absPath = getAbsolutePath(path18, cwd);
|
|
7069
6935
|
return absPath;
|
|
7070
6936
|
});
|
|
7071
6937
|
}
|
|
7072
|
-
paths.forEach((
|
|
7073
|
-
this._removeIgnoredPath(
|
|
6938
|
+
paths.forEach((path18) => {
|
|
6939
|
+
this._removeIgnoredPath(path18);
|
|
7074
6940
|
});
|
|
7075
6941
|
this._userIgnored = void 0;
|
|
7076
6942
|
if (!this._readyCount)
|
|
7077
6943
|
this._readyCount = 0;
|
|
7078
6944
|
this._readyCount += paths.length;
|
|
7079
|
-
Promise.all(paths.map(async (
|
|
7080
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
6945
|
+
Promise.all(paths.map(async (path18) => {
|
|
6946
|
+
const res = await this._nodeFsHandler._addToNodeFs(path18, !_internal, void 0, 0, _origAdd);
|
|
7081
6947
|
if (res)
|
|
7082
6948
|
this._emitReady();
|
|
7083
6949
|
return res;
|
|
@@ -7099,17 +6965,17 @@ var init_chokidar = __esm({
|
|
|
7099
6965
|
return this;
|
|
7100
6966
|
const paths = unifyPaths(paths_);
|
|
7101
6967
|
const { cwd } = this.options;
|
|
7102
|
-
paths.forEach((
|
|
7103
|
-
if (!sp2.isAbsolute(
|
|
6968
|
+
paths.forEach((path18) => {
|
|
6969
|
+
if (!sp2.isAbsolute(path18) && !this._closers.has(path18)) {
|
|
7104
6970
|
if (cwd)
|
|
7105
|
-
|
|
7106
|
-
|
|
6971
|
+
path18 = sp2.join(cwd, path18);
|
|
6972
|
+
path18 = sp2.resolve(path18);
|
|
7107
6973
|
}
|
|
7108
|
-
this._closePath(
|
|
7109
|
-
this._addIgnoredPath(
|
|
7110
|
-
if (this._watched.has(
|
|
6974
|
+
this._closePath(path18);
|
|
6975
|
+
this._addIgnoredPath(path18);
|
|
6976
|
+
if (this._watched.has(path18)) {
|
|
7111
6977
|
this._addIgnoredPath({
|
|
7112
|
-
path:
|
|
6978
|
+
path: path18,
|
|
7113
6979
|
recursive: true
|
|
7114
6980
|
});
|
|
7115
6981
|
}
|
|
@@ -7173,38 +7039,38 @@ var init_chokidar = __esm({
|
|
|
7173
7039
|
* @param stats arguments to be passed with event
|
|
7174
7040
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
7175
7041
|
*/
|
|
7176
|
-
async _emit(event,
|
|
7042
|
+
async _emit(event, path18, stats) {
|
|
7177
7043
|
if (this.closed)
|
|
7178
7044
|
return;
|
|
7179
7045
|
const opts = this.options;
|
|
7180
7046
|
if (isWindows)
|
|
7181
|
-
|
|
7047
|
+
path18 = sp2.normalize(path18);
|
|
7182
7048
|
if (opts.cwd)
|
|
7183
|
-
|
|
7184
|
-
const args = [
|
|
7049
|
+
path18 = sp2.relative(opts.cwd, path18);
|
|
7050
|
+
const args = [path18];
|
|
7185
7051
|
if (stats != null)
|
|
7186
7052
|
args.push(stats);
|
|
7187
7053
|
const awf = opts.awaitWriteFinish;
|
|
7188
7054
|
let pw;
|
|
7189
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
7055
|
+
if (awf && (pw = this._pendingWrites.get(path18))) {
|
|
7190
7056
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
7191
7057
|
return this;
|
|
7192
7058
|
}
|
|
7193
7059
|
if (opts.atomic) {
|
|
7194
7060
|
if (event === EVENTS.UNLINK) {
|
|
7195
|
-
this._pendingUnlinks.set(
|
|
7061
|
+
this._pendingUnlinks.set(path18, [event, ...args]);
|
|
7196
7062
|
setTimeout(() => {
|
|
7197
|
-
this._pendingUnlinks.forEach((entry,
|
|
7063
|
+
this._pendingUnlinks.forEach((entry, path19) => {
|
|
7198
7064
|
this.emit(...entry);
|
|
7199
7065
|
this.emit(EVENTS.ALL, ...entry);
|
|
7200
|
-
this._pendingUnlinks.delete(
|
|
7066
|
+
this._pendingUnlinks.delete(path19);
|
|
7201
7067
|
});
|
|
7202
7068
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
7203
7069
|
return this;
|
|
7204
7070
|
}
|
|
7205
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
7071
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path18)) {
|
|
7206
7072
|
event = EVENTS.CHANGE;
|
|
7207
|
-
this._pendingUnlinks.delete(
|
|
7073
|
+
this._pendingUnlinks.delete(path18);
|
|
7208
7074
|
}
|
|
7209
7075
|
}
|
|
7210
7076
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -7222,16 +7088,16 @@ var init_chokidar = __esm({
|
|
|
7222
7088
|
this.emitWithAll(event, args);
|
|
7223
7089
|
}
|
|
7224
7090
|
};
|
|
7225
|
-
this._awaitWriteFinish(
|
|
7091
|
+
this._awaitWriteFinish(path18, awf.stabilityThreshold, event, awfEmit);
|
|
7226
7092
|
return this;
|
|
7227
7093
|
}
|
|
7228
7094
|
if (event === EVENTS.CHANGE) {
|
|
7229
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
7095
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path18, 50);
|
|
7230
7096
|
if (isThrottled)
|
|
7231
7097
|
return this;
|
|
7232
7098
|
}
|
|
7233
7099
|
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,
|
|
7100
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path18) : path18;
|
|
7235
7101
|
let stats2;
|
|
7236
7102
|
try {
|
|
7237
7103
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -7262,23 +7128,23 @@ var init_chokidar = __esm({
|
|
|
7262
7128
|
* @param timeout duration of time to suppress duplicate actions
|
|
7263
7129
|
* @returns tracking object or false if action should be suppressed
|
|
7264
7130
|
*/
|
|
7265
|
-
_throttle(actionType,
|
|
7131
|
+
_throttle(actionType, path18, timeout) {
|
|
7266
7132
|
if (!this._throttled.has(actionType)) {
|
|
7267
7133
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
7268
7134
|
}
|
|
7269
7135
|
const action = this._throttled.get(actionType);
|
|
7270
7136
|
if (!action)
|
|
7271
7137
|
throw new Error("invalid throttle");
|
|
7272
|
-
const actionPath = action.get(
|
|
7138
|
+
const actionPath = action.get(path18);
|
|
7273
7139
|
if (actionPath) {
|
|
7274
7140
|
actionPath.count++;
|
|
7275
7141
|
return false;
|
|
7276
7142
|
}
|
|
7277
7143
|
let timeoutObject;
|
|
7278
7144
|
const clear = () => {
|
|
7279
|
-
const item = action.get(
|
|
7145
|
+
const item = action.get(path18);
|
|
7280
7146
|
const count = item ? item.count : 0;
|
|
7281
|
-
action.delete(
|
|
7147
|
+
action.delete(path18);
|
|
7282
7148
|
clearTimeout(timeoutObject);
|
|
7283
7149
|
if (item)
|
|
7284
7150
|
clearTimeout(item.timeoutObject);
|
|
@@ -7286,7 +7152,7 @@ var init_chokidar = __esm({
|
|
|
7286
7152
|
};
|
|
7287
7153
|
timeoutObject = setTimeout(clear, timeout);
|
|
7288
7154
|
const thr = { timeoutObject, clear, count: 0 };
|
|
7289
|
-
action.set(
|
|
7155
|
+
action.set(path18, thr);
|
|
7290
7156
|
return thr;
|
|
7291
7157
|
}
|
|
7292
7158
|
_incrReadyCount() {
|
|
@@ -7300,44 +7166,44 @@ var init_chokidar = __esm({
|
|
|
7300
7166
|
* @param event
|
|
7301
7167
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
7302
7168
|
*/
|
|
7303
|
-
_awaitWriteFinish(
|
|
7169
|
+
_awaitWriteFinish(path18, threshold, event, awfEmit) {
|
|
7304
7170
|
const awf = this.options.awaitWriteFinish;
|
|
7305
7171
|
if (typeof awf !== "object")
|
|
7306
7172
|
return;
|
|
7307
7173
|
const pollInterval = awf.pollInterval;
|
|
7308
7174
|
let timeoutHandler;
|
|
7309
|
-
let fullPath =
|
|
7310
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
7311
|
-
fullPath = sp2.join(this.options.cwd,
|
|
7175
|
+
let fullPath = path18;
|
|
7176
|
+
if (this.options.cwd && !sp2.isAbsolute(path18)) {
|
|
7177
|
+
fullPath = sp2.join(this.options.cwd, path18);
|
|
7312
7178
|
}
|
|
7313
7179
|
const now = /* @__PURE__ */ new Date();
|
|
7314
7180
|
const writes = this._pendingWrites;
|
|
7315
7181
|
function awaitWriteFinishFn(prevStat) {
|
|
7316
7182
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
7317
|
-
if (err || !writes.has(
|
|
7183
|
+
if (err || !writes.has(path18)) {
|
|
7318
7184
|
if (err && err.code !== "ENOENT")
|
|
7319
7185
|
awfEmit(err);
|
|
7320
7186
|
return;
|
|
7321
7187
|
}
|
|
7322
7188
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
7323
7189
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
7324
|
-
writes.get(
|
|
7190
|
+
writes.get(path18).lastChange = now2;
|
|
7325
7191
|
}
|
|
7326
|
-
const pw = writes.get(
|
|
7192
|
+
const pw = writes.get(path18);
|
|
7327
7193
|
const df = now2 - pw.lastChange;
|
|
7328
7194
|
if (df >= threshold) {
|
|
7329
|
-
writes.delete(
|
|
7195
|
+
writes.delete(path18);
|
|
7330
7196
|
awfEmit(void 0, curStat);
|
|
7331
7197
|
} else {
|
|
7332
7198
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
7333
7199
|
}
|
|
7334
7200
|
});
|
|
7335
7201
|
}
|
|
7336
|
-
if (!writes.has(
|
|
7337
|
-
writes.set(
|
|
7202
|
+
if (!writes.has(path18)) {
|
|
7203
|
+
writes.set(path18, {
|
|
7338
7204
|
lastChange: now,
|
|
7339
7205
|
cancelWait: () => {
|
|
7340
|
-
writes.delete(
|
|
7206
|
+
writes.delete(path18);
|
|
7341
7207
|
clearTimeout(timeoutHandler);
|
|
7342
7208
|
return event;
|
|
7343
7209
|
}
|
|
@@ -7348,8 +7214,8 @@ var init_chokidar = __esm({
|
|
|
7348
7214
|
/**
|
|
7349
7215
|
* Determines whether user has asked to ignore this path.
|
|
7350
7216
|
*/
|
|
7351
|
-
_isIgnored(
|
|
7352
|
-
if (this.options.atomic && DOT_RE.test(
|
|
7217
|
+
_isIgnored(path18, stats) {
|
|
7218
|
+
if (this.options.atomic && DOT_RE.test(path18))
|
|
7353
7219
|
return true;
|
|
7354
7220
|
if (!this._userIgnored) {
|
|
7355
7221
|
const { cwd } = this.options;
|
|
@@ -7359,17 +7225,17 @@ var init_chokidar = __esm({
|
|
|
7359
7225
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
7360
7226
|
this._userIgnored = anymatch(list, void 0);
|
|
7361
7227
|
}
|
|
7362
|
-
return this._userIgnored(
|
|
7228
|
+
return this._userIgnored(path18, stats);
|
|
7363
7229
|
}
|
|
7364
|
-
_isntIgnored(
|
|
7365
|
-
return !this._isIgnored(
|
|
7230
|
+
_isntIgnored(path18, stat4) {
|
|
7231
|
+
return !this._isIgnored(path18, stat4);
|
|
7366
7232
|
}
|
|
7367
7233
|
/**
|
|
7368
7234
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
7369
7235
|
* @param path file or directory pattern being watched
|
|
7370
7236
|
*/
|
|
7371
|
-
_getWatchHelpers(
|
|
7372
|
-
return new WatchHelper(
|
|
7237
|
+
_getWatchHelpers(path18) {
|
|
7238
|
+
return new WatchHelper(path18, this.options.followSymlinks, this);
|
|
7373
7239
|
}
|
|
7374
7240
|
// Directory helpers
|
|
7375
7241
|
// -----------------
|
|
@@ -7401,63 +7267,63 @@ var init_chokidar = __esm({
|
|
|
7401
7267
|
* @param item base path of item/directory
|
|
7402
7268
|
*/
|
|
7403
7269
|
_remove(directory, item, isDirectory) {
|
|
7404
|
-
const
|
|
7405
|
-
const fullPath = sp2.resolve(
|
|
7406
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
7407
|
-
if (!this._throttle("remove",
|
|
7270
|
+
const path18 = sp2.join(directory, item);
|
|
7271
|
+
const fullPath = sp2.resolve(path18);
|
|
7272
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path18) || this._watched.has(fullPath);
|
|
7273
|
+
if (!this._throttle("remove", path18, 100))
|
|
7408
7274
|
return;
|
|
7409
7275
|
if (!isDirectory && this._watched.size === 1) {
|
|
7410
7276
|
this.add(directory, item, true);
|
|
7411
7277
|
}
|
|
7412
|
-
const wp = this._getWatchedDir(
|
|
7278
|
+
const wp = this._getWatchedDir(path18);
|
|
7413
7279
|
const nestedDirectoryChildren = wp.getChildren();
|
|
7414
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
7280
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path18, nested));
|
|
7415
7281
|
const parent = this._getWatchedDir(directory);
|
|
7416
7282
|
const wasTracked = parent.has(item);
|
|
7417
7283
|
parent.remove(item);
|
|
7418
7284
|
if (this._symlinkPaths.has(fullPath)) {
|
|
7419
7285
|
this._symlinkPaths.delete(fullPath);
|
|
7420
7286
|
}
|
|
7421
|
-
let relPath =
|
|
7287
|
+
let relPath = path18;
|
|
7422
7288
|
if (this.options.cwd)
|
|
7423
|
-
relPath = sp2.relative(this.options.cwd,
|
|
7289
|
+
relPath = sp2.relative(this.options.cwd, path18);
|
|
7424
7290
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
7425
7291
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
7426
7292
|
if (event === EVENTS.ADD)
|
|
7427
7293
|
return;
|
|
7428
7294
|
}
|
|
7429
|
-
this._watched.delete(
|
|
7295
|
+
this._watched.delete(path18);
|
|
7430
7296
|
this._watched.delete(fullPath);
|
|
7431
7297
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
7432
|
-
if (wasTracked && !this._isIgnored(
|
|
7433
|
-
this._emit(eventName,
|
|
7434
|
-
this._closePath(
|
|
7298
|
+
if (wasTracked && !this._isIgnored(path18))
|
|
7299
|
+
this._emit(eventName, path18);
|
|
7300
|
+
this._closePath(path18);
|
|
7435
7301
|
}
|
|
7436
7302
|
/**
|
|
7437
7303
|
* Closes all watchers for a path
|
|
7438
7304
|
*/
|
|
7439
|
-
_closePath(
|
|
7440
|
-
this._closeFile(
|
|
7441
|
-
const dir = sp2.dirname(
|
|
7442
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
7305
|
+
_closePath(path18) {
|
|
7306
|
+
this._closeFile(path18);
|
|
7307
|
+
const dir = sp2.dirname(path18);
|
|
7308
|
+
this._getWatchedDir(dir).remove(sp2.basename(path18));
|
|
7443
7309
|
}
|
|
7444
7310
|
/**
|
|
7445
7311
|
* Closes only file-specific watchers
|
|
7446
7312
|
*/
|
|
7447
|
-
_closeFile(
|
|
7448
|
-
const closers = this._closers.get(
|
|
7313
|
+
_closeFile(path18) {
|
|
7314
|
+
const closers = this._closers.get(path18);
|
|
7449
7315
|
if (!closers)
|
|
7450
7316
|
return;
|
|
7451
7317
|
closers.forEach((closer) => closer());
|
|
7452
|
-
this._closers.delete(
|
|
7318
|
+
this._closers.delete(path18);
|
|
7453
7319
|
}
|
|
7454
|
-
_addPathCloser(
|
|
7320
|
+
_addPathCloser(path18, closer) {
|
|
7455
7321
|
if (!closer)
|
|
7456
7322
|
return;
|
|
7457
|
-
let list = this._closers.get(
|
|
7323
|
+
let list = this._closers.get(path18);
|
|
7458
7324
|
if (!list) {
|
|
7459
7325
|
list = [];
|
|
7460
|
-
this._closers.set(
|
|
7326
|
+
this._closers.set(path18, list);
|
|
7461
7327
|
}
|
|
7462
7328
|
list.push(closer);
|
|
7463
7329
|
}
|
|
@@ -7483,12 +7349,12 @@ var init_chokidar = __esm({
|
|
|
7483
7349
|
});
|
|
7484
7350
|
|
|
7485
7351
|
// ../../oss/packages/daemon-core/src/providers/provider-loader.ts
|
|
7486
|
-
var fs5,
|
|
7352
|
+
var fs5, path6, os7, ProviderLoader;
|
|
7487
7353
|
var init_provider_loader = __esm({
|
|
7488
7354
|
"../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
|
|
7489
7355
|
"use strict";
|
|
7490
7356
|
fs5 = __toESM(require("fs"));
|
|
7491
|
-
|
|
7357
|
+
path6 = __toESM(require("path"));
|
|
7492
7358
|
os7 = __toESM(require("os"));
|
|
7493
7359
|
init_chokidar();
|
|
7494
7360
|
init_ide_detector();
|
|
@@ -7510,12 +7376,12 @@ var init_provider_loader = __esm({
|
|
|
7510
7376
|
static META_FILE = ".meta.json";
|
|
7511
7377
|
constructor(options) {
|
|
7512
7378
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
7513
|
-
const defaultProvidersDir =
|
|
7379
|
+
const defaultProvidersDir = path6.join(os7.homedir(), ".adhdev", "providers");
|
|
7514
7380
|
if (options?.userDir) {
|
|
7515
7381
|
this.userDir = options.userDir;
|
|
7516
7382
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
7517
7383
|
} else {
|
|
7518
|
-
const localRepoPath =
|
|
7384
|
+
const localRepoPath = path6.resolve(__dirname, "../../../../../adhdev-providers");
|
|
7519
7385
|
if (fs5.existsSync(localRepoPath)) {
|
|
7520
7386
|
this.userDir = localRepoPath;
|
|
7521
7387
|
this.log(`Auto-detected local public repository: ${this.userDir} (Dev workspace speedup)`);
|
|
@@ -7524,7 +7390,7 @@ var init_provider_loader = __esm({
|
|
|
7524
7390
|
this.log(`Using default user providers directory: ${this.userDir}`);
|
|
7525
7391
|
}
|
|
7526
7392
|
}
|
|
7527
|
-
this.upstreamDir =
|
|
7393
|
+
this.upstreamDir = path6.join(defaultProvidersDir, ".upstream");
|
|
7528
7394
|
this.disableUpstream = options?.disableUpstream ?? false;
|
|
7529
7395
|
}
|
|
7530
7396
|
log(msg) {
|
|
@@ -7554,7 +7420,7 @@ var init_provider_loader = __esm({
|
|
|
7554
7420
|
* Canonical provider directory shape for a given root.
|
|
7555
7421
|
*/
|
|
7556
7422
|
getProviderDir(root, category, type) {
|
|
7557
|
-
return
|
|
7423
|
+
return path6.join(root, category, type);
|
|
7558
7424
|
}
|
|
7559
7425
|
/**
|
|
7560
7426
|
* Canonical user override directory for a provider.
|
|
@@ -7581,7 +7447,7 @@ var init_provider_loader = __esm({
|
|
|
7581
7447
|
resolveProviderFile(type, ...segments) {
|
|
7582
7448
|
const dir = this.findProviderDirInternal(type);
|
|
7583
7449
|
if (!dir) return null;
|
|
7584
|
-
return
|
|
7450
|
+
return path6.join(dir, ...segments);
|
|
7585
7451
|
}
|
|
7586
7452
|
/**
|
|
7587
7453
|
* Load all providers (3-tier priority)
|
|
@@ -7619,7 +7485,7 @@ var init_provider_loader = __esm({
|
|
|
7619
7485
|
if (!fs5.existsSync(this.upstreamDir)) return false;
|
|
7620
7486
|
try {
|
|
7621
7487
|
return fs5.readdirSync(this.upstreamDir).some(
|
|
7622
|
-
(d) => fs5.statSync(
|
|
7488
|
+
(d) => fs5.statSync(path6.join(this.upstreamDir, d)).isDirectory()
|
|
7623
7489
|
);
|
|
7624
7490
|
} catch {
|
|
7625
7491
|
return false;
|
|
@@ -7704,16 +7570,23 @@ var init_provider_loader = __esm({
|
|
|
7704
7570
|
isEnabled(type, ideType) {
|
|
7705
7571
|
if (!ideType) return true;
|
|
7706
7572
|
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;
|
|
7573
|
+
return this.getIdeExtensionEnabledState(ideType, type);
|
|
7712
7574
|
} catch {
|
|
7713
7575
|
return false;
|
|
7714
7576
|
}
|
|
7715
7577
|
}
|
|
7716
7578
|
/**
|
|
7579
|
+
* Resolve per-IDE extension enabled state using the same normalization
|
|
7580
|
+
* that runtime attach/remove uses.
|
|
7581
|
+
*/
|
|
7582
|
+
getIdeExtensionEnabledState(ideType, extensionType) {
|
|
7583
|
+
const { loadConfig: loadConfig2 } = (init_config(), __toCommonJS(config_exports));
|
|
7584
|
+
const config2 = loadConfig2();
|
|
7585
|
+
const baseIdeType = ideType.split("_")[0];
|
|
7586
|
+
const val = config2.ideSettings?.[baseIdeType]?.extensions?.[extensionType]?.enabled;
|
|
7587
|
+
return val === true;
|
|
7588
|
+
}
|
|
7589
|
+
/**
|
|
7717
7590
|
* Save IDE extension enabled setting
|
|
7718
7591
|
*/
|
|
7719
7592
|
setIdeExtensionEnabled(ideType, extensionType, enabled) {
|
|
@@ -7911,14 +7784,14 @@ var init_provider_loader = __esm({
|
|
|
7911
7784
|
this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
|
|
7912
7785
|
return null;
|
|
7913
7786
|
}
|
|
7914
|
-
const dir =
|
|
7787
|
+
const dir = path6.join(providerDir, scriptDir);
|
|
7915
7788
|
if (!fs5.existsSync(dir)) {
|
|
7916
7789
|
this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
7917
7790
|
return null;
|
|
7918
7791
|
}
|
|
7919
7792
|
const cached2 = this.scriptsCache.get(dir);
|
|
7920
7793
|
if (cached2) return cached2;
|
|
7921
|
-
const scriptsJs =
|
|
7794
|
+
const scriptsJs = path6.join(dir, "scripts.js");
|
|
7922
7795
|
if (fs5.existsSync(scriptsJs)) {
|
|
7923
7796
|
try {
|
|
7924
7797
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -7957,7 +7830,7 @@ var init_provider_loader = __esm({
|
|
|
7957
7830
|
});
|
|
7958
7831
|
const handleChange = (filePath) => {
|
|
7959
7832
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
7960
|
-
this.log(`File changed: ${
|
|
7833
|
+
this.log(`File changed: ${path6.basename(filePath)}, reloading...`);
|
|
7961
7834
|
this.reload();
|
|
7962
7835
|
}
|
|
7963
7836
|
};
|
|
@@ -8012,7 +7885,7 @@ var init_provider_loader = __esm({
|
|
|
8012
7885
|
}
|
|
8013
7886
|
const https = require("https");
|
|
8014
7887
|
const { execSync: execSync7 } = require("child_process");
|
|
8015
|
-
const metaPath =
|
|
7888
|
+
const metaPath = path6.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
8016
7889
|
let prevEtag = "";
|
|
8017
7890
|
let prevTimestamp = 0;
|
|
8018
7891
|
try {
|
|
@@ -8029,7 +7902,7 @@ var init_provider_loader = __esm({
|
|
|
8029
7902
|
return { updated: false };
|
|
8030
7903
|
}
|
|
8031
7904
|
try {
|
|
8032
|
-
const etag = await new Promise((
|
|
7905
|
+
const etag = await new Promise((resolve12, reject) => {
|
|
8033
7906
|
const options = {
|
|
8034
7907
|
method: "HEAD",
|
|
8035
7908
|
hostname: "github.com",
|
|
@@ -8047,7 +7920,7 @@ var init_provider_loader = __esm({
|
|
|
8047
7920
|
headers: { "User-Agent": "adhdev-launcher" },
|
|
8048
7921
|
timeout: 1e4
|
|
8049
7922
|
}, (res2) => {
|
|
8050
|
-
|
|
7923
|
+
resolve12(res2.headers.etag || res2.headers["last-modified"] || "");
|
|
8051
7924
|
});
|
|
8052
7925
|
req2.on("error", reject);
|
|
8053
7926
|
req2.on("timeout", () => {
|
|
@@ -8056,7 +7929,7 @@ var init_provider_loader = __esm({
|
|
|
8056
7929
|
});
|
|
8057
7930
|
req2.end();
|
|
8058
7931
|
} else {
|
|
8059
|
-
|
|
7932
|
+
resolve12(res.headers.etag || res.headers["last-modified"] || "");
|
|
8060
7933
|
}
|
|
8061
7934
|
});
|
|
8062
7935
|
req.on("error", reject);
|
|
@@ -8072,17 +7945,17 @@ var init_provider_loader = __esm({
|
|
|
8072
7945
|
return { updated: false };
|
|
8073
7946
|
}
|
|
8074
7947
|
this.log("Downloading latest providers from GitHub...");
|
|
8075
|
-
const tmpTar =
|
|
8076
|
-
const tmpExtract =
|
|
7948
|
+
const tmpTar = path6.join(os7.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
7949
|
+
const tmpExtract = path6.join(os7.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
8077
7950
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
8078
7951
|
fs5.mkdirSync(tmpExtract, { recursive: true });
|
|
8079
7952
|
execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
8080
7953
|
const extracted = fs5.readdirSync(tmpExtract);
|
|
8081
7954
|
const rootDir = extracted.find(
|
|
8082
|
-
(d) => fs5.statSync(
|
|
7955
|
+
(d) => fs5.statSync(path6.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
8083
7956
|
);
|
|
8084
7957
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
8085
|
-
const sourceDir =
|
|
7958
|
+
const sourceDir = path6.join(tmpExtract, rootDir);
|
|
8086
7959
|
const backupDir = this.upstreamDir + ".bak";
|
|
8087
7960
|
if (fs5.existsSync(this.upstreamDir)) {
|
|
8088
7961
|
if (fs5.existsSync(backupDir)) fs5.rmSync(backupDir, { recursive: true, force: true });
|
|
@@ -8120,7 +7993,7 @@ var init_provider_loader = __esm({
|
|
|
8120
7993
|
downloadFile(url2, destPath) {
|
|
8121
7994
|
const https = require("https");
|
|
8122
7995
|
const http3 = require("http");
|
|
8123
|
-
return new Promise((
|
|
7996
|
+
return new Promise((resolve12, reject) => {
|
|
8124
7997
|
const doRequest = (reqUrl, redirectCount = 0) => {
|
|
8125
7998
|
if (redirectCount > 5) {
|
|
8126
7999
|
reject(new Error("Too many redirects"));
|
|
@@ -8140,7 +8013,7 @@ var init_provider_loader = __esm({
|
|
|
8140
8013
|
res.pipe(ws2);
|
|
8141
8014
|
ws2.on("finish", () => {
|
|
8142
8015
|
ws2.close();
|
|
8143
|
-
|
|
8016
|
+
resolve12();
|
|
8144
8017
|
});
|
|
8145
8018
|
ws2.on("error", reject);
|
|
8146
8019
|
});
|
|
@@ -8157,8 +8030,8 @@ var init_provider_loader = __esm({
|
|
|
8157
8030
|
copyDirRecursive(src, dest) {
|
|
8158
8031
|
fs5.mkdirSync(dest, { recursive: true });
|
|
8159
8032
|
for (const entry of fs5.readdirSync(src, { withFileTypes: true })) {
|
|
8160
|
-
const srcPath =
|
|
8161
|
-
const destPath =
|
|
8033
|
+
const srcPath = path6.join(src, entry.name);
|
|
8034
|
+
const destPath = path6.join(dest, entry.name);
|
|
8162
8035
|
if (entry.isDirectory()) {
|
|
8163
8036
|
this.copyDirRecursive(srcPath, destPath);
|
|
8164
8037
|
} else {
|
|
@@ -8169,7 +8042,7 @@ var init_provider_loader = __esm({
|
|
|
8169
8042
|
/** .meta.json save */
|
|
8170
8043
|
writeMeta(metaPath, etag, timestamp) {
|
|
8171
8044
|
try {
|
|
8172
|
-
fs5.mkdirSync(
|
|
8045
|
+
fs5.mkdirSync(path6.dirname(metaPath), { recursive: true });
|
|
8173
8046
|
fs5.writeFileSync(metaPath, JSON.stringify({
|
|
8174
8047
|
etag,
|
|
8175
8048
|
timestamp,
|
|
@@ -8186,7 +8059,7 @@ var init_provider_loader = __esm({
|
|
|
8186
8059
|
const scan = (d) => {
|
|
8187
8060
|
try {
|
|
8188
8061
|
for (const entry of fs5.readdirSync(d, { withFileTypes: true })) {
|
|
8189
|
-
if (entry.isDirectory()) scan(
|
|
8062
|
+
if (entry.isDirectory()) scan(path6.join(d, entry.name));
|
|
8190
8063
|
else if (entry.name === "provider.json") count++;
|
|
8191
8064
|
}
|
|
8192
8065
|
} catch {
|
|
@@ -8285,17 +8158,17 @@ var init_provider_loader = __esm({
|
|
|
8285
8158
|
for (const root of searchRoots) {
|
|
8286
8159
|
if (!fs5.existsSync(root)) continue;
|
|
8287
8160
|
const candidate = this.getProviderDir(root, cat, type);
|
|
8288
|
-
if (fs5.existsSync(
|
|
8289
|
-
const catDir =
|
|
8161
|
+
if (fs5.existsSync(path6.join(candidate, "provider.json"))) return candidate;
|
|
8162
|
+
const catDir = path6.join(root, cat);
|
|
8290
8163
|
if (fs5.existsSync(catDir)) {
|
|
8291
8164
|
try {
|
|
8292
8165
|
for (const entry of fs5.readdirSync(catDir, { withFileTypes: true })) {
|
|
8293
8166
|
if (!entry.isDirectory()) continue;
|
|
8294
|
-
const jsonPath =
|
|
8167
|
+
const jsonPath = path6.join(catDir, entry.name, "provider.json");
|
|
8295
8168
|
if (fs5.existsSync(jsonPath)) {
|
|
8296
8169
|
try {
|
|
8297
8170
|
const data = JSON.parse(fs5.readFileSync(jsonPath, "utf-8"));
|
|
8298
|
-
if (data.type === type) return
|
|
8171
|
+
if (data.type === type) return path6.join(catDir, entry.name);
|
|
8299
8172
|
} catch {
|
|
8300
8173
|
}
|
|
8301
8174
|
}
|
|
@@ -8312,7 +8185,7 @@ var init_provider_loader = __esm({
|
|
|
8312
8185
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
8313
8186
|
*/
|
|
8314
8187
|
buildScriptWrappersFromDir(dir) {
|
|
8315
|
-
const scriptsJs =
|
|
8188
|
+
const scriptsJs = path6.join(dir, "scripts.js");
|
|
8316
8189
|
if (fs5.existsSync(scriptsJs)) {
|
|
8317
8190
|
try {
|
|
8318
8191
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -8326,7 +8199,7 @@ var init_provider_loader = __esm({
|
|
|
8326
8199
|
for (const file2 of fs5.readdirSync(dir)) {
|
|
8327
8200
|
if (!file2.endsWith(".js")) continue;
|
|
8328
8201
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
8329
|
-
const filePath =
|
|
8202
|
+
const filePath = path6.join(dir, file2);
|
|
8330
8203
|
result[scriptName] = (...args) => {
|
|
8331
8204
|
try {
|
|
8332
8205
|
let content = fs5.readFileSync(filePath, "utf-8");
|
|
@@ -8386,7 +8259,7 @@ var init_provider_loader = __esm({
|
|
|
8386
8259
|
}
|
|
8387
8260
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
8388
8261
|
if (hasJson) {
|
|
8389
|
-
const jsonPath =
|
|
8262
|
+
const jsonPath = path6.join(d, "provider.json");
|
|
8390
8263
|
try {
|
|
8391
8264
|
const raw = fs5.readFileSync(jsonPath, "utf-8");
|
|
8392
8265
|
const mod = JSON.parse(raw);
|
|
@@ -8399,7 +8272,7 @@ var init_provider_loader = __esm({
|
|
|
8399
8272
|
delete mod.extensionIdPattern_flags;
|
|
8400
8273
|
}
|
|
8401
8274
|
const hasCompatibility = Array.isArray(mod.compatibility);
|
|
8402
|
-
const scriptsPath =
|
|
8275
|
+
const scriptsPath = path6.join(d, "scripts.js");
|
|
8403
8276
|
if (!hasCompatibility && fs5.existsSync(scriptsPath)) {
|
|
8404
8277
|
try {
|
|
8405
8278
|
delete require.cache[require.resolve(scriptsPath)];
|
|
@@ -8425,7 +8298,7 @@ var init_provider_loader = __esm({
|
|
|
8425
8298
|
if (!entry.isDirectory()) continue;
|
|
8426
8299
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
8427
8300
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
8428
|
-
scan(
|
|
8301
|
+
scan(path6.join(d, entry.name));
|
|
8429
8302
|
}
|
|
8430
8303
|
}
|
|
8431
8304
|
};
|
|
@@ -8506,17 +8379,17 @@ async function findFreePort(ports) {
|
|
|
8506
8379
|
throw new Error("No free port found");
|
|
8507
8380
|
}
|
|
8508
8381
|
function checkPortFree(port) {
|
|
8509
|
-
return new Promise((
|
|
8382
|
+
return new Promise((resolve12) => {
|
|
8510
8383
|
const server = net.createServer();
|
|
8511
8384
|
server.unref();
|
|
8512
|
-
server.on("error", () =>
|
|
8385
|
+
server.on("error", () => resolve12(false));
|
|
8513
8386
|
server.listen(port, "127.0.0.1", () => {
|
|
8514
|
-
server.close(() =>
|
|
8387
|
+
server.close(() => resolve12(true));
|
|
8515
8388
|
});
|
|
8516
8389
|
});
|
|
8517
8390
|
}
|
|
8518
8391
|
async function isCdpActive(port) {
|
|
8519
|
-
return new Promise((
|
|
8392
|
+
return new Promise((resolve12) => {
|
|
8520
8393
|
const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
|
|
8521
8394
|
timeout: 2e3
|
|
8522
8395
|
}, (res) => {
|
|
@@ -8525,16 +8398,16 @@ async function isCdpActive(port) {
|
|
|
8525
8398
|
res.on("end", () => {
|
|
8526
8399
|
try {
|
|
8527
8400
|
const info = JSON.parse(data);
|
|
8528
|
-
|
|
8401
|
+
resolve12(!!info["WebKit-Version"] || !!info["Browser"]);
|
|
8529
8402
|
} catch {
|
|
8530
|
-
|
|
8403
|
+
resolve12(false);
|
|
8531
8404
|
}
|
|
8532
8405
|
});
|
|
8533
8406
|
});
|
|
8534
|
-
req.on("error", () =>
|
|
8407
|
+
req.on("error", () => resolve12(false));
|
|
8535
8408
|
req.on("timeout", () => {
|
|
8536
8409
|
req.destroy();
|
|
8537
|
-
|
|
8410
|
+
resolve12(false);
|
|
8538
8411
|
});
|
|
8539
8412
|
});
|
|
8540
8413
|
}
|
|
@@ -8653,8 +8526,8 @@ function detectCurrentWorkspace(ideId) {
|
|
|
8653
8526
|
const appNameMap = getMacAppIdentifiers();
|
|
8654
8527
|
const appName = appNameMap[ideId];
|
|
8655
8528
|
if (appName) {
|
|
8656
|
-
const storagePath =
|
|
8657
|
-
process.env.APPDATA ||
|
|
8529
|
+
const storagePath = path7.join(
|
|
8530
|
+
process.env.APPDATA || path7.join(os8.homedir(), "AppData", "Roaming"),
|
|
8658
8531
|
appName,
|
|
8659
8532
|
"storage.json"
|
|
8660
8533
|
);
|
|
@@ -8820,14 +8693,14 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
8820
8693
|
function getAvailableIdeIds() {
|
|
8821
8694
|
return getProviderLoader().getAvailableIdeTypes();
|
|
8822
8695
|
}
|
|
8823
|
-
var import_child_process4, net, os8,
|
|
8696
|
+
var import_child_process4, net, os8, path7, _providerLoader;
|
|
8824
8697
|
var init_launch = __esm({
|
|
8825
8698
|
"../../oss/packages/daemon-core/src/launch.ts"() {
|
|
8826
8699
|
"use strict";
|
|
8827
8700
|
import_child_process4 = require("child_process");
|
|
8828
8701
|
net = __toESM(require("net"));
|
|
8829
8702
|
os8 = __toESM(require("os"));
|
|
8830
|
-
|
|
8703
|
+
path7 = __toESM(require("path"));
|
|
8831
8704
|
init_ide_detector();
|
|
8832
8705
|
init_provider_loader();
|
|
8833
8706
|
_providerLoader = null;
|
|
@@ -8858,7 +8731,7 @@ function checkRotation() {
|
|
|
8858
8731
|
const today = getDateStr2();
|
|
8859
8732
|
if (today !== currentDate2) {
|
|
8860
8733
|
currentDate2 = today;
|
|
8861
|
-
currentFile =
|
|
8734
|
+
currentFile = path8.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
8862
8735
|
cleanOldFiles();
|
|
8863
8736
|
}
|
|
8864
8737
|
}
|
|
@@ -8872,7 +8745,7 @@ function cleanOldFiles() {
|
|
|
8872
8745
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
8873
8746
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
8874
8747
|
try {
|
|
8875
|
-
fs6.unlinkSync(
|
|
8748
|
+
fs6.unlinkSync(path8.join(LOG_DIR2, file2));
|
|
8876
8749
|
} catch {
|
|
8877
8750
|
}
|
|
8878
8751
|
}
|
|
@@ -8939,14 +8812,14 @@ function getRecentCommands(count = 50) {
|
|
|
8939
8812
|
return [];
|
|
8940
8813
|
}
|
|
8941
8814
|
}
|
|
8942
|
-
var fs6,
|
|
8815
|
+
var fs6, path8, os9, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
|
|
8943
8816
|
var init_command_log = __esm({
|
|
8944
8817
|
"../../oss/packages/daemon-core/src/logging/command-log.ts"() {
|
|
8945
8818
|
"use strict";
|
|
8946
8819
|
fs6 = __toESM(require("fs"));
|
|
8947
|
-
|
|
8820
|
+
path8 = __toESM(require("path"));
|
|
8948
8821
|
os9 = __toESM(require("os"));
|
|
8949
|
-
LOG_DIR2 = process.platform === "win32" ?
|
|
8822
|
+
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
8823
|
MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
8951
8824
|
MAX_DAYS = 7;
|
|
8952
8825
|
try {
|
|
@@ -8965,7 +8838,7 @@ var init_command_log = __esm({
|
|
|
8965
8838
|
"text"
|
|
8966
8839
|
]);
|
|
8967
8840
|
currentDate2 = getDateStr2();
|
|
8968
|
-
currentFile =
|
|
8841
|
+
currentFile = path8.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
8969
8842
|
writeCount2 = 0;
|
|
8970
8843
|
SKIP_COMMANDS = /* @__PURE__ */ new Set([
|
|
8971
8844
|
"heartbeat",
|
|
@@ -8975,355 +8848,6 @@ var init_command_log = __esm({
|
|
|
8975
8848
|
}
|
|
8976
8849
|
});
|
|
8977
8850
|
|
|
8978
|
-
// ../../oss/packages/daemon-core/src/commands/router.ts
|
|
8979
|
-
var fs7, CHAT_COMMANDS, DaemonCommandRouter;
|
|
8980
|
-
var init_router = __esm({
|
|
8981
|
-
"../../oss/packages/daemon-core/src/commands/router.ts"() {
|
|
8982
|
-
"use strict";
|
|
8983
|
-
init_manager();
|
|
8984
|
-
init_setup();
|
|
8985
|
-
init_launch();
|
|
8986
|
-
init_config();
|
|
8987
|
-
init_workspaces();
|
|
8988
|
-
init_workspace_activity();
|
|
8989
|
-
init_config();
|
|
8990
|
-
init_recent_activity();
|
|
8991
|
-
init_ide_detector();
|
|
8992
|
-
init_logger();
|
|
8993
|
-
init_command_log();
|
|
8994
|
-
init_logger();
|
|
8995
|
-
fs7 = __toESM(require("fs"));
|
|
8996
|
-
CHAT_COMMANDS = [
|
|
8997
|
-
"send_chat",
|
|
8998
|
-
"new_chat",
|
|
8999
|
-
"switch_chat",
|
|
9000
|
-
"set_mode",
|
|
9001
|
-
"change_model"
|
|
9002
|
-
];
|
|
9003
|
-
DaemonCommandRouter = class {
|
|
9004
|
-
deps;
|
|
9005
|
-
constructor(deps) {
|
|
9006
|
-
this.deps = deps;
|
|
9007
|
-
}
|
|
9008
|
-
/**
|
|
9009
|
-
* Unified command routing.
|
|
9010
|
-
* Returns result for all commands:
|
|
9011
|
-
* 1. Daemon-level commands (launch_ide, stop_ide, etc.)
|
|
9012
|
-
* 2. CLI commands (launch_cli, stop_cli, agent_command)
|
|
9013
|
-
* 3. DaemonCommandHandler delegation (CDP/agent-stream/file commands)
|
|
9014
|
-
*
|
|
9015
|
-
* @param cmd Command name
|
|
9016
|
-
* @param args Command arguments
|
|
9017
|
-
* @param source Log source ('ws' | 'p2p' | 'standalone' | etc.)
|
|
9018
|
-
*/
|
|
9019
|
-
async execute(cmd, args, source = "unknown") {
|
|
9020
|
-
const cmdStart = Date.now();
|
|
9021
|
-
try {
|
|
9022
|
-
const daemonResult = await this.executeDaemonCommand(cmd, args);
|
|
9023
|
-
if (daemonResult) {
|
|
9024
|
-
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source, args, success: daemonResult.success, durationMs: Date.now() - cmdStart });
|
|
9025
|
-
return daemonResult;
|
|
9026
|
-
}
|
|
9027
|
-
const handlerResult = await this.deps.commandHandler.handle(cmd, args);
|
|
9028
|
-
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source, args, success: handlerResult.success, durationMs: Date.now() - cmdStart });
|
|
9029
|
-
if (CHAT_COMMANDS.includes(cmd) && this.deps.onPostChatCommand) {
|
|
9030
|
-
this.deps.onPostChatCommand();
|
|
9031
|
-
}
|
|
9032
|
-
return handlerResult;
|
|
9033
|
-
} catch (e) {
|
|
9034
|
-
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source, args, success: false, error: e.message, durationMs: Date.now() - cmdStart });
|
|
9035
|
-
throw e;
|
|
9036
|
-
}
|
|
9037
|
-
}
|
|
9038
|
-
// ─── Daemon-level command core ───────────────────
|
|
9039
|
-
/**
|
|
9040
|
-
* Daemon-level command execution (IDE start/stop/restart, CLI, detect, logs).
|
|
9041
|
-
* Returns null if not handled at this level → caller delegates to CommandHandler.
|
|
9042
|
-
*/
|
|
9043
|
-
async executeDaemonCommand(cmd, args) {
|
|
9044
|
-
switch (cmd) {
|
|
9045
|
-
// ─── CLI / ACP commands ───
|
|
9046
|
-
case "launch_cli":
|
|
9047
|
-
case "stop_cli":
|
|
9048
|
-
case "agent_command": {
|
|
9049
|
-
return this.deps.cliManager.handleCliCommand(cmd, args);
|
|
9050
|
-
}
|
|
9051
|
-
// ─── Logs ───
|
|
9052
|
-
case "get_logs": {
|
|
9053
|
-
const count = parseInt(args?.count) || parseInt(args?.lines) || 100;
|
|
9054
|
-
const minLevel = args?.minLevel || "info";
|
|
9055
|
-
const sinceTs = args?.since || 0;
|
|
9056
|
-
try {
|
|
9057
|
-
let logs = getRecentLogs(count, minLevel);
|
|
9058
|
-
if (sinceTs > 0) {
|
|
9059
|
-
logs = logs.filter((l) => l.ts > sinceTs);
|
|
9060
|
-
}
|
|
9061
|
-
if (logs.length > 0) {
|
|
9062
|
-
return { success: true, logs, totalBuffered: logs.length };
|
|
9063
|
-
}
|
|
9064
|
-
if (fs7.existsSync(LOG_PATH)) {
|
|
9065
|
-
const content = fs7.readFileSync(LOG_PATH, "utf-8");
|
|
9066
|
-
const allLines = content.split("\n");
|
|
9067
|
-
const recent = allLines.slice(-count).join("\n");
|
|
9068
|
-
return { success: true, logs: recent, totalLines: allLines.length };
|
|
9069
|
-
}
|
|
9070
|
-
return { success: true, logs: [], totalBuffered: 0 };
|
|
9071
|
-
} catch (e) {
|
|
9072
|
-
return { success: false, error: e.message };
|
|
9073
|
-
}
|
|
9074
|
-
}
|
|
9075
|
-
// ─── restart_session: IDE / CLI / ACP unified ───
|
|
9076
|
-
case "restart_session": {
|
|
9077
|
-
const targetType = args?.cliType || args?.agentType || args?.ideType;
|
|
9078
|
-
if (!targetType) throw new Error("cliType or ideType required");
|
|
9079
|
-
const isIde = this.deps.cdpManagers.has(targetType) || this.deps.providerLoader.getMeta(targetType)?.category === "ide";
|
|
9080
|
-
if (isIde) {
|
|
9081
|
-
await this.stopIde(targetType, true);
|
|
9082
|
-
const launchResult = await this.executeDaemonCommand("launch_ide", { ideType: targetType, enableCdp: true, workspace: args?.workspace });
|
|
9083
|
-
return { success: true, restarted: true, ideType: targetType, launch: launchResult };
|
|
9084
|
-
}
|
|
9085
|
-
return this.deps.cliManager.handleCliCommand(cmd, args);
|
|
9086
|
-
}
|
|
9087
|
-
// ─── IDE stop ───
|
|
9088
|
-
case "stop_ide": {
|
|
9089
|
-
const ideType = args?.ideType;
|
|
9090
|
-
if (!ideType) throw new Error("ideType required");
|
|
9091
|
-
const killProcess = args?.killProcess !== false;
|
|
9092
|
-
await this.stopIde(ideType, killProcess);
|
|
9093
|
-
return { success: true, ideType, stopped: true, processKilled: killProcess };
|
|
9094
|
-
}
|
|
9095
|
-
// ─── IDE restart ───
|
|
9096
|
-
case "restart_ide": {
|
|
9097
|
-
const ideType = args?.ideType;
|
|
9098
|
-
if (!ideType) throw new Error("ideType required");
|
|
9099
|
-
await this.stopIde(ideType, true);
|
|
9100
|
-
const launchResult = await this.executeDaemonCommand("launch_ide", { ideType, enableCdp: true, workspace: args?.workspace });
|
|
9101
|
-
return { success: true, ideType, restarted: true, launch: launchResult };
|
|
9102
|
-
}
|
|
9103
|
-
// ─── IDE launch + CDP connect ───
|
|
9104
|
-
case "launch_ide": {
|
|
9105
|
-
const ideKey = args?.ideId || args?.ideType;
|
|
9106
|
-
const resolvedWorkspace = resolveIdeLaunchWorkspace(
|
|
9107
|
-
{
|
|
9108
|
-
workspace: args?.workspace,
|
|
9109
|
-
workspaceId: args?.workspaceId,
|
|
9110
|
-
useDefaultWorkspace: args?.useDefaultWorkspace
|
|
9111
|
-
},
|
|
9112
|
-
loadConfig()
|
|
9113
|
-
);
|
|
9114
|
-
const launchArgs = {
|
|
9115
|
-
ideId: ideKey,
|
|
9116
|
-
workspace: resolvedWorkspace,
|
|
9117
|
-
newWindow: args?.newWindow
|
|
9118
|
-
};
|
|
9119
|
-
LOG.info("LaunchIDE", `target=${ideKey || "auto"}`);
|
|
9120
|
-
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
|
-
if (result.success && result.port && result.ideId && !this.deps.cdpManagers.has(result.ideId)) {
|
|
9134
|
-
const logFn = this.deps.getCdpLogFn ? this.deps.getCdpLogFn(result.ideId) : LOG.forComponent(`CDP:${result.ideId}`).asLogFn();
|
|
9135
|
-
const provider = this.deps.providerLoader.getMeta(result.ideId);
|
|
9136
|
-
const manager = new DaemonCdpManager(result.port, logFn, void 0, provider?.targetFilter);
|
|
9137
|
-
const connected = await manager.connect();
|
|
9138
|
-
if (connected) {
|
|
9139
|
-
registerExtensionProviders(this.deps.providerLoader, manager, result.ideId);
|
|
9140
|
-
this.deps.cdpManagers.set(result.ideId, manager);
|
|
9141
|
-
LOG.info("CDP", `Connected: ${result.ideId} (port ${result.port})`);
|
|
9142
|
-
LOG.info("CDP", `${this.deps.cdpManagers.size} IDE(s) connected`);
|
|
9143
|
-
this.deps.onCdpManagerCreated?.(result.ideId, manager);
|
|
9144
|
-
}
|
|
9145
|
-
}
|
|
9146
|
-
this.deps.onIdeConnected?.();
|
|
9147
|
-
if (result.success && resolvedWorkspace) {
|
|
9148
|
-
try {
|
|
9149
|
-
let next = appendWorkspaceActivity(loadConfig(), resolvedWorkspace, {
|
|
9150
|
-
kind: "ide",
|
|
9151
|
-
agentType: result.ideId
|
|
9152
|
-
});
|
|
9153
|
-
next = appendRecentActivity(next, {
|
|
9154
|
-
kind: "ide",
|
|
9155
|
-
providerType: result.ideId || ideKey,
|
|
9156
|
-
providerName: result.ideId || ideKey,
|
|
9157
|
-
workspace: resolvedWorkspace,
|
|
9158
|
-
title: result.ideId || ideKey
|
|
9159
|
-
});
|
|
9160
|
-
saveConfig(next);
|
|
9161
|
-
} catch {
|
|
9162
|
-
}
|
|
9163
|
-
} else if (result.success && (result.ideId || ideKey)) {
|
|
9164
|
-
try {
|
|
9165
|
-
saveConfig(appendRecentActivity(loadConfig(), {
|
|
9166
|
-
kind: "ide",
|
|
9167
|
-
providerType: result.ideId || ideKey,
|
|
9168
|
-
providerName: result.ideId || ideKey,
|
|
9169
|
-
title: result.ideId || ideKey
|
|
9170
|
-
}));
|
|
9171
|
-
} catch {
|
|
9172
|
-
}
|
|
9173
|
-
}
|
|
9174
|
-
return { success: result.success, ...result };
|
|
9175
|
-
}
|
|
9176
|
-
// ─── Detect IDEs ───
|
|
9177
|
-
case "detect_ides": {
|
|
9178
|
-
const results = await detectIDEs();
|
|
9179
|
-
this.deps.detectedIdes.value = results;
|
|
9180
|
-
return { success: true, detectedInfo: results };
|
|
9181
|
-
}
|
|
9182
|
-
// ─── Set User Name ───
|
|
9183
|
-
case "set_user_name": {
|
|
9184
|
-
const name = args?.userName;
|
|
9185
|
-
if (!name || typeof name !== "string") throw new Error("userName required");
|
|
9186
|
-
updateConfig({ userName: name });
|
|
9187
|
-
return { success: true, userName: name };
|
|
9188
|
-
}
|
|
9189
|
-
case "mark_recent_seen": {
|
|
9190
|
-
const kind = args?.kind;
|
|
9191
|
-
const providerType = args?.providerType;
|
|
9192
|
-
if (!kind || !providerType) {
|
|
9193
|
-
return { success: false, error: "kind and providerType are required" };
|
|
9194
|
-
}
|
|
9195
|
-
const recentKey = args?.recentKey || buildRecentActivityKey({
|
|
9196
|
-
kind,
|
|
9197
|
-
providerType,
|
|
9198
|
-
workspace: args?.workspace || null
|
|
9199
|
-
});
|
|
9200
|
-
const next = markRecentSessionSeen(
|
|
9201
|
-
loadConfig(),
|
|
9202
|
-
recentKey,
|
|
9203
|
-
typeof args?.seenAt === "number" ? args.seenAt : Date.now()
|
|
9204
|
-
);
|
|
9205
|
-
saveConfig(next);
|
|
9206
|
-
this.deps.onStatusChange?.();
|
|
9207
|
-
return {
|
|
9208
|
-
success: true,
|
|
9209
|
-
recentKey,
|
|
9210
|
-
seenAt: next.recentSessionReads?.[recentKey] || Date.now()
|
|
9211
|
-
};
|
|
9212
|
-
}
|
|
9213
|
-
// ─── Daemon Self-Upgrade ───
|
|
9214
|
-
case "daemon_upgrade": {
|
|
9215
|
-
LOG.info("Upgrade", "Remote upgrade requested from dashboard");
|
|
9216
|
-
try {
|
|
9217
|
-
const { execSync: execSync7 } = await import("child_process");
|
|
9218
|
-
const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
|
|
9219
|
-
const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
|
|
9220
|
-
const latest = execSync7(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
9221
|
-
LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
|
|
9222
|
-
execSync7(`npm install -g ${pkgName}@latest --force`, {
|
|
9223
|
-
encoding: "utf-8",
|
|
9224
|
-
timeout: 12e4,
|
|
9225
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
9226
|
-
});
|
|
9227
|
-
LOG.info("Upgrade", `\u2705 Upgraded to v${latest}`);
|
|
9228
|
-
setTimeout(() => {
|
|
9229
|
-
LOG.info("Upgrade", "Restarting daemon with new version...");
|
|
9230
|
-
try {
|
|
9231
|
-
const path19 = require("path");
|
|
9232
|
-
const fs16 = require("fs");
|
|
9233
|
-
const pidFile = path19.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
|
|
9234
|
-
if (fs16.existsSync(pidFile)) fs16.unlinkSync(pidFile);
|
|
9235
|
-
} catch {
|
|
9236
|
-
}
|
|
9237
|
-
const { spawn: spawn4 } = require("child_process");
|
|
9238
|
-
const child = spawn4(process.execPath, process.argv.slice(1), {
|
|
9239
|
-
detached: true,
|
|
9240
|
-
stdio: "ignore",
|
|
9241
|
-
env: { ...process.env }
|
|
9242
|
-
});
|
|
9243
|
-
child.unref();
|
|
9244
|
-
process.exit(0);
|
|
9245
|
-
}, 3e3);
|
|
9246
|
-
return { success: true, upgraded: true, version: latest };
|
|
9247
|
-
} catch (e) {
|
|
9248
|
-
LOG.error("Upgrade", `Failed: ${e.message}`);
|
|
9249
|
-
return { success: false, error: e.message };
|
|
9250
|
-
}
|
|
9251
|
-
}
|
|
9252
|
-
// ─── Machine Settings ───
|
|
9253
|
-
case "set_machine_nickname": {
|
|
9254
|
-
const nickname = args?.nickname;
|
|
9255
|
-
updateConfig({ machineNickname: nickname || null });
|
|
9256
|
-
return { success: true };
|
|
9257
|
-
}
|
|
9258
|
-
default:
|
|
9259
|
-
break;
|
|
9260
|
-
}
|
|
9261
|
-
return null;
|
|
9262
|
-
}
|
|
9263
|
-
/**
|
|
9264
|
-
* IDE stop: CDP disconnect + InstanceManager cleanup + optionally kill OS process
|
|
9265
|
-
*/
|
|
9266
|
-
async stopIde(ideType, killProcess = false) {
|
|
9267
|
-
const cdpKeysToRemove = [];
|
|
9268
|
-
for (const key of this.deps.cdpManagers.keys()) {
|
|
9269
|
-
if (key === ideType || key.startsWith(`${ideType}_`)) {
|
|
9270
|
-
cdpKeysToRemove.push(key);
|
|
9271
|
-
}
|
|
9272
|
-
}
|
|
9273
|
-
for (const key of cdpKeysToRemove) {
|
|
9274
|
-
const cdp = this.deps.cdpManagers.get(key);
|
|
9275
|
-
if (cdp) {
|
|
9276
|
-
try {
|
|
9277
|
-
cdp.disconnect();
|
|
9278
|
-
} catch {
|
|
9279
|
-
}
|
|
9280
|
-
this.deps.cdpManagers.delete(key);
|
|
9281
|
-
this.deps.sessionRegistry.unregisterByManagerKey(key);
|
|
9282
|
-
LOG.info("StopIDE", `CDP disconnected: ${key}`);
|
|
9283
|
-
}
|
|
9284
|
-
}
|
|
9285
|
-
const keysToRemove = [];
|
|
9286
|
-
for (const key of this.deps.instanceManager.listInstanceIds()) {
|
|
9287
|
-
if (key === `ide:${ideType}` || typeof key === "string" && key.startsWith(`ide:${ideType}_`)) {
|
|
9288
|
-
keysToRemove.push(key);
|
|
9289
|
-
}
|
|
9290
|
-
}
|
|
9291
|
-
for (const instanceKey of keysToRemove) {
|
|
9292
|
-
const ideInstance = this.deps.instanceManager.getInstance(instanceKey);
|
|
9293
|
-
if (ideInstance) {
|
|
9294
|
-
this.deps.instanceManager.removeInstance(instanceKey);
|
|
9295
|
-
LOG.info("StopIDE", `Instance removed: ${instanceKey}`);
|
|
9296
|
-
}
|
|
9297
|
-
}
|
|
9298
|
-
if (keysToRemove.length === 0) {
|
|
9299
|
-
const instanceKey = `ide:${ideType}`;
|
|
9300
|
-
const ideInstance = this.deps.instanceManager.getInstance(instanceKey);
|
|
9301
|
-
if (ideInstance) {
|
|
9302
|
-
this.deps.instanceManager.removeInstance(instanceKey);
|
|
9303
|
-
LOG.info("StopIDE", `Instance removed: ${instanceKey}`);
|
|
9304
|
-
}
|
|
9305
|
-
}
|
|
9306
|
-
if (killProcess) {
|
|
9307
|
-
const running = isIdeRunning(ideType);
|
|
9308
|
-
if (running) {
|
|
9309
|
-
LOG.info("StopIDE", `Killing IDE process: ${ideType}`);
|
|
9310
|
-
const killed = await killIdeProcess(ideType);
|
|
9311
|
-
if (killed) {
|
|
9312
|
-
LOG.info("StopIDE", `\u2705 Process killed: ${ideType}`);
|
|
9313
|
-
} else {
|
|
9314
|
-
LOG.warn("StopIDE", `\u26A0 Could not kill process: ${ideType} (may need manual intervention)`);
|
|
9315
|
-
}
|
|
9316
|
-
} else {
|
|
9317
|
-
LOG.info("StopIDE", `Process not running: ${ideType}`);
|
|
9318
|
-
}
|
|
9319
|
-
}
|
|
9320
|
-
this.deps.onStatusChange?.();
|
|
9321
|
-
LOG.info("StopIDE", `IDE stopped: ${ideType} (processKill=${killProcess})`);
|
|
9322
|
-
}
|
|
9323
|
-
};
|
|
9324
|
-
}
|
|
9325
|
-
});
|
|
9326
|
-
|
|
9327
8851
|
// ../../oss/packages/daemon-core/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts
|
|
9328
8852
|
function isModuleNotFoundError(error48, ref) {
|
|
9329
8853
|
if (!(error48 instanceof Error)) return false;
|
|
@@ -10151,7 +9675,7 @@ function Ec(s15, t) {
|
|
|
10151
9675
|
function Tc(s15) {
|
|
10152
9676
|
return s15.keyCode === 16 || s15.keyCode === 17 || s15.keyCode === 18;
|
|
10153
9677
|
}
|
|
10154
|
-
var zs, Rl, Ll, M, S, Gs, mi, $s, _i, er, tr, ir, we, De, rt, q, js, Hn, Fn, F, rr, ge, Zs, xt, nr, H, sr, Js, Be, wt, nt, ae, Dt, ce, Qs, or, Re, lr, Wn, Bl, Un, bi, ar, Rt, cr, ro, so, At, lo, ao, oo, ur, zn, Wl, dt, hr, dr, Ee, D, ye, fe, kt, G, Ct, zl, mr, Gl, fo, $l, $, Mt, $n, po, br, Vn, gi, qn, Yn, Vl, Pt, ql, Yl, _r, v, jn, gr, Si, Eu, Tu, Ot, Ei, Bt, Ti, Sr, Iu, yu, vr, Nt, yr, xr, Ii, Zl, vo, go, Jl, Ql, ea, ta, Tr, Ir, bo, ia, $e, Ve, xe, So, ra, Xn, wr, Te, Zn, Dr, na, xu, Fe, st, sa, oa, Eo, la, wu, Du, Ru, Lu, ot, aa, yi, Jn, To, Io, yo, Qn, Rr, es, ua, ha, da, fa, ft, wo, Lr, qe, xi, Do, ma, ts2, Ye, kr, ba, Ar, va, _e, Cr, Bh, be, Nh, Fh, Hh, Oo, Wh, Uh, No, Kh, zh, ss, os10, wa, mt, Mr, Di, pt, Gh, Y, Da, ls, Wt, He, Q, Pr, lt, Uo, Or, cs, Ri, Br, Nr, Fr, Ca, Ut, Kt, Wr, Ur, Ma, Ko, zo, us, zr, hs, ds, Kr, zt, Gt, Gr, We, at, Li, bt, b, Ai,
|
|
9678
|
+
var zs, Rl, Ll, M, S, Gs, mi, $s, _i, er, tr, ir, we, De, rt, q, js, Hn, Fn, F, rr, ge, Zs, xt, nr, H, sr, Js, Be, wt, nt, ae, Dt, ce, Qs, or, Re, lr, Wn, Bl, Un, bi, ar, Rt, cr, ro, so, At, lo, ao, oo, ur, zn, Wl, dt, hr, dr, Ee, D, ye, fe, kt, G, Ct, zl, mr, Gl, fo, $l, $, Mt, $n, po, br, Vn, gi, qn, Yn, Vl, Pt, ql, Yl, _r, v, jn, gr, Si, Eu, Tu, Ot, Ei, Bt, Ti, Sr, Iu, yu, vr, Nt, yr, xr, Ii, Zl, vo, go, Jl, Ql, ea, ta, Tr, Ir, bo, ia, $e, Ve, xe, So, ra, Xn, wr, Te, Zn, Dr, na, xu, Fe, st, sa, oa, Eo, la, wu, Du, Ru, Lu, ot, aa, yi, Jn, To, Io, yo, Qn, Rr, es, ua, ha, da, fa, ft, wo, Lr, qe, xi, Do, ma, ts2, Ye, kr, ba, Ar, va, _e, Cr, Bh, be, Nh, Fh, Hh, Oo, Wh, Uh, No, Kh, zh, ss, os10, wa, mt, Mr, Di, pt, Gh, Y, Da, ls, Wt, He, Q, Pr, lt, Uo, Or, cs, Ri, Br, Nr, Fr, Ca, Ut, Kt, Wr, Ur, Ma, Ko, zo, us, zr, hs, ds, Kr, zt, Gt, Gr, We, at, Li, bt, b, Ai, fs7, $t, ue, he, de, J, ps, j, U, z, ve, $r, Vr, ct, Vt, Yr, ms, _s, Le, jr, jo, ki, Xr, Na, Yt, jt, Zr, bs, vs, Jr, gs, Qr, Xt, en, tn, Mi, Pi, Oi, Ss, Fa, Zo, Zt, Wa, Ua, Es, Bi, Ts, rn, Is, ys, Jt, nn, Qt, xs, on, Ds, Ya, ja, Xa, Za, Ja, ei, Hi, Wi, re, St, Ki, tl, il, Ui, Qa, ti, Rs, ln, ec, tc, ii, ic, zi, B, X, an, Ls, Ze, un, cn, ne, Je, cl, $i, hn, ks, Cs, ni, si, nc, dn, ul, hl, li, dl, Ps, fl, ai, Os, ac, se, fn, Ae, pn, Vi, uc, ci, qi, mn, pe, Yi, _n, ji, Xi, Fs, ke, hc, bn, dc, fc, mc, ut, _l, vl, gl, vn, Zi, _c, El, bc, gn, ui, Tl, Sn, gc, ee, En, Us, yl, Tn, Ks, Sc, In, xl, wl, Tt, hi, yn, xn, wn, Ji, Dn, Rn, Ln, Ic, Ue, Dl;
|
|
10155
9679
|
var init_xterm = __esm({
|
|
10156
9680
|
"../../oss/node_modules/@xterm/xterm/lib/xterm.mjs"() {
|
|
10157
9681
|
"use strict";
|
|
@@ -13426,7 +12950,7 @@ ${h.join(`
|
|
|
13426
12950
|
((E) => (E.NUL = "\0", E.SOH = "", E.STX = "", E.ETX = "", E.EOT = "", E.ENQ = "", E.ACK = "", E.BEL = "\x07", E.BS = "\b", E.HT = " ", E.LF = `
|
|
13427
12951
|
`, E.VT = "\v", E.FF = "\f", E.CR = "\r", E.SO = "", E.SI = "", E.DLE = "", E.DC1 = "", E.DC2 = "", E.DC3 = "", E.DC4 = "", E.NAK = "", E.SYN = "", E.ETB = "", E.CAN = "", E.EM = "", E.SUB = "", E.ESC = "\x1B", E.FS = "", E.GS = "", E.RS = "", E.US = "", E.SP = " ", E.DEL = "\x7F"))(b ||= {});
|
|
13428
12952
|
((g) => (g.PAD = "\x80", g.HOP = "\x81", g.BPH = "\x82", g.NBH = "\x83", g.IND = "\x84", g.NEL = "\x85", g.SSA = "\x86", g.ESA = "\x87", g.HTS = "\x88", g.HTJ = "\x89", g.VTS = "\x8A", g.PLD = "\x8B", g.PLU = "\x8C", g.RI = "\x8D", g.SS2 = "\x8E", g.SS3 = "\x8F", g.DCS = "\x90", g.PU1 = "\x91", g.PU2 = "\x92", g.STS = "\x93", g.CCH = "\x94", g.MW = "\x95", g.SPA = "\x96", g.EPA = "\x97", g.SOS = "\x98", g.SGCI = "\x99", g.SCI = "\x9A", g.CSI = "\x9B", g.ST = "\x9C", g.OSC = "\x9D", g.PM = "\x9E", g.APC = "\x9F"))(Ai ||= {});
|
|
13429
|
-
((t) => t.ST = `${b.ESC}\\`)(
|
|
12953
|
+
((t) => t.ST = `${b.ESC}\\`)(fs7 ||= {});
|
|
13430
12954
|
$t = class {
|
|
13431
12955
|
constructor(t, e, i, r, n, o) {
|
|
13432
12956
|
this._textarea = t;
|
|
@@ -17855,7 +17379,7 @@ ${h.join(`
|
|
|
17855
17379
|
switch (i.type) {
|
|
17856
17380
|
case 0:
|
|
17857
17381
|
let o = U.toColorRGB(r === "ansi" ? this._themeService.colors.ansi[i.index] : this._themeService.colors[r]);
|
|
17858
|
-
this.coreService.triggerDataEvent(`${b.ESC}]${n};${ml(o)}${
|
|
17382
|
+
this.coreService.triggerDataEvent(`${b.ESC}]${n};${ml(o)}${fs7.ST}`);
|
|
17859
17383
|
break;
|
|
17860
17384
|
case 1:
|
|
17861
17385
|
if (r === "ansi") this._themeService.modifyColors((l) => l.ansi[i.index] = j.toColor(...i.color));
|
|
@@ -18696,81 +18220,45 @@ function getSessionMessageUpdatedAt(session) {
|
|
|
18696
18220
|
if (!lastMessage) return 0;
|
|
18697
18221
|
return parseMessageTime(lastMessage.timestamp) || parseMessageTime(lastMessage.receivedAt) || parseMessageTime(lastMessage.createdAt) || 0;
|
|
18698
18222
|
}
|
|
18223
|
+
function getSessionCompletionMarker(session) {
|
|
18224
|
+
const lastMessage = session.activeChat?.messages?.at?.(-1);
|
|
18225
|
+
if (!lastMessage) return "";
|
|
18226
|
+
const role = typeof lastMessage.role === "string" ? lastMessage.role : "";
|
|
18227
|
+
if (role === "user" || role === "human") return "";
|
|
18228
|
+
if (typeof lastMessage._turnKey === "string" && lastMessage._turnKey) return `turn:${lastMessage._turnKey}`;
|
|
18229
|
+
if (typeof lastMessage.id === "string" && lastMessage.id) return `id:${lastMessage.id}`;
|
|
18230
|
+
if (typeof lastMessage.index === "number" && Number.isFinite(lastMessage.index)) return `idx:${lastMessage.index}`;
|
|
18231
|
+
const timestamp = parseMessageTime(lastMessage.timestamp) || parseMessageTime(lastMessage.receivedAt) || parseMessageTime(lastMessage.createdAt);
|
|
18232
|
+
return timestamp > 0 ? `ts:${timestamp}` : "";
|
|
18233
|
+
}
|
|
18699
18234
|
function getSessionLastUsedAt(session) {
|
|
18700
18235
|
return getSessionMessageUpdatedAt(session) || session.lastUpdated || Date.now();
|
|
18701
18236
|
}
|
|
18702
|
-
function getSessionKind(session) {
|
|
18703
|
-
return session.transport === "cdp-page" || session.transport === "cdp-webview" ? "ide" : session.transport === "acp" ? "acp" : "cli";
|
|
18704
|
-
}
|
|
18705
18237
|
function getLastMessageRole(session) {
|
|
18706
18238
|
const role = session.activeChat?.messages?.at?.(-1)?.role;
|
|
18707
18239
|
return typeof role === "string" ? role : "";
|
|
18708
18240
|
}
|
|
18709
|
-
function getUnreadState(hasContentChange, status, lastUsedAt, lastSeenAt, lastRole) {
|
|
18241
|
+
function getUnreadState(hasContentChange, status, lastUsedAt, lastSeenAt, lastRole, completionMarker, seenCompletionMarker) {
|
|
18710
18242
|
if (status === "waiting_approval") {
|
|
18711
18243
|
return { unread: false, inboxBucket: "needs_attention" };
|
|
18712
18244
|
}
|
|
18713
18245
|
if (status === "generating" || status === "starting") {
|
|
18714
18246
|
return { unread: false, inboxBucket: "working" };
|
|
18715
18247
|
}
|
|
18716
|
-
const unread = hasContentChange && lastUsedAt > lastSeenAt && lastRole !== "user" && lastRole !== "human";
|
|
18248
|
+
const unread = completionMarker ? completionMarker !== seenCompletionMarker : hasContentChange && lastUsedAt > lastSeenAt && lastRole !== "user" && lastRole !== "human";
|
|
18717
18249
|
return { unread, inboxBucket: unread ? "task_complete" : "idle" };
|
|
18718
18250
|
}
|
|
18719
|
-
function
|
|
18720
|
-
|
|
18721
|
-
|
|
18722
|
-
|
|
18723
|
-
|
|
18724
|
-
|
|
18725
|
-
|
|
18726
|
-
|
|
18727
|
-
|
|
18728
|
-
|
|
18729
|
-
|
|
18730
|
-
getSessionMessageUpdatedAt(session) > 0,
|
|
18731
|
-
session.status,
|
|
18732
|
-
lastUsedAt,
|
|
18733
|
-
lastSeenAt,
|
|
18734
|
-
getLastMessageRole(session)
|
|
18735
|
-
);
|
|
18736
|
-
return {
|
|
18737
|
-
id: session.id,
|
|
18738
|
-
recentKey,
|
|
18739
|
-
sessionId: session.id,
|
|
18740
|
-
providerType: session.providerType,
|
|
18741
|
-
providerName: session.providerName,
|
|
18742
|
-
kind,
|
|
18743
|
-
title: session.activeChat?.title || session.title || session.providerName,
|
|
18744
|
-
workspace: session.workspace,
|
|
18745
|
-
currentModel: session.currentModel,
|
|
18746
|
-
status: session.status,
|
|
18747
|
-
lastUsedAt,
|
|
18748
|
-
unread,
|
|
18749
|
-
lastSeenAt,
|
|
18750
|
-
inboxBucket
|
|
18751
|
-
};
|
|
18752
|
-
});
|
|
18753
|
-
const seen = new Set(live.map((item) => `${item.kind}:${item.providerType}:${item.workspace || ""}`));
|
|
18754
|
-
const persisted = recentActivity.filter((item) => !seen.has(`${item.kind}:${item.providerType}:${item.workspace || ""}`)).map((item) => {
|
|
18755
|
-
const lastSeenAt = readState[item.id] || 0;
|
|
18756
|
-
const unread = item.lastUsedAt > lastSeenAt;
|
|
18757
|
-
return {
|
|
18758
|
-
id: item.id,
|
|
18759
|
-
recentKey: item.id,
|
|
18760
|
-
sessionId: item.sessionId || null,
|
|
18761
|
-
providerType: item.providerType,
|
|
18762
|
-
providerName: item.providerName,
|
|
18763
|
-
kind: item.kind,
|
|
18764
|
-
title: item.title || item.providerName,
|
|
18765
|
-
workspace: item.workspace,
|
|
18766
|
-
currentModel: item.currentModel,
|
|
18767
|
-
lastUsedAt: item.lastUsedAt,
|
|
18768
|
-
unread,
|
|
18769
|
-
lastSeenAt,
|
|
18770
|
-
inboxBucket: unread ? "task_complete" : "idle"
|
|
18771
|
-
};
|
|
18772
|
-
});
|
|
18773
|
-
return [...live, ...persisted].sort((a, b2) => b2.lastUsedAt - a.lastUsedAt).slice(0, 12);
|
|
18251
|
+
function buildRecentLaunches(recentActivity) {
|
|
18252
|
+
return recentActivity.map((item) => ({
|
|
18253
|
+
id: item.id,
|
|
18254
|
+
providerType: item.providerType,
|
|
18255
|
+
providerName: item.providerName,
|
|
18256
|
+
kind: item.kind,
|
|
18257
|
+
title: item.title || item.providerName,
|
|
18258
|
+
workspace: item.workspace,
|
|
18259
|
+
currentModel: item.currentModel,
|
|
18260
|
+
lastLaunchedAt: item.lastUsedAt
|
|
18261
|
+
})).sort((a, b2) => b2.lastLaunchedAt - a.lastLaunchedAt).slice(0, 12);
|
|
18774
18262
|
}
|
|
18775
18263
|
function buildStatusSnapshot(options) {
|
|
18776
18264
|
const cfg = loadConfig();
|
|
@@ -18781,27 +18269,29 @@ function buildStatusSnapshot(options) {
|
|
|
18781
18269
|
options.allStates,
|
|
18782
18270
|
options.cdpManagers
|
|
18783
18271
|
);
|
|
18784
|
-
const readState = cfg.recentSessionReads || {};
|
|
18785
18272
|
for (const session of sessions) {
|
|
18786
|
-
const
|
|
18787
|
-
const
|
|
18788
|
-
kind,
|
|
18789
|
-
providerType: session.providerType,
|
|
18790
|
-
workspace: session.workspace
|
|
18791
|
-
});
|
|
18792
|
-
const lastSeenAt = getRecentSessionSeenAt(cfg, recentKey);
|
|
18273
|
+
const lastSeenAt = getSessionSeenAt(cfg, session.id);
|
|
18274
|
+
const seenCompletionMarker = getSessionSeenMarker(cfg, session.id);
|
|
18793
18275
|
const lastUsedAt = getSessionLastUsedAt(session);
|
|
18794
|
-
const
|
|
18276
|
+
const completionMarker = getSessionCompletionMarker(session);
|
|
18277
|
+
const { unread, inboxBucket } = session.surfaceHidden ? { unread: false, inboxBucket: "idle" } : getUnreadState(
|
|
18795
18278
|
getSessionMessageUpdatedAt(session) > 0,
|
|
18796
18279
|
session.status,
|
|
18797
18280
|
lastUsedAt,
|
|
18798
18281
|
lastSeenAt,
|
|
18799
|
-
getLastMessageRole(session)
|
|
18282
|
+
getLastMessageRole(session),
|
|
18283
|
+
completionMarker,
|
|
18284
|
+
seenCompletionMarker
|
|
18800
18285
|
);
|
|
18801
|
-
session.recentKey = recentKey;
|
|
18802
18286
|
session.lastSeenAt = lastSeenAt;
|
|
18803
18287
|
session.unread = unread;
|
|
18804
18288
|
session.inboxBucket = inboxBucket;
|
|
18289
|
+
if (READ_DEBUG_ENABLED && (session.unread || session.inboxBucket !== "idle" || session.providerType.includes("codex"))) {
|
|
18290
|
+
LOG.info(
|
|
18291
|
+
"RecentRead",
|
|
18292
|
+
`snapshot session id=${session.id} provider=${session.providerType} status=${String(session.status || "")} bucket=${inboxBucket} unread=${String(unread)} lastSeenAt=${lastSeenAt} completionMarker=${completionMarker || "-"} seenMarker=${seenCompletionMarker || "-"} lastUpdated=${String(session.lastUpdated || 0)} lastUsedAt=${lastUsedAt} lastRole=${getLastMessageRole(session)} msgUpdatedAt=${getSessionMessageUpdatedAt(session)}`
|
|
18293
|
+
);
|
|
18294
|
+
}
|
|
18805
18295
|
}
|
|
18806
18296
|
const terminalBackend = getTerminalBackendRuntimeStatus();
|
|
18807
18297
|
return {
|
|
@@ -18828,13 +18318,12 @@ function buildStatusSnapshot(options) {
|
|
|
18828
18318
|
workspaces: wsState.workspaces,
|
|
18829
18319
|
defaultWorkspaceId: wsState.defaultWorkspaceId,
|
|
18830
18320
|
defaultWorkspacePath: wsState.defaultWorkspacePath,
|
|
18831
|
-
|
|
18832
|
-
recentSessions: buildRecentSessions(sessions, recentActivity, readState),
|
|
18321
|
+
recentLaunches: buildRecentLaunches(recentActivity),
|
|
18833
18322
|
terminalBackend,
|
|
18834
18323
|
availableProviders: buildAvailableProviders(options.providerLoader)
|
|
18835
18324
|
};
|
|
18836
18325
|
}
|
|
18837
|
-
var os11;
|
|
18326
|
+
var os11, READ_DEBUG_ENABLED;
|
|
18838
18327
|
var init_snapshot = __esm({
|
|
18839
18328
|
"../../oss/packages/daemon-core/src/status/snapshot.ts"() {
|
|
18840
18329
|
"use strict";
|
|
@@ -18842,10 +18331,352 @@ var init_snapshot = __esm({
|
|
|
18842
18331
|
init_config();
|
|
18843
18332
|
init_recent_activity();
|
|
18844
18333
|
init_workspaces();
|
|
18845
|
-
init_workspace_activity();
|
|
18846
18334
|
init_host_memory();
|
|
18847
18335
|
init_terminal_screen();
|
|
18336
|
+
init_logger();
|
|
18337
|
+
init_builders();
|
|
18338
|
+
READ_DEBUG_ENABLED = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
|
|
18339
|
+
}
|
|
18340
|
+
});
|
|
18341
|
+
|
|
18342
|
+
// ../../oss/packages/daemon-core/src/commands/router.ts
|
|
18343
|
+
var fs8, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
|
|
18344
|
+
var init_router = __esm({
|
|
18345
|
+
"../../oss/packages/daemon-core/src/commands/router.ts"() {
|
|
18346
|
+
"use strict";
|
|
18347
|
+
init_manager();
|
|
18348
|
+
init_setup();
|
|
18349
|
+
init_launch();
|
|
18350
|
+
init_config();
|
|
18351
|
+
init_workspaces();
|
|
18352
|
+
init_recent_activity();
|
|
18353
|
+
init_ide_detector();
|
|
18354
|
+
init_logger();
|
|
18355
|
+
init_command_log();
|
|
18356
|
+
init_logger();
|
|
18848
18357
|
init_builders();
|
|
18358
|
+
init_snapshot();
|
|
18359
|
+
fs8 = __toESM(require("fs"));
|
|
18360
|
+
CHAT_COMMANDS = [
|
|
18361
|
+
"send_chat",
|
|
18362
|
+
"new_chat",
|
|
18363
|
+
"switch_chat",
|
|
18364
|
+
"set_mode",
|
|
18365
|
+
"change_model"
|
|
18366
|
+
];
|
|
18367
|
+
READ_DEBUG_ENABLED2 = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
|
|
18368
|
+
DaemonCommandRouter = class {
|
|
18369
|
+
deps;
|
|
18370
|
+
constructor(deps) {
|
|
18371
|
+
this.deps = deps;
|
|
18372
|
+
}
|
|
18373
|
+
/**
|
|
18374
|
+
* Unified command routing.
|
|
18375
|
+
* Returns result for all commands:
|
|
18376
|
+
* 1. Daemon-level commands (launch_ide, stop_ide, etc.)
|
|
18377
|
+
* 2. CLI commands (launch_cli, stop_cli, agent_command)
|
|
18378
|
+
* 3. DaemonCommandHandler delegation (CDP/agent-stream/file commands)
|
|
18379
|
+
*
|
|
18380
|
+
* @param cmd Command name
|
|
18381
|
+
* @param args Command arguments
|
|
18382
|
+
* @param source Log source ('ws' | 'p2p' | 'standalone' | etc.)
|
|
18383
|
+
*/
|
|
18384
|
+
async execute(cmd, args, source = "unknown") {
|
|
18385
|
+
const cmdStart = Date.now();
|
|
18386
|
+
try {
|
|
18387
|
+
const daemonResult = await this.executeDaemonCommand(cmd, args);
|
|
18388
|
+
if (daemonResult) {
|
|
18389
|
+
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source, args, success: daemonResult.success, durationMs: Date.now() - cmdStart });
|
|
18390
|
+
return daemonResult;
|
|
18391
|
+
}
|
|
18392
|
+
const handlerResult = await this.deps.commandHandler.handle(cmd, args);
|
|
18393
|
+
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source, args, success: handlerResult.success, durationMs: Date.now() - cmdStart });
|
|
18394
|
+
if (CHAT_COMMANDS.includes(cmd) && this.deps.onPostChatCommand) {
|
|
18395
|
+
this.deps.onPostChatCommand();
|
|
18396
|
+
}
|
|
18397
|
+
return handlerResult;
|
|
18398
|
+
} catch (e) {
|
|
18399
|
+
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source, args, success: false, error: e.message, durationMs: Date.now() - cmdStart });
|
|
18400
|
+
throw e;
|
|
18401
|
+
}
|
|
18402
|
+
}
|
|
18403
|
+
// ─── Daemon-level command core ───────────────────
|
|
18404
|
+
/**
|
|
18405
|
+
* Daemon-level command execution (IDE start/stop/restart, CLI, detect, logs).
|
|
18406
|
+
* Returns null if not handled at this level → caller delegates to CommandHandler.
|
|
18407
|
+
*/
|
|
18408
|
+
async executeDaemonCommand(cmd, args) {
|
|
18409
|
+
switch (cmd) {
|
|
18410
|
+
// ─── CLI / ACP commands ───
|
|
18411
|
+
case "launch_cli":
|
|
18412
|
+
case "stop_cli":
|
|
18413
|
+
case "agent_command": {
|
|
18414
|
+
return this.deps.cliManager.handleCliCommand(cmd, args);
|
|
18415
|
+
}
|
|
18416
|
+
// ─── Logs ───
|
|
18417
|
+
case "get_logs": {
|
|
18418
|
+
const count = parseInt(args?.count) || parseInt(args?.lines) || 100;
|
|
18419
|
+
const minLevel = args?.minLevel || "info";
|
|
18420
|
+
const sinceTs = args?.since || 0;
|
|
18421
|
+
try {
|
|
18422
|
+
let logs = getRecentLogs(count, minLevel);
|
|
18423
|
+
if (sinceTs > 0) {
|
|
18424
|
+
logs = logs.filter((l) => l.ts > sinceTs);
|
|
18425
|
+
}
|
|
18426
|
+
if (logs.length > 0) {
|
|
18427
|
+
return { success: true, logs, totalBuffered: logs.length };
|
|
18428
|
+
}
|
|
18429
|
+
if (fs8.existsSync(LOG_PATH)) {
|
|
18430
|
+
const content = fs8.readFileSync(LOG_PATH, "utf-8");
|
|
18431
|
+
const allLines = content.split("\n");
|
|
18432
|
+
const recent = allLines.slice(-count).join("\n");
|
|
18433
|
+
return { success: true, logs: recent, totalLines: allLines.length };
|
|
18434
|
+
}
|
|
18435
|
+
return { success: true, logs: [], totalBuffered: 0 };
|
|
18436
|
+
} catch (e) {
|
|
18437
|
+
return { success: false, error: e.message };
|
|
18438
|
+
}
|
|
18439
|
+
}
|
|
18440
|
+
// ─── restart_session: IDE / CLI / ACP unified ───
|
|
18441
|
+
case "restart_session": {
|
|
18442
|
+
const targetType = args?.cliType || args?.agentType || args?.ideType;
|
|
18443
|
+
if (!targetType) throw new Error("cliType or ideType required");
|
|
18444
|
+
const isIde = this.deps.cdpManagers.has(targetType) || this.deps.providerLoader.getMeta(targetType)?.category === "ide";
|
|
18445
|
+
if (isIde) {
|
|
18446
|
+
await this.stopIde(targetType, true);
|
|
18447
|
+
const launchResult = await this.executeDaemonCommand("launch_ide", { ideType: targetType, enableCdp: true, workspace: args?.workspace });
|
|
18448
|
+
return { success: true, restarted: true, ideType: targetType, launch: launchResult };
|
|
18449
|
+
}
|
|
18450
|
+
return this.deps.cliManager.handleCliCommand(cmd, args);
|
|
18451
|
+
}
|
|
18452
|
+
// ─── IDE stop ───
|
|
18453
|
+
case "stop_ide": {
|
|
18454
|
+
const ideType = args?.ideType;
|
|
18455
|
+
if (!ideType) throw new Error("ideType required");
|
|
18456
|
+
const killProcess = args?.killProcess !== false;
|
|
18457
|
+
await this.stopIde(ideType, killProcess);
|
|
18458
|
+
return { success: true, ideType, stopped: true, processKilled: killProcess };
|
|
18459
|
+
}
|
|
18460
|
+
// ─── IDE restart ───
|
|
18461
|
+
case "restart_ide": {
|
|
18462
|
+
const ideType = args?.ideType;
|
|
18463
|
+
if (!ideType) throw new Error("ideType required");
|
|
18464
|
+
await this.stopIde(ideType, true);
|
|
18465
|
+
const launchResult = await this.executeDaemonCommand("launch_ide", { ideType, enableCdp: true, workspace: args?.workspace });
|
|
18466
|
+
return { success: true, ideType, restarted: true, launch: launchResult };
|
|
18467
|
+
}
|
|
18468
|
+
// ─── IDE launch + CDP connect ───
|
|
18469
|
+
case "launch_ide": {
|
|
18470
|
+
const ideKey = args?.ideId || args?.ideType;
|
|
18471
|
+
const resolvedWorkspace = resolveIdeLaunchWorkspace(
|
|
18472
|
+
{
|
|
18473
|
+
workspace: args?.workspace,
|
|
18474
|
+
workspaceId: args?.workspaceId,
|
|
18475
|
+
useDefaultWorkspace: args?.useDefaultWorkspace
|
|
18476
|
+
},
|
|
18477
|
+
loadConfig()
|
|
18478
|
+
);
|
|
18479
|
+
const launchArgs = {
|
|
18480
|
+
ideId: ideKey,
|
|
18481
|
+
workspace: resolvedWorkspace,
|
|
18482
|
+
newWindow: args?.newWindow
|
|
18483
|
+
};
|
|
18484
|
+
LOG.info("LaunchIDE", `target=${ideKey || "auto"}`);
|
|
18485
|
+
const result = await launchWithCdp(launchArgs);
|
|
18486
|
+
if (result.success && result.port && result.ideId && !this.deps.cdpManagers.has(result.ideId)) {
|
|
18487
|
+
const logFn = this.deps.getCdpLogFn ? this.deps.getCdpLogFn(result.ideId) : LOG.forComponent(`CDP:${result.ideId}`).asLogFn();
|
|
18488
|
+
const provider = this.deps.providerLoader.getMeta(result.ideId);
|
|
18489
|
+
const manager = new DaemonCdpManager(result.port, logFn, void 0, provider?.targetFilter);
|
|
18490
|
+
const connected = await manager.connect();
|
|
18491
|
+
if (connected) {
|
|
18492
|
+
registerExtensionProviders(this.deps.providerLoader, manager, result.ideId);
|
|
18493
|
+
this.deps.cdpManagers.set(result.ideId, manager);
|
|
18494
|
+
LOG.info("CDP", `Connected: ${result.ideId} (port ${result.port})`);
|
|
18495
|
+
LOG.info("CDP", `${this.deps.cdpManagers.size} IDE(s) connected`);
|
|
18496
|
+
this.deps.onCdpManagerCreated?.(result.ideId, manager);
|
|
18497
|
+
}
|
|
18498
|
+
}
|
|
18499
|
+
this.deps.onIdeConnected?.();
|
|
18500
|
+
if (result.success && resolvedWorkspace) {
|
|
18501
|
+
try {
|
|
18502
|
+
const next = appendRecentActivity(loadConfig(), {
|
|
18503
|
+
kind: "ide",
|
|
18504
|
+
providerType: result.ideId || ideKey,
|
|
18505
|
+
providerName: result.ideId || ideKey,
|
|
18506
|
+
workspace: resolvedWorkspace,
|
|
18507
|
+
title: result.ideId || ideKey
|
|
18508
|
+
});
|
|
18509
|
+
saveConfig(next);
|
|
18510
|
+
} catch {
|
|
18511
|
+
}
|
|
18512
|
+
} else if (result.success && (result.ideId || ideKey)) {
|
|
18513
|
+
try {
|
|
18514
|
+
saveConfig(appendRecentActivity(loadConfig(), {
|
|
18515
|
+
kind: "ide",
|
|
18516
|
+
providerType: result.ideId || ideKey,
|
|
18517
|
+
providerName: result.ideId || ideKey,
|
|
18518
|
+
title: result.ideId || ideKey
|
|
18519
|
+
}));
|
|
18520
|
+
} catch {
|
|
18521
|
+
}
|
|
18522
|
+
}
|
|
18523
|
+
return { success: result.success, ...result };
|
|
18524
|
+
}
|
|
18525
|
+
// ─── Detect IDEs ───
|
|
18526
|
+
case "detect_ides": {
|
|
18527
|
+
const results = await detectIDEs();
|
|
18528
|
+
this.deps.detectedIdes.value = results;
|
|
18529
|
+
return { success: true, detectedInfo: results };
|
|
18530
|
+
}
|
|
18531
|
+
// ─── Set User Name ───
|
|
18532
|
+
case "set_user_name": {
|
|
18533
|
+
const name = args?.userName;
|
|
18534
|
+
if (!name || typeof name !== "string") throw new Error("userName required");
|
|
18535
|
+
updateConfig({ userName: name });
|
|
18536
|
+
return { success: true, userName: name };
|
|
18537
|
+
}
|
|
18538
|
+
case "mark_session_seen": {
|
|
18539
|
+
const sessionId = args?.sessionId;
|
|
18540
|
+
if (!sessionId || typeof sessionId !== "string") {
|
|
18541
|
+
return { success: false, error: "sessionId is required" };
|
|
18542
|
+
}
|
|
18543
|
+
const currentConfig = loadConfig();
|
|
18544
|
+
const prevSeenAt = currentConfig.sessionReads?.[sessionId] || 0;
|
|
18545
|
+
const sessionEntries = buildSessionEntries(
|
|
18546
|
+
this.deps.instanceManager.collectAllStates(),
|
|
18547
|
+
this.deps.cdpManagers
|
|
18548
|
+
);
|
|
18549
|
+
const targetSession = sessionEntries.find((entry) => entry.id === sessionId);
|
|
18550
|
+
const completionMarker = targetSession ? getSessionCompletionMarker(targetSession) : "";
|
|
18551
|
+
const next = markSessionSeen(
|
|
18552
|
+
currentConfig,
|
|
18553
|
+
sessionId,
|
|
18554
|
+
typeof args?.seenAt === "number" ? args.seenAt : Date.now(),
|
|
18555
|
+
completionMarker
|
|
18556
|
+
);
|
|
18557
|
+
if (READ_DEBUG_ENABLED2) {
|
|
18558
|
+
LOG.info("RecentRead", `mark_session_seen sessionId=${sessionId} seenAt=${String(args?.seenAt || "")} prevSeenAt=${String(prevSeenAt)} nextSeenAt=${String(next.sessionReads?.[sessionId] || 0)} marker=${completionMarker || "-"}`);
|
|
18559
|
+
}
|
|
18560
|
+
saveConfig(next);
|
|
18561
|
+
this.deps.onStatusChange?.();
|
|
18562
|
+
return {
|
|
18563
|
+
success: true,
|
|
18564
|
+
sessionId,
|
|
18565
|
+
seenAt: next.sessionReads?.[sessionId] || Date.now(),
|
|
18566
|
+
completionMarker
|
|
18567
|
+
};
|
|
18568
|
+
}
|
|
18569
|
+
// ─── Daemon Self-Upgrade ───
|
|
18570
|
+
case "daemon_upgrade": {
|
|
18571
|
+
LOG.info("Upgrade", "Remote upgrade requested from dashboard");
|
|
18572
|
+
try {
|
|
18573
|
+
const { execSync: execSync7 } = await import("child_process");
|
|
18574
|
+
const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
|
|
18575
|
+
const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
|
|
18576
|
+
const latest = execSync7(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
18577
|
+
LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
|
|
18578
|
+
execSync7(`npm install -g ${pkgName}@latest --force`, {
|
|
18579
|
+
encoding: "utf-8",
|
|
18580
|
+
timeout: 12e4,
|
|
18581
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
18582
|
+
});
|
|
18583
|
+
LOG.info("Upgrade", `\u2705 Upgraded to v${latest}`);
|
|
18584
|
+
setTimeout(() => {
|
|
18585
|
+
LOG.info("Upgrade", "Restarting daemon with new version...");
|
|
18586
|
+
try {
|
|
18587
|
+
const path18 = require("path");
|
|
18588
|
+
const fs16 = require("fs");
|
|
18589
|
+
const pidFile = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
|
|
18590
|
+
if (fs16.existsSync(pidFile)) fs16.unlinkSync(pidFile);
|
|
18591
|
+
} catch {
|
|
18592
|
+
}
|
|
18593
|
+
const { spawn: spawn4 } = require("child_process");
|
|
18594
|
+
const child = spawn4(process.execPath, process.argv.slice(1), {
|
|
18595
|
+
detached: true,
|
|
18596
|
+
stdio: "ignore",
|
|
18597
|
+
env: { ...process.env }
|
|
18598
|
+
});
|
|
18599
|
+
child.unref();
|
|
18600
|
+
process.exit(0);
|
|
18601
|
+
}, 3e3);
|
|
18602
|
+
return { success: true, upgraded: true, version: latest };
|
|
18603
|
+
} catch (e) {
|
|
18604
|
+
LOG.error("Upgrade", `Failed: ${e.message}`);
|
|
18605
|
+
return { success: false, error: e.message };
|
|
18606
|
+
}
|
|
18607
|
+
}
|
|
18608
|
+
// ─── Machine Settings ───
|
|
18609
|
+
case "set_machine_nickname": {
|
|
18610
|
+
const nickname = args?.nickname;
|
|
18611
|
+
updateConfig({ machineNickname: nickname || null });
|
|
18612
|
+
return { success: true };
|
|
18613
|
+
}
|
|
18614
|
+
default:
|
|
18615
|
+
break;
|
|
18616
|
+
}
|
|
18617
|
+
return null;
|
|
18618
|
+
}
|
|
18619
|
+
/**
|
|
18620
|
+
* IDE stop: CDP disconnect + InstanceManager cleanup + optionally kill OS process
|
|
18621
|
+
*/
|
|
18622
|
+
async stopIde(ideType, killProcess = false) {
|
|
18623
|
+
const cdpKeysToRemove = [];
|
|
18624
|
+
for (const key of this.deps.cdpManagers.keys()) {
|
|
18625
|
+
if (key === ideType || key.startsWith(`${ideType}_`)) {
|
|
18626
|
+
cdpKeysToRemove.push(key);
|
|
18627
|
+
}
|
|
18628
|
+
}
|
|
18629
|
+
for (const key of cdpKeysToRemove) {
|
|
18630
|
+
const cdp = this.deps.cdpManagers.get(key);
|
|
18631
|
+
if (cdp) {
|
|
18632
|
+
try {
|
|
18633
|
+
cdp.disconnect();
|
|
18634
|
+
} catch {
|
|
18635
|
+
}
|
|
18636
|
+
this.deps.cdpManagers.delete(key);
|
|
18637
|
+
this.deps.sessionRegistry.unregisterByManagerKey(key);
|
|
18638
|
+
LOG.info("StopIDE", `CDP disconnected: ${key}`);
|
|
18639
|
+
}
|
|
18640
|
+
}
|
|
18641
|
+
const keysToRemove = [];
|
|
18642
|
+
for (const key of this.deps.instanceManager.listInstanceIds()) {
|
|
18643
|
+
if (key === `ide:${ideType}` || typeof key === "string" && key.startsWith(`ide:${ideType}_`)) {
|
|
18644
|
+
keysToRemove.push(key);
|
|
18645
|
+
}
|
|
18646
|
+
}
|
|
18647
|
+
for (const instanceKey of keysToRemove) {
|
|
18648
|
+
const ideInstance = this.deps.instanceManager.getInstance(instanceKey);
|
|
18649
|
+
if (ideInstance) {
|
|
18650
|
+
this.deps.instanceManager.removeInstance(instanceKey);
|
|
18651
|
+
LOG.info("StopIDE", `Instance removed: ${instanceKey}`);
|
|
18652
|
+
}
|
|
18653
|
+
}
|
|
18654
|
+
if (keysToRemove.length === 0) {
|
|
18655
|
+
const instanceKey = `ide:${ideType}`;
|
|
18656
|
+
const ideInstance = this.deps.instanceManager.getInstance(instanceKey);
|
|
18657
|
+
if (ideInstance) {
|
|
18658
|
+
this.deps.instanceManager.removeInstance(instanceKey);
|
|
18659
|
+
LOG.info("StopIDE", `Instance removed: ${instanceKey}`);
|
|
18660
|
+
}
|
|
18661
|
+
}
|
|
18662
|
+
if (killProcess) {
|
|
18663
|
+
const running = isIdeRunning(ideType);
|
|
18664
|
+
if (running) {
|
|
18665
|
+
LOG.info("StopIDE", `Killing IDE process: ${ideType}`);
|
|
18666
|
+
const killed = await killIdeProcess(ideType);
|
|
18667
|
+
if (killed) {
|
|
18668
|
+
LOG.info("StopIDE", `\u2705 Process killed: ${ideType}`);
|
|
18669
|
+
} else {
|
|
18670
|
+
LOG.warn("StopIDE", `\u26A0 Could not kill process: ${ideType} (may need manual intervention)`);
|
|
18671
|
+
}
|
|
18672
|
+
} else {
|
|
18673
|
+
LOG.info("StopIDE", `Process not running: ${ideType}`);
|
|
18674
|
+
}
|
|
18675
|
+
}
|
|
18676
|
+
this.deps.onStatusChange?.();
|
|
18677
|
+
LOG.info("StopIDE", `IDE stopped: ${ideType} (processKill=${killProcess})`);
|
|
18678
|
+
}
|
|
18679
|
+
};
|
|
18849
18680
|
}
|
|
18850
18681
|
});
|
|
18851
18682
|
|
|
@@ -19004,10 +18835,11 @@ var init_reporter = __esm({
|
|
|
19004
18835
|
currentModel: session.currentModel,
|
|
19005
18836
|
currentPlan: session.currentPlan,
|
|
19006
18837
|
currentAutoApprove: session.currentAutoApprove,
|
|
19007
|
-
|
|
18838
|
+
lastUpdated: session.lastUpdated,
|
|
19008
18839
|
unread: session.unread,
|
|
19009
18840
|
lastSeenAt: session.lastSeenAt,
|
|
19010
18841
|
inboxBucket: session.inboxBucket,
|
|
18842
|
+
surfaceHidden: session.surfaceHidden,
|
|
19011
18843
|
controlValues: session.controlValues,
|
|
19012
18844
|
providerControls: session.providerControls,
|
|
19013
18845
|
acpConfigOptions: session.acpConfigOptions,
|
|
@@ -19125,7 +18957,7 @@ function findBinary(name) {
|
|
|
19125
18957
|
}
|
|
19126
18958
|
}
|
|
19127
18959
|
function isScriptBinary(binaryPath) {
|
|
19128
|
-
if (!
|
|
18960
|
+
if (!path9.isAbsolute(binaryPath)) return false;
|
|
19129
18961
|
try {
|
|
19130
18962
|
const fs16 = require("fs");
|
|
19131
18963
|
const resolved = fs16.realpathSync(binaryPath);
|
|
@@ -19141,7 +18973,7 @@ function isScriptBinary(binaryPath) {
|
|
|
19141
18973
|
}
|
|
19142
18974
|
}
|
|
19143
18975
|
function looksLikeMachOOrElf(filePath) {
|
|
19144
|
-
if (!
|
|
18976
|
+
if (!path9.isAbsolute(filePath)) return false;
|
|
19145
18977
|
try {
|
|
19146
18978
|
const fs16 = require("fs");
|
|
19147
18979
|
const resolved = fs16.realpathSync(filePath);
|
|
@@ -19255,12 +19087,12 @@ function normalizeCliProviderForRuntime(raw) {
|
|
|
19255
19087
|
}
|
|
19256
19088
|
};
|
|
19257
19089
|
}
|
|
19258
|
-
var os13,
|
|
19090
|
+
var os13, path9, import_child_process5, pty2, ProviderCliAdapter;
|
|
19259
19091
|
var init_provider_cli_adapter = __esm({
|
|
19260
19092
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
|
|
19261
19093
|
"use strict";
|
|
19262
19094
|
os13 = __toESM(require("os"));
|
|
19263
|
-
|
|
19095
|
+
path9 = __toESM(require("path"));
|
|
19264
19096
|
import_child_process5 = require("child_process");
|
|
19265
19097
|
init_logger();
|
|
19266
19098
|
init_terminal_screen();
|
|
@@ -19270,9 +19102,9 @@ var init_provider_cli_adapter = __esm({
|
|
|
19270
19102
|
if (os13.platform() !== "win32") {
|
|
19271
19103
|
try {
|
|
19272
19104
|
const fs16 = require("fs");
|
|
19273
|
-
const ptyDir =
|
|
19105
|
+
const ptyDir = path9.resolve(path9.dirname(require.resolve("node-pty")), "..");
|
|
19274
19106
|
const platformArch = `${os13.platform()}-${os13.arch()}`;
|
|
19275
|
-
const helper =
|
|
19107
|
+
const helper = path9.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
19276
19108
|
if (fs16.existsSync(helper)) {
|
|
19277
19109
|
const stat4 = fs16.statSync(helper);
|
|
19278
19110
|
if (!(stat4.mode & 73)) {
|
|
@@ -19461,7 +19293,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
19461
19293
|
LOG.info("CLI", `[${this.cliType}] Spawning in ${this.workingDir}`);
|
|
19462
19294
|
let shellCmd;
|
|
19463
19295
|
let shellArgs;
|
|
19464
|
-
const useShellUnix = !isWin && (!!spawnConfig.shell || !
|
|
19296
|
+
const useShellUnix = !isWin && (!!spawnConfig.shell || !path9.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
19465
19297
|
const useShell = isWin ? !!spawnConfig.shell : useShellUnix;
|
|
19466
19298
|
if (useShell) {
|
|
19467
19299
|
if (!spawnConfig.shell && !isWin) {
|
|
@@ -19886,7 +19718,7 @@ ${data.message || ""}`.trim();
|
|
|
19886
19718
|
if (this.startupParseGate) {
|
|
19887
19719
|
const deadline = Date.now() + 1e4;
|
|
19888
19720
|
while (this.startupParseGate && Date.now() < deadline) {
|
|
19889
|
-
await new Promise((
|
|
19721
|
+
await new Promise((resolve12) => setTimeout(resolve12, 50));
|
|
19890
19722
|
}
|
|
19891
19723
|
}
|
|
19892
19724
|
if (!this.ready) throw new Error(`${this.cliName} not ready (status: ${this.currentStatus})`);
|
|
@@ -20054,17 +19886,17 @@ ${data.message || ""}`.trim();
|
|
|
20054
19886
|
}
|
|
20055
19887
|
}
|
|
20056
19888
|
waitForStopped(timeoutMs) {
|
|
20057
|
-
return new Promise((
|
|
19889
|
+
return new Promise((resolve12) => {
|
|
20058
19890
|
const startedAt = Date.now();
|
|
20059
19891
|
const timer = setInterval(() => {
|
|
20060
19892
|
if (!this.ptyProcess || this.currentStatus === "stopped") {
|
|
20061
19893
|
clearInterval(timer);
|
|
20062
|
-
|
|
19894
|
+
resolve12(true);
|
|
20063
19895
|
return;
|
|
20064
19896
|
}
|
|
20065
19897
|
if (Date.now() - startedAt >= timeoutMs) {
|
|
20066
19898
|
clearInterval(timer);
|
|
20067
|
-
|
|
19899
|
+
resolve12(false);
|
|
20068
19900
|
}
|
|
20069
19901
|
}, 100);
|
|
20070
19902
|
});
|
|
@@ -20753,10 +20585,10 @@ function mergeDefs(...defs) {
|
|
|
20753
20585
|
function cloneDef(schema) {
|
|
20754
20586
|
return mergeDefs(schema._zod.def);
|
|
20755
20587
|
}
|
|
20756
|
-
function getElementAtPath(obj,
|
|
20757
|
-
if (!
|
|
20588
|
+
function getElementAtPath(obj, path18) {
|
|
20589
|
+
if (!path18)
|
|
20758
20590
|
return obj;
|
|
20759
|
-
return
|
|
20591
|
+
return path18.reduce((acc, key) => acc?.[key], obj);
|
|
20760
20592
|
}
|
|
20761
20593
|
function promiseAllObject(promisesObj) {
|
|
20762
20594
|
const keys = Object.keys(promisesObj);
|
|
@@ -21068,11 +20900,11 @@ function aborted(x, startIndex = 0) {
|
|
|
21068
20900
|
}
|
|
21069
20901
|
return false;
|
|
21070
20902
|
}
|
|
21071
|
-
function prefixIssues(
|
|
20903
|
+
function prefixIssues(path18, issues) {
|
|
21072
20904
|
return issues.map((iss) => {
|
|
21073
20905
|
var _a2;
|
|
21074
20906
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
21075
|
-
iss.path.unshift(
|
|
20907
|
+
iss.path.unshift(path18);
|
|
21076
20908
|
return iss;
|
|
21077
20909
|
});
|
|
21078
20910
|
}
|
|
@@ -21315,7 +21147,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
21315
21147
|
}
|
|
21316
21148
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
21317
21149
|
const result = { errors: [] };
|
|
21318
|
-
const processError = (error49,
|
|
21150
|
+
const processError = (error49, path18 = []) => {
|
|
21319
21151
|
var _a2, _b;
|
|
21320
21152
|
for (const issue2 of error49.issues) {
|
|
21321
21153
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -21325,7 +21157,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
21325
21157
|
} else if (issue2.code === "invalid_element") {
|
|
21326
21158
|
processError({ issues: issue2.issues }, issue2.path);
|
|
21327
21159
|
} else {
|
|
21328
|
-
const fullpath = [...
|
|
21160
|
+
const fullpath = [...path18, ...issue2.path];
|
|
21329
21161
|
if (fullpath.length === 0) {
|
|
21330
21162
|
result.errors.push(mapper(issue2));
|
|
21331
21163
|
continue;
|
|
@@ -21357,8 +21189,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
21357
21189
|
}
|
|
21358
21190
|
function toDotPath(_path) {
|
|
21359
21191
|
const segs = [];
|
|
21360
|
-
const
|
|
21361
|
-
for (const seg of
|
|
21192
|
+
const path18 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
21193
|
+
for (const seg of path18) {
|
|
21362
21194
|
if (typeof seg === "number")
|
|
21363
21195
|
segs.push(`[${seg}]`);
|
|
21364
21196
|
else if (typeof seg === "symbol")
|
|
@@ -34122,13 +33954,13 @@ function resolveRef(ref, ctx) {
|
|
|
34122
33954
|
if (!ref.startsWith("#")) {
|
|
34123
33955
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
34124
33956
|
}
|
|
34125
|
-
const
|
|
34126
|
-
if (
|
|
33957
|
+
const path18 = ref.slice(1).split("/").filter(Boolean);
|
|
33958
|
+
if (path18.length === 0) {
|
|
34127
33959
|
return ctx.rootSchema;
|
|
34128
33960
|
}
|
|
34129
33961
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
34130
|
-
if (
|
|
34131
|
-
const key =
|
|
33962
|
+
if (path18[0] === defsKey) {
|
|
33963
|
+
const key = path18[1];
|
|
34132
33964
|
if (!key || !ctx.defs[key]) {
|
|
34133
33965
|
throw new Error(`Reference not found: ${ref}`);
|
|
34134
33966
|
}
|
|
@@ -36555,8 +36387,8 @@ var init_acp = __esm({
|
|
|
36555
36387
|
this.#requestHandler = requestHandler;
|
|
36556
36388
|
this.#notificationHandler = notificationHandler;
|
|
36557
36389
|
this.#stream = stream;
|
|
36558
|
-
this.#closedPromise = new Promise((
|
|
36559
|
-
this.#abortController.signal.addEventListener("abort", () =>
|
|
36390
|
+
this.#closedPromise = new Promise((resolve12) => {
|
|
36391
|
+
this.#abortController.signal.addEventListener("abort", () => resolve12());
|
|
36560
36392
|
});
|
|
36561
36393
|
this.#receive();
|
|
36562
36394
|
}
|
|
@@ -36705,8 +36537,8 @@ var init_acp = __esm({
|
|
|
36705
36537
|
}
|
|
36706
36538
|
async sendRequest(method, params) {
|
|
36707
36539
|
const id = this.#nextRequestId++;
|
|
36708
|
-
const responsePromise = new Promise((
|
|
36709
|
-
this.#pendingResponses.set(id, { resolve:
|
|
36540
|
+
const responsePromise = new Promise((resolve12, reject) => {
|
|
36541
|
+
this.#pendingResponses.set(id, { resolve: resolve12, reject });
|
|
36710
36542
|
});
|
|
36711
36543
|
await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
|
|
36712
36544
|
return responsePromise;
|
|
@@ -37246,13 +37078,13 @@ var init_acp_provider_instance = __esm({
|
|
|
37246
37078
|
}
|
|
37247
37079
|
this.currentStatus = "waiting_approval";
|
|
37248
37080
|
this.detectStatusTransition();
|
|
37249
|
-
const approved = await new Promise((
|
|
37250
|
-
this.permissionResolvers.push(
|
|
37081
|
+
const approved = await new Promise((resolve12) => {
|
|
37082
|
+
this.permissionResolvers.push(resolve12);
|
|
37251
37083
|
setTimeout(() => {
|
|
37252
|
-
const idx = this.permissionResolvers.indexOf(
|
|
37084
|
+
const idx = this.permissionResolvers.indexOf(resolve12);
|
|
37253
37085
|
if (idx >= 0) {
|
|
37254
37086
|
this.permissionResolvers.splice(idx, 1);
|
|
37255
|
-
|
|
37087
|
+
resolve12(false);
|
|
37256
37088
|
}
|
|
37257
37089
|
}, 3e5);
|
|
37258
37090
|
});
|
|
@@ -37714,19 +37546,18 @@ function colorize(color, text) {
|
|
|
37714
37546
|
const fn2 = chalkApi?.[color];
|
|
37715
37547
|
return typeof fn2 === "function" ? fn2(text) : text;
|
|
37716
37548
|
}
|
|
37717
|
-
var os14,
|
|
37549
|
+
var os14, path10, crypto4, import_chalk, chalkApi, DaemonCliManager;
|
|
37718
37550
|
var init_cli_manager = __esm({
|
|
37719
37551
|
"../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
|
|
37720
37552
|
"use strict";
|
|
37721
37553
|
os14 = __toESM(require("os"));
|
|
37722
|
-
|
|
37554
|
+
path10 = __toESM(require("path"));
|
|
37723
37555
|
crypto4 = __toESM(require("crypto"));
|
|
37724
37556
|
import_chalk = __toESM(require("chalk"));
|
|
37725
37557
|
init_provider_cli_adapter();
|
|
37726
37558
|
init_cli_detector();
|
|
37727
37559
|
init_config();
|
|
37728
37560
|
init_workspaces();
|
|
37729
|
-
init_workspace_activity();
|
|
37730
37561
|
init_recent_activity();
|
|
37731
37562
|
init_cli_provider_instance();
|
|
37732
37563
|
init_acp_provider_instance();
|
|
@@ -37745,24 +37576,6 @@ var init_cli_manager = __esm({
|
|
|
37745
37576
|
const hash2 = require("crypto").createHash("md5").update(require("path").resolve(dir)).digest("hex").slice(0, 8);
|
|
37746
37577
|
return `${cliType}_${hash2}`;
|
|
37747
37578
|
}
|
|
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
37579
|
persistRecentActivity(entry) {
|
|
37767
37580
|
try {
|
|
37768
37581
|
saveConfig(appendRecentActivity(loadConfig(), entry));
|
|
@@ -37852,7 +37665,7 @@ var init_cli_manager = __esm({
|
|
|
37852
37665
|
async startSession(cliType, workingDir, cliArgs, initialModel) {
|
|
37853
37666
|
const trimmed = (workingDir || "").trim();
|
|
37854
37667
|
if (!trimmed) throw new Error("working directory required");
|
|
37855
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os14.homedir()) :
|
|
37668
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os14.homedir()) : path10.resolve(trimmed);
|
|
37856
37669
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
37857
37670
|
const provider = this.providerLoader.getByAlias(cliType);
|
|
37858
37671
|
const key = crypto4.randomUUID();
|
|
@@ -37923,11 +37736,6 @@ ${installInfo}`
|
|
|
37923
37736
|
LOG.warn("CLI", `[ACP] Initial model set failed: ${e?.message}`);
|
|
37924
37737
|
}
|
|
37925
37738
|
}
|
|
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
37739
|
this.persistRecentActivity({
|
|
37932
37740
|
kind: "acp",
|
|
37933
37741
|
providerType: normalizedType,
|
|
@@ -37994,11 +37802,6 @@ ${installInfo}`
|
|
|
37994
37802
|
this.adapters.set(key, adapter);
|
|
37995
37803
|
console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
|
|
37996
37804
|
}
|
|
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
37805
|
this.persistRecentActivity({
|
|
38003
37806
|
kind: "cli",
|
|
38004
37807
|
providerType: normalizedType,
|
|
@@ -38151,7 +37954,6 @@ ${installInfo}`
|
|
|
38151
37954
|
newKey = k;
|
|
38152
37955
|
}
|
|
38153
37956
|
}
|
|
38154
|
-
this.persistRecentDir(cliType, dir);
|
|
38155
37957
|
return { success: true, cliType, dir, id: newKey, launchSource };
|
|
38156
37958
|
}
|
|
38157
37959
|
case "stop_cli": {
|
|
@@ -38194,7 +37996,6 @@ ${installInfo}`
|
|
|
38194
37996
|
const found = this.findAdapter(cliType, { instanceKey: args?.targetSessionId, dir });
|
|
38195
37997
|
if (found) await this.stopSession(found.key);
|
|
38196
37998
|
await this.startSession(cliType, dir);
|
|
38197
|
-
this.persistRecentDir(cliType, dir);
|
|
38198
37999
|
return { success: true, restarted: true };
|
|
38199
38000
|
}
|
|
38200
38001
|
case "agent_command": {
|
|
@@ -39108,7 +38909,7 @@ function checkPathExists2(paths) {
|
|
|
39108
38909
|
for (const p of paths) {
|
|
39109
38910
|
if (p.includes("*")) {
|
|
39110
38911
|
const home = os15.homedir();
|
|
39111
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
38912
|
+
const resolved = p.replace(/\*/g, home.split(path11.sep).pop() || "");
|
|
39112
38913
|
if (fs9.existsSync(resolved)) return resolved;
|
|
39113
38914
|
} else {
|
|
39114
38915
|
if (fs9.existsSync(p)) return p;
|
|
@@ -39118,7 +38919,7 @@ function checkPathExists2(paths) {
|
|
|
39118
38919
|
}
|
|
39119
38920
|
function getMacAppVersion(appPath) {
|
|
39120
38921
|
if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
39121
|
-
const plistPath =
|
|
38922
|
+
const plistPath = path11.join(appPath, "Contents", "Info.plist");
|
|
39122
38923
|
if (!fs9.existsSync(plistPath)) return null;
|
|
39123
38924
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
39124
38925
|
return raw || null;
|
|
@@ -39145,7 +38946,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
39145
38946
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
39146
38947
|
let resolvedBin = cliBin;
|
|
39147
38948
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
39148
|
-
const bundled =
|
|
38949
|
+
const bundled = path11.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
39149
38950
|
if (provider.cli && fs9.existsSync(bundled)) resolvedBin = bundled;
|
|
39150
38951
|
}
|
|
39151
38952
|
info.installed = !!(appPath || resolvedBin);
|
|
@@ -39182,16 +38983,16 @@ async function detectAllVersions(loader, archive) {
|
|
|
39182
38983
|
}
|
|
39183
38984
|
return results;
|
|
39184
38985
|
}
|
|
39185
|
-
var fs9,
|
|
38986
|
+
var fs9, path11, os15, import_child_process7, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
|
|
39186
38987
|
var init_version_archive = __esm({
|
|
39187
38988
|
"../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
|
|
39188
38989
|
"use strict";
|
|
39189
38990
|
fs9 = __toESM(require("fs"));
|
|
39190
|
-
|
|
38991
|
+
path11 = __toESM(require("path"));
|
|
39191
38992
|
os15 = __toESM(require("os"));
|
|
39192
38993
|
import_child_process7 = require("child_process");
|
|
39193
38994
|
import_os3 = require("os");
|
|
39194
|
-
ARCHIVE_PATH =
|
|
38995
|
+
ARCHIVE_PATH = path11.join(os15.homedir(), ".adhdev", "version-history.json");
|
|
39195
38996
|
MAX_ENTRIES_PER_PROVIDER = 20;
|
|
39196
38997
|
VersionArchive = class {
|
|
39197
38998
|
history = {};
|
|
@@ -39238,7 +39039,7 @@ var init_version_archive = __esm({
|
|
|
39238
39039
|
}
|
|
39239
39040
|
save() {
|
|
39240
39041
|
try {
|
|
39241
|
-
fs9.mkdirSync(
|
|
39042
|
+
fs9.mkdirSync(path11.dirname(ARCHIVE_PATH), { recursive: true });
|
|
39242
39043
|
fs9.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
39243
39044
|
} catch {
|
|
39244
39045
|
}
|
|
@@ -39759,17 +39560,17 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
39759
39560
|
return;
|
|
39760
39561
|
}
|
|
39761
39562
|
let scriptsPath = "";
|
|
39762
|
-
const directScripts =
|
|
39563
|
+
const directScripts = path12.join(dir, "scripts.js");
|
|
39763
39564
|
if (fs10.existsSync(directScripts)) {
|
|
39764
39565
|
scriptsPath = directScripts;
|
|
39765
39566
|
} else {
|
|
39766
|
-
const scriptsDir =
|
|
39567
|
+
const scriptsDir = path12.join(dir, "scripts");
|
|
39767
39568
|
if (fs10.existsSync(scriptsDir)) {
|
|
39768
39569
|
const versions = fs10.readdirSync(scriptsDir).filter((d) => {
|
|
39769
|
-
return fs10.statSync(
|
|
39570
|
+
return fs10.statSync(path12.join(scriptsDir, d)).isDirectory();
|
|
39770
39571
|
}).sort().reverse();
|
|
39771
39572
|
for (const ver of versions) {
|
|
39772
|
-
const p =
|
|
39573
|
+
const p = path12.join(scriptsDir, ver, "scripts.js");
|
|
39773
39574
|
if (fs10.existsSync(p)) {
|
|
39774
39575
|
scriptsPath = p;
|
|
39775
39576
|
break;
|
|
@@ -40585,12 +40386,12 @@ async function handleDomContext(ctx, type, req, res) {
|
|
|
40585
40386
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
40586
40387
|
}
|
|
40587
40388
|
}
|
|
40588
|
-
var fs10,
|
|
40389
|
+
var fs10, path12;
|
|
40589
40390
|
var init_dev_cdp_handlers = __esm({
|
|
40590
40391
|
"../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
|
|
40591
40392
|
"use strict";
|
|
40592
40393
|
fs10 = __toESM(require("fs"));
|
|
40593
|
-
|
|
40394
|
+
path12 = __toESM(require("path"));
|
|
40594
40395
|
init_logger();
|
|
40595
40396
|
}
|
|
40596
40397
|
});
|
|
@@ -40855,22 +40656,22 @@ function getLatestScriptVersionDir(scriptsDir) {
|
|
|
40855
40656
|
if (!fs11.existsSync(scriptsDir)) return null;
|
|
40856
40657
|
const versions = fs11.readdirSync(scriptsDir).filter((d) => {
|
|
40857
40658
|
try {
|
|
40858
|
-
return fs11.statSync(
|
|
40659
|
+
return fs11.statSync(path13.join(scriptsDir, d)).isDirectory();
|
|
40859
40660
|
} catch {
|
|
40860
40661
|
return false;
|
|
40861
40662
|
}
|
|
40862
40663
|
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
40863
40664
|
if (versions.length === 0) return null;
|
|
40864
|
-
return
|
|
40665
|
+
return path13.join(scriptsDir, versions[0]);
|
|
40865
40666
|
}
|
|
40866
40667
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
40867
|
-
const canonicalUserDir =
|
|
40868
|
-
const desiredDir = requestedDir ?
|
|
40869
|
-
const upstreamRoot =
|
|
40870
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
40668
|
+
const canonicalUserDir = path13.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
40669
|
+
const desiredDir = requestedDir ? path13.resolve(requestedDir) : canonicalUserDir;
|
|
40670
|
+
const upstreamRoot = path13.resolve(ctx.providerLoader.getUpstreamDir());
|
|
40671
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path13.sep}`)) {
|
|
40871
40672
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
40872
40673
|
}
|
|
40873
|
-
if (
|
|
40674
|
+
if (path13.basename(desiredDir) !== type) {
|
|
40874
40675
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
40875
40676
|
}
|
|
40876
40677
|
const sourceDir = ctx.findProviderDir(type);
|
|
@@ -40878,11 +40679,11 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
40878
40679
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
40879
40680
|
}
|
|
40880
40681
|
if (!fs11.existsSync(desiredDir)) {
|
|
40881
|
-
fs11.mkdirSync(
|
|
40682
|
+
fs11.mkdirSync(path13.dirname(desiredDir), { recursive: true });
|
|
40882
40683
|
fs11.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
40883
40684
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
40884
40685
|
}
|
|
40885
|
-
const providerJson =
|
|
40686
|
+
const providerJson = path13.join(desiredDir, "provider.json");
|
|
40886
40687
|
if (!fs11.existsSync(providerJson)) {
|
|
40887
40688
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
40888
40689
|
}
|
|
@@ -40905,13 +40706,13 @@ function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
|
40905
40706
|
const refDir = ctx.findProviderDir(referenceType);
|
|
40906
40707
|
if (!refDir || !fs11.existsSync(refDir)) return {};
|
|
40907
40708
|
const referenceScripts = {};
|
|
40908
|
-
const scriptsDir =
|
|
40709
|
+
const scriptsDir = path13.join(refDir, "scripts");
|
|
40909
40710
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
40910
40711
|
if (!latestDir) return referenceScripts;
|
|
40911
40712
|
for (const file2 of fs11.readdirSync(latestDir)) {
|
|
40912
40713
|
if (!file2.endsWith(".js")) continue;
|
|
40913
40714
|
try {
|
|
40914
|
-
referenceScripts[file2] = fs11.readFileSync(
|
|
40715
|
+
referenceScripts[file2] = fs11.readFileSync(path13.join(latestDir, file2), "utf-8");
|
|
40915
40716
|
} catch {
|
|
40916
40717
|
}
|
|
40917
40718
|
}
|
|
@@ -40962,9 +40763,9 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
40962
40763
|
});
|
|
40963
40764
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
40964
40765
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference);
|
|
40965
|
-
const tmpDir =
|
|
40766
|
+
const tmpDir = path13.join(os16.tmpdir(), "adhdev-autoimpl");
|
|
40966
40767
|
if (!fs11.existsSync(tmpDir)) fs11.mkdirSync(tmpDir, { recursive: true });
|
|
40967
|
-
const promptFile =
|
|
40768
|
+
const promptFile = path13.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
40968
40769
|
fs11.writeFileSync(promptFile, prompt, "utf-8");
|
|
40969
40770
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
40970
40771
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
@@ -41335,7 +41136,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41335
41136
|
setMode: "set_mode.js"
|
|
41336
41137
|
};
|
|
41337
41138
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
41338
|
-
const scriptsDir =
|
|
41139
|
+
const scriptsDir = path13.join(providerDir, "scripts");
|
|
41339
41140
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
41340
41141
|
if (latestScriptsDir) {
|
|
41341
41142
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -41346,7 +41147,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41346
41147
|
for (const file2 of fs11.readdirSync(latestScriptsDir)) {
|
|
41347
41148
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
41348
41149
|
try {
|
|
41349
|
-
const content = fs11.readFileSync(
|
|
41150
|
+
const content = fs11.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
|
|
41350
41151
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
41351
41152
|
lines.push("```javascript");
|
|
41352
41153
|
lines.push(content);
|
|
@@ -41363,7 +41164,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41363
41164
|
lines.push("");
|
|
41364
41165
|
for (const file2 of refFiles) {
|
|
41365
41166
|
try {
|
|
41366
|
-
const content = fs11.readFileSync(
|
|
41167
|
+
const content = fs11.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
|
|
41367
41168
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
41368
41169
|
lines.push("```javascript");
|
|
41369
41170
|
lines.push(content);
|
|
@@ -41404,10 +41205,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41404
41205
|
lines.push("");
|
|
41405
41206
|
}
|
|
41406
41207
|
}
|
|
41407
|
-
const docsDir =
|
|
41208
|
+
const docsDir = path13.join(providerDir, "../../docs");
|
|
41408
41209
|
const loadGuide = (name) => {
|
|
41409
41210
|
try {
|
|
41410
|
-
const p =
|
|
41211
|
+
const p = path13.join(docsDir, name);
|
|
41411
41212
|
if (fs11.existsSync(p)) return fs11.readFileSync(p, "utf-8");
|
|
41412
41213
|
} catch {
|
|
41413
41214
|
}
|
|
@@ -41581,7 +41382,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41581
41382
|
parseApproval: "parse_approval.js"
|
|
41582
41383
|
};
|
|
41583
41384
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
41584
|
-
const scriptsDir =
|
|
41385
|
+
const scriptsDir = path13.join(providerDir, "scripts");
|
|
41585
41386
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
41586
41387
|
if (latestScriptsDir) {
|
|
41587
41388
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -41593,7 +41394,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41593
41394
|
if (!file2.endsWith(".js")) continue;
|
|
41594
41395
|
if (!targetFileNames.has(file2)) continue;
|
|
41595
41396
|
try {
|
|
41596
|
-
const content = fs11.readFileSync(
|
|
41397
|
+
const content = fs11.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
|
|
41597
41398
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
41598
41399
|
lines.push("```javascript");
|
|
41599
41400
|
lines.push(content);
|
|
@@ -41609,7 +41410,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41609
41410
|
lines.push("");
|
|
41610
41411
|
for (const file2 of refFiles) {
|
|
41611
41412
|
try {
|
|
41612
|
-
const content = fs11.readFileSync(
|
|
41413
|
+
const content = fs11.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
|
|
41613
41414
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
41614
41415
|
lines.push("```javascript");
|
|
41615
41416
|
lines.push(content);
|
|
@@ -41642,10 +41443,10 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41642
41443
|
lines.push("");
|
|
41643
41444
|
}
|
|
41644
41445
|
}
|
|
41645
|
-
const docsDir =
|
|
41446
|
+
const docsDir = path13.join(providerDir, "../../docs");
|
|
41646
41447
|
const loadGuide = (name) => {
|
|
41647
41448
|
try {
|
|
41648
|
-
const p =
|
|
41449
|
+
const p = path13.join(docsDir, name);
|
|
41649
41450
|
if (fs11.existsSync(p)) return fs11.readFileSync(p, "utf-8");
|
|
41650
41451
|
} catch {
|
|
41651
41452
|
}
|
|
@@ -41809,25 +41610,25 @@ data: ${JSON.stringify(msg.data)}
|
|
|
41809
41610
|
}
|
|
41810
41611
|
}
|
|
41811
41612
|
}
|
|
41812
|
-
var fs11,
|
|
41613
|
+
var fs11, path13, os16;
|
|
41813
41614
|
var init_dev_auto_implement = __esm({
|
|
41814
41615
|
"../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
|
|
41815
41616
|
"use strict";
|
|
41816
41617
|
fs11 = __toESM(require("fs"));
|
|
41817
|
-
|
|
41618
|
+
path13 = __toESM(require("path"));
|
|
41818
41619
|
os16 = __toESM(require("os"));
|
|
41819
41620
|
init_dev_server();
|
|
41820
41621
|
}
|
|
41821
41622
|
});
|
|
41822
41623
|
|
|
41823
41624
|
// ../../oss/packages/daemon-core/src/daemon/dev-server.ts
|
|
41824
|
-
var http2, fs12,
|
|
41625
|
+
var http2, fs12, path14, DEV_SERVER_PORT, DevServer;
|
|
41825
41626
|
var init_dev_server = __esm({
|
|
41826
41627
|
"../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
|
|
41827
41628
|
"use strict";
|
|
41828
41629
|
http2 = __toESM(require("http"));
|
|
41829
41630
|
fs12 = __toESM(require("fs"));
|
|
41830
|
-
|
|
41631
|
+
path14 = __toESM(require("path"));
|
|
41831
41632
|
init_scaffold_template();
|
|
41832
41633
|
init_version_archive();
|
|
41833
41634
|
init_logger();
|
|
@@ -41926,8 +41727,8 @@ var init_dev_server = __esm({
|
|
|
41926
41727
|
}
|
|
41927
41728
|
getEndpointList() {
|
|
41928
41729
|
return this.routes.map((r) => {
|
|
41929
|
-
const
|
|
41930
|
-
return `${r.method.padEnd(5)} ${
|
|
41730
|
+
const path18 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
41731
|
+
return `${r.method.padEnd(5)} ${path18}`;
|
|
41931
41732
|
});
|
|
41932
41733
|
}
|
|
41933
41734
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -41958,15 +41759,15 @@ var init_dev_server = __esm({
|
|
|
41958
41759
|
this.json(res, 500, { error: e.message });
|
|
41959
41760
|
}
|
|
41960
41761
|
});
|
|
41961
|
-
return new Promise((
|
|
41762
|
+
return new Promise((resolve12, reject) => {
|
|
41962
41763
|
this.server.listen(port, "127.0.0.1", () => {
|
|
41963
41764
|
this.log(`Dev server listening on http://127.0.0.1:${port}`);
|
|
41964
|
-
|
|
41765
|
+
resolve12();
|
|
41965
41766
|
});
|
|
41966
41767
|
this.server.on("error", (e) => {
|
|
41967
41768
|
if (e.code === "EADDRINUSE") {
|
|
41968
41769
|
this.log(`Port ${port} in use, skipping dev server`);
|
|
41969
|
-
|
|
41770
|
+
resolve12();
|
|
41970
41771
|
} else {
|
|
41971
41772
|
reject(e);
|
|
41972
41773
|
}
|
|
@@ -42049,20 +41850,20 @@ var init_dev_server = __esm({
|
|
|
42049
41850
|
child.stderr?.on("data", (d) => {
|
|
42050
41851
|
stderr += d.toString().slice(0, 2e3);
|
|
42051
41852
|
});
|
|
42052
|
-
await new Promise((
|
|
41853
|
+
await new Promise((resolve12) => {
|
|
42053
41854
|
const timer = setTimeout(() => {
|
|
42054
41855
|
child.kill();
|
|
42055
|
-
|
|
41856
|
+
resolve12();
|
|
42056
41857
|
}, 3e3);
|
|
42057
41858
|
child.on("exit", () => {
|
|
42058
41859
|
clearTimeout(timer);
|
|
42059
|
-
|
|
41860
|
+
resolve12();
|
|
42060
41861
|
});
|
|
42061
41862
|
child.stdout?.once("data", () => {
|
|
42062
41863
|
setTimeout(() => {
|
|
42063
41864
|
child.kill();
|
|
42064
41865
|
clearTimeout(timer);
|
|
42065
|
-
|
|
41866
|
+
resolve12();
|
|
42066
41867
|
}, 500);
|
|
42067
41868
|
});
|
|
42068
41869
|
});
|
|
@@ -42209,12 +42010,12 @@ var init_dev_server = __esm({
|
|
|
42209
42010
|
// ─── DevConsole SPA ───
|
|
42210
42011
|
getConsoleDistDir() {
|
|
42211
42012
|
const candidates = [
|
|
42212
|
-
|
|
42213
|
-
|
|
42214
|
-
|
|
42013
|
+
path14.resolve(__dirname, "../../web-devconsole/dist"),
|
|
42014
|
+
path14.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
42015
|
+
path14.join(process.cwd(), "packages/web-devconsole/dist")
|
|
42215
42016
|
];
|
|
42216
42017
|
for (const dir of candidates) {
|
|
42217
|
-
if (fs12.existsSync(
|
|
42018
|
+
if (fs12.existsSync(path14.join(dir, "index.html"))) return dir;
|
|
42218
42019
|
}
|
|
42219
42020
|
return null;
|
|
42220
42021
|
}
|
|
@@ -42224,7 +42025,7 @@ var init_dev_server = __esm({
|
|
|
42224
42025
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
42225
42026
|
return;
|
|
42226
42027
|
}
|
|
42227
|
-
const htmlPath =
|
|
42028
|
+
const htmlPath = path14.join(distDir, "index.html");
|
|
42228
42029
|
try {
|
|
42229
42030
|
const html = fs12.readFileSync(htmlPath, "utf-8");
|
|
42230
42031
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
@@ -42249,15 +42050,15 @@ var init_dev_server = __esm({
|
|
|
42249
42050
|
this.json(res, 404, { error: "Not found" });
|
|
42250
42051
|
return;
|
|
42251
42052
|
}
|
|
42252
|
-
const safePath =
|
|
42253
|
-
const filePath =
|
|
42053
|
+
const safePath = path14.normalize(pathname).replace(/^\.\.\//, "");
|
|
42054
|
+
const filePath = path14.join(distDir, safePath);
|
|
42254
42055
|
if (!filePath.startsWith(distDir)) {
|
|
42255
42056
|
this.json(res, 403, { error: "Forbidden" });
|
|
42256
42057
|
return;
|
|
42257
42058
|
}
|
|
42258
42059
|
try {
|
|
42259
42060
|
const content = fs12.readFileSync(filePath);
|
|
42260
|
-
const ext =
|
|
42061
|
+
const ext = path14.extname(filePath);
|
|
42261
42062
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
42262
42063
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
42263
42064
|
res.end(content);
|
|
@@ -42370,9 +42171,9 @@ var init_dev_server = __esm({
|
|
|
42370
42171
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
42371
42172
|
if (entry.isDirectory()) {
|
|
42372
42173
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
42373
|
-
scan(
|
|
42174
|
+
scan(path14.join(d, entry.name), rel);
|
|
42374
42175
|
} else {
|
|
42375
|
-
const stat4 = fs12.statSync(
|
|
42176
|
+
const stat4 = fs12.statSync(path14.join(d, entry.name));
|
|
42376
42177
|
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
42377
42178
|
}
|
|
42378
42179
|
}
|
|
@@ -42395,7 +42196,7 @@ var init_dev_server = __esm({
|
|
|
42395
42196
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
42396
42197
|
return;
|
|
42397
42198
|
}
|
|
42398
|
-
const fullPath =
|
|
42199
|
+
const fullPath = path14.resolve(dir, path14.normalize(filePath));
|
|
42399
42200
|
if (!fullPath.startsWith(dir)) {
|
|
42400
42201
|
this.json(res, 403, { error: "Forbidden" });
|
|
42401
42202
|
return;
|
|
@@ -42420,14 +42221,14 @@ var init_dev_server = __esm({
|
|
|
42420
42221
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
42421
42222
|
return;
|
|
42422
42223
|
}
|
|
42423
|
-
const fullPath =
|
|
42224
|
+
const fullPath = path14.resolve(dir, path14.normalize(filePath));
|
|
42424
42225
|
if (!fullPath.startsWith(dir)) {
|
|
42425
42226
|
this.json(res, 403, { error: "Forbidden" });
|
|
42426
42227
|
return;
|
|
42427
42228
|
}
|
|
42428
42229
|
try {
|
|
42429
42230
|
if (fs12.existsSync(fullPath)) fs12.copyFileSync(fullPath, fullPath + ".bak");
|
|
42430
|
-
fs12.mkdirSync(
|
|
42231
|
+
fs12.mkdirSync(path14.dirname(fullPath), { recursive: true });
|
|
42431
42232
|
fs12.writeFileSync(fullPath, content, "utf-8");
|
|
42432
42233
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
42433
42234
|
this.providerLoader.reload();
|
|
@@ -42444,7 +42245,7 @@ var init_dev_server = __esm({
|
|
|
42444
42245
|
return;
|
|
42445
42246
|
}
|
|
42446
42247
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
42447
|
-
const p =
|
|
42248
|
+
const p = path14.join(dir, name);
|
|
42448
42249
|
if (fs12.existsSync(p)) {
|
|
42449
42250
|
const source = fs12.readFileSync(p, "utf-8");
|
|
42450
42251
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
@@ -42465,8 +42266,8 @@ var init_dev_server = __esm({
|
|
|
42465
42266
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
42466
42267
|
return;
|
|
42467
42268
|
}
|
|
42468
|
-
const target = fs12.existsSync(
|
|
42469
|
-
const targetPath =
|
|
42269
|
+
const target = fs12.existsSync(path14.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
42270
|
+
const targetPath = path14.join(dir, target);
|
|
42470
42271
|
try {
|
|
42471
42272
|
if (fs12.existsSync(targetPath)) fs12.copyFileSync(targetPath, targetPath + ".bak");
|
|
42472
42273
|
fs12.writeFileSync(targetPath, source, "utf-8");
|
|
@@ -42571,14 +42372,14 @@ var init_dev_server = __esm({
|
|
|
42571
42372
|
child.stderr?.on("data", (d) => {
|
|
42572
42373
|
stderr += d.toString();
|
|
42573
42374
|
});
|
|
42574
|
-
await new Promise((
|
|
42375
|
+
await new Promise((resolve12) => {
|
|
42575
42376
|
const timer = setTimeout(() => {
|
|
42576
42377
|
child.kill();
|
|
42577
|
-
|
|
42378
|
+
resolve12();
|
|
42578
42379
|
}, timeout);
|
|
42579
42380
|
child.on("exit", () => {
|
|
42580
42381
|
clearTimeout(timer);
|
|
42581
|
-
|
|
42382
|
+
resolve12();
|
|
42582
42383
|
});
|
|
42583
42384
|
});
|
|
42584
42385
|
const elapsed = Date.now() - start;
|
|
@@ -42626,7 +42427,7 @@ var init_dev_server = __esm({
|
|
|
42626
42427
|
}
|
|
42627
42428
|
let targetDir;
|
|
42628
42429
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
42629
|
-
const jsonPath =
|
|
42430
|
+
const jsonPath = path14.join(targetDir, "provider.json");
|
|
42630
42431
|
if (fs12.existsSync(jsonPath)) {
|
|
42631
42432
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
42632
42433
|
return;
|
|
@@ -42638,8 +42439,8 @@ var init_dev_server = __esm({
|
|
|
42638
42439
|
const createdFiles = ["provider.json"];
|
|
42639
42440
|
if (result.files) {
|
|
42640
42441
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
42641
|
-
const fullPath =
|
|
42642
|
-
fs12.mkdirSync(
|
|
42442
|
+
const fullPath = path14.join(targetDir, relPath);
|
|
42443
|
+
fs12.mkdirSync(path14.dirname(fullPath), { recursive: true });
|
|
42643
42444
|
fs12.writeFileSync(fullPath, content, "utf-8");
|
|
42644
42445
|
createdFiles.push(relPath);
|
|
42645
42446
|
}
|
|
@@ -42692,22 +42493,22 @@ var init_dev_server = __esm({
|
|
|
42692
42493
|
if (!fs12.existsSync(scriptsDir)) return null;
|
|
42693
42494
|
const versions = fs12.readdirSync(scriptsDir).filter((d) => {
|
|
42694
42495
|
try {
|
|
42695
|
-
return fs12.statSync(
|
|
42496
|
+
return fs12.statSync(path14.join(scriptsDir, d)).isDirectory();
|
|
42696
42497
|
} catch {
|
|
42697
42498
|
return false;
|
|
42698
42499
|
}
|
|
42699
42500
|
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
42700
42501
|
if (versions.length === 0) return null;
|
|
42701
|
-
return
|
|
42502
|
+
return path14.join(scriptsDir, versions[0]);
|
|
42702
42503
|
}
|
|
42703
42504
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
42704
|
-
const canonicalUserDir =
|
|
42705
|
-
const desiredDir = requestedDir ?
|
|
42706
|
-
const upstreamRoot =
|
|
42707
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
42505
|
+
const canonicalUserDir = path14.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
42506
|
+
const desiredDir = requestedDir ? path14.resolve(requestedDir) : canonicalUserDir;
|
|
42507
|
+
const upstreamRoot = path14.resolve(this.providerLoader.getUpstreamDir());
|
|
42508
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path14.sep}`)) {
|
|
42708
42509
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
42709
42510
|
}
|
|
42710
|
-
if (
|
|
42511
|
+
if (path14.basename(desiredDir) !== type) {
|
|
42711
42512
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
42712
42513
|
}
|
|
42713
42514
|
const sourceDir = this.findProviderDir(type);
|
|
@@ -42715,11 +42516,11 @@ var init_dev_server = __esm({
|
|
|
42715
42516
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
42716
42517
|
}
|
|
42717
42518
|
if (!fs12.existsSync(desiredDir)) {
|
|
42718
|
-
fs12.mkdirSync(
|
|
42519
|
+
fs12.mkdirSync(path14.dirname(desiredDir), { recursive: true });
|
|
42719
42520
|
fs12.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
42720
42521
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
42721
42522
|
}
|
|
42722
|
-
const providerJson =
|
|
42523
|
+
const providerJson = path14.join(desiredDir, "provider.json");
|
|
42723
42524
|
if (!fs12.existsSync(providerJson)) {
|
|
42724
42525
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
42725
42526
|
}
|
|
@@ -42767,7 +42568,7 @@ var init_dev_server = __esm({
|
|
|
42767
42568
|
setMode: "set_mode.js"
|
|
42768
42569
|
};
|
|
42769
42570
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
42770
|
-
const scriptsDir =
|
|
42571
|
+
const scriptsDir = path14.join(providerDir, "scripts");
|
|
42771
42572
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
42772
42573
|
if (latestScriptsDir) {
|
|
42773
42574
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -42778,7 +42579,7 @@ var init_dev_server = __esm({
|
|
|
42778
42579
|
for (const file2 of fs12.readdirSync(latestScriptsDir)) {
|
|
42779
42580
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
42780
42581
|
try {
|
|
42781
|
-
const content = fs12.readFileSync(
|
|
42582
|
+
const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
42782
42583
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
42783
42584
|
lines.push("```javascript");
|
|
42784
42585
|
lines.push(content);
|
|
@@ -42795,7 +42596,7 @@ var init_dev_server = __esm({
|
|
|
42795
42596
|
lines.push("");
|
|
42796
42597
|
for (const file2 of refFiles) {
|
|
42797
42598
|
try {
|
|
42798
|
-
const content = fs12.readFileSync(
|
|
42599
|
+
const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
42799
42600
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
42800
42601
|
lines.push("```javascript");
|
|
42801
42602
|
lines.push(content);
|
|
@@ -42836,10 +42637,10 @@ var init_dev_server = __esm({
|
|
|
42836
42637
|
lines.push("");
|
|
42837
42638
|
}
|
|
42838
42639
|
}
|
|
42839
|
-
const docsDir =
|
|
42640
|
+
const docsDir = path14.join(providerDir, "../../docs");
|
|
42840
42641
|
const loadGuide = (name) => {
|
|
42841
42642
|
try {
|
|
42842
|
-
const p =
|
|
42643
|
+
const p = path14.join(docsDir, name);
|
|
42843
42644
|
if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
|
|
42844
42645
|
} catch {
|
|
42845
42646
|
}
|
|
@@ -43013,7 +42814,7 @@ var init_dev_server = __esm({
|
|
|
43013
42814
|
parseApproval: "parse_approval.js"
|
|
43014
42815
|
};
|
|
43015
42816
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
43016
|
-
const scriptsDir =
|
|
42817
|
+
const scriptsDir = path14.join(providerDir, "scripts");
|
|
43017
42818
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
43018
42819
|
if (latestScriptsDir) {
|
|
43019
42820
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -43025,7 +42826,7 @@ var init_dev_server = __esm({
|
|
|
43025
42826
|
if (!file2.endsWith(".js")) continue;
|
|
43026
42827
|
if (!targetFileNames.has(file2)) continue;
|
|
43027
42828
|
try {
|
|
43028
|
-
const content = fs12.readFileSync(
|
|
42829
|
+
const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
43029
42830
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
43030
42831
|
lines.push("```javascript");
|
|
43031
42832
|
lines.push(content);
|
|
@@ -43041,7 +42842,7 @@ var init_dev_server = __esm({
|
|
|
43041
42842
|
lines.push("");
|
|
43042
42843
|
for (const file2 of refFiles) {
|
|
43043
42844
|
try {
|
|
43044
|
-
const content = fs12.readFileSync(
|
|
42845
|
+
const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
43045
42846
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
43046
42847
|
lines.push("```javascript");
|
|
43047
42848
|
lines.push(content);
|
|
@@ -43074,10 +42875,10 @@ var init_dev_server = __esm({
|
|
|
43074
42875
|
lines.push("");
|
|
43075
42876
|
}
|
|
43076
42877
|
}
|
|
43077
|
-
const docsDir =
|
|
42878
|
+
const docsDir = path14.join(providerDir, "../../docs");
|
|
43078
42879
|
const loadGuide = (name) => {
|
|
43079
42880
|
try {
|
|
43080
|
-
const p =
|
|
42881
|
+
const p = path14.join(docsDir, name);
|
|
43081
42882
|
if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
|
|
43082
42883
|
} catch {
|
|
43083
42884
|
}
|
|
@@ -43234,14 +43035,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
43234
43035
|
res.end(JSON.stringify(data, null, 2));
|
|
43235
43036
|
}
|
|
43236
43037
|
async readBody(req) {
|
|
43237
|
-
return new Promise((
|
|
43038
|
+
return new Promise((resolve12) => {
|
|
43238
43039
|
let body = "";
|
|
43239
43040
|
req.on("data", (chunk) => body += chunk);
|
|
43240
43041
|
req.on("end", () => {
|
|
43241
43042
|
try {
|
|
43242
|
-
|
|
43043
|
+
resolve12(JSON.parse(body));
|
|
43243
43044
|
} catch {
|
|
43244
|
-
|
|
43045
|
+
resolve12({});
|
|
43245
43046
|
}
|
|
43246
43047
|
});
|
|
43247
43048
|
});
|
|
@@ -43365,8 +43166,8 @@ var init_dist = __esm({
|
|
|
43365
43166
|
}
|
|
43366
43167
|
this.requestWaiters.clear();
|
|
43367
43168
|
});
|
|
43368
|
-
await new Promise((
|
|
43369
|
-
socket.once("connect", () =>
|
|
43169
|
+
await new Promise((resolve12, reject) => {
|
|
43170
|
+
socket.once("connect", () => resolve12());
|
|
43370
43171
|
socket.once("error", reject);
|
|
43371
43172
|
});
|
|
43372
43173
|
}
|
|
@@ -43385,7 +43186,7 @@ var init_dist = __esm({
|
|
|
43385
43186
|
requestId,
|
|
43386
43187
|
request
|
|
43387
43188
|
};
|
|
43388
|
-
const response = await new Promise((
|
|
43189
|
+
const response = await new Promise((resolve12, reject) => {
|
|
43389
43190
|
const timeout = setTimeout(() => {
|
|
43390
43191
|
this.requestWaiters.delete(requestId);
|
|
43391
43192
|
reject(new Error(`Session host request timed out after 30s (${request.type})`));
|
|
@@ -43393,7 +43194,7 @@ var init_dist = __esm({
|
|
|
43393
43194
|
this.requestWaiters.set(requestId, {
|
|
43394
43195
|
resolve: (value) => {
|
|
43395
43196
|
clearTimeout(timeout);
|
|
43396
|
-
|
|
43197
|
+
resolve12(value);
|
|
43397
43198
|
},
|
|
43398
43199
|
reject: (error48) => {
|
|
43399
43200
|
clearTimeout(timeout);
|
|
@@ -43412,12 +43213,12 @@ var init_dist = __esm({
|
|
|
43412
43213
|
waiter.reject(new Error("Session host client closed"));
|
|
43413
43214
|
}
|
|
43414
43215
|
this.requestWaiters.clear();
|
|
43415
|
-
await new Promise((
|
|
43216
|
+
await new Promise((resolve12) => {
|
|
43416
43217
|
let settled = false;
|
|
43417
43218
|
const done = () => {
|
|
43418
43219
|
if (settled) return;
|
|
43419
43220
|
settled = true;
|
|
43420
|
-
|
|
43221
|
+
resolve12();
|
|
43421
43222
|
};
|
|
43422
43223
|
socket.once("close", done);
|
|
43423
43224
|
socket.end();
|
|
@@ -43794,7 +43595,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
|
|
|
43794
43595
|
const deadline = Date.now() + timeoutMs;
|
|
43795
43596
|
while (Date.now() < deadline) {
|
|
43796
43597
|
if (await canConnect(endpoint)) return;
|
|
43797
|
-
await new Promise((
|
|
43598
|
+
await new Promise((resolve12) => setTimeout(resolve12, STARTUP_POLL_MS));
|
|
43798
43599
|
}
|
|
43799
43600
|
throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
|
|
43800
43601
|
}
|
|
@@ -43884,10 +43685,10 @@ async function installExtension(ide, extension) {
|
|
|
43884
43685
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
43885
43686
|
const fs16 = await import("fs");
|
|
43886
43687
|
fs16.writeFileSync(vsixPath, buffer);
|
|
43887
|
-
return new Promise((
|
|
43688
|
+
return new Promise((resolve12) => {
|
|
43888
43689
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
43889
43690
|
(0, import_child_process8.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
43890
|
-
|
|
43691
|
+
resolve12({
|
|
43891
43692
|
extensionId: extension.id,
|
|
43892
43693
|
marketplaceId: extension.marketplaceId,
|
|
43893
43694
|
success: !error48,
|
|
@@ -43900,11 +43701,11 @@ async function installExtension(ide, extension) {
|
|
|
43900
43701
|
} catch (e) {
|
|
43901
43702
|
}
|
|
43902
43703
|
}
|
|
43903
|
-
return new Promise((
|
|
43704
|
+
return new Promise((resolve12) => {
|
|
43904
43705
|
const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
|
|
43905
43706
|
(0, import_child_process8.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
|
|
43906
43707
|
if (error48) {
|
|
43907
|
-
|
|
43708
|
+
resolve12({
|
|
43908
43709
|
extensionId: extension.id,
|
|
43909
43710
|
marketplaceId: extension.marketplaceId,
|
|
43910
43711
|
success: false,
|
|
@@ -43912,7 +43713,7 @@ async function installExtension(ide, extension) {
|
|
|
43912
43713
|
error: stderr || error48.message
|
|
43913
43714
|
});
|
|
43914
43715
|
} else {
|
|
43915
|
-
|
|
43716
|
+
resolve12({
|
|
43916
43717
|
extensionId: extension.id,
|
|
43917
43718
|
marketplaceId: extension.marketplaceId,
|
|
43918
43719
|
success: true,
|
|
@@ -44322,7 +44123,6 @@ __export(src_exports, {
|
|
|
44322
44123
|
ProviderLoader: () => ProviderLoader,
|
|
44323
44124
|
SessionHostPtyTransportFactory: () => SessionHostPtyTransportFactory,
|
|
44324
44125
|
VersionArchive: () => VersionArchive,
|
|
44325
|
-
addCliHistory: () => addCliHistory,
|
|
44326
44126
|
appendRecentActivity: () => appendRecentActivity,
|
|
44327
44127
|
buildSessionEntries: () => buildSessionEntries,
|
|
44328
44128
|
buildStatusSnapshot: () => buildStatusSnapshot,
|
|
@@ -44340,7 +44140,6 @@ __export(src_exports, {
|
|
|
44340
44140
|
getRecentActivity: () => getRecentActivity,
|
|
44341
44141
|
getRecentCommands: () => getRecentCommands,
|
|
44342
44142
|
getRecentLogs: () => getRecentLogs,
|
|
44343
|
-
getWorkspaceActivity: () => getWorkspaceActivity,
|
|
44344
44143
|
getWorkspaceState: () => getWorkspaceState,
|
|
44345
44144
|
hasCdpManager: () => hasCdpManager,
|
|
44346
44145
|
initDaemonComponents: () => initDaemonComponents,
|
|
@@ -44377,7 +44176,6 @@ var init_src = __esm({
|
|
|
44377
44176
|
"use strict";
|
|
44378
44177
|
init_config();
|
|
44379
44178
|
init_workspaces();
|
|
44380
|
-
init_workspace_activity();
|
|
44381
44179
|
init_recent_activity();
|
|
44382
44180
|
init_ide_detector();
|
|
44383
44181
|
init_cli_detector();
|
|
@@ -44610,9 +44408,9 @@ var init_server_connection = __esm({
|
|
|
44610
44408
|
LOG.info("Server", `[ServerConn] Run 'adhdev setup' to re-authenticate.`);
|
|
44611
44409
|
this.setState("disconnected");
|
|
44612
44410
|
try {
|
|
44613
|
-
const
|
|
44411
|
+
const path18 = require("path");
|
|
44614
44412
|
const fs16 = require("fs");
|
|
44615
|
-
const configPath =
|
|
44413
|
+
const configPath = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "config.json");
|
|
44616
44414
|
if (fs16.existsSync(configPath)) {
|
|
44617
44415
|
fs16.unlinkSync(configPath);
|
|
44618
44416
|
LOG.info("Server", `[ServerConn] Config file removed. Re-run 'adhdev setup'.`);
|
|
@@ -44723,17 +44521,17 @@ function canPeerUsePrivilegedShareCommand(commandType, permission) {
|
|
|
44723
44521
|
return false;
|
|
44724
44522
|
}
|
|
44725
44523
|
}
|
|
44726
|
-
var fs13,
|
|
44524
|
+
var fs13, path15, os18, import_node_module, esmRequire, logFile, log, logDebug, DaemonP2PSender;
|
|
44727
44525
|
var init_daemon_p2p = __esm({
|
|
44728
44526
|
"src/daemon-p2p.ts"() {
|
|
44729
44527
|
"use strict";
|
|
44730
44528
|
fs13 = __toESM(require("fs"));
|
|
44731
44529
|
init_src();
|
|
44732
|
-
|
|
44530
|
+
path15 = __toESM(require("path"));
|
|
44733
44531
|
os18 = __toESM(require("os"));
|
|
44734
44532
|
import_node_module = require("module");
|
|
44735
44533
|
esmRequire = (0, import_node_module.createRequire)(__filename);
|
|
44736
|
-
logFile =
|
|
44534
|
+
logFile = path15.join(os18.tmpdir(), "adhdev_daemon_p2p.log");
|
|
44737
44535
|
log = (msg) => {
|
|
44738
44536
|
LOG.info("P2P", `[${(/* @__PURE__ */ new Date()).toISOString()}] [P2P] ${msg}`);
|
|
44739
44537
|
};
|
|
@@ -44801,15 +44599,15 @@ ${e?.stack || ""}`);
|
|
|
44801
44599
|
const prebuildKey = `${platform11}-${arch3}`;
|
|
44802
44600
|
try {
|
|
44803
44601
|
const candidates = [
|
|
44804
|
-
|
|
44805
|
-
|
|
44806
|
-
|
|
44602
|
+
path15.join(__dirname, "node_modules", "node-datachannel"),
|
|
44603
|
+
path15.join(__dirname, "..", "node_modules", "node-datachannel"),
|
|
44604
|
+
path15.join(__dirname, "..", "..", "node_modules", "node-datachannel")
|
|
44807
44605
|
];
|
|
44808
44606
|
for (const candidate of candidates) {
|
|
44809
|
-
const prebuildPath =
|
|
44607
|
+
const prebuildPath = path15.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
|
|
44810
44608
|
if (fs13.existsSync(prebuildPath)) {
|
|
44811
|
-
const targetDir =
|
|
44812
|
-
const targetPath =
|
|
44609
|
+
const targetDir = path15.join(candidate, "build", "Release");
|
|
44610
|
+
const targetPath = path15.join(targetDir, "node_datachannel.node");
|
|
44813
44611
|
fs13.mkdirSync(targetDir, { recursive: true });
|
|
44814
44612
|
fs13.copyFileSync(prebuildPath, targetPath);
|
|
44815
44613
|
try {
|
|
@@ -44885,7 +44683,7 @@ ${e?.stack || ""}`);
|
|
|
44885
44683
|
async fetchTurnCredentials() {
|
|
44886
44684
|
try {
|
|
44887
44685
|
const serverUrl = process.env.ADHDEV_SERVER_URL || "https://api.adhf.dev";
|
|
44888
|
-
const configPath =
|
|
44686
|
+
const configPath = path15.join(os18.homedir(), ".adhdev", "config.json");
|
|
44889
44687
|
let token = "";
|
|
44890
44688
|
try {
|
|
44891
44689
|
const config2 = JSON.parse(fs13.readFileSync(configPath, "utf-8"));
|
|
@@ -44893,13 +44691,13 @@ ${e?.stack || ""}`);
|
|
|
44893
44691
|
} catch {
|
|
44894
44692
|
}
|
|
44895
44693
|
const http3 = esmRequire("https");
|
|
44896
|
-
const data = await new Promise((
|
|
44694
|
+
const data = await new Promise((resolve12, reject) => {
|
|
44897
44695
|
const req = http3.get(`${serverUrl}/api/v1/turn/credentials`, {
|
|
44898
44696
|
headers: { "Authorization": `Bearer ${token}` }
|
|
44899
44697
|
}, (res) => {
|
|
44900
44698
|
let d = "";
|
|
44901
44699
|
res.on("data", (c) => d += c);
|
|
44902
|
-
res.on("end", () =>
|
|
44700
|
+
res.on("end", () => resolve12(d));
|
|
44903
44701
|
});
|
|
44904
44702
|
req.on("error", reject);
|
|
44905
44703
|
req.setTimeout(5e3, () => {
|
|
@@ -45712,8 +45510,8 @@ __export(session_host_exports, {
|
|
|
45712
45510
|
});
|
|
45713
45511
|
function resolveSessionHostEntry() {
|
|
45714
45512
|
const packagedCandidates = [
|
|
45715
|
-
|
|
45716
|
-
|
|
45513
|
+
path16.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
45514
|
+
path16.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
45717
45515
|
];
|
|
45718
45516
|
for (const candidate of packagedCandidates) {
|
|
45719
45517
|
if (fs14.existsSync(candidate)) {
|
|
@@ -45723,7 +45521,7 @@ function resolveSessionHostEntry() {
|
|
|
45723
45521
|
return require.resolve("@adhdev/session-host-daemon");
|
|
45724
45522
|
}
|
|
45725
45523
|
function getSessionHostPidFile() {
|
|
45726
|
-
return
|
|
45524
|
+
return path16.join(os19.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
|
|
45727
45525
|
}
|
|
45728
45526
|
function killPid(pid) {
|
|
45729
45527
|
try {
|
|
@@ -45789,14 +45587,14 @@ async function ensureSessionHostReady2() {
|
|
|
45789
45587
|
async function listHostedCliRuntimes2(endpoint) {
|
|
45790
45588
|
return listHostedCliRuntimes(endpoint);
|
|
45791
45589
|
}
|
|
45792
|
-
var import_child_process9, fs14, os19,
|
|
45590
|
+
var import_child_process9, fs14, os19, path16, SESSION_HOST_APP_NAME;
|
|
45793
45591
|
var init_session_host = __esm({
|
|
45794
45592
|
"src/session-host.ts"() {
|
|
45795
45593
|
"use strict";
|
|
45796
45594
|
import_child_process9 = require("child_process");
|
|
45797
45595
|
fs14 = __toESM(require("fs"));
|
|
45798
45596
|
os19 = __toESM(require("os"));
|
|
45799
|
-
|
|
45597
|
+
path16 = __toESM(require("path"));
|
|
45800
45598
|
init_src();
|
|
45801
45599
|
SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
|
|
45802
45600
|
}
|
|
@@ -45810,9 +45608,9 @@ __export(adhdev_daemon_exports, {
|
|
|
45810
45608
|
stopDaemon: () => stopDaemon
|
|
45811
45609
|
});
|
|
45812
45610
|
function getDaemonPidFile() {
|
|
45813
|
-
const dir =
|
|
45611
|
+
const dir = path17.join(os20.homedir(), ".adhdev");
|
|
45814
45612
|
if (!fs15.existsSync(dir)) fs15.mkdirSync(dir, { recursive: true });
|
|
45815
|
-
return
|
|
45613
|
+
return path17.join(dir, "daemon.pid");
|
|
45816
45614
|
}
|
|
45817
45615
|
function writeDaemonPid(pid) {
|
|
45818
45616
|
fs15.writeFileSync(getDaemonPidFile(), String(pid), "utf-8");
|
|
@@ -45848,7 +45646,7 @@ function stopDaemon() {
|
|
|
45848
45646
|
return false;
|
|
45849
45647
|
}
|
|
45850
45648
|
}
|
|
45851
|
-
var os20, fs15,
|
|
45649
|
+
var os20, fs15, path17, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
|
|
45852
45650
|
var init_adhdev_daemon = __esm({
|
|
45853
45651
|
"src/adhdev-daemon.ts"() {
|
|
45854
45652
|
"use strict";
|
|
@@ -45860,14 +45658,14 @@ var init_adhdev_daemon = __esm({
|
|
|
45860
45658
|
init_dist();
|
|
45861
45659
|
os20 = __toESM(require("os"));
|
|
45862
45660
|
fs15 = __toESM(require("fs"));
|
|
45863
|
-
|
|
45661
|
+
path17 = __toESM(require("path"));
|
|
45864
45662
|
import_chalk2 = __toESM(require("chalk"));
|
|
45865
|
-
pkgVersion = "0.7.
|
|
45663
|
+
pkgVersion = "0.7.40";
|
|
45866
45664
|
if (pkgVersion === "unknown") {
|
|
45867
45665
|
try {
|
|
45868
45666
|
const possiblePaths = [
|
|
45869
|
-
|
|
45870
|
-
|
|
45667
|
+
path17.join(__dirname, "..", "package.json"),
|
|
45668
|
+
path17.join(__dirname, "package.json")
|
|
45871
45669
|
];
|
|
45872
45670
|
for (const p of possiblePaths) {
|
|
45873
45671
|
try {
|
|
@@ -46225,11 +46023,6 @@ ${err?.stack || ""}`);
|
|
|
46225
46023
|
});
|
|
46226
46024
|
}
|
|
46227
46025
|
}
|
|
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
46026
|
case "set_machine_nickname": {
|
|
46234
46027
|
const nickname = data.nickname?.trim() || null;
|
|
46235
46028
|
const config2 = loadConfig();
|
|
@@ -46547,8 +46340,8 @@ async function startDaemonFlow() {
|
|
|
46547
46340
|
const daemon = new AdhdevDaemon2();
|
|
46548
46341
|
const { execSync: execSync7 } = await import("child_process");
|
|
46549
46342
|
const os21 = await import("os");
|
|
46550
|
-
const
|
|
46551
|
-
const logPath =
|
|
46343
|
+
const path18 = await import("path");
|
|
46344
|
+
const logPath = path18.join(os21.homedir(), ".adhdev", "daemon.log");
|
|
46552
46345
|
const platform11 = os21.platform();
|
|
46553
46346
|
try {
|
|
46554
46347
|
if (platform11 === "win32") {
|
|
@@ -46711,7 +46504,7 @@ __export(cdp_utils_exports, {
|
|
|
46711
46504
|
async function sendDaemonCommand(cmd, args = {}, port = 19222) {
|
|
46712
46505
|
const WebSocket3 = (await import("ws")).default;
|
|
46713
46506
|
const { DAEMON_WS_PATH: DAEMON_WS_PATH2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
46714
|
-
return new Promise((
|
|
46507
|
+
return new Promise((resolve12, reject) => {
|
|
46715
46508
|
const wsUrl = `ws://127.0.0.1:${port}${DAEMON_WS_PATH2 || "/daemon"}`;
|
|
46716
46509
|
const ws2 = new WebSocket3(wsUrl);
|
|
46717
46510
|
const timeout = setTimeout(() => {
|
|
@@ -46742,7 +46535,7 @@ async function sendDaemonCommand(cmd, args = {}, port = 19222) {
|
|
|
46742
46535
|
if (msg.type === "daemon:command_result" || msg.type === "command_result") {
|
|
46743
46536
|
clearTimeout(timeout);
|
|
46744
46537
|
ws2.close();
|
|
46745
|
-
|
|
46538
|
+
resolve12(msg.payload?.result || msg.payload || msg);
|
|
46746
46539
|
}
|
|
46747
46540
|
} catch {
|
|
46748
46541
|
}
|
|
@@ -46759,13 +46552,13 @@ Is 'adhdev daemon' running?`));
|
|
|
46759
46552
|
}
|
|
46760
46553
|
async function directCdpEval(expression, port = 9222) {
|
|
46761
46554
|
const http3 = await import("http");
|
|
46762
|
-
const targets = await new Promise((
|
|
46555
|
+
const targets = await new Promise((resolve12, reject) => {
|
|
46763
46556
|
http3.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
46764
46557
|
let data = "";
|
|
46765
46558
|
res.on("data", (c) => data += c);
|
|
46766
46559
|
res.on("end", () => {
|
|
46767
46560
|
try {
|
|
46768
|
-
|
|
46561
|
+
resolve12(JSON.parse(data));
|
|
46769
46562
|
} catch {
|
|
46770
46563
|
reject(new Error("Invalid JSON"));
|
|
46771
46564
|
}
|
|
@@ -46778,7 +46571,7 @@ async function directCdpEval(expression, port = 9222) {
|
|
|
46778
46571
|
const target = (mainPages.length > 0 ? mainPages[0] : pages[0]) || targets[0];
|
|
46779
46572
|
if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target found");
|
|
46780
46573
|
const WebSocket3 = (await import("ws")).default;
|
|
46781
|
-
return new Promise((
|
|
46574
|
+
return new Promise((resolve12, reject) => {
|
|
46782
46575
|
const ws2 = new WebSocket3(target.webSocketDebuggerUrl);
|
|
46783
46576
|
const timeout = setTimeout(() => {
|
|
46784
46577
|
ws2.close();
|
|
@@ -46800,11 +46593,11 @@ async function directCdpEval(expression, port = 9222) {
|
|
|
46800
46593
|
clearTimeout(timeout);
|
|
46801
46594
|
ws2.close();
|
|
46802
46595
|
if (msg.result?.result?.value !== void 0) {
|
|
46803
|
-
|
|
46596
|
+
resolve12(msg.result.result.value);
|
|
46804
46597
|
} else if (msg.result?.exceptionDetails) {
|
|
46805
46598
|
reject(new Error(msg.result.exceptionDetails.text));
|
|
46806
46599
|
} else {
|
|
46807
|
-
|
|
46600
|
+
resolve12(msg.result);
|
|
46808
46601
|
}
|
|
46809
46602
|
}
|
|
46810
46603
|
});
|
|
@@ -47466,7 +47259,7 @@ function registerProviderCommands(program2) {
|
|
|
47466
47259
|
} catch {
|
|
47467
47260
|
try {
|
|
47468
47261
|
const http3 = await import("http");
|
|
47469
|
-
const result = await new Promise((
|
|
47262
|
+
const result = await new Promise((resolve12, reject) => {
|
|
47470
47263
|
const req = http3.request({
|
|
47471
47264
|
hostname: "127.0.0.1",
|
|
47472
47265
|
port: 19280,
|
|
@@ -47478,9 +47271,9 @@ function registerProviderCommands(program2) {
|
|
|
47478
47271
|
res.on("data", (c) => data += c);
|
|
47479
47272
|
res.on("end", () => {
|
|
47480
47273
|
try {
|
|
47481
|
-
|
|
47274
|
+
resolve12(JSON.parse(data));
|
|
47482
47275
|
} catch {
|
|
47483
|
-
|
|
47276
|
+
resolve12({ raw: data });
|
|
47484
47277
|
}
|
|
47485
47278
|
});
|
|
47486
47279
|
});
|
|
@@ -47541,7 +47334,7 @@ function registerProviderCommands(program2) {
|
|
|
47541
47334
|
let processNames = {};
|
|
47542
47335
|
if (category === "ide") {
|
|
47543
47336
|
const fs16 = await import("fs");
|
|
47544
|
-
const
|
|
47337
|
+
const path18 = await import("path");
|
|
47545
47338
|
const os21 = await import("os");
|
|
47546
47339
|
if (os21.platform() === "darwin") {
|
|
47547
47340
|
while (true) {
|
|
@@ -47554,7 +47347,7 @@ function registerProviderCommands(program2) {
|
|
|
47554
47347
|
}
|
|
47555
47348
|
console.log(import_chalk6.default.green(` \u2713 Path verified: ${p}`));
|
|
47556
47349
|
osPaths["darwin"] = [p];
|
|
47557
|
-
processNames["darwin"] =
|
|
47350
|
+
processNames["darwin"] = path18.basename(p, ".app");
|
|
47558
47351
|
break;
|
|
47559
47352
|
}
|
|
47560
47353
|
} else if (os21.platform() === "win32") {
|
|
@@ -47568,7 +47361,7 @@ function registerProviderCommands(program2) {
|
|
|
47568
47361
|
}
|
|
47569
47362
|
console.log(import_chalk6.default.green(` \u2713 Path verified: ${p}`));
|
|
47570
47363
|
osPaths["win32"] = [p];
|
|
47571
|
-
processNames["win32"] =
|
|
47364
|
+
processNames["win32"] = path18.basename(p, ".exe");
|
|
47572
47365
|
break;
|
|
47573
47366
|
}
|
|
47574
47367
|
}
|
|
@@ -47582,12 +47375,12 @@ function registerProviderCommands(program2) {
|
|
|
47582
47375
|
console.log(import_chalk6.default.yellow("Invalid port number."));
|
|
47583
47376
|
continue;
|
|
47584
47377
|
}
|
|
47585
|
-
const isFree = await new Promise((
|
|
47378
|
+
const isFree = await new Promise((resolve12) => {
|
|
47586
47379
|
const server = net3.createServer();
|
|
47587
47380
|
server.unref();
|
|
47588
|
-
server.on("error", () =>
|
|
47381
|
+
server.on("error", () => resolve12(false));
|
|
47589
47382
|
server.listen(port, "127.0.0.1", () => {
|
|
47590
|
-
server.close(() =>
|
|
47383
|
+
server.close(() => resolve12(true));
|
|
47591
47384
|
});
|
|
47592
47385
|
});
|
|
47593
47386
|
if (!isFree) {
|
|
@@ -47602,7 +47395,7 @@ function registerProviderCommands(program2) {
|
|
|
47602
47395
|
rl.close();
|
|
47603
47396
|
const location = options.builtin ? "builtin" : "user";
|
|
47604
47397
|
const http3 = await import("http");
|
|
47605
|
-
const result = await new Promise((
|
|
47398
|
+
const result = await new Promise((resolve12, reject) => {
|
|
47606
47399
|
const postData = JSON.stringify({ type, name, category, location, cdpPorts, osPaths, processNames });
|
|
47607
47400
|
const req = http3.request({
|
|
47608
47401
|
hostname: "127.0.0.1",
|
|
@@ -47615,9 +47408,9 @@ function registerProviderCommands(program2) {
|
|
|
47615
47408
|
res.on("data", (c) => data += c);
|
|
47616
47409
|
res.on("end", () => {
|
|
47617
47410
|
try {
|
|
47618
|
-
|
|
47411
|
+
resolve12(JSON.parse(data));
|
|
47619
47412
|
} catch {
|
|
47620
|
-
|
|
47413
|
+
resolve12({ raw: data });
|
|
47621
47414
|
}
|
|
47622
47415
|
});
|
|
47623
47416
|
});
|
|
@@ -47815,7 +47608,7 @@ function registerProviderCommands(program2) {
|
|
|
47815
47608
|
...userComment ? { comment: userComment } : {},
|
|
47816
47609
|
reference
|
|
47817
47610
|
});
|
|
47818
|
-
const startResult = await new Promise((
|
|
47611
|
+
const startResult = await new Promise((resolve12, reject) => {
|
|
47819
47612
|
const req = http3.request({
|
|
47820
47613
|
hostname: "127.0.0.1",
|
|
47821
47614
|
port: 19280,
|
|
@@ -47827,9 +47620,9 @@ function registerProviderCommands(program2) {
|
|
|
47827
47620
|
res.on("data", (c) => data += c);
|
|
47828
47621
|
res.on("end", () => {
|
|
47829
47622
|
try {
|
|
47830
|
-
|
|
47623
|
+
resolve12(JSON.parse(data));
|
|
47831
47624
|
} catch {
|
|
47832
|
-
|
|
47625
|
+
resolve12({ raw: data });
|
|
47833
47626
|
}
|
|
47834
47627
|
});
|
|
47835
47628
|
});
|
|
@@ -47855,7 +47648,7 @@ function registerProviderCommands(program2) {
|
|
|
47855
47648
|
fsMock.writeFileSync(logFile2, `=== Auto-Impl Started ===
|
|
47856
47649
|
`);
|
|
47857
47650
|
console.log(import_chalk6.default.gray(` Agent logs: ${logFile2}`));
|
|
47858
|
-
await new Promise((
|
|
47651
|
+
await new Promise((resolve12, reject) => {
|
|
47859
47652
|
http3.get(`http://127.0.0.1:19280${startResult.sseUrl}`, (res) => {
|
|
47860
47653
|
let buffer = "";
|
|
47861
47654
|
res.on("data", (chunk) => {
|
|
@@ -47892,7 +47685,7 @@ function registerProviderCommands(program2) {
|
|
|
47892
47685
|
if (currentData.success === false) {
|
|
47893
47686
|
reject(new Error(`Agent failed to implement scripts properly (exit: ${currentData.exitCode})`));
|
|
47894
47687
|
} else {
|
|
47895
|
-
|
|
47688
|
+
resolve12();
|
|
47896
47689
|
}
|
|
47897
47690
|
} else if (currentEvent === "error") {
|
|
47898
47691
|
fsMock.appendFileSync(logFile2, `
|
|
@@ -47903,7 +47696,7 @@ function registerProviderCommands(program2) {
|
|
|
47903
47696
|
}
|
|
47904
47697
|
}
|
|
47905
47698
|
});
|
|
47906
|
-
res.on("end",
|
|
47699
|
+
res.on("end", resolve12);
|
|
47907
47700
|
}).on("error", reject);
|
|
47908
47701
|
});
|
|
47909
47702
|
console.log(import_chalk6.default.green(`
|
|
@@ -47962,7 +47755,7 @@ function registerProviderCommands(program2) {
|
|
|
47962
47755
|
ideType: type,
|
|
47963
47756
|
params: options.param ? { text: options.param, sessionId: options.param, buttonText: options.param } : {}
|
|
47964
47757
|
});
|
|
47965
|
-
const result = await new Promise((
|
|
47758
|
+
const result = await new Promise((resolve12, reject) => {
|
|
47966
47759
|
const req = http3.request({
|
|
47967
47760
|
hostname: "127.0.0.1",
|
|
47968
47761
|
port: 19280,
|
|
@@ -47974,9 +47767,9 @@ function registerProviderCommands(program2) {
|
|
|
47974
47767
|
res.on("data", (c) => data += c);
|
|
47975
47768
|
res.on("end", () => {
|
|
47976
47769
|
try {
|
|
47977
|
-
|
|
47770
|
+
resolve12(JSON.parse(data));
|
|
47978
47771
|
} catch {
|
|
47979
|
-
|
|
47772
|
+
resolve12({ raw: data });
|
|
47980
47773
|
}
|
|
47981
47774
|
});
|
|
47982
47775
|
});
|
|
@@ -48012,15 +47805,15 @@ function registerProviderCommands(program2) {
|
|
|
48012
47805
|
provider.command("source <type>").description("View source code of a provider").action(async (type) => {
|
|
48013
47806
|
try {
|
|
48014
47807
|
const http3 = await import("http");
|
|
48015
|
-
const result = await new Promise((
|
|
47808
|
+
const result = await new Promise((resolve12, reject) => {
|
|
48016
47809
|
http3.get(`http://127.0.0.1:19280/api/providers/${type}/source`, (res) => {
|
|
48017
47810
|
let data = "";
|
|
48018
47811
|
res.on("data", (c) => data += c);
|
|
48019
47812
|
res.on("end", () => {
|
|
48020
47813
|
try {
|
|
48021
|
-
|
|
47814
|
+
resolve12(JSON.parse(data));
|
|
48022
47815
|
} catch {
|
|
48023
|
-
|
|
47816
|
+
resolve12({ raw: data });
|
|
48024
47817
|
}
|
|
48025
47818
|
});
|
|
48026
47819
|
}).on("error", () => {
|
|
@@ -48066,7 +47859,7 @@ function registerProviderCommands(program2) {
|
|
|
48066
47859
|
try {
|
|
48067
47860
|
const http3 = await import("http");
|
|
48068
47861
|
const postData = JSON.stringify({ script: "readChat", params: {} });
|
|
48069
|
-
const result = await new Promise((
|
|
47862
|
+
const result = await new Promise((resolve12, reject) => {
|
|
48070
47863
|
const req = http3.request({
|
|
48071
47864
|
hostname: "127.0.0.1",
|
|
48072
47865
|
port: 19280,
|
|
@@ -48078,9 +47871,9 @@ function registerProviderCommands(program2) {
|
|
|
48078
47871
|
res2.on("data", (c) => data += c);
|
|
48079
47872
|
res2.on("end", () => {
|
|
48080
47873
|
try {
|
|
48081
|
-
|
|
47874
|
+
resolve12(JSON.parse(data));
|
|
48082
47875
|
} catch {
|
|
48083
|
-
|
|
47876
|
+
resolve12({ raw: data });
|
|
48084
47877
|
}
|
|
48085
47878
|
});
|
|
48086
47879
|
});
|
|
@@ -48321,13 +48114,13 @@ function registerCdpCommands(program2) {
|
|
|
48321
48114
|
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
48115
|
try {
|
|
48323
48116
|
const http3 = await import("http");
|
|
48324
|
-
const targets = await new Promise((
|
|
48117
|
+
const targets = await new Promise((resolve12, reject) => {
|
|
48325
48118
|
http3.get(`http://127.0.0.1:${options.port}/json`, (res) => {
|
|
48326
48119
|
let data = "";
|
|
48327
48120
|
res.on("data", (c) => data += c);
|
|
48328
48121
|
res.on("end", () => {
|
|
48329
48122
|
try {
|
|
48330
|
-
|
|
48123
|
+
resolve12(JSON.parse(data));
|
|
48331
48124
|
} catch {
|
|
48332
48125
|
reject(new Error("Invalid JSON"));
|
|
48333
48126
|
}
|
|
@@ -48341,7 +48134,7 @@ function registerCdpCommands(program2) {
|
|
|
48341
48134
|
if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target");
|
|
48342
48135
|
const WebSocket3 = (await import("ws")).default;
|
|
48343
48136
|
const ws2 = new WebSocket3(target.webSocketDebuggerUrl);
|
|
48344
|
-
await new Promise((
|
|
48137
|
+
await new Promise((resolve12, reject) => {
|
|
48345
48138
|
ws2.on("open", () => {
|
|
48346
48139
|
ws2.send(JSON.stringify({ id: 1, method: "Page.captureScreenshot", params: { format: "jpeg", quality: 50 } }));
|
|
48347
48140
|
});
|
|
@@ -48354,7 +48147,7 @@ function registerCdpCommands(program2) {
|
|
|
48354
48147
|
\u2713 Screenshot saved to ${options.output}
|
|
48355
48148
|
`));
|
|
48356
48149
|
ws2.close();
|
|
48357
|
-
|
|
48150
|
+
resolve12();
|
|
48358
48151
|
}
|
|
48359
48152
|
});
|
|
48360
48153
|
ws2.on("error", (e) => reject(e));
|