adhdev 0.7.38 → 0.7.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -31,6 +31,164 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  ));
32
32
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
33
 
34
+ // ../../oss/packages/daemon-core/src/config/config.ts
35
+ var config_exports = {};
36
+ __export(config_exports, {
37
+ generateConnectionToken: () => generateConnectionToken,
38
+ generateMachineId: () => generateMachineId,
39
+ getConfigDir: () => getConfigDir,
40
+ isSetupComplete: () => isSetupComplete,
41
+ isStableMachineId: () => isStableMachineId,
42
+ loadConfig: () => loadConfig,
43
+ markSetupComplete: () => markSetupComplete,
44
+ resetConfig: () => resetConfig,
45
+ saveConfig: () => saveConfig,
46
+ updateConfig: () => updateConfig
47
+ });
48
+ function generateMachineId() {
49
+ return `${MACHINE_ID_PREFIX}${(0, import_crypto.randomUUID)().replace(/-/g, "")}`;
50
+ }
51
+ function isStableMachineId(machineId) {
52
+ return typeof machineId === "string" && machineId.startsWith(MACHINE_ID_PREFIX);
53
+ }
54
+ function ensureMachineId(config2) {
55
+ if (isStableMachineId(config2.machineId)) {
56
+ return { config: config2, changed: false };
57
+ }
58
+ const legacyRegisteredMachineId = !config2.registeredMachineId && config2.machineSecret && config2.machineId ? config2.machineId : config2.registeredMachineId;
59
+ return {
60
+ config: {
61
+ ...config2,
62
+ machineId: generateMachineId(),
63
+ registeredMachineId: legacyRegisteredMachineId
64
+ },
65
+ changed: true
66
+ };
67
+ }
68
+ function getConfigDir() {
69
+ const dir = (0, import_path.join)((0, import_os.homedir)(), ".adhdev");
70
+ if (!(0, import_fs.existsSync)(dir)) {
71
+ (0, import_fs.mkdirSync)(dir, { recursive: true });
72
+ }
73
+ return dir;
74
+ }
75
+ function getConfigPath() {
76
+ return (0, import_path.join)(getConfigDir(), "config.json");
77
+ }
78
+ function loadConfig() {
79
+ const configPath = getConfigPath();
80
+ if (!(0, import_fs.existsSync)(configPath)) {
81
+ const initialized = ensureMachineId({ ...DEFAULT_CONFIG });
82
+ try {
83
+ saveConfig(initialized.config);
84
+ } catch {
85
+ }
86
+ return initialized.config;
87
+ }
88
+ try {
89
+ const raw = (0, import_fs.readFileSync)(configPath, "utf-8");
90
+ const parsed = JSON.parse(raw);
91
+ const merged = { ...DEFAULT_CONFIG, ...parsed };
92
+ if (merged.defaultWorkspaceId == null && merged.activeWorkspaceId != null) {
93
+ merged.defaultWorkspaceId = merged.activeWorkspaceId;
94
+ }
95
+ delete merged.activeWorkspaceId;
96
+ const ensured = ensureMachineId(merged);
97
+ const normalized = ensured.config;
98
+ if (ensured.changed) {
99
+ try {
100
+ saveConfig(normalized);
101
+ } catch {
102
+ }
103
+ }
104
+ return normalized;
105
+ } catch {
106
+ const initialized = ensureMachineId({ ...DEFAULT_CONFIG });
107
+ return initialized.config;
108
+ }
109
+ }
110
+ function saveConfig(config2) {
111
+ const configPath = getConfigPath();
112
+ const dir = getConfigDir();
113
+ if (!(0, import_fs.existsSync)(dir)) {
114
+ (0, import_fs.mkdirSync)(dir, { recursive: true, mode: 448 });
115
+ }
116
+ (0, import_fs.writeFileSync)(configPath, JSON.stringify(config2, null, 2), { encoding: "utf-8", mode: 384 });
117
+ try {
118
+ (0, import_fs.chmodSync)(configPath, 384);
119
+ } catch {
120
+ }
121
+ }
122
+ function updateConfig(updates) {
123
+ const config2 = loadConfig();
124
+ const updated = { ...config2, ...updates };
125
+ saveConfig(updated);
126
+ return updated;
127
+ }
128
+ function markSetupComplete(ideId, extensions) {
129
+ const ideIds = Array.isArray(ideId) ? ideId : [ideId];
130
+ return updateConfig({
131
+ selectedIde: ideIds[0],
132
+ configuredIdes: ideIds,
133
+ installedExtensions: extensions,
134
+ setupCompleted: true,
135
+ setupDate: (/* @__PURE__ */ new Date()).toISOString()
136
+ });
137
+ }
138
+ function isSetupComplete() {
139
+ const config2 = loadConfig();
140
+ return config2.setupCompleted;
141
+ }
142
+ function resetConfig() {
143
+ saveConfig({ ...DEFAULT_CONFIG });
144
+ }
145
+ function generateConnectionToken() {
146
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
147
+ let token = "db_";
148
+ for (let i = 0; i < 32; i++) {
149
+ token += chars.charAt(Math.floor(Math.random() * chars.length));
150
+ }
151
+ return token;
152
+ }
153
+ var import_os, import_path, import_fs, import_crypto, DEFAULT_CONFIG, MACHINE_ID_PREFIX;
154
+ var init_config = __esm({
155
+ "../../oss/packages/daemon-core/src/config/config.ts"() {
156
+ "use strict";
157
+ import_os = require("os");
158
+ import_path = require("path");
159
+ import_fs = require("fs");
160
+ import_crypto = require("crypto");
161
+ DEFAULT_CONFIG = {
162
+ serverUrl: "https://api.adhf.dev",
163
+ apiToken: null,
164
+ connectionToken: null,
165
+ selectedIde: null,
166
+ configuredIdes: [],
167
+ installedExtensions: [],
168
+ autoConnect: true,
169
+ notifications: true,
170
+ userEmail: null,
171
+ userName: null,
172
+ setupCompleted: false,
173
+ setupDate: null,
174
+ configuredCLIs: [],
175
+ enabledIdes: [],
176
+ workspaces: [],
177
+ defaultWorkspaceId: null,
178
+ recentActivity: [],
179
+ recentSessionReads: {},
180
+ machineNickname: null,
181
+ machineId: void 0,
182
+ machineSecret: null,
183
+ registeredMachineId: void 0,
184
+ providerSettings: {},
185
+ ideSettings: {},
186
+ disableUpstream: false
187
+ };
188
+ MACHINE_ID_PREFIX = "mach_";
189
+ }
190
+ });
191
+
34
192
  // ../../oss/packages/daemon-core/src/config/workspaces.ts
