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/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, import_crypto.randomUUID)(),
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, import_crypto, MAX_WORKSPACES;
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
- init_workspaces();
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 path3.resolve(expandPath(workspace));
369
+ return path2.resolve(expandPath(workspace));
473
370
  } catch {
474
- return path3.resolve(workspace);
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, MAX_ACTIVITY2)
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 getRecentSessionSeenAt(config2, recentKey) {
497
- return config2.recentSessionReads?.[recentKey] || 0;
393
+ function getSessionSeenAt(config2, sessionId) {
394
+ return config2.sessionReads?.[sessionId] || 0;
498
395
  }
499
- function markRecentSessionSeen(config2, recentKey, seenAt = Date.now()) {
500
- const prev = config2.recentSessionReads || {};
501
- const nextSeenAt = Math.max(prev[recentKey] || 0, seenAt);
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
- recentSessionReads: {
406
+ sessionReads: {
505
407
  ...prev,
506
- [recentKey]: nextSeenAt
507
- }
408
+ [sessionId]: nextSeenAt
409
+ },
410
+ sessionReadMarkers: nextMarker ? {
411
+ ...prevMarkers,
412
+ [sessionId]: nextMarker
413
+ } : prevMarkers
508
414
  };
509
415
  }
510
- var path3, MAX_ACTIVITY2;
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
- path3 = __toESM(require("path"));
420
+ path2 = __toESM(require("path"));
515
421
  init_workspaces();
516
- MAX_ACTIVITY2 = 30;
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((resolve13) => {
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
- resolve13(null);
540
+ resolve12(null);
635
541
  } else {
636
- resolve13(stdout.trim());
542
+ resolve12(stdout.trim());
637
543
  }
638
544
  });
639
- child.on("error", () => resolve13(null));
545
+ child.on("error", () => resolve12(null));
640
546
  });
641
547
  }