35
193
  function expandPath(p) {
36
194
  const t = (p || "").trim();
@@ -53,25 +211,6 @@ function defaultWorkspaceLabel(absPath) {
53
211
  const base = path.basename(absPath) || absPath;
54
212
  return base;
55
213
  }
56
- function migrateWorkspacesFromRecent(config2) {
57
- if (!config2.workspaces) config2.workspaces = [];
58
- if (config2.workspaces.length > 0) return config2;
59
- const recent = config2.recentCliWorkspaces || [];
60
- const now = Date.now();
61
- for (const raw of recent) {
62
- const abs = expandPath(raw);
63
- if (!abs || validateWorkspacePath(abs).ok !== true) continue;
64
- if (config2.workspaces.some((w) => path.resolve(w.path) === abs)) continue;
65
- config2.workspaces.push({
66
- id: (0, import_crypto.randomUUID)(),
67
- path: abs,
68
- label: defaultWorkspaceLabel(abs),
69
- addedAt: now
70
- });
71
- if (config2.workspaces.length >= MAX_WORKSPACES) break;
72
- }
73
- return config2;
74
- }
75
214
  function getDefaultWorkspacePath(config2) {
76
215
  const id = config2.defaultWorkspaceId;
77
216
  if (!id) return null;
@@ -185,7 +324,7 @@ function addWorkspaceEntry(config2, rawPath, label, options) {
185
324
  return { error: `Maximum ${MAX_WORKSPACES} workspaces` };
186
325
  }
187
326
  const entry = {
188
- id: (0, import_crypto.randomUUID)(),
327
+ id: (0, import_crypto2.randomUUID)(),
189
328
  path: abs,
190
329
  label: (label || "").trim() || defaultWorkspaceLabel(abs),
191
330
  addedAt: Date.now()
@@ -210,258 +349,15 @@ function setDefaultWorkspaceId(config2, id) {
210
349
  if (validateWorkspacePath(abs).ok !== true) return { error: "Workspace path is no longer valid" };
211
350
  return { config: { ...config2, defaultWorkspaceId: id } };
212
351
  }
213
- var fs, os, path, import_crypto, MAX_WORKSPACES;
352
+ var fs, os, path, import_crypto2, MAX_WORKSPACES;
214
353
  var init_workspaces = __esm({
215
354
  "../../oss/packages/daemon-core/src/config/workspaces.ts"() {
216
355
  "use strict";
217
356
  fs = __toESM(require("fs"));
218
357
  os = __toESM(require("os"));
219
358
  path = __toESM(require("path"));
220
- import_crypto = require("crypto");
221
- MAX_WORKSPACES = 50;
222
- }
223
- });
224
-
225
- // ../../oss/packages/daemon-core/src/config/config.ts
226
- var config_exports = {};
227
- __export(config_exports, {
228
- addCliHistory: () => addCliHistory,
229
- generateConnectionToken: () => generateConnectionToken,
230
- generateMachineId: () => generateMachineId,
231
- getConfigDir: () => getConfigDir,
232
- isSetupComplete: () => isSetupComplete,
233
- isStableMachineId: () => isStableMachineId,
234
- loadConfig: () => loadConfig,
235
- markSetupComplete: () => markSetupComplete,
236
- resetConfig: () => resetConfig,
237
- saveConfig: () => saveConfig,
238
- updateConfig: () => updateConfig
239
- });
240
- function generateMachineId() {
241
- return `${MACHINE_ID_PREFIX}${(0, import_crypto2.randomUUID)().replace(/-/g, "")}`;
242
- }
243
- function isStableMachineId(machineId) {
244
- return typeof machineId === "string" && machineId.startsWith(MACHINE_ID_PREFIX);
245
- }
246
- function ensureMachineId(config2) {
247
- if (isStableMachineId(config2.machineId)) {
248
- return { config: config2, changed: false };
249
- }
250
- const legacyRegisteredMachineId = !config2.registeredMachineId && config2.machineSecret && config2.machineId ? config2.machineId : config2.registeredMachineId;
251
- return {
252
- config: {
253
- ...config2,
254
- machineId: generateMachineId(),
255
- registeredMachineId: legacyRegisteredMachineId
256
- },
257
- changed: true
258
- };
259
- }
260
- function getConfigDir() {
261
- const dir = (0, import_path.join)((0, import_os.homedir)(), ".adhdev");
262
- if (!(0, import_fs.existsSync)(dir)) {
263
- (0, import_fs.mkdirSync)(dir, { recursive: true });
264
- }
265
- return dir;
266
- }
267
- function getConfigPath() {
268
- return (0, import_path.join)(getConfigDir(), "config.json");
269
- }
270
- function loadConfig() {
271
- const configPath = getConfigPath();
272
- if (!(0, import_fs.existsSync)(configPath)) {
273
- const initialized = ensureMachineId({ ...DEFAULT_CONFIG });
274
- try {
275
- saveConfig(initialized.config);
276
- } catch {
277
- }
278
- return initialized.config;
279
- }
280
- try {
281
- const raw = (0, import_fs.readFileSync)(configPath, "utf-8");
282
- const parsed = JSON.parse(raw);
283
- const merged = { ...DEFAULT_CONFIG, ...parsed };
284
- if (merged.defaultWorkspaceId == null && merged.activeWorkspaceId != null) {
285
- merged.defaultWorkspaceId = merged.activeWorkspaceId;
286
- }
287
- delete merged.activeWorkspaceId;
288
- const hadStoredWorkspaces = Array.isArray(parsed.workspaces) && parsed.workspaces.length > 0;
289
- const ensured = ensureMachineId(merged);
290
- const normalized = ensured.config;
291
- migrateWorkspacesFromRecent(normalized);
292
- let configChanged = ensured.changed;
293
- if (!hadStoredWorkspaces && (normalized.workspaces?.length || 0) > 0) {
294
- configChanged = true;
295
- }
296
- if (configChanged) {
297
- try {
298
- saveConfig(normalized);
299
- } catch {
300
- }
301
- }
302
- return normalized;
303
- } catch {
304
- const initialized = ensureMachineId({ ...DEFAULT_CONFIG });
305
- return initialized.config;
306
- }
307
- }
308
- function saveConfig(config2) {
309
- const configPath = getConfigPath();
310
- const dir = getConfigDir();
311
- if (!(0, import_fs.existsSync)(dir)) {
312
- (0, import_fs.mkdirSync)(dir, { recursive: true, mode: 448 });
313
- }
314
- (0, import_fs.writeFileSync)(configPath, JSON.stringify(config2, null, 2), { encoding: "utf-8", mode: 384 });
315
- try {
316
- (0, import_fs.chmodSync)(configPath, 384);
317
- } catch {
318
- }
319
- }
320
- function updateConfig(updates) {
321
- const config2 = loadConfig();
322
- const updated = { ...config2, ...updates };
323
- saveConfig(updated);
324
- return updated;
325
- }
326
- function markSetupComplete(ideId, extensions) {
327
- const ideIds = Array.isArray(ideId) ? ideId : [ideId];
328
- return updateConfig({
329
- selectedIde: ideIds[0],
330
- configuredIdes: ideIds,
331
- installedExtensions: extensions,
332
- setupCompleted: true,
333
- setupDate: (/* @__PURE__ */ new Date()).toISOString()
334
- });
335
- }
336
- function isSetupComplete() {
337
- const config2 = loadConfig();
338
- return config2.setupCompleted;
339
- }
340
- function resetConfig() {
341
- saveConfig({ ...DEFAULT_CONFIG });
342
- }
343
- function generateConnectionToken() {
344
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
345
- let token = "db_";
346
- for (let i = 0; i < 32; i++) {
347
- token += chars.charAt(Math.floor(Math.random() * chars.length));
348
- }
349
- return token;
350
- }
351
- function addCliHistory(entry) {
352
- const config2 = loadConfig();
353
- const history = config2.cliHistory || [];
354
- const argsKey = (entry.cliArgs || []).join(" ");
355
- const category = entry.category || "cli";
356
- const workspaceKey = entry.workspace || "";
357
- const modelKey = entry.model || "";
358
- const filtered = history.filter((h) => {
359
- const hArgsKey = (h.cliArgs || []).join(" ");
360
- return !((h.category || "cli") === category && h.cliType === entry.cliType && h.dir === entry.dir && hArgsKey === argsKey && (h.workspace || "") === workspaceKey && (h.model || "") === modelKey);
361
- });
362
- filtered.unshift({
363
- ...entry,
364
- category,
365
- timestamp: Date.now(),
366
- label: entry.label || (() => {
367
- const base = `${entry.cliType} \xB7 ${entry.dir.split("/").filter(Boolean).pop() || "root"}`;
368
- const suffix = [];
369
- if (entry.workspace && entry.workspace !== entry.dir) suffix.push(entry.workspace.split("/").filter(Boolean).pop() || entry.workspace);
370
- if (entry.model) suffix.push(`model=${entry.model}`);
371
- if (argsKey) suffix.push(argsKey);
372
- if (entry.newWindow) suffix.push("new window");
373
- return suffix.length > 0 ? `${base} (${suffix.join(" \xB7 ")})` : base;
374
- })()
375
- });
376
- config2.cliHistory = filtered.slice(0, 20);
377
- saveConfig(config2);
378
- }
379
- var import_os, import_path, import_fs, import_crypto2, DEFAULT_CONFIG, MACHINE_ID_PREFIX;
380
- var init_config = __esm({
381
- "../../oss/packages/daemon-core/src/config/config.ts"() {
382
- "use strict";
383
- import_os = require("os");
384
- import_path = require("path");
385
- import_fs = require("fs");
386
359
  import_crypto2 = require("crypto");
387
- 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;
360
+ MAX_WORKSPACES = 50;
465
361
  }
466
362
  });
467
363
 
@@ -469,9 +365,9 @@ var init_workspace_activity = __esm({
469
365
  function normalizeWorkspace(workspace) {
470
366
  if (!workspace) return "";
471
367
  try {
472
- return path3.resolve(expandPath(workspace));
368
+ return path2.resolve(expandPath(workspace));
473
369
  } catch {
474
- return path3.resolve(workspace);
370
+ return path2.resolve(workspace);
475
371
  }
476
372
  }
477
373
  function buildRecentActivityKey(entry) {
@@ -487,7 +383,7 @@ function appendRecentActivity(config2, entry) {
487
383
  const filtered = (config2.recentActivity || []).filter((item) => item.id !== nextEntry.id);
488
384
  return {
489
385
  ...config2,
490
- recentActivity: [nextEntry, ...filtered].slice(0, MAX_ACTIVITY2)
386
+ recentActivity: [nextEntry, ...filtered].slice(0, MAX_ACTIVITY)
491
387
  };
492
388
  }
493
389
  function getRecentActivity(config2, limit = 20) {
@@ -507,13 +403,13 @@ function markRecentSessionSeen(config2, recentKey, seenAt = Date.now()) {
507
403
  }
508
404
  };
509
405
  }
510
- var path3, MAX_ACTIVITY2;
406
+ var path2, MAX_ACTIVITY;
511
407
  var init_recent_activity = __esm({
512
408
  "../../oss/packages/daemon-core/src/config/recent-activity.ts"() {
513
409
  "use strict";
514
- path3 = __toESM(require("path"));
410
+ path2 = __toESM(require("path"));
515
411
  init_workspaces();
516
- MAX_ACTIVITY2 = 30;
412
+ MAX_ACTIVITY = 30;
517
413
  }
518
414
  });
519
415
 
@@ -628,15 +524,15 @@ function parseVersion(raw) {
628
524
  return match ? match[1] : raw.split("\n")[0].slice(0, 100);
629
525
  }
630
526
  function execAsync(cmd, timeoutMs = 5e3) {
631
- return new Promise((resolve13) => {
527
+ return new Promise((resolve12) => {
632
528
  const child = (0, import_child_process2.exec)(cmd, { encoding: "utf-8", timeout: timeoutMs }, (err, stdout) => {
633
529
  if (err || !stdout?.trim()) {
634
- resolve13(null);
530
+ resolve12(null);
635
531
  } else {
636
- resolve13(stdout.trim());
532
+ resolve12(stdout.trim());
637
533
  }
638
534
  });
639
- child.on("error", () => resolve13(null));
535
+ child.on("error", () => resolve12(null));
640
536
  });
641
537
  }
642
538
  async function detectCLIs(providerLoader) {
@@ -744,7 +640,7 @@ function checkDateRotation() {
744
640
  const today = getDateStr();
745
641
  if (today !== currentDate) {
746
642
  currentDate = today;
747
- currentLogFile = path4.join(LOG_DIR, `daemon-${currentDate}.log`);
643
+ currentLogFile = path3.join(LOG_DIR, `daemon-${currentDate}.log`);
748
644
  cleanOldLogs();
749
645
  }
750
646
  }
@@ -758,7 +654,7 @@ function cleanOldLogs() {
758
654
  const dateMatch = file2.match(/daemon-(\d{4}-\d{2}-\d{2})/);
759
655
  if (dateMatch && dateMatch[1] < cutoffStr) {
760
656
  try {
761
- fs2.unlinkSync(path4.join(LOG_DIR, file2));
657
+ fs2.unlinkSync(path3.join(LOG_DIR, file2));
762
658
  } catch {
763
659
  }
764
660
  }
@@ -875,17 +771,17 @@ function installGlobalInterceptor() {
875
771
  writeToFile(`Log file: ${currentLogFile}`);
876
772
  writeToFile(`Log level: ${currentLevel}`);
877
773
  }
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;
774
+ 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
775
  var init_logger = __esm({
880
776
  "../../oss/packages/daemon-core/src/logging/logger.ts"() {
881
777
  "use strict";
882
778
  fs2 = __toESM(require("fs"));
883
- path4 = __toESM(require("path"));
779
+ path3 = __toESM(require("path"));
884
780
  os4 = __toESM(require("os"));
885
781
  LEVEL_NUM = { debug: 0, info: 1, warn: 2, error: 3 };
886
782
  LEVEL_LABEL = { debug: "DBG", info: "INF", warn: "WRN", error: "ERR" };
887
783
  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");
784
+ 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
785
  MAX_LOG_SIZE = 5 * 1024 * 1024;
890
786
  MAX_LOG_DAYS = 7;
891
787
  try {
@@ -893,16 +789,16 @@ var init_logger = __esm({
893
789
  } catch {
894
790
  }
895
791
  currentDate = getDateStr();
896
- currentLogFile = path4.join(LOG_DIR, `daemon-${currentDate}.log`);
792
+ currentLogFile = path3.join(LOG_DIR, `daemon-${currentDate}.log`);
897
793
  cleanOldLogs();
898
794
  try {
899
- const oldLog = path4.join(LOG_DIR, "daemon.log");
795
+ const oldLog = path3.join(LOG_DIR, "daemon.log");
900
796
  if (fs2.existsSync(oldLog)) {
901
797
  const stat4 = fs2.statSync(oldLog);
902
798
  const oldDate = stat4.mtime.toISOString().slice(0, 10);
903
- fs2.renameSync(oldLog, path4.join(LOG_DIR, `daemon-${oldDate}.log`));
799
+ fs2.renameSync(oldLog, path3.join(LOG_DIR, `daemon-${oldDate}.log`));
904
800
  }
905
- const oldLogBackup = path4.join(LOG_DIR, "daemon.log.old");
801
+ const oldLogBackup = path3.join(LOG_DIR, "daemon.log.old");
906
802
  if (fs2.existsSync(oldLogBackup)) {
907
803
  fs2.unlinkSync(oldLogBackup);
908
804
  }
@@ -934,7 +830,7 @@ var init_logger = __esm({
934
830
  }
935
831
  };
936
832
  interceptorInstalled = false;
937
- LOG_PATH = path4.join(LOG_DIR, `daemon-${getDateStr()}.log`);
833
+ LOG_PATH = path3.join(LOG_DIR, `daemon-${getDateStr()}.log`);
938
834
  }
939
835
  });
940
836
 
@@ -1023,7 +919,7 @@ var init_manager = __esm({
1023
919
  * Returns multiple entries if multiple IDE windows are open on same port
1024
920
  */
1025
921
  static listAllTargets(port) {
1026
- return new Promise((resolve13) => {
922
+ return new Promise((resolve12) => {
1027
923
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
1028
924
  let data = "";
1029
925
  res.on("data", (chunk) => data += chunk.toString());
@@ -1039,16 +935,16 @@ var init_manager = __esm({
1039
935
  (t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
1040
936
  );
1041
937
  const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
1042
- resolve13(mainPages.length > 0 ? mainPages : fallbackPages);
938
+ resolve12(mainPages.length > 0 ? mainPages : fallbackPages);
1043
939
  } catch {
1044
- resolve13([]);
940
+ resolve12([]);
1045
941
  }
1046
942
  });
1047
943
  });
1048
- req.on("error", () => resolve13([]));
944
+ req.on("error", () => resolve12([]));
1049
945
  req.setTimeout(2e3, () => {
1050
946
  req.destroy();
1051
- resolve13([]);
947
+ resolve12([]);
1052
948
  });
1053
949
  });
1054
950
  }
@@ -1088,7 +984,7 @@ var init_manager = __esm({
1088
984
  }
1089
985
  }
1090
986
  findTargetOnPort(port) {
1091
- return new Promise((resolve13) => {
987
+ return new Promise((resolve12) => {
1092
988
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
1093
989
  let data = "";
1094
990
  res.on("data", (chunk) => data += chunk.toString());
@@ -1099,7 +995,7 @@ var init_manager = __esm({
1099
995
  (t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
1100
996
  );
1101
997
  if (pages.length === 0) {
1102
- resolve13(targets.find((t) => t.webSocketDebuggerUrl) || null);
998
+ resolve12(targets.find((t) => t.webSocketDebuggerUrl) || null);
1103
999
  return;
1104
1000
  }
1105
1001
  const mainPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
@@ -1109,24 +1005,24 @@ var init_manager = __esm({
1109
1005
  const specific = list.find((t) => t.id === this._targetId);
1110
1006
  if (specific) {
1111
1007
  this._pageTitle = specific.title || "";
1112
- resolve13(specific);
1008
+ resolve12(specific);
1113
1009
  } else {
1114
1010
  this.log(`[CDP] Target ${this._targetId} not found in page list`);
1115
- resolve13(null);
1011
+ resolve12(null);
1116
1012
  }
1117
1013
  return;
1118
1014
  }
1119
1015
  this._pageTitle = list[0]?.title || "";
1120
- resolve13(list[0]);
1016
+ resolve12(list[0]);
1121
1017
  } catch {
1122
- resolve13(null);
1018
+ resolve12(null);
1123
1019
  }
1124
1020
  });
1125
1021
  });
1126
- req.on("error", () => resolve13(null));
1022
+ req.on("error", () => resolve12(null));
1127
1023
  req.setTimeout(2e3, () => {
1128
1024
  req.destroy();
1129
- resolve13(null);
1025
+ resolve12(null);
1130
1026
  });
1131
1027
  });
1132
1028
  }
@@ -1137,7 +1033,7 @@ var init_manager = __esm({
1137
1033
  this.extensionProviders = providers;
1138
1034
  }
1139
1035
  connectToTarget(wsUrl) {
1140
- return new Promise((resolve13) => {
1036
+ return new Promise((resolve12) => {
1141
1037
  this.ws = new import_ws.default(wsUrl);
1142
1038
  this.ws.on("open", async () => {
1143
1039
  this._connected = true;
@@ -1147,17 +1043,17 @@ var init_manager = __esm({
1147
1043
  }
1148
1044
  this.connectBrowserWs().catch(() => {
1149
1045
  });
1150
- resolve13(true);
1046
+ resolve12(true);
1151
1047
  });
1152
1048
  this.ws.on("message", (data) => {
1153
1049
  try {
1154
1050
  const msg = JSON.parse(data.toString());
1155
1051
  if (msg.id && this.pending.has(msg.id)) {
1156
- const { resolve: resolve14, reject } = this.pending.get(msg.id);
1052
+ const { resolve: resolve13, reject } = this.pending.get(msg.id);
1157
1053
  this.pending.delete(msg.id);
1158
1054
  this.failureCount = 0;
1159
1055
  if (msg.error) reject(new Error(msg.error.message));
1160
- else resolve14(msg.result);
1056
+ else resolve13(msg.result);
1161
1057
  } else if (msg.method === "Runtime.executionContextCreated") {
1162
1058
  this.contexts.add(msg.params.context.id);
1163
1059
  } else if (msg.method === "Runtime.executionContextDestroyed") {
@@ -1180,7 +1076,7 @@ var init_manager = __esm({
1180
1076
  this.ws.on("error", (err) => {
1181
1077
  this.log(`[CDP] WebSocket error: ${err.message}`);
1182
1078
  this._connected = false;
1183
- resolve13(false);
1079
+ resolve12(false);
1184
1080
  });
1185
1081
  });
1186
1082
  }
@@ -1194,7 +1090,7 @@ var init_manager = __esm({
1194
1090
  return;
1195
1091
  }
1196
1092
  this.log(`[CDP] Connecting browser WS for target discovery...`);
1197
- await new Promise((resolve13, reject) => {
1093
+ await new Promise((resolve12, reject) => {
1198
1094
  this.browserWs = new import_ws.default(browserWsUrl);
1199
1095
  this.browserWs.on("open", async () => {
1200
1096
  this._browserConnected = true;
@@ -1204,16 +1100,16 @@ var init_manager = __esm({
1204
1100
  } catch (e) {
1205
1101
  this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
1206
1102
  }
1207
- resolve13();
1103
+ resolve12();
1208
1104
  });
1209
1105
  this.browserWs.on("message", (data) => {
1210
1106
  try {
1211
1107
  const msg = JSON.parse(data.toString());
1212
1108
  if (msg.id && this.browserPending.has(msg.id)) {
1213
- const { resolve: resolve14, reject: reject2 } = this.browserPending.get(msg.id);
1109
+ const { resolve: resolve13, reject: reject2 } = this.browserPending.get(msg.id);
1214
1110
  this.browserPending.delete(msg.id);
1215
1111
  if (msg.error) reject2(new Error(msg.error.message));
1216
- else resolve14(msg.result);
1112
+ else resolve13(msg.result);
1217
1113
  }
1218
1114
  } catch {
1219
1115
  }
@@ -1233,31 +1129,31 @@ var init_manager = __esm({
1233
1129
  }
1234
1130
  }
1235
1131
  getBrowserWsUrl() {
1236
- return new Promise((resolve13) => {
1132
+ return new Promise((resolve12) => {
1237
1133
  const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
1238
1134
  let data = "";
1239
1135
  res.on("data", (chunk) => data += chunk.toString());
1240
1136
  res.on("end", () => {
1241
1137
  try {
1242
1138
  const info = JSON.parse(data);
1243
- resolve13(info.webSocketDebuggerUrl || null);
1139
+ resolve12(info.webSocketDebuggerUrl || null);
1244
1140
  } catch {
1245
- resolve13(null);
1141
+ resolve12(null);
1246
1142
  }
1247
1143
  });
1248
1144
  });
1249
- req.on("error", () => resolve13(null));
1145
+ req.on("error", () => resolve12(null));
1250
1146
  req.setTimeout(3e3, () => {
1251
1147
  req.destroy();
1252
- resolve13(null);
1148
+ resolve12(null);
1253
1149
  });
1254
1150
  });
1255
1151
  }
1256
1152
  sendBrowser(method, params = {}, timeoutMs = 15e3) {
1257
- return new Promise((resolve13, reject) => {
1153
+ return new Promise((resolve12, reject) => {
1258
1154
  if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
1259
1155
  const id = this.browserMsgId++;
1260
- this.browserPending.set(id, { resolve: resolve13, reject });
1156
+ this.browserPending.set(id, { resolve: resolve12, reject });
1261
1157
  this.browserWs.send(JSON.stringify({ id, method, params }));
1262
1158
  setTimeout(() => {
1263
1159
  if (this.browserPending.has(id)) {
@@ -1297,11 +1193,11 @@ var init_manager = __esm({
1297
1193
  }
1298
1194
  // ─── CDP Protocol ────────────────────────────────────────
1299
1195
  sendInternal(method, params = {}, timeoutMs = 15e3) {
1300
- return new Promise((resolve13, reject) => {
1196
+ return new Promise((resolve12, reject) => {
1301
1197
  if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
1302
1198
  if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
1303
1199
  const id = this.msgId++;
1304
- this.pending.set(id, { resolve: resolve13, reject });
1200
+ this.pending.set(id, { resolve: resolve12, reject });
1305
1201
  this.ws.send(JSON.stringify({ id, method, params }));
1306
1202
  setTimeout(() => {
1307
1203
  if (this.pending.has(id)) {
@@ -1550,7 +1446,7 @@ var init_manager = __esm({
1550
1446
  const browserWs = this.browserWs;
1551
1447
  let msgId = this.browserMsgId;
1552
1448
  const sendWs = (method, params = {}, sessionId) => {
1553
- return new Promise((resolve13, reject) => {
1449
+ return new Promise((resolve12, reject) => {
1554
1450
  const mid = msgId++;
1555
1451
  this.browserMsgId = msgId;
1556
1452
  const handler = (raw) => {
@@ -1559,7 +1455,7 @@ var init_manager = __esm({
1559
1455
  if (msg.id === mid) {
1560
1456
  browserWs.removeListener("message", handler);
1561
1457
  if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
1562
- else resolve13(msg.result);
1458
+ else resolve12(msg.result);
1563
1459
  }
1564
1460
  } catch {
1565
1461
  }
@@ -1750,14 +1646,14 @@ var init_manager = __esm({
1750
1646
  if (!ws2 || ws2.readyState !== import_ws.default.OPEN) {
1751
1647
  throw new Error("CDP not connected");
1752
1648
  }
1753
- return new Promise((resolve13, reject) => {
1649
+ return new Promise((resolve12, reject) => {
1754
1650
  const id = getNextId();
1755
1651
  pendingMap.set(id, {
1756
1652
  resolve: (result) => {
1757
1653
  if (result?.result?.subtype === "error") {
1758
1654
  reject(new Error(result.result.description));
1759
1655
  } else {
1760
- resolve13(result?.result?.value);
1656
+ resolve12(result?.result?.value);
1761
1657
  }
1762
1658
  },
1763
1659
  reject
@@ -1789,10 +1685,10 @@ var init_manager = __esm({
1789
1685
  throw new Error("CDP not connected");
1790
1686
  }
1791
1687
  const sendViaSession = (method, params = {}) => {
1792
- return new Promise((resolve13, reject) => {
1688
+ return new Promise((resolve12, reject) => {
1793
1689
  const pendingMap = this._browserConnected ? this.browserPending : this.pending;
1794
1690
  const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
1795
- pendingMap.set(id, { resolve: resolve13, reject });
1691
+ pendingMap.set(id, { resolve: resolve12, reject });
1796
1692
  ws2.send(JSON.stringify({ id, sessionId, method, params }));
1797
1693
  setTimeout(() => {
1798
1694
  if (pendingMap.has(id)) {
@@ -2519,7 +2415,7 @@ var init_extension_provider_instance = __esm({
2519
2415
  function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
2520
2416
  try {
2521
2417
  const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
2522
- const dir = path5.join(HISTORY_DIR, sanitized);
2418
+ const dir = path4.join(HISTORY_DIR, sanitized);
2523
2419
  if (!fs3.existsSync(dir)) return { messages: [], hasMore: false };
2524
2420
  const sanitizedInstance = instanceId?.replace(/[^a-zA-Z0-9_-]/g, "_");
2525
2421
  const files = fs3.readdirSync(dir).filter((f) => {
@@ -2533,7 +2429,7 @@ function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
2533
2429
  const needed = offset + limit + 1;
2534
2430
  for (const file2 of files) {
2535
2431
  if (allMessages.length >= needed) break;
2536
- const filePath = path5.join(dir, file2);
2432
+ const filePath = path4.join(dir, file2);
2537
2433
  const content = fs3.readFileSync(filePath, "utf-8");
2538
2434
  const lines = content.trim().split("\n").filter(Boolean);
2539
2435
  for (let i = lines.length - 1; i >= 0; i--) {
@@ -2552,14 +2448,14 @@ function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
2552
2448
  return { messages: [], hasMore: false };
2553
2449
  }
2554
2450
  }
2555
- var fs3, path5, os5, HISTORY_DIR, RETAIN_DAYS, ChatHistoryWriter;
2451
+ var fs3, path4, os5, HISTORY_DIR, RETAIN_DAYS, ChatHistoryWriter;
2556
2452
  var init_chat_history = __esm({
2557
2453
  "../../oss/packages/daemon-core/src/config/chat-history.ts"() {
2558
2454
  "use strict";
2559
2455
  fs3 = __toESM(require("fs"));
2560
- path5 = __toESM(require("path"));
2456
+ path4 = __toESM(require("path"));
2561
2457
  os5 = __toESM(require("os"));
2562
- HISTORY_DIR = path5.join(os5.homedir(), ".adhdev", "history");
2458
+ HISTORY_DIR = path4.join(os5.homedir(), ".adhdev", "history");
2563
2459
  RETAIN_DAYS = 30;
2564
2460
  ChatHistoryWriter = class {
2565
2461
  /** Last seen message count per agent (deduplication) */
@@ -2602,11 +2498,11 @@ var init_chat_history = __esm({
2602
2498
  });
2603
2499
  }
2604
2500
  if (newMessages.length === 0) return;
2605
- const dir = path5.join(HISTORY_DIR, this.sanitize(agentType));
2501
+ const dir = path4.join(HISTORY_DIR, this.sanitize(agentType));
2606
2502
  fs3.mkdirSync(dir, { recursive: true });
2607
2503
  const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
2608
2504
  const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
2609
- const filePath = path5.join(dir, `${filePrefix}${date5}.jsonl`);
2505
+ const filePath = path4.join(dir, `${filePrefix}${date5}.jsonl`);
2610
2506
  const lines = newMessages.map((m) => JSON.stringify(m)).join("\n") + "\n";
2611
2507
  fs3.appendFileSync(filePath, lines, "utf-8");
2612
2508
  const prevCount = this.lastSeenCounts.get(dedupKey) || 0;
@@ -2650,11 +2546,11 @@ ${next}`;
2650
2546
  this.lastSeenTerminal.set(dedupKey, next);
2651
2547
  return;
2652
2548
  }
2653
- const dir = path5.join(HISTORY_DIR, this.sanitize(agentType));
2549
+ const dir = path4.join(HISTORY_DIR, this.sanitize(agentType));
2654
2550
  fs3.mkdirSync(dir, { recursive: true });
2655
2551
  const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
2656
2552
  const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
2657
- const filePath = path5.join(dir, `${filePrefix}${date5}.terminal.log`);
2553
+ const filePath = path4.join(dir, `${filePrefix}${date5}.terminal.log`);
2658
2554
  fs3.appendFileSync(filePath, delta, "utf-8");
2659
2555
  this.lastSeenTerminal.set(dedupKey, next);
2660
2556
  if (!this.rotated) {
@@ -2678,10 +2574,10 @@ ${next}`;
2678
2574
  const cutoff = Date.now() - RETAIN_DAYS * 24 * 60 * 60 * 1e3;
2679
2575
  const agentDirs = fs3.readdirSync(HISTORY_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
2680
2576
  for (const dir of agentDirs) {
2681
- const dirPath = path5.join(HISTORY_DIR, dir.name);
2577
+ const dirPath = path4.join(HISTORY_DIR, dir.name);
2682
2578
  const files = fs3.readdirSync(dirPath).filter((f) => f.endsWith(".jsonl") || f.endsWith(".terminal.log"));
2683
2579
  for (const file2 of files) {
2684
- const filePath = path5.join(dirPath, file2);
2580
+ const filePath = path4.join(dirPath, file2);
2685
2581
  const stat4 = fs3.statSync(filePath);
2686
2582
  if (stat4.mtimeMs < cutoff) {
2687
2583
  fs3.unlinkSync(filePath);
@@ -3583,6 +3479,14 @@ function buildSessionEntries(allStates, cdpManagers) {
3583
3479
  for (const state of acpStates) {
3584
3480
  sessions.push(buildAcpSession(state));
3585
3481
  }
3482
+ const extensionParentIds = new Set(
3483
+ sessions.filter((session) => session.transport === "cdp-webview" && !!session.parentId).map((session) => session.parentId)
3484
+ );
3485
+ for (const session of sessions) {
3486
+ if (session.transport === "cdp-page" && extensionParentIds.has(session.id)) {
3487
+ session.surfaceHidden = true;
3488
+ }
3489
+ }
3586
3490
  return sessions;
3587
3491
  }
3588
3492
  var IDE_SESSION_CAPABILITIES, EXTENSION_SESSION_CAPABILITIES, PTY_SESSION_CAPABILITIES, ACP_SESSION_CAPABILITIES;
@@ -4652,11 +4556,11 @@ function resolveSafePath(requestedPath) {
4652
4556
  const home = os6.homedir();
4653
4557
  let resolved;
4654
4558
  if (requestedPath.startsWith("~")) {
4655
- resolved = path6.join(home, requestedPath.slice(1));
4656
- } else if (path6.isAbsolute(requestedPath)) {
4559
+ resolved = path5.join(home, requestedPath.slice(1));
4560
+ } else if (path5.isAbsolute(requestedPath)) {
4657
4561
  resolved = requestedPath;
4658
4562
  } else {
4659
- resolved = path6.resolve(requestedPath);
4563
+ resolved = path5.resolve(requestedPath);
4660
4564
  }
4661
4565
  return resolved;
4662
4566
  }
@@ -4672,7 +4576,7 @@ async function handleFileRead(h, args) {
4672
4576
  async function handleFileWrite(h, args) {
4673
4577
  try {
4674
4578
  const filePath = resolveSafePath(args?.path);
4675
- fs4.mkdirSync(path6.dirname(filePath), { recursive: true });
4579
+ fs4.mkdirSync(path5.dirname(filePath), { recursive: true });
4676
4580
  fs4.writeFileSync(filePath, args?.content || "", "utf-8");
4677
4581
  return { success: true, path: filePath };
4678
4582
  } catch (e) {
@@ -4686,7 +4590,7 @@ async function handleFileList(h, args) {
4686
4590
  const files = entries.map((e) => ({
4687
4591
  name: e.name,
4688
4592
  type: e.isDirectory() ? "directory" : "file",
4689
- size: e.isFile() ? fs4.statSync(path6.join(dirPath, e.name)).size : void 0
4593
+ size: e.isFile() ? fs4.statSync(path5.join(dirPath, e.name)).size : void 0
4690
4594
  }));
4691
4595
  return { success: true, files, path: dirPath };
4692
4596
  } catch (e) {
@@ -4696,12 +4600,12 @@ async function handleFileList(h, args) {
4696
4600
  async function handleFileListBrowse(h, args) {
4697
4601
  return handleFileList(h, args);
4698
4602
  }
4699
- var fs4, path6, os6, KEY_TO_VK;
4603
+ var fs4, path5, os6, KEY_TO_VK;
4700
4604
  var init_cdp_commands = __esm({
4701
4605
  "../../oss/packages/daemon-core/src/commands/cdp-commands.ts"() {
4702
4606
  "use strict";
4703
4607
  fs4 = __toESM(require("fs"));
4704
- path6 = __toESM(require("path"));
4608
+ path5 = __toESM(require("path"));
4705
4609
  os6 = __toESM(require("os"));
4706
4610
  KEY_TO_VK = {
4707
4611
  Backspace: 8,
@@ -4894,13 +4798,12 @@ function handleGetIdeExtensions(h, args) {
4894
4798
  const loader = h.ctx.providerLoader;
4895
4799
  if (!loader) return { success: false, error: "ProviderLoader not initialized" };
4896
4800
  const allExtProviders = loader.getByCategory?.("extension") || [];
4897
- const config2 = loadConfig();
4898
4801
  if (ideType) {
4899
4802
  const extensions = allExtProviders.map((p) => ({
4900
4803
  type: p.type,
4901
4804
  name: p.name,
4902
4805
  extensionId: p.extensionId,
4903
- enabled: config2.ideSettings?.[ideType]?.extensions?.[p.type]?.enabled === true
4806
+ enabled: loader.getIdeExtensionEnabledState?.(ideType, p.type) === true
4904
4807
  }));
4905
4808
  return { success: true, ideType, extensions };
4906
4809
  }
@@ -4911,7 +4814,7 @@ function handleGetIdeExtensions(h, args) {
4911
4814
  type: p.type,
4912
4815
  name: p.name,
4913
4816
  extensionId: p.extensionId,
4914
- enabled: config2.ideSettings?.[ide]?.extensions?.[p.type]?.enabled === true
4817
+ enabled: loader.getIdeExtensionEnabledState?.(ide, p.type) === true
4915
4818
  }));
4916
4819
  }
4917
4820
  return { success: true, ideExtensions: result };
@@ -4934,7 +4837,6 @@ function handleSetIdeExtension(h, args) {
4934
4837
  var init_stream_commands = __esm({
4935
4838
  "../../oss/packages/daemon-core/src/commands/stream-commands.ts"() {
4936
4839
  "use strict";
4937
- init_config();
4938
4840
  init_logger();
4939
4841
  }
4940
4842
  });
@@ -4947,9 +4849,7 @@ function handleWorkspaceList() {
4947
4849
  success: true,
4948
4850
  workspaces: state.workspaces,
4949
4851
  defaultWorkspaceId: state.defaultWorkspaceId,
4950
- defaultWorkspacePath: state.defaultWorkspacePath,
4951
- legacyRecentPaths: config2.recentCliWorkspaces || [],
4952
- activity: getWorkspaceActivity(config2, 25)
4852
+ defaultWorkspacePath: state.defaultWorkspacePath
4953
4853
  };
4954
4854
  }
4955
4855
  function handleWorkspaceAdd(args) {
@@ -4960,10 +4860,9 @@ function handleWorkspaceAdd(args) {
4960
4860
  const config2 = loadConfig();
4961
4861
  const result = addWorkspaceEntry(config2, rawPath, label, { createIfMissing });
4962
4862
  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) };
4863
+ saveConfig(result.config);
4864
+ const state = getWorkspaceState(result.config);
4865
+ return { success: true, entry: result.entry, ...state };
4967
4866
  }
4968
4867
  function handleWorkspaceRemove(args) {
4969
4868
  const id = (args?.id || "").trim();
@@ -4972,13 +4871,9 @@ function handleWorkspaceRemove(args) {
4972
4871
  const removed = (config2.workspaces || []).find((w) => w.id === id);
4973
4872
  const result = removeWorkspaceEntry(config2, id);
4974
4873
  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) };
4874
+ saveConfig(result.config);
4875
+ const state = getWorkspaceState(result.config);
4876
+ return { success: true, removedId: id, ...state };
4982
4877
  }
4983
4878
  function handleWorkspaceSetDefault(args) {
4984
4879
  const clear = args?.clear === true || args?.id === null || args?.id === "";
@@ -4990,8 +4885,7 @@ function handleWorkspaceSetDefault(args) {
4990
4885
  const state2 = getWorkspaceState(result2.config);
4991
4886
  return {
4992
4887
  success: true,
4993
- ...state2,
4994
- activity: getWorkspaceActivity(result2.config, 25)
4888
+ ...state2
4995
4889
  };
4996
4890
  }
4997
4891
  const pathArg = args?.path != null && String(args.path).trim() ? String(args.path).trim() : "";
@@ -5015,21 +4909,15 @@ function handleWorkspaceSetDefault(args) {
5015
4909
  }
5016
4910
  const result = setDefaultWorkspaceId(config2, nextId);
5017
4911
  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) };
4912
+ saveConfig(result.config);
4913
+ const state = getWorkspaceState(result.config);
4914
+ return { success: true, ...state };
5026
4915
  }
5027
4916
  var init_workspace_commands = __esm({
5028
4917
  "../../oss/packages/daemon-core/src/commands/workspace-commands.ts"() {
5029
4918
  "use strict";
5030
4919
  init_config();
5031
4920
  init_workspaces();
5032
- init_workspace_activity();
5033
4921
  }
5034
4922
  });
5035
4923
 
@@ -5108,15 +4996,12 @@ var init_handler = __esm({
5108
4996
  "use strict";
5109
4997
  init_devtools();
5110
4998
  init_builders();
5111
- init_config();
5112
4999
  init_chat_history();
5113
5000
  init_logger();
5114
5001
  init_chat_commands();
5115
5002
  init_cdp_commands();
5116
5003
  init_stream_commands();
5117
5004
  init_workspace_commands();
5118
- init_workspaces();
5119
- init_workspace_activity();
5120
5005
  COMMAND_DEBUG_LEVELS = /* @__PURE__ */ new Set([
5121
5006
  "pty_input",
5122
5007
  "pty_resize",
@@ -5375,22 +5260,7 @@ var init_handler = __esm({
5375
5260
  return handleFileList(this, args);
5376
5261
  case "file_list_browse":
5377
5262
  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
5263
  // ─── 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
5264
  case "workspace_list":
5395
5265
  return handleWorkspaceList();
5396
5266
  case "workspace_add":
@@ -5398,7 +5268,6 @@ var init_handler = __esm({
5398
5268
  case "workspace_remove":
5399
5269
  return handleWorkspaceRemove(args);
5400
5270
  case "workspace_set_default":
5401
- case "workspace_set_active":
5402
5271
  return handleWorkspaceSetDefault(args);
5403
5272
  // ─── Script manage ───────────────────
5404
5273
  case "refresh_scripts":
@@ -5444,19 +5313,6 @@ var init_handler = __esm({
5444
5313
  }
5445
5314
  }
5446
5315
  // ─── 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
5316
  async handleRefreshScripts(_args) {
5461
5317
  if (this._ctx.providerLoader) {
5462
5318
  await this._ctx.providerLoader.fetchLatest().catch(() => {
@@ -5474,7 +5330,7 @@ var init_handler = __esm({
5474
5330
  try {
5475
5331
  const http3 = await import("http");
5476
5332
  const postData = JSON.stringify(body);
5477
- const result = await new Promise((resolve13, reject) => {
5333
+ const result = await new Promise((resolve12, reject) => {
5478
5334
  const req = http3.request({
5479
5335
  hostname: "127.0.0.1",
5480
5336
  port: 19280,
@@ -5486,9 +5342,9 @@ var init_handler = __esm({
5486
5342
  res.on("data", (chunk) => data += chunk);
5487
5343
  res.on("end", () => {
5488
5344
  try {
5489
- resolve13(JSON.parse(data));
5345
+ resolve12(JSON.parse(data));
5490
5346
  } catch {
5491
- resolve13({ raw: data });
5347
+ resolve12({ raw: data });
5492
5348
  }
5493
5349
  });
5494
5350
  });
@@ -5506,15 +5362,15 @@ var init_handler = __esm({
5506
5362
  if (!providerType) return { success: false, error: "providerType required" };
5507
5363
  try {
5508
5364
  const http3 = await import("http");
5509
- const result = await new Promise((resolve13, reject) => {
5365
+ const result = await new Promise((resolve12, reject) => {
5510
5366
  http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
5511
5367
  let data = "";
5512
5368
  res.on("data", (chunk) => data += chunk);
5513
5369
  res.on("end", () => {
5514
5370
  try {
5515
- resolve13(JSON.parse(data));
5371
+ resolve12(JSON.parse(data));
5516
5372
  } catch {
5517
- resolve13({ raw: data });
5373
+ resolve12({ raw: data });
5518
5374
  }
5519
5375
  });
5520
5376
  }).on("error", reject);
@@ -5528,7 +5384,7 @@ var init_handler = __esm({
5528
5384
  try {
5529
5385
  const http3 = await import("http");
5530
5386
  const postData = JSON.stringify(args || {});
5531
- const result = await new Promise((resolve13, reject) => {
5387
+ const result = await new Promise((resolve12, reject) => {
5532
5388
  const req = http3.request({
5533
5389
  hostname: "127.0.0.1",
5534
5390
  port: 19280,
@@ -5540,9 +5396,9 @@ var init_handler = __esm({
5540
5396
  res.on("data", (chunk) => data += chunk);
5541
5397
  res.on("end", () => {
5542
5398
  try {
5543
- resolve13(JSON.parse(data));
5399
+ resolve12(JSON.parse(data));
5544
5400
  } catch {
5545
- resolve13({ raw: data });
5401
+ resolve12({ raw: data });
5546
5402
  }
5547
5403
  });
5548
5404
  });
@@ -5663,7 +5519,7 @@ var init_readdirp = __esm({
5663
5519
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
5664
5520
  const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
5665
5521
  if (wantBigintFsStats) {
5666
- this._stat = (path19) => statMethod(path19, { bigint: true });
5522
+ this._stat = (path18) => statMethod(path18, { bigint: true });
5667
5523
  } else {
5668
5524
  this._stat = statMethod;
5669
5525
  }
@@ -5688,8 +5544,8 @@ var init_readdirp = __esm({
5688
5544
  const par = this.parent;
5689
5545
  const fil = par && par.files;
5690
5546
  if (fil && fil.length > 0) {
5691
- const { path: path19, depth } = par;
5692
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path19));
5547
+ const { path: path18, depth } = par;
5548
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path18));
5693
5549
  const awaited = await Promise.all(slice);
5694
5550
  for (const entry of awaited) {
5695
5551
  if (!entry)
@@ -5729,20 +5585,20 @@ var init_readdirp = __esm({
5729
5585
  this.reading = false;
5730
5586
  }
5731
5587
  }
5732
- async _exploreDir(path19, depth) {
5588
+ async _exploreDir(path18, depth) {
5733
5589
  let files;
5734
5590
  try {
5735
- files = await (0, import_promises.readdir)(path19, this._rdOptions);
5591
+ files = await (0, import_promises.readdir)(path18, this._rdOptions);
5736
5592
  } catch (error48) {
5737
5593
  this._onError(error48);
5738
5594
  }
5739
- return { files, depth, path: path19 };
5595
+ return { files, depth, path: path18 };
5740
5596
  }
5741
- async _formatEntry(dirent, path19) {
5597
+ async _formatEntry(dirent, path18) {
5742
5598
  let entry;
5743
5599
  const basename7 = this._isDirent ? dirent.name : dirent;
5744
5600
  try {
5745
- const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path19, basename7));
5601
+ const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path18, basename7));
5746
5602
  entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename7 };
5747
5603
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
5748
5604
  } catch (err) {
@@ -5799,16 +5655,16 @@ var init_readdirp = __esm({
5799
5655
  });
5800
5656
 
5801
5657
  // ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
5802
- function createFsWatchInstance(path19, options, listener, errHandler, emitRaw) {
5658
+ function createFsWatchInstance(path18, options, listener, errHandler, emitRaw) {
5803
5659
  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));
5660
+ listener(path18);
5661
+ emitRaw(rawEvent, evPath, { watchedPath: path18 });
5662
+ if (evPath && path18 !== evPath) {
5663
+ fsWatchBroadcast(sp.resolve(path18, evPath), KEY_LISTENERS, sp.join(path18, evPath));
5808
5664
  }
5809
5665
  };
5810
5666
  try {
5811
- return (0, import_node_fs.watch)(path19, {
5667
+ return (0, import_node_fs.watch)(path18, {
5812
5668
  persistent: options.persistent
5813
5669
  }, handleEvent);
5814
5670
  } catch (error48) {
@@ -6157,12 +6013,12 @@ var init_handler2 = __esm({
6157
6013
  listener(val1, val2, val3);
6158
6014
  });
6159
6015
  };
6160
- setFsWatchListener = (path19, fullPath, options, handlers) => {
6016
+ setFsWatchListener = (path18, fullPath, options, handlers) => {
6161
6017
  const { listener, errHandler, rawEmitter } = handlers;
6162
6018
  let cont = FsWatchInstances.get(fullPath);
6163
6019
  let watcher;
6164
6020
  if (!options.persistent) {
6165
- watcher = createFsWatchInstance(path19, options, listener, errHandler, rawEmitter);
6021
+ watcher = createFsWatchInstance(path18, options, listener, errHandler, rawEmitter);
6166
6022
  if (!watcher)
6167
6023
  return;
6168
6024
  return watcher.close.bind(watcher);
@@ -6173,7 +6029,7 @@ var init_handler2 = __esm({
6173
6029
  addAndConvert(cont, KEY_RAW, rawEmitter);
6174
6030
  } else {
6175
6031
  watcher = createFsWatchInstance(
6176
- path19,
6032
+ path18,
6177
6033
  options,
6178
6034
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
6179
6035
  errHandler,
@@ -6188,7 +6044,7 @@ var init_handler2 = __esm({
6188
6044
  cont.watcherUnusable = true;
6189
6045
  if (isWindows && error48.code === "EPERM") {
6190
6046
  try {
6191
- const fd = await (0, import_promises2.open)(path19, "r");
6047
+ const fd = await (0, import_promises2.open)(path18, "r");
6192
6048
  await fd.close();
6193
6049
  broadcastErr(error48);
6194
6050
  } catch (err) {
@@ -6219,7 +6075,7 @@ var init_handler2 = __esm({
6219
6075
  };
6220
6076
  };
6221
6077
  FsWatchFileInstances = /* @__PURE__ */ new Map();
6222
- setFsWatchFileListener = (path19, fullPath, options, handlers) => {
6078
+ setFsWatchFileListener = (path18, fullPath, options, handlers) => {
6223
6079
  const { listener, rawEmitter } = handlers;
6224
6080
  let cont = FsWatchFileInstances.get(fullPath);
6225
6081
  const copts = cont && cont.options;
@@ -6241,7 +6097,7 @@ var init_handler2 = __esm({
6241
6097
  });
6242
6098
  const currmtime = curr.mtimeMs;
6243
6099
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
6244
- foreach(cont.listeners, (listener2) => listener2(path19, curr));
6100
+ foreach(cont.listeners, (listener2) => listener2(path18, curr));
6245
6101
  }
6246
6102
  })
6247
6103
  };
@@ -6271,13 +6127,13 @@ var init_handler2 = __esm({
6271
6127
  * @param listener on fs change
6272
6128
  * @returns closer for the watcher instance
6273
6129
  */
6274
- _watchWithNodeFs(path19, listener) {
6130
+ _watchWithNodeFs(path18, listener) {
6275
6131
  const opts = this.fsw.options;
6276
- const directory = sp.dirname(path19);
6277
- const basename7 = sp.basename(path19);
6132
+ const directory = sp.dirname(path18);
6133
+ const basename7 = sp.basename(path18);
6278
6134
  const parent = this.fsw._getWatchedDir(directory);
6279
6135
  parent.add(basename7);
6280
- const absolutePath = sp.resolve(path19);
6136
+ const absolutePath = sp.resolve(path18);
6281
6137
  const options = {
6282
6138
  persistent: opts.persistent
6283
6139
  };
@@ -6287,12 +6143,12 @@ var init_handler2 = __esm({
6287
6143
  if (opts.usePolling) {
6288
6144
  const enableBin = opts.interval !== opts.binaryInterval;
6289
6145
  options.interval = enableBin && isBinaryPath(basename7) ? opts.binaryInterval : opts.interval;
6290
- closer = setFsWatchFileListener(path19, absolutePath, options, {
6146
+ closer = setFsWatchFileListener(path18, absolutePath, options, {
6291
6147
  listener,
6292
6148
  rawEmitter: this.fsw._emitRaw
6293
6149
  });
6294
6150
  } else {
6295
- closer = setFsWatchListener(path19, absolutePath, options, {
6151
+ closer = setFsWatchListener(path18, absolutePath, options, {
6296
6152
  listener,
6297
6153
  errHandler: this._boundHandleError,
6298
6154
  rawEmitter: this.fsw._emitRaw
@@ -6314,7 +6170,7 @@ var init_handler2 = __esm({
6314
6170
  let prevStats = stats;
6315
6171
  if (parent.has(basename7))
6316
6172
  return;
6317
- const listener = async (path19, newStats) => {
6173
+ const listener = async (path18, newStats) => {
6318
6174
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
6319
6175
  return;
6320
6176
  if (!newStats || newStats.mtimeMs === 0) {
@@ -6328,11 +6184,11 @@ var init_handler2 = __esm({
6328
6184
  this.fsw._emit(EV.CHANGE, file2, newStats2);
6329
6185
  }
6330
6186
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
6331
- this.fsw._closeFile(path19);
6187
+ this.fsw._closeFile(path18);
6332
6188
  prevStats = newStats2;
6333
6189
  const closer2 = this._watchWithNodeFs(file2, listener);
6334
6190
  if (closer2)
6335
- this.fsw._addPathCloser(path19, closer2);
6191
+ this.fsw._addPathCloser(path18, closer2);
6336
6192
  } else {
6337
6193
  prevStats = newStats2;
6338
6194
  }
@@ -6364,7 +6220,7 @@ var init_handler2 = __esm({
6364
6220
  * @param item basename of this item
6365
6221
  * @returns true if no more processing is needed for this entry.
6366
6222
  */
6367
- async _handleSymlink(entry, directory, path19, item) {
6223
+ async _handleSymlink(entry, directory, path18, item) {
6368
6224
  if (this.fsw.closed) {
6369
6225
  return;
6370
6226
  }
@@ -6374,7 +6230,7 @@ var init_handler2 = __esm({
6374
6230
  this.fsw._incrReadyCount();
6375
6231
  let linkPath;
6376
6232
  try {
6377
- linkPath = await (0, import_promises2.realpath)(path19);
6233
+ linkPath = await (0, import_promises2.realpath)(path18);
6378
6234
  } catch (e) {
6379
6235
  this.fsw._emitReady();
6380
6236
  return true;
@@ -6384,12 +6240,12 @@ var init_handler2 = __esm({
6384
6240
  if (dir.has(item)) {
6385
6241
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
6386
6242
  this.fsw._symlinkPaths.set(full, linkPath);
6387
- this.fsw._emit(EV.CHANGE, path19, entry.stats);
6243
+ this.fsw._emit(EV.CHANGE, path18, entry.stats);
6388
6244
  }
6389
6245
  } else {
6390
6246
  dir.add(item);
6391
6247
  this.fsw._symlinkPaths.set(full, linkPath);
6392
- this.fsw._emit(EV.ADD, path19, entry.stats);
6248
+ this.fsw._emit(EV.ADD, path18, entry.stats);
6393
6249
  }
6394
6250
  this.fsw._emitReady();
6395
6251
  return true;
@@ -6419,9 +6275,9 @@ var init_handler2 = __esm({
6419
6275
  return;
6420
6276
  }
6421
6277
  const item = entry.path;
6422
- let path19 = sp.join(directory, item);
6278
+ let path18 = sp.join(directory, item);
6423
6279
  current.add(item);
6424
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path19, item)) {
6280
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path18, item)) {
6425
6281
  return;
6426
6282
  }
6427
6283
  if (this.fsw.closed) {
@@ -6430,11 +6286,11 @@ var init_handler2 = __esm({
6430
6286
  }
6431
6287
  if (item === target || !target && !previous.has(item)) {
6432
6288
  this.fsw._incrReadyCount();
6433
- path19 = sp.join(dir, sp.relative(dir, path19));
6434
- this._addToNodeFs(path19, initialAdd, wh, depth + 1);
6289
+ path18 = sp.join(dir, sp.relative(dir, path18));
6290
+ this._addToNodeFs(path18, initialAdd, wh, depth + 1);
6435
6291
  }
6436
6292
  }).on(EV.ERROR, this._boundHandleError);
6437
- return new Promise((resolve13, reject) => {
6293
+ return new Promise((resolve12, reject) => {
6438
6294
  if (!stream)
6439
6295
  return reject();
6440
6296
  stream.once(STR_END, () => {
@@ -6443,7 +6299,7 @@ var init_handler2 = __esm({
6443
6299
  return;
6444
6300
  }
6445
6301
  const wasThrottled = throttler ? throttler.clear() : false;
6446
- resolve13(void 0);
6302
+ resolve12(void 0);
6447
6303
  previous.getChildren().filter((item) => {
6448
6304
  return item !== directory && !current.has(item);
6449
6305
  }).forEach((item) => {
@@ -6500,13 +6356,13 @@ var init_handler2 = __esm({
6500
6356
  * @param depth Child path actually targeted for watch
6501
6357
  * @param target Child path actually targeted for watch
6502
6358
  */
6503
- async _addToNodeFs(path19, initialAdd, priorWh, depth, target) {
6359
+ async _addToNodeFs(path18, initialAdd, priorWh, depth, target) {
6504
6360
  const ready = this.fsw._emitReady;
6505
- if (this.fsw._isIgnored(path19) || this.fsw.closed) {
6361
+ if (this.fsw._isIgnored(path18) || this.fsw.closed) {
6506
6362
  ready();
6507
6363
  return false;
6508
6364
  }
6509
- const wh = this.fsw._getWatchHelpers(path19);
6365
+ const wh = this.fsw._getWatchHelpers(path18);
6510
6366
  if (priorWh) {
6511
6367
  wh.filterPath = (entry) => priorWh.filterPath(entry);
6512
6368
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -6522,8 +6378,8 @@ var init_handler2 = __esm({
6522
6378
  const follow = this.fsw.options.followSymlinks;
6523
6379
  let closer;
6524
6380
  if (stats.isDirectory()) {
6525
- const absPath = sp.resolve(path19);
6526
- const targetPath = follow ? await (0, import_promises2.realpath)(path19) : path19;
6381
+ const absPath = sp.resolve(path18);
6382
+ const targetPath = follow ? await (0, import_promises2.realpath)(path18) : path18;
6527
6383
  if (this.fsw.closed)
6528
6384
  return;
6529
6385
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -6533,29 +6389,29 @@ var init_handler2 = __esm({
6533
6389
  this.fsw._symlinkPaths.set(absPath, targetPath);
6534
6390
  }
6535
6391
  } else if (stats.isSymbolicLink()) {
6536
- const targetPath = follow ? await (0, import_promises2.realpath)(path19) : path19;
6392
+ const targetPath = follow ? await (0, import_promises2.realpath)(path18) : path18;
6537
6393
  if (this.fsw.closed)
6538
6394
  return;
6539
6395
  const parent = sp.dirname(wh.watchPath);
6540
6396
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
6541
6397
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
6542
- closer = await this._handleDir(parent, stats, initialAdd, depth, path19, wh, targetPath);
6398
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path18, wh, targetPath);
6543
6399
  if (this.fsw.closed)
6544
6400
  return;
6545
6401
  if (targetPath !== void 0) {
6546
- this.fsw._symlinkPaths.set(sp.resolve(path19), targetPath);
6402
+ this.fsw._symlinkPaths.set(sp.resolve(path18), targetPath);
6547
6403
  }
6548
6404
  } else {
6549
6405
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
6550
6406
  }
6551
6407
  ready();
6552
6408
  if (closer)
6553
- this.fsw._addPathCloser(path19, closer);
6409
+ this.fsw._addPathCloser(path18, closer);
6554
6410
  return false;
6555
6411
  } catch (error48) {
6556
6412
  if (this.fsw._handleError(error48)) {
6557
6413
  ready();
6558
- return path19;
6414
+ return path18;
6559
6415
  }
6560
6416
  }
6561
6417
  }
@@ -6590,24 +6446,24 @@ function createPattern(matcher) {
6590
6446
  }
6591
6447
  return () => false;
6592
6448
  }
6593
- function normalizePath(path19) {
6594
- if (typeof path19 !== "string")
6449
+ function normalizePath(path18) {
6450
+ if (typeof path18 !== "string")
6595
6451
  throw new Error("string expected");
6596
- path19 = sp2.normalize(path19);
6597
- path19 = path19.replace(/\\/g, "/");
6452
+ path18 = sp2.normalize(path18);
6453
+ path18 = path18.replace(/\\/g, "/");
6598
6454
  let prepend = false;
6599
- if (path19.startsWith("//"))
6455
+ if (path18.startsWith("//"))
6600
6456
  prepend = true;
6601
- path19 = path19.replace(DOUBLE_SLASH_RE, "/");
6457
+ path18 = path18.replace(DOUBLE_SLASH_RE, "/");
6602
6458
  if (prepend)
6603
- path19 = "/" + path19;
6604
- return path19;
6459
+ path18 = "/" + path18;
6460
+ return path18;
6605
6461
  }
6606
6462
  function matchPatterns(patterns, testString, stats) {
6607
- const path19 = normalizePath(testString);
6463
+ const path18 = normalizePath(testString);
6608
6464
  for (let index = 0; index < patterns.length; index++) {
6609
6465
  const pattern = patterns[index];
6610
- if (pattern(path19, stats)) {
6466
+ if (pattern(path18, stats)) {
6611
6467
  return true;
6612
6468
  }
6613
6469
  }
@@ -6670,19 +6526,19 @@ var init_chokidar = __esm({
6670
6526
  }
6671
6527
  return str;
6672
6528
  };
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));
6529
+ normalizePathToUnix = (path18) => toUnix(sp2.normalize(toUnix(path18)));
6530
+ normalizeIgnored = (cwd = "") => (path18) => {
6531
+ if (typeof path18 === "string") {
6532
+ return normalizePathToUnix(sp2.isAbsolute(path18) ? path18 : sp2.join(cwd, path18));
6677
6533
  } else {
6678
- return path19;
6534
+ return path18;
6679
6535
  }
6680
6536
  };
6681
- getAbsolutePath = (path19, cwd) => {
6682
- if (sp2.isAbsolute(path19)) {
6683
- return path19;
6537
+ getAbsolutePath = (path18, cwd) => {
6538
+ if (sp2.isAbsolute(path18)) {
6539
+ return path18;
6684
6540
  }
6685
- return sp2.join(cwd, path19);
6541
+ return sp2.join(cwd, path18);
6686
6542
  };
6687
6543
  EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
6688
6544
  DirEntry = class {
@@ -6747,10 +6603,10 @@ var init_chokidar = __esm({
6747
6603
  dirParts;
6748
6604
  followSymlinks;
6749
6605
  statMethod;
6750
- constructor(path19, follow, fsw) {
6606
+ constructor(path18, follow, fsw) {
6751
6607
  this.fsw = fsw;
6752
- const watchPath = path19;
6753
- this.path = path19 = path19.replace(REPLACER_RE, "");
6608
+ const watchPath = path18;
6609
+ this.path = path18 = path18.replace(REPLACER_RE, "");
6754
6610
  this.watchPath = watchPath;
6755
6611
  this.fullWatchPath = sp2.resolve(watchPath);
6756
6612
  this.dirParts = [];
@@ -6890,20 +6746,20 @@ var init_chokidar = __esm({
6890
6746
  this._closePromise = void 0;
6891
6747
  let paths = unifyPaths(paths_);
6892
6748
  if (cwd) {
6893
- paths = paths.map((path19) => {
6894
- const absPath = getAbsolutePath(path19, cwd);
6749
+ paths = paths.map((path18) => {
6750
+ const absPath = getAbsolutePath(path18, cwd);
6895
6751
  return absPath;
6896
6752
  });
6897
6753
  }
6898
- paths.forEach((path19) => {
6899
- this._removeIgnoredPath(path19);
6754
+ paths.forEach((path18) => {
6755
+ this._removeIgnoredPath(path18);
6900
6756
  });
6901
6757
  this._userIgnored = void 0;
6902
6758
  if (!this._readyCount)
6903
6759
  this._readyCount = 0;
6904
6760
  this._readyCount += paths.length;
6905
- Promise.all(paths.map(async (path19) => {
6906
- const res = await this._nodeFsHandler._addToNodeFs(path19, !_internal, void 0, 0, _origAdd);
6761
+ Promise.all(paths.map(async (path18) => {
6762
+ const res = await this._nodeFsHandler._addToNodeFs(path18, !_internal, void 0, 0, _origAdd);
6907
6763
  if (res)
6908
6764
  this._emitReady();
6909
6765
  return res;
@@ -6925,17 +6781,17 @@ var init_chokidar = __esm({
6925
6781
  return this;
6926
6782
  const paths = unifyPaths(paths_);
6927
6783
  const { cwd } = this.options;
6928
- paths.forEach((path19) => {
6929
- if (!sp2.isAbsolute(path19) && !this._closers.has(path19)) {
6784
+ paths.forEach((path18) => {
6785
+ if (!sp2.isAbsolute(path18) && !this._closers.has(path18)) {
6930
6786
  if (cwd)
6931
- path19 = sp2.join(cwd, path19);
6932
- path19 = sp2.resolve(path19);
6787
+ path18 = sp2.join(cwd, path18);
6788
+ path18 = sp2.resolve(path18);
6933
6789
  }
6934
- this._closePath(path19);
6935
- this._addIgnoredPath(path19);
6936
- if (this._watched.has(path19)) {
6790
+ this._closePath(path18);
6791
+ this._addIgnoredPath(path18);
6792
+ if (this._watched.has(path18)) {
6937
6793
  this._addIgnoredPath({
6938
- path: path19,
6794
+ path: path18,
6939
6795
  recursive: true
6940
6796
  });
6941
6797
  }
@@ -6999,38 +6855,38 @@ var init_chokidar = __esm({
6999
6855
  * @param stats arguments to be passed with event
7000
6856
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
7001
6857
  */
7002
- async _emit(event, path19, stats) {
6858
+ async _emit(event, path18, stats) {
7003
6859
  if (this.closed)
7004
6860
  return;
7005
6861
  const opts = this.options;
7006
6862
  if (isWindows)
7007
- path19 = sp2.normalize(path19);
6863
+ path18 = sp2.normalize(path18);
7008
6864
  if (opts.cwd)
7009
- path19 = sp2.relative(opts.cwd, path19);
7010
- const args = [path19];
6865
+ path18 = sp2.relative(opts.cwd, path18);
6866
+ const args = [path18];
7011
6867
  if (stats != null)
7012
6868
  args.push(stats);
7013
6869
  const awf = opts.awaitWriteFinish;
7014
6870
  let pw;
7015
- if (awf && (pw = this._pendingWrites.get(path19))) {
6871
+ if (awf && (pw = this._pendingWrites.get(path18))) {
7016
6872
  pw.lastChange = /* @__PURE__ */ new Date();
7017
6873
  return this;
7018
6874
  }
7019
6875
  if (opts.atomic) {
7020
6876
  if (event === EVENTS.UNLINK) {
7021
- this._pendingUnlinks.set(path19, [event, ...args]);
6877
+ this._pendingUnlinks.set(path18, [event, ...args]);
7022
6878
  setTimeout(() => {
7023
- this._pendingUnlinks.forEach((entry, path20) => {
6879
+ this._pendingUnlinks.forEach((entry, path19) => {
7024
6880
  this.emit(...entry);
7025
6881
  this.emit(EVENTS.ALL, ...entry);
7026
- this._pendingUnlinks.delete(path20);
6882
+ this._pendingUnlinks.delete(path19);
7027
6883
  });
7028
6884
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
7029
6885
  return this;
7030
6886
  }
7031
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path19)) {
6887
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path18)) {
7032
6888
  event = EVENTS.CHANGE;
7033
- this._pendingUnlinks.delete(path19);
6889
+ this._pendingUnlinks.delete(path18);
7034
6890
  }
7035
6891
  }
7036
6892
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -7048,16 +6904,16 @@ var init_chokidar = __esm({
7048
6904
  this.emitWithAll(event, args);
7049
6905
  }
7050
6906
  };
7051
- this._awaitWriteFinish(path19, awf.stabilityThreshold, event, awfEmit);
6907
+ this._awaitWriteFinish(path18, awf.stabilityThreshold, event, awfEmit);
7052
6908
  return this;
7053
6909
  }
7054
6910
  if (event === EVENTS.CHANGE) {
7055
- const isThrottled = !this._throttle(EVENTS.CHANGE, path19, 50);
6911
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path18, 50);
7056
6912
  if (isThrottled)
7057
6913
  return this;
7058
6914
  }
7059
6915
  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;
6916
+ const fullPath = opts.cwd ? sp2.join(opts.cwd, path18) : path18;
7061
6917
  let stats2;
7062
6918
  try {
7063
6919
  stats2 = await (0, import_promises3.stat)(fullPath);
@@ -7088,23 +6944,23 @@ var init_chokidar = __esm({
7088
6944
  * @param timeout duration of time to suppress duplicate actions
7089
6945
  * @returns tracking object or false if action should be suppressed
7090
6946
  */
7091
- _throttle(actionType, path19, timeout) {
6947
+ _throttle(actionType, path18, timeout) {
7092
6948
  if (!this._throttled.has(actionType)) {
7093
6949
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
7094
6950
  }
7095
6951
  const action = this._throttled.get(actionType);
7096
6952
  if (!action)
7097
6953
  throw new Error("invalid throttle");
7098
- const actionPath = action.get(path19);
6954
+ const actionPath = action.get(path18);
7099
6955
  if (actionPath) {
7100
6956
  actionPath.count++;
7101
6957
  return false;
7102
6958
  }
7103
6959
  let timeoutObject;
7104
6960
  const clear = () => {
7105
- const item = action.get(path19);
6961
+ const item = action.get(path18);
7106
6962
  const count = item ? item.count : 0;
7107
- action.delete(path19);
6963
+ action.delete(path18);
7108
6964
  clearTimeout(timeoutObject);
7109
6965
  if (item)
7110
6966
  clearTimeout(item.timeoutObject);
@@ -7112,7 +6968,7 @@ var init_chokidar = __esm({
7112
6968
  };
7113
6969
  timeoutObject = setTimeout(clear, timeout);
7114
6970
  const thr = { timeoutObject, clear, count: 0 };
7115
- action.set(path19, thr);
6971
+ action.set(path18, thr);
7116
6972
  return thr;
7117
6973
  }
7118
6974
  _incrReadyCount() {
@@ -7126,44 +6982,44 @@ var init_chokidar = __esm({
7126
6982
  * @param event
7127
6983
  * @param awfEmit Callback to be called when ready for event to be emitted.
7128
6984
  */
7129
- _awaitWriteFinish(path19, threshold, event, awfEmit) {
6985
+ _awaitWriteFinish(path18, threshold, event, awfEmit) {
7130
6986
  const awf = this.options.awaitWriteFinish;
7131
6987
  if (typeof awf !== "object")
7132
6988
  return;
7133
6989
  const pollInterval = awf.pollInterval;
7134
6990
  let timeoutHandler;
7135
- let fullPath = path19;
7136
- if (this.options.cwd && !sp2.isAbsolute(path19)) {
7137
- fullPath = sp2.join(this.options.cwd, path19);
6991
+ let fullPath = path18;
6992
+ if (this.options.cwd && !sp2.isAbsolute(path18)) {
6993
+ fullPath = sp2.join(this.options.cwd, path18);
7138
6994
  }
7139
6995
  const now = /* @__PURE__ */ new Date();
7140
6996
  const writes = this._pendingWrites;
7141
6997
  function awaitWriteFinishFn(prevStat) {
7142
6998
  (0, import_node_fs2.stat)(fullPath, (err, curStat) => {
7143
- if (err || !writes.has(path19)) {
6999
+ if (err || !writes.has(path18)) {
7144
7000
  if (err && err.code !== "ENOENT")
7145
7001
  awfEmit(err);
7146
7002
  return;
7147
7003
  }
7148
7004
  const now2 = Number(/* @__PURE__ */ new Date());
7149
7005
  if (prevStat && curStat.size !== prevStat.size) {
7150
- writes.get(path19).lastChange = now2;
7006
+ writes.get(path18).lastChange = now2;
7151
7007
  }
7152
- const pw = writes.get(path19);
7008
+ const pw = writes.get(path18);
7153
7009
  const df = now2 - pw.lastChange;
7154
7010
  if (df >= threshold) {
7155
- writes.delete(path19);
7011
+ writes.delete(path18);
7156
7012
  awfEmit(void 0, curStat);
7157
7013
  } else {
7158
7014
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
7159
7015
  }
7160
7016
  });
7161
7017
  }
7162
- if (!writes.has(path19)) {
7163
- writes.set(path19, {
7018
+ if (!writes.has(path18)) {
7019
+ writes.set(path18, {
7164
7020
  lastChange: now,
7165
7021
  cancelWait: () => {
7166
- writes.delete(path19);
7022
+ writes.delete(path18);
7167
7023
  clearTimeout(timeoutHandler);
7168
7024
  return event;
7169
7025
  }
@@ -7174,8 +7030,8 @@ var init_chokidar = __esm({
7174
7030
  /**
7175
7031
  * Determines whether user has asked to ignore this path.
7176
7032
  */
7177
- _isIgnored(path19, stats) {
7178
- if (this.options.atomic && DOT_RE.test(path19))
7033
+ _isIgnored(path18, stats) {
7034
+ if (this.options.atomic && DOT_RE.test(path18))
7179
7035
  return true;
7180
7036
  if (!this._userIgnored) {
7181
7037
  const { cwd } = this.options;
@@ -7185,17 +7041,17 @@ var init_chokidar = __esm({
7185
7041
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
7186
7042
  this._userIgnored = anymatch(list, void 0);
7187
7043
  }
7188
- return this._userIgnored(path19, stats);
7044
+ return this._userIgnored(path18, stats);
7189
7045
  }
7190
- _isntIgnored(path19, stat4) {
7191
- return !this._isIgnored(path19, stat4);
7046
+ _isntIgnored(path18, stat4) {
7047
+ return !this._isIgnored(path18, stat4);
7192
7048
  }
7193
7049
  /**
7194
7050
  * Provides a set of common helpers and properties relating to symlink handling.
7195
7051
  * @param path file or directory pattern being watched
7196
7052
  */
7197
- _getWatchHelpers(path19) {
7198
- return new WatchHelper(path19, this.options.followSymlinks, this);
7053
+ _getWatchHelpers(path18) {
7054
+ return new WatchHelper(path18, this.options.followSymlinks, this);
7199
7055
  }
7200
7056
  // Directory helpers
7201
7057
  // -----------------
@@ -7227,63 +7083,63 @@ var init_chokidar = __esm({
7227
7083
  * @param item base path of item/directory
7228
7084
  */
7229
7085
  _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))
7086
+ const path18 = sp2.join(directory, item);
7087
+ const fullPath = sp2.resolve(path18);
7088
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path18) || this._watched.has(fullPath);
7089
+ if (!this._throttle("remove", path18, 100))
7234
7090
  return;
7235
7091
  if (!isDirectory && this._watched.size === 1) {
7236
7092
  this.add(directory, item, true);
7237
7093
  }
7238
- const wp = this._getWatchedDir(path19);
7094
+ const wp = this._getWatchedDir(path18);
7239
7095
  const nestedDirectoryChildren = wp.getChildren();
7240
- nestedDirectoryChildren.forEach((nested) => this._remove(path19, nested));
7096
+ nestedDirectoryChildren.forEach((nested) => this._remove(path18, nested));
7241
7097
  const parent = this._getWatchedDir(directory);
7242
7098
  const wasTracked = parent.has(item);
7243
7099
  parent.remove(item);
7244
7100
  if (this._symlinkPaths.has(fullPath)) {
7245
7101
  this._symlinkPaths.delete(fullPath);
7246
7102
  }
7247
- let relPath = path19;
7103
+ let relPath = path18;
7248
7104
  if (this.options.cwd)
7249
- relPath = sp2.relative(this.options.cwd, path19);
7105
+ relPath = sp2.relative(this.options.cwd, path18);
7250
7106
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
7251
7107
  const event = this._pendingWrites.get(relPath).cancelWait();
7252
7108
  if (event === EVENTS.ADD)
7253
7109
  return;
7254
7110
  }
7255
- this._watched.delete(path19);
7111
+ this._watched.delete(path18);
7256
7112
  this._watched.delete(fullPath);
7257
7113
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
7258
- if (wasTracked && !this._isIgnored(path19))
7259
- this._emit(eventName, path19);
7260
- this._closePath(path19);
7114
+ if (wasTracked && !this._isIgnored(path18))
7115
+ this._emit(eventName, path18);
7116
+ this._closePath(path18);
7261
7117
  }
7262
7118
  /**
7263
7119
  * Closes all watchers for a path
7264
7120
  */
7265
- _closePath(path19) {
7266
- this._closeFile(path19);
7267
- const dir = sp2.dirname(path19);
7268
- this._getWatchedDir(dir).remove(sp2.basename(path19));
7121
+ _closePath(path18) {
7122
+ this._closeFile(path18);
7123
+ const dir = sp2.dirname(path18);
7124
+ this._getWatchedDir(dir).remove(sp2.basename(path18));
7269
7125
  }
7270
7126
  /**
7271
7127
  * Closes only file-specific watchers
7272
7128
  */
7273
- _closeFile(path19) {
7274
- const closers = this._closers.get(path19);
7129
+ _closeFile(path18) {
7130
+ const closers = this._closers.get(path18);
7275
7131
  if (!closers)
7276
7132
  return;
7277
7133
  closers.forEach((closer) => closer());
7278
- this._closers.delete(path19);
7134
+ this._closers.delete(path18);
7279
7135
  }
7280
- _addPathCloser(path19, closer) {
7136
+ _addPathCloser(path18, closer) {
7281
7137
  if (!closer)
7282
7138
  return;
7283
- let list = this._closers.get(path19);
7139
+ let list = this._closers.get(path18);
7284
7140
  if (!list) {
7285
7141
  list = [];
7286
- this._closers.set(path19, list);
7142
+ this._closers.set(path18, list);
7287
7143
  }
7288
7144
  list.push(closer);
7289
7145
  }
@@ -7309,12 +7165,12 @@ var init_chokidar = __esm({
7309
7165
  });
7310
7166
 
7311
7167
  // ../../oss/packages/daemon-core/src/providers/provider-loader.ts
7312
- var fs5, path7, os7, ProviderLoader;
7168
+ var fs5, path6, os7, ProviderLoader;
7313
7169
  var init_provider_loader = __esm({
7314
7170
  "../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
7315
7171
  "use strict";
7316
7172
  fs5 = __toESM(require("fs"));
7317
- path7 = __toESM(require("path"));
7173
+ path6 = __toESM(require("path"));
7318
7174
  os7 = __toESM(require("os"));
7319
7175
  init_chokidar();
7320
7176
  init_ide_detector();
@@ -7336,12 +7192,12 @@ var init_provider_loader = __esm({
7336
7192
  static META_FILE = ".meta.json";
7337
7193
  constructor(options) {
7338
7194
  this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
7339
- const defaultProvidersDir = path7.join(os7.homedir(), ".adhdev", "providers");
7195
+ const defaultProvidersDir = path6.join(os7.homedir(), ".adhdev", "providers");
7340
7196
  if (options?.userDir) {
7341
7197
  this.userDir = options.userDir;
7342
7198
  this.log(`Config 'providerDir' applied: ${this.userDir}`);
7343
7199
  } else {
7344
- const localRepoPath = path7.resolve(__dirname, "../../../../../adhdev-providers");
7200
+ const localRepoPath = path6.resolve(__dirname, "../../../../../adhdev-providers");
7345
7201
  if (fs5.existsSync(localRepoPath)) {
7346
7202
  this.userDir = localRepoPath;
7347
7203
  this.log(`Auto-detected local public repository: ${this.userDir} (Dev workspace speedup)`);
@@ -7350,7 +7206,7 @@ var init_provider_loader = __esm({
7350
7206
  this.log(`Using default user providers directory: ${this.userDir}`);
7351
7207
  }
7352
7208
  }
7353
- this.upstreamDir = path7.join(defaultProvidersDir, ".upstream");
7209
+ this.upstreamDir = path6.join(defaultProvidersDir, ".upstream");
7354
7210
  this.disableUpstream = options?.disableUpstream ?? false;
7355
7211
  }
7356
7212
  log(msg) {
@@ -7380,7 +7236,7 @@ var init_provider_loader = __esm({
7380
7236
  * Canonical provider directory shape for a given root.
7381
7237
  */
7382
7238
  getProviderDir(root, category, type) {
7383
- return path7.join(root, category, type);
7239
+ return path6.join(root, category, type);
7384
7240
  }
7385
7241
  /**
7386
7242
  * Canonical user override directory for a provider.
@@ -7407,7 +7263,7 @@ var init_provider_loader = __esm({
7407
7263
  resolveProviderFile(type, ...segments) {
7408
7264
  const dir = this.findProviderDirInternal(type);
7409
7265
  if (!dir) return null;
7410
- return path7.join(dir, ...segments);
7266
+ return path6.join(dir, ...segments);
7411
7267
  }
7412
7268
  /**
7413
7269
  * Load all providers (3-tier priority)
@@ -7445,7 +7301,7 @@ var init_provider_loader = __esm({
7445
7301
  if (!fs5.existsSync(this.upstreamDir)) return false;
7446
7302
  try {
7447
7303
  return fs5.readdirSync(this.upstreamDir).some(
7448
- (d) => fs5.statSync(path7.join(this.upstreamDir, d)).isDirectory()
7304
+ (d) => fs5.statSync(path6.join(this.upstreamDir, d)).isDirectory()
7449
7305
  );
7450
7306
  } catch {
7451
7307
  return false;
@@ -7530,16 +7386,23 @@ var init_provider_loader = __esm({
7530
7386
  isEnabled(type, ideType) {
7531
7387
  if (!ideType) return true;
7532
7388
  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;
7389
+ return this.getIdeExtensionEnabledState(ideType, type);
7538
7390
  } catch {
7539
7391
  return false;
7540
7392
  }
7541
7393
  }
7542
7394
  /**
7395
+ * Resolve per-IDE extension enabled state using the same normalization
7396
+ * that runtime attach/remove uses.
7397
+ */
7398
+ getIdeExtensionEnabledState(ideType, extensionType) {
7399
+ const { loadConfig: loadConfig2 } = (init_config(), __toCommonJS(config_exports));
7400
+ const config2 = loadConfig2();
7401
+ const baseIdeType = ideType.split("_")[0];
7402
+ const val = config2.ideSettings?.[baseIdeType]?.extensions?.[extensionType]?.enabled;
7403
+ return val === true;
7404
+ }
7405
+ /**
7543
7406
  * Save IDE extension enabled setting
7544
7407
  */
7545
7408
  setIdeExtensionEnabled(ideType, extensionType, enabled) {
@@ -7737,14 +7600,14 @@ var init_provider_loader = __esm({
7737
7600
  this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
7738
7601
  return null;
7739
7602
  }
7740
- const dir = path7.join(providerDir, scriptDir);
7603
+ const dir = path6.join(providerDir, scriptDir);
7741
7604
  if (!fs5.existsSync(dir)) {
7742
7605
  this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
7743
7606
  return null;
7744
7607
  }
7745
7608
  const cached2 = this.scriptsCache.get(dir);
7746
7609
  if (cached2) return cached2;
7747
- const scriptsJs = path7.join(dir, "scripts.js");
7610
+ const scriptsJs = path6.join(dir, "scripts.js");
7748
7611
  if (fs5.existsSync(scriptsJs)) {
7749
7612
  try {
7750
7613
  delete require.cache[require.resolve(scriptsJs)];
@@ -7783,7 +7646,7 @@ var init_provider_loader = __esm({
7783
7646
  });
7784
7647
  const handleChange = (filePath) => {
7785
7648
  if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
7786
- this.log(`File changed: ${path7.basename(filePath)}, reloading...`);
7649
+ this.log(`File changed: ${path6.basename(filePath)}, reloading...`);
7787
7650
  this.reload();
7788
7651
  }
7789
7652
  };
@@ -7838,7 +7701,7 @@ var init_provider_loader = __esm({
7838
7701
  }
7839
7702
  const https = require("https");
7840
7703
  const { execSync: execSync6 } = require("child_process");
7841
- const metaPath = path7.join(this.upstreamDir, _ProviderLoader.META_FILE);
7704
+ const metaPath = path6.join(this.upstreamDir, _ProviderLoader.META_FILE);
7842
7705
  let prevEtag = "";
7843
7706
  let prevTimestamp = 0;
7844
7707
  try {
@@ -7855,7 +7718,7 @@ var init_provider_loader = __esm({
7855
7718
  return { updated: false };
7856
7719
  }
7857
7720
  try {
7858
- const etag = await new Promise((resolve13, reject) => {
7721
+ const etag = await new Promise((resolve12, reject) => {
7859
7722
  const options = {
7860
7723
  method: "HEAD",
7861
7724
  hostname: "github.com",
@@ -7873,7 +7736,7 @@ var init_provider_loader = __esm({
7873
7736
  headers: { "User-Agent": "adhdev-launcher" },
7874
7737
  timeout: 1e4
7875
7738
  }, (res2) => {
7876
- resolve13(res2.headers.etag || res2.headers["last-modified"] || "");
7739
+ resolve12(res2.headers.etag || res2.headers["last-modified"] || "");
7877
7740
  });
7878
7741
  req2.on("error", reject);
7879
7742
  req2.on("timeout", () => {
@@ -7882,7 +7745,7 @@ var init_provider_loader = __esm({
7882
7745
  });
7883
7746
  req2.end();
7884
7747
  } else {
7885
- resolve13(res.headers.etag || res.headers["last-modified"] || "");
7748
+ resolve12(res.headers.etag || res.headers["last-modified"] || "");
7886
7749
  }
7887
7750
  });
7888
7751
  req.on("error", reject);
@@ -7898,17 +7761,17 @@ var init_provider_loader = __esm({
7898
7761
  return { updated: false };
7899
7762
  }
7900
7763
  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()}`);
7764
+ const tmpTar = path6.join(os7.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
7765
+ const tmpExtract = path6.join(os7.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
7903
7766
  await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
7904
7767
  fs5.mkdirSync(tmpExtract, { recursive: true });
7905
7768
  execSync6(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
7906
7769
  const extracted = fs5.readdirSync(tmpExtract);
7907
7770
  const rootDir = extracted.find(
7908
- (d) => fs5.statSync(path7.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
7771
+ (d) => fs5.statSync(path6.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
7909
7772
  );
7910
7773
  if (!rootDir) throw new Error("Unexpected tarball structure");
7911
- const sourceDir = path7.join(tmpExtract, rootDir);
7774
+ const sourceDir = path6.join(tmpExtract, rootDir);
7912
7775
  const backupDir = this.upstreamDir + ".bak";
7913
7776
  if (fs5.existsSync(this.upstreamDir)) {
7914
7777
  if (fs5.existsSync(backupDir)) fs5.rmSync(backupDir, { recursive: true, force: true });
@@ -7946,7 +7809,7 @@ var init_provider_loader = __esm({
7946
7809
  downloadFile(url2, destPath) {
7947
7810
  const https = require("https");
7948
7811
  const http3 = require("http");
7949
- return new Promise((resolve13, reject) => {
7812
+ return new Promise((resolve12, reject) => {
7950
7813
  const doRequest = (reqUrl, redirectCount = 0) => {
7951
7814
  if (redirectCount > 5) {
7952
7815
  reject(new Error("Too many redirects"));
@@ -7966,7 +7829,7 @@ var init_provider_loader = __esm({
7966
7829
  res.pipe(ws2);
7967
7830
  ws2.on("finish", () => {
7968
7831
  ws2.close();
7969
- resolve13();
7832
+ resolve12();
7970
7833
  });
7971
7834
  ws2.on("error", reject);
7972
7835
  });
@@ -7983,8 +7846,8 @@ var init_provider_loader = __esm({
7983
7846
  copyDirRecursive(src, dest) {
7984
7847
  fs5.mkdirSync(dest, { recursive: true });
7985
7848
  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);
7849
+ const srcPath = path6.join(src, entry.name);
7850
+ const destPath = path6.join(dest, entry.name);
7988
7851
  if (entry.isDirectory()) {
7989
7852
  this.copyDirRecursive(srcPath, destPath);
7990
7853
  } else {
@@ -7995,7 +7858,7 @@ var init_provider_loader = __esm({
7995
7858
  /** .meta.json save */
7996
7859
  writeMeta(metaPath, etag, timestamp) {
7997
7860
  try {
7998
- fs5.mkdirSync(path7.dirname(metaPath), { recursive: true });
7861
+ fs5.mkdirSync(path6.dirname(metaPath), { recursive: true });
7999
7862
  fs5.writeFileSync(metaPath, JSON.stringify({
8000
7863
  etag,
8001
7864
  timestamp,
@@ -8012,7 +7875,7 @@ var init_provider_loader = __esm({
8012
7875
  const scan = (d) => {
8013
7876
  try {
8014
7877
  for (const entry of fs5.readdirSync(d, { withFileTypes: true })) {
8015
- if (entry.isDirectory()) scan(path7.join(d, entry.name));
7878
+ if (entry.isDirectory()) scan(path6.join(d, entry.name));
8016
7879
  else if (entry.name === "provider.json") count++;
8017
7880
  }
8018
7881
  } catch {
@@ -8111,17 +7974,17 @@ var init_provider_loader = __esm({
8111
7974
  for (const root of searchRoots) {
8112
7975
  if (!fs5.existsSync(root)) continue;
8113
7976
  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);
7977
+ if (fs5.existsSync(path6.join(candidate, "provider.json"))) return candidate;
7978
+ const catDir = path6.join(root, cat);
8116
7979
  if (fs5.existsSync(catDir)) {
8117
7980
  try {
8118
7981
  for (const entry of fs5.readdirSync(catDir, { withFileTypes: true })) {
8119
7982
  if (!entry.isDirectory()) continue;
8120
- const jsonPath = path7.join(catDir, entry.name, "provider.json");
7983
+ const jsonPath = path6.join(catDir, entry.name, "provider.json");
8121
7984
  if (fs5.existsSync(jsonPath)) {
8122
7985
  try {
8123
7986
  const data = JSON.parse(fs5.readFileSync(jsonPath, "utf-8"));
8124
- if (data.type === type) return path7.join(catDir, entry.name);
7987
+ if (data.type === type) return path6.join(catDir, entry.name);
8125
7988
  } catch {
8126
7989
  }
8127
7990
  }
@@ -8138,7 +8001,7 @@ var init_provider_loader = __esm({
8138
8001
  * (template substitution is NOT applied here — scripts.js handles that)
8139
8002
  */
8140
8003
  buildScriptWrappersFromDir(dir) {
8141
- const scriptsJs = path7.join(dir, "scripts.js");
8004
+ const scriptsJs = path6.join(dir, "scripts.js");
8142
8005
  if (fs5.existsSync(scriptsJs)) {
8143
8006
  try {
8144
8007
  delete require.cache[require.resolve(scriptsJs)];
@@ -8152,7 +8015,7 @@ var init_provider_loader = __esm({
8152
8015
  for (const file2 of fs5.readdirSync(dir)) {
8153
8016
  if (!file2.endsWith(".js")) continue;
8154
8017
  const scriptName = toCamel(file2.replace(".js", ""));
8155
- const filePath = path7.join(dir, file2);
8018
+ const filePath = path6.join(dir, file2);
8156
8019
  result[scriptName] = (...args) => {
8157
8020
  try {
8158
8021
  let content = fs5.readFileSync(filePath, "utf-8");
@@ -8212,7 +8075,7 @@ var init_provider_loader = __esm({
8212
8075
  }
8213
8076
  const hasJson = entries.some((e) => e.name === "provider.json");
8214
8077
  if (hasJson) {
8215
- const jsonPath = path7.join(d, "provider.json");
8078
+ const jsonPath = path6.join(d, "provider.json");
8216
8079
  try {
8217
8080
  const raw = fs5.readFileSync(jsonPath, "utf-8");
8218
8081
  const mod = JSON.parse(raw);
@@ -8225,7 +8088,7 @@ var init_provider_loader = __esm({
8225
8088
  delete mod.extensionIdPattern_flags;
8226
8089
  }
8227
8090
  const hasCompatibility = Array.isArray(mod.compatibility);
8228
- const scriptsPath = path7.join(d, "scripts.js");
8091
+ const scriptsPath = path6.join(d, "scripts.js");
8229
8092
  if (!hasCompatibility && fs5.existsSync(scriptsPath)) {
8230
8093
  try {
8231
8094
  delete require.cache[require.resolve(scriptsPath)];
@@ -8251,7 +8114,7 @@ var init_provider_loader = __esm({
8251
8114
  if (!entry.isDirectory()) continue;
8252
8115
  if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
8253
8116
  if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
8254
- scan(path7.join(d, entry.name));
8117
+ scan(path6.join(d, entry.name));
8255
8118
  }
8256
8119
  }
8257
8120
  };
@@ -8332,17 +8195,17 @@ async function findFreePort(ports) {
8332
8195
  throw new Error("No free port found");
8333
8196
  }
8334
8197
  function checkPortFree(port) {
8335
- return new Promise((resolve13) => {
8198
+ return new Promise((resolve12) => {
8336
8199
  const server = net.createServer();
8337
8200
  server.unref();
8338
- server.on("error", () => resolve13(false));
8201
+ server.on("error", () => resolve12(false));
8339
8202
  server.listen(port, "127.0.0.1", () => {
8340
- server.close(() => resolve13(true));
8203
+ server.close(() => resolve12(true));
8341
8204
  });
8342
8205
  });
8343
8206
  }
8344
8207
  async function isCdpActive(port) {
8345
- return new Promise((resolve13) => {
8208
+ return new Promise((resolve12) => {
8346
8209
  const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
8347
8210
  timeout: 2e3
8348
8211
  }, (res) => {
@@ -8351,16 +8214,16 @@ async function isCdpActive(port) {
8351
8214
  res.on("end", () => {
8352
8215
  try {
8353
8216
  const info = JSON.parse(data);
8354
- resolve13(!!info["WebKit-Version"] || !!info["Browser"]);
8217
+ resolve12(!!info["WebKit-Version"] || !!info["Browser"]);
8355
8218
  } catch {
8356
- resolve13(false);
8219
+ resolve12(false);
8357
8220
  }
8358
8221
  });
8359
8222
  });
8360
- req.on("error", () => resolve13(false));
8223
+ req.on("error", () => resolve12(false));
8361
8224
  req.on("timeout", () => {
8362
8225
  req.destroy();
8363
- resolve13(false);
8226
+ resolve12(false);
8364
8227
  });
8365
8228
  });
8366
8229
  }
@@ -8479,8 +8342,8 @@ function detectCurrentWorkspace(ideId) {
8479
8342
  const appNameMap = getMacAppIdentifiers();
8480
8343
  const appName = appNameMap[ideId];
8481
8344
  if (appName) {
8482
- const storagePath = path8.join(
8483
- process.env.APPDATA || path8.join(os8.homedir(), "AppData", "Roaming"),
8345
+ const storagePath = path7.join(
8346
+ process.env.APPDATA || path7.join(os8.homedir(), "AppData", "Roaming"),
8484
8347
  appName,
8485
8348
  "storage.json"
8486
8349
  );
@@ -8643,14 +8506,14 @@ async function launchLinux(ide, port, workspace, newWindow) {
8643
8506
  if (workspace) args.push(workspace);
8644
8507
  (0, import_child_process4.spawn)(cli, args, { detached: true, stdio: "ignore" }).unref();
8645
8508
  }
8646
- var import_child_process4, net, os8, path8, _providerLoader;
8509
+ var import_child_process4, net, os8, path7, _providerLoader;
8647
8510
  var init_launch = __esm({
8648
8511
  "../../oss/packages/daemon-core/src/launch.ts"() {
8649
8512
  "use strict";
8650
8513
  import_child_process4 = require("child_process");
8651
8514
  net = __toESM(require("net"));
8652
8515
  os8 = __toESM(require("os"));
8653
- path8 = __toESM(require("path"));
8516
+ path7 = __toESM(require("path"));
8654
8517
  init_ide_detector();
8655
8518
  init_provider_loader();
8656
8519
  _providerLoader = null;
@@ -8681,7 +8544,7 @@ function checkRotation() {
8681
8544
  const today = getDateStr2();
8682
8545
  if (today !== currentDate2) {
8683
8546
  currentDate2 = today;
8684
- currentFile = path9.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
8547
+ currentFile = path8.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
8685
8548
  cleanOldFiles();
8686
8549
  }
8687
8550
  }
@@ -8695,7 +8558,7 @@ function cleanOldFiles() {
8695
8558
  const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
8696
8559
  if (dateMatch && dateMatch[1] < cutoffStr) {
8697
8560
  try {
8698
- fs6.unlinkSync(path9.join(LOG_DIR2, file2));
8561
+ fs6.unlinkSync(path8.join(LOG_DIR2, file2));
8699
8562
  } catch {
8700
8563
  }
8701
8564
  }
@@ -8737,14 +8600,14 @@ function logCommand(entry) {
8737
8600
  } catch {
8738
8601
  }
8739
8602
  }
8740
- var fs6, path9, os9, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
8603
+ var fs6, path8, os9, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
8741
8604
  var init_command_log = __esm({
8742
8605
  "../../oss/packages/daemon-core/src/logging/command-log.ts"() {
8743
8606
  "use strict";
8744
8607
  fs6 = __toESM(require("fs"));
8745
- path9 = __toESM(require("path"));
8608
+ path8 = __toESM(require("path"));
8746
8609
  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");
8610
+ 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
8611
  MAX_FILE_SIZE = 5 * 1024 * 1024;
8749
8612
  MAX_DAYS = 7;
8750
8613
  try {
@@ -8763,7 +8626,7 @@ var init_command_log = __esm({
8763
8626
  "text"
8764
8627
  ]);
8765
8628
  currentDate2 = getDateStr2();
8766
- currentFile = path9.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
8629
+ currentFile = path8.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
8767
8630
  writeCount2 = 0;
8768
8631
  SKIP_COMMANDS = /* @__PURE__ */ new Set([
8769
8632
  "heartbeat",
@@ -8783,8 +8646,6 @@ var init_router = __esm({
8783
8646
  init_launch();
8784
8647
  init_config();
8785
8648
  init_workspaces();
8786
- init_workspace_activity();
8787
- init_config();
8788
8649
  init_recent_activity();
8789
8650
  init_ide_detector();
8790
8651
  init_logger();
@@ -8916,18 +8777,6 @@ var init_router = __esm({
8916
8777
  };
8917
8778
  LOG.info("LaunchIDE", `target=${ideKey || "auto"}`);
8918
8779
  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
8780
  if (result.success && result.port && result.ideId && !this.deps.cdpManagers.has(result.ideId)) {
8932
8781
  const logFn = this.deps.getCdpLogFn ? this.deps.getCdpLogFn(result.ideId) : LOG.forComponent(`CDP:${result.ideId}`).asLogFn();
8933
8782
  const provider = this.deps.providerLoader.getMeta(result.ideId);
@@ -8944,11 +8793,7 @@ var init_router = __esm({
8944
8793
  this.deps.onIdeConnected?.();
8945
8794
  if (result.success && resolvedWorkspace) {
8946
8795
  try {
8947
- let next = appendWorkspaceActivity(loadConfig(), resolvedWorkspace, {
8948
- kind: "ide",
8949
- agentType: result.ideId
8950
- });
8951
- next = appendRecentActivity(next, {
8796
+ const next = appendRecentActivity(loadConfig(), {
8952
8797
  kind: "ide",
8953
8798
  providerType: result.ideId || ideKey,
8954
8799
  providerName: result.ideId || ideKey,
@@ -9026,9 +8871,9 @@ var init_router = __esm({
9026
8871
  setTimeout(() => {
9027
8872
  LOG.info("Upgrade", "Restarting daemon with new version...");
9028
8873
  try {
9029
- const path19 = require("path");
8874
+ const path18 = require("path");
9030
8875
  const fs16 = require("fs");
9031
- const pidFile = path19.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
8876
+ const pidFile = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
9032
8877
  if (fs16.existsSync(pidFile)) fs16.unlinkSync(pidFile);
9033
8878
  } catch {
9034
8879
  }
@@ -18515,7 +18360,9 @@ function getUnreadState(hasContentChange, status, lastUsedAt, lastSeenAt, lastRo
18515
18360
  return { unread, inboxBucket: unread ? "task_complete" : "idle" };
18516
18361
  }
18517
18362
  function buildRecentSessions(sessions, recentActivity, readState) {
18518
- const live = sessions.filter((session) => !session.parentId && session.status !== "stopped").map((session) => {
18363
+ const visibleKeys = /* @__PURE__ */ new Set();
18364
+ const hiddenKeys = /* @__PURE__ */ new Set();
18365
+ const live = sessions.filter((session) => !session.surfaceHidden && session.status !== "stopped").map((session) => {
18519
18366
  const kind = getSessionKind(session);
18520
18367
  const recentKey = buildRecentActivityKey({
18521
18368
  kind,
@@ -18545,11 +18392,21 @@ function buildRecentSessions(sessions, recentActivity, readState) {
18545
18392
  lastUsedAt,
18546
18393
  unread,
18547
18394
  lastSeenAt,
18548
- inboxBucket
18395
+ inboxBucket,
18396
+ surfaceHidden: false
18549
18397
  };
18550
18398
  });
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) => {
18399
+ for (const item of live) {
18400
+ visibleKeys.add(`${item.kind}:${item.providerType}:${item.workspace || ""}`);
18401
+ }
18402
+ for (const session of sessions) {
18403
+ if (!session.surfaceHidden) continue;
18404
+ hiddenKeys.add(`${getSessionKind(session)}:${session.providerType}:${session.workspace || ""}`);
18405
+ }
18406
+ const persisted = recentActivity.filter((item) => {
18407
+ const key = `${item.kind}:${item.providerType}:${item.workspace || ""}`;
18408
+ return !visibleKeys.has(key) && !hiddenKeys.has(key);
18409
+ }).map((item) => {
18553
18410
  const lastSeenAt = readState[item.id] || 0;
18554
18411
  const unread = item.lastUsedAt > lastSeenAt;
18555
18412
  return {
@@ -18565,7 +18422,8 @@ function buildRecentSessions(sessions, recentActivity, readState) {
18565
18422
  lastUsedAt: item.lastUsedAt,
18566
18423
  unread,
18567
18424
  lastSeenAt,
18568
- inboxBucket: unread ? "task_complete" : "idle"
18425
+ inboxBucket: unread ? "task_complete" : "idle",
18426
+ surfaceHidden: false
18569
18427
  };
18570
18428
  });
18571
18429
  return [...live, ...persisted].sort((a, b2) => b2.lastUsedAt - a.lastUsedAt).slice(0, 12);
@@ -18589,7 +18447,7 @@ function buildStatusSnapshot(options) {
18589
18447
  });
18590
18448
  const lastSeenAt = getRecentSessionSeenAt(cfg, recentKey);
18591
18449
  const lastUsedAt = getSessionLastUsedAt(session);
18592
- const { unread, inboxBucket } = getUnreadState(
18450
+ const { unread, inboxBucket } = session.surfaceHidden ? { unread: false, inboxBucket: "idle" } : getUnreadState(
18593
18451
  getSessionMessageUpdatedAt(session) > 0,
18594
18452
  session.status,
18595
18453
  lastUsedAt,
@@ -18626,7 +18484,6 @@ function buildStatusSnapshot(options) {
18626
18484
  workspaces: wsState.workspaces,
18627
18485
  defaultWorkspaceId: wsState.defaultWorkspaceId,
18628
18486
  defaultWorkspacePath: wsState.defaultWorkspacePath,
18629
- workspaceActivity: getWorkspaceActivity(cfg, 15),
18630
18487
  recentSessions: buildRecentSessions(sessions, recentActivity, readState),
18631
18488
  terminalBackend,
18632
18489
  availableProviders: buildAvailableProviders(options.providerLoader)
@@ -18640,7 +18497,6 @@ var init_snapshot = __esm({
18640
18497
  init_config();
18641
18498
  init_recent_activity();
18642
18499
  init_workspaces();
18643
- init_workspace_activity();
18644
18500
  init_host_memory();
18645
18501
  init_terminal_screen();
18646
18502
  init_builders();
@@ -18806,6 +18662,7 @@ var init_reporter = __esm({
18806
18662
  unread: session.unread,
18807
18663
  lastSeenAt: session.lastSeenAt,
18808
18664
  inboxBucket: session.inboxBucket,
18665
+ surfaceHidden: session.surfaceHidden,
18809
18666
  controlValues: session.controlValues,
18810
18667
  providerControls: session.providerControls,
18811
18668
  acpConfigOptions: session.acpConfigOptions,
@@ -18923,7 +18780,7 @@ function findBinary(name) {
18923
18780
  }
18924
18781
  }
18925
18782
  function isScriptBinary(binaryPath) {
18926
- if (!path10.isAbsolute(binaryPath)) return false;
18783
+ if (!path9.isAbsolute(binaryPath)) return false;
18927
18784
  try {
18928
18785
  const fs16 = require("fs");
18929
18786
  const resolved = fs16.realpathSync(binaryPath);
@@ -18939,7 +18796,7 @@ function isScriptBinary(binaryPath) {
18939
18796
  }
18940
18797
  }
18941
18798
  function looksLikeMachOOrElf(filePath) {
18942
- if (!path10.isAbsolute(filePath)) return false;
18799
+ if (!path9.isAbsolute(filePath)) return false;
18943
18800
  try {
18944
18801
  const fs16 = require("fs");
18945
18802
  const resolved = fs16.realpathSync(filePath);
@@ -19053,12 +18910,12 @@ function normalizeCliProviderForRuntime(raw) {
19053
18910
  }
19054
18911
  };
19055
18912
  }
19056
- var os13, path10, import_child_process5, pty2, ProviderCliAdapter;
18913
+ var os13, path9, import_child_process5, pty2, ProviderCliAdapter;
19057
18914
  var init_provider_cli_adapter = __esm({
19058
18915
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
19059
18916
  "use strict";
19060
18917
  os13 = __toESM(require("os"));
19061
- path10 = __toESM(require("path"));
18918
+ path9 = __toESM(require("path"));
19062
18919
  import_child_process5 = require("child_process");
19063
18920
  init_logger();
19064
18921
  init_terminal_screen();
@@ -19068,9 +18925,9 @@ var init_provider_cli_adapter = __esm({
19068
18925
  if (os13.platform() !== "win32") {
19069
18926
  try {
19070
18927
  const fs16 = require("fs");
19071
- const ptyDir = path10.resolve(path10.dirname(require.resolve("node-pty")), "..");
18928
+ const ptyDir = path9.resolve(path9.dirname(require.resolve("node-pty")), "..");
19072
18929
  const platformArch = `${os13.platform()}-${os13.arch()}`;
19073
- const helper = path10.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
18930
+ const helper = path9.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
19074
18931
  if (fs16.existsSync(helper)) {
19075
18932
  const stat4 = fs16.statSync(helper);
19076
18933
  if (!(stat4.mode & 73)) {
@@ -19259,7 +19116,7 @@ var init_provider_cli_adapter = __esm({
19259
19116
  LOG.info("CLI", `[${this.cliType}] Spawning in ${this.workingDir}`);
19260
19117
  let shellCmd;
19261
19118
  let shellArgs;
19262
- const useShellUnix = !isWin && (!!spawnConfig.shell || !path10.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
19119
+ const useShellUnix = !isWin && (!!spawnConfig.shell || !path9.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
19263
19120
  const useShell = isWin ? !!spawnConfig.shell : useShellUnix;
19264
19121
  if (useShell) {
19265
19122
  if (!spawnConfig.shell && !isWin) {
@@ -19684,7 +19541,7 @@ ${data.message || ""}`.trim();
19684
19541
  if (this.startupParseGate) {
19685
19542
  const deadline = Date.now() + 1e4;
19686
19543
  while (this.startupParseGate && Date.now() < deadline) {
19687
- await new Promise((resolve13) => setTimeout(resolve13, 50));
19544
+ await new Promise((resolve12) => setTimeout(resolve12, 50));
19688
19545
  }
19689
19546
  }
19690
19547
  if (!this.ready) throw new Error(`${this.cliName} not ready (status: ${this.currentStatus})`);
@@ -19852,17 +19709,17 @@ ${data.message || ""}`.trim();
19852
19709
  }
19853
19710
  }
19854
19711
  waitForStopped(timeoutMs) {
19855
- return new Promise((resolve13) => {
19712
+ return new Promise((resolve12) => {
19856
19713
  const startedAt = Date.now();
19857
19714
  const timer = setInterval(() => {
19858
19715
  if (!this.ptyProcess || this.currentStatus === "stopped") {
19859
19716
  clearInterval(timer);
19860
- resolve13(true);
19717
+ resolve12(true);
19861
19718
  return;
19862
19719
  }
19863
19720
  if (Date.now() - startedAt >= timeoutMs) {
19864
19721
  clearInterval(timer);
19865
- resolve13(false);
19722
+ resolve12(false);
19866
19723
  }
19867
19724
  }, 100);
19868
19725
  });
@@ -20551,10 +20408,10 @@ function mergeDefs(...defs) {
20551
20408
  function cloneDef(schema) {
20552
20409
  return mergeDefs(schema._zod.def);
20553
20410
  }
20554
- function getElementAtPath(obj, path19) {
20555
- if (!path19)
20411
+ function getElementAtPath(obj, path18) {
20412
+ if (!path18)
20556
20413
  return obj;
20557
- return path19.reduce((acc, key) => acc?.[key], obj);
20414
+ return path18.reduce((acc, key) => acc?.[key], obj);
20558
20415
  }
20559
20416
  function promiseAllObject(promisesObj) {
20560
20417
  const keys = Object.keys(promisesObj);
@@ -20866,11 +20723,11 @@ function aborted(x, startIndex = 0) {
20866
20723
  }
20867
20724
  return false;
20868
20725
  }
20869
- function prefixIssues(path19, issues) {
20726
+ function prefixIssues(path18, issues) {
20870
20727
  return issues.map((iss) => {
20871
20728
  var _a2;
20872
20729
  (_a2 = iss).path ?? (_a2.path = []);
20873
- iss.path.unshift(path19);
20730
+ iss.path.unshift(path18);
20874
20731
  return iss;
20875
20732
  });
20876
20733
  }
@@ -21113,7 +20970,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
21113
20970
  }
21114
20971
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
21115
20972
  const result = { errors: [] };
21116
- const processError = (error49, path19 = []) => {
20973
+ const processError = (error49, path18 = []) => {
21117
20974
  var _a2, _b;
21118
20975
  for (const issue2 of error49.issues) {
21119
20976
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -21123,7 +20980,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
21123
20980
  } else if (issue2.code === "invalid_element") {
21124
20981
  processError({ issues: issue2.issues }, issue2.path);
21125
20982
  } else {
21126
- const fullpath = [...path19, ...issue2.path];
20983
+ const fullpath = [...path18, ...issue2.path];
21127
20984
  if (fullpath.length === 0) {
21128
20985
  result.errors.push(mapper(issue2));
21129
20986
  continue;
@@ -21155,8 +21012,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
21155
21012
  }
21156
21013
  function toDotPath(_path) {
21157
21014
  const segs = [];
21158
- const path19 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
21159
- for (const seg of path19) {
21015
+ const path18 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
21016
+ for (const seg of path18) {
21160
21017
  if (typeof seg === "number")
21161
21018
  segs.push(`[${seg}]`);
21162
21019
  else if (typeof seg === "symbol")
@@ -33920,13 +33777,13 @@ function resolveRef(ref, ctx) {
33920
33777
  if (!ref.startsWith("#")) {
33921
33778
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
33922
33779
  }
33923
- const path19 = ref.slice(1).split("/").filter(Boolean);
33924
- if (path19.length === 0) {
33780
+ const path18 = ref.slice(1).split("/").filter(Boolean);
33781
+ if (path18.length === 0) {
33925
33782
  return ctx.rootSchema;
33926
33783
  }
33927
33784
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
33928
- if (path19[0] === defsKey) {
33929
- const key = path19[1];
33785
+ if (path18[0] === defsKey) {
33786
+ const key = path18[1];
33930
33787
  if (!key || !ctx.defs[key]) {
33931
33788
  throw new Error(`Reference not found: ${ref}`);
33932
33789
  }
@@ -36353,8 +36210,8 @@ var init_acp = __esm({
36353
36210
  this.#requestHandler = requestHandler;
36354
36211
  this.#notificationHandler = notificationHandler;
36355
36212
  this.#stream = stream;
36356
- this.#closedPromise = new Promise((resolve13) => {
36357
- this.#abortController.signal.addEventListener("abort", () => resolve13());
36213
+ this.#closedPromise = new Promise((resolve12) => {
36214
+ this.#abortController.signal.addEventListener("abort", () => resolve12());
36358
36215
  });
36359
36216
  this.#receive();
36360
36217
  }
@@ -36503,8 +36360,8 @@ var init_acp = __esm({
36503
36360
  }
36504
36361
  async sendRequest(method, params) {
36505
36362
  const id = this.#nextRequestId++;
36506
- const responsePromise = new Promise((resolve13, reject) => {
36507
- this.#pendingResponses.set(id, { resolve: resolve13, reject });
36363
+ const responsePromise = new Promise((resolve12, reject) => {
36364
+ this.#pendingResponses.set(id, { resolve: resolve12, reject });
36508
36365
  });
36509
36366
  await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
36510
36367
  return responsePromise;
@@ -37044,13 +36901,13 @@ var init_acp_provider_instance = __esm({
37044
36901
  }
37045
36902
  this.currentStatus = "waiting_approval";
37046
36903
  this.detectStatusTransition();
37047
- const approved = await new Promise((resolve13) => {
37048
- this.permissionResolvers.push(resolve13);
36904
+ const approved = await new Promise((resolve12) => {
36905
+ this.permissionResolvers.push(resolve12);
37049
36906
  setTimeout(() => {
37050
- const idx = this.permissionResolvers.indexOf(resolve13);
36907
+ const idx = this.permissionResolvers.indexOf(resolve12);
37051
36908
  if (idx >= 0) {
37052
36909
  this.permissionResolvers.splice(idx, 1);
37053
- resolve13(false);
36910
+ resolve12(false);
37054
36911
  }
37055
36912
  }, 3e5);
37056
36913
  });
@@ -37512,19 +37369,18 @@ function colorize(color, text) {
37512
37369
  const fn2 = chalkApi?.[color];
37513
37370
  return typeof fn2 === "function" ? fn2(text) : text;
37514
37371
  }
37515
- var os14, path11, crypto4, import_chalk, chalkApi, DaemonCliManager;
37372
+ var os14, path10, crypto4, import_chalk, chalkApi, DaemonCliManager;
37516
37373
  var init_cli_manager = __esm({
37517
37374
  "../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
37518
37375
  "use strict";
37519
37376
  os14 = __toESM(require("os"));
37520
- path11 = __toESM(require("path"));
37377
+ path10 = __toESM(require("path"));
37521
37378
  crypto4 = __toESM(require("crypto"));
37522
37379
  import_chalk = __toESM(require("chalk"));
37523
37380
  init_provider_cli_adapter();
37524
37381
  init_cli_detector();
37525
37382
  init_config();
37526
37383
  init_workspaces();
37527
- init_workspace_activity();
37528
37384
  init_recent_activity();
37529
37385
  init_cli_provider_instance();
37530
37386
  init_acp_provider_instance();
@@ -37543,24 +37399,6 @@ var init_cli_manager = __esm({
37543
37399
  const hash2 = require("crypto").createHash("md5").update(require("path").resolve(dir)).digest("hex").slice(0, 8);
37544
37400
  return `${cliType}_${hash2}`;
37545
37401
  }
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
37402
  persistRecentActivity(entry) {
37565
37403
  try {
37566
37404
  saveConfig(appendRecentActivity(loadConfig(), entry));
@@ -37650,7 +37488,7 @@ var init_cli_manager = __esm({
37650
37488
  async startSession(cliType, workingDir, cliArgs, initialModel) {
37651
37489
  const trimmed = (workingDir || "").trim();
37652
37490
  if (!trimmed) throw new Error("working directory required");
37653
- const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os14.homedir()) : path11.resolve(trimmed);
37491
+ const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os14.homedir()) : path10.resolve(trimmed);
37654
37492
  const normalizedType = this.providerLoader.resolveAlias(cliType);
37655
37493
  const provider = this.providerLoader.getByAlias(cliType);
37656
37494
  const key = crypto4.randomUUID();
@@ -37721,11 +37559,6 @@ ${installInfo}`
37721
37559
  LOG.warn("CLI", `[ACP] Initial model set failed: ${e?.message}`);
37722
37560
  }
37723
37561
  }
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
37562
  this.persistRecentActivity({
37730
37563
  kind: "acp",
37731
37564
  providerType: normalizedType,
@@ -37792,11 +37625,6 @@ ${installInfo}`
37792
37625
  this.adapters.set(key, adapter);
37793
37626
  console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
37794
37627
  }
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
37628
  this.persistRecentActivity({
37801
37629
  kind: "cli",
37802
37630
  providerType: normalizedType,
@@ -37949,7 +37777,6 @@ ${installInfo}`
37949
37777
  newKey = k;
37950
37778
  }
37951
37779
  }
37952
- this.persistRecentDir(cliType, dir);
37953
37780
  return { success: true, cliType, dir, id: newKey, launchSource };
37954
37781
  }
37955
37782
  case "stop_cli": {
@@ -37992,7 +37819,6 @@ ${installInfo}`
37992
37819
  const found = this.findAdapter(cliType, { instanceKey: args?.targetSessionId, dir });
37993
37820
  if (found) await this.stopSession(found.key);
37994
37821
  await this.startSession(cliType, dir);
37995
- this.persistRecentDir(cliType, dir);
37996
37822
  return { success: true, restarted: true };
37997
37823
  }
37998
37824
  case "agent_command": {
@@ -38905,7 +38731,7 @@ function checkPathExists2(paths) {
38905
38731
  for (const p of paths) {
38906
38732
  if (p.includes("*")) {
38907
38733
  const home = os15.homedir();
38908
- const resolved = p.replace(/\*/g, home.split(path12.sep).pop() || "");
38734
+ const resolved = p.replace(/\*/g, home.split(path11.sep).pop() || "");
38909
38735
  if (fs9.existsSync(resolved)) return resolved;
38910
38736
  } else {
38911
38737
  if (fs9.existsSync(p)) return p;
@@ -38915,7 +38741,7 @@ function checkPathExists2(paths) {
38915
38741
  }
38916
38742
  function getMacAppVersion(appPath) {
38917
38743
  if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
38918
- const plistPath = path12.join(appPath, "Contents", "Info.plist");
38744
+ const plistPath = path11.join(appPath, "Contents", "Info.plist");
38919
38745
  if (!fs9.existsSync(plistPath)) return null;
38920
38746
  const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
38921
38747
  return raw || null;
@@ -38942,7 +38768,7 @@ async function detectAllVersions(loader, archive) {
38942
38768
  const cliBin = provider.cli ? findBinary2(provider.cli) : null;
38943
38769
  let resolvedBin = cliBin;
38944
38770
  if (!resolvedBin && appPath && currentOs === "darwin") {
38945
- const bundled = path12.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
38771
+ const bundled = path11.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
38946
38772
  if (provider.cli && fs9.existsSync(bundled)) resolvedBin = bundled;
38947
38773
  }
38948
38774
  info.installed = !!(appPath || resolvedBin);
@@ -38979,16 +38805,16 @@ async function detectAllVersions(loader, archive) {
38979
38805
  }
38980
38806
  return results;
38981
38807
  }
38982
- var fs9, path12, os15, import_child_process7, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
38808
+ var fs9, path11, os15, import_child_process7, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
38983
38809
  var init_version_archive = __esm({
38984
38810
  "../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
38985
38811
  "use strict";
38986
38812
  fs9 = __toESM(require("fs"));
38987
- path12 = __toESM(require("path"));
38813
+ path11 = __toESM(require("path"));
38988
38814
  os15 = __toESM(require("os"));
38989
38815
  import_child_process7 = require("child_process");
38990
38816
  import_os3 = require("os");
38991
- ARCHIVE_PATH = path12.join(os15.homedir(), ".adhdev", "version-history.json");
38817
+ ARCHIVE_PATH = path11.join(os15.homedir(), ".adhdev", "version-history.json");
38992
38818
  MAX_ENTRIES_PER_PROVIDER = 20;
38993
38819
  VersionArchive = class {
38994
38820
  history = {};
@@ -39035,7 +38861,7 @@ var init_version_archive = __esm({
39035
38861
  }
39036
38862
  save() {
39037
38863
  try {
39038
- fs9.mkdirSync(path12.dirname(ARCHIVE_PATH), { recursive: true });
38864
+ fs9.mkdirSync(path11.dirname(ARCHIVE_PATH), { recursive: true });
39039
38865
  fs9.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
39040
38866
  } catch {
39041
38867
  }
@@ -39556,17 +39382,17 @@ async function handleScriptHints(ctx, type, _req, res) {
39556
39382
  return;
39557
39383
  }
39558
39384
  let scriptsPath = "";
39559
- const directScripts = path13.join(dir, "scripts.js");
39385
+ const directScripts = path12.join(dir, "scripts.js");
39560
39386
  if (fs10.existsSync(directScripts)) {
39561
39387
  scriptsPath = directScripts;
39562
39388
  } else {
39563
- const scriptsDir = path13.join(dir, "scripts");
39389
+ const scriptsDir = path12.join(dir, "scripts");
39564
39390
  if (fs10.existsSync(scriptsDir)) {
39565
39391
  const versions = fs10.readdirSync(scriptsDir).filter((d) => {
39566
- return fs10.statSync(path13.join(scriptsDir, d)).isDirectory();
39392
+ return fs10.statSync(path12.join(scriptsDir, d)).isDirectory();
39567
39393
  }).sort().reverse();
39568
39394
  for (const ver of versions) {
39569
- const p = path13.join(scriptsDir, ver, "scripts.js");
39395
+ const p = path12.join(scriptsDir, ver, "scripts.js");
39570
39396
  if (fs10.existsSync(p)) {
39571
39397
  scriptsPath = p;
39572
39398
  break;
@@ -40382,12 +40208,12 @@ async function handleDomContext(ctx, type, req, res) {
40382
40208
  ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
40383
40209
  }
40384
40210
  }
40385
- var fs10, path13;
40211
+ var fs10, path12;
40386
40212
  var init_dev_cdp_handlers = __esm({
40387
40213
  "../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
40388
40214
  "use strict";
40389
40215
  fs10 = __toESM(require("fs"));
40390
- path13 = __toESM(require("path"));
40216
+ path12 = __toESM(require("path"));
40391
40217
  init_logger();
40392
40218
  }
40393
40219
  });
@@ -40652,22 +40478,22 @@ function getLatestScriptVersionDir(scriptsDir) {
40652
40478
  if (!fs11.existsSync(scriptsDir)) return null;
40653
40479
  const versions = fs11.readdirSync(scriptsDir).filter((d) => {
40654
40480
  try {
40655
- return fs11.statSync(path14.join(scriptsDir, d)).isDirectory();
40481
+ return fs11.statSync(path13.join(scriptsDir, d)).isDirectory();
40656
40482
  } catch {
40657
40483
  return false;
40658
40484
  }
40659
40485
  }).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
40660
40486
  if (versions.length === 0) return null;
40661
- return path14.join(scriptsDir, versions[0]);
40487
+ return path13.join(scriptsDir, versions[0]);
40662
40488
  }
40663
40489
  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}`)) {
40490
+ const canonicalUserDir = path13.resolve(ctx.providerLoader.getUserProviderDir(category, type));
40491
+ const desiredDir = requestedDir ? path13.resolve(requestedDir) : canonicalUserDir;
40492
+ const upstreamRoot = path13.resolve(ctx.providerLoader.getUpstreamDir());
40493
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path13.sep}`)) {
40668
40494
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
40669
40495
  }
40670
- if (path14.basename(desiredDir) !== type) {
40496
+ if (path13.basename(desiredDir) !== type) {
40671
40497
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
40672
40498
  }
40673
40499
  const sourceDir = ctx.findProviderDir(type);
@@ -40675,11 +40501,11 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
40675
40501
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
40676
40502
  }
40677
40503
  if (!fs11.existsSync(desiredDir)) {
40678
- fs11.mkdirSync(path14.dirname(desiredDir), { recursive: true });
40504
+ fs11.mkdirSync(path13.dirname(desiredDir), { recursive: true });
40679
40505
  fs11.cpSync(sourceDir, desiredDir, { recursive: true });
40680
40506
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
40681
40507
  }
40682
- const providerJson = path14.join(desiredDir, "provider.json");
40508
+ const providerJson = path13.join(desiredDir, "provider.json");
40683
40509
  if (!fs11.existsSync(providerJson)) {
40684
40510
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
40685
40511
  }
@@ -40702,13 +40528,13 @@ function loadAutoImplReferenceScripts(ctx, referenceType) {
40702
40528
  const refDir = ctx.findProviderDir(referenceType);
40703
40529
  if (!refDir || !fs11.existsSync(refDir)) return {};
40704
40530
  const referenceScripts = {};
40705
- const scriptsDir = path14.join(refDir, "scripts");
40531
+ const scriptsDir = path13.join(refDir, "scripts");
40706
40532
  const latestDir = getLatestScriptVersionDir(scriptsDir);
40707
40533
  if (!latestDir) return referenceScripts;
40708
40534
  for (const file2 of fs11.readdirSync(latestDir)) {
40709
40535
  if (!file2.endsWith(".js")) continue;
40710
40536
  try {
40711
- referenceScripts[file2] = fs11.readFileSync(path14.join(latestDir, file2), "utf-8");
40537
+ referenceScripts[file2] = fs11.readFileSync(path13.join(latestDir, file2), "utf-8");
40712
40538
  } catch {
40713
40539
  }
40714
40540
  }
@@ -40759,9 +40585,9 @@ async function handleAutoImplement(ctx, type, req, res) {
40759
40585
  });
40760
40586
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
40761
40587
  const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference);
40762
- const tmpDir = path14.join(os16.tmpdir(), "adhdev-autoimpl");
40588
+ const tmpDir = path13.join(os16.tmpdir(), "adhdev-autoimpl");
40763
40589
  if (!fs11.existsSync(tmpDir)) fs11.mkdirSync(tmpDir, { recursive: true });
40764
- const promptFile = path14.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
40590
+ const promptFile = path13.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
40765
40591
  fs11.writeFileSync(promptFile, prompt, "utf-8");
40766
40592
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
40767
40593
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
@@ -41132,7 +40958,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
41132
40958
  setMode: "set_mode.js"
41133
40959
  };
41134
40960
  const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
41135
- const scriptsDir = path14.join(providerDir, "scripts");
40961
+ const scriptsDir = path13.join(providerDir, "scripts");
41136
40962
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
41137
40963
  if (latestScriptsDir) {
41138
40964
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -41143,7 +40969,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
41143
40969
  for (const file2 of fs11.readdirSync(latestScriptsDir)) {
41144
40970
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
41145
40971
  try {
41146
- const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
40972
+ const content = fs11.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
41147
40973
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
41148
40974
  lines.push("```javascript");
41149
40975
  lines.push(content);
@@ -41160,7 +40986,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
41160
40986
  lines.push("");
41161
40987
  for (const file2 of refFiles) {
41162
40988
  try {
41163
- const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
40989
+ const content = fs11.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
41164
40990
  lines.push(`### \`${file2}\` \u{1F512}`);
41165
40991
  lines.push("```javascript");
41166
40992
  lines.push(content);
@@ -41201,10 +41027,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
41201
41027
  lines.push("");
41202
41028
  }
41203
41029
  }
41204
- const docsDir = path14.join(providerDir, "../../docs");
41030
+ const docsDir = path13.join(providerDir, "../../docs");
41205
41031
  const loadGuide = (name) => {
41206
41032
  try {
41207
- const p = path14.join(docsDir, name);
41033
+ const p = path13.join(docsDir, name);
41208
41034
  if (fs11.existsSync(p)) return fs11.readFileSync(p, "utf-8");
41209
41035
  } catch {
41210
41036
  }
@@ -41378,7 +41204,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
41378
41204
  parseApproval: "parse_approval.js"
41379
41205
  };
41380
41206
  const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
41381
- const scriptsDir = path14.join(providerDir, "scripts");
41207
+ const scriptsDir = path13.join(providerDir, "scripts");
41382
41208
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
41383
41209
  if (latestScriptsDir) {
41384
41210
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -41390,7 +41216,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
41390
41216
  if (!file2.endsWith(".js")) continue;
41391
41217
  if (!targetFileNames.has(file2)) continue;
41392
41218
  try {
41393
- const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
41219
+ const content = fs11.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
41394
41220
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
41395
41221
  lines.push("```javascript");
41396
41222
  lines.push(content);
@@ -41406,7 +41232,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
41406
41232
  lines.push("");
41407
41233
  for (const file2 of refFiles) {
41408
41234
  try {
41409
- const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
41235
+ const content = fs11.readFileSync(path13.join(latestScriptsDir, file2), "utf-8");
41410
41236
  lines.push(`### \`${file2}\` \u{1F512}`);
41411
41237
  lines.push("```javascript");
41412
41238
  lines.push(content);
@@ -41439,10 +41265,10 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
41439
41265
  lines.push("");
41440
41266
  }
41441
41267
  }
41442
- const docsDir = path14.join(providerDir, "../../docs");
41268
+ const docsDir = path13.join(providerDir, "../../docs");
41443
41269
  const loadGuide = (name) => {
41444
41270
  try {
41445
- const p = path14.join(docsDir, name);
41271
+ const p = path13.join(docsDir, name);
41446
41272
  if (fs11.existsSync(p)) return fs11.readFileSync(p, "utf-8");
41447
41273
  } catch {
41448
41274
  }
@@ -41606,25 +41432,25 @@ data: ${JSON.stringify(msg.data)}
41606
41432
  }
41607
41433
  }
41608
41434
  }
41609
- var fs11, path14, os16;
41435
+ var fs11, path13, os16;
41610
41436
  var init_dev_auto_implement = __esm({
41611
41437
  "../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
41612
41438
  "use strict";
41613
41439
  fs11 = __toESM(require("fs"));
41614
- path14 = __toESM(require("path"));
41440
+ path13 = __toESM(require("path"));
41615
41441
  os16 = __toESM(require("os"));
41616
41442
  init_dev_server();
41617
41443
  }
41618
41444
  });
41619
41445
 
41620
41446
  // ../../oss/packages/daemon-core/src/daemon/dev-server.ts
41621
- var http2, fs12, path15, DEV_SERVER_PORT, DevServer;
41447
+ var http2, fs12, path14, DEV_SERVER_PORT, DevServer;
41622
41448
  var init_dev_server = __esm({
41623
41449
  "../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
41624
41450
  "use strict";
41625
41451
  http2 = __toESM(require("http"));
41626
41452
  fs12 = __toESM(require("fs"));
41627
- path15 = __toESM(require("path"));
41453
+ path14 = __toESM(require("path"));
41628
41454
  init_scaffold_template();
41629
41455
  init_version_archive();
41630
41456
  init_logger();
@@ -41723,8 +41549,8 @@ var init_dev_server = __esm({
41723
41549
  }
41724
41550
  getEndpointList() {
41725
41551
  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}`;
41552
+ const path18 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
41553
+ return `${r.method.padEnd(5)} ${path18}`;
41728
41554
  });
41729
41555
  }
41730
41556
  async start(port = DEV_SERVER_PORT) {
@@ -41755,15 +41581,15 @@ var init_dev_server = __esm({
41755
41581
  this.json(res, 500, { error: e.message });
41756
41582
  }
41757
41583
  });
41758
- return new Promise((resolve13, reject) => {
41584
+ return new Promise((resolve12, reject) => {
41759
41585
  this.server.listen(port, "127.0.0.1", () => {
41760
41586
  this.log(`Dev server listening on http://127.0.0.1:${port}`);
41761
- resolve13();
41587
+ resolve12();
41762
41588
  });
41763
41589
  this.server.on("error", (e) => {
41764
41590
  if (e.code === "EADDRINUSE") {
41765
41591
  this.log(`Port ${port} in use, skipping dev server`);
41766
- resolve13();
41592
+ resolve12();
41767
41593
  } else {
41768
41594
  reject(e);
41769
41595
  }
@@ -41846,20 +41672,20 @@ var init_dev_server = __esm({
41846
41672
  child.stderr?.on("data", (d) => {
41847
41673
  stderr += d.toString().slice(0, 2e3);
41848
41674
  });
41849
- await new Promise((resolve13) => {
41675
+ await new Promise((resolve12) => {
41850
41676
  const timer = setTimeout(() => {
41851
41677
  child.kill();
41852
- resolve13();
41678
+ resolve12();
41853
41679
  }, 3e3);
41854
41680
  child.on("exit", () => {
41855
41681
  clearTimeout(timer);
41856
- resolve13();
41682
+ resolve12();
41857
41683
  });
41858
41684
  child.stdout?.once("data", () => {
41859
41685
  setTimeout(() => {
41860
41686
  child.kill();
41861
41687
  clearTimeout(timer);
41862
- resolve13();
41688
+ resolve12();
41863
41689
  }, 500);
41864
41690
  });
41865
41691
  });
@@ -42006,12 +41832,12 @@ var init_dev_server = __esm({
42006
41832
  // ─── DevConsole SPA ───
42007
41833
  getConsoleDistDir() {
42008
41834
  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")
41835
+ path14.resolve(__dirname, "../../web-devconsole/dist"),
41836
+ path14.resolve(__dirname, "../../../web-devconsole/dist"),
41837
+ path14.join(process.cwd(), "packages/web-devconsole/dist")
42012
41838
  ];
42013
41839
  for (const dir of candidates) {
42014
- if (fs12.existsSync(path15.join(dir, "index.html"))) return dir;
41840
+ if (fs12.existsSync(path14.join(dir, "index.html"))) return dir;
42015
41841
  }
42016
41842
  return null;
42017
41843
  }
@@ -42021,7 +41847,7 @@ var init_dev_server = __esm({
42021
41847
  this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
42022
41848
  return;
42023
41849
  }
42024
- const htmlPath = path15.join(distDir, "index.html");
41850
+ const htmlPath = path14.join(distDir, "index.html");
42025
41851
  try {
42026
41852
  const html = fs12.readFileSync(htmlPath, "utf-8");
42027
41853
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
@@ -42046,15 +41872,15 @@ var init_dev_server = __esm({
42046
41872
  this.json(res, 404, { error: "Not found" });
42047
41873
  return;
42048
41874
  }
42049
- const safePath = path15.normalize(pathname).replace(/^\.\.\//, "");
42050
- const filePath = path15.join(distDir, safePath);
41875
+ const safePath = path14.normalize(pathname).replace(/^\.\.\//, "");
41876
+ const filePath = path14.join(distDir, safePath);
42051
41877
  if (!filePath.startsWith(distDir)) {
42052
41878
  this.json(res, 403, { error: "Forbidden" });
42053
41879
  return;
42054
41880
  }
42055
41881
  try {
42056
41882
  const content = fs12.readFileSync(filePath);
42057
- const ext = path15.extname(filePath);
41883
+ const ext = path14.extname(filePath);
42058
41884
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
42059
41885
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
42060
41886
  res.end(content);
@@ -42167,9 +41993,9 @@ var init_dev_server = __esm({
42167
41993
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
42168
41994
  if (entry.isDirectory()) {
42169
41995
  files.push({ path: rel, size: 0, type: "dir" });
42170
- scan(path15.join(d, entry.name), rel);
41996
+ scan(path14.join(d, entry.name), rel);
42171
41997
  } else {
42172
- const stat4 = fs12.statSync(path15.join(d, entry.name));
41998
+ const stat4 = fs12.statSync(path14.join(d, entry.name));
42173
41999
  files.push({ path: rel, size: stat4.size, type: "file" });
42174
42000
  }
42175
42001
  }
@@ -42192,7 +42018,7 @@ var init_dev_server = __esm({
42192
42018
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
42193
42019
  return;
42194
42020
  }
42195
- const fullPath = path15.resolve(dir, path15.normalize(filePath));
42021
+ const fullPath = path14.resolve(dir, path14.normalize(filePath));
42196
42022
  if (!fullPath.startsWith(dir)) {
42197
42023
  this.json(res, 403, { error: "Forbidden" });
42198
42024
  return;
@@ -42217,14 +42043,14 @@ var init_dev_server = __esm({
42217
42043
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
42218
42044
  return;
42219
42045
  }
42220
- const fullPath = path15.resolve(dir, path15.normalize(filePath));
42046
+ const fullPath = path14.resolve(dir, path14.normalize(filePath));
42221
42047
  if (!fullPath.startsWith(dir)) {
42222
42048
  this.json(res, 403, { error: "Forbidden" });
42223
42049
  return;
42224
42050
  }
42225
42051
  try {
42226
42052
  if (fs12.existsSync(fullPath)) fs12.copyFileSync(fullPath, fullPath + ".bak");
42227
- fs12.mkdirSync(path15.dirname(fullPath), { recursive: true });
42053
+ fs12.mkdirSync(path14.dirname(fullPath), { recursive: true });
42228
42054
  fs12.writeFileSync(fullPath, content, "utf-8");
42229
42055
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
42230
42056
  this.providerLoader.reload();
@@ -42241,7 +42067,7 @@ var init_dev_server = __esm({
42241
42067
  return;
42242
42068
  }
42243
42069
  for (const name of ["scripts.js", "provider.json"]) {
42244
- const p = path15.join(dir, name);
42070
+ const p = path14.join(dir, name);
42245
42071
  if (fs12.existsSync(p)) {
42246
42072
  const source = fs12.readFileSync(p, "utf-8");
42247
42073
  this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
@@ -42262,8 +42088,8 @@ var init_dev_server = __esm({
42262
42088
  this.json(res, 404, { error: `Provider not found: ${type}` });
42263
42089
  return;
42264
42090
  }
42265
- const target = fs12.existsSync(path15.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
42266
- const targetPath = path15.join(dir, target);
42091
+ const target = fs12.existsSync(path14.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
42092
+ const targetPath = path14.join(dir, target);
42267
42093
  try {
42268
42094
  if (fs12.existsSync(targetPath)) fs12.copyFileSync(targetPath, targetPath + ".bak");
42269
42095
  fs12.writeFileSync(targetPath, source, "utf-8");
@@ -42368,14 +42194,14 @@ var init_dev_server = __esm({
42368
42194
  child.stderr?.on("data", (d) => {
42369
42195
  stderr += d.toString();
42370
42196
  });
42371
- await new Promise((resolve13) => {
42197
+ await new Promise((resolve12) => {
42372
42198
  const timer = setTimeout(() => {
42373
42199
  child.kill();
42374
- resolve13();
42200
+ resolve12();
42375
42201
  }, timeout);
42376
42202
  child.on("exit", () => {
42377
42203
  clearTimeout(timer);
42378
- resolve13();
42204
+ resolve12();
42379
42205
  });
42380
42206
  });
42381
42207
  const elapsed = Date.now() - start;
@@ -42423,7 +42249,7 @@ var init_dev_server = __esm({
42423
42249
  }
42424
42250
  let targetDir;
42425
42251
  targetDir = this.providerLoader.getUserProviderDir(category, type);
42426
- const jsonPath = path15.join(targetDir, "provider.json");
42252
+ const jsonPath = path14.join(targetDir, "provider.json");
42427
42253
  if (fs12.existsSync(jsonPath)) {
42428
42254
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
42429
42255
  return;
@@ -42435,8 +42261,8 @@ var init_dev_server = __esm({
42435
42261
  const createdFiles = ["provider.json"];
42436
42262
  if (result.files) {
42437
42263
  for (const [relPath, content] of Object.entries(result.files)) {
42438
- const fullPath = path15.join(targetDir, relPath);
42439
- fs12.mkdirSync(path15.dirname(fullPath), { recursive: true });
42264
+ const fullPath = path14.join(targetDir, relPath);
42265
+ fs12.mkdirSync(path14.dirname(fullPath), { recursive: true });
42440
42266
  fs12.writeFileSync(fullPath, content, "utf-8");
42441
42267
  createdFiles.push(relPath);
42442
42268
  }
@@ -42489,22 +42315,22 @@ var init_dev_server = __esm({
42489
42315
  if (!fs12.existsSync(scriptsDir)) return null;
42490
42316
  const versions = fs12.readdirSync(scriptsDir).filter((d) => {
42491
42317
  try {
42492
- return fs12.statSync(path15.join(scriptsDir, d)).isDirectory();
42318
+ return fs12.statSync(path14.join(scriptsDir, d)).isDirectory();
42493
42319
  } catch {
42494
42320
  return false;
42495
42321
  }
42496
42322
  }).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
42497
42323
  if (versions.length === 0) return null;
42498
- return path15.join(scriptsDir, versions[0]);
42324
+ return path14.join(scriptsDir, versions[0]);
42499
42325
  }
42500
42326
  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}`)) {
42327
+ const canonicalUserDir = path14.resolve(this.providerLoader.getUserProviderDir(category, type));
42328
+ const desiredDir = requestedDir ? path14.resolve(requestedDir) : canonicalUserDir;
42329
+ const upstreamRoot = path14.resolve(this.providerLoader.getUpstreamDir());
42330
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path14.sep}`)) {
42505
42331
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
42506
42332
  }
42507
- if (path15.basename(desiredDir) !== type) {
42333
+ if (path14.basename(desiredDir) !== type) {
42508
42334
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
42509
42335
  }
42510
42336
  const sourceDir = this.findProviderDir(type);
@@ -42512,11 +42338,11 @@ var init_dev_server = __esm({
42512
42338
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
42513
42339
  }
42514
42340
  if (!fs12.existsSync(desiredDir)) {
42515
- fs12.mkdirSync(path15.dirname(desiredDir), { recursive: true });
42341
+ fs12.mkdirSync(path14.dirname(desiredDir), { recursive: true });
42516
42342
  fs12.cpSync(sourceDir, desiredDir, { recursive: true });
42517
42343
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
42518
42344
  }
42519
- const providerJson = path15.join(desiredDir, "provider.json");
42345
+ const providerJson = path14.join(desiredDir, "provider.json");
42520
42346
  if (!fs12.existsSync(providerJson)) {
42521
42347
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
42522
42348
  }
@@ -42564,7 +42390,7 @@ var init_dev_server = __esm({
42564
42390
  setMode: "set_mode.js"
42565
42391
  };
42566
42392
  const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
42567
- const scriptsDir = path15.join(providerDir, "scripts");
42393
+ const scriptsDir = path14.join(providerDir, "scripts");
42568
42394
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
42569
42395
  if (latestScriptsDir) {
42570
42396
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -42575,7 +42401,7 @@ var init_dev_server = __esm({
42575
42401
  for (const file2 of fs12.readdirSync(latestScriptsDir)) {
42576
42402
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
42577
42403
  try {
42578
- const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
42404
+ const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
42579
42405
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
42580
42406
  lines.push("```javascript");
42581
42407
  lines.push(content);
@@ -42592,7 +42418,7 @@ var init_dev_server = __esm({
42592
42418
  lines.push("");
42593
42419
  for (const file2 of refFiles) {
42594
42420
  try {
42595
- const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
42421
+ const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
42596
42422
  lines.push(`### \`${file2}\` \u{1F512}`);
42597
42423
  lines.push("```javascript");
42598
42424
  lines.push(content);
@@ -42633,10 +42459,10 @@ var init_dev_server = __esm({
42633
42459
  lines.push("");
42634
42460
  }
42635
42461
  }
42636
- const docsDir = path15.join(providerDir, "../../docs");
42462
+ const docsDir = path14.join(providerDir, "../../docs");
42637
42463
  const loadGuide = (name) => {
42638
42464
  try {
42639
- const p = path15.join(docsDir, name);
42465
+ const p = path14.join(docsDir, name);
42640
42466
  if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
42641
42467
  } catch {
42642
42468
  }
@@ -42810,7 +42636,7 @@ var init_dev_server = __esm({
42810
42636
  parseApproval: "parse_approval.js"
42811
42637
  };
42812
42638
  const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
42813
- const scriptsDir = path15.join(providerDir, "scripts");
42639
+ const scriptsDir = path14.join(providerDir, "scripts");
42814
42640
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
42815
42641
  if (latestScriptsDir) {
42816
42642
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -42822,7 +42648,7 @@ var init_dev_server = __esm({
42822
42648
  if (!file2.endsWith(".js")) continue;
42823
42649
  if (!targetFileNames.has(file2)) continue;
42824
42650
  try {
42825
- const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
42651
+ const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
42826
42652
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
42827
42653
  lines.push("```javascript");
42828
42654
  lines.push(content);
@@ -42838,7 +42664,7 @@ var init_dev_server = __esm({
42838
42664
  lines.push("");
42839
42665
  for (const file2 of refFiles) {
42840
42666
  try {
42841
- const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
42667
+ const content = fs12.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
42842
42668
  lines.push(`### \`${file2}\` \u{1F512}`);
42843
42669
  lines.push("```javascript");
42844
42670
  lines.push(content);
@@ -42871,10 +42697,10 @@ var init_dev_server = __esm({
42871
42697
  lines.push("");
42872
42698
  }
42873
42699
  }
42874
- const docsDir = path15.join(providerDir, "../../docs");
42700
+ const docsDir = path14.join(providerDir, "../../docs");
42875
42701
  const loadGuide = (name) => {
42876
42702
  try {
42877
- const p = path15.join(docsDir, name);
42703
+ const p = path14.join(docsDir, name);
42878
42704
  if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
42879
42705
  } catch {
42880
42706
  }
@@ -43031,14 +42857,14 @@ data: ${JSON.stringify(msg.data)}
43031
42857
  res.end(JSON.stringify(data, null, 2));
43032
42858
  }
43033
42859
  async readBody(req) {
43034
- return new Promise((resolve13) => {
42860
+ return new Promise((resolve12) => {
43035
42861
  let body = "";
43036
42862
  req.on("data", (chunk) => body += chunk);
43037
42863
  req.on("end", () => {
43038
42864
  try {
43039
- resolve13(JSON.parse(body));
42865
+ resolve12(JSON.parse(body));
43040
42866
  } catch {
43041
- resolve13({});
42867
+ resolve12({});
43042
42868
  }
43043
42869
  });
43044
42870
  });
@@ -43162,8 +42988,8 @@ var init_dist = __esm({
43162
42988
  }
43163
42989
  this.requestWaiters.clear();
43164
42990
  });
43165
- await new Promise((resolve13, reject) => {
43166
- socket.once("connect", () => resolve13());
42991
+ await new Promise((resolve12, reject) => {
42992
+ socket.once("connect", () => resolve12());
43167
42993
  socket.once("error", reject);
43168
42994
  });
43169
42995
  }
@@ -43182,7 +43008,7 @@ var init_dist = __esm({
43182
43008
  requestId,
43183
43009
  request
43184
43010
  };
43185
- const response = await new Promise((resolve13, reject) => {
43011
+ const response = await new Promise((resolve12, reject) => {
43186
43012
  const timeout = setTimeout(() => {
43187
43013
  this.requestWaiters.delete(requestId);
43188
43014
  reject(new Error(`Session host request timed out after 30s (${request.type})`));
@@ -43190,7 +43016,7 @@ var init_dist = __esm({
43190
43016
  this.requestWaiters.set(requestId, {
43191
43017
  resolve: (value) => {
43192
43018
  clearTimeout(timeout);
43193
- resolve13(value);
43019
+ resolve12(value);
43194
43020
  },
43195
43021
  reject: (error48) => {
43196
43022
  clearTimeout(timeout);
@@ -43209,12 +43035,12 @@ var init_dist = __esm({
43209
43035
  waiter.reject(new Error("Session host client closed"));
43210
43036
  }
43211
43037
  this.requestWaiters.clear();
43212
- await new Promise((resolve13) => {
43038
+ await new Promise((resolve12) => {
43213
43039
  let settled = false;
43214
43040
  const done = () => {
43215
43041
  if (settled) return;
43216
43042
  settled = true;
43217
- resolve13();
43043
+ resolve12();
43218
43044
  };
43219
43045
  socket.once("close", done);
43220
43046
  socket.end();
@@ -43591,7 +43417,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
43591
43417
  const deadline = Date.now() + timeoutMs;
43592
43418
  while (Date.now() < deadline) {
43593
43419
  if (await canConnect(endpoint)) return;
43594
- await new Promise((resolve13) => setTimeout(resolve13, STARTUP_POLL_MS));
43420
+ await new Promise((resolve12) => setTimeout(resolve12, STARTUP_POLL_MS));
43595
43421
  }
43596
43422
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
43597
43423
  }
@@ -43909,7 +43735,6 @@ var init_src = __esm({
43909
43735
  "use strict";
43910
43736
  init_config();
43911
43737
  init_workspaces();
43912
- init_workspace_activity();
43913
43738
  init_recent_activity();
43914
43739
  init_ide_detector();
43915
43740
  init_cli_detector();
@@ -44142,9 +43967,9 @@ var init_server_connection = __esm({
44142
43967
  LOG.info("Server", `[ServerConn] Run 'adhdev setup' to re-authenticate.`);
44143
43968
  this.setState("disconnected");
44144
43969
  try {
44145
- const path19 = require("path");
43970
+ const path18 = require("path");
44146
43971
  const fs16 = require("fs");
44147
- const configPath = path19.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "config.json");
43972
+ const configPath = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "config.json");
44148
43973
  if (fs16.existsSync(configPath)) {
44149
43974
  fs16.unlinkSync(configPath);
44150
43975
  LOG.info("Server", `[ServerConn] Config file removed. Re-run 'adhdev setup'.`);
@@ -44255,17 +44080,17 @@ function canPeerUsePrivilegedShareCommand(commandType, permission) {
44255
44080
  return false;
44256
44081
  }
44257
44082
  }
44258
- var fs13, path16, os18, import_node_module, esmRequire, logFile, log, logDebug, DaemonP2PSender;
44083
+ var fs13, path15, os18, import_node_module, esmRequire, logFile, log, logDebug, DaemonP2PSender;
44259
44084
  var init_daemon_p2p = __esm({
44260
44085
  "src/daemon-p2p.ts"() {
44261
44086
  "use strict";
44262
44087
  fs13 = __toESM(require("fs"));
44263
44088
  init_src();
44264
- path16 = __toESM(require("path"));
44089
+ path15 = __toESM(require("path"));
44265
44090
  os18 = __toESM(require("os"));
44266
44091
  import_node_module = require("module");
44267
44092
  esmRequire = (0, import_node_module.createRequire)(__filename);
44268
- logFile = path16.join(os18.tmpdir(), "adhdev_daemon_p2p.log");
44093
+ logFile = path15.join(os18.tmpdir(), "adhdev_daemon_p2p.log");
44269
44094
  log = (msg) => {
44270
44095
  LOG.info("P2P", `[${(/* @__PURE__ */ new Date()).toISOString()}] [P2P] ${msg}`);
44271
44096
  };
@@ -44333,15 +44158,15 @@ ${e?.stack || ""}`);
44333
44158
  const prebuildKey = `${platform11}-${arch3}`;
44334
44159
  try {
44335
44160
  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")
44161
+ path15.join(__dirname, "node_modules", "node-datachannel"),
44162
+ path15.join(__dirname, "..", "node_modules", "node-datachannel"),
44163
+ path15.join(__dirname, "..", "..", "node_modules", "node-datachannel")
44339
44164
  ];
44340
44165
  for (const candidate of candidates) {
44341
- const prebuildPath = path16.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
44166
+ const prebuildPath = path15.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
44342
44167
  if (fs13.existsSync(prebuildPath)) {
44343
- const targetDir = path16.join(candidate, "build", "Release");
44344
- const targetPath = path16.join(targetDir, "node_datachannel.node");
44168
+ const targetDir = path15.join(candidate, "build", "Release");
44169
+ const targetPath = path15.join(targetDir, "node_datachannel.node");
44345
44170
  fs13.mkdirSync(targetDir, { recursive: true });
44346
44171
  fs13.copyFileSync(prebuildPath, targetPath);
44347
44172
  try {
@@ -44417,7 +44242,7 @@ ${e?.stack || ""}`);
44417
44242
  async fetchTurnCredentials() {
44418
44243
  try {
44419
44244
  const serverUrl = process.env.ADHDEV_SERVER_URL || "https://api.adhf.dev";
44420
- const configPath = path16.join(os18.homedir(), ".adhdev", "config.json");
44245
+ const configPath = path15.join(os18.homedir(), ".adhdev", "config.json");
44421
44246
  let token = "";
44422
44247
  try {
44423
44248
  const config2 = JSON.parse(fs13.readFileSync(configPath, "utf-8"));
@@ -44425,13 +44250,13 @@ ${e?.stack || ""}`);
44425
44250
  } catch {
44426
44251
  }
44427
44252
  const http3 = esmRequire("https");
44428
- const data = await new Promise((resolve13, reject) => {
44253
+ const data = await new Promise((resolve12, reject) => {
44429
44254
  const req = http3.get(`${serverUrl}/api/v1/turn/credentials`, {
44430
44255
  headers: { "Authorization": `Bearer ${token}` }
44431
44256
  }, (res) => {
44432
44257
  let d = "";
44433
44258
  res.on("data", (c) => d += c);
44434
- res.on("end", () => resolve13(d));
44259
+ res.on("end", () => resolve12(d));
44435
44260
  });
44436
44261
  req.on("error", reject);
44437
44262
  req.setTimeout(5e3, () => {
@@ -45238,8 +45063,8 @@ var init_screenshot_controller = __esm({
45238
45063
  // src/session-host.ts
45239
45064
  function resolveSessionHostEntry() {
45240
45065
  const packagedCandidates = [
45241
- path17.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
45242
- path17.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
45066
+ path16.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
45067
+ path16.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
45243
45068
  ];
45244
45069
  for (const candidate of packagedCandidates) {
45245
45070
  if (fs14.existsSync(candidate)) {
@@ -45269,13 +45094,13 @@ async function ensureSessionHostReady2() {
45269
45094
  async function listHostedCliRuntimes2(endpoint) {
45270
45095
  return listHostedCliRuntimes(endpoint);
45271
45096
  }
45272
- var import_child_process8, fs14, path17, SESSION_HOST_APP_NAME;
45097
+ var import_child_process8, fs14, path16, SESSION_HOST_APP_NAME;
45273
45098
  var init_session_host = __esm({
45274
45099
  "src/session-host.ts"() {
45275
45100
  "use strict";
45276
45101
  import_child_process8 = require("child_process");
45277
45102
  fs14 = __toESM(require("fs"));
45278
- path17 = __toESM(require("path"));
45103
+ path16 = __toESM(require("path"));
45279
45104
  init_src();
45280
45105
  SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
45281
45106
  }
@@ -45289,9 +45114,9 @@ __export(adhdev_daemon_exports, {
45289
45114
  stopDaemon: () => stopDaemon
45290
45115
  });
45291
45116
  function getDaemonPidFile() {
45292
- const dir = path18.join(os19.homedir(), ".adhdev");
45117
+ const dir = path17.join(os19.homedir(), ".adhdev");
45293
45118
  if (!fs15.existsSync(dir)) fs15.mkdirSync(dir, { recursive: true });
45294
- return path18.join(dir, "daemon.pid");
45119
+ return path17.join(dir, "daemon.pid");
45295
45120
  }
45296
45121
  function writeDaemonPid(pid) {
45297
45122
  fs15.writeFileSync(getDaemonPidFile(), String(pid), "utf-8");
@@ -45327,7 +45152,7 @@ function stopDaemon() {
45327
45152
  return false;
45328
45153
  }
45329
45154
  }
45330
- var os19, fs15, path18, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
45155
+ var os19, fs15, path17, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
45331
45156
  var init_adhdev_daemon = __esm({
45332
45157
  "src/adhdev-daemon.ts"() {
45333
45158
  "use strict";
@@ -45339,14 +45164,14 @@ var init_adhdev_daemon = __esm({
45339
45164
  init_dist();
45340
45165
  os19 = __toESM(require("os"));
45341
45166
  fs15 = __toESM(require("fs"));
45342
- path18 = __toESM(require("path"));
45167
+ path17 = __toESM(require("path"));
45343
45168
  import_chalk2 = __toESM(require("chalk"));
45344
- pkgVersion = "0.7.38";
45169
+ pkgVersion = "0.7.39";
45345
45170
  if (pkgVersion === "unknown") {
45346
45171
  try {
45347
45172
  const possiblePaths = [
45348
- path18.join(__dirname, "..", "package.json"),
45349
- path18.join(__dirname, "package.json")
45173
+ path17.join(__dirname, "..", "package.json"),
45174
+ path17.join(__dirname, "package.json")
45350
45175
  ];
45351
45176
  for (const p of possiblePaths) {
45352
45177
  try {
@@ -45704,11 +45529,6 @@ ${err?.stack || ""}`);
45704
45529
  });
45705
45530
  }
45706
45531
  }
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
45532
  case "set_machine_nickname": {
45713
45533
  const nickname = data.nickname?.trim() || null;
45714
45534
  const config2 = loadConfig();
@@ -46051,8 +45871,8 @@ async function startDaemonFlow() {
46051
45871
  const daemon = new AdhdevDaemon2();
46052
45872
  const { execSync: execSync6 } = await import("child_process");
46053
45873
  const os20 = await import("os");
46054
- const path19 = await import("path");
46055
- const logPath = path19.join(os20.homedir(), ".adhdev", "daemon.log");
45874
+ const path18 = await import("path");
45875
+ const logPath = path18.join(os20.homedir(), ".adhdev", "daemon.log");
46056
45876
  const platform11 = os20.platform();
46057
45877
  try {
46058
45878
  if (platform11 === "win32") {