642
548
  async function detectCLIs(providerLoader) {
@@ -744,7 +650,7 @@ function checkDateRotation() {
744
650
  const today = getDateStr();
745
651
  if (today !== currentDate) {
746
652
  currentDate = today;
747
- currentLogFile = path4.join(LOG_DIR, `daemon-${currentDate}.log`);
653
+ currentLogFile = path3.join(LOG_DIR, `daemon-${currentDate}.log`);
748
654
  cleanOldLogs();
749
655
  }
750
656
  }
@@ -758,7 +664,7 @@ function cleanOldLogs() {
758
664
  const dateMatch = file2.match(/daemon-(\d{4}-\d{2}-\d{2})/);
759
665
  if (dateMatch && dateMatch[1] < cutoffStr) {
760
666
  try {
761
- fs2.unlinkSync(path4.join(LOG_DIR, file2));
667
+ fs2.unlinkSync(path3.join(LOG_DIR, file2));
762
668
  } catch {
763
669
  }
764
670
  }
@@ -875,17 +781,17 @@ function installGlobalInterceptor() {
875
781
  writeToFile(`Log file: ${currentLogFile}`);
876
782
  writeToFile(`Log level: ${currentLevel}`);
877
783
  }
878
- var fs2, path4, 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;
784
+ 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;
879
785
  var init_logger = __esm({
880
786
  "../../oss/packages/daemon-core/src/logging/logger.ts"() {
881
787
  "use strict";
882
788
  fs2 = __toESM(require("fs"));
883
- path4 = __toESM(require("path"));
789
+ path3 = __toESM(require("path"));
884
790
  os4 = __toESM(require("os"));
885
791
  LEVEL_NUM = { debug: 0, info: 1, warn: 2, error: 3 };
886
792
  LEVEL_LABEL = { debug: "DBG", info: "INF", warn: "WRN", error: "ERR" };
887
793
  currentLevel = "info";
888
- LOG_DIR = process.platform === "win32" ? path4.join(process.env.LOCALAPPDATA || process.env.APPDATA || path4.join(os4.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path4.join(os4.homedir(), "Library", "Logs", "adhdev") : path4.join(os4.homedir(), ".local", "share", "adhdev", "logs");
794
+ 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");
889
795
  MAX_LOG_SIZE = 5 * 1024 * 1024;
890
796
  MAX_LOG_DAYS = 7;
891
797
  try {
@@ -893,16 +799,16 @@ var init_logger = __esm({
893
799
  } catch {
894
800
  }
895
801
  currentDate = getDateStr();
896
- currentLogFile = path4.join(LOG_DIR, `daemon-${currentDate}.log`);
802
+ currentLogFile = path3.join(LOG_DIR, `daemon-${currentDate}.log`);
897
803
  cleanOldLogs();
898
804
  try {
899
- const oldLog = path4.join(LOG_DIR, "daemon.log");
805
+ const oldLog = path3.join(LOG_DIR, "daemon.log");
900
806
  if (fs2.existsSync(oldLog)) {
901
807
  const stat4 = fs2.statSync(oldLog);
902
808
  const oldDate = stat4.mtime.toISOString().slice(0, 10);
903
- fs2.renameSync(oldLog, path4.join(LOG_DIR, `daemon-${oldDate}.log`));
809
+ fs2.renameSync(oldLog, path3.join(LOG_DIR, `daemon-${oldDate}.log`));
904
810
  }
905
- const oldLogBackup = path4.join(LOG_DIR, "daemon.log.old");
811
+ const oldLogBackup = path3.join(LOG_DIR, "daemon.log.old");
906
812
  if (fs2.existsSync(oldLogBackup)) {
907
813
  fs2.unlinkSync(oldLogBackup);
908
814
  }
@@ -934,7 +840,7 @@ var init_logger = __esm({
934
840
  }
935
841
  };
936
842
  interceptorInstalled = false;
937
- LOG_PATH = path4.join(LOG_DIR, `daemon-${getDateStr()}.log`);
843
+ LOG_PATH = path3.join(LOG_DIR, `daemon-${getDateStr()}.log`);
938
844
  }
939
845
  });
940
846
 
@@ -1023,7 +929,7 @@ var init_manager = __esm({
1023
929
  * Returns multiple entries if multiple IDE windows are open on same port
1024
930
  */
1025
931
  static listAllTargets(port) {
1026
- return new Promise((resolve13) => {
932
+ return new Promise((resolve12) => {
1027
933
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
1028
934
  let data = "";
1029
935
  res.on("data", (chunk) => data += chunk.toString());
@@ -1039,16 +945,16 @@ var init_manager = __esm({
1039
945
  (t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
1040
946
  );
1041
947
  const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
1042
- resolve13(mainPages.length > 0 ? mainPages : fallbackPages);
948
+ resolve12(mainPages.length > 0 ? mainPages : fallbackPages);
1043
949
  } catch {
1044
- resolve13([]);
950
+ resolve12([]);
1045
951
  }
1046
952
  });
1047
953
  });
1048
- req.on("error", () => resolve13([]));
954
+ req.on("error", () => resolve12([]));
1049
955
  req.setTimeout(2e3, () => {
1050
956
  req.destroy();
1051
- resolve13([]);
957
+ resolve12([]);
1052
958
  });
1053
959
  });
1054
960
  }
@@ -1088,7 +994,7 @@ var init_manager = __esm({
1088
994
  }
1089
995
  }
1090
996
  findTargetOnPort(port) {
1091
- return new Promise((resolve13) => {
997
+ return new Promise((resolve12) => {
1092
998
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
1093
999
  let data = "";
1094
1000
  res.on("data", (chunk) => data += chunk.toString());
@@ -1099,7 +1005,7 @@ var init_manager = __esm({
1099
1005
  (t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
1100
1006
  );
1101
1007
  if (pages.length === 0) {
1102
- resolve13(targets.find((t) => t.webSocketDebuggerUrl) || null);
1008
+ resolve12(targets.find((t) => t.webSocketDebuggerUrl) || null);
1103
1009
  return;
1104
1010
  }
1105
1011
  const mainPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
@@ -1109,24 +1015,24 @@ var init_manager = __esm({
1109
1015
  const specific = list.find((t) => t.id === this._targetId);
1110
1016
  if (specific) {
1111
1017
  this._pageTitle = specific.title || "";
1112
- resolve13(specific);
1018
+ resolve12(specific);
1113
1019
  } else {
1114
1020
  this.log(`[CDP] Target ${this._targetId} not found in page list`);
1115
- resolve13(null);
1021
+ resolve12(null);
1116
1022
  }
1117
1023
  return;
1118
1024
  }
1119
1025
  this._pageTitle = list[0]?.title || "";
1120
- resolve13(list[0]);
1026
+ resolve12(list[0]);
1121
1027
  } catch {
1122
- resolve13(null);
1028
+ resolve12(null);
1123
1029
  }
1124
1030
  });
1125
1031
  });
1126
- req.on("error", () => resolve13(null));
1032
+ req.on("error", () => resolve12(null));
1127
1033
  req.setTimeout(2e3, () => {
1128
1034
  req.destroy();
1129
- resolve13(null);
1035
+ resolve12(null);
1130
1036
  });
1131
1037
  });
1132
1038
  }
@@ -1137,7 +1043,7 @@ var init_manager = __esm({
1137
1043
  this.extensionProviders = providers;
1138
1044
  }
1139
1045
  connectToTarget(wsUrl) {
1140
- return new Promise((resolve13) => {
1046
+ return new Promise((resolve12) => {
1141
1047
  this.ws = new import_ws.default(wsUrl);
1142
1048
  this.ws.on("open", async () => {
1143
1049
  this._connected = true;
@@ -1147,17 +1053,17 @@ var init_manager = __esm({
1147
1053
  }
1148
1054
  this.connectBrowserWs().catch(() => {
1149
1055
  });
1150
- resolve13(true);
1056
+ resolve12(true);
1151
1057
  });
1152
1058
  this.ws.on("message", (data) => {
1153
1059
  try {
1154
1060
  const msg = JSON.parse(data.toString());
1155
1061
  if (msg.id && this.pending.has(msg.id)) {
1156
- const { resolve: resolve14, reject } = this.pending.get(msg.id);
1062
+ const { resolve: resolve13, reject } = this.pending.get(msg.id);
1157
1063
  this.pending.delete(msg.id);
1158
1064
  this.failureCount = 0;
1159
1065
  if (msg.error) reject(new Error(msg.error.message));
1160
- else resolve14(msg.result);
1066
+ else resolve13(msg.result);
1161
1067
  } else if (msg.method === "Runtime.executionContextCreated") {
1162
1068
  this.contexts.add(msg.params.context.id);
1163
1069
  } else if (msg.method === "Runtime.executionContextDestroyed") {
@@ -1180,7 +1086,7 @@ var init_manager = __esm({
1180
1086
  this.ws.on("error", (err) => {
1181
1087
  this.log(`[CDP] WebSocket error: ${err.message}`);
1182
1088
  this._connected = false;
1183
- resolve13(false);
1089
+ resolve12(false);
1184
1090
  });
1185
1091
  });
1186
1092
  }
@@ -1194,7 +1100,7 @@ var init_manager = __esm({
1194
1100
  return;
1195
1101
  }
1196
1102
  this.log(`[CDP] Connecting browser WS for target discovery...`);
1197
- await new Promise((resolve13, reject) => {
1103
+ await new Promise((resolve12, reject) => {
1198
1104
  this.browserWs = new import_ws.default(browserWsUrl);
1199
1105
  this.browserWs.on("open", async () => {
1200
1106
  this._browserConnected = true;
@@ -1204,16 +1110,16 @@ var init_manager = __esm({
1204
1110
  } catch (e) {
1205
1111
  this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
1206
1112
  }
1207
- resolve13();
1113
+ resolve12();
1208
1114
  });
1209
1115
  this.browserWs.on("message", (data) => {
1210
1116
  try {
1211
1117
  const msg = JSON.parse(data.toString());
1212
1118
  if (msg.id && this.browserPending.has(msg.id)) {
1213
- const { resolve: resolve14, reject: reject2 } = this.browserPending.get(msg.id);
1119
+ const { resolve: resolve13, reject: reject2 } = this.browserPending.get(msg.id);
1214
1120
  this.browserPending.delete(msg.id);
1215
1121
  if (msg.error) reject2(new Error(msg.error.message));
1216
- else resolve14(msg.result);
1122
+ else resolve13(msg.result);
1217
1123
  }
1218
1124
  } catch {
1219
1125
  }
@@ -1233,31 +1139,31 @@ var init_manager = __esm({
1233
1139
  }
1234
1140
  }
1235
1141
  getBrowserWsUrl() {
1236
- return new Promise((resolve13) => {
1142
+ return new Promise((resolve12) => {
1237
1143
  const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
1238
1144
  let data = "";
1239
1145
  res.on("data", (chunk) => data += chunk.toString());
1240
1146
  res.on("end", () => {
1241
1147
  try {
1242
1148
  const info = JSON.parse(data);
1243
- resolve13(info.webSocketDebuggerUrl || null);
1149
+ resolve12(info.webSocketDebuggerUrl || null);
1244
1150
  } catch {
1245
- resolve13(null);
1151
+ resolve12(null);
1246
1152
  }
1247
1153
  });
1248
1154
  });
1249
- req.on("error", () => resolve13(null));
1155
+ req.on("error", () => resolve12(null));
1250
1156
  req.setTimeout(3e3, () => {
1251
1157
  req.destroy();
1252
- resolve13(null);
1158
+ resolve12(null);
1253
1159
  });
1254
1160
  });
1255
1161
  }
1256
1162
  sendBrowser(method, params = {}, timeoutMs = 15e3) {
1257
- return new Promise((resolve13, reject) => {
1163
+ return new Promise((resolve12, reject) => {
1258
1164
  if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
1259
1165
  const id = this.browserMsgId++;
1260
- this.browserPending.set(id, { resolve: resolve13, reject });
1166
+ this.browserPending.set(id, { resolve: resolve12, reject });
1261
1167
  this.browserWs.send(JSON.stringify({ id, method, params }));
1262
1168
  setTimeout(() => {
1263
1169
  if (this.browserPending.has(id)) {
@@ -1297,11 +1203,11 @@ var init_manager = __esm({
1297
1203
  }
1298
1204
  // ─── CDP Protocol ────────────────────────────────────────
1299
1205
  sendInternal(method, params = {}, timeoutMs = 15e3) {
1300
- return new Promise((resolve13, reject) => {
1206
+ return new Promise((resolve12, reject) => {
1301
1207
  if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
1302
1208
  if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
1303
1209
  const id = this.msgId++;
1304
- this.pending.set(id, { resolve: resolve13, reject });
1210
+ this.pending.set(id, { resolve: resolve12, reject });
1305
1211
  this.ws.send(JSON.stringify({ id, method, params }));
1306
1212
  setTimeout(() => {
1307
1213
  if (this.pending.has(id)) {
@@ -1550,7 +1456,7 @@ var init_manager = __esm({
1550
1456
  const browserWs = this.browserWs;
1551
1457
  let msgId = this.browserMsgId;
1552
1458
  const sendWs = (method, params = {}, sessionId) => {
1553
- return new Promise((resolve13, reject) => {
1459
+ return new Promise((resolve12, reject) => {
1554
1460
  const mid = msgId++;
1555
1461
  this.browserMsgId = msgId;
1556
1462
  const handler = (raw) => {
@@ -1559,7 +1465,7 @@ var init_manager = __esm({
1559
1465
  if (msg.id === mid) {
1560
1466
  browserWs.removeListener("message", handler);
1561
1467
  if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
1562
- else resolve13(msg.result);
1468
+ else resolve12(msg.result);
1563
1469
  }
1564
1470
  } catch {
1565
1471
  }
@@ -1750,14 +1656,14 @@ var init_manager = __esm({
1750
1656
  if (!ws2 || ws2.readyState !== import_ws.default.OPEN) {
1751
1657
  throw new Error("CDP not connected");
1752
1658
  }
1753
- return new Promise((resolve13, reject) => {
1659
+ return new Promise((resolve12, reject) => {
1754
1660
  const id = getNextId();
1755
1661
  pendingMap.set(id, {
1756
1662
  resolve: (result) => {
1757
1663
  if (result?.result?.subtype === "error") {
1758
1664
  reject(new Error(result.result.description));
1759
1665
  } else {
1760
- resolve13(result?.result?.value);
1666
+ resolve12(result?.result?.value);
1761
1667
  }
1762
1668
  },
1763
1669
  reject
@@ -1789,10 +1695,10 @@ var init_manager = __esm({
1789
1695
  throw new Error("CDP not connected");
1790
1696
  }
1791
1697
  const sendViaSession = (method, params = {}) => {
1792
- return new Promise((resolve13, reject) => {
1698
+ return new Promise((resolve12, reject) => {
1793
1699
  const pendingMap = this._browserConnected ? this.browserPending : this.pending;
1794
1700
  const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
1795
- pendingMap.set(id, { resolve: resolve13, reject });
1701
+ pendingMap.set(id, { resolve: resolve12, reject });
1796
1702
  ws2.send(JSON.stringify({ id, sessionId, method, params }));
1797
1703
  setTimeout(() => {
1798
1704
  if (pendingMap.has(id)) {
@@ -2519,7 +2425,7 @@ var init_extension_provider_instance = __esm({
2519
2425
  function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
2520
2426
  try {
2521
2427
  const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
2522
- const dir = path5.join(HISTORY_DIR, sanitized);
2428
+ const dir = path4.join(HISTORY_DIR, sanitized);
2523
2429
  if (!fs3.existsSync(dir)) return { messages: [], hasMore: false };
2524
2430
  const sanitizedInstance = instanceId?.replace(/[^a-zA-Z0-9_-]/g, "_");
2525
2431
  const files = fs3.readdirSync(dir).filter((f) => {
@@ -2533,7 +2439,7 @@ function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
2533
2439
  const needed = offset + limit + 1;
2534
2440
  for (const file2 of files) {
2535
2441
  if (allMessages.length >= needed) break;
2536
- const filePath = path5.join(dir, file2);
2442
+ const filePath = path4.join(dir, file2);
2537
2443
  const content = fs3.readFileSync(filePath, "utf-8");
2538
2444
  const lines = content.trim().split("\n").filter(Boolean);
2539
2445
  for (let i = lines.length - 1; i >= 0; i--) {
@@ -2552,14 +2458,14 @@ function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
2552
2458
  return { messages: [], hasMore: false };
2553
2459
  }
2554
2460
  }
2555
- var fs3, path5, os5, HISTORY_DIR, RETAIN_DAYS, ChatHistoryWriter;
2461
+ var fs3, path4, os5, HISTORY_DIR, RETAIN_DAYS, ChatHistoryWriter;
2556
2462
  var init_chat_history = __esm({
2557
2463
  "../../oss/packages/daemon-core/src/config/chat-history.ts"() {
2558
2464
  "use strict";
2559
2465
  fs3 = __toESM(require("fs"));
2560
- path5 = __toESM(require("path"));
2466
+ path4 = __toESM(require("path"));
2561
2467
  os5 = __toESM(require("os"));
2562
- HISTORY_DIR = path5.join(os5.homedir(), ".adhdev", "history");
2468
+ HISTORY_DIR = path4.join(os5.homedir(), ".adhdev", "history");
2563
2469
  RETAIN_DAYS = 30;
2564
2470
  ChatHistoryWriter = class {
2565
2471
  /** Last seen message count per agent (deduplication) */
@@ -2602,11 +2508,11 @@ var init_chat_history = __esm({
2602
2508
  });
2603
2509
  }
2604
2510
  if (newMessages.length === 0) return;
2605
- const dir = path5.join(HISTORY_DIR, this.sanitize(agentType));
2511
+ const dir = path4.join(HISTORY_DIR, this.sanitize(agentType));
2606
2512
  fs3.mkdirSync(dir, { recursive: true });
2607
2513
  const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
2608
2514
  const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
2609
- const filePath = path5.join(dir, `${filePrefix}${date5}.jsonl`);
2515
+ const filePath = path4.join(dir, `${filePrefix}${date5}.jsonl`);
2610
2516
  const lines = newMessages.map((m) => JSON.stringify(m)).join("\n") + "\n";
2611
2517
  fs3.appendFileSync(filePath, lines, "utf-8");
2612
2518
  const prevCount = this.lastSeenCounts.get(dedupKey) || 0;
@@ -2650,11 +2556,11 @@ ${next}`;
2650
2556
  this.lastSeenTerminal.set(dedupKey, next);
2651
2557
  return;
2652
2558
  }
2653
- const dir = path5.join(HISTORY_DIR, this.sanitize(agentType));
2559
+ const dir = path4.join(HISTORY_DIR, this.sanitize(agentType));
2654
2560
  fs3.mkdirSync(dir, { recursive: true });
2655
2561
  const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
2656
2562
  const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
2657
- const filePath = path5.join(dir, `${filePrefix}${date5}.terminal.log`);
2563
+ const filePath = path4.join(dir, `${filePrefix}${date5}.terminal.log`);
2658
2564
  fs3.appendFileSync(filePath, delta, "utf-8");
2659
2565
  this.lastSeenTerminal.set(dedupKey, next);
2660
2566
  if (!this.rotated) {
@@ -2678,10 +2584,10 @@ ${next}`;
2678
2584
  const cutoff = Date.now() - RETAIN_DAYS * 24 * 60 * 60 * 1e3;
2679
2585
  const agentDirs = fs3.readdirSync(HISTORY_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
2680
2586
  for (const dir of agentDirs) {
2681
- const dirPath = path5.join(HISTORY_DIR, dir.name);
2587
+ const dirPath = path4.join(HISTORY_DIR, dir.name);
2682
2588
  const files = fs3.readdirSync(dirPath).filter((f) => f.endsWith(".jsonl") || f.endsWith(".terminal.log"));
2683
2589
  for (const file2 of files) {
2684
- const filePath = path5.join(dirPath, file2);
2590
+ const filePath = path4.join(dirPath, file2);
2685
2591
  const stat4 = fs3.statSync(filePath);
2686
2592
  if (stat4.mtimeMs < cutoff) {
2687
2593
  fs3.unlinkSync(filePath);
@@ -3583,6 +3489,14 @@ function buildSessionEntries(allStates, cdpManagers) {
3583
3489
  for (const state of acpStates) {
3584
3490
  sessions.push(buildAcpSession(state));
3585
3491
  }
3492
+ const extensionParentIds = new Set(
3493
+ sessions.filter((session) => session.transport === "cdp-webview" && !!session.parentId).map((session) => session.parentId)
3494
+ );
3495
+ for (const session of sessions) {
3496
+ if (session.transport === "cdp-page" && extensionParentIds.has(session.id)) {
3497
+ session.surfaceHidden = true;
3498
+ }
3499
+ }
3586
3500
  return sessions;
3587
3501
  }
3588
3502
  var IDE_SESSION_CAPABILITIES, EXTENSION_SESSION_CAPABILITIES, PTY_SESSION_CAPABILITIES, ACP_SESSION_CAPABILITIES;
@@ -4652,11 +4566,11 @@ function resolveSafePath(requestedPath) {
4652
4566
  const home = os6.homedir();
4653
4567
  let resolved;
4654
4568
  if (requestedPath.startsWith("~")) {
4655
- resolved = path6.join(home, requestedPath.slice(1));
4656
- } else if (path6.isAbsolute(requestedPath)) {
4569
+ resolved = path5.join(home, requestedPath.slice(1));
4570
+ } else if (path5.isAbsolute(requestedPath)) {
4657
4571
  resolved = requestedPath;
4658
4572
  } else {
4659
- resolved = path6.resolve(requestedPath);
4573
+ resolved = path5.resolve(requestedPath);
4660
4574
  }
4661
4575
  return resolved;
4662
4576
  }
@@ -4672,7 +4586,7 @@ async function handleFileRead(h, args) {
4672
4586
  async function handleFileWrite(h, args) {
4673
4587
  try {
4674
4588
  const filePath = resolveSafePath(args?.path);
4675
- fs4.mkdirSync(path6.dirname(filePath), { recursive: true });
4589
+ fs4.mkdirSync(path5.dirname(filePath), { recursive: true });
4676
4590
  fs4.writeFileSync(filePath, args?.content || "", "utf-8");
4677
4591
  return { success: true, path: filePath };
4678
4592
  } catch (e) {
@@ -4686,7 +4600,7 @@ async function handleFileList(h, args) {
4686
4600
  const files = entries.map((e) => ({
4687
4601
  name: e.name,
4688
4602
  type: e.isDirectory() ? "directory" : "file",
4689
- size: e.isFile() ? fs4.statSync(path6.join(dirPath, e.name)).size : void 0
4603
+ size: e.isFile() ? fs4.statSync(path5.join(dirPath, e.name)).size : void 0
4690
4604
  }));
4691
4605
  return { success: true, files, path: dirPath };
4692
4606
  } catch (e) {
@@ -4696,12 +4610,12 @@ async function handleFileList(h, args) {
4696
4610
  async function handleFileListBrowse(h, args) {
4697
4611
  return handleFileList(h, args);
4698
4612
  }
4699
- var fs4, path6, os6, KEY_TO_VK;
4613
+ var fs4, path5, os6, KEY_TO_VK;
4700
4614
  var init_cdp_commands = __esm({
4701
4615
  "../../oss/packages/daemon-core/src/commands/cdp-commands.ts"() {
4702
4616
  "use strict";
4703
4617
  fs4 = __toESM(require("fs"));
4704
- path6 = __toESM(require("path"));
4618
+ path5 = __toESM(require("path"));
4705
4619
  os6 = __toESM(require("os"));
4706
4620
  KEY_TO_VK = {
4707
4621
  Backspace: 8,
@@ -4894,13 +4808,12 @@ function handleGetIdeExtensions(h, args) {
4894
4808
  const loader = h.ctx.providerLoader;
4895
4809
  if (!loader) return { success: false, error: "ProviderLoader not initialized" };
4896
4810
  const allExtProviders = loader.getByCategory?.("extension") || [];
4897
- const config2 = loadConfig();
4898
4811
  if (ideType) {
4899
4812
  const extensions = allExtProviders.map((p) => ({
4900
4813
  type: p.type,
4901
4814
  name: p.name,
4902
4815
  extensionId: p.extensionId,
4903
- enabled: config2.ideSettings?.[ideType]?.extensions?.[p.type]?.enabled === true
4816
+ enabled: loader.getIdeExtensionEnabledState?.(ideType, p.type) === true
4904
4817
  }));
4905
4818
  return { success: true, ideType, extensions };
4906
4819
  }
@@ -4911,7 +4824,7 @@ function handleGetIdeExtensions(h, args) {
4911
4824
  type: p.type,
4912
4825
  name: p.name,
4913
4826
  extensionId: p.extensionId,
4914
- enabled: config2.ideSettings?.[ide]?.extensions?.[p.type]?.enabled === true
4827
+ enabled: loader.getIdeExtensionEnabledState?.(ide, p.type) === true
4915
4828
  }));
4916
4829
  }
4917
4830
  return { success: true, ideExtensions: result };
@@ -4934,7 +4847,6 @@ function handleSetIdeExtension(h, args) {
4934
4847
  var init_stream_commands = __esm({
4935
4848
  "../../oss/packages/daemon-core/src/commands/stream-commands.ts"() {
4936
4849
  "use strict";
4937
- init_config();
4938
4850
  init_logger();
4939
4851
  }
4940
4852
  });
@@ -4947,9 +4859,7 @@ function handleWorkspaceList() {
4947
4859
  success: true,
4948
4860
  workspaces: state.workspaces,
4949
4861
  defaultWorkspaceId: state.defaultWorkspaceId,
4950
- defaultWorkspacePath: state.defaultWorkspacePath,
4951
- legacyRecentPaths: config2.recentCliWorkspaces || [],
4952
- activity: getWorkspaceActivity(config2, 25)
4862
+ defaultWorkspacePath: state.defaultWorkspacePath
4953
4863
  };
4954
4864
  }
4955
4865
  function handleWorkspaceAdd(args) {
@@ -4960,10 +4870,9 @@ function handleWorkspaceAdd(args) {
4960
4870
  const config2 = loadConfig();
4961
4871
  const result = addWorkspaceEntry(config2, rawPath, label, { createIfMissing });
4962
4872
  if ("error" in result) return { success: false, error: result.error };
4963
- let cfg = appendWorkspaceActivity(result.config, result.entry.path, {});
4964
- saveConfig(cfg);
4965
- const state = getWorkspaceState(cfg);
4966
- return { success: true, entry: result.entry, ...state, activity: getWorkspaceActivity(cfg, 25) };
4873
+ saveConfig(result.config);
4874
+ const state = getWorkspaceState(result.config);
4875
+ return { success: true, entry: result.entry, ...state };
4967
4876
  }
4968
4877
  function handleWorkspaceRemove(args) {
4969
4878
  const id = (args?.id || "").trim();
@@ -4972,13 +4881,9 @@ function handleWorkspaceRemove(args) {
4972
4881
  const removed = (config2.workspaces || []).find((w) => w.id === id);
4973
4882
  const result = removeWorkspaceEntry(config2, id);
4974
4883
  if ("error" in result) return { success: false, error: result.error };
4975
- let cfg = result.config;
4976
- if (removed) {
4977
- cfg = removeActivityForPath(cfg, removed.path);
4978
- }
4979
- saveConfig(cfg);
4980
- const state = getWorkspaceState(cfg);
4981
- return { success: true, removedId: id, ...state, activity: getWorkspaceActivity(cfg, 25) };
4884
+ saveConfig(result.config);
4885
+ const state = getWorkspaceState(result.config);
4886
+ return { success: true, removedId: id, ...state };
4982
4887
  }
4983
4888
  function handleWorkspaceSetDefault(args) {
4984
4889
  const clear = args?.clear === true || args?.id === null || args?.id === "";
@@ -4990,8 +4895,7 @@ function handleWorkspaceSetDefault(args) {
4990
4895
  const state2 = getWorkspaceState(result2.config);
4991
4896
  return {
4992
4897
  success: true,
4993
- ...state2,
4994
- activity: getWorkspaceActivity(result2.config, 25)
4898
+ ...state2
4995
4899
  };
4996
4900
  }
4997
4901
  const pathArg = args?.path != null && String(args.path).trim() ? String(args.path).trim() : "";
@@ -5015,21 +4919,15 @@ function handleWorkspaceSetDefault(args) {
5015
4919
  }
5016
4920
  const result = setDefaultWorkspaceId(config2, nextId);
5017
4921
  if ("error" in result) return { success: false, error: result.error };
5018
- let out = result.config;
5019
- const ap = getDefaultWorkspacePath(out);
5020
- if (ap) {
5021
- out = appendWorkspaceActivity(out, ap, { kind: "default" });
5022
- }
5023
- saveConfig(out);
5024
- const state = getWorkspaceState(out);
5025
- return { success: true, ...state, activity: getWorkspaceActivity(out, 25) };
4922
+ saveConfig(result.config);
4923
+ const state = getWorkspaceState(result.config);
4924
+ return { success: true, ...state };
5026
4925
  }
5027
4926
  var init_workspace_commands = __esm({
5028
4927
  "../../oss/packages/daemon-core/src/commands/workspace-commands.ts"() {
5029
4928
  "use strict";
5030
4929
  init_config();
5031
4930
  init_workspaces();
5032
- init_workspace_activity();
5033
4931
  }
5034
4932
  });
5035
4933
 
@@ -5108,15 +5006,12 @@ var init_handler = __esm({
5108
5006
  "use strict";
5109
5007
  init_devtools();
5110
5008
  init_builders();
5111
- init_config();
5112
5009
  init_chat_history();
5113
5010
  init_logger();
5114
5011
  init_chat_commands();
5115
5012
  init_cdp_commands();
5116
5013
  init_stream_commands();
5117
5014
  init_workspace_commands();
5118
- init_workspaces();
5119
- init_workspace_activity();
5120
5015
  COMMAND_DEBUG_LEVELS = /* @__PURE__ */ new Set([
5121
5016
  "pty_input",
5122
5017
  "pty_resize",
@@ -5375,22 +5270,7 @@ var init_handler = __esm({
5375
5270
  return handleFileList(this, args);
5376
5271
  case "file_list_browse":
5377
5272
  return handleFileListBrowse(this, args);
5378
- // ─── VSCode API commands (not available) ────
5379
- case "vscode_command_exec":
5380
- case "execute_vscode_command": {
5381
- const resolvedCmd = args?.commandId || args?.command;
5382
- if (resolvedCmd === "adhdev.captureCdpScreenshot") {
5383
- return handleScreenshot(this, args);
5384
- }
5385
- return { success: false, error: `VSCode command not available: ${resolvedCmd || cmd}` };
5386
- }
5387
5273
  // ─── Workspace cmds ──────────────
5388
- case "get_recent_workspaces":
5389
- return this.handleGetRecentWorkspaces(args);
5390
- case "get_cli_history": {
5391
- const config2 = loadConfig();
5392
- return { success: true, history: config2.cliHistory || [] };
5393
- }
5394
5274
  case "workspace_list":
5395
5275
  return handleWorkspaceList();
5396
5276
  case "workspace_add":
@@ -5398,7 +5278,6 @@ var init_handler = __esm({
5398
5278
  case "workspace_remove":
5399
5279
  return handleWorkspaceRemove(args);
5400
5280
  case "workspace_set_default":
5401
- case "workspace_set_active":
5402
5281
  return handleWorkspaceSetDefault(args);
5403
5282
  // ─── Script manage ───────────────────
5404
5283
  case "refresh_scripts":
@@ -5444,19 +5323,6 @@ var init_handler = __esm({
5444
5323
  }
5445
5324
  }
5446
5325
  // ─── Misc (kept in handler — too small to extract) ───────
5447
- async handleGetRecentWorkspaces(_args) {
5448
- const config2 = loadConfig();
5449
- const cliRecent = config2.recentCliWorkspaces || [];
5450
- const ws2 = getWorkspaceState(config2);
5451
- return {
5452
- success: true,
5453
- result: cliRecent,
5454
- workspaces: ws2.workspaces,
5455
- defaultWorkspaceId: ws2.defaultWorkspaceId,
5456
- defaultWorkspacePath: ws2.defaultWorkspacePath,
5457
- activity: getWorkspaceActivity(config2, 25)
5458
- };
5459
- }
5460
5326
  async handleRefreshScripts(_args) {
5461
5327
  if (this._ctx.providerLoader) {
5462
5328
  await this._ctx.providerLoader.fetchLatest().catch(() => {
@@ -5474,7 +5340,7 @@ var init_handler = __esm({
5474
5340
  try {
5475
5341
  const http3 = await import("http");
5476
5342
  const postData = JSON.stringify(body);
5477
- const result = await new Promise((resolve13, reject) => {
5343
+ const result = await new Promise((resolve12, reject) => {
5478
5344
  const req = http3.request({
5479
5345
  hostname: "127.0.0.1",
5480
5346
  port: 19280,
@@ -5486,9 +5352,9 @@ var init_handler = __esm({
5486
5352
  res.on("data", (chunk) => data += chunk);
5487
5353
  res.on("end", () => {
5488
5354
  try {
5489
- resolve13(JSON.parse(data));
5355
+ resolve12(JSON.parse(data));
5490
5356
  } catch {
5491
- resolve13({ raw: data });
5357
+ resolve12({ raw: data });
5492
5358
  }
5493
5359
  });
5494
5360
  });
@@ -5506,15 +5372,15 @@ var init_handler = __esm({
5506
5372
  if (!providerType) return { success: false, error: "providerType required" };
5507
5373
  try {
5508
5374
  const http3 = await import("http");
5509
- const result = await new Promise((resolve13, reject) => {
5375
+ const result = await new Promise((resolve12, reject) => {
5510
5376
  http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
5511
5377
  let data = "";
5512
5378
  res.on("data", (chunk) => data += chunk);
5513
5379
  res.on("end", () => {
5514
5380
  try {
5515
- resolve13(JSON.parse(data));
5381
+ resolve12(JSON.parse(data));
5516
5382
  } catch {
5517
- resolve13({ raw: data });
5383
+ resolve12({ raw: data });
5518
5384
  }
5519
5385
  });
5520
5386
  }).on("error", reject);
@@ -5528,7 +5394,7 @@ var init_handler = __esm({
5528
5394
  try {
5529
5395
  const http3 = await import("http");
5530
5396
  const postData = JSON.stringify(args || {});
5531
- const result = await new Promise((resolve13, reject) => {
5397
+ const result = await new Promise((resolve12, reject) => {
5532
5398
  const req = http3.request({
5533
5399
  hostname: "127.0.0.1",
5534
5400
  port: 19280,
@@ -5540,9 +5406,9 @@ var init_handler = __esm({
5540
5406
  res.on("data", (chunk) => data += chunk);
5541
5407
  res.on("end", () => {
5542
5408
  try {
5543
- resolve13(JSON.parse(data));
5409
+ resolve12(JSON.parse(data));
5544
5410
  } catch {
5545
- resolve13({ raw: data });
5411
+ resolve12({ raw: data });
5546
5412
  }
5547
5413
  });
5548
5414
  });
@@ -5663,7 +5529,7 @@ var init_readdirp = __esm({
5663
5529
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
5664
5530
  const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
5665
5531
  if (wantBigintFsStats) {
5666
- this._stat = (path19) => statMethod(path19, { bigint: true });
5532
+ this._stat = (path18) => statMethod(path18, { bigint: true });
5667
5533
  } else {
5668
5534
  this._stat = statMethod;
5669
5535
  }
@@ -5688,8 +5554,8 @@ var init_readdirp = __esm({
5688
5554
  const par = this.parent;
5689
5555
  const fil = par && par.files;
5690
5556
  if (fil && fil.length > 0) {
5691
- const { path: path19, depth } = par;
5692
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path19));
5557
+ const { path: path18, depth } = par;
5558
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path18));
5693
5559
  const awaited = await Promise.all(slice);
5694
5560
  for (const entry of awaited) {
5695
5561
  if (!entry)
@@ -5729,20 +5595,20 @@ var init_readdirp = __esm({
5729
5595
  this.reading = false;
5730
5596
  }
5731
5597
  }
5732
- async _exploreDir(path19, depth) {
5598
+ async _exploreDir(path18, depth) {
5733
5599
  let files;
5734
5600
  try {
5735
- files = await (0, import_promises.readdir)(path19, this._rdOptions);
5601
+ files = await (0, import_promises.readdir)(path18, this._rdOptions);
5736
5602
  } catch (error48) {
5737
5603
  this._onError(error48);
5738
5604
  }
5739
- return { files, depth, path: path19 };
5605
+ return { files, depth, path: path18 };
5740
5606
  }
5741
- async _formatEntry(dirent, path19) {
5607
+ async _formatEntry(dirent, path18) {
5742
5608
  let entry;
5743
5609
  const basename7 = this._isDirent ? dirent.name : dirent;
5744
5610
  try {
5745
- const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path19, basename7));
5611
+ const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path18, basename7));
5746
5612
  entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename7 };
5747
5613
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
5748
5614
  } catch (err) {
@@ -5799,16 +5665,16 @@ var init_readdirp = __esm({
5799
5665
  });
5800
5666
 
5801
5667
  // ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
5802
- function createFsWatchInstance(path19, options, listener, errHandler, emitRaw) {
5668
+ function createFsWatchInstance(path18, options, listener, errHandler, emitRaw) {
5803
5669
  const handleEvent = (rawEvent, evPath) => {
5804
- listener(path19);
5805
- emitRaw(rawEvent, evPath, { watchedPath: path19 });
5806
- if (evPath && path19 !== evPath) {
5807
- fsWatchBroadcast(sp.resolve(path19, evPath), KEY_LISTENERS, sp.join(path19, evPath));
5670
+ listener(path18);
5671
+ emitRaw(rawEvent, evPath, { watchedPath: path18 });
5672
+ if (evPath && path18 !== evPath) {
5673
+ fsWatchBroadcast(sp.resolve(path18, evPath), KEY_LISTENERS, sp.join(path18, evPath));
5808
5674
  }
5809
5675
  };
5810
5676
  try {
5811
- return (0, import_node_fs.watch)(path19, {
5677
+ return (0, import_node_fs.watch)(path18, {
5812
5678
  persistent: options.persistent
5813
5679
  }, handleEvent);
5814
5680
  } catch (error48) {
@@ -6157,12 +6023,12 @@ var init_handler2 = __esm({
6157
6023
  listener(val1, val2, val3);
6158
6024
  });
6159
6025
  };
6160
- setFsWatchListener = (path19, fullPath, options, handlers) => {
6026
+ setFsWatchListener = (path18, fullPath, options, handlers) => {
6161
6027
  const { listener, errHandler, rawEmitter } = handlers;
6162
6028
  let cont = FsWatchInstances.get(fullPath);
6163
6029
  let watcher;
6164
6030
  if (!options.persistent) {
6165
- watcher = createFsWatchInstance(path19, options, listener, errHandler, rawEmitter);
6031
+ watcher = createFsWatchInstance(path18, options, listener, errHandler, rawEmitter);
6166
6032
  if (!watcher)
6167
6033
  return;
6168
6034
  return watcher.close.bind(watcher);
@@ -6173,7 +6039,7 @@ var init_handler2 = __esm({
6173
6039
  addAndConvert(cont, KEY_RAW, rawEmitter);
6174
6040
  } else {
6175
6041
  watcher = createFsWatchInstance(
6176
- path19,
6042
+ path18,
6177
6043
  options,
6178
6044
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
6179
6045
  errHandler,
@@ -6188,7 +6054,7 @@ var init_handler2 = __esm({
6188
6054
  cont.watcherUnusable = true;
6189
6055
  if (isWindows && error48.code === "EPERM") {
6190
6056
  try {
6191
- const fd = await (0, import_promises2.open)(path19, "r");
6057
+ const fd = await (0, import_promises2.open)(path18, "r");
6192
6058
  await fd.close();
6193
6059
  broadcastErr(error48);
6194
6060
  } catch (err) {
@@ -6219,7 +6085,7 @@ var init_handler2 = __esm({
6219
6085
  };
6220
6086
  };
6221
6087
  FsWatchFileInstances = /* @__PURE__ */ new Map();
6222
- setFsWatchFileListener = (path19, fullPath, options, handlers) => {
6088
+ setFsWatchFileListener = (path18, fullPath, options, handlers) => {
6223
6089
  const { listener, rawEmitter } = handlers;
6224
6090
  let cont = FsWatchFileInstances.get(fullPath);
6225
6091
  const copts = cont && cont.options;
@@ -6241,7 +6107,7 @@ var init_handler2 = __esm({
6241
6107
  });
6242
6108
  const currmtime = curr.mtimeMs;
6243
6109
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
6244
- foreach(cont.listeners, (listener2) => listener2(path19, curr));
6110
+ foreach(cont.listeners, (listener2) => listener2(path18, curr));
6245
6111
  }
6246
6112
  })
6247
6113
  };
@@ -6271,13 +6137,13 @@ var init_handler2 = __esm({
6271
6137
  * @param listener on fs change
6272
6138
  * @returns closer for the watcher instance
6273
6139
  */
6274
- _watchWithNodeFs(path19, listener) {
6140
+ _watchWithNodeFs(path18, listener) {
6275
6141
  const opts = this.fsw.options;
6276
- const directory = sp.dirname(path19);
6277
- const basename7 = sp.basename(path19);
6142
+ const directory = sp.dirname(path18);
6143
+ const basename7 = sp.basename(path18);
6278
6144
  const parent = this.fsw._getWatchedDir(directory);
6279
6145
  parent.add(basename7);
6280
- const absolutePath = sp.resolve(path19);
6146
+ const absolutePath = sp.resolve(path18);
6281
6147
  const options = {
6282
6148
  persistent: opts.persistent
6283
6149
  };
@@ -6287,12 +6153,12 @@ var init_handler2 = __esm({
6287
6153
  if (opts.usePolling) {
6288
6154
  const enableBin = opts.interval !== opts.binaryInterval;
6289
6155
  options.interval = enableBin && isBinaryPath(basename7) ? opts.binaryInterval : opts.interval;
6290
- closer = setFsWatchFileListener(path19, absolutePath, options, {
6156
+ closer = setFsWatchFileListener(path18, absolutePath, options, {
6291
6157
  listener,
6292
6158
  rawEmitter: this.fsw._emitRaw
6293
6159
  });
6294
6160
  } else {
6295
- closer = setFsWatchListener(path19, absolutePath, options, {
6161
+ closer = setFsWatchListener(path18, absolutePath, options, {
6296
6162
  listener,
6297
6163
  errHandler: this._boundHandleError,
6298
6164
  rawEmitter: this.fsw._emitRaw
@@ -6314,7 +6180,7 @@ var init_handler2 = __esm({
6314
6180
  let prevStats = stats;
6315
6181
  if (parent.has(basename7))
6316
6182
  return;
6317
- const listener = async (path19, newStats) => {
6183
+ const listener = async (path18, newStats) => {
6318
6184
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
6319
6185
  return;
6320
6186
  if (!newStats || newStats.mtimeMs === 0) {
@@ -6328,11 +6194,11 @@ var init_handler2 = __esm({
6328
6194
  this.fsw._emit(EV.CHANGE, file2, newStats2);
6329
6195
  }
6330
6196
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
6331
- this.fsw._closeFile(path19);
6197
+ this.fsw._closeFile(path18);
6332
6198
  prevStats = newStats2;
6333
6199
  const closer2 = this._watchWithNodeFs(file2, listener);
6334
6200
  if (closer2)
6335
- this.fsw._addPathCloser(path19, closer2);
6201
+ this.fsw._addPathCloser(path18, closer2);
6336
6202
  } else {
6337
6203
  prevStats = newStats2;
6338
6204
  }
@@ -6364,7 +6230,7 @@ var init_handler2 = __esm({
6364
6230
  * @param item basename of this item
6365
6231
  * @returns true if no more processing is needed for this entry.
6366
6232
  */
6367
- async _handleSymlink(entry, directory, path19, item) {
6233
+ async _handleSymlink(entry, directory, path18, item) {
6368
6234
  if (this.fsw.closed) {
6369
6235
  return;
6370
6236
  }
@@ -6374,7 +6240,7 @@ var init_handler2 = __esm({
6374
6240
  this.fsw._incrReadyCount();
6375
6241
  let linkPath;
6376
6242
  try {
6377
- linkPath = await (0, import_promises2.realpath)(path19);
6243
+ linkPath = await (0, import_promises2.realpath)(path18);
6378
6244
  } catch (e) {
6379
6245
  this.fsw._emitReady();
6380
6246
  return true;
@@ -6384,12 +6250,12 @@ var init_handler2 = __esm({
6384
6250
  if (dir.has(item)) {
6385
6251
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
6386
6252
  this.fsw._symlinkPaths.set(full, linkPath);
6387
- this.fsw._emit(EV.CHANGE, path19, entry.stats);
6253
+ this.fsw._emit(EV.CHANGE, path18, entry.stats);
6388
6254
  }
6389
6255
  } else {
6390
6256
  dir.add(item);
6391
6257
  this.fsw._symlinkPaths.set(full, linkPath);
6392
- this.fsw._emit(EV.ADD, path19, entry.stats);
6258
+ this.fsw._emit(EV.ADD, path18, entry.stats);
6393
6259
  }
6394
6260
  this.fsw._emitReady();
6395
6261
  return true;
@@ -6419,9 +6285,9 @@ var init_handler2 = __esm({
6419
6285
  return;
6420
6286
  }
6421
6287
  const item = entry.path;
6422
- let path19 = sp.join(directory, item);
6288
+ let path18 = sp.join(directory, item);
6423
6289
  current.add(item);
6424
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path19, item)) {
6290
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path18, item)) {
6425
6291
  return;
6426
6292
  }
6427
6293
  if (this.fsw.closed) {
@@ -6430,11 +6296,11 @@ var init_handler2 = __esm({
6430
6296
  }
6431
6297
  if (item === target || !target && !previous.has(item)) {
6432
6298
  this.fsw._incrReadyCount();
6433
- path19 = sp.join(dir, sp.relative(dir, path19));
6434
- this._addToNodeFs(path19, initialAdd, wh, depth + 1);
6299
+ path18 = sp.join(dir, sp.relative(dir, path18));
6300
+ this._addToNodeFs(path18, initialAdd, wh, depth + 1);
6435
6301
  }
6436
6302
  }).on(EV.ERROR, this._boundHandleError);
6437
- return new Promise((resolve13, reject) => {
6303
+ return new Promise((resolve12, reject) => {
6438
6304
  if (!stream)
6439
6305
  return reject();
6440
6306
  stream.once(STR_END, () => {
@@ -6443,7 +6309,7 @@ var init_handler2 = __esm({
6443
6309
  return;
6444
6310
  }
6445
6311
  const wasThrottled = throttler ? throttler.clear() : false;
6446
- resolve13(void 0);
6312
+ resolve12(void 0);
6447
6313
  previous.getChildren().filter((item) => {
6448
6314
  return item !== directory && !current.has(item);
6449
6315
  }).forEach((item) => {
@@ -6500,13 +6366,13 @@ var init_handler2 = __esm({
6500
6366
  * @param depth Child path actually targeted for watch
6501
6367
  * @param target Child path actually targeted for watch
6502
6368
  */
6503
- async _addToNodeFs(path19, initialAdd, priorWh, depth, target) {
6369
+ async _addToNodeFs(path18, initialAdd, priorWh, depth, target) {
6504
6370
  const ready = this.fsw._emitReady;
6505
- if (this.fsw._isIgnored(path19) || this.fsw.closed) {
6371
+ if (this.fsw._isIgnored(path18) || this.fsw.closed) {
6506
6372
  ready();
6507
6373
  return false;
6508
6374
  }
6509
- const wh = this.fsw._getWatchHelpers(path19);
6375
+ const wh = this.fsw._getWatchHelpers(path18);
6510
6376
  if (priorWh) {
6511
6377
  wh.filterPath = (entry) => priorWh.filterPath(entry);
6512
6378
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -6522,8 +6388,8 @@ var init_handler2 = __esm({
6522
6388
  const follow = this.fsw.options.followSymlinks;
6523
6389
  let closer;
6524
6390
  if (stats.isDirectory()) {
6525
- const absPath = sp.resolve(path19);
6526
- const targetPath = follow ? await (0, import_promises2.realpath)(path19) : path19;
6391
+ const absPath = sp.resolve(path18);
6392
+ const targetPath = follow ? await (0, import_promises2.realpath)(path18) : path18;
6527
6393
  if (this.fsw.closed)
6528
6394
  return;
6529
6395
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -6533,29 +6399,29 @@ var init_handler2 = __esm({
6533
6399
  this.fsw._symlinkPaths.set(absPath, targetPath);
6534
6400
  }
6535
6401
  } else if (stats.isSymbolicLink()) {
6536
- const targetPath = follow ? await (0, import_promises2.realpath)(path19) : path19;
6402
+ const targetPath = follow ? await (0, import_promises2.realpath)(path18) : path18;
6537
6403
  if (this.fsw.closed)
6538
6404
  return;
6539
6405
  const parent = sp.dirname(wh.watchPath);
6540
6406
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
6541
6407
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
6542
- closer = await this._handleDir(parent, stats, initialAdd, depth, path19, wh, targetPath);
6408
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path18, wh, targetPath);
6543
6409
  if (this.fsw.closed)
6544
6410
  return;
6545
6411
  if (targetPath !== void 0) {
6546
- this.fsw._symlinkPaths.set(sp.resolve(path19), targetPath);
6412
+ this.fsw._symlinkPaths.set(sp.resolve(path18), targetPath);
6547
6413
  }
6548
6414
  } else {
6549
6415
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
6550
6416
  }
6551
6417
  ready();
6552
6418
  if (closer)
6553
- this.fsw._addPathCloser(path19, closer);
6419
+ this.fsw._addPathCloser(path18, closer);
6554
6420
  return false;
6555
6421
  } catch (error48) {
6556
6422
  if (this.fsw._handleError(error48)) {
6557
6423
  ready();
6558
- return path19;
6424
+ return path18;
6559
6425
  }
6560
6426
  }
6561
6427
  }
@@ -6590,24 +6456,24 @@ function createPattern(matcher) {
6590
6456
  }
6591
6457
  return () => false;
6592
6458
  }
6593
- function normalizePath(path19) {
6594
- if (typeof path19 !== "string")
6459
+ function normalizePath(path18) {
6460
+ if (typeof path18 !== "string")
6595
6461
  throw new Error("string expected");
6596
- path19 = sp2.normalize(path19);
6597
- path19 = path19.replace(/\\/g, "/");
6462
+ path18 = sp2.normalize(path18);
6463
+ path18 = path18.replace(/\\/g, "/");
6598
6464
  let prepend = false;
6599
- if (path19.startsWith("//"))
6465
+ if (path18.startsWith("//"))
6600
6466
  prepend = true;
6601
- path19 = path19.replace(DOUBLE_SLASH_RE, "/");
6467
+ path18 = path18.replace(DOUBLE_SLASH_RE, "/");
6602
6468
  if (prepend)
6603
- path19 = "/" + path19;
6604
- return path19;
6469
+ path18 = "/" + path18;
6470
+ return path18;
6605
6471
  }
6606
6472
  function matchPatterns(patterns, testString, stats) {
6607
- const path19 = normalizePath(testString);
6473
+ const path18 = normalizePath(testString);
6608
6474
  for (let index = 0; index < patterns.length; index++) {
6609
6475
  const pattern = patterns[index];
6610
- if (pattern(path19, stats)) {
6476
+ if (pattern(path18, stats)) {
6611
6477
  return true;
6612
6478
  }
6613
6479
  }
@@ -6670,19 +6536,19 @@ var init_chokidar = __esm({
6670
6536
  }
6671
6537
  return str;
6672
6538
  };
6673
- normalizePathToUnix = (path19) => toUnix(sp2.normalize(toUnix(path19)));
6674
- normalizeIgnored = (cwd = "") => (path19) => {
6675
- if (typeof path19 === "string") {
6676
- return normalizePathToUnix(sp2.isAbsolute(path19) ? path19 : sp2.join(cwd, path19));
6539
+ normalizePathToUnix = (path18) => toUnix(sp2.normalize(toUnix(path18)));
6540
+ normalizeIgnored = (cwd = "") => (path18) => {
6541
+ if (typeof path18 === "string") {
6542
+ return normalizePathToUnix(sp2.isAbsolute(path18) ? path18 : sp2.join(cwd, path18));
6677
6543
  } else {
6678
- return path19;
6544
+ return path18;
6679
6545
  }
6680
6546
  };
6681
- getAbsolutePath = (path19, cwd) => {
6682
- if (sp2.isAbsolute(path19)) {
6683
- return path19;
6547
+ getAbsolutePath = (path18, cwd) => {
6548
+ if (sp2.isAbsolute(path18)) {
6549
+ return path18;
6684
6550
  }
6685
- return sp2.join(cwd, path19);
6551
+ return sp2.join(cwd, path18);
6686
6552
  };
6687
6553
  EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
6688
6554
  DirEntry = class {
@@ -6747,10 +6613,10 @@ var init_chokidar = __esm({
6747
6613
  dirParts;
6748
6614
  followSymlinks;
6749
6615
  statMethod;
6750
- constructor(path19, follow, fsw) {
6616
+ constructor(path18, follow, fsw) {
6751
6617
  this.fsw = fsw;
6752
- const watchPath = path19;
6753
- this.path = path19 = path19.replace(REPLACER_RE, "");
6618
+ const watchPath = path18;
6619
+ this.path = path18 = path18.replace(REPLACER_RE, "");
6754
6620
  this.watchPath = watchPath;
6755
6621
  this.fullWatchPath = sp2.resolve(watchPath);
6756
6622
  this.dirParts = [];
@@ -6890,20 +6756,20 @@ var init_chokidar = __esm({
6890
6756
  this._closePromise = void 0;
6891
6757
  let paths = unifyPaths(paths_);
6892
6758
  if (cwd) {
6893
- paths = paths.map((path19) => {
6894
- const absPath = getAbsolutePath(path19, cwd);
6759
+ paths = paths.map((path18) => {
6760
+ const absPath = getAbsolutePath(path18, cwd);
6895
6761
  return absPath;
6896
6762
  });
6897
6763
  }
6898
- paths.forEach((path19) => {
6899
- this._removeIgnoredPath(path19);
6764
+ paths.forEach((path18) => {
6765
+ this._removeIgnoredPath(path18);
6900
6766
  });
6901
6767
  this._userIgnored = void 0;
6902
6768
  if (!this._readyCount)
6903
6769
  this._readyCount = 0;
6904
6770
  this._readyCount += paths.length;
6905
- Promise.all(paths.map(async (path19) => {
6906
- const res = await this._nodeFsHandler._addToNodeFs(path19, !_internal, void 0, 0, _origAdd);
6771
+ Promise.all(paths.map(async (path18) => {
6772
+ const res = await this._nodeFsHandler._addToNodeFs(path18, !_internal, void 0, 0, _origAdd);
6907
6773
  if (res)
6908
6774
  this._emitReady();
6909
6775
  return res;
@@ -6925,17 +6791,17 @@ var init_chokidar = __esm({
6925
6791
  return this;
6926
6792
  const paths = unifyPaths(paths_);
6927
6793
  const { cwd } = this.options;
6928
- paths.forEach((path19) => {
6929
- if (!sp2.isAbsolute(path19) && !this._closers.has(path19)) {
6794
+ paths.forEach((path18) => {
6795
+ if (!sp2.isAbsolute(path18) && !this._closers.has(path18)) {
6930
6796
  if (cwd)
6931
- path19 = sp2.join(cwd, path19);
6932
- path19 = sp2.resolve(path19);
6797
+ path18 = sp2.join(cwd, path18);
6798
+ path18 = sp2.resolve(path18);
6933
6799
  }
6934
- this._closePath(path19);
6935
- this._addIgnoredPath(path19);
6936
- if (this._watched.has(path19)) {
6800
+ this._closePath(path18);
6801
+ this._addIgnoredPath(path18);
6802
+ if (this._watched.has(path18)) {
6937
6803
  this._addIgnoredPath({
6938
- path: path19,
6804
+ path: path18,
6939
6805
  recursive: true
6940
6806
  });
6941
6807
  }
@@ -6999,38 +6865,38 @@ var init_chokidar = __esm({
6999
6865
  * @param stats arguments to be passed with event
7000
6866
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
7001
6867
  */
7002
- async _emit(event, path19, stats) {
6868
+ async _emit(event, path18, stats) {
7003
6869
  if (this.closed)
7004
6870
  return;
7005
6871
  const opts = this.options;
7006
6872
  if (isWindows)
7007
- path19 = sp2.normalize(path19);
6873
+ path18 = sp2.normalize(path18);
7008
6874
  if (opts.cwd)
7009
- path19 = sp2.relative(opts.cwd, path19);
7010
- const args = [path19];
6875
+ path18 = sp2.relative(opts.cwd, path18);
6876
+ const args = [path18];
7011
6877
  if (stats != null)
7012
6878
  args.push(stats);
7013
6879
  const awf = opts.awaitWriteFinish;
7014
6880
  let pw;
7015
- if (awf && (pw = this._pendingWrites.get(path19))) {
6881
+ if (awf && (pw = this._pendingWrites.get(path18))) {
7016
6882
  pw.lastChange = /* @__PURE__ */ new Date();
7017
6883
  return this;
7018
6884
  }
7019
6885
  if (opts.atomic) {
7020
6886
  if (event === EVENTS.UNLINK) {
7021
- this._pendingUnlinks.set(path19, [event, ...args]);
6887
+ this._pendingUnlinks.set(path18, [event, ...args]);
7022
6888
  setTimeout(() => {
7023
- this._pendingUnlinks.forEach((entry, path20) => {
6889
+ this._pendingUnlinks.forEach((entry, path19) => {
7024
6890
  this.emit(...entry);
7025
6891
  this.emit(EVENTS.ALL, ...entry);
7026
- this._pendingUnlinks.delete(path20);
6892
+ this._pendingUnlinks.delete(path19);
7027
6893
  });
7028
6894
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
7029
6895
  return this;
7030
6896
  }
7031
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path19)) {
6897
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path18)) {
7032
6898
  event = EVENTS.CHANGE;
7033
- this._pendingUnlinks.delete(path19);
6899
+ this._pendingUnlinks.delete(path18);
7034
6900
  }
7035
6901
  }
7036
6902
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -7048,16 +6914,16 @@ var init_chokidar = __esm({
7048
6914
  this.emitWithAll(event, args);
7049
6915
  }
7050
6916
  };
7051
- this._awaitWriteFinish(path19, awf.stabilityThreshold, event, awfEmit);
6917
+ this._awaitWriteFinish(path18, awf.stabilityThreshold, event, awfEmit);
7052
6918
  return this;
7053
6919
  }
7054
6920
  if (event === EVENTS.CHANGE) {
7055
- const isThrottled = !this._throttle(EVENTS.CHANGE, path19, 50);
6921
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path18, 50);
7056
6922
  if (isThrottled)
7057
6923
  return this;
7058
6924
  }
7059
6925
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
7060
- const fullPath = opts.cwd ? sp2.join(opts.cwd, path19) : path19;
6926
+ const fullPath = opts.cwd ? sp2.join(opts.cwd, path18) : path18;
7061
6927
  let stats2;
7062
6928
  try {
7063
6929
  stats2 = await (0, import_promises3.stat)(fullPath);
@@ -7088,23 +6954,23 @@ var init_chokidar = __esm({
7088
6954
  * @param timeout duration of time to suppress duplicate actions
7089
6955
  * @returns tracking object or false if action should be suppressed
7090
6956
  */
7091
- _throttle(actionType, path19, timeout) {
6957
+ _throttle(actionType, path18, timeout) {
7092
6958
  if (!this._throttled.has(actionType)) {
7093
6959
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
7094
6960
  }
7095
6961
  const action = this._throttled.get(actionType);
7096
6962
  if (!action)
7097
6963
  throw new Error("invalid throttle");
7098
- const actionPath = action.get(path19);
6964
+ const actionPath = action.get(path18);
7099
6965
  if (actionPath) {
7100
6966
  actionPath.count++;
7101
6967
  return false;
7102
6968
  }
7103
6969
  let timeoutObject;
7104
6970
  const clear = () => {
7105
- const item = action.get(path19);
6971
+ const item = action.get(path18);
7106
6972
  const count = item ? item.count : 0;
7107
- action.delete(path19);
6973
+ action.delete(path18);
7108
6974
  clearTimeout(timeoutObject);
7109
6975
  if (item)
7110
6976
  clearTimeout(item.timeoutObject);
@@ -7112,7 +6978,7 @@ var init_chokidar = __esm({
7112
6978
  };
7113
6979
  timeoutObject = setTimeout(clear, timeout);
7114
6980
  const thr = { timeoutObject, clear, count: 0 };
7115
- action.set(path19, thr);
6981
+ action.set(path18, thr);
7116
6982
  return thr;
7117
6983
  }
7118
6984
  _incrReadyCount() {
@@ -7126,44 +6992,44 @@ var init_chokidar = __esm({
7126
6992
  * @param event
7127
6993
  * @param awfEmit Callback to be called when ready for event to be emitted.
7128
6994
  */
7129
- _awaitWriteFinish(path19, threshold, event, awfEmit) {
6995
+ _awaitWriteFinish(path18, threshold, event, awfEmit) {
7130
6996
  const awf = this.options.awaitWriteFinish;
7131
6997
  if (typeof awf !== "object")
7132
6998
  return;
7133
6999
  const pollInterval = awf.pollInterval;
7134
7000
  let timeoutHandler;
7135
- let fullPath = path19;
7136
- if (this.options.cwd && !sp2.isAbsolute(path19)) {
7137
- fullPath = sp2.join(this.options.cwd, path19);
7001
+ let fullPath = path18;
7002
+ if (this.options.cwd && !sp2.isAbsolute(path18)) {
7003
+ fullPath = sp2.join(this.options.cwd, path18);
7138
7004
  }
7139
7005
  const now = /* @__PURE__ */ new Date();
7140
7006
  const writes = this._pendingWrites;
7141
7007
  function awaitWriteFinishFn(prevStat) {
7142
7008
  (0, import_node_fs2.stat)(fullPath, (err, curStat) => {
7143
- if (err || !writes.has(path19)) {
7009
+ if (err || !writes.has(path18)) {
7144
7010
  if (err && err.code !== "ENOENT")
7145
7011
  awfEmit(err);
7146
7012
  return;
7147
7013
  }
7148
7014
  const now2 = Number(/* @__PURE__ */ new Date());
7149
7015
  if (prevStat && curStat.size !== prevStat.size) {
7150
- writes.get(path19).lastChange = now2;
7016
+ writes.get(path18).lastChange = now2;
7151
7017
  }
7152
- const pw = writes.get(path19);
7018
+ const pw = writes.get(path18);
7153
7019
  const df = now2 - pw.lastChange;
7154
7020
  if (df >= threshold) {
7155
- writes.delete(path19);
7021
+ writes.delete(path18);
7156
7022
  awfEmit(void 0, curStat);
7157
7023
  } else {
7158
7024
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
7159
7025
  }
7160
7026
  });
7161
7027
  }
7162
- if (!writes.has(path19)) {
7163
- writes.set(path19, {
7028
+ if (!writes.has(path18)) {
7029
+ writes.set(path18, {
7164
7030
  lastChange: now,
7165
7031
  cancelWait: () => {
7166
- writes.delete(path19);
7032
+ writes.delete(path18);
7167
7033
  clearTimeout(timeoutHandler);
7168
7034
  return event;
7169
7035
  }
@@ -7174,8 +7040,8 @@ var init_chokidar = __esm({
7174
7040
  /**
7175
7041
  * Determines whether user has asked to ignore this path.
7176
7042
  */
7177
- _isIgnored(path19, stats) {
7178
- if (this.options.atomic && DOT_RE.test(path19))
7043
+ _isIgnored(path18, stats) {
7044
+ if (this.options.atomic && DOT_RE.test(path18))
7179
7045
  return true;
7180
7046
  if (!this._userIgnored) {
7181
7047
  const { cwd } = this.options;
@@ -7185,17 +7051,17 @@ var init_chokidar = __esm({
7185
7051
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
7186
7052
  this._userIgnored = anymatch(list, void 0);
7187
7053
  }
7188
- return this._userIgnored(path19, stats);
7054
+ return this._userIgnored(path18, stats);
7189
7055
  }
7190
- _isntIgnored(path19, stat4) {
7191
- return !this._isIgnored(path19, stat4);
7056
+ _isntIgnored(path18, stat4) {
7057
+ return !this._isIgnored(path18, stat4);
7192
7058
  }
7193
7059
  /**
7194
7060
  * Provides a set of common helpers and properties relating to symlink handling.
7195
7061
  * @param path file or directory pattern being watched
7196
7062
  */
7197
- _getWatchHelpers(path19) {
7198
- return new WatchHelper(path19, this.options.followSymlinks, this);
7063
+ _getWatchHelpers(path18) {
7064
+ return new WatchHelper(path18, this.options.followSymlinks, this);
7199
7065
  }
7200
7066
  // Directory helpers
7201
7067
  // -----------------
@@ -7227,63 +7093,63 @@ var init_chokidar = __esm({
7227
7093
  * @param item base path of item/directory
7228
7094
  */
7229
7095
  _remove(directory, item, isDirectory) {
7230
- const path19 = sp2.join(directory, item);
7231
- const fullPath = sp2.resolve(path19);
7232
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path19) || this._watched.has(fullPath);
7233
- if (!this._throttle("remove", path19, 100))
7096
+ const path18 = sp2.join(directory, item);
7097
+ const fullPath = sp2.resolve(path18);
7098
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path18) || this._watched.has(fullPath);
7099
+ if (!this._throttle("remove", path18, 100))
7234
7100
  return;
7235
7101
  if (!isDirectory && this._watched.size === 1) {
7236
7102
  this.add(directory, item, true);
7237
7103
  }
7238
- const wp = this._getWatchedDir(path19);
7104
+ const wp = this._getWatchedDir(path18);
7239
7105
  const nestedDirectoryChildren = wp.getChildren();
7240
- nestedDirectoryChildren.forEach((nested) => this._remove(path19, nested));
7106
+ nestedDirectoryChildren.forEach((nested) => this._remove(path18, nested));
7241
7107
  const parent = this._getWatchedDir(directory);
7242
7108
  const wasTracked = parent.has(item);
7243
7109
  parent.remove(item);
7244
7110
  if (this._symlinkPaths.has(fullPath)) {
7245
7111
  this._symlinkPaths.delete(fullPath);
7246
7112
  }
7247
- let relPath = path19;
7113
+ let relPath = path18;
7248
7114
  if (this.options.cwd)
7249
- relPath = sp2.relative(this.options.cwd, path19);
7115
+ relPath = sp2.relative(this.options.cwd, path18);
7250
7116
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
7251
7117
  const event = this._pendingWrites.get(relPath).cancelWait();
7252
7118
  if (event === EVENTS.ADD)
7253
7119
  return;
7254
7120
  }
7255
- this._watched.delete(path19);
7121
+ this._watched.delete(path18);
7256
7122
  this._watched.delete(fullPath);
7257
7123
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
7258
- if (wasTracked && !this._isIgnored(path19))
7259
- this._emit(eventName, path19);
7260
- this._closePath(path19);
7124
+ if (wasTracked && !this._isIgnored(path18))
7125
+ this._emit(eventName, path18);
7126
+ this._closePath(path18);
7261
7127
  }
7262
7128
  /**
7263
7129
  * Closes all watchers for a path
7264
7130
  */
7265
- _closePath(path19) {
7266
- this._closeFile(path19);
7267
- const dir = sp2.dirname(path19);
7268
- this._getWatchedDir(dir).remove(sp2.basename(path19));
7131
+ _closePath(path18) {
7132
+ this._closeFile(path18);
7133
+ const dir = sp2.dirname(path18);
7134
+ this._getWatchedDir(dir).remove(sp2.basename(path18));
7269
7135
  }
7270
7136
  /**
7271
7137
  * Closes only file-specific watchers
7272
7138
  */
7273
- _closeFile(path19) {
7274
- const closers = this._closers.get(path19);
7139
+ _closeFile(path18) {
7140
+ const closers = this._closers.get(path18);
7275
7141
  if (!closers)
7276
7142
  return;
7277
7143
  closers.forEach((closer) => closer());
7278
- this._closers.delete(path19);
7144
+ this._closers.delete(path18);
7279
7145
  }
7280
- _addPathCloser(path19, closer) {
7146
+ _addPathCloser(path18, closer) {
7281
7147
  if (!closer)
7282
7148
  return;
7283
- let list = this._closers.get(path19);
7149
+ let list = this._closers.get(path18);
7284
7150
  if (!list) {
7285
7151
  list = [];
7286
- this._closers.set(path19, list);
7152
+ this._closers.set(path18, list);
7287
7153
  }
7288
7154
  list.push(closer);
7289
7155
  }
@@ -7309,12 +7175,12 @@ var init_chokidar = __esm({
7309
7175
  });
7310
7176
 
7311
7177
  // ../../oss/packages/daemon-core/src/providers/provider-loader.ts
7312
- var fs5, path7, os7, ProviderLoader;
7178
+ var fs5, path6, os7, ProviderLoader;
7313
7179
  var init_provider_loader = __esm({
7314
7180
  "../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
7315
7181
  "use strict";
7316
7182
  fs5 = __toESM(require("fs"));
7317
- path7 = __toESM(require("path"));
7183
+ path6 = __toESM(require("path"));
7318
7184
  os7 = __toESM(require("os"));
7319
7185
  init_chokidar();
7320
7186
  init_ide_detector();
@@ -7336,12 +7202,12 @@ var init_provider_loader = __esm({
7336
7202
  static META_FILE = ".meta.json";
7337
7203
  constructor(options) {
7338
7204
  this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
7339
- const defaultProvidersDir = path7.join(os7.homedir(), ".adhdev", "providers");
7205
+ const defaultProvidersDir = path6.join(os7.homedir(), ".adhdev", "providers");
7340
7206
  if (options?.userDir) {
7341
7207
  this.userDir = options.userDir;
7342
7208
  this.log(`Config 'providerDir' applied: ${this.userDir}`);
7343
7209
  } else {
7344
- const localRepoPath = path7.resolve(__dirname, "../../../../../adhdev-providers");
7210
+ const localRepoPath = path6.resolve(__dirname, "../../../../../adhdev-providers");
7345
7211
  if (fs5.existsSync(localRepoPath)) {
7346
7212
  this.userDir = localRepoPath;
7347
7213
  this.log(`Auto-detected local public repository: ${this.userDir} (Dev workspace speedup)`);
@@ -7350,7 +7216,7 @@ var init_provider_loader = __esm({
7350
7216
  this.log(`Using default user providers directory: ${this.userDir}`);
7351
7217
  }
7352
7218
  }
7353
- this.upstreamDir = path7.join(defaultProvidersDir, ".upstream");
7219
+ this.upstreamDir = path6.join(defaultProvidersDir, ".upstream");
7354
7220
  this.disableUpstream = options?.disableUpstream ?? false;
7355
7221
  }
7356
7222
  log(msg) {
@@ -7380,7 +7246,7 @@ var init_provider_loader = __esm({
7380
7246
  * Canonical provider directory shape for a given root.
7381
7247
  */
7382
7248
  getProviderDir(root, category, type) {
7383
- return path7.join(root, category, type);
7249
+ return path6.join(root, category, type);
7384
7250
  }
7385
7251
  /**
7386
7252
  * Canonical user override directory for a provider.
@@ -7407,7 +7273,7 @@ var init_provider_loader = __esm({
7407
7273
  resolveProviderFile(type, ...segments) {
7408
7274
  const dir = this.findProviderDirInternal(type);
7409
7275
  if (!dir) return null;
7410
- return path7.join(dir, ...segments);
7276
+ return path6.join(dir, ...segments);
7411
7277
  }
7412
7278
  /**
7413
7279
  * Load all providers (3-tier priority)
@@ -7445,7 +7311,7 @@ var init_provider_loader = __esm({
7445
7311
  if (!fs5.existsSync(this.upstreamDir)) return false;
7446
7312
  try {
7447
7313
  return fs5.readdirSync(this.upstreamDir).some(
7448
- (d) => fs5.statSync(path7.join(this.upstreamDir, d)).isDirectory()
7314
+ (d) => fs5.statSync(path6.join(this.upstreamDir, d)).isDirectory()
7449
7315
  );
7450
7316
  } catch {
7451
7317
  return false;
@@ -7530,16 +7396,23 @@ var init_provider_loader = __esm({
7530
7396
  isEnabled(type, ideType) {
7531
7397
  if (!ideType) return true;
7532
7398
  try {
7533
- const { loadConfig: loadConfig2 } = (init_config(), __toCommonJS(config_exports));
7534
- const config2 = loadConfig2();
7535
- const baseIdeType = ideType.split("_")[0];
7536
- const val = config2.ideSettings?.[baseIdeType]?.extensions?.[type]?.enabled;
7537
- return val === true;
7399
+ return this.getIdeExtensionEnabledState(ideType, type);
7538
7400
  } catch {
7539
7401
  return false;
7540
7402
  }
7541
7403
  }
7542
7404
  /**
7405
+ * Resolve per-IDE extension enabled state using the same normalization
7406
+ * that runtime attach/remove uses.
7407
+ */
7408
+ getIdeExtensionEnabledState(ideType, extensionType) {
7409
+ const { loadConfig: loadConfig2 } = (init_config(), __toCommonJS(config_exports));
7410
+ const config2 = loadConfig2();
7411
+ const baseIdeType = ideType.split("_")[0];
7412
+ const val = config2.ideSettings?.[baseIdeType]?.extensions?.[extensionType]?.enabled;
7413
+ return val === true;
7414
+ }
7415
+ /**
7543
7416
  * Save IDE extension enabled setting
7544
7417
  */
7545
7418
  setIdeExtensionEnabled(ideType, extensionType, enabled) {
@@ -7737,14 +7610,14 @@ var init_provider_loader = __esm({
7737
7610
  this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
7738
7611
  return null;
7739
7612
  }
7740
- const dir = path7.join(providerDir, scriptDir);
7613
+ const dir = path6.join(providerDir, scriptDir);
7741
7614
  if (!fs5.existsSync(dir)) {
7742
7615
  this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
7743
7616
  return null;
7744
7617
  }
7745
7618
  const cached2 = this.scriptsCache.get(dir);
7746
7619
  if (cached2) return cached2;
7747
- const scriptsJs = path7.join(dir, "scripts.js");
7620
+ const scriptsJs = path6.join(dir, "scripts.js");
7748
7621
  if (fs5.existsSync(scriptsJs)) {
7749
7622
  try {
7750
7623
  delete require.cache[require.resolve(scriptsJs)];
@@ -7783,7 +7656,7 @@ var init_provider_loader = __esm({
7783
7656
  });
7784
7657
  const handleChange = (filePath) => {
7785
7658
  if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
7786
- this.log(`File changed: ${path7.basename(filePath)}, reloading...`);
7659
+ this.log(`File changed: ${path6.basename(filePath)}, reloading...`);
7787
7660
  this.reload();
7788
7661
  }
7789
7662
  };
@@ -7838,7 +7711,7 @@ var init_provider_loader = __esm({
7838
7711
  }
7839
7712
  const https = require("https");
7840
7713
  const { execSync: execSync6 } = require("child_process");
7841
- const metaPath = path7.join(this.upstreamDir, _ProviderLoader.META_FILE);
7714
+ const metaPath = path6.join(this.upstreamDir, _ProviderLoader.META_FILE);
7842
7715
  let prevEtag = "";
7843
7716
  let prevTimestamp = 0;
7844
7717
  try {
@@ -7855,7 +7728,7 @@ var init_provider_loader = __esm({
7855
7728
  return { updated: false };
7856
7729
  }
7857
7730
  try {
7858
- const etag = await new Promise((resolve13, reject) => {
7731
+ const etag = await new Promise((resolve12, reject) => {
7859
7732
  const options = {
7860
7733
  method: "HEAD",
7861
7734
  hostname: "github.com",
@@ -7873,7 +7746,7 @@ var init_provider_loader = __esm({
7873
7746
  headers: { "User-Agent": "adhdev-launcher" },
7874
7747
  timeout: 1e4
7875
7748
  }, (res2) => {
7876
- resolve13(res2.headers.etag || res2.headers["last-modified"] || "");
7749
+ resolve12(res2.headers.etag || res2.headers["last-modified"] || "");
7877
7750
  });
7878
7751
  req2.on("error", reject);
7879
7752
  req2.on("timeout", () => {
@@ -7882,7 +7755,7 @@ var init_provider_loader = __esm({
7882
7755
  });
7883
7756
  req2.end();
7884
7757
  } else {
7885
- resolve13(res.headers.etag || res.headers["last-modified"] || "");
7758
+ resolve12(res.headers.etag || res.headers["last-modified"] || "");
7886
7759
  }
7887
7760
  });
7888
7761
  req.on("error", reject);
@@ -7898,17 +7771,17 @@ var init_provider_loader = __esm({
7898
7771
  return { updated: false };
7899
7772
  }
7900
7773
  this.log("Downloading latest providers from GitHub...");
7901
- const tmpTar = path7.join(os7.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
7902
- const tmpExtract = path7.join(os7.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
7774
+ const tmpTar = path6.join(os7.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
7775
+ const tmpExtract = path6.join(os7.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
7903
7776
  await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
7904
7777
  fs5.mkdirSync(tmpExtract, { recursive: true });
7905
7778
  execSync6(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
7906
7779
  const extracted = fs5.readdirSync(tmpExtract);
7907
7780
  const rootDir = extracted.find(
7908
- (d) => fs5.statSync(path7.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
7781
+ (d) => fs5.statSync(path6.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
7909
7782
  );
7910
7783
  if (!rootDir) throw new Error("Unexpected tarball structure");
7911
- const sourceDir = path7.join(tmpExtract, rootDir);
7784
+ const sourceDir = path6.join(tmpExtract, rootDir);
7912
7785
  const backupDir = this.upstreamDir + ".bak";
7913
7786
  if (fs5.existsSync(this.upstreamDir)) {
7914
7787
  if (fs5.existsSync(backupDir)) fs5.rmSync(backupDir, { recursive: true, force: true });
@@ -7946,7 +7819,7 @@ var init_provider_loader = __esm({
7946
7819
  downloadFile(url2, destPath) {
7947
7820
  const https = require("https");
7948
7821
  const http3 = require("http");
7949
- return new Promise((resolve13, reject) => {
7822
+ return new Promise((resolve12, reject) => {
7950
7823
  const doRequest = (reqUrl, redirectCount = 0) => {
7951
7824
  if (redirectCount > 5) {
7952
7825
  reject(new Error("Too many redirects"));
@@ -7966,7 +7839,7 @@ var init_provider_loader = __esm({
7966
7839
  res.pipe(ws2);
7967
7840
  ws2.on("finish", () => {
7968
7841
  ws2.close();
7969
- resolve13();
7842
+ resolve12();
7970
7843
  });
7971
7844
  ws2.on("error", reject);
7972
7845
  });
@@ -7983,8 +7856,8 @@ var init_provider_loader = __esm({
7983
7856
  copyDirRecursive(src, dest) {
7984
7857
  fs5.mkdirSync(dest, { recursive: true });
7985
7858
  for (const entry of fs5.readdirSync(src, { withFileTypes: true })) {
7986
- const srcPath = path7.join(src, entry.name);
7987
- const destPath = path7.join(dest, entry.name);
7859
+ const srcPath = path6.join(src, entry.name);
7860
+ const destPath = path6.join(dest, entry.name);
7988
7861
  if (entry.isDirectory()) {
7989
7862
  this.copyDirRecursive(srcPath, destPath);
7990
7863
  } else {
@@ -7995,7 +7868,7 @@ var init_provider_loader = __esm({
7995
7868
  /** .meta.json save */
7996
7869
  writeMeta(metaPath, etag, timestamp) {
7997
7870
  try {
7998
- fs5.mkdirSync(path7.dirname(metaPath), { recursive: true });
7871
+ fs5.mkdirSync(path6.dirname(metaPath), { recursive: true });
7999
7872
  fs5.writeFileSync(metaPath, JSON.stringify({
8000
7873
  etag,
8001
7874
  timestamp,
@@ -8012,7 +7885,7 @@ var init_provider_loader = __esm({
8012
7885
  const scan = (d) => {
8013
7886
  try {
8014
7887
  for (const entry of fs5.readdirSync(d, { withFileTypes: true })) {
8015
- if (entry.isDirectory()) scan(path7.join(d, entry.name));
7888
+ if (entry.isDirectory()) scan(path6.join(d, entry.name));
8016
7889
  else if (entry.name === "provider.json") count++;
8017
7890
  }
8018
7891
  } catch {
@@ -8111,17 +7984,17 @@ var init_provider_loader = __esm({
8111
7984
  for (const root of searchRoots) {
8112
7985
  if (!fs5.existsSync(root)) continue;
8113
7986
  const candidate = this.getProviderDir(root, cat, type);
8114
- if (fs5.existsSync(path7.join(candidate, "provider.json"))) return candidate;
8115
- const catDir = path7.join(root, cat);
7987
+ if (fs5.existsSync(path6.join(candidate, "provider.json"))) return candidate;
7988
+ const catDir = path6.join(root, cat);
8116
7989
  if (fs5.existsSync(catDir)) {
8117
7990
  try {
8118
7991
  for (const entry of fs5.readdirSync(catDir, { withFileTypes: true })) {
8119
7992
  if (!entry.isDirectory()) continue;
8120
- const jsonPath = path7.join(catDir, entry.name, "provider.json");
7993
+ const jsonPath = path6.join(catDir, entry.name, "provider.json");
8121
7994
  if (fs5.existsSync(jsonPath)) {
8122
7995
  try {
8123
7996
  const data = JSON.parse(fs5.readFileSync(jsonPath, "utf-8"));
8124
- if (data.type === type) return path7.join(catDir, entry.name);
7997
+ if (data.type === type) return path6.join(catDir, entry.name);
8125
7998
  } catch {
8126
7999
  }
8127
8000
  }
@@ -8138,7 +8011,7 @@ var init_provider_loader = __esm({
8138
8011
  * (template substitution is NOT applied here — scripts.js handles that)
8139
8012
  */
8140
8013
  buildScriptWrappersFromDir(dir) {
8141
- const scriptsJs = path7.join(dir, "scripts.js");
8014
+ const scriptsJs = path6.join(dir, "scripts.js");
8142
8015
  if (fs5.existsSync(scriptsJs)) {
8143
8016
  try {
8144
8017
  delete require.cache[require.resolve(scriptsJs)];
@@ -8152,7 +8025,7 @@ var init_provider_loader = __esm({
8152
8025
  for (const file2 of fs5.readdirSync(dir)) {
8153
8026
  if (!file2.endsWith(".js")) continue;
8154
8027
  const scriptName = toCamel(file2.replace(".js", ""));
8155
- const filePath = path7.join(dir, file2);
8028
+ const filePath = path6.join(dir, file2);
8156
8029
  result[scriptName] = (...args) => {
8157
8030
  try {
8158
8031
  let content = fs5.readFileSync(filePath, "utf-8");
@@ -8212,7 +8085,7 @@ var init_provider_loader = __esm({
8212
8085
  }
8213
8086
  const hasJson = entries.some((e) => e.name === "provider.json");
8214
8087
  if (hasJson) {
8215
- const jsonPath = path7.join(d, "provider.json");
8088
+ const jsonPath = path6.join(d, "provider.json");
8216
8089
  try {
8217
8090
  const raw = fs5.readFileSync(jsonPath, "utf-8");
8218
8091
  const mod = JSON.parse(raw);
@@ -8225,7 +8098,7 @@ var init_provider_loader = __esm({
8225
8098
  delete mod.extensionIdPattern_flags;
8226
8099
  }
8227
8100
  const hasCompatibility = Array.isArray(mod.compatibility);
8228
- const scriptsPath = path7.join(d, "scripts.js");
8101
+ const scriptsPath = path6.join(d, "scripts.js");
8229
8102
  if (!hasCompatibility && fs5.existsSync(scriptsPath)) {
8230
8103
  try {
8231
8104
  delete require.cache[require.resolve(scriptsPath)];
@@ -8251,7 +8124,7 @@ var init_provider_loader = __esm({
8251
8124
  if (!entry.isDirectory()) continue;
8252
8125
  if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
8253
8126
  if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
8254
- scan(path7.join(d, entry.name));
8127
+ scan(path6.join(d, entry.name));
8255
8128
  }
8256
8129
  }
8257
8130
  };
@@ -8332,17 +8205,17 @@ async function findFreePort(ports) {
8332
8205
  throw new Error("No free port found");
8333
8206
  }
8334
8207
  function checkPortFree(port) {
8335
- return new Promise((resolve13) => {
8208
+ return new Promise((resolve12) => {
8336
8209
  const server = net.createServer();
8337
8210
  server.unref();
8338
- server.on("error", () => resolve13(false));
8211
+ server.on("error", () => resolve12(false));
8339
8212
  server.listen(port, "127.0.0.1", () => {
8340
- server.close(() => resolve13(true));
8213
+ server.close(() => resolve12(true));
8341
8214
  });
8342
8215
  });
8343
8216
  }
8344
8217
  async function isCdpActive(port) {
8345
- return new Promise((resolve13) => {
8218
+ return new Promise((resolve12) => {
8346
8219
  const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
8347
8220
  timeout: 2e3
8348
8221
  }, (res) => {
@@ -8351,16 +8224,16 @@ async function isCdpActive(port) {
8351
8224
  res.on("end", () => {
8352
8225
  try {
8353
8226
  const info = JSON.parse(data);
8354
- resolve13(!!info["WebKit-Version"] || !!info["Browser"]);
8227
+ resolve12(!!info["WebKit-Version"] || !!info["Browser"]);
8355
8228
  } catch {
8356
- resolve13(false);
8229
+ resolve12(false);
8357
8230
  }
8358
8231
  });
8359
8232
  });
8360
- req.on("error", () => resolve13(false));
8233
+ req.on("error", () => resolve12(false));
8361
8234
  req.on("timeout", () => {
8362
8235
  req.destroy();
8363
- resolve13(false);
8236
+ resolve12(false);
8364
8237
  });
8365
8238
  });
8366
8239
  }
@@ -8479,8 +8352,8 @@ function detectCurrentWorkspace(ideId) {
8479
8352
  const appNameMap = getMacAppIdentifiers();
8480
8353
  const appName = appNameMap[ideId];
8481
8354
  if (appName) {
8482
- const storagePath = path8.join(
8483
- process.env.APPDATA || path8.join(os8.homedir(), "AppData", "Roaming"),
8355
+ const storagePath = path7.join(
8356
+ process.env.APPDATA || path7.join(os8.homedir(), "AppData", "Roaming"),
8484
8357
  appName,
8485
8358
  "storage.json"
8486
8359
  );
@@ -8643,14 +8516,14 @@ async function launchLinux(ide, port, workspace, newWindow) {
8643
8516
  if (workspace) args.push(workspace);
8644
8517
  (0, import_child_process4.spawn)(cli, args, { detached: true, stdio: "ignore" }).unref();
8645
8518
  }
8646
- var import_child_process4, net, os8, path8, _providerLoader;
8519
+ var import_child_process4, net, os8, path7, _providerLoader;
8647
8520
  var init_launch = __esm({
8648
8521
  "../../oss/packages/daemon-core/src/launch.ts"() {
8649
8522
  "use strict";
8650
8523
  import_child_process4 = require("child_process");
8651
8524
  net = __toESM(require("net"));
8652
8525
  os8 = __toESM(require("os"));
8653
- path8 = __toESM(require("path"));
8526
+ path7 = __toESM(require("path"));
8654
8527
  init_ide_detector();
8655
8528
  init_provider_loader();
8656
8529
  _providerLoader = null;
@@ -8681,7 +8554,7 @@ function checkRotation() {
8681
8554
  const today = getDateStr2();
8682
8555
  if (today !== currentDate2) {
8683
8556
  currentDate2 = today;
8684
- currentFile = path9.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
8557
+ currentFile = path8.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
8685
8558
  cleanOldFiles();
8686
8559
  }
8687
8560
  }
@@ -8695,7 +8568,7 @@ function cleanOldFiles() {
8695
8568
  const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
8696
8569
  if (dateMatch && dateMatch[1] < cutoffStr) {
8697
8570
  try {
8698
- fs6.unlinkSync(path9.join(LOG_DIR2, file2));
8571
+ fs6.unlinkSync(path8.join(LOG_DIR2, file2));
8699
8572
  } catch {
8700
8573
  }
8701
8574
  }
@@ -8737,14 +8610,14 @@ function logCommand(entry) {
8737
8610
  } catch {
8738
8611
  }
8739
8612
  }
8740
- var fs6, path9, os9, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
8613
+ var fs6, path8, os9, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
8741
8614
  var init_command_log = __esm({
8742
8615
  "../../oss/packages/daemon-core/src/logging/command-log.ts"() {
8743
8616
  "use strict";
8744
8617
  fs6 = __toESM(require("fs"));
8745
- path9 = __toESM(require("path"));
8618
+ path8 = __toESM(require("path"));
8746
8619
  os9 = __toESM(require("os"));
8747
- LOG_DIR2 = process.platform === "win32" ? path9.join(process.env.LOCALAPPDATA || process.env.APPDATA || path9.join(os9.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path9.join(os9.homedir(), "Library", "Logs", "adhdev") : path9.join(os9.homedir(), ".local", "share", "adhdev", "logs");
8620
+ 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");
8748
8621
  MAX_FILE_SIZE = 5 * 1024 * 1024;
8749
8622
  MAX_DAYS = 7;
8750
8623
  try {
@@ -8763,7 +8636,7 @@ var init_command_log = __esm({
8763
8636
  "text"
8764
8637
  ]);
8765
8638
  currentDate2 = getDateStr2();
8766
- currentFile = path9.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
8639
+ currentFile = path8.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
8767
8640
  writeCount2 = 0;
8768
8641
  SKIP_COMMANDS = /* @__PURE__ */ new Set([
8769
8642
  "heartbeat",
@@ -8773,355 +8646,6 @@ var init_command_log = __esm({
8773
8646
  }
8774
8647
  });
8775
8648
 
8776
- // ../../oss/packages/daemon-core/src/commands/router.ts
8777
- var fs7, CHAT_COMMANDS, DaemonCommandRouter;
8778
- var init_router = __esm({
8779
- "../../oss/packages/daemon-core/src/commands/router.ts"() {
8780
- "use strict";
8781
- init_manager();
8782
- init_setup();
8783
- init_launch();
8784
- init_config();
8785
- init_workspaces();
8786
- init_workspace_activity();
8787
- init_config();
8788
- init_recent_activity();
8789
- init_ide_detector();
8790
- init_logger();
8791
- init_command_log();
8792
- init_logger();
8793
- fs7 = __toESM(require("fs"));
8794
- CHAT_COMMANDS = [
8795
- "send_chat",
8796
- "new_chat",
8797
- "switch_chat",
8798
- "set_mode",
8799
- "change_model"
8800
- ];
8801
- DaemonCommandRouter = class {
8802
- deps;
8803
- constructor(deps) {
8804
- this.deps = deps;
8805
- }
8806
- /**
8807
- * Unified command routing.
8808
- * Returns result for all commands:
8809
- * 1. Daemon-level commands (launch_ide, stop_ide, etc.)
8810
- * 2. CLI commands (launch_cli, stop_cli, agent_command)
8811
- * 3. DaemonCommandHandler delegation (CDP/agent-stream/file commands)
8812
- *
8813
- * @param cmd Command name
8814
- * @param args Command arguments
8815
- * @param source Log source ('ws' | 'p2p' | 'standalone' | etc.)
8816
- */
8817
- async execute(cmd, args, source = "unknown") {
8818
- const cmdStart = Date.now();
8819
- try {
8820
- const daemonResult = await this.executeDaemonCommand(cmd, args);
8821
- if (daemonResult) {
8822
- logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source, args, success: daemonResult.success, durationMs: Date.now() - cmdStart });
8823
- return daemonResult;
8824
- }
8825
- const handlerResult = await this.deps.commandHandler.handle(cmd, args);
8826
- logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source, args, success: handlerResult.success, durationMs: Date.now() - cmdStart });
8827
- if (CHAT_COMMANDS.includes(cmd) && this.deps.onPostChatCommand) {
8828
- this.deps.onPostChatCommand();
8829
- }
8830
- return handlerResult;
8831
- } catch (e) {
8832
- logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source, args, success: false, error: e.message, durationMs: Date.now() - cmdStart });
8833
- throw e;
8834
- }
8835
- }
8836
- // ─── Daemon-level command core ───────────────────
8837
- /**
8838
- * Daemon-level command execution (IDE start/stop/restart, CLI, detect, logs).
8839
- * Returns null if not handled at this level → caller delegates to CommandHandler.
8840
- */
8841
- async executeDaemonCommand(cmd, args) {
8842
- switch (cmd) {
8843
- // ─── CLI / ACP commands ───
8844
- case "launch_cli":
8845
- case "stop_cli":
8846
- case "agent_command": {
8847
- return this.deps.cliManager.handleCliCommand(cmd, args);
8848
- }
8849
- // ─── Logs ───
8850
- case "get_logs": {
8851
- const count = parseInt(args?.count) || parseInt(args?.lines) || 100;
8852
- const minLevel = args?.minLevel || "info";
8853
- const sinceTs = args?.since || 0;
8854
- try {
8855
- let logs = getRecentLogs(count, minLevel);
8856
- if (sinceTs > 0) {
8857
- logs = logs.filter((l) => l.ts > sinceTs);
8858
- }
8859
- if (logs.length > 0) {
8860
- return { success: true, logs, totalBuffered: logs.length };
8861
- }
8862
- if (fs7.existsSync(LOG_PATH)) {
8863
- const content = fs7.readFileSync(LOG_PATH, "utf-8");
8864
- const allLines = content.split("\n");
8865
- const recent = allLines.slice(-count).join("\n");
8866
- return { success: true, logs: recent, totalLines: allLines.length };
8867
- }
8868
- return { success: true, logs: [], totalBuffered: 0 };
8869
- } catch (e) {
8870
- return { success: false, error: e.message };
8871
- }
8872
- }
8873
- // ─── restart_session: IDE / CLI / ACP unified ───
8874
- case "restart_session": {
8875
- const targetType = args?.cliType || args?.agentType || args?.ideType;
8876
- if (!targetType) throw new Error("cliType or ideType required");
8877
- const isIde = this.deps.cdpManagers.has(targetType) || this.deps.providerLoader.getMeta(targetType)?.category === "ide";
8878
- if (isIde) {
8879
- await this.stopIde(targetType, true);
8880
- const launchResult = await this.executeDaemonCommand("launch_ide", { ideType: targetType, enableCdp: true, workspace: args?.workspace });
8881
- return { success: true, restarted: true, ideType: targetType, launch: launchResult };
8882
- }
8883
- return this.deps.cliManager.handleCliCommand(cmd, args);
8884
- }
8885
- // ─── IDE stop ───
8886
- case "stop_ide": {
8887
- const ideType = args?.ideType;
8888
- if (!ideType) throw new Error("ideType required");
8889
- const killProcess = args?.killProcess !== false;
8890
- await this.stopIde(ideType, killProcess);
8891
- return { success: true, ideType, stopped: true, processKilled: killProcess };
8892
- }
8893
- // ─── IDE restart ───
8894
- case "restart_ide": {
8895
- const ideType = args?.ideType;
8896
- if (!ideType) throw new Error("ideType required");
8897
- await this.stopIde(ideType, true);
8898
- const launchResult = await this.executeDaemonCommand("launch_ide", { ideType, enableCdp: true, workspace: args?.workspace });
8899
- return { success: true, ideType, restarted: true, launch: launchResult };
8900
- }
8901
- // ─── IDE launch + CDP connect ───
8902
- case "launch_ide": {
8903
- const ideKey = args?.ideId || args?.ideType;
8904
- const resolvedWorkspace = resolveIdeLaunchWorkspace(
8905
- {
8906
- workspace: args?.workspace,
8907
- workspaceId: args?.workspaceId,
8908
- useDefaultWorkspace: args?.useDefaultWorkspace
8909
- },
8910
- loadConfig()
8911
- );
8912
- const launchArgs = {
8913
- ideId: ideKey,
8914
- workspace: resolvedWorkspace,
8915
- newWindow: args?.newWindow
8916
- };
8917
- LOG.info("LaunchIDE", `target=${ideKey || "auto"}`);
8918
- const result = await launchWithCdp(launchArgs);
8919
- if (result.success && (result.ideId || ideKey)) {
8920
- try {
8921
- addCliHistory({
8922
- category: "ide",
8923
- cliType: result.ideId || ideKey,
8924
- dir: resolvedWorkspace || "",
8925
- workspace: resolvedWorkspace || "",
8926
- newWindow: args?.newWindow === true
8927
- });
8928
- } catch {
8929
- }
8930
- }
8931
- if (result.success && result.port && result.ideId && !this.deps.cdpManagers.has(result.ideId)) {
8932
- const logFn = this.deps.getCdpLogFn ? this.deps.getCdpLogFn(result.ideId) : LOG.forComponent(`CDP:${result.ideId}`).asLogFn();
8933
- const provider = this.deps.providerLoader.getMeta(result.ideId);
8934
- const manager = new DaemonCdpManager(result.port, logFn, void 0, provider?.targetFilter);
8935
- const connected = await manager.connect();
8936
- if (connected) {
8937
- registerExtensionProviders(this.deps.providerLoader, manager, result.ideId);
8938
- this.deps.cdpManagers.set(result.ideId, manager);
8939
- LOG.info("CDP", `Connected: ${result.ideId} (port ${result.port})`);
8940
- LOG.info("CDP", `${this.deps.cdpManagers.size} IDE(s) connected`);
8941
- this.deps.onCdpManagerCreated?.(result.ideId, manager);
8942
- }
8943
- }
8944
- this.deps.onIdeConnected?.();
8945
- if (result.success && resolvedWorkspace) {
8946
- try {
8947
- let next = appendWorkspaceActivity(loadConfig(), resolvedWorkspace, {
8948
- kind: "ide",
8949
- agentType: result.ideId
8950
- });
8951
- next = appendRecentActivity(next, {
8952
- kind: "ide",
8953
- providerType: result.ideId || ideKey,
8954
- providerName: result.ideId || ideKey,
8955
- workspace: resolvedWorkspace,
8956
- title: result.ideId || ideKey
8957
- });
8958
- saveConfig(next);
8959
- } catch {
8960
- }
8961
- } else if (result.success && (result.ideId || ideKey)) {
8962
- try {
8963
- saveConfig(appendRecentActivity(loadConfig(), {
8964
- kind: "ide",
8965
- providerType: result.ideId || ideKey,
8966
- providerName: result.ideId || ideKey,
8967
- title: result.ideId || ideKey
8968
- }));
8969
- } catch {
8970
- }
8971
- }
8972
- return { success: result.success, ...result };
8973
- }
8974
- // ─── Detect IDEs ───
8975
- case "detect_ides": {
8976
- const results = await detectIDEs();
8977
- this.deps.detectedIdes.value = results;
8978
- return { success: true, detectedInfo: results };
8979
- }
8980
- // ─── Set User Name ───
8981
- case "set_user_name": {
8982
- const name = args?.userName;
8983
- if (!name || typeof name !== "string") throw new Error("userName required");
8984
- updateConfig({ userName: name });
8985
- return { success: true, userName: name };
8986
- }
8987
- case "mark_recent_seen": {
8988
- const kind = args?.kind;
8989
- const providerType = args?.providerType;
8990
- if (!kind || !providerType) {
8991
- return { success: false, error: "kind and providerType are required" };
8992
- }
8993
- const recentKey = args?.recentKey || buildRecentActivityKey({
8994
- kind,
8995
- providerType,
8996
- workspace: args?.workspace || null
8997
- });
8998
- const next = markRecentSessionSeen(
8999
- loadConfig(),
9000
- recentKey,
9001
- typeof args?.seenAt === "number" ? args.seenAt : Date.now()
9002
- );
9003
- saveConfig(next);
9004
- this.deps.onStatusChange?.();
9005
- return {
9006
- success: true,
9007
- recentKey,
9008
- seenAt: next.recentSessionReads?.[recentKey] || Date.now()
9009
- };
9010
- }
9011
- // ─── Daemon Self-Upgrade ───
9012
- case "daemon_upgrade": {
9013
- LOG.info("Upgrade", "Remote upgrade requested from dashboard");
9014
- try {
9015
- const { execSync: execSync6 } = await import("child_process");
9016
- const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
9017
- const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
9018
- const latest = execSync6(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
9019
- LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
9020
- execSync6(`npm install -g ${pkgName}@latest --force`, {
9021
- encoding: "utf-8",
9022
- timeout: 12e4,
9023
- stdio: ["pipe", "pipe", "pipe"]
9024
- });
9025
- LOG.info("Upgrade", `\u2705 Upgraded to v${latest}`);
9026
- setTimeout(() => {
9027
- LOG.info("Upgrade", "Restarting daemon with new version...");
9028
- try {
9029
- const path19 = require("path");
9030
- const fs16 = require("fs");
9031
- const pidFile = path19.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
9032
- if (fs16.existsSync(pidFile)) fs16.unlinkSync(pidFile);
9033
- } catch {
9034
- }
9035
- const { spawn: spawn4 } = require("child_process");
9036
- const child = spawn4(process.execPath, process.argv.slice(1), {
9037
- detached: true,
9038
- stdio: "ignore",
9039
- env: { ...process.env }
9040
- });
9041
- child.unref();
9042
- process.exit(0);
9043
- }, 3e3);
9044
- return { success: true, upgraded: true, version: latest };
9045
- } catch (e) {
9046
- LOG.error("Upgrade", `Failed: ${e.message}`);
9047
- return { success: false, error: e.message };
9048
- }
9049
- }
9050
- // ─── Machine Settings ───
9051
- case "set_machine_nickname": {
9052
- const nickname = args?.nickname;
9053
- updateConfig({ machineNickname: nickname || null });
9054
- return { success: true };
9055
- }
9056
- default:
9057
- break;
9058
- }
9059
- return null;
9060
- }
9061
- /**
9062
- * IDE stop: CDP disconnect + InstanceManager cleanup + optionally kill OS process
9063
- */
9064
- async stopIde(ideType, killProcess = false) {
9065
- const cdpKeysToRemove = [];
9066
- for (const key of this.deps.cdpManagers.keys()) {
9067
- if (key === ideType || key.startsWith(`${ideType}_`)) {
9068
- cdpKeysToRemove.push(key);
9069
- }
9070
- }
9071
- for (const key of cdpKeysToRemove) {
9072
- const cdp = this.deps.cdpManagers.get(key);
9073
- if (cdp) {
9074
- try {
9075
- cdp.disconnect();
9076
- } catch {
9077
- }
9078
- this.deps.cdpManagers.delete(key);
9079
- this.deps.sessionRegistry.unregisterByManagerKey(key);
9080
- LOG.info("StopIDE", `CDP disconnected: ${key}`);
9081
- }
9082
- }
9083
- const keysToRemove = [];
9084
- for (const key of this.deps.instanceManager.listInstanceIds()) {
9085
- if (key === `ide:${ideType}` || typeof key === "string" && key.startsWith(`ide:${ideType}_`)) {
9086
- keysToRemove.push(key);
9087
- }
9088
- }
9089
- for (const instanceKey of keysToRemove) {
9090
- const ideInstance = this.deps.instanceManager.getInstance(instanceKey);
9091
- if (ideInstance) {
9092
- this.deps.instanceManager.removeInstance(instanceKey);
9093
- LOG.info("StopIDE", `Instance removed: ${instanceKey}`);
9094
- }
9095
- }
9096
- if (keysToRemove.length === 0) {
9097
- const instanceKey = `ide:${ideType}`;
9098
- const ideInstance = this.deps.instanceManager.getInstance(instanceKey);
9099
- if (ideInstance) {
9100
- this.deps.instanceManager.removeInstance(instanceKey);
9101
- LOG.info("StopIDE", `Instance removed: ${instanceKey}`);
9102
- }
9103
- }
9104
- if (killProcess) {
9105
- const running = isIdeRunning(ideType);
9106
- if (running) {
9107
- LOG.info("StopIDE", `Killing IDE process: ${ideType}`);
9108
- const killed = await killIdeProcess(ideType);
9109
- if (killed) {
9110
- LOG.info("StopIDE", `\u2705 Process killed: ${ideType}`);
9111
- } else {
9112
- LOG.warn("StopIDE", `\u26A0 Could not kill process: ${ideType} (may need manual intervention)`);
9113
- }
9114
- } else {
9115
- LOG.info("StopIDE", `Process not running: ${ideType}`);
9116
- }
9117
- }
9118
- this.deps.onStatusChange?.();
9119
- LOG.info("StopIDE", `IDE stopped: ${ideType} (processKill=${killProcess})`);
9120
- }
9121
- };
9122
- }
9123
- });
9124
-
9125
8649
  // ../../oss/packages/daemon-core/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts
9126
8650
  function isModuleNotFoundError(error48, ref) {
9127
8651
  if (!(error48 instanceof Error)) return false;
@@ -9949,7 +9473,7 @@ function Ec(s15, t) {
9949
9473
  function Tc(s15) {
9950
9474
  return s15.keyCode === 16 || s15.keyCode === 17 || s15.keyCode === 18;
9951
9475
  }
9952
- 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, fs8, $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;
9476
+ 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;
9953
9477
  var init_xterm = __esm({
9954
9478
  "../../oss/node_modules/@xterm/xterm/lib/xterm.mjs"() {
9955
9479
  "use strict";
@@ -13224,7 +12748,7 @@ ${h.join(`
13224
12748
  ((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 = `
13225
12749
  `, 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 ||= {});
13226
12750
  ((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 ||= {});
13227
- ((t) => t.ST = `${b.ESC}\\`)(fs8 ||= {});
12751
+ ((t) => t.ST = `${b.ESC}\\`)(fs7 ||= {});
13228
12752
  $t = class {
13229
12753
  constructor(t, e, i, r, n, o) {
13230
12754
  this._textarea = t;
@@ -17653,7 +17177,7 @@ ${h.join(`
17653
17177
  switch (i.type) {
17654
17178
  case 0:
17655
17179
  let o = U.toColorRGB(r === "ansi" ? this._themeService.colors.ansi[i.index] : this._themeService.colors[r]);
17656
- this.coreService.triggerDataEvent(`${b.ESC}]${n};${ml(o)}${fs8.ST}`);
17180
+ this.coreService.triggerDataEvent(`${b.ESC}]${n};${ml(o)}${fs7.ST}`);
17657
17181
  break;
17658
17182
  case 1:
17659
17183
  if (r === "ansi") this._themeService.modifyColors((l) => l.ansi[i.index] = j.toColor(...i.color));
@@ -18494,81 +18018,45 @@ function getSessionMessageUpdatedAt(session) {
18494
18018
  if (!lastMessage) return 0;
18495
18019
  return parseMessageTime(lastMessage.timestamp) || parseMessageTime(lastMessage.receivedAt) || parseMessageTime(lastMessage.createdAt) || 0;
18496
18020
  }
18021
+ function getSessionCompletionMarker(session) {
18022
+ const lastMessage = session.activeChat?.messages?.at?.(-1);
18023
+ if (!lastMessage) return "";
18024
+ const role = typeof lastMessage.role === "string" ? lastMessage.role : "";
18025
+ if (role === "user" || role === "human") return "";
18026
+ if (typeof lastMessage._turnKey === "string" && lastMessage._turnKey) return `turn:${lastMessage._turnKey}`;
18027
+ if (typeof lastMessage.id === "string" && lastMessage.id) return `id:${lastMessage.id}`;
18028
+ if (typeof lastMessage.index === "number" && Number.isFinite(lastMessage.index)) return `idx:${lastMessage.index}`;
18029
+ const timestamp = parseMessageTime(lastMessage.timestamp) || parseMessageTime(lastMessage.receivedAt) || parseMessageTime(lastMessage.createdAt);
18030
+ return timestamp > 0 ? `ts:${timestamp}` : "";
18031
+ }
18497
18032
  function getSessionLastUsedAt(session) {
18498
18033
  return getSessionMessageUpdatedAt(session) || session.lastUpdated || Date.now();
18499
18034
  }
18500
- function getSessionKind(session) {
18501
- return session.transport === "cdp-page" || session.transport === "cdp-webview" ? "ide" : session.transport === "acp" ? "acp" : "cli";
18502
- }
18503
18035
  function getLastMessageRole(session) {
18504
18036
  const role = session.activeChat?.messages?.at?.(-1)?.role;
18505
18037
  return typeof role === "string" ? role : "";
18506
18038
  }
18507
- function getUnreadState(hasContentChange, status, lastUsedAt, lastSeenAt, lastRole) {
18039
+ function getUnreadState(hasContentChange, status, lastUsedAt, lastSeenAt, lastRole, completionMarker, seenCompletionMarker) {
18508
18040
  if (status === "waiting_approval") {
18509
18041
  return { unread: false, inboxBucket: "needs_attention" };
18510
18042
  }
18511
18043
  if (status === "generating" || status === "starting") {
18512
18044
  return { unread: false, inboxBucket: "working" };
18513
18045
  }
18514
- const unread = hasContentChange && lastUsedAt > lastSeenAt && lastRole !== "user" && lastRole !== "human";
18046
+ const unread = completionMarker ? completionMarker !== seenCompletionMarker : hasContentChange && lastUsedAt > lastSeenAt && lastRole !== "user" && lastRole !== "human";
18515
18047
  return { unread, inboxBucket: unread ? "task_complete" : "idle" };
18516
18048
  }
18517
- function buildRecentSessions(sessions, recentActivity, readState) {
18518
- const live = sessions.filter((session) => !session.parentId && session.status !== "stopped").map((session) => {
18519
- const kind = getSessionKind(session);
18520
- const recentKey = buildRecentActivityKey({
18521
- kind,
18522
- providerType: session.providerType,
18523
- workspace: session.workspace
18524
- });
18525
- const lastSeenAt = readState[recentKey] || 0;
18526
- const lastUsedAt = getSessionLastUsedAt(session);
18527
- const { unread, inboxBucket } = getUnreadState(
18528
- getSessionMessageUpdatedAt(session) > 0,
18529
- session.status,
18530
- lastUsedAt,
18531
- lastSeenAt,
18532
- getLastMessageRole(session)
18533
- );
18534
- return {
18535
- id: session.id,
18536
- recentKey,
18537
- sessionId: session.id,
18538
- providerType: session.providerType,
18539
- providerName: session.providerName,
18540
- kind,
18541
- title: session.activeChat?.title || session.title || session.providerName,
18542
- workspace: session.workspace,
18543
- currentModel: session.currentModel,
18544
- status: session.status,
18545
- lastUsedAt,
18546
- unread,
18547
- lastSeenAt,
18548
- inboxBucket
18549
- };
18550
- });
18551
- const seen = new Set(live.map((item) => `${item.kind}:${item.providerType}:${item.workspace || ""}`));
18552
- const persisted = recentActivity.filter((item) => !seen.has(`${item.kind}:${item.providerType}:${item.workspace || ""}`)).map((item) => {
18553
- const lastSeenAt = readState[item.id] || 0;
18554
- const unread = item.lastUsedAt > lastSeenAt;
18555
- return {
18556
- id: item.id,
18557
- recentKey: item.id,
18558
- sessionId: item.sessionId || null,
18559
- providerType: item.providerType,
18560
- providerName: item.providerName,
18561
- kind: item.kind,
18562
- title: item.title || item.providerName,
18563
- workspace: item.workspace,
18564
- currentModel: item.currentModel,
18565
- lastUsedAt: item.lastUsedAt,
18566
- unread,
18567
- lastSeenAt,
18568
- inboxBucket: unread ? "task_complete" : "idle"
18569
- };
18570
- });
18571
- return [...live, ...persisted].sort((a, b2) => b2.lastUsedAt - a.lastUsedAt).slice(0, 12);
18049
+ function buildRecentLaunches(recentActivity) {
18050
+ return recentActivity.map((item) => ({
18051
+ id: item.id,
18052
+ providerType: item.providerType,
18053
+ providerName: item.providerName,
18054
+ kind: item.kind,
18055
+ title: item.title || item.providerName,
18056
+ workspace: item.workspace,
18057
+ currentModel: item.currentModel,
18058
+ lastLaunchedAt: item.lastUsedAt
18059
+ })).sort((a, b2) => b2.lastLaunchedAt - a.lastLaunchedAt).slice(0, 12);
18572
18060
  }
18573
18061
  function buildStatusSnapshot(options) {
18574
18062
  const cfg = loadConfig();
@@ -18579,27 +18067,29 @@ function buildStatusSnapshot(options) {
18579
18067
  options.allStates,
18580
18068
  options.cdpManagers
18581
18069
  );
18582
- const readState = cfg.recentSessionReads || {};
18583
18070
  for (const session of sessions) {
18584
- const kind = getSessionKind(session);
18585
- const recentKey = buildRecentActivityKey({
18586
- kind,
18587
- providerType: session.providerType,
18588
- workspace: session.workspace
18589
- });
18590
- const lastSeenAt = getRecentSessionSeenAt(cfg, recentKey);
18071
+ const lastSeenAt = getSessionSeenAt(cfg, session.id);
18072
+ const seenCompletionMarker = getSessionSeenMarker(cfg, session.id);
18591
18073
  const lastUsedAt = getSessionLastUsedAt(session);
18592
- const { unread, inboxBucket } = getUnreadState(
18074
+ const completionMarker = getSessionCompletionMarker(session);
18075
+ const { unread, inboxBucket } = session.surfaceHidden ? { unread: false, inboxBucket: "idle" } : getUnreadState(
18593
18076
  getSessionMessageUpdatedAt(session) > 0,
18594
18077
  session.status,
18595
18078
  lastUsedAt,
18596
18079
  lastSeenAt,
18597
- getLastMessageRole(session)
18080
+ getLastMessageRole(session),
18081
+ completionMarker,
18082
+ seenCompletionMarker
18598
18083
  );
18599
- session.recentKey = recentKey;
18600
18084
  session.lastSeenAt = lastSeenAt;
18601
18085
  session.unread = unread;
18602
18086
  session.inboxBucket = inboxBucket;
18087
+ if (READ_DEBUG_ENABLED && (session.unread || session.inboxBucket !== "idle" || session.providerType.includes("codex"))) {
18088
+ LOG.info(
18089
+ "RecentRead",
18090
+ `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)}`
18091
+ );
18092
+ }
18603
18093
  }
18604
18094
  const terminalBackend = getTerminalBackendRuntimeStatus();
18605
18095
  return {
@@ -18626,13 +18116,12 @@ function buildStatusSnapshot(options) {
18626
18116
  workspaces: wsState.workspaces,
18627
18117
  defaultWorkspaceId: wsState.defaultWorkspaceId,
18628
18118
  defaultWorkspacePath: wsState.defaultWorkspacePath,
18629
- workspaceActivity: getWorkspaceActivity(cfg, 15),
18630
- recentSessions: buildRecentSessions(sessions, recentActivity, readState),
18119
+ recentLaunches: buildRecentLaunches(recentActivity),
18631
18120
  terminalBackend,
18632
18121
  availableProviders: buildAvailableProviders(options.providerLoader)
18633
18122
  };
18634
18123
  }
18635
- var os11;
18124
+ var os11, READ_DEBUG_ENABLED;
18636
18125
  var init_snapshot = __esm({
18637
18126
  "../../oss/packages/daemon-core/src/status/snapshot.ts"() {
18638
18127
  "use strict";
@@ -18640,10 +18129,352 @@ var init_snapshot = __esm({
18640
18129
  init_config();
18641
18130
  init_recent_activity();
18642
18131
  init_workspaces();
18643
- init_workspace_activity();
18644
18132
  init_host_memory();
18645
18133
  init_terminal_screen();
18134
+ init_logger();
18135
+ init_builders();
18136
+ READ_DEBUG_ENABLED = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
18137
+ }
18138
+ });
18139
+
18140
+ // ../../oss/packages/daemon-core/src/commands/router.ts
18141
+ var fs8, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
18142
+ var init_router = __esm({
18143
+ "../../oss/packages/daemon-core/src/commands/router.ts"() {
18144
+ "use strict";
18145
+ init_manager();
18146
+ init_setup();
18147
+ init_launch();
18148
+ init_config();
18149
+ init_workspaces();
18150
+ init_recent_activity();
18151
+ init_ide_detector();
18152
+ init_logger();
18153
+ init_command_log();
18154
+ init_logger();
18646
18155
  init_builders();
18156
+ init_snapshot();
18157
+ fs8 = __toESM(require("fs"));
18158
+ CHAT_COMMANDS = [
18159
+ "send_chat",
18160
+ "new_chat",
18161
+ "switch_chat",
18162
+ "set_mode",
18163
+ "change_model"
18164
+ ];
18165
+ READ_DEBUG_ENABLED2 = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
18166
+ DaemonCommandRouter = class {
18167
+ deps;
18168
+ constructor(deps) {
18169
+ this.deps = deps;
18170
+ }
18171
+ /**
18172
+ * Unified command routing.
18173
+ * Returns result for all commands:
18174
+ * 1. Daemon-level commands (launch_ide, stop_ide, etc.)
18175
+ * 2. CLI commands (launch_cli, stop_cli, agent_command)
18176
+ * 3. DaemonCommandHandler delegation (CDP/agent-stream/file commands)
18177
+ *
18178
+ * @param cmd Command name
18179
+ * @param args Command arguments
18180
+ * @param source Log source ('ws' | 'p2p' | 'standalone' | etc.)
18181
+ */
18182
+ async execute(cmd, args, source = "unknown") {
18183
+ const cmdStart = Date.now();
18184
+ try {
18185
+ const daemonResult = await this.executeDaemonCommand(cmd, args);
18186
+ if (daemonResult) {
18187
+ logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source, args, success: daemonResult.success, durationMs: Date.now() - cmdStart });
18188
+ return daemonResult;
18189
+ }
18190
+ const handlerResult = await this.deps.commandHandler.handle(cmd, args);
18191
+ logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source, args, success: handlerResult.success, durationMs: Date.now() - cmdStart });
18192
+ if (CHAT_COMMANDS.includes(cmd) && this.deps.onPostChatCommand) {
18193
+ this.deps.onPostChatCommand();
18194
+ }
18195
+ return handlerResult;
18196
+ } catch (e) {
18197
+ logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source, args, success: false, error: e.message, durationMs: Date.now() - cmdStart });
18198
+ throw e;
18199
+ }
18200
+ }
18201
+ // ─── Daemon-level command core ───────────────────
18202
+ /**
18203
+ * Daemon-level command execution (IDE start/stop/restart, CLI, detect, logs).
18204
+ * Returns null if not handled at this level → caller delegates to CommandHandler.
18205
+ */
18206
+ async executeDaemonCommand(cmd, args) {
18207
+ switch (cmd) {
18208
+ // ─── CLI / ACP commands ───
18209
+ case "launch_cli":
18210
+ case "stop_cli":
18211
+ case "agent_command": {
18212
+ return this.deps.cliManager.handleCliCommand(cmd, args);
18213
+ }
18214
+ // ─── Logs ───
18215
+ case "get_logs": {
18216
+ const count = parseInt(args?.count) || parseInt(args?.lines) || 100;
18217
+ const minLevel = args?.minLevel || "info";
18218
+ const sinceTs = args?.since || 0;
18219
+ try {
18220
+ let logs = getRecentLogs(count, minLevel);
18221
+ if (sinceTs > 0) {
18222
+ logs = logs.filter((l) => l.ts > sinceTs);
18223
+ }
18224
+ if (logs.length > 0) {
18225
+ return { success: true, logs, totalBuffered: logs.length };
18226
+ }
18227
+ if (fs8.existsSync(LOG_PATH)) {
18228
+ const content = fs8.readFileSync(LOG_PATH, "utf-8");
18229
+ const allLines = content.split("\n");
18230
+ const recent = allLines.slice(-count).join("\n");
18231
+ return { success: true, logs: recent, totalLines: allLines.length };
18232
+ }
18233
+ return { success: true, logs: [], totalBuffered: 0 };
18234
+ } catch (e) {
18235
+ return { success: false, error: e.message };
18236
+ }
18237
+ }
18238
+ // ─── restart_session: IDE / CLI / ACP unified ───
18239
+ case "restart_session": {
18240
+ const targetType = args?.cliType || args?.agentType || args?.ideType;
18241
+ if (!targetType) throw new Error("cliType or ideType required");
18242
+ const isIde = this.deps.cdpManagers.has(targetType) || this.deps.providerLoader.getMeta(targetType)?.category === "ide";
18243
+ if (isIde) {
18244
+ await this.stopIde(targetType, true);
18245
+ const launchResult = await this.executeDaemonCommand("launch_ide", { ideType: targetType, enableCdp: true, workspace: args?.workspace });
18246
+ return { success: true, restarted: true, ideType: targetType, launch: launchResult };
18247
+ }
18248
+ return this.deps.cliManager.handleCliCommand(cmd, args);
18249
+ }
18250
+ // ─── IDE stop ───
18251
+ case "stop_ide": {
18252
+ const ideType = args?.ideType;
18253
+ if (!ideType) throw new Error("ideType required");
18254
+ const killProcess = args?.killProcess !== false;
18255
+ await this.stopIde(ideType, killProcess);
18256
+ return { success: true, ideType, stopped: true, processKilled: killProcess };
18257
+ }
18258
+ // ─── IDE restart ───
18259
+ case "restart_ide": {
18260
+ const ideType = args?.ideType;
18261
+ if (!ideType) throw new Error("ideType required");
18262
+ await this.stopIde(ideType, true);
18263
+ const launchResult = await this.executeDaemonCommand("launch_ide", { ideType, enableCdp: true, workspace: args?.workspace });
18264
+ return { success: true, ideType, restarted: true, launch: launchResult };
18265
+ }
18266
+ // ─── IDE launch + CDP connect ───
18267
+ case "launch_ide": {
18268
+ const ideKey = args?.ideId || args?.ideType;
18269
+ const resolvedWorkspace = resolveIdeLaunchWorkspace(
18270
+ {
18271
+ workspace: args?.workspace,
18272
+ workspaceId: args?.workspaceId,
18273
+ useDefaultWorkspace: args?.useDefaultWorkspace
18274
+ },
18275
+ loadConfig()
18276
+ );
18277
+ const launchArgs = {
18278
+ ideId: ideKey,
18279
+ workspace: resolvedWorkspace,
18280
+ newWindow: args?.newWindow
18281
+ };
18282
+ LOG.info("LaunchIDE", `target=${ideKey || "auto"}`);
18283
+ const result = await launchWithCdp(launchArgs);
18284
+ if (result.success && result.port && result.ideId && !this.deps.cdpManagers.has(result.ideId)) {
18285
+ const logFn = this.deps.getCdpLogFn ? this.deps.getCdpLogFn(result.ideId) : LOG.forComponent(`CDP:${result.ideId}`).asLogFn();
18286
+ const provider = this.deps.providerLoader.getMeta(result.ideId);
18287
+ const manager = new DaemonCdpManager(result.port, logFn, void 0, provider?.targetFilter);
18288
+ const connected = await manager.connect();
18289
+ if (connected) {
18290
+ registerExtensionProviders(this.deps.providerLoader, manager, result.ideId);
18291
+ this.deps.cdpManagers.set(result.ideId, manager);
18292
+ LOG.info("CDP", `Connected: ${result.ideId} (port ${result.port})`);
18293
+ LOG.info("CDP", `${this.deps.cdpManagers.size} IDE(s) connected`);
18294
+ this.deps.onCdpManagerCreated?.(result.ideId, manager);
18295
+ }
18296
+ }
18297
+ this.deps.onIdeConnected?.();
18298
+ if (result.success && resolvedWorkspace) {
18299
+ try {
18300
+ const next = appendRecentActivity(loadConfig(), {
18301
+ kind: "ide",
18302
+ providerType: result.ideId || ideKey,
18303
+ providerName: result.ideId || ideKey,
18304
+ workspace: resolvedWorkspace,
18305
+ title: result.ideId || ideKey
18306
+ });
18307
+ saveConfig(next);
18308
+ } catch {
18309
+ }
18310
+ } else if (result.success && (result.ideId || ideKey)) {
18311
+ try {
18312
+ saveConfig(appendRecentActivity(loadConfig(), {
18313
+ kind: "ide",
18314
+ providerType: result.ideId || ideKey,
18315
+ providerName: result.ideId || ideKey,
18316
+ title: result.ideId || ideKey
18317
+ }));
18318
+ } catch {
18319
+ }
18320
+ }
18321
+ return { success: result.success, ...result };
18322
+ }
18323
+ // ─── Detect IDEs ───
18324
+ case "detect_ides": {
18325
+ const results = await detectIDEs();
18326
+ this.deps.detectedIdes.value = results;
18327
+ return { success: true, detectedInfo: results };
18328
+ }
18329
+ // ─── Set User Name ───
18330
+ case "set_user_name": {
18331
+ const name = args?.userName;
18332
+ if (!name || typeof name !== "string") throw new Error("userName required");
18333
+ updateConfig({ userName: name });
18334
+ return { success: true, userName: name };
18335
+ }
18336
+ case "mark_session_seen": {
18337
+ const sessionId = args?.sessionId;
18338
+ if (!sessionId || typeof sessionId !== "string") {
18339
+ return { success: false, error: "sessionId is required" };
18340
+ }
18341
+ const currentConfig = loadConfig();
18342
+ const prevSeenAt = currentConfig.sessionReads?.[sessionId] || 0;
18343
+ const sessionEntries = buildSessionEntries(
18344
+ this.deps.instanceManager.collectAllStates(),
18345
+ this.deps.cdpManagers
18346
+ );
18347
+ const targetSession = sessionEntries.find((entry) => entry.id === sessionId);
18348
+ const completionMarker = targetSession ? getSessionCompletionMarker(targetSession) : "";
18349
+ const next = markSessionSeen(
18350
+ currentConfig,
18351
+ sessionId,
18352
+ typeof args?.seenAt === "number" ? args.seenAt : Date.now(),
18353
+ completionMarker
18354
+ );
18355
+ if (READ_DEBUG_ENABLED2) {
18356
+ LOG.info("RecentRead", `mark_session_seen sessionId=${sessionId} seenAt=${String(args?.seenAt || "")} prevSeenAt=${String(prevSeenAt)} nextSeenAt=${String(next.sessionReads?.[sessionId] || 0)} marker=${completionMarker || "-"}`);
18357
+ }
18358
+ saveConfig(next);
18359
+ this.deps.onStatusChange?.();
18360
+ return {
18361
+ success: true,
18362
+ sessionId,
18363
+ seenAt: next.sessionReads?.[sessionId] || Date.now(),
18364
+ completionMarker
18365
+ };
18366
+ }
18367
+ // ─── Daemon Self-Upgrade ───
18368
+ case "daemon_upgrade": {
18369
+ LOG.info("Upgrade", "Remote upgrade requested from dashboard");
18370
+ try {
18371
+ const { execSync: execSync6 } = await import("child_process");
18372
+ const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
18373
+ const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
18374
+ const latest = execSync6(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
18375
+ LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
18376
+ execSync6(`npm install -g ${pkgName}@latest --force`, {
18377
+ encoding: "utf-8",
18378
+ timeout: 12e4,
18379
+ stdio: ["pipe", "pipe", "pipe"]
18380
+ });
18381
+ LOG.info("Upgrade", `\u2705 Upgraded to v${latest}`);
18382
+ setTimeout(() => {
18383
+ LOG.info("Upgrade", "Restarting daemon with new version...");
18384
+ try {
18385
+ const path18 = require("path");
18386
+ const fs16 = require("fs");
18387
+ const pidFile = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
18388
+ if (fs16.existsSync(pidFile)) fs16.unlinkSync(pidFile);
18389
+ } catch {
18390
+ }
18391
+ const { spawn: spawn4 } = require("child_process");
18392
+ const child = spawn4(process.execPath, process.argv.slice(1), {
18393
+ detached: true,
18394
+ stdio: "ignore",
18395
+ env: { ...process.env }
18396
+ });
18397
+ child.unref();
18398
+ process.exit(0);
18399
+ }, 3e3);
18400
+ return { success: true, upgraded: true, version: latest };
18401
+ } catch (e) {
18402
+ LOG.error("Upgrade", `Failed: ${e.message}`);
18403
+ return { success: false, error: e.message };
18404
+ }
18405
+ }
18406
+ // ─── Machine Settings ───
18407
+ case "set_machine_nickname": {
18408
+ const nickname = args?.nickname;
18409
+ updateConfig({ machineNickname: nickname || null });
18410
+ return { success: true };
18411
+ }
18412
+ default:
18413
+ break;
18414
+ }
18415
+ return null;
18416
+ }
18417
+ /**
18418
+ * IDE stop: CDP disconnect + InstanceManager cleanup + optionally kill OS process
18419
+ */
18420
+ async stopIde(ideType, killProcess = false) {
18421
+ const cdpKeysToRemove = [];
18422
+ for (const key of this.deps.cdpManagers.keys()) {
18423
+ if (key === ideType || key.startsWith(`${ideType}_`)) {
18424
+ cdpKeysToRemove.push(key);
18425
+ }
18426
+ }
18427
+ for (const key of cdpKeysToRemove) {
18428
+ const cdp = this.deps.cdpManagers.get(key);
18429
+ if (cdp) {
18430
+ try {
18431
+ cdp.disconnect();
18432
+ } catch {
18433
+ }
18434
+ this.deps.cdpManagers.delete(key);
18435
+ this.deps.sessionRegistry.unregisterByManagerKey(key);
18436
+ LOG.info("StopIDE", `CDP disconnected: ${key}`);
18437
+ }
18438
+ }
18439
+ const keysToRemove = [];
18440
+ for (const key of this.deps.instanceManager.listInstanceIds()) {
18441
+ if (key === `ide:${ideType}` || typeof key === "string" && key.startsWith(`ide:${ideType}_`)) {
18442
+ keysToRemove.push(key);
18443
+ }
18444
+ }
18445
+ for (const instanceKey of keysToRemove) {
18446
+ const ideInstance = this.deps.instanceManager.getInstance(instanceKey);
18447
+ if (ideInstance) {
18448
+ this.deps.instanceManager.removeInstance(instanceKey);
18449
+ LOG.info("StopIDE", `Instance removed: ${instanceKey}`);
18450
+ }
18451
+ }
18452
+ if (keysToRemove.length === 0) {
18453
+ const instanceKey = `ide:${ideType}`;
18454
+ const ideInstance = this.deps.instanceManager.getInstance(instanceKey);
18455
+ if (ideInstance) {
18456
+ this.deps.instanceManager.removeInstance(instanceKey);
18457
+ LOG.info("StopIDE", `Instance removed: ${instanceKey}`);
18458
+ }
18459
+ }
18460
+ if (killProcess) {
18461
+ const running = isIdeRunning(ideType);
18462
+ if (running) {
18463
+ LOG.info("StopIDE", `Killing IDE process: ${ideType}`);
18464
+ const killed = await killIdeProcess(ideType);
18465
+ if (killed) {
18466
+ LOG.info("StopIDE", `\u2705 Process killed: ${ideType}`);
18467
+ } else {
18468
+ LOG.warn("StopIDE", `\u26A0 Could not kill process: ${ideType} (may need manual intervention)`);
18469
+ }
18470
+ } else {
18471
+ LOG.info("StopIDE", `Process not running: ${ideType}`);
18472
+ }
18473
+ }
18474
+ this.deps.onStatusChange?.();
18475
+ LOG.info("StopIDE", `IDE stopped: ${ideType} (processKill=${killProcess})`);
18476
+ }
18477
+ };
18647
18478
  }
18648
18479
  });
18649
18480
 
@@ -18802,10 +18633,11 @@ var init_reporter = __esm({
18802
18633
  currentModel: session.currentModel,
18803
18634
  currentPlan: session.currentPlan,
18804
18635
  currentAutoApprove: session.currentAutoApprove,
18805
- recentKey: session.recentKey,
18636
+ lastUpdated: session.lastUpdated,
18806
18637
  unread: session.unread,
18807
18638
  lastSeenAt: session.lastSeenAt,
18808
18639
  inboxBucket: session.inboxBucket,
18640
+ surfaceHidden: session.surfaceHidden,
18809
18641
  controlValues: session.controlValues,
18810
18642
  providerControls: session.providerControls,
18811
18643
  acpConfigOptions: session.acpConfigOptions,
@@ -18923,7 +18755,7 @@ function findBinary(name) {
18923
18755
  }
18924
18756
  }
18925
18757
  function isScriptBinary(binaryPath) {
18926
- if (!path10.isAbsolute(binaryPath)) return false;
18758
+ if (!path9.isAbsolute(binaryPath)) return false;
18927
18759
  try {
18928
18760
  const fs16 = require("fs");
18929
18761
  const resolved = fs16.realpathSync(binaryPath);
@@ -18939,7 +18771,7 @@ function isScriptBinary(binaryPath) {
18939
18771
  }
18940
18772
  }
18941
18773
  function looksLikeMachOOrElf(filePath) {
18942
- if (!path10.isAbsolute(filePath)) return false;
18774
+ if (!path9.isAbsolute(filePath)) return false;
18943
18775
  try {
18944
18776
  const fs16 = require("fs");
18945
18777
  const resolved = fs16.realpathSync(filePath);
@@ -19053,12 +18885,12 @@ function normalizeCliProviderForRuntime(raw) {
19053
18885
  }
19054
18886
  };
19055
18887
  }
19056
- var os13, path10, import_child_process5, pty2, ProviderCliAdapter;
18888
+ var os13, path9, import_child_process5, pty2, ProviderCliAdapter;
19057
18889
  var init_provider_cli_adapter = __esm({
19058
18890
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
19059
18891
  "use strict";
19060
18892
  os13 = __toESM(require("os"));
19061
- path10 = __toESM(require("path"));
18893
+ path9 = __toESM(require("path"));
19062
18894
  import_child_process5 = require("child_process");
19063
18895
  init_logger();
19064
18896
  init_terminal_screen();
@@ -19068,9 +18900,9 @@ var init_provider_cli_adapter = __esm({
19068
18900
  if (os13.platform() !== "win32") {
19069
18901
  try {
19070
18902
  const fs16 = require("fs");
19071
- const ptyDir = path10.resolve(path10.dirname(require.resolve("node-pty")), "..");
18903
+ const ptyDir = path9.resolve(path9.dirname(require.resolve("node-pty")), "..");
19072
18904
  const platformArch = `${os13.platform()}-${os13.arch()}`;
19073
- const helper = path10.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
18905
+ const helper = path9.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
19074
18906
  if (fs16.existsSync(helper)) {
19075
18907
  const stat4 = fs16.statSync(helper);
19076
18908
  if (!(stat4.mode & 73)) {
@@ -19259,7 +19091,7 @@ var init_provider_cli_adapter = __esm({
19259
19091
  LOG.info("CLI", `[${this.cliType}] Spawning in ${this.workingDir}`);
19260
19092
  let shellCmd;
19261
19093
  let shellArgs;
19262
- const useShellUnix = !isWin && (!!spawnConfig.shell || !path10.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
19094
+ const useShellUnix = !isWin && (!!spawnConfig.shell || !path9.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
19263
19095
  const useShell = isWin ? !!spawnConfig.shell : useShellUnix;
19264
19096
  if (useShell) {
19265
19097
  if (!spawnConfig.shell && !isWin) {
@@ -19684,7 +19516,7 @@ ${data.message || ""}`.trim();
19684
19516
  if (this.startupParseGate) {
19685
19517
  const deadline = Date.now() + 1e4;
19686
19518
  while (this.startupParseGate && Date.now() < deadline) {
19687
- await new Promise((resolve13) => setTimeout(resolve13, 50));
19519
+ await new Promise((resolve12) => setTimeout(resolve12, 50));
19688
19520
  }
19689
19521
  }
19690
19522
  if (!this.ready) throw new Error(`${this.cliName} not ready (status: ${this.currentStatus})`);
@@ -19852,17 +19684,17 @@ ${data.message || ""}`.trim();
19852
19684
  }
19853
19685
  }
19854
19686
  waitForStopped(timeoutMs) {
19855
- return new Promise((resolve13) => {
19687
+ return new Promise((resolve12) => {
19856
19688
  const startedAt = Date.now();
19857
19689
  const timer = setInterval(() => {
19858
19690
  if (!this.ptyProcess || this.currentStatus === "stopped") {
19859
19691
  clearInterval(timer);
19860
- resolve13(true);
19692
+ resolve12(true);
19861
19693
  return;
19862
19694
  }
19863
19695
  if (Date.now() - startedAt >= timeoutMs) {
19864
19696
  clearInterval(timer);
19865
- resolve13(false);
19697
+ resolve12(false);
19866
19698
  }
19867
19699
  }, 100);
19868
19700
  });
@@ -20551,10 +20383,10 @@ function mergeDefs(...defs) {
20551
20383
  function cloneDef(schema) {
20552
20384
  return mergeDefs(schema._zod.def);
20553
20385
  }
20554
- function getElementAtPath(obj, path19) {
20555
- if (!path19)
20386
+ function getElementAtPath(obj, path18) {
20387
+ if (!path18)
20556
20388
  return obj;
20557
- return path19.reduce((acc, key) => acc?.[key], obj);
20389
+ return path18.reduce((acc, key) => acc?.[key], obj);
20558
20390
  }
20559
20391
  function promiseAllObject(promisesObj) {
20560
20392
  const keys = Object.keys(promisesObj);
@@ -20866,11 +20698,11 @@ function aborted(x, startIndex = 0) {
20866
20698
  }
20867
20699
  return false;
20868
20700
  }
20869
- function prefixIssues(path19, issues) {
20701
+ function prefixIssues(path18, issues) {
20870
20702
  return issues.map((iss) => {
20871
20703
  var _a2;
20872
20704
  (_a2 = iss).path ?? (_a2.path = []);
20873
- iss.path.unshift(path19);
20705
+ iss.path.unshift(path18);
20874
20706
  return iss;
20875
20707
  });
20876
20708
  }
@@ -21113,7 +20945,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
21113
20945
  }
21114
20946
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
21115
20947
  const result = { errors: [] };
21116
- const processError = (error49, path19 = []) => {
20948
+ const processError = (error49, path18 = []) => {
21117
20949
  var _a2, _b;
21118
20950
  for (const issue2 of error49.issues) {
21119
20951
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -21123,7 +20955,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
21123
20955
  } else if (issue2.code === "invalid_element") {
21124
20956
  processError({ issues: issue2.issues }, issue2.path);
21125
20957
  } else {
21126
- const fullpath = [...path19, ...issue2.path];
20958
+ const fullpath = [...path18, ...issue2.path];
21127
20959
  if (fullpath.length === 0) {
21128
20960
  result.errors.push(mapper(issue2));
21129
20961
  continue;
@@ -21155,8 +20987,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
21155
20987
  }
21156
20988
  function toDotPath(_path) {
21157
20989
  const segs = [];
21158
- const path19 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
21159
- for (const seg of path19) {
20990
+ const path18 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
20991
+ for (const seg of path18) {
21160
20992
  if (typeof seg === "number")
21161
20993
  segs.push(`[${seg}]`);
21162
20994
  else if (typeof seg === "symbol")
@@ -33920,13 +33752,13 @@ function resolveRef(ref, ctx) {
33920
33752
  if (!ref.startsWith("#")) {
33921
33753
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
33922
33754
  }
33923
- const path19 = ref.slice(1).split("/").filter(Boolean);
33924
- if (path19.length === 0) {
33755
+ const path18 = ref.slice(1).split("/").filter(Boolean);
33756
+ if (path18.length === 0) {
33925
33757
  return ctx.rootSchema;
33926
33758
  }
33927
33759
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
33928
- if (path19[0] === defsKey) {
33929
- const key = path19[1];
33760
+ if (path18[0] === defsKey) {
33761
+ const key = path18[1];
33930
33762
  if (!key || !ctx.defs[key]) {
33931
33763
  throw new Error(`Reference not found: ${ref}`);
33932
33764
  }
@@ -36353,8 +36185,8 @@ var init_acp = __esm({
36353
36185
  this.#requestHandler = requestHandler;
36354
36186
  this.#notificationHandler = notificationHandler;
36355
36187
  this.#stream = stream;
36356
- this.#closedPromise = new Promise((resolve13) => {
36357
- this.#abortController.signal.addEventListener("abort", () => resolve13());
36188
+ this.#closedPromise = new Promise((resolve12) => {
36189
+ this.#abortController.signal.addEventListener("abort", () => resolve12());
36358
36190
  });
36359
36191
  this.#receive();
36360
36192
  }
@@ -36503,8 +36335,8 @@ var init_acp = __esm({
36503
36335
  }
36504
36336
  async sendRequest(method, params) {
36505
36337
  const id = this.#nextRequestId++;
36506
- const responsePromise = new Promise((resolve13, reject) => {
36507
- this.#pendingResponses.set(id, { resolve: resolve13, reject });
36338
+ const responsePromise = new Promise((resolve12, reject) => {
36339
+ this.#pendingResponses.set(id, { resolve: resolve12, reject });
36508
36340
  });
36509
36341
  await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
36510
36342
  return responsePromise;
@@ -37044,13 +36876,13 @@ var init_acp_provider_instance = __esm({
37044
36876
  }
37045
36877
  this.currentStatus = "waiting_approval";
37046
36878
  this.detectStatusTransition();
37047
- const approved = await new Promise((resolve13) => {
37048
- this.permissionResolvers.push(resolve13);
36879
+ const approved = await new Promise((resolve12) => {
36880
+ this.permissionResolvers.push(resolve12);
37049
36881
  setTimeout(() => {
37050
- const idx = this.permissionResolvers.indexOf(resolve13);
36882
+ const idx = this.permissionResolvers.indexOf(resolve12);
37051
36883
  if (idx >= 0) {
37052
36884
  this.permissionResolvers.splice(idx, 1);
37053
- resolve13(false);
36885
+ resolve12(false);
37054
36886
  }
37055
36887
  }, 3e5);
37056
36888
  });
@@ -37512,19 +37344,18 @@ function colorize(color, text) {
37512
37344
  const fn2 = chalkApi?.[color];
37513
37345
  return typeof fn2 === "function" ? fn2(text) : text;
37514
37346
  }
37515
- var os14, path11, crypto4, import_chalk, chalkApi, DaemonCliManager;
37347
+ var os14, path10, crypto4, import_chalk, chalkApi, DaemonCliManager;
37516
37348
  var init_cli_manager = __esm({
37517
37349
  "../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
37518
37350
  "use strict";
37519
37351
  os14 = __toESM(require("os"));
37520
- path11 = __toESM(require("path"));
37352
+ path10 = __toESM(require("path"));
37521
37353
  crypto4 = __toESM(require("crypto"));
37522
37354
  import_chalk = __toESM(require("chalk"));
37523
37355
  init_provider_cli_adapter();
37524
37356
  init_cli_detector();
37525
37357
  init_config();
37526
37358
  init_workspaces();
37527
- init_workspace_activity();
37528
37359
  init_recent_activity();
37529
37360
  init_cli_provider_instance();
37530
37361
  init_acp_provider_instance();
@@ -37543,24 +37374,6 @@ var init_cli_manager = __esm({
37543
37374
  const hash2 = require("crypto").createHash("md5").update(require("path").resolve(dir)).digest("hex").slice(0, 8);
37544
37375
  return `${cliType}_${hash2}`;
37545
37376
  }
37546
- persistRecentDir(cliType, dir) {
37547
- try {
37548
- const normalizedType = this.providerLoader.resolveAlias(cliType);
37549
- const provider = this.providerLoader.getByAlias(cliType);
37550
- const actKind = provider?.category === "acp" ? "acp" : "cli";
37551
- let next = loadConfig();
37552
- console.log(colorize("cyan", ` \u{1F4C2} Saving recent workspace: ${dir}`));
37553
- const recent = next.recentCliWorkspaces || [];
37554
- if (!recent.includes(dir)) {
37555
- next = { ...next, recentCliWorkspaces: [dir, ...recent].slice(0, 10) };
37556
- }
37557
- next = appendWorkspaceActivity(next, dir, { kind: actKind, agentType: normalizedType });
37558
- saveConfig(next);
37559
- console.log(colorize("green", ` \u2713 Recent workspace saved: ${dir}`));
37560
- } catch (e) {
37561
- console.error(colorize("red", ` \u2717 Failed to save recent workspace: ${e}`));
37562
- }
37563
- }
37564
37377
  persistRecentActivity(entry) {
37565
37378
  try {
37566
37379
  saveConfig(appendRecentActivity(loadConfig(), entry));
@@ -37650,7 +37463,7 @@ var init_cli_manager = __esm({
37650
37463
  async startSession(cliType, workingDir, cliArgs, initialModel) {
37651
37464
  const trimmed = (workingDir || "").trim();
37652
37465
  if (!trimmed) throw new Error("working directory required");
37653
- const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os14.homedir()) : path11.resolve(trimmed);
37466
+ const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os14.homedir()) : path10.resolve(trimmed);
37654
37467
  const normalizedType = this.providerLoader.resolveAlias(cliType);
37655
37468
  const provider = this.providerLoader.getByAlias(cliType);
37656
37469
  const key = crypto4.randomUUID();
@@ -37721,11 +37534,6 @@ ${installInfo}`
37721
37534
  LOG.warn("CLI", `[ACP] Initial model set failed: ${e?.message}`);
37722
37535
  }
37723
37536
  }
37724
- try {
37725
- addCliHistory({ category: "acp", cliType: normalizedType, dir: resolvedDir, workspace: resolvedDir, cliArgs, model: initialModel });
37726
- } catch (e) {
37727
- LOG.warn("CLI", `ACP history save failed: ${e?.message}`);
37728
- }
37729
37537
  this.persistRecentActivity({
37730
37538
  kind: "acp",
37731
37539
  providerType: normalizedType,
@@ -37792,11 +37600,6 @@ ${installInfo}`
37792
37600
  this.adapters.set(key, adapter);
37793
37601
  console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
37794
37602
  }
37795
- try {
37796
- addCliHistory({ category: "cli", cliType, dir: resolvedDir, workspace: resolvedDir, cliArgs, model: initialModel });
37797
- } catch (e) {
37798
- LOG.warn("CLI", `CLI history save failed: ${e?.message}`);
37799
- }
37800
37603
  this.persistRecentActivity({
37801
37604
  kind: "cli",
37802
37605
  providerType: normalizedType,
@@ -37949,7 +37752,6 @@ ${installInfo}`
37949
37752
  newKey = k;
37950
37753
  }
37951
37754
  }
37952
- this.persistRecentDir(cliType, dir);
37953
37755
  return { success: true, cliType, dir, id: newKey, launchSource };
37954
37756
  }
37955
37757
  case "stop_cli": {
@@ -37992,7 +37794,6 @@ ${installInfo}`
37992
37794
  const found = this.findAdapter(cliType, { instanceKey: args?.targetSessionId, dir });
37993
37795
  if (found) await this.stopSession(found.key);
37994
37796
  await this.startSession(cliType, dir);
37995
- this.persistRecentDir(cliType, dir);
37996
37797
  return { success: true, restarted: true };
37997
37798
  }
37998
37799
  case "agent_command": {
@@ -38905,7 +38706,7 @@ function checkPathExists2(paths) {
38905
38706
  for (const p of paths) {
38906
38707
  if (p.includes("*")) {
38907
38708
  const home = os15.homedir();
38908
- const resolved = p.replace(/\*/g, home.split(path12.sep).pop() || "");
38709
+ const resolved = p.replace(/\*/g, home.split(path11.sep).pop() || "");
38909
38710
  if (fs9.existsSync(resolved)) return resolved;
38910
38711
  } else {
38911
38712
  if (fs9.existsSync(p)) return p;
@@ -38915,7 +38716,7 @@ function checkPathExists2(paths) {
38915
38716
  }
38916
38717
  function getMacAppVersion(appPath) {
38917
38718
  if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
38918
- const plistPath = path12.join(appPath, "Contents", "Info.plist");
38719
+ const plistPath = path11.join(appPath, "Contents", "Info.plist");
38919
38720
  if (!fs9.existsSync(plistPath)) return null;
38920
38721
  const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
38921
38722
  return raw || null;
@@ -38942,7 +38743,7 @@ async function detectAllVersions(loader, archive) {
38942
38743
  const cliBin = provider.cli ? findBinary2(provider.cli) : null;
38943
38744
  let resolvedBin = cliBin;
38944
38745
  if (!resolvedBin && appPath && currentOs === "darwin") {
38945
- const bundled = path12.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
38746
+ const bundled = path11.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
38946
38747
  if (provider.cli && fs9.existsSync(bundled)) resolvedBin = bundled;
38947
38748
  }
38948
38749
  info.installed = !!(appPath || resolvedBin);
@@ -38979,16 +38780,16 @@ async function detectAllVersions(loader, archive) {
38979
38780
  }
38980
38781
  return results;
38981
38782
  }
38982
- var fs9, path12, os15, import_child_process7, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
38783
+ var fs9, path11, os15, import_child_process7, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
38983
38784
  var init_version_archive = __esm({
38984
38785
  "../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
38985
38786
  "use strict";
38986
38787
  fs9 = __toESM(require("fs"));
38987
- path12 = __toESM(require("path"));
38788
+ path11 = __toESM(require("path"));
38988
38789
  os15 = __toESM(require("os"));
38989
38790
  import_child_process7 = require("child_process");
38990
38791
  import_os3 = require("os");
38991
- ARCHIVE_PATH = path12.join(os15.homedir(), ".adhdev", "version-history.json");
38792
+ ARCHIVE_PATH = path11.join(os15.homedir(), ".adhdev", "version-history.json");
38992
38793
  MAX_ENTRIES_PER_PROVIDER = 20;
38993
38794
  VersionArchive = class {
38994
38795
  history = {};
@@ -39035,7 +38836,7 @@ var init_version_archive = __esm({
39035
38836
  }
39036
38837
  save() {
39037
38838
  try {
39038
- fs9.mkdirSync(path12.dirname(ARCHIVE_PATH), { recursive: true });
38839
+ fs9.mkdirSync(path11.dirname(ARCHIVE_PATH), { recursive: true });
39039
38840
  fs9.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
39040
38841
  } catch {
39041
38842
  }
@@ -39556,17 +39357,17 @@ async function handleScriptHints(ctx, type, _req, res) {
39556
39357
  return;
39557
39358
  }
39558
39359
  let scriptsPath = "";
39559
- const directScripts = path13.join(dir, "scripts.js");
39360
+ const directScripts = path12.join(dir, "scripts.js");
39560
39361
  if (fs10.existsSync(directScripts)) {
39561
39362
  scriptsPath = directScripts;
39562
39363
  } else {
39563
- const scriptsDir = path13.join(dir, "scripts");
39364
+ const scriptsDir = path12.join(dir, "scripts");
39564
39365
  if (fs10.existsSync(scriptsDir)) {
39565
39366
  const versions = fs10.readdirSync(scriptsDir).filter((d) => {
39566
- return fs10.statSync(path13.join(scriptsDir, d)).isDirectory();
39367
+ return fs10.statSync(path12.join(scriptsDir, d)).isDirectory();
39567
39368
  }).sort().reverse();
39568
39369
  for (const ver of versions) {
39569
- const p = path13.join(scriptsDir, ver, "scripts.js");
39370
+ const p = path12.join(scriptsDir, ver, "scripts.js");
39570
39371
  if (fs10.existsSync(p)) {
39571
39372
  scriptsPath = p;
39572
39373
  break;
@@ -40382,12 +40183,12 @@ async function handleDomContext(ctx, type, req, res) {
40382
40183
  ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
40383
40184
  }
40384
40185
  }
40385
- var fs10, path13;
40186
+ var fs10, path12;
40386
40187
  var init_dev_cdp_handlers = __esm({
40387
40188
  "../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
40388
40189
  "use strict";
40389
40190
  fs10 = __toESM(require("fs"));
40390
- path13 = __toESM(require("path"));
40191
+ path12 = __toESM(require("path"));
40391
40192
  init_logger();
40392
40193
  }
40393
40194
  });
@@ -40652,22 +40453,22 @@ function getLatestScriptVersionDir(scriptsDir) {
40652
40453
  if (!fs11.existsSync(scriptsDir)) return null;
40653
40454
  const versions = fs11.readdirSync(scriptsDir).filter((d) => {
40654
40455
  try {
40655
- return fs11.statSync(path14.join(scriptsDir, d)).isDirectory();
40456
+ return fs11.statSync(path13.join(scriptsDir, d)).isDirectory();
40656
40457
  } catch {
40657
40458
  return false;
40658
40459
  }
40659
40460
  }).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
40660
40461
  if (versions.length === 0) return null;
40661
- return path14.join(scriptsDir, versions[0]);
40462
+ return path13.join(scriptsDir, versions[0]);
40662
40463
  }
40663
40464
  function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
40664
- const canonicalUserDir = path14.resolve(ctx.providerLoader.getUserProviderDir(category, type));
40665
- const desiredDir = requestedDir ? path14.resolve(requestedDir) : canonicalUserDir;
40666
- const upstreamRoot = path14.resolve(ctx.providerLoader.getUpstreamDir());
40667
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path14.sep}`)) {
40465
+ const canonicalUserDir = path13.resolve(ctx.providerLoader.getUserProviderDir(category, type));
40466
+ const desiredDir = requestedDir ? path13.resolve(requestedDir) : canonicalUserDir;
40467
+ const upstreamRoot = path13.resolve(ctx.providerLoader.getUpstreamDir());
40468
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path13.sep}`)) {
40668
40469
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
40669
40470
  }
40670
- if (path14.basename(desiredDir) !== type) {
40471
+ if (path13.basename(desiredDir) !== type) {
40671
40472
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
40672
40473
  }
40673
40474
  const sourceDir = ctx.findProviderDir(type);
@@ -40675,11 +40476,11 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
40675
40476
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
40676
40477
  }
40677
40478
  if (!fs11.existsSync(desiredDir)) {
40678
- fs11.mkdirSync(path14.dirname(desiredDir), { recursive: true });
40479
+ fs11.mkdirSync(path13.dirname(desiredDir), { recursive: true });
40679
40480
  fs11.cpSync(sourceDir, desiredDir, { recursive: true });
40680
40481
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
40681
40482
  }
40682
- const providerJson = path14.join(desiredDir, "provider.json");
40483
+ const providerJson = path13.join(desiredDir, "provider.json");
40683
40484
  if (!fs11.existsSync(providerJson)) {
40684
40485
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
40685
40486
  }
@@ -40702,13 +40503,13 @@ function loadAutoImplReferenceScripts(ctx, referenceType) {
40702
40503
  const refDir = ctx.findProviderDir(referenceType);
40703
40504
  if (!refDir || !fs11.existsSync(refDir)) return {};
40704
40505
  const referenceScripts = {};
40705
- const scriptsDir = path14.join(refDir, "scripts");
40506
+ const scriptsDir = path13.join(refDir, "scripts");
40706
40507
  const latestDir = getLatestScriptVersionDir(scriptsDir);
40707
40508
  if (!latestDir) return referenceScripts;
40708
40509
  for (const file2 of fs11.readdirSync(latestDir)) {
40709
40510
  if (!file2.endsWith(".js")) continue;
40710
40511
  try {
40711
- referenceScripts[file2] = fs11.readFileSync(path14.join(latestDir, file2), "utf-8");
40512
+ referenceScripts[file2] = fs11.readFileSync(path13.join(latestDir, file2), "utf-8");
40712
40513
  } catch {
40713
40514
  }
40714
40515
  }
@@ -40759,9 +40560,9 @@ async function handleAutoImplement(ctx, type, req, res) {
40759
40560
  });
40760
40561
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
40761
40562
  const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference);
40762
- const tmpDir = path14.join(os16.tmpdir(), "adhdev-autoimpl");
40563
+ const tmpDir = path13.join(os16.tmpdir(), "adhdev-autoimpl");
40763
40564
  if (!fs11.existsSync(tmpDir)) fs11.mkdirSync(tmpDir, { recursive: true });
40764
- const promptFile = path14.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
40565
+ const promptFile = path13.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
40765
40566
  fs11.writeFileSync(promptFile, prompt, "utf-8");
40766
40567
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
40767
40568
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
@@ -41132,7 +40933,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
41132
40933
  setMode: "set_mode.js"
41133
40934
  };
41134
40935
  const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
41135
- const scriptsDir = path14.join(providerDir, "scripts");
40936
+ const scriptsDir = path13.join(providerDir, "scripts");
41136
40937
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
41137
40938
  if (latestScriptsDir) {
41138
40939
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -41143,7 +40944,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
41143
40944
  for (const file2 of fs11.readdirSync(latestScriptsDir)) {
41144
40945
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
41145
40946
  try {
41146
- const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
40947
+ const content = fs11.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
41147
40948
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
41148
40949
  lines.push("```javascript");
41149
40950
  lines.push(content);
@@ -41160,7 +40961,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
41160
40961
  lines.push("");
41161
40962
  for (const file2 of refFiles) {
41162
40963
  try {
41163
- const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
40964
+ const content = fs11.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
41164
40965
  lines.push(`### \`${file2}\` \u{1F512}`);
41165
40966
  lines.push("```javascript");
41166
40967
  lines.push(content);
@@ -41201,10 +41002,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
41201
41002
  lines.push("");
41202
41003
  }
41203
41004
  }
41204
- const docsDir = path14.join(providerDir, "../../docs");
41005
+ const docsDir = path13.join(providerDir, "../../docs");
41205
41006
  const loadGuide = (name) => {
41206
41007
  try {
41207
- const p = path14.join(docsDir, name);
41008
+ const p = path13.join(docsDir, name);
41208
41009
  if (fs11.existsSync(p)) return fs11.readFileSync(p, "utf-8");
41209
41010
  } catch {
41210
41011
  }
@@ -41378,7 +41179,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
41378
41179
  parseApproval: "parse_approval.js"
41379
41180
  };
41380
41181
  const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
41381
- const scriptsDir = path14.join(providerDir, "scripts");
41182
+ const scriptsDir = path13.join(providerDir, "scripts");
41382
41183
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
41383
41184
  if (latestScriptsDir) {
41384
41185
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -41390,7 +41191,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
41390
41191
  if (!file2.endsWith(".js")) continue;
41391
41192
  if (!targetFileNames.has(file2)) continue;
41392
41193
  try {
41393
- const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
41194
+ const content = fs11.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
41394
41195
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
41395
41196
  lines.push("```javascript");
41396
41197
  lines.push(content);
@@ -41406,7 +41207,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
41406
41207
  lines.push("");
41407
41208
  for (const file2 of refFiles) {
41408
41209
  try {
41409
- const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
41210
+ const content = fs11.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
41410
41211
  lines.push(`### \`${file2}\` \u{1F512}`);
41411
41212
  lines.push("```javascript");
41412
41213
  lines.push(content);
@@ -41439,10 +41240,10 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
41439
41240
  lines.push("");
41440
41241
  }
41441
41242
  }
41442
- const docsDir = path14.join(providerDir, "../../docs");
41243
+ const docsDir = path13.join(providerDir, "../../docs");
41443
41244
  const loadGuide = (name) => {
41444
41245
  try {
41445
- const p = path14.join(docsDir, name);
41246
+ const p = path13.join(docsDir, name);
41446
41247
  if (fs11.existsSync(p)) return fs11.readFileSync(p, "utf-8");
41447
41248
  } catch {
41448
41249
  }
@@ -41606,25 +41407,25 @@ data: ${JSON.stringify(msg.data)}
41606
41407
  }
41607
41408
  }
41608
41409
  }
41609
- var fs11, path14, os16;
41410
+ var fs11, path13, os16;
41610
41411
  var init_dev_auto_implement = __esm({
41611
41412
  "../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
41612
41413
  "use strict";
41613
41414
  fs11 = __toESM(require("fs"));
41614
- path14 = __toESM(require("path"));
41415
+ path13 = __toESM(require("path"));
41615
41416
  os16 = __toESM(require("os"));
41616
41417
  init_dev_server();
41617
41418
  }
41618
41419
  });
41619
41420
 
41620
41421
  // ../../oss/packages/daemon-core/src/daemon/dev-server.ts
41621
- var http2, fs12, path15, DEV_SERVER_PORT, DevServer;
41422
+ var http2, fs12, path14, DEV_SERVER_PORT, DevServer;
41622
41423
  var init_dev_server = __esm({
41623
41424
  "../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
41624
41425
  "use strict";
41625
41426
  http2 = __toESM(require("http"));
41626
41427
  fs12 = __toESM(require("fs"));
41627
- path15 = __toESM(require("path"));
41428
+ path14 = __toESM(require("path"));
41628
41429
  init_scaffold_template();
41629
41430
  init_version_archive();
41630
41431
  init_logger();
@@ -41723,8 +41524,8 @@ var init_dev_server = __esm({
41723
41524
  }
41724
41525
  getEndpointList() {
41725
41526
  return this.routes.map((r) => {
41726
- const path19 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
41727
- return `${r.method.padEnd(5)} ${path19}`;
41527
+ const path18 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
41528
+ return `${r.method.padEnd(5)} ${path18}`;
41728
41529
  });
41729
41530
  }
41730
41531
  async start(port = DEV_SERVER_PORT) {
@@ -41755,15 +41556,15 @@ var init_dev_server = __esm({
41755
41556
  this.json(res, 500, { error: e.message });
41756
41557
  }
41757
41558
  });
41758
- return new Promise((resolve13, reject) => {
41559
+ return new Promise((resolve12, reject) => {
41759
41560
  this.server.listen(port, "127.0.0.1", () => {
41760
41561
  this.log(`Dev server listening on http://127.0.0.1:${port}`);
41761
- resolve13();
41562
+ resolve12();
41762
41563
  });
41763
41564
  this.server.on("error", (e) => {
41764
41565
  if (e.code === "EADDRINUSE") {
41765
41566
  this.log(`Port ${port} in use, skipping dev server`);
41766
- resolve13();
41567
+ resolve12();
41767
41568
  } else {
41768
41569
  reject(e);
41769
41570
  }
@@ -41846,20 +41647,20 @@ var init_dev_server = __esm({
41846
41647
  child.stderr?.on("data", (d) => {
41847
41648
  stderr += d.toString().slice(0, 2e3);
41848
41649
  });
41849
- await new Promise((resolve13) => {
41650
+ await new Promise((resolve12) => {
41850
41651
  const timer = setTimeout(() => {
41851
41652
  child.kill();
41852
- resolve13();
41653
+ resolve12();
41853
41654
  }, 3e3);
41854
41655
  child.on("exit", () => {
41855
41656
  clearTimeout(timer);
41856
- resolve13();
41657
+ resolve12();
41857
41658
  });
41858
41659
  child.stdout?.once("data", () => {
41859
41660
  setTimeout(() => {
41860
41661
  child.kill();
41861
41662
  clearTimeout(timer);
41862
- resolve13();
41663
+ resolve12();
41863
41664
  }, 500);
41864
41665
  });
41865
41666
  });
@@ -42006,12 +41807,12 @@ var init_dev_server = __esm({
42006
41807
  // ─── DevConsole SPA ───
42007
41808
  getConsoleDistDir() {
42008
41809
  const candidates = [
42009
- path15.resolve(__dirname, "../../web-devconsole/dist"),
42010
- path15.resolve(__dirname, "../../../web-devconsole/dist"),
42011
- path15.join(process.cwd(), "packages/web-devconsole/dist")
41810
+ path14.resolve(__dirname, "../../web-devconsole/dist"),
41811
+ path14.resolve(__dirname, "../../../web-devconsole/dist"),
41812
+ path14.join(process.cwd(), "packages/web-devconsole/dist")
42012
41813
  ];
42013
41814
  for (const dir of candidates) {
42014
- if (fs12.existsSync(path15.join(dir, "index.html"))) return dir;
41815
+ if (fs12.existsSync(path14.join(dir, "index.html"))) return dir;
42015
41816
  }
42016
41817
  return null;
42017
41818
  }
@@ -42021,7 +41822,7 @@ var init_dev_server = __esm({
42021
41822
  this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
42022
41823
  return;
42023
41824
  }
42024
- const htmlPath = path15.join(distDir, "index.html");
41825
+ const htmlPath = path14.join(distDir, "index.html");
42025
41826
  try {
42026
41827
  const html = fs12.readFileSync(htmlPath, "utf-8");
42027
41828
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
@@ -42046,15 +41847,15 @@ var init_dev_server = __esm({
42046
41847
  this.json(res, 404, { error: "Not found" });
42047
41848
  return;
42048
41849
  }
42049
- const safePath = path15.normalize(pathname).replace(/^\.\.\//, "");
42050
- const filePath = path15.join(distDir, safePath);
41850
+ const safePath = path14.normalize(pathname).replace(/^\.\.\//, "");
41851
+ const filePath = path14.join(distDir, safePath);
42051
41852
  if (!filePath.startsWith(distDir)) {
42052
41853
  this.json(res, 403, { error: "Forbidden" });
42053
41854
  return;
42054
41855
  }
42055
41856
  try {
42056
41857
  const content = fs12.readFileSync(filePath);
42057
- const ext = path15.extname(filePath);
41858
+ const ext = path14.extname(filePath);
42058
41859
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
42059
41860
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
42060
41861
  res.end(content);
@@ -42167,9 +41968,9 @@ var init_dev_server = __esm({
42167
41968
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
42168
41969
  if (entry.isDirectory()) {
42169
41970
  files.push({ path: rel, size: 0, type: "dir" });
42170
- scan(path15.join(d, entry.name), rel);
41971
+ scan(path14.join(d, entry.name), rel);
42171
41972
  } else {
42172
- const stat4 = fs12.statSync(path15.join(d, entry.name));
41973
+ const stat4 = fs12.statSync(path14.join(d, entry.name));
42173
41974
  files.push({ path: rel, size: stat4.size, type: "file" });
42174
41975
  }
42175
41976
  }
@@ -42192,7 +41993,7 @@ var init_dev_server = __esm({
42192
41993
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
42193
41994
  return;
42194
41995
  }
42195
- const fullPath = path15.resolve(dir, path15.normalize(filePath));
41996
+ const fullPath = path14.resolve(dir, path14.normalize(filePath));
42196
41997
  if (!fullPath.startsWith(dir)) {
42197
41998
  this.json(res, 403, { error: "Forbidden" });
42198
41999
  return;
@@ -42217,14 +42018,14 @@ var init_dev_server = __esm({
42217
42018
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
42218
42019
  return;
42219
42020
  }
42220
- const fullPath = path15.resolve(dir, path15.normalize(filePath));
42021
+ const fullPath = path14.resolve(dir, path14.normalize(filePath));
42221
42022
  if (!fullPath.startsWith(dir)) {
42222
42023
  this.json(res, 403, { error: "Forbidden" });
42223
42024
  return;
42224
42025
  }
42225
42026
  try {
42226
42027
  if (fs12.existsSync(fullPath)) fs12.copyFileSync(fullPath, fullPath + ".bak");
42227
- fs12.mkdirSync(path15.dirname(fullPath), { recursive: true });
42028
+ fs12.mkdirSync(path14.dirname(fullPath), { recursive: true });
42228
42029
  fs12.writeFileSync(fullPath, content, "utf-8");
42229
42030
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
42230
42031
  this.providerLoader.reload();
@@ -42241,7 +42042,7 @@ var init_dev_server = __esm({
42241
42042
  return;
42242
42043
  }
42243
42044
  for (const name of ["scripts.js", "provider.json"]) {
42244
- const p = path15.join(dir, name);
42045
+ const p = path14.join(dir, name);
42245
42046
  if (fs12.existsSync(p)) {
42246
42047
  const source = fs12.readFileSync(p, "utf-8");
42247
42048
  this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
@@ -42262,8 +42063,8 @@ var init_dev_server = __esm({
42262
42063
  this.json(res, 404, { error: `Provider not found: ${type}` });
42263
42064
  return;
42264
42065
  }
42265
- const target = fs12.existsSync(path15.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
42266
- const targetPath = path15.join(dir, target);
42066
+ const target = fs12.existsSync(path14.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
42067
+ const targetPath = path14.join(dir, target);
42267
42068
  try {
42268
42069
  if (fs12.existsSync(targetPath)) fs12.copyFileSync(targetPath, targetPath + ".bak");
42269
42070
  fs12.writeFileSync(targetPath, source, "utf-8");
@@ -42368,14 +42169,14 @@ var init_dev_server = __esm({
42368
42169
  child.stderr?.on("data", (d) => {
42369
42170
  stderr += d.toString();
42370
42171
  });
42371
- await new Promise((resolve13) => {
42172
+ await new Promise((resolve12) => {
42372
42173
  const timer = setTimeout(() => {
42373
42174
  child.kill();
42374
- resolve13();
42175
+ resolve12();
42375
42176
  }, timeout);
42376
42177
  child.on("exit", () => {
42377
42178
  clearTimeout(timer);
42378
- resolve13();
42179
+ resolve12();
42379
42180
  });
42380
42181
  });
42381
42182
  const elapsed = Date.now() - start;
@@ -42423,7 +42224,7 @@ var init_dev_server = __esm({
42423
42224
  }
42424
42225
  let targetDir;
42425
42226
  targetDir = this.providerLoader.getUserProviderDir(category, type);
42426
- const jsonPath = path15.join(targetDir, "provider.json");
42227
+ const jsonPath = path14.join(targetDir, "provider.json");
42427
42228
  if (fs12.existsSync(jsonPath)) {
42428
42229
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
42429
42230
  return;
@@ -42435,8 +42236,8 @@ var init_dev_server = __esm({
42435
42236
  const createdFiles = ["provider.json"];
42436
42237
  if (result.files) {
42437
42238
  for (const [relPath, content] of Object.entries(result.files)) {
42438
- const fullPath = path15.join(targetDir, relPath);
42439
- fs12.mkdirSync(path15.dirname(fullPath), { recursive: true });
42239
+ const fullPath = path14.join(targetDir, relPath);
42240
+ fs12.mkdirSync(path14.dirname(fullPath), { recursive: true });
42440
42241
  fs12.writeFileSync(fullPath, content, "utf-8");
42441
42242
  createdFiles.push(relPath);
42442
42243
  }
@@ -42489,22 +42290,22 @@ var init_dev_server = __esm({
42489
42290
  if (!fs12.existsSync(scriptsDir)) return null;
42490
42291
  const versions = fs12.readdirSync(scriptsDir).filter((d) => {
42491
42292
  try {
42492
- return fs12.statSync(path15.join(scriptsDir, d)).isDirectory();
42293
+ return fs12.statSync(path14.join(scriptsDir, d)).isDirectory();
42493
42294
  } catch {
42494
42295
  return false;
42495
42296
  }
42496
42297
  }).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
42497
42298
  if (versions.length === 0) return null;
42498
- return path15.join(scriptsDir, versions[0]);
42299
+ return path14.join(scriptsDir, versions[0]);
42499
42300
  }
42500
42301
  resolveAutoImplWritableProviderDir(category, type, requestedDir) {
42501
- const canonicalUserDir = path15.resolve(this.providerLoader.getUserProviderDir(category, type));
42502
- const desiredDir = requestedDir ? path15.resolve(requestedDir) : canonicalUserDir;
42503
- const upstreamRoot = path15.resolve(this.providerLoader.getUpstreamDir());
42504
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path15.sep}`)) {
42302
+ const canonicalUserDir = path14.resolve(this.providerLoader.getUserProviderDir(category, type));
42303
+ const desiredDir = requestedDir ? path14.resolve(requestedDir) : canonicalUserDir;
42304
+ const upstreamRoot = path14.resolve(this.providerLoader.getUpstreamDir());
42305
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path14.sep}`)) {
42505
42306
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
42506
42307
  }
42507
- if (path15.basename(desiredDir) !== type) {
42308
+ if (path14.basename(desiredDir) !== type) {
42508
42309
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
42509
42310
  }
42510
42311
  const sourceDir = this.findProviderDir(type);
@@ -42512,11 +42313,11 @@ var init_dev_server = __esm({
42512
42313
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
42513
42314
  }
42514
42315
  if (!fs12.existsSync(desiredDir)) {
42515
- fs12.mkdirSync(path15.dirname(desiredDir), { recursive: true });
42316
+ fs12.mkdirSync(path14.dirname(desiredDir), { recursive: true });
42516
42317
  fs12.cpSync(sourceDir, desiredDir, { recursive: true });
42517
42318
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
42518
42319
  }
42519
- const providerJson = path15.join(desiredDir, "provider.json");
42320
+ const providerJson = path14.join(desiredDir, "provider.json");
42520
42321
  if (!fs12.existsSync(providerJson)) {
42521
42322
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
42522
42323
  }
@@ -42564,7 +42365,7 @@ var init_dev_server = __esm({
42564
42365
  setMode: "set_mode.js"
42565
42366
  };
42566
42367
  const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
42567
- const scriptsDir = path15.join(providerDir, "scripts");
42368
+ const scriptsDir = path14.join(providerDir, "scripts");
42568
42369
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
42569
42370
  if (latestScriptsDir) {
42570
42371
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -42575,7 +42376,7 @@ var init_dev_server = __esm({
42575
42376
  for (const file2 of fs12.readdirSync(latestScriptsDir)) {
42576
42377
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
42577
42378
  try {
42578
- const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
42379
+ const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
42579
42380
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
42580
42381
  lines.push("```javascript");
42581
42382
  lines.push(content);
@@ -42592,7 +42393,7 @@ var init_dev_server = __esm({
42592
42393
  lines.push("");
42593
42394
  for (const file2 of refFiles) {
42594
42395
  try {
42595
- const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
42396
+ const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
42596
42397
  lines.push(`### \`${file2}\` \u{1F512}`);
42597
42398
  lines.push("```javascript");
42598
42399
  lines.push(content);
@@ -42633,10 +42434,10 @@ var init_dev_server = __esm({
42633
42434
  lines.push("");
42634
42435
  }
42635
42436
  }
42636
- const docsDir = path15.join(providerDir, "../../docs");
42437
+ const docsDir = path14.join(providerDir, "../../docs");
42637
42438
  const loadGuide = (name) => {
42638
42439
  try {
42639
- const p = path15.join(docsDir, name);
42440
+ const p = path14.join(docsDir, name);
42640
42441
  if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
42641
42442
  } catch {
42642
42443
  }
@@ -42810,7 +42611,7 @@ var init_dev_server = __esm({
42810
42611
  parseApproval: "parse_approval.js"
42811
42612
  };
42812
42613
  const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
42813
- const scriptsDir = path15.join(providerDir, "scripts");
42614
+ const scriptsDir = path14.join(providerDir, "scripts");
42814
42615
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
42815
42616
  if (latestScriptsDir) {
42816
42617
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -42822,7 +42623,7 @@ var init_dev_server = __esm({
42822
42623
  if (!file2.endsWith(".js")) continue;
42823
42624
  if (!targetFileNames.has(file2)) continue;
42824
42625
  try {
42825
- const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
42626
+ const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
42826
42627
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
42827
42628
  lines.push("```javascript");
42828
42629
  lines.push(content);
@@ -42838,7 +42639,7 @@ var init_dev_server = __esm({
42838
42639
  lines.push("");
42839
42640
  for (const file2 of refFiles) {
42840
42641
  try {
42841
- const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
42642
+ const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
42842
42643
  lines.push(`### \`${file2}\` \u{1F512}`);
42843
42644
  lines.push("```javascript");
42844
42645
  lines.push(content);
@@ -42871,10 +42672,10 @@ var init_dev_server = __esm({
42871
42672
  lines.push("");
42872
42673
  }
42873
42674
  }
42874
- const docsDir = path15.join(providerDir, "../../docs");
42675
+ const docsDir = path14.join(providerDir, "../../docs");
42875
42676
  const loadGuide = (name) => {
42876
42677
  try {
42877
- const p = path15.join(docsDir, name);
42678
+ const p = path14.join(docsDir, name);
42878
42679
  if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
42879
42680
  } catch {
42880
42681
  }
@@ -43031,14 +42832,14 @@ data: ${JSON.stringify(msg.data)}
43031
42832
  res.end(JSON.stringify(data, null, 2));
43032
42833
  }
43033
42834
  async readBody(req) {
43034
- return new Promise((resolve13) => {
42835
+ return new Promise((resolve12) => {
43035
42836
  let body = "";
43036
42837
  req.on("data", (chunk) => body += chunk);
43037
42838
  req.on("end", () => {
43038
42839
  try {
43039
- resolve13(JSON.parse(body));
42840
+ resolve12(JSON.parse(body));
43040
42841
  } catch {
43041
- resolve13({});
42842
+ resolve12({});
43042
42843
  }
43043
42844
  });
43044
42845
  });
@@ -43162,8 +42963,8 @@ var init_dist = __esm({
43162
42963
  }
43163
42964
  this.requestWaiters.clear();
43164
42965
  });
43165
- await new Promise((resolve13, reject) => {
43166
- socket.once("connect", () => resolve13());
42966
+ await new Promise((resolve12, reject) => {
42967
+ socket.once("connect", () => resolve12());
43167
42968
  socket.once("error", reject);
43168
42969
  });
43169
42970
  }
@@ -43182,7 +42983,7 @@ var init_dist = __esm({
43182
42983
  requestId,
43183
42984
  request
43184
42985
  };
43185
- const response = await new Promise((resolve13, reject) => {
42986
+ const response = await new Promise((resolve12, reject) => {
43186
42987
  const timeout = setTimeout(() => {
43187
42988
  this.requestWaiters.delete(requestId);
43188
42989
  reject(new Error(`Session host request timed out after 30s (${request.type})`));
@@ -43190,7 +42991,7 @@ var init_dist = __esm({
43190
42991
  this.requestWaiters.set(requestId, {
43191
42992
  resolve: (value) => {
43192
42993
  clearTimeout(timeout);
43193
- resolve13(value);
42994
+ resolve12(value);
43194
42995
  },
43195
42996
  reject: (error48) => {
43196
42997
  clearTimeout(timeout);
@@ -43209,12 +43010,12 @@ var init_dist = __esm({
43209
43010
  waiter.reject(new Error("Session host client closed"));
43210
43011
  }
43211
43012
  this.requestWaiters.clear();
43212
- await new Promise((resolve13) => {
43013
+ await new Promise((resolve12) => {
43213
43014
  let settled = false;
43214
43015
  const done = () => {
43215
43016
  if (settled) return;
43216
43017
  settled = true;
43217
- resolve13();
43018
+ resolve12();
43218
43019
  };
43219
43020
  socket.once("close", done);
43220
43021
  socket.end();
@@ -43591,7 +43392,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
43591
43392
  const deadline = Date.now() + timeoutMs;
43592
43393
  while (Date.now() < deadline) {
43593
43394
  if (await canConnect(endpoint)) return;
43594
- await new Promise((resolve13) => setTimeout(resolve13, STARTUP_POLL_MS));
43395
+ await new Promise((resolve12) => setTimeout(resolve12, STARTUP_POLL_MS));
43595
43396
  }
43596
43397
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
43597
43398
  }
@@ -43909,7 +43710,6 @@ var init_src = __esm({
43909
43710
  "use strict";
43910
43711
  init_config();
43911
43712
  init_workspaces();
43912
- init_workspace_activity();
43913
43713
  init_recent_activity();
43914
43714
  init_ide_detector();
43915
43715
  init_cli_detector();
@@ -44142,9 +43942,9 @@ var init_server_connection = __esm({
44142
43942
  LOG.info("Server", `[ServerConn] Run 'adhdev setup' to re-authenticate.`);
44143
43943
  this.setState("disconnected");
44144
43944
  try {
44145
- const path19 = require("path");
43945
+ const path18 = require("path");
44146
43946
  const fs16 = require("fs");
44147
- const configPath = path19.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "config.json");
43947
+ const configPath = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "config.json");
44148
43948
  if (fs16.existsSync(configPath)) {
44149
43949
  fs16.unlinkSync(configPath);
44150
43950
  LOG.info("Server", `[ServerConn] Config file removed. Re-run 'adhdev setup'.`);
@@ -44255,17 +44055,17 @@ function canPeerUsePrivilegedShareCommand(commandType, permission) {
44255
44055
  return false;
44256
44056
  }
44257
44057
  }
44258
- var fs13, path16, os18, import_node_module, esmRequire, logFile, log, logDebug, DaemonP2PSender;
44058
+ var fs13, path15, os18, import_node_module, esmRequire, logFile, log, logDebug, DaemonP2PSender;
44259
44059
  var init_daemon_p2p = __esm({
44260
44060
  "src/daemon-p2p.ts"() {
44261
44061
  "use strict";
44262
44062
  fs13 = __toESM(require("fs"));
44263
44063
  init_src();
44264
- path16 = __toESM(require("path"));
44064
+ path15 = __toESM(require("path"));
44265
44065
  os18 = __toESM(require("os"));
44266
44066
  import_node_module = require("module");
44267
44067
  esmRequire = (0, import_node_module.createRequire)(__filename);
44268
- logFile = path16.join(os18.tmpdir(), "adhdev_daemon_p2p.log");
44068
+ logFile = path15.join(os18.tmpdir(), "adhdev_daemon_p2p.log");
44269
44069
  log = (msg) => {
44270
44070
  LOG.info("P2P", `[${(/* @__PURE__ */ new Date()).toISOString()}] [P2P] ${msg}`);
44271
44071
  };
@@ -44333,15 +44133,15 @@ ${e?.stack || ""}`);
44333
44133
  const prebuildKey = `${platform11}-${arch3}`;
44334
44134
  try {
44335
44135
  const candidates = [
44336
- path16.join(__dirname, "node_modules", "node-datachannel"),
44337
- path16.join(__dirname, "..", "node_modules", "node-datachannel"),
44338
- path16.join(__dirname, "..", "..", "node_modules", "node-datachannel")
44136
+ path15.join(__dirname, "node_modules", "node-datachannel"),
44137
+ path15.join(__dirname, "..", "node_modules", "node-datachannel"),
44138
+ path15.join(__dirname, "..", "..", "node_modules", "node-datachannel")
44339
44139
  ];
44340
44140
  for (const candidate of candidates) {
44341
- const prebuildPath = path16.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
44141
+ const prebuildPath = path15.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
44342
44142
  if (fs13.existsSync(prebuildPath)) {
44343
- const targetDir = path16.join(candidate, "build", "Release");
44344
- const targetPath = path16.join(targetDir, "node_datachannel.node");
44143
+ const targetDir = path15.join(candidate, "build", "Release");
44144
+ const targetPath = path15.join(targetDir, "node_datachannel.node");
44345
44145
  fs13.mkdirSync(targetDir, { recursive: true });
44346
44146
  fs13.copyFileSync(prebuildPath, targetPath);
44347
44147
  try {
@@ -44417,7 +44217,7 @@ ${e?.stack || ""}`);
44417
44217
  async fetchTurnCredentials() {
44418
44218
  try {
44419
44219
  const serverUrl = process.env.ADHDEV_SERVER_URL || "https://api.adhf.dev";
44420
- const configPath = path16.join(os18.homedir(), ".adhdev", "config.json");
44220
+ const configPath = path15.join(os18.homedir(), ".adhdev", "config.json");
44421
44221
  let token = "";
44422
44222
  try {
44423
44223
  const config2 = JSON.parse(fs13.readFileSync(configPath, "utf-8"));
@@ -44425,13 +44225,13 @@ ${e?.stack || ""}`);
44425
44225
  } catch {
44426
44226
  }
44427
44227
  const http3 = esmRequire("https");
44428
- const data = await new Promise((resolve13, reject) => {
44228
+ const data = await new Promise((resolve12, reject) => {
44429
44229
  const req = http3.get(`${serverUrl}/api/v1/turn/credentials`, {
44430
44230
  headers: { "Authorization": `Bearer ${token}` }
44431
44231
  }, (res) => {
44432
44232
  let d = "";
44433
44233
  res.on("data", (c) => d += c);
44434
- res.on("end", () => resolve13(d));
44234
+ res.on("end", () => resolve12(d));
44435
44235
  });
44436
44236
  req.on("error", reject);
44437
44237
  req.setTimeout(5e3, () => {
@@ -45238,8 +45038,8 @@ var init_screenshot_controller = __esm({
45238
45038
  // src/session-host.ts
45239
45039
  function resolveSessionHostEntry() {
45240
45040
  const packagedCandidates = [
45241
- path17.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
45242
- path17.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
45041
+ path16.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
45042
+ path16.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
45243
45043
  ];
45244
45044
  for (const candidate of packagedCandidates) {
45245
45045
  if (fs14.existsSync(candidate)) {
@@ -45269,13 +45069,13 @@ async function ensureSessionHostReady2() {
45269
45069
  async function listHostedCliRuntimes2(endpoint) {
45270
45070
  return listHostedCliRuntimes(endpoint);
45271
45071
  }
45272
- var import_child_process8, fs14, path17, SESSION_HOST_APP_NAME;
45072
+ var import_child_process8, fs14, path16, SESSION_HOST_APP_NAME;
45273
45073
  var init_session_host = __esm({
45274
45074
  "src/session-host.ts"() {
45275
45075
  "use strict";
45276
45076
  import_child_process8 = require("child_process");
45277
45077
  fs14 = __toESM(require("fs"));
45278
- path17 = __toESM(require("path"));
45078
+ path16 = __toESM(require("path"));
45279
45079
  init_src();
45280
45080
  SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
45281
45081
  }
@@ -45289,9 +45089,9 @@ __export(adhdev_daemon_exports, {
45289
45089
  stopDaemon: () => stopDaemon
45290
45090
  });
45291
45091
  function getDaemonPidFile() {
45292
- const dir = path18.join(os19.homedir(), ".adhdev");
45092
+ const dir = path17.join(os19.homedir(), ".adhdev");
45293
45093
  if (!fs15.existsSync(dir)) fs15.mkdirSync(dir, { recursive: true });
45294
- return path18.join(dir, "daemon.pid");
45094
+ return path17.join(dir, "daemon.pid");
45295
45095
  }
45296
45096
  function writeDaemonPid(pid) {
45297
45097
  fs15.writeFileSync(getDaemonPidFile(), String(pid), "utf-8");
@@ -45327,7 +45127,7 @@ function stopDaemon() {
45327
45127
  return false;
45328
45128
  }
45329
45129
  }
45330
- var os19, fs15, path18, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
45130
+ var os19, fs15, path17, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
45331
45131
  var init_adhdev_daemon = __esm({
45332
45132
  "src/adhdev-daemon.ts"() {
45333
45133
  "use strict";
@@ -45339,14 +45139,14 @@ var init_adhdev_daemon = __esm({
45339
45139
  init_dist();
45340
45140
  os19 = __toESM(require("os"));
45341
45141
  fs15 = __toESM(require("fs"));
45342
- path18 = __toESM(require("path"));
45142
+ path17 = __toESM(require("path"));
45343
45143
  import_chalk2 = __toESM(require("chalk"));
45344
- pkgVersion = "0.7.38";
45144
+ pkgVersion = "0.7.40";
45345
45145
  if (pkgVersion === "unknown") {
45346
45146
  try {
45347
45147
  const possiblePaths = [
45348
- path18.join(__dirname, "..", "package.json"),
45349
- path18.join(__dirname, "package.json")
45148
+ path17.join(__dirname, "..", "package.json"),
45149
+ path17.join(__dirname, "package.json")
45350
45150
  ];
45351
45151
  for (const p of possiblePaths) {
45352
45152
  try {
@@ -45704,11 +45504,6 @@ ${err?.stack || ""}`);
45704
45504
  });
45705
45505
  }
45706
45506
  }
45707
- case "get_cli_history": {
45708
- const config2 = loadConfig();
45709
- logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd: cmdType, source: "p2p", success: true, durationMs: Date.now() - cmdStart });
45710
- return { success: true, history: config2.cliHistory || [] };
45711
- }
45712
45507
  case "set_machine_nickname": {
45713
45508
  const nickname = data.nickname?.trim() || null;
45714
45509
  const config2 = loadConfig();
@@ -46051,8 +45846,8 @@ async function startDaemonFlow() {
46051
45846
  const daemon = new AdhdevDaemon2();
46052
45847
  const { execSync: execSync6 } = await import("child_process");
46053
45848
  const os20 = await import("os");
46054
- const path19 = await import("path");
46055
- const logPath = path19.join(os20.homedir(), ".adhdev", "daemon.log");
45849
+ const path18 = await import("path");
45850
+ const logPath = path18.join(os20.homedir(), ".adhdev", "daemon.log");
46056
45851
  const platform11 = os20.platform();
46057
45852
  try {
46058
45853
  if (platform11 === "win32") {