adhdev 0.9.76-rc.1 → 0.9.76-rc.11

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
@@ -1443,6 +1443,134 @@ var init_turn_snapshot_tracker = __esm({
1443
1443
  }
1444
1444
  });
1445
1445
 
1446
+ // ../../oss/packages/daemon-core/src/git/git-worktree.ts
1447
+ var git_worktree_exports = {};
1448
+ __export(git_worktree_exports, {
1449
+ createWorktree: () => createWorktree,
1450
+ listWorktrees: () => listWorktrees,
1451
+ parseWorktreeListOutput: () => parseWorktreeListOutput,
1452
+ removeWorktree: () => removeWorktree,
1453
+ resolveWorktreePath: () => resolveWorktreePath
1454
+ });
1455
+ function resolveWorktreePath(repoRoot, meshName, branch) {
1456
+ const safeBranch = branch.replace(/[/\\:*?"<>|]/g, "-").replace(/^\.+|\.+$/g, "");
1457
+ const safeMeshName = meshName.replace(/[/\\:*?"<>|]/g, "-").replace(/^\.+|\.+$/g, "");
1458
+ const parentDir = path4.dirname(repoRoot);
1459
+ return path4.join(parentDir, WORKTREE_DIR_NAME, safeMeshName, safeBranch);
1460
+ }
1461
+ async function createWorktree(opts) {
1462
+ const { repoRoot, branch, baseBranch, meshName } = opts;
1463
+ const targetDir = opts.targetDir || resolveWorktreePath(repoRoot, meshName, branch);
1464
+ if ((0, import_node_fs2.existsSync)(targetDir)) {
1465
+ throw new Error(`Worktree target directory already exists: ${targetDir}`);
1466
+ }
1467
+ await (0, import_promises3.mkdir)(path4.dirname(targetDir), { recursive: true });
1468
+ const args = ["worktree", "add", targetDir, "-b", branch];
1469
+ if (baseBranch) {
1470
+ args.push(baseBranch);
1471
+ }
1472
+ try {
1473
+ await execFileAsync2("git", args, {
1474
+ cwd: repoRoot,
1475
+ encoding: "utf8",
1476
+ timeout: GIT_TIMEOUT_MS,
1477
+ maxBuffer: GIT_MAX_BUFFER,
1478
+ windowsHide: true
1479
+ });
1480
+ } catch (error48) {
1481
+ const stderr = typeof error48.stderr === "string" ? error48.stderr : "";
1482
+ if (/already exists/i.test(stderr)) {
1483
+ throw new Error(`Branch '${branch}' already exists or is checked out in another worktree`);
1484
+ }
1485
+ throw new Error(`git worktree add failed: ${stderr.trim() || error48.message}`);
1486
+ }
1487
+ return {
1488
+ success: true,
1489
+ worktreePath: targetDir,
1490
+ branch
1491
+ };
1492
+ }
1493
+ async function removeWorktree(repoRoot, worktreePath) {
1494
+ if (!(0, import_node_fs2.existsSync)(worktreePath)) {
1495
+ await pruneWorktrees(repoRoot);
1496
+ return { success: true, removedPath: worktreePath };
1497
+ }
1498
+ try {
1499
+ await execFileAsync2("git", ["worktree", "remove", worktreePath, "--force"], {
1500
+ cwd: repoRoot,
1501
+ encoding: "utf8",
1502
+ timeout: GIT_TIMEOUT_MS,
1503
+ maxBuffer: GIT_MAX_BUFFER,
1504
+ windowsHide: true
1505
+ });
1506
+ } catch (error48) {
1507
+ const stderr = typeof error48.stderr === "string" ? error48.stderr : "";
1508
+ throw new Error(`git worktree remove failed: ${stderr.trim() || error48.message}`);
1509
+ }
1510
+ return { success: true, removedPath: worktreePath };
1511
+ }
1512
+ async function listWorktrees(repoRoot) {
1513
+ const { stdout } = await execFileAsync2("git", ["worktree", "list", "--porcelain"], {
1514
+ cwd: repoRoot,
1515
+ encoding: "utf8",
1516
+ timeout: GIT_TIMEOUT_MS,
1517
+ maxBuffer: GIT_MAX_BUFFER,
1518
+ windowsHide: true
1519
+ });
1520
+ return parseWorktreeListOutput(stdout);
1521
+ }
1522
+ function parseWorktreeListOutput(output) {
1523
+ const entries = [];
1524
+ const blocks = output.trim().split(/\n\n+/);
1525
+ for (const block of blocks) {
1526
+ if (!block.trim()) continue;
1527
+ const lines = block.trim().split("\n");
1528
+ const entry = { path: "", head: "", branch: null, bare: false };
1529
+ for (const line of lines) {
1530
+ if (line.startsWith("worktree ")) {
1531
+ entry.path = line.slice("worktree ".length).trim();
1532
+ } else if (line.startsWith("HEAD ")) {
1533
+ entry.head = line.slice("HEAD ".length).trim();
1534
+ } else if (line.startsWith("branch ")) {
1535
+ const ref = line.slice("branch ".length).trim();
1536
+ entry.branch = ref.replace(/^refs\/heads\//, "");
1537
+ } else if (line === "bare") {
1538
+ entry.bare = true;
1539
+ }
1540
+ }
1541
+ if (entry.path) {
1542
+ entries.push(entry);
1543
+ }
1544
+ }
1545
+ return entries;
1546
+ }
1547
+ async function pruneWorktrees(repoRoot) {
1548
+ try {
1549
+ await execFileAsync2("git", ["worktree", "prune"], {
1550
+ cwd: repoRoot,
1551
+ encoding: "utf8",
1552
+ timeout: GIT_TIMEOUT_MS,
1553
+ windowsHide: true
1554
+ });
1555
+ } catch {
1556
+ }
1557
+ }
1558
+ var path4, import_promises3, import_node_fs2, import_node_child_process2, import_node_util2, execFileAsync2, WORKTREE_DIR_NAME, GIT_TIMEOUT_MS, GIT_MAX_BUFFER;
1559
+ var init_git_worktree = __esm({
1560
+ "../../oss/packages/daemon-core/src/git/git-worktree.ts"() {
1561
+ "use strict";
1562
+ path4 = __toESM(require("path"));
1563
+ import_promises3 = require("fs/promises");
1564
+ import_node_fs2 = require("fs");
1565
+ import_node_child_process2 = require("child_process");
1566
+ import_node_util2 = require("util");
1567
+ execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process2.execFile);
1568
+ WORKTREE_DIR_NAME = ".adhdev-worktrees";
1569
+ GIT_TIMEOUT_MS = 3e4;
1570
+ GIT_MAX_BUFFER = 4 * 1024 * 1024;
1571
+ }
1572
+ });
1573
+
1446
1574
  // ../../oss/packages/daemon-core/src/git/index.ts
1447
1575
  var init_git = __esm({
1448
1576
  "../../oss/packages/daemon-core/src/git/index.ts"() {
@@ -1455,6 +1583,7 @@ var init_git = __esm({
1455
1583
  init_git_monitor();
1456
1584
  init_git_commands();
1457
1585
  init_turn_snapshot_tracker();
1586
+ init_git_worktree();
1458
1587
  }
1459
1588
  });
1460
1589
 
@@ -1702,8 +1831,8 @@ var init_config = __esm({
1702
1831
  function expandPath(p) {
1703
1832
  const t = (p || "").trim();
1704
1833
  if (!t) return "";
1705
- if (t.startsWith("~")) return path4.join(os.homedir(), t.slice(1).replace(/^\//, ""));
1706
- return path4.resolve(t);
1834
+ if (t.startsWith("~")) return path5.join(os.homedir(), t.slice(1).replace(/^\//, ""));
1835
+ return path5.resolve(t);
1707
1836
  }
1708
1837
  function validateWorkspacePath(absPath) {
1709
1838
  try {
@@ -1717,7 +1846,7 @@ function validateWorkspacePath(absPath) {
1717
1846
  }
1718
1847
  }
1719
1848
  function defaultWorkspaceLabel(absPath) {
1720
- const base = path4.basename(absPath) || absPath;
1849
+ const base = path5.basename(absPath) || absPath;
1721
1850
  return base;
1722
1851
  }
1723
1852
  function getDefaultWorkspacePath(config2) {
@@ -1808,9 +1937,9 @@ function resolveIdeLaunchWorkspace(args, config2) {
1808
1937
  return getDefaultWorkspacePath(config2) || void 0;
1809
1938
  }
1810
1939
  function findWorkspaceByPath(config2, rawPath) {
1811
- const abs = path4.resolve(expandPath(rawPath));
1940
+ const abs = path5.resolve(expandPath(rawPath));
1812
1941
  if (!abs) return void 0;
1813
- return (config2.workspaces || []).find((w) => path4.resolve(expandPath(w.path)) === abs);
1942
+ return (config2.workspaces || []).find((w) => path5.resolve(expandPath(w.path)) === abs);
1814
1943
  }
1815
1944
  function addWorkspaceEntry(config2, rawPath, label, options) {
1816
1945
  const abs = expandPath(rawPath);
@@ -1826,7 +1955,7 @@ function addWorkspaceEntry(config2, rawPath, label, options) {
1826
1955
  const v = validateWorkspacePath(abs);
1827
1956
  if (!v.ok) return { error: v.error };
1828
1957
  const list = [...config2.workspaces || []];
1829
- if (list.some((w) => path4.resolve(w.path) === abs)) {
1958
+ if (list.some((w) => path5.resolve(w.path) === abs)) {
1830
1959
  return { error: "Workspace already in list" };
1831
1960
  }
1832
1961
  if (list.length >= MAX_WORKSPACES) {
@@ -1858,13 +1987,13 @@ function setDefaultWorkspaceId(config2, id) {
1858
1987
  if (validateWorkspacePath(abs).ok !== true) return { error: "Workspace path is no longer valid" };
1859
1988
  return { config: { ...config2, defaultWorkspaceId: id } };
1860
1989
  }
1861
- var fs, os, path4, import_crypto2, MAX_WORKSPACES;
1990
+ var fs, os, path5, import_crypto2, MAX_WORKSPACES;
1862
1991
  var init_workspaces = __esm({
1863
1992
  "../../oss/packages/daemon-core/src/config/workspaces.ts"() {
1864
1993
  "use strict";
1865
1994
  fs = __toESM(require("fs"));
1866
1995
  os = __toESM(require("os"));
1867
- path4 = __toESM(require("path"));
1996
+ path5 = __toESM(require("path"));
1868
1997
  import_crypto2 = require("crypto");
1869
1998
  MAX_WORKSPACES = 50;
1870
1999
  }
@@ -1941,9 +2070,9 @@ var init_summary_metadata = __esm({
1941
2070
  function normalizeWorkspace(workspace) {
1942
2071
  if (!workspace) return "";
1943
2072
  try {
1944
- return path5.resolve(expandPath(workspace));
2073
+ return path6.resolve(expandPath(workspace));
1945
2074
  } catch {
1946
- return path5.resolve(workspace);
2075
+ return path6.resolve(workspace);
1947
2076
  }
1948
2077
  }
1949
2078
  function buildRecentActivityKey(entry) {
@@ -2109,11 +2238,11 @@ function markSessionSeen(state, sessionId, seenAt = Date.now(), completionMarker
2109
2238
  sessionNotificationUnreadOverrides: nextSessionNotificationUnreadOverrides
2110
2239
  };
2111
2240
  }
2112
- var path5, MAX_ACTIVITY;
2241
+ var path6, MAX_ACTIVITY;
2113
2242
  var init_recent_activity = __esm({
2114
2243
  "../../oss/packages/daemon-core/src/config/recent-activity.ts"() {
2115
2244
  "use strict";
2116
- path5 = __toESM(require("path"));
2245
+ path6 = __toESM(require("path"));
2117
2246
  init_workspaces();
2118
2247
  init_summary_metadata();
2119
2248
  MAX_ACTIVITY = 30;
@@ -2124,9 +2253,9 @@ var init_recent_activity = __esm({
2124
2253
  function normalizeWorkspace2(workspace) {
2125
2254
  if (!workspace) return "";
2126
2255
  try {
2127
- return path6.resolve(expandPath(workspace));
2256
+ return path7.resolve(expandPath(workspace));
2128
2257
  } catch {
2129
- return path6.resolve(workspace);
2258
+ return path7.resolve(workspace);
2130
2259
  }
2131
2260
  }
2132
2261
  function buildSavedProviderSessionKey(providerSessionId) {
@@ -2169,11 +2298,11 @@ function getSavedProviderSessions(state, filters) {
2169
2298
  })
2170
2299
  })).sort((a, b) => b.lastUsedAt - a.lastUsedAt);
2171
2300
  }
2172
- var path6, MAX_SAVED_SESSIONS;
2301
+ var path7, MAX_SAVED_SESSIONS;
2173
2302
  var init_saved_sessions = __esm({
2174
2303
  "../../oss/packages/daemon-core/src/config/saved-sessions.ts"() {
2175
2304
  "use strict";
2176
- path6 = __toESM(require("path"));
2305
+ path7 = __toESM(require("path"));
2177
2306
  init_workspaces();
2178
2307
  init_summary_metadata();
2179
2308
  MAX_SAVED_SESSIONS = 500;
@@ -2198,10 +2327,10 @@ function getMeshConfigPath() {
2198
2327
  return (0, import_path2.join)(getConfigDir(), "meshes.json");
2199
2328
  }
2200
2329
  function loadMeshConfig() {
2201
- const path33 = getMeshConfigPath();
2202
- if (!(0, import_fs2.existsSync)(path33)) return { meshes: [] };
2330
+ const path34 = getMeshConfigPath();
2331
+ if (!(0, import_fs2.existsSync)(path34)) return { meshes: [] };
2203
2332
  try {
2204
- const raw = JSON.parse((0, import_fs2.readFileSync)(path33, "utf-8"));
2333
+ const raw = JSON.parse((0, import_fs2.readFileSync)(path34, "utf-8"));
2205
2334
  if (!raw || !Array.isArray(raw.meshes)) return { meshes: [] };
2206
2335
  return raw;
2207
2336
  } catch {
@@ -2209,16 +2338,16 @@ function loadMeshConfig() {
2209
2338
  }
2210
2339
  }
2211
2340
  function saveMeshConfig(config2) {
2212
- const path33 = getMeshConfigPath();
2213
- (0, import_fs2.writeFileSync)(path33, JSON.stringify(config2, null, 2), { encoding: "utf-8", mode: 384 });
2341
+ const path34 = getMeshConfigPath();
2342
+ (0, import_fs2.writeFileSync)(path34, JSON.stringify(config2, null, 2), { encoding: "utf-8", mode: 384 });
2214
2343
  }
2215
2344
  function normalizeRepoIdentity(remoteUrl) {
2216
2345
  let identity = remoteUrl.trim();
2217
2346
  if (identity.startsWith("http://") || identity.startsWith("https://")) {
2218
2347
  try {
2219
2348
  const url2 = new URL(identity);
2220
- const path33 = url2.pathname.replace(/^\//, "").replace(/\.git$/, "");
2221
- return `${url2.hostname}/${path33}`;
2349
+ const path34 = url2.pathname.replace(/^\//, "").replace(/\.git$/, "");
2350
+ return `${url2.hostname}/${path34}`;
2222
2351
  } catch {
2223
2352
  }
2224
2353
  }
@@ -2293,9 +2422,12 @@ function addNode(meshId, opts) {
2293
2422
  id: `node_${(0, import_crypto3.randomUUID)().replace(/-/g, "")}`,
2294
2423
  workspace: opts.workspace.trim(),
2295
2424
  repoRoot: opts.repoRoot,
2425
+ daemonId: opts.daemonId,
2296
2426
  userOverrides: opts.userOverrides || {},
2297
2427
  policy: opts.policy || {},
2298
- isLocalWorktree: opts.isLocalWorktree
2428
+ isLocalWorktree: opts.isLocalWorktree,
2429
+ worktreeBranch: opts.worktreeBranch,
2430
+ clonedFromNodeId: opts.clonedFromNodeId
2299
2431
  };
2300
2432
  mesh.nodes.push(node);
2301
2433
  mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -2343,7 +2475,7 @@ __export(coordinator_prompt_exports, {
2343
2475
  buildCoordinatorSystemPrompt: () => buildCoordinatorSystemPrompt
2344
2476
  });
2345
2477
  function buildCoordinatorSystemPrompt(ctx) {
2346
- const { mesh, status, userInstruction } = ctx;
2478
+ const { mesh, status, userInstruction, coordinatorCliType } = ctx;
2347
2479
  const sections = [];
2348
2480
  sections.push(`You are a **Repo Mesh Coordinator** \u2014 a technical team lead who orchestrates work across multiple agent sessions on a shared Git repository.
2349
2481
 
@@ -2357,15 +2489,15 @@ Default branch: \`${mesh.defaultBranch}\`` : ""}`);
2357
2489
  } else {
2358
2490
  sections.push("## Nodes\nNo nodes configured yet. Ask the user to add nodes with `adhdev mesh add-node`.");
2359
2491
  }
2360
- sections.push(buildPolicySection(mesh.policy));
2492
+ sections.push(buildPolicySection({ ...DEFAULT_MESH_POLICY, ...mesh.policy || {} }));
2361
2493
  sections.push(TOOLS_SECTION);
2362
2494
  sections.push(WORKFLOW_SECTION);
2363
- sections.push(RULES_SECTION);
2495
+ sections.push(buildRulesSection(coordinatorCliType));
2364
2496
  if (userInstruction) {
2365
2497
  sections.push(`## Additional Context
2366
2498
  ${userInstruction}`);
2367
2499
  }
2368
- if (mesh.coordinator.systemPromptSuffix) {
2500
+ if (mesh.coordinator?.systemPromptSuffix) {
2369
2501
  sections.push(mesh.coordinator.systemPromptSuffix);
2370
2502
  }
2371
2503
  return sections.join("\n\n");
@@ -2410,10 +2542,29 @@ function buildPolicySection(policy) {
2410
2542
  return `## Policy
2411
2543
  ${rules.join("\n")}`;
2412
2544
  }
2413
- var TOOLS_SECTION, WORKFLOW_SECTION, RULES_SECTION;
2545
+ function buildRulesSection(coordinatorCliType) {
2546
+ const coordinatorNote = coordinatorCliType ? `
2547
+ - **Coordinator runtime is not a delegation default.** This coordinator is running as \`${coordinatorCliType}\`, but delegated node sessions must follow the user's requested provider, not the coordinator's own runtime.` : "";
2548
+ return `## Rules
2549
+
2550
+ - **Minimize coordinator context.** The coordinator's job is routing, not implementing. Do not read source files, run commands, or analyze code directly \u2014 delegate all of that to node agents. Your context should stay lean.
2551
+ - **Delegate analysis too.** If you need to understand a bug or explore the codebase, send that investigation as a task to a node. Do not do it yourself.
2552
+ - **Respect explicit provider requests.** If the user names an agent/provider, pass the matching provider type to \`mesh_launch_session\`: Hermes \u2192 \`hermes-cli\`, Claude Code/Claude \u2192 \`claude-cli\`, Codex \u2192 \`codex-cli\`, Gemini \u2192 \`gemini-cli\`. Never substitute \`claude-cli\` just because the coordinator itself is Claude Code.
2553
+ - **Front-load the task message.** When calling \`mesh_send_task\`, include everything the agent needs: what files to touch, what the problem is, what the fix should look like. The agent won't ask follow-up questions.
2554
+ - **Don't inspect code.** Trust the agent's output. Verify via \`mesh_git_status\`, not by reading source files.
2555
+ - **Don't over-parallelize.** Start with 1-2 concurrent tasks. Scale up if they succeed.
2556
+ - **Handle failures gracefully.** If a task fails, read the chat to understand why, then retry or reassign.
2557
+ - **Keep the user informed.** Report progress after each delegation round \u2014 one or two sentences, not a narration.
2558
+ - **Respect node capabilities.** Don't send build tasks to read-only nodes. Don't push from nodes that aren't allowed to.
2559
+ - **Never fabricate tool results.** Always call the actual tool; never pretend you did.
2560
+ - **Clean up worktree nodes.** After a worktree task completes and its changes are merged or checkpointed, call \`mesh_remove_node\` to free resources.
2561
+ - **Name worktree branches meaningfully.** Use descriptive names like \`feat/auth-refactor\` or \`fix/build-123\`.${coordinatorNote}`;
2562
+ }
2563
+ var TOOLS_SECTION, WORKFLOW_SECTION;
2414
2564
  var init_coordinator_prompt = __esm({
2415
2565
  "../../oss/packages/daemon-core/src/mesh/coordinator-prompt.ts"() {
2416
2566
  "use strict";
2567
+ init_repo_mesh_types();
2417
2568
  TOOLS_SECTION = `## Available Tools
2418
2569
 
2419
2570
  | Tool | Purpose |
@@ -2425,30 +2576,23 @@ var init_coordinator_prompt = __esm({
2425
2576
  | \`mesh_read_chat\` | Read an agent's recent messages to check progress |
2426
2577
  | \`mesh_git_status\` | Check git status on a specific node |
2427
2578
  | \`mesh_checkpoint\` | Create a git checkpoint on a node |
2428
- | \`mesh_approve\` | Approve/reject a pending agent action |`;
2579
+ | \`mesh_approve\` | Approve/reject a pending agent action |
2580
+ | \`mesh_clone_node\` | Create a worktree node for isolated parallel branch work |
2581
+ | \`mesh_remove_node\` | Remove a node (cleans up worktree if applicable) |`;
2429
2582
  WORKFLOW_SECTION = `## Orchestration Workflow
2430
2583
 
2431
2584
  1. **Assess** \u2014 Call \`mesh_status\` to see which nodes are healthy and available.
2432
2585
  2. **Plan** \u2014 Decompose the user's request into independent tasks for parallel execution, or sequential tasks when dependencies exist.
2433
2586
  3. **Delegate** \u2014 For each task:
2434
2587
  a. Pick the best node (consider: health, dirty state, current workload).
2435
- b. If no session exists, call \`mesh_launch_session\` to start one.
2436
- c. Call \`mesh_send_task\` with a **complete, self-contained** instruction that includes all context the agent needs (file paths, line numbers, what to change, why). Do not send partial instructions expecting future follow-up.
2588
+ b. If you need branch isolation for parallel work, call \`mesh_clone_node\` to create a worktree node first.
2589
+ c. If no session exists, call \`mesh_launch_session\` to start one.
2590
+ d. Call \`mesh_send_task\` with a **complete, self-contained** instruction that includes all context the agent needs (file paths, line numbers, what to change, why). Do not send partial instructions expecting future follow-up.
2437
2591
  4. **Monitor** \u2014 Periodically call \`mesh_read_chat\` to check progress. Handle approvals via \`mesh_approve\`.
2438
2592
  5. **Verify** \u2014 When a task reports completion, call \`mesh_git_status\` to verify changes were made.
2439
2593
  6. **Checkpoint** \u2014 Call \`mesh_checkpoint\` to save the work.
2440
- 7. **Report** \u2014 Summarize what was done, what changed, and any issues.`;
2441
- RULES_SECTION = `## Rules
2442
-
2443
- - **Minimize coordinator context.** The coordinator's job is routing, not implementing. Do not read source files, run commands, or analyze code directly \u2014 delegate all of that to node agents. Your context should stay lean.
2444
- - **Delegate analysis too.** If you need to understand a bug or explore the codebase, send that investigation as a task to a node. Do not do it yourself.
2445
- - **Front-load the task message.** When calling \`mesh_send_task\`, include everything the agent needs: what files to touch, what the problem is, what the fix should look like. The agent won't ask follow-up questions.
2446
- - **Don't inspect code.** Trust the agent's output. Verify via \`mesh_git_status\`, not by reading source files.
2447
- - **Don't over-parallelize.** Start with 1-2 concurrent tasks. Scale up if they succeed.
2448
- - **Handle failures gracefully.** If a task fails, read the chat to understand why, then retry or reassign.
2449
- - **Keep the user informed.** Report progress after each delegation round \u2014 one or two sentences, not a narration.
2450
- - **Respect node capabilities.** Don't send build tasks to read-only nodes. Don't push from nodes that aren't allowed to.
2451
- - **Never fabricate tool results.** Always call the actual tool; never pretend you did.`;
2594
+ 7. **Clean up** \u2014 Remove worktree nodes via \`mesh_remove_node\` after their work is merged or no longer needed.
2595
+ 8. **Report** \u2014 Summarize what was done, what changed, and any issues.`;
2452
2596
  }
2453
2597
  });
2454
2598
 
@@ -2607,9 +2751,9 @@ function getMergedDefinitions() {
2607
2751
  function findCliCommand(command) {
2608
2752
  const trimmed = String(command || "").trim();
2609
2753
  if (!trimmed) return null;
2610
- if (path7.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~")) {
2611
- const candidate = trimmed.startsWith("~") ? path7.join((0, import_os2.homedir)(), trimmed.slice(1)) : trimmed;
2612
- const resolved = path7.isAbsolute(candidate) ? candidate : path7.resolve(candidate);
2754
+ if (path8.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~")) {
2755
+ const candidate = trimmed.startsWith("~") ? path8.join((0, import_os2.homedir)(), trimmed.slice(1)) : trimmed;
2756
+ const resolved = path8.isAbsolute(candidate) ? candidate : path8.resolve(candidate);
2613
2757
  return (0, import_fs4.existsSync)(resolved) ? resolved : null;
2614
2758
  }
2615
2759
  try {
@@ -2637,7 +2781,7 @@ function getIdeVersion(cliCommand) {
2637
2781
  function checkPathExists(paths) {
2638
2782
  const home = (0, import_os2.homedir)();
2639
2783
  for (const p of paths) {
2640
- const normalized = p.startsWith("~") ? path7.join(home, p.slice(1)) : p;
2784
+ const normalized = p.startsWith("~") ? path8.join(home, p.slice(1)) : p;
2641
2785
  if (normalized.includes("*")) {
2642
2786
  const username = home.split(/[\\/]/).pop() || "";
2643
2787
  const resolved = normalized.replace("*", username);
@@ -2660,8 +2804,8 @@ async function detectIDEs(providerLoader) {
2660
2804
  if ((0, import_fs4.existsSync)(bundledCli)) resolvedCli = bundledCli;
2661
2805
  }
2662
2806
  if (!resolvedCli && appPath && os29 === "win32") {
2663
- const { dirname: dirname11 } = await import("path");
2664
- const appDir = dirname11(appPath);
2807
+ const { dirname: dirname12 } = await import("path");
2808
+ const appDir = dirname12(appPath);
2665
2809
  const candidates = [
2666
2810
  `${appDir}\\\\bin\\\\${def.cli}.cmd`,
2667
2811
  `${appDir}\\\\bin\\\\${def.cli}`,
@@ -2691,14 +2835,14 @@ async function detectIDEs(providerLoader) {
2691
2835
  }
2692
2836
  return results;
2693
2837
  }
2694
- var import_child_process, import_fs4, import_os2, path7, BUILTIN_IDE_DEFINITIONS, registeredIDEs;
2838
+ var import_child_process, import_fs4, import_os2, path8, BUILTIN_IDE_DEFINITIONS, registeredIDEs;
2695
2839
  var init_ide_detector = __esm({
2696
2840
  "../../oss/packages/daemon-core/src/detection/ide-detector.ts"() {
2697
2841
  "use strict";
2698
2842
  import_child_process = require("child_process");
2699
2843
  import_fs4 = require("fs");
2700
2844
  import_os2 = require("os");
2701
- path7 = __toESM(require("path"));
2845
+ path8 = __toESM(require("path"));
2702
2846
  BUILTIN_IDE_DEFINITIONS = [];
2703
2847
  registeredIDEs = /* @__PURE__ */ new Map();
2704
2848
  }
@@ -2716,18 +2860,18 @@ function shellQuote(value) {
2716
2860
  function expandHome(value) {
2717
2861
  const trimmed = value.trim();
2718
2862
  if (!trimmed.startsWith("~")) return trimmed;
2719
- return path8.join(os2.homedir(), trimmed.slice(1));
2863
+ return path9.join(os2.homedir(), trimmed.slice(1));
2720
2864
  }
2721
2865
  function isExplicitCommandPath(command) {
2722
2866
  const trimmed = command.trim();
2723
- return path8.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
2867
+ return path9.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
2724
2868
  }
2725
2869
  function resolveCommandPath(command) {
2726
2870
  const trimmed = command.trim();
2727
2871
  if (!trimmed) return null;
2728
2872
  if (isExplicitCommandPath(trimmed)) {
2729
2873
  const expanded = expandHome(trimmed);
2730
- const candidate = path8.isAbsolute(expanded) ? expanded : path8.resolve(expanded);
2874
+ const candidate = path9.isAbsolute(expanded) ? expanded : path9.resolve(expanded);
2731
2875
  return (0, import_fs5.existsSync)(candidate) ? candidate : null;
2732
2876
  }
2733
2877
  return null;
@@ -2828,13 +2972,13 @@ async function detectCLI(cliId, providerLoader, options) {
2828
2972
  const all = await detectCLIs(providerLoader, options);
2829
2973
  return all.find((c) => c.id === resolvedId && c.installed) || null;
2830
2974
  }
2831
- var import_child_process2, os2, path8, import_fs5;
2975
+ var import_child_process2, os2, path9, import_fs5;
2832
2976
  var init_cli_detector = __esm({
2833
2977
  "../../oss/packages/daemon-core/src/detection/cli-detector.ts"() {
2834
2978
  "use strict";
2835
2979
  import_child_process2 = require("child_process");
2836
2980
  os2 = __toESM(require("os"));
2837
- path8 = __toESM(require("path"));
2981
+ path9 = __toESM(require("path"));
2838
2982
  import_fs5 = require("fs");
2839
2983
  }
2840
2984
  });
@@ -3043,13 +3187,13 @@ function getDaemonLogDir() {
3043
3187
  return LOG_DIR;
3044
3188
  }
3045
3189
  function getCurrentDaemonLogPath(date5 = /* @__PURE__ */ new Date()) {
3046
- return path9.join(LOG_DIR, `daemon-${date5.toISOString().slice(0, 10)}.log`);
3190
+ return path10.join(LOG_DIR, `daemon-${date5.toISOString().slice(0, 10)}.log`);
3047
3191
  }
3048
3192
  function checkDateRotation() {
3049
3193
  const today = getDateStr();
3050
3194
  if (today !== currentDate) {
3051
3195
  currentDate = today;
3052
- currentLogFile = path9.join(LOG_DIR, `daemon-${currentDate}.log`);
3196
+ currentLogFile = path10.join(LOG_DIR, `daemon-${currentDate}.log`);
3053
3197
  cleanOldLogs();
3054
3198
  }
3055
3199
  }
@@ -3063,7 +3207,7 @@ function cleanOldLogs() {
3063
3207
  const dateMatch = file2.match(/daemon-(\d{4}-\d{2}-\d{2})/);
3064
3208
  if (dateMatch && dateMatch[1] < cutoffStr) {
3065
3209
  try {
3066
- fs2.unlinkSync(path9.join(LOG_DIR, file2));
3210
+ fs2.unlinkSync(path10.join(LOG_DIR, file2));
3067
3211
  } catch {
3068
3212
  }
3069
3213
  }
@@ -3179,17 +3323,17 @@ function installGlobalInterceptor() {
3179
3323
  writeToFile(`Log file: ${currentLogFile}`);
3180
3324
  writeToFile(`Log level: ${currentLevel}`);
3181
3325
  }
3182
- var fs2, path9, 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;
3326
+ var fs2, path10, 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;
3183
3327
  var init_logger = __esm({
3184
3328
  "../../oss/packages/daemon-core/src/logging/logger.ts"() {
3185
3329
  "use strict";
3186
3330
  fs2 = __toESM(require("fs"));
3187
- path9 = __toESM(require("path"));
3331
+ path10 = __toESM(require("path"));
3188
3332
  os4 = __toESM(require("os"));
3189
3333
  LEVEL_NUM = { debug: 0, info: 1, warn: 2, error: 3 };
3190
3334
  LEVEL_LABEL = { debug: "DBG", info: "INF", warn: "WRN", error: "ERR" };
3191
3335
  currentLevel = "info";
3192
- LOG_DIR = process.platform === "win32" ? path9.join(process.env.LOCALAPPDATA || process.env.APPDATA || path9.join(os4.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path9.join(os4.homedir(), "Library", "Logs", "adhdev") : path9.join(os4.homedir(), ".local", "share", "adhdev", "logs");
3336
+ LOG_DIR = process.platform === "win32" ? path10.join(process.env.LOCALAPPDATA || process.env.APPDATA || path10.join(os4.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path10.join(os4.homedir(), "Library", "Logs", "adhdev") : path10.join(os4.homedir(), ".local", "share", "adhdev", "logs");
3193
3337
  MAX_LOG_SIZE = 5 * 1024 * 1024;
3194
3338
  MAX_LOG_DAYS = 7;
3195
3339
  try {
@@ -3197,16 +3341,16 @@ var init_logger = __esm({
3197
3341
  } catch {
3198
3342
  }
3199
3343
  currentDate = getDateStr();
3200
- currentLogFile = path9.join(LOG_DIR, `daemon-${currentDate}.log`);
3344
+ currentLogFile = path10.join(LOG_DIR, `daemon-${currentDate}.log`);
3201
3345
  cleanOldLogs();
3202
3346
  try {
3203
- const oldLog = path9.join(LOG_DIR, "daemon.log");
3347
+ const oldLog = path10.join(LOG_DIR, "daemon.log");
3204
3348
  if (fs2.existsSync(oldLog)) {
3205
3349
  const stat5 = fs2.statSync(oldLog);
3206
3350
  const oldDate = stat5.mtime.toISOString().slice(0, 10);
3207
- fs2.renameSync(oldLog, path9.join(LOG_DIR, `daemon-${oldDate}.log`));
3351
+ fs2.renameSync(oldLog, path10.join(LOG_DIR, `daemon-${oldDate}.log`));
3208
3352
  }
3209
- const oldLogBackup = path9.join(LOG_DIR, "daemon.log.old");
3353
+ const oldLogBackup = path10.join(LOG_DIR, "daemon.log.old");
3210
3354
  if (fs2.existsSync(oldLogBackup)) {
3211
3355
  fs2.unlinkSync(oldLogBackup);
3212
3356
  }
@@ -3238,7 +3382,7 @@ var init_logger = __esm({
3238
3382
  }
3239
3383
  };
3240
3384
  interceptorInstalled = false;
3241
- LOG_PATH = path9.join(LOG_DIR, `daemon-${getDateStr()}.log`);
3385
+ LOG_PATH = path10.join(LOG_DIR, `daemon-${getDateStr()}.log`);
3242
3386
  }
3243
3387
  });
3244
3388
 
@@ -5428,7 +5572,7 @@ function extractSavedHistorySessionIdFromFile(file2) {
5428
5572
  function buildSavedHistoryFileSignatureMap(dir, files) {
5429
5573
  return new Map(files.map((file2) => {
5430
5574
  try {
5431
- const stat5 = fs3.statSync(path10.join(dir, file2));
5575
+ const stat5 = fs3.statSync(path11.join(dir, file2));
5432
5576
  return [file2, `${file2}:${stat5.size}:${Math.trunc(stat5.mtimeMs)}`];
5433
5577
  } catch {
5434
5578
  return [file2, `${file2}:missing`];
@@ -5439,7 +5583,7 @@ function buildSavedHistoryCacheSignature(files, fileSignatures) {
5439
5583
  return files.map((file2) => fileSignatures.get(file2) || `${file2}:missing`).join("|");
5440
5584
  }
5441
5585
  function getSavedHistoryIndexFilePath(dir) {
5442
- return path10.join(dir, SAVED_HISTORY_INDEX_FILE);
5586
+ return path11.join(dir, SAVED_HISTORY_INDEX_FILE);
5443
5587
  }
5444
5588
  function getSavedHistoryIndexLockPath(dir) {
5445
5589
  return `${getSavedHistoryIndexFilePath(dir)}${SAVED_HISTORY_INDEX_LOCK_SUFFIX}`;
@@ -5541,7 +5685,7 @@ function savePersistedSavedHistoryIndex(dir, entries) {
5541
5685
  }
5542
5686
  for (const file2 of Array.from(currentEntries.keys())) {
5543
5687
  if (incomingFiles.has(file2)) continue;
5544
- if (!fs3.existsSync(path10.join(dir, file2))) {
5688
+ if (!fs3.existsSync(path11.join(dir, file2))) {
5545
5689
  currentEntries.delete(file2);
5546
5690
  }
5547
5691
  }
@@ -5567,7 +5711,7 @@ function historyDirectoryHasFilesNewerThanIndex(dir) {
5567
5711
  const indexStat = fs3.statSync(getSavedHistoryIndexFilePath(dir));
5568
5712
  const files = listHistoryFiles(dir);
5569
5713
  for (const file2 of files) {
5570
- const stat5 = fs3.statSync(path10.join(dir, file2));
5714
+ const stat5 = fs3.statSync(path11.join(dir, file2));
5571
5715
  if (stat5.mtimeMs > indexStat.mtimeMs) return true;
5572
5716
  }
5573
5717
  return false;
@@ -5577,14 +5721,14 @@ function historyDirectoryHasFilesNewerThanIndex(dir) {
5577
5721
  }
5578
5722
  function buildSavedHistoryFileSignature(dir, file2) {
5579
5723
  try {
5580
- const stat5 = fs3.statSync(path10.join(dir, file2));
5724
+ const stat5 = fs3.statSync(path11.join(dir, file2));
5581
5725
  return `${file2}:${stat5.size}:${Math.trunc(stat5.mtimeMs)}`;
5582
5726
  } catch {
5583
5727
  return `${file2}:missing`;
5584
5728
  }
5585
5729
  }
5586
5730
  function persistSavedHistoryFileSummaryEntry(agentType, dir, file2, updater) {
5587
- const filePath = path10.join(dir, file2);
5731
+ const filePath = path11.join(dir, file2);
5588
5732
  const result = withLockedPersistedSavedHistoryIndex(dir, (entries) => {
5589
5733
  const currentEntry = entries.get(file2) || null;
5590
5734
  const nextSummary = updater(currentEntry?.summary || null);
@@ -5657,7 +5801,7 @@ function updateSavedHistoryIndexForAppendedMessages(agentType, dir, file2, histo
5657
5801
  function computeSavedHistoryFileSummary(dir, file2) {
5658
5802
  const historySessionId = extractSavedHistorySessionIdFromFile(file2);
5659
5803
  if (!historySessionId) return null;
5660
- const filePath = path10.join(dir, file2);
5804
+ const filePath = path11.join(dir, file2);
5661
5805
  const content = fs3.readFileSync(filePath, "utf-8");
5662
5806
  const lines = content.split("\n").filter(Boolean);
5663
5807
  let messageCount = 0;
@@ -5744,7 +5888,7 @@ function computeSavedHistorySessionSummaries(agentType, dir, files, fileSignatur
5744
5888
  const summaryBySessionId = /* @__PURE__ */ new Map();
5745
5889
  const nextPersistedEntries = /* @__PURE__ */ new Map();
5746
5890
  for (const file2 of files.slice().sort()) {
5747
- const filePath = path10.join(dir, file2);
5891
+ const filePath = path11.join(dir, file2);
5748
5892
  const signature = fileSignatures.get(file2) || `${file2}:missing`;
5749
5893
  const cached2 = savedHistoryFileSummaryCache.get(filePath);
5750
5894
  const persisted = persistedEntries.get(file2);
@@ -5826,13 +5970,13 @@ function pageHistoryRecords(agentType, records, offset = 0, limit = 30, excludeR
5826
5970
  function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, excludeRecentCount = 0, historyBehavior) {
5827
5971
  try {
5828
5972
  const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
5829
- const dir = path10.join(HISTORY_DIR, sanitized);
5973
+ const dir = path11.join(HISTORY_DIR, sanitized);
5830
5974
  if (!fs3.existsSync(dir)) return { messages: [], hasMore: false };
5831
5975
  const files = listHistoryFiles(dir, historySessionId);
5832
5976
  const allMessages = [];
5833
5977
  const seen = /* @__PURE__ */ new Set();
5834
5978
  for (const file2 of files) {
5835
- const filePath = path10.join(dir, file2);
5979
+ const filePath = path11.join(dir, file2);
5836
5980
  const content = fs3.readFileSync(filePath, "utf-8");
5837
5981
  const lines = content.trim().split("\n").filter(Boolean);
5838
5982
  for (let i = 0; i < lines.length; i++) {
@@ -5856,7 +6000,7 @@ function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, ex
5856
6000
  function listSavedHistorySessions(agentType, options = {}, historyBehavior) {
5857
6001
  try {
5858
6002
  const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
5859
- const dir = path10.join(HISTORY_DIR, sanitized);
6003
+ const dir = path11.join(HISTORY_DIR, sanitized);
5860
6004
  if (!fs3.existsSync(dir)) {
5861
6005
  savedHistorySessionCache.delete(sanitized);
5862
6006
  return { sessions: [], hasMore: false };
@@ -5917,11 +6061,11 @@ function listSavedHistorySessions(agentType, options = {}, historyBehavior) {
5917
6061
  }
5918
6062
  function readExistingSessionStartRecord(agentType, historySessionId) {
5919
6063
  try {
5920
- const dir = path10.join(HISTORY_DIR, agentType);
6064
+ const dir = path11.join(HISTORY_DIR, agentType);
5921
6065
  if (!fs3.existsSync(dir)) return null;
5922
6066
  const files = listHistoryFiles(dir, historySessionId).sort();
5923
6067
  for (const file2 of files) {
5924
- const lines = fs3.readFileSync(path10.join(dir, file2), "utf-8").split("\n").filter(Boolean);
6068
+ const lines = fs3.readFileSync(path11.join(dir, file2), "utf-8").split("\n").filter(Boolean);
5925
6069
  for (const line of lines) {
5926
6070
  try {
5927
6071
  const parsed = JSON.parse(line);
@@ -5941,16 +6085,16 @@ function readExistingSessionStartRecord(agentType, historySessionId) {
5941
6085
  function rewriteCanonicalSavedHistory(agentType, historySessionId, records) {
5942
6086
  if (records.length === 0) return false;
5943
6087
  try {
5944
- const dir = path10.join(HISTORY_DIR, agentType);
6088
+ const dir = path11.join(HISTORY_DIR, agentType);
5945
6089
  fs3.mkdirSync(dir, { recursive: true });
5946
6090
  const prefix = `${historySessionId.replace(/[^a-zA-Z0-9_-]/g, "_")}_`;
5947
6091
  for (const file2 of fs3.readdirSync(dir)) {
5948
6092
  if (file2.startsWith(prefix) && file2.endsWith(".jsonl")) {
5949
- fs3.unlinkSync(path10.join(dir, file2));
6093
+ fs3.unlinkSync(path11.join(dir, file2));
5950
6094
  }
5951
6095
  }
5952
6096
  const targetDate = new Date(records[records.length - 1].receivedAt || Date.now()).toISOString().slice(0, 10);
5953
- const filePath = path10.join(dir, `${prefix}${targetDate}.jsonl`);
6097
+ const filePath = path11.join(dir, `${prefix}${targetDate}.jsonl`);
5954
6098
  fs3.writeFileSync(filePath, `${records.map((record2) => JSON.stringify(record2)).join("\n")}
5955
6099
  `, "utf-8");
5956
6100
  invalidatePersistedSavedHistoryIndex(agentType, dir);
@@ -6148,15 +6292,15 @@ function listProviderHistorySessions(agentType, options = {}) {
6148
6292
  source: "adhdev-mirror"
6149
6293
  };
6150
6294
  }
6151
- var fs3, path10, os5, HISTORY_DIR, RETAIN_DAYS, SAVED_HISTORY_INDEX_VERSION, SAVED_HISTORY_INDEX_FILE, SAVED_HISTORY_INDEX_LOCK_SUFFIX, SAVED_HISTORY_INDEX_LOCK_WAIT_MS, SAVED_HISTORY_INDEX_LOCK_STALE_MS, SAVED_HISTORY_INDEX_LOCK_POLL_MS, SAVED_HISTORY_ROLLUP_THRESHOLD_BYTES, savedHistorySessionCache, savedHistoryFileSummaryCache, savedHistoryBackgroundRefresh, savedHistoryRollupInFlight, ChatHistoryWriter;
6295
+ var fs3, path11, os5, HISTORY_DIR, RETAIN_DAYS, SAVED_HISTORY_INDEX_VERSION, SAVED_HISTORY_INDEX_FILE, SAVED_HISTORY_INDEX_LOCK_SUFFIX, SAVED_HISTORY_INDEX_LOCK_WAIT_MS, SAVED_HISTORY_INDEX_LOCK_STALE_MS, SAVED_HISTORY_INDEX_LOCK_POLL_MS, SAVED_HISTORY_ROLLUP_THRESHOLD_BYTES, savedHistorySessionCache, savedHistoryFileSummaryCache, savedHistoryBackgroundRefresh, savedHistoryRollupInFlight, ChatHistoryWriter;
6152
6296
  var init_chat_history = __esm({
6153
6297
  "../../oss/packages/daemon-core/src/config/chat-history.ts"() {
6154
6298
  "use strict";
6155
6299
  fs3 = __toESM(require("fs"));
6156
- path10 = __toESM(require("path"));
6300
+ path11 = __toESM(require("path"));
6157
6301
  os5 = __toESM(require("os"));
6158
6302
  init_chat_message_normalization();
6159
- HISTORY_DIR = path10.join(os5.homedir(), ".adhdev", "history");
6303
+ HISTORY_DIR = path11.join(os5.homedir(), ".adhdev", "history");
6160
6304
  RETAIN_DAYS = 30;
6161
6305
  SAVED_HISTORY_INDEX_VERSION = 1;
6162
6306
  SAVED_HISTORY_INDEX_FILE = ".saved-history-index.json";
@@ -6238,12 +6382,12 @@ var init_chat_history = __esm({
6238
6382
  });
6239
6383
  }
6240
6384
  if (newMessages.length === 0) return;
6241
- const dir = path10.join(HISTORY_DIR, this.sanitize(agentType));
6385
+ const dir = path11.join(HISTORY_DIR, this.sanitize(agentType));
6242
6386
  fs3.mkdirSync(dir, { recursive: true });
6243
6387
  const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
6244
6388
  const filePrefix = effectiveHistoryKey ? `${this.sanitize(effectiveHistoryKey)}_` : "";
6245
6389
  const fileName = `${filePrefix}${date5}.jsonl`;
6246
- const filePath = path10.join(dir, fileName);
6390
+ const filePath = path11.join(dir, fileName);
6247
6391
  const lines = newMessages.map((m) => JSON.stringify(m)).join("\n") + "\n";
6248
6392
  fs3.appendFileSync(filePath, lines, "utf-8");
6249
6393
  updateSavedHistoryIndexForAppendedMessages(agentType, dir, fileName, effectiveHistoryKey, newMessages);
@@ -6334,11 +6478,11 @@ var init_chat_history = __esm({
6334
6478
  const ws = String(workspace || "").trim();
6335
6479
  if (!id || !ws) return;
6336
6480
  try {
6337
- const dir = path10.join(HISTORY_DIR, this.sanitize(agentType));
6481
+ const dir = path11.join(HISTORY_DIR, this.sanitize(agentType));
6338
6482
  fs3.mkdirSync(dir, { recursive: true });
6339
6483
  const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
6340
6484
  const fileName = `${this.sanitize(id)}_${date5}.jsonl`;
6341
- const filePath = path10.join(dir, fileName);
6485
+ const filePath = path11.join(dir, fileName);
6342
6486
  const record2 = {
6343
6487
  ts: (/* @__PURE__ */ new Date()).toISOString(),
6344
6488
  receivedAt: Date.now(),
@@ -6384,14 +6528,14 @@ var init_chat_history = __esm({
6384
6528
  this.lastSeenCounts.set(toDedupKey, Math.max(fromCount, this.lastSeenCounts.get(toDedupKey) || 0));
6385
6529
  this.lastSeenCounts.delete(fromDedupKey);
6386
6530
  }
6387
- const dir = path10.join(HISTORY_DIR, this.sanitize(agentType));
6531
+ const dir = path11.join(HISTORY_DIR, this.sanitize(agentType));
6388
6532
  if (!fs3.existsSync(dir)) return;
6389
6533
  const fromPrefix = `${this.sanitize(fromId)}_`;
6390
6534
  const toPrefix = `${this.sanitize(toId)}_`;
6391
6535
  const files = fs3.readdirSync(dir).filter((file2) => file2.startsWith(fromPrefix) && file2.endsWith(".jsonl"));
6392
6536
  for (const file2 of files) {
6393
- const sourcePath = path10.join(dir, file2);
6394
- const targetPath = path10.join(dir, `${toPrefix}${file2.slice(fromPrefix.length)}`);
6537
+ const sourcePath = path11.join(dir, file2);
6538
+ const targetPath = path11.join(dir, `${toPrefix}${file2.slice(fromPrefix.length)}`);
6395
6539
  const sourceLines = fs3.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
6396
6540
  const rewritten = sourceLines.map((line) => {
6397
6541
  try {
@@ -6425,13 +6569,13 @@ var init_chat_history = __esm({
6425
6569
  const sessionId = String(historySessionId || "").trim();
6426
6570
  if (!sessionId) return;
6427
6571
  try {
6428
- const dir = path10.join(HISTORY_DIR, this.sanitize(agentType));
6572
+ const dir = path11.join(HISTORY_DIR, this.sanitize(agentType));
6429
6573
  if (!fs3.existsSync(dir)) return;
6430
6574
  const prefix = `${this.sanitize(sessionId)}_`;
6431
6575
  const files = fs3.readdirSync(dir).filter((file2) => file2.startsWith(prefix) && file2.endsWith(".jsonl")).sort();
6432
6576
  const seen = /* @__PURE__ */ new Set();
6433
6577
  for (const file2 of files) {
6434
- const filePath = path10.join(dir, file2);
6578
+ const filePath = path11.join(dir, file2);
6435
6579
  const lines = fs3.readFileSync(filePath, "utf-8").split("\n").filter(Boolean);
6436
6580
  const next = [];
6437
6581
  for (const line of lines) {
@@ -6485,11 +6629,11 @@ var init_chat_history = __esm({
6485
6629
  const cutoff = Date.now() - RETAIN_DAYS * 24 * 60 * 60 * 1e3;
6486
6630
  const agentDirs = fs3.readdirSync(HISTORY_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
6487
6631
  for (const dir of agentDirs) {
6488
- const dirPath = path10.join(HISTORY_DIR, dir.name);
6632
+ const dirPath = path11.join(HISTORY_DIR, dir.name);
6489
6633
  const files = fs3.readdirSync(dirPath).filter((f) => f.endsWith(".jsonl") || f.endsWith(".terminal.log"));
6490
6634
  let removedAny = false;
6491
6635
  for (const file2 of files) {
6492
- const filePath = path10.join(dirPath, file2);
6636
+ const filePath = path11.join(dirPath, file2);
6493
6637
  const stat5 = fs3.statSync(filePath);
6494
6638
  if (stat5.mtimeMs < cutoff) {
6495
6639
  fs3.unlinkSync(filePath);
@@ -8397,6 +8541,14 @@ function getActiveChatOptions(profile) {
8397
8541
  if (profile === "full") return {};
8398
8542
  return LIVE_STATUS_ACTIVE_CHAT_OPTIONS;
8399
8543
  }
8544
+ function resolveSessionStatus(activeChat, providerStatus) {
8545
+ const chatStatus = normalizeManagedStatus(activeChat?.status, { activeModal: activeChat?.activeModal || null });
8546
+ const topLevelStatus = normalizeManagedStatus(providerStatus, { activeModal: activeChat?.activeModal || null });
8547
+ if (chatStatus === "waiting_approval" || topLevelStatus === "waiting_approval") return "waiting_approval";
8548
+ if (chatStatus === "generating" || topLevelStatus === "generating") return "generating";
8549
+ if (topLevelStatus !== "idle") return topLevelStatus;
8550
+ return chatStatus;
8551
+ }
8400
8552
  function shouldIncludeSessionControls(profile) {
8401
8553
  return profile !== "live";
8402
8554
  }
@@ -8452,9 +8604,7 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
8452
8604
  providerName: state.name,
8453
8605
  kind: "workspace",
8454
8606
  transport: "cdp-page",
8455
- status: normalizeManagedStatus(activeChat?.status || state.status, {
8456
- activeModal: activeChat?.activeModal || null
8457
- }),
8607
+ status: resolveSessionStatus(activeChat, state.status),
8458
8608
  title,
8459
8609
  workspace,
8460
8610
  ...git && { git },
@@ -8489,9 +8639,7 @@ function buildExtensionAgentSession(parent, ext, options) {
8489
8639
  providerSessionId: ext.providerSessionId,
8490
8640
  kind: "agent",
8491
8641
  transport: "cdp-webview",
8492
- status: normalizeManagedStatus(activeChat?.status || ext.status, {
8493
- activeModal: activeChat?.activeModal || null
8494
- }),
8642
+ status: resolveSessionStatus(activeChat, ext.status),
8495
8643
  title: activeChat?.title || ext.name,
8496
8644
  workspace,
8497
8645
  ...git && { git },
@@ -8541,9 +8689,7 @@ function buildCliSession(state, options) {
8541
8689
  providerSessionId: state.providerSessionId,
8542
8690
  kind: "agent",
8543
8691
  transport: "pty",
8544
- status: normalizeManagedStatus(activeChat?.status || state.status, {
8545
- activeModal: activeChat?.activeModal || null
8546
- }),
8692
+ status: resolveSessionStatus(activeChat, state.status),
8547
8693
  title: activeChat?.title || state.name,
8548
8694
  workspace,
8549
8695
  ...git && { git },
@@ -8591,9 +8737,7 @@ function buildAcpSession(state, options) {
8591
8737
  providerName: state.name,
8592
8738
  kind: "agent",
8593
8739
  transport: "acp",
8594
- status: normalizeManagedStatus(activeChat?.status || state.status, {
8595
- activeModal: activeChat?.activeModal || null
8596
- }),
8740
+ status: resolveSessionStatus(activeChat, state.status),
8597
8741
  title: activeChat?.title || state.name,
8598
8742
  workspace,
8599
8743
  ...git && { git },
@@ -9317,7 +9461,7 @@ function buildDebugBundleText(bundle) {
9317
9461
  }
9318
9462
  function getChatDebugBundleDir() {
9319
9463
  const override = typeof process.env.ADHDEV_DEBUG_BUNDLE_DIR === "string" ? process.env.ADHDEV_DEBUG_BUNDLE_DIR.trim() : "";
9320
- return override || path11.join(os6.homedir(), ".adhdev", "debug-bundles", "chat");
9464
+ return override || path12.join(os6.homedir(), ".adhdev", "debug-bundles", "chat");
9321
9465
  }
9322
9466
  function safeBundleIdSegment(value, fallback2) {
9323
9467
  const normalized = String(value || fallback2).trim().replace(/[^A-Za-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
@@ -9350,7 +9494,7 @@ function storeChatDebugBundleOnDaemon(bundle, targetSessionId) {
9350
9494
  const bundleId = createChatDebugBundleId(targetSessionId);
9351
9495
  const dir = getChatDebugBundleDir();
9352
9496
  fs4.mkdirSync(dir, { recursive: true });
9353
- const savedPath = path11.join(dir, `${bundleId}.json`);
9497
+ const savedPath = path12.join(dir, `${bundleId}.json`);
9354
9498
  const json2 = `${JSON.stringify(bundle, null, 2)}
9355
9499
  `;
9356
9500
  fs4.writeFileSync(savedPath, json2, { encoding: "utf8", mode: 384 });
@@ -10491,13 +10635,13 @@ async function handleResolveAction(h, args) {
10491
10635
  }
10492
10636
  return { success: false, error: "resolveAction script not available for this provider" };
10493
10637
  }
10494
- var fs4, os6, path11, import_node_crypto, RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN;
10638
+ var fs4, os6, path12, import_node_crypto, RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN;
10495
10639
  var init_chat_commands = __esm({
10496
10640
  "../../oss/packages/daemon-core/src/commands/chat-commands.ts"() {
10497
10641
  "use strict";
10498
10642
  fs4 = __toESM(require("fs"));
10499
10643
  os6 = __toESM(require("os"));
10500
- path11 = __toESM(require("path"));
10644
+ path12 = __toESM(require("path"));
10501
10645
  import_node_crypto = require("crypto");
10502
10646
  init_contracts();
10503
10647
  init_provider_input_support();
@@ -10740,25 +10884,25 @@ function resolveSafePath(requestedPath) {
10740
10884
  const inputPath = rawPath || ".";
10741
10885
  const home = os7.homedir();
10742
10886
  if (inputPath.startsWith("~")) {
10743
- return path12.resolve(path12.join(home, inputPath.slice(1)));
10887
+ return path13.resolve(path13.join(home, inputPath.slice(1)));
10744
10888
  }
10745
10889
  if (process.platform === "win32") {
10746
10890
  const normalized = normalizeWindowsRequestedPath(inputPath);
10747
- if (path12.win32.isAbsolute(normalized)) {
10748
- return path12.win32.normalize(normalized);
10891
+ if (path13.win32.isAbsolute(normalized)) {
10892
+ return path13.win32.normalize(normalized);
10749
10893
  }
10750
- return path12.win32.resolve(normalized);
10894
+ return path13.win32.resolve(normalized);
10751
10895
  }
10752
- if (path12.isAbsolute(inputPath)) {
10753
- return path12.normalize(inputPath);
10896
+ if (path13.isAbsolute(inputPath)) {
10897
+ return path13.normalize(inputPath);
10754
10898
  }
10755
- return path12.resolve(inputPath);
10899
+ return path13.resolve(inputPath);
10756
10900
  }
10757
10901
  function listDirectoryEntriesSafe(dirPath) {
10758
10902
  const entries = fs5.readdirSync(dirPath, { withFileTypes: true });
10759
10903
  const files = [];
10760
10904
  for (const entry of entries) {
10761
- const entryPath = path12.join(dirPath, entry.name);
10905
+ const entryPath = path13.join(dirPath, entry.name);
10762
10906
  try {
10763
10907
  if (entry.isDirectory()) {
10764
10908
  files.push({ name: entry.name, type: "directory" });
@@ -10812,7 +10956,7 @@ async function handleFileRead(h, args) {
10812
10956
  async function handleFileWrite(h, args) {
10813
10957
  try {
10814
10958
  const filePath = resolveSafePath(args?.path);
10815
- fs5.mkdirSync(path12.dirname(filePath), { recursive: true });
10959
+ fs5.mkdirSync(path13.dirname(filePath), { recursive: true });
10816
10960
  fs5.writeFileSync(filePath, args?.content || "", "utf-8");
10817
10961
  return { success: true, path: filePath };
10818
10962
  } catch (e) {
@@ -10845,12 +10989,12 @@ async function handleFileListBrowse(h, args) {
10845
10989
  return { success: false, error: e.message };
10846
10990
  }
10847
10991
  }
10848
- var fs5, path12, os7, KEY_TO_VK;
10992
+ var fs5, path13, os7, KEY_TO_VK;
10849
10993
  var init_cdp_commands = __esm({
10850
10994
  "../../oss/packages/daemon-core/src/commands/cdp-commands.ts"() {
10851
10995
  "use strict";
10852
10996
  fs5 = __toESM(require("fs"));
10853
- path12 = __toESM(require("path"));
10997
+ path13 = __toESM(require("path"));
10854
10998
  os7 = __toESM(require("os"));
10855
10999
  KEY_TO_VK = {
10856
11000
  Backspace: 8,
@@ -13148,9 +13292,9 @@ function buildCliScreenSnapshot(text) {
13148
13292
  function findBinary(name) {
13149
13293
  const trimmed = String(name || "").trim();
13150
13294
  if (!trimmed) return trimmed;
13151
- const expanded = trimmed.startsWith("~") ? path13.join(os11.homedir(), trimmed.slice(1)) : trimmed;
13152
- if (path13.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
13153
- return path13.isAbsolute(expanded) ? expanded : path13.resolve(expanded);
13295
+ const expanded = trimmed.startsWith("~") ? path14.join(os11.homedir(), trimmed.slice(1)) : trimmed;
13296
+ if (path14.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
13297
+ return path14.isAbsolute(expanded) ? expanded : path14.resolve(expanded);
13154
13298
  }
13155
13299
  const isWin = os11.platform() === "win32";
13156
13300
  try {
@@ -13166,7 +13310,7 @@ function findBinary(name) {
13166
13310
  }
13167
13311
  }
13168
13312
  function isScriptBinary(binaryPath) {
13169
- if (!path13.isAbsolute(binaryPath)) return false;
13313
+ if (!path14.isAbsolute(binaryPath)) return false;
13170
13314
  try {
13171
13315
  const fs20 = require("fs");
13172
13316
  const resolved = fs20.realpathSync(binaryPath);
@@ -13182,7 +13326,7 @@ function isScriptBinary(binaryPath) {
13182
13326
  }
13183
13327
  }
13184
13328
  function looksLikeMachOOrElf(filePath) {
13185
- if (!path13.isAbsolute(filePath)) return false;
13329
+ if (!path14.isAbsolute(filePath)) return false;
13186
13330
  try {
13187
13331
  const fs20 = require("fs");
13188
13332
  const resolved = fs20.realpathSync(filePath);
@@ -13271,12 +13415,12 @@ function normalizeCliProviderForRuntime(raw) {
13271
13415
  }
13272
13416
  };
13273
13417
  }
13274
- var os11, path13, import_child_process4, buildCliSpawnEnv;
13418
+ var os11, path14, import_child_process4, buildCliSpawnEnv;
13275
13419
  var init_provider_cli_shared = __esm({
13276
13420
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-shared.ts"() {
13277
13421
  "use strict";
13278
13422
  os11 = __toESM(require("os"));
13279
- path13 = __toESM(require("path"));
13423
+ path14 = __toESM(require("path"));
13280
13424
  import_child_process4 = require("child_process");
13281
13425
  init_spawn_env();
13282
13426
  buildCliSpawnEnv = sanitizeSpawnEnv;
@@ -13407,9 +13551,9 @@ function resolveCliSpawnPlan(options) {
13407
13551
  const allArgs = [...spawnConfig.args, ...extraArgs];
13408
13552
  let shellCmd;
13409
13553
  let shellArgs;
13410
- const useShellUnix = !isWin && (!!spawnConfig.shell || !path14.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
13554
+ const useShellUnix = !isWin && (!!spawnConfig.shell || !path15.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
13411
13555
  const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
13412
- const useShellWin = !!spawnConfig.shell || isCmdShim || !path14.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
13556
+ const useShellWin = !!spawnConfig.shell || isCmdShim || !path15.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
13413
13557
  const useShell = isWin ? useShellWin : useShellUnix;
13414
13558
  if (useShell) {
13415
13559
  shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
@@ -13485,12 +13629,12 @@ function respondToCliTerminalQueries(options) {
13485
13629
  }
13486
13630
  return "";
13487
13631
  }
13488
- var os12, path14;
13632
+ var os12, path15;
13489
13633
  var init_provider_cli_runtime = __esm({
13490
13634
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-runtime.ts"() {
13491
13635
  "use strict";
13492
13636
  os12 = __toESM(require("os"));
13493
- path14 = __toESM(require("path"));
13637
+ path15 = __toESM(require("path"));
13494
13638
  init_dist();
13495
13639
  init_provider_cli_shared();
13496
13640
  }
@@ -13678,8 +13822,9 @@ var init_provider_cli_adapter = __esm({
13678
13822
  const currentSnapshot = normalizeScreenSnapshot(screenText);
13679
13823
  const lastSnapshot = this.lastScreenSnapshot;
13680
13824
  if (!lastSnapshot || lastSnapshot === currentSnapshot) return screenText;
13681
- const staleSnapshotLooksActive = /\besc to (?:interrupt|stop)\b|Enter to interrupt, Ctrl\+C to cancel/i.test(lastSnapshot);
13682
- const currentScreenLooksIdle = /(?:^|\n|\r)\s*[❯›>]\s*(?:\n|\r|$)/.test(screenText) && !/\besc to (?:interrupt|stop)\b|Enter to interrupt, Ctrl\+C to cancel/i.test(screenText);
13825
+ const activeScreenPattern = /\besc to (?:interrupt|stop)\b|Enter to interrupt, Ctrl\+C to cancel|Enter to confirm\s*[·•-]\s*Esc to cancel|\b(?:MCP servers?|tool calls?)\b[^\n\r]{0,160}\brequire approval\b/i;
13826
+ const staleSnapshotLooksActive = activeScreenPattern.test(lastSnapshot);
13827
+ const currentScreenLooksIdle = /(?:^|\n|\r)\s*[❯›>]\s*(?:Try\s+["“][^\n\r"”]+["”])?\s*(?:\n|\r|$)/.test(screenText) && !activeScreenPattern.test(screenText);
13683
13828
  if (staleSnapshotLooksActive && currentScreenLooksIdle) return screenText;
13684
13829
  if (currentSnapshot.length >= lastSnapshot.length) return screenText;
13685
13830
  return `${screenText}
@@ -15615,7 +15760,7 @@ function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages
15615
15760
  }
15616
15761
  function getDatabaseSync() {
15617
15762
  if (CachedDatabaseSync) return CachedDatabaseSync;
15618
- const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path15.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
15763
+ const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path16.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
15619
15764
  const sqliteModule = requireFn(`node:${"sqlite"}`);
15620
15765
  CachedDatabaseSync = sqliteModule.DatabaseSync;
15621
15766
  if (!CachedDatabaseSync) {
@@ -15657,12 +15802,12 @@ async function waitForCliAdapterReady(adapter, options) {
15657
15802
  }
15658
15803
  throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
15659
15804
  }
15660
- var os14, path15, crypto3, fs6, import_node_module, CachedDatabaseSync, CliProviderInstance;
15805
+ var os14, path16, crypto3, fs6, import_node_module, CachedDatabaseSync, CliProviderInstance;
15661
15806
  var init_cli_provider_instance = __esm({
15662
15807
  "../../oss/packages/daemon-core/src/providers/cli-provider-instance.ts"() {
15663
15808
  "use strict";
15664
15809
  os14 = __toESM(require("os"));
15665
- path15 = __toESM(require("path"));
15810
+ path16 = __toESM(require("path"));
15666
15811
  crypto3 = __toESM(require("crypto"));
15667
15812
  fs6 = __toESM(require("fs"));
15668
15813
  import_node_module = require("module");
@@ -16798,10 +16943,10 @@ function mergeDefs(...defs) {
16798
16943
  function cloneDef(schema) {
16799
16944
  return mergeDefs(schema._zod.def);
16800
16945
  }
16801
- function getElementAtPath(obj, path33) {
16802
- if (!path33)
16946
+ function getElementAtPath(obj, path34) {
16947
+ if (!path34)
16803
16948
  return obj;
16804
- return path33.reduce((acc, key) => acc?.[key], obj);
16949
+ return path34.reduce((acc, key) => acc?.[key], obj);
16805
16950
  }
16806
16951
  function promiseAllObject(promisesObj) {
16807
16952
  const keys = Object.keys(promisesObj);
@@ -17113,11 +17258,11 @@ function aborted(x, startIndex = 0) {
17113
17258
  }
17114
17259
  return false;
17115
17260
  }
17116
- function prefixIssues(path33, issues) {
17261
+ function prefixIssues(path34, issues) {
17117
17262
  return issues.map((iss) => {
17118
17263
  var _a2;
17119
17264
  (_a2 = iss).path ?? (_a2.path = []);
17120
- iss.path.unshift(path33);
17265
+ iss.path.unshift(path34);
17121
17266
  return iss;
17122
17267
  });
17123
17268
  }
@@ -17360,7 +17505,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
17360
17505
  }
17361
17506
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
17362
17507
  const result = { errors: [] };
17363
- const processError = (error49, path33 = []) => {
17508
+ const processError = (error49, path34 = []) => {
17364
17509
  var _a2, _b;
17365
17510
  for (const issue2 of error49.issues) {
17366
17511
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -17370,7 +17515,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
17370
17515
  } else if (issue2.code === "invalid_element") {
17371
17516
  processError({ issues: issue2.issues }, issue2.path);
17372
17517
  } else {
17373
- const fullpath = [...path33, ...issue2.path];
17518
+ const fullpath = [...path34, ...issue2.path];
17374
17519
  if (fullpath.length === 0) {
17375
17520
  result.errors.push(mapper(issue2));
17376
17521
  continue;
@@ -17402,8 +17547,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
17402
17547
  }
17403
17548
  function toDotPath(_path) {
17404
17549
  const segs = [];
17405
- const path33 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
17406
- for (const seg of path33) {
17550
+ const path34 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
17551
+ for (const seg of path34) {
17407
17552
  if (typeof seg === "number")
17408
17553
  segs.push(`[${seg}]`);
17409
17554
  else if (typeof seg === "symbol")
@@ -30167,13 +30312,13 @@ function resolveRef(ref, ctx) {
30167
30312
  if (!ref.startsWith("#")) {
30168
30313
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
30169
30314
  }
30170
- const path33 = ref.slice(1).split("/").filter(Boolean);
30171
- if (path33.length === 0) {
30315
+ const path34 = ref.slice(1).split("/").filter(Boolean);
30316
+ if (path34.length === 0) {
30172
30317
  return ctx.rootSchema;
30173
30318
  }
30174
30319
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
30175
- if (path33[0] === defsKey) {
30176
- const key = path33[1];
30320
+ if (path34[0] === defsKey) {
30321
+ const key = path34[1];
30177
30322
  if (!key || !ctx.defs[key]) {
30178
30323
  throw new Error(`Reference not found: ${ref}`);
30179
30324
  }
@@ -34019,11 +34164,11 @@ var init_hosted_runtime_restore = __esm({
34019
34164
  // ../../oss/packages/daemon-core/src/commands/cli-manager.ts
34020
34165
  function isExplicitCommand(command) {
34021
34166
  const trimmed = command.trim();
34022
- return path16.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
34167
+ return path17.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
34023
34168
  }
34024
34169
  function expandExecutable(command) {
34025
34170
  const trimmed = command.trim();
34026
- return trimmed.startsWith("~") ? path16.join(os15.homedir(), trimmed.slice(1)) : trimmed;
34171
+ return trimmed.startsWith("~") ? path17.join(os15.homedir(), trimmed.slice(1)) : trimmed;
34027
34172
  }
34028
34173
  function commandExists(command) {
34029
34174
  const trimmed = command.trim();
@@ -34160,12 +34305,12 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
34160
34305
  launchMode: "new"
34161
34306
  };
34162
34307
  }
34163
- var os15, path16, crypto4, import_fs6, import_child_process6, chalkModule, chalkApi, DaemonCliManager;
34308
+ var os15, path17, crypto4, import_fs6, import_child_process6, chalkModule, chalkApi, DaemonCliManager;
34164
34309
  var init_cli_manager = __esm({
34165
34310
  "../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
34166
34311
  "use strict";
34167
34312
  os15 = __toESM(require("os"));
34168
- path16 = __toESM(require("path"));
34313
+ path17 = __toESM(require("path"));
34169
34314
  crypto4 = __toESM(require("crypto"));
34170
34315
  import_fs6 = require("fs");
34171
34316
  import_child_process6 = require("child_process");
@@ -34328,7 +34473,7 @@ var init_cli_manager = __esm({
34328
34473
  async startSession(cliType, workingDir, cliArgs, initialModel, options) {
34329
34474
  const trimmed = (workingDir || "").trim();
34330
34475
  if (!trimmed) throw new Error("working directory required");
34331
- const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os15.homedir()) : path16.resolve(trimmed);
34476
+ const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os15.homedir()) : path17.resolve(trimmed);
34332
34477
  const normalizedType = this.providerLoader.resolveAlias(cliType);
34333
34478
  const rawProvider = this.providerLoader.getByAlias(cliType);
34334
34479
  const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
@@ -34827,7 +34972,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
34827
34972
  }
34828
34973
  });
34829
34974
 
34830
- // ../../oss/packages/daemon-core/node_modules/readdirp/index.js
34975
+ // ../../oss/node_modules/readdirp/esm/index.js
34831
34976
  function readdirp(root, options = {}) {
34832
34977
  let type = options.entryType || options.type;
34833
34978
  if (type === "both")
@@ -34844,13 +34989,13 @@ function readdirp(root, options = {}) {
34844
34989
  options.root = root;
34845
34990
  return new ReaddirpStream(options);
34846
34991
  }
34847
- var import_promises3, import_node_path, import_node_stream, EntryTypes, defaultOptions, RECURSIVE_ERROR_CODE, NORMAL_FLOW_ERRORS, ALL_TYPES, DIR_TYPES, FILE_TYPES, isNormalFlowError, wantBigintFsStats, emptyFn, normalizeFilter, ReaddirpStream;
34848
- var init_readdirp = __esm({
34849
- "../../oss/packages/daemon-core/node_modules/readdirp/index.js"() {
34992
+ var import_promises4, import_node_stream, import_node_path, EntryTypes, defaultOptions, RECURSIVE_ERROR_CODE, NORMAL_FLOW_ERRORS, ALL_TYPES, DIR_TYPES, FILE_TYPES, isNormalFlowError, wantBigintFsStats, emptyFn, normalizeFilter, ReaddirpStream;
34993
+ var init_esm = __esm({
34994
+ "../../oss/node_modules/readdirp/esm/index.js"() {
34850
34995
  "use strict";
34851
- import_promises3 = require("fs/promises");
34852
- import_node_path = require("path");
34996
+ import_promises4 = require("fs/promises");
34853
34997
  import_node_stream = require("stream");
34998
+ import_node_path = require("path");
34854
34999
  EntryTypes = {
34855
35000
  FILE_TYPE: "files",
34856
35001
  DIR_TYPE: "directories",
@@ -34905,20 +35050,6 @@ var init_readdirp = __esm({
34905
35050
  return emptyFn;
34906
35051
  };
34907
35052
  ReaddirpStream = class extends import_node_stream.Readable {
34908
- parents;
34909
- reading;
34910
- parent;
34911
- _stat;
34912
- _maxDepth;
34913
- _wantsDir;
34914
- _wantsFile;
34915
- _wantsEverything;
34916
- _root;
34917
- _isDirent;
34918
- _statsProp;
34919
- _rdOptions;
34920
- _fileFilter;
34921
- _directoryFilter;
34922
35053
  constructor(options = {}) {
34923
35054
  super({
34924
35055
  objectMode: true,
@@ -34929,13 +35060,13 @@ var init_readdirp = __esm({
34929
35060
  const { root, type } = opts;
34930
35061
  this._fileFilter = normalizeFilter(opts.fileFilter);
34931
35062
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
34932
- const statMethod = opts.lstat ? import_promises3.lstat : import_promises3.stat;
35063
+ const statMethod = opts.lstat ? import_promises4.lstat : import_promises4.stat;
34933
35064
  if (wantBigintFsStats) {
34934
- this._stat = (path33) => statMethod(path33, { bigint: true });
35065
+ this._stat = (path34) => statMethod(path34, { bigint: true });
34935
35066
  } else {
34936
35067
  this._stat = statMethod;
34937
35068
  }
34938
- this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions.depth;
35069
+ this._maxDepth = opts.depth ?? defaultOptions.depth;
34939
35070
  this._wantsDir = type ? DIR_TYPES.has(type) : false;
34940
35071
  this._wantsFile = type ? FILE_TYPES.has(type) : false;
34941
35072
  this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
@@ -34956,8 +35087,8 @@ var init_readdirp = __esm({
34956
35087
  const par = this.parent;
34957
35088
  const fil = par && par.files;
34958
35089
  if (fil && fil.length > 0) {
34959
- const { path: path33, depth } = par;
34960
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path33));
35090
+ const { path: path34, depth } = par;
35091
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path34));
34961
35092
  const awaited = await Promise.all(slice);
34962
35093
  for (const entry of awaited) {
34963
35094
  if (!entry)
@@ -34997,20 +35128,20 @@ var init_readdirp = __esm({
34997
35128
  this.reading = false;
34998
35129
  }
34999
35130
  }
35000
- async _exploreDir(path33, depth) {
35131
+ async _exploreDir(path34, depth) {
35001
35132
  let files;
35002
35133
  try {
35003
- files = await (0, import_promises3.readdir)(path33, this._rdOptions);
35134
+ files = await (0, import_promises4.readdir)(path34, this._rdOptions);
35004
35135
  } catch (error48) {
35005
35136
  this._onError(error48);
35006
35137
  }
35007
- return { files, depth, path: path33 };
35138
+ return { files, depth, path: path34 };
35008
35139
  }
35009
- async _formatEntry(dirent, path33) {
35140
+ async _formatEntry(dirent, path34) {
35010
35141
  let entry;
35011
35142
  const basename9 = this._isDirent ? dirent.name : dirent;
35012
35143
  try {
35013
- const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path33, basename9));
35144
+ const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path34, basename9));
35014
35145
  entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename9 };
35015
35146
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
35016
35147
  } catch (err) {
@@ -35038,8 +35169,8 @@ var init_readdirp = __esm({
35038
35169
  if (stats && stats.isSymbolicLink()) {
35039
35170
  const full = entry.fullPath;
35040
35171
  try {
35041
- const entryRealPath = await (0, import_promises3.realpath)(full);
35042
- const entryRealPathStats = await (0, import_promises3.lstat)(entryRealPath);
35172
+ const entryRealPath = await (0, import_promises4.realpath)(full);
35173
+ const entryRealPathStats = await (0, import_promises4.lstat)(entryRealPath);
35043
35174
  if (entryRealPathStats.isFile()) {
35044
35175
  return "file";
35045
35176
  }
@@ -35066,17 +35197,17 @@ var init_readdirp = __esm({
35066
35197
  }
35067
35198
  });
35068
35199
 
35069
- // ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
35070
- function createFsWatchInstance(path33, options, listener, errHandler, emitRaw) {
35200
+ // ../../oss/node_modules/chokidar/esm/handler.js
35201
+ function createFsWatchInstance(path34, options, listener, errHandler, emitRaw) {
35071
35202
  const handleEvent = (rawEvent, evPath) => {
35072
- listener(path33);
35073
- emitRaw(rawEvent, evPath, { watchedPath: path33 });
35074
- if (evPath && path33 !== evPath) {
35075
- fsWatchBroadcast(sp.resolve(path33, evPath), KEY_LISTENERS, sp.join(path33, evPath));
35203
+ listener(path34);
35204
+ emitRaw(rawEvent, evPath, { watchedPath: path34 });
35205
+ if (evPath && path34 !== evPath) {
35206
+ fsWatchBroadcast(sysPath.resolve(path34, evPath), KEY_LISTENERS, sysPath.join(path34, evPath));
35076
35207
  }
35077
35208
  };
35078
35209
  try {
35079
- return (0, import_node_fs2.watch)(path33, {
35210
+ return (0, import_fs7.watch)(path34, {
35080
35211
  persistent: options.persistent
35081
35212
  }, handleEvent);
35082
35213
  } catch (error48) {
@@ -35084,14 +35215,14 @@ function createFsWatchInstance(path33, options, listener, errHandler, emitRaw) {
35084
35215
  return void 0;
35085
35216
  }
35086
35217
  }
35087
- var import_node_fs2, import_promises4, import_node_os2, sp, STR_DATA, STR_END, STR_CLOSE, EMPTY_FN, pl, isWindows, isMacos, isLinux, isFreeBSD, isIBMi, EVENTS, EV, THROTTLE_MODE_WATCH, statMethods, KEY_LISTENERS, KEY_ERR, KEY_RAW, HANDLER_KEYS, binaryExtensions, isBinaryPath, foreach, addAndConvert, clearItem, delFromSet, isEmptySet, FsWatchInstances, fsWatchBroadcast, setFsWatchListener, FsWatchFileInstances, setFsWatchFileListener, NodeFsHandler;
35218
+ var import_fs7, import_promises5, sysPath, import_os3, STR_DATA, STR_END, STR_CLOSE, EMPTY_FN, pl, isWindows, isMacos, isLinux, isFreeBSD, isIBMi, EVENTS, EV, THROTTLE_MODE_WATCH, statMethods, KEY_LISTENERS, KEY_ERR, KEY_RAW, HANDLER_KEYS, binaryExtensions, isBinaryPath, foreach, addAndConvert, clearItem, delFromSet, isEmptySet, FsWatchInstances, fsWatchBroadcast, setFsWatchListener, FsWatchFileInstances, setFsWatchFileListener, NodeFsHandler;
35088
35219
  var init_handler2 = __esm({
35089
- "../../oss/packages/daemon-core/node_modules/chokidar/handler.js"() {
35220
+ "../../oss/node_modules/chokidar/esm/handler.js"() {
35090
35221
  "use strict";
35091
- import_node_fs2 = require("fs");
35092
- import_promises4 = require("fs/promises");
35093
- import_node_os2 = require("os");
35094
- sp = __toESM(require("path"), 1);
35222
+ import_fs7 = require("fs");
35223
+ import_promises5 = require("fs/promises");
35224
+ sysPath = __toESM(require("path"), 1);
35225
+ import_os3 = require("os");
35095
35226
  STR_DATA = "data";
35096
35227
  STR_END = "end";
35097
35228
  STR_CLOSE = "close";
@@ -35102,7 +35233,7 @@ var init_handler2 = __esm({
35102
35233
  isMacos = pl === "darwin";
35103
35234
  isLinux = pl === "linux";
35104
35235
  isFreeBSD = pl === "freebsd";
35105
- isIBMi = (0, import_node_os2.type)() === "OS400";
35236
+ isIBMi = (0, import_os3.type)() === "OS400";
35106
35237
  EVENTS = {
35107
35238
  ALL: "all",
35108
35239
  READY: "ready",
@@ -35116,7 +35247,7 @@ var init_handler2 = __esm({
35116
35247
  };
35117
35248
  EV = EVENTS;
35118
35249
  THROTTLE_MODE_WATCH = "watch";
35119
- statMethods = { lstat: import_promises4.lstat, stat: import_promises4.stat };
35250
+ statMethods = { lstat: import_promises5.lstat, stat: import_promises5.stat };
35120
35251
  KEY_LISTENERS = "listeners";
35121
35252
  KEY_ERR = "errHandlers";
35122
35253
  KEY_RAW = "rawEmitters";
@@ -35384,7 +35515,7 @@ var init_handler2 = __esm({
35384
35515
  "zip",
35385
35516
  "zipx"
35386
35517
  ]);
35387
- isBinaryPath = (filePath) => binaryExtensions.has(sp.extname(filePath).slice(1).toLowerCase());
35518
+ isBinaryPath = (filePath) => binaryExtensions.has(sysPath.extname(filePath).slice(1).toLowerCase());
35388
35519
  foreach = (val, fn) => {
35389
35520
  if (val instanceof Set) {
35390
35521
  val.forEach(fn);
@@ -35425,12 +35556,12 @@ var init_handler2 = __esm({
35425
35556
  listener(val1, val2, val3);
35426
35557
  });
35427
35558
  };
35428
- setFsWatchListener = (path33, fullPath, options, handlers) => {
35559
+ setFsWatchListener = (path34, fullPath, options, handlers) => {
35429
35560
  const { listener, errHandler, rawEmitter } = handlers;
35430
35561
  let cont = FsWatchInstances.get(fullPath);
35431
35562
  let watcher;
35432
35563
  if (!options.persistent) {
35433
- watcher = createFsWatchInstance(path33, options, listener, errHandler, rawEmitter);
35564
+ watcher = createFsWatchInstance(path34, options, listener, errHandler, rawEmitter);
35434
35565
  if (!watcher)
35435
35566
  return;
35436
35567
  return watcher.close.bind(watcher);
@@ -35441,7 +35572,7 @@ var init_handler2 = __esm({
35441
35572
  addAndConvert(cont, KEY_RAW, rawEmitter);
35442
35573
  } else {
35443
35574
  watcher = createFsWatchInstance(
35444
- path33,
35575
+ path34,
35445
35576
  options,
35446
35577
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
35447
35578
  errHandler,
@@ -35456,7 +35587,7 @@ var init_handler2 = __esm({
35456
35587
  cont.watcherUnusable = true;
35457
35588
  if (isWindows && error48.code === "EPERM") {
35458
35589
  try {
35459
- const fd = await (0, import_promises4.open)(path33, "r");
35590
+ const fd = await (0, import_promises5.open)(path34, "r");
35460
35591
  await fd.close();
35461
35592
  broadcastErr(error48);
35462
35593
  } catch (err) {
@@ -35487,12 +35618,12 @@ var init_handler2 = __esm({
35487
35618
  };
35488
35619
  };
35489
35620
  FsWatchFileInstances = /* @__PURE__ */ new Map();
35490
- setFsWatchFileListener = (path33, fullPath, options, handlers) => {
35621
+ setFsWatchFileListener = (path34, fullPath, options, handlers) => {
35491
35622
  const { listener, rawEmitter } = handlers;
35492
35623
  let cont = FsWatchFileInstances.get(fullPath);
35493
35624
  const copts = cont && cont.options;
35494
35625
  if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
35495
- (0, import_node_fs2.unwatchFile)(fullPath);
35626
+ (0, import_fs7.unwatchFile)(fullPath);
35496
35627
  cont = void 0;
35497
35628
  }
35498
35629
  if (cont) {
@@ -35503,13 +35634,13 @@ var init_handler2 = __esm({
35503
35634
  listeners: listener,
35504
35635
  rawEmitters: rawEmitter,
35505
35636
  options,
35506
- watcher: (0, import_node_fs2.watchFile)(fullPath, options, (curr, prev) => {
35637
+ watcher: (0, import_fs7.watchFile)(fullPath, options, (curr, prev) => {
35507
35638
  foreach(cont.rawEmitters, (rawEmitter2) => {
35508
35639
  rawEmitter2(EV.CHANGE, fullPath, { curr, prev });
35509
35640
  });
35510
35641
  const currmtime = curr.mtimeMs;
35511
35642
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
35512
- foreach(cont.listeners, (listener2) => listener2(path33, curr));
35643
+ foreach(cont.listeners, (listener2) => listener2(path34, curr));
35513
35644
  }
35514
35645
  })
35515
35646
  };
@@ -35520,15 +35651,13 @@ var init_handler2 = __esm({
35520
35651
  delFromSet(cont, KEY_RAW, rawEmitter);
35521
35652
  if (isEmptySet(cont.listeners)) {
35522
35653
  FsWatchFileInstances.delete(fullPath);
35523
- (0, import_node_fs2.unwatchFile)(fullPath);
35654
+ (0, import_fs7.unwatchFile)(fullPath);
35524
35655
  cont.options = cont.watcher = void 0;
35525
35656
  Object.freeze(cont);
35526
35657
  }
35527
35658
  };
35528
35659
  };
35529
35660
  NodeFsHandler = class {
35530
- fsw;
35531
- _boundHandleError;
35532
35661
  constructor(fsW) {
35533
35662
  this.fsw = fsW;
35534
35663
  this._boundHandleError = (error48) => fsW._handleError(error48);
@@ -35539,13 +35668,13 @@ var init_handler2 = __esm({
35539
35668
  * @param listener on fs change
35540
35669
  * @returns closer for the watcher instance
35541
35670
  */
35542
- _watchWithNodeFs(path33, listener) {
35671
+ _watchWithNodeFs(path34, listener) {
35543
35672
  const opts = this.fsw.options;
35544
- const directory = sp.dirname(path33);
35545
- const basename9 = sp.basename(path33);
35673
+ const directory = sysPath.dirname(path34);
35674
+ const basename9 = sysPath.basename(path34);
35546
35675
  const parent = this.fsw._getWatchedDir(directory);
35547
35676
  parent.add(basename9);
35548
- const absolutePath = sp.resolve(path33);
35677
+ const absolutePath = sysPath.resolve(path34);
35549
35678
  const options = {
35550
35679
  persistent: opts.persistent
35551
35680
  };
@@ -35555,12 +35684,12 @@ var init_handler2 = __esm({
35555
35684
  if (opts.usePolling) {
35556
35685
  const enableBin = opts.interval !== opts.binaryInterval;
35557
35686
  options.interval = enableBin && isBinaryPath(basename9) ? opts.binaryInterval : opts.interval;
35558
- closer = setFsWatchFileListener(path33, absolutePath, options, {
35687
+ closer = setFsWatchFileListener(path34, absolutePath, options, {
35559
35688
  listener,
35560
35689
  rawEmitter: this.fsw._emitRaw
35561
35690
  });
35562
35691
  } else {
35563
- closer = setFsWatchListener(path33, absolutePath, options, {
35692
+ closer = setFsWatchListener(path34, absolutePath, options, {
35564
35693
  listener,
35565
35694
  errHandler: this._boundHandleError,
35566
35695
  rawEmitter: this.fsw._emitRaw
@@ -35576,18 +35705,18 @@ var init_handler2 = __esm({
35576
35705
  if (this.fsw.closed) {
35577
35706
  return;
35578
35707
  }
35579
- const dirname11 = sp.dirname(file2);
35580
- const basename9 = sp.basename(file2);
35581
- const parent = this.fsw._getWatchedDir(dirname11);
35708
+ const dirname12 = sysPath.dirname(file2);
35709
+ const basename9 = sysPath.basename(file2);
35710
+ const parent = this.fsw._getWatchedDir(dirname12);
35582
35711
  let prevStats = stats;
35583
35712
  if (parent.has(basename9))
35584
35713
  return;
35585
- const listener = async (path33, newStats) => {
35714
+ const listener = async (path34, newStats) => {
35586
35715
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
35587
35716
  return;
35588
35717
  if (!newStats || newStats.mtimeMs === 0) {
35589
35718
  try {
35590
- const newStats2 = await (0, import_promises4.stat)(file2);
35719
+ const newStats2 = await (0, import_promises5.stat)(file2);
35591
35720
  if (this.fsw.closed)
35592
35721
  return;
35593
35722
  const at = newStats2.atimeMs;
@@ -35596,16 +35725,16 @@ var init_handler2 = __esm({
35596
35725
  this.fsw._emit(EV.CHANGE, file2, newStats2);
35597
35726
  }
35598
35727
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
35599
- this.fsw._closeFile(path33);
35728
+ this.fsw._closeFile(path34);
35600
35729
  prevStats = newStats2;
35601
35730
  const closer2 = this._watchWithNodeFs(file2, listener);
35602
35731
  if (closer2)
35603
- this.fsw._addPathCloser(path33, closer2);
35732
+ this.fsw._addPathCloser(path34, closer2);
35604
35733
  } else {
35605
35734
  prevStats = newStats2;
35606
35735
  }
35607
35736
  } catch (error48) {
35608
- this.fsw._remove(dirname11, basename9);
35737
+ this.fsw._remove(dirname12, basename9);
35609
35738
  }
35610
35739
  } else if (parent.has(basename9)) {
35611
35740
  const at = newStats.atimeMs;
@@ -35632,7 +35761,7 @@ var init_handler2 = __esm({
35632
35761
  * @param item basename of this item
35633
35762
  * @returns true if no more processing is needed for this entry.
35634
35763
  */
35635
- async _handleSymlink(entry, directory, path33, item) {
35764
+ async _handleSymlink(entry, directory, path34, item) {
35636
35765
  if (this.fsw.closed) {
35637
35766
  return;
35638
35767
  }
@@ -35642,7 +35771,7 @@ var init_handler2 = __esm({
35642
35771
  this.fsw._incrReadyCount();
35643
35772
  let linkPath;
35644
35773
  try {
35645
- linkPath = await (0, import_promises4.realpath)(path33);
35774
+ linkPath = await (0, import_promises5.realpath)(path34);
35646
35775
  } catch (e) {
35647
35776
  this.fsw._emitReady();
35648
35777
  return true;
@@ -35652,12 +35781,12 @@ var init_handler2 = __esm({
35652
35781
  if (dir.has(item)) {
35653
35782
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
35654
35783
  this.fsw._symlinkPaths.set(full, linkPath);
35655
- this.fsw._emit(EV.CHANGE, path33, entry.stats);
35784
+ this.fsw._emit(EV.CHANGE, path34, entry.stats);
35656
35785
  }
35657
35786
  } else {
35658
35787
  dir.add(item);
35659
35788
  this.fsw._symlinkPaths.set(full, linkPath);
35660
- this.fsw._emit(EV.ADD, path33, entry.stats);
35789
+ this.fsw._emit(EV.ADD, path34, entry.stats);
35661
35790
  }
35662
35791
  this.fsw._emitReady();
35663
35792
  return true;
@@ -35668,9 +35797,8 @@ var init_handler2 = __esm({
35668
35797
  this.fsw._symlinkPaths.set(full, true);
35669
35798
  }
35670
35799
  _handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
35671
- directory = sp.join(directory, "");
35672
- const throttleKey = target ? `${directory}:${target}` : directory;
35673
- throttler = this.fsw._throttle("readdir", throttleKey, 1e3);
35800
+ directory = sysPath.join(directory, "");
35801
+ throttler = this.fsw._throttle("readdir", directory, 1e3);
35674
35802
  if (!throttler)
35675
35803
  return;
35676
35804
  const previous = this.fsw._getWatchedDir(wh.path);
@@ -35687,9 +35815,9 @@ var init_handler2 = __esm({
35687
35815
  return;
35688
35816
  }
35689
35817
  const item = entry.path;
35690
- let path33 = sp.join(directory, item);
35818
+ let path34 = sysPath.join(directory, item);
35691
35819
  current.add(item);
35692
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path33, item)) {
35820
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path34, item)) {
35693
35821
  return;
35694
35822
  }
35695
35823
  if (this.fsw.closed) {
@@ -35698,8 +35826,8 @@ var init_handler2 = __esm({
35698
35826
  }
35699
35827
  if (item === target || !target && !previous.has(item)) {
35700
35828
  this.fsw._incrReadyCount();
35701
- path33 = sp.join(dir, sp.relative(dir, path33));
35702
- this._addToNodeFs(path33, initialAdd, wh, depth + 1);
35829
+ path34 = sysPath.join(dir, sysPath.relative(dir, path34));
35830
+ this._addToNodeFs(path34, initialAdd, wh, depth + 1);
35703
35831
  }
35704
35832
  }).on(EV.ERROR, this._boundHandleError);
35705
35833
  return new Promise((resolve20, reject) => {
@@ -35735,12 +35863,12 @@ var init_handler2 = __esm({
35735
35863
  * @returns closer for the watcher instance.
35736
35864
  */
35737
35865
  async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath4) {
35738
- const parentDir = this.fsw._getWatchedDir(sp.dirname(dir));
35739
- const tracked = parentDir.has(sp.basename(dir));
35866
+ const parentDir = this.fsw._getWatchedDir(sysPath.dirname(dir));
35867
+ const tracked = parentDir.has(sysPath.basename(dir));
35740
35868
  if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
35741
35869
  this.fsw._emit(EV.ADD_DIR, dir, stats);
35742
35870
  }
35743
- parentDir.add(sp.basename(dir));
35871
+ parentDir.add(sysPath.basename(dir));
35744
35872
  this.fsw._getWatchedDir(dir);
35745
35873
  let throttler;
35746
35874
  let closer;
@@ -35768,13 +35896,13 @@ var init_handler2 = __esm({
35768
35896
  * @param depth Child path actually targeted for watch
35769
35897
  * @param target Child path actually targeted for watch
35770
35898
  */
35771
- async _addToNodeFs(path33, initialAdd, priorWh, depth, target) {
35899
+ async _addToNodeFs(path34, initialAdd, priorWh, depth, target) {
35772
35900
  const ready = this.fsw._emitReady;
35773
- if (this.fsw._isIgnored(path33) || this.fsw.closed) {
35901
+ if (this.fsw._isIgnored(path34) || this.fsw.closed) {
35774
35902
  ready();
35775
35903
  return false;
35776
35904
  }
35777
- const wh = this.fsw._getWatchHelpers(path33);
35905
+ const wh = this.fsw._getWatchHelpers(path34);
35778
35906
  if (priorWh) {
35779
35907
  wh.filterPath = (entry) => priorWh.filterPath(entry);
35780
35908
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -35790,8 +35918,8 @@ var init_handler2 = __esm({
35790
35918
  const follow = this.fsw.options.followSymlinks;
35791
35919
  let closer;
35792
35920
  if (stats.isDirectory()) {
35793
- const absPath = sp.resolve(path33);
35794
- const targetPath = follow ? await (0, import_promises4.realpath)(path33) : path33;
35921
+ const absPath = sysPath.resolve(path34);
35922
+ const targetPath = follow ? await (0, import_promises5.realpath)(path34) : path34;
35795
35923
  if (this.fsw.closed)
35796
35924
  return;
35797
35925
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -35801,29 +35929,29 @@ var init_handler2 = __esm({
35801
35929
  this.fsw._symlinkPaths.set(absPath, targetPath);
35802
35930
  }
35803
35931
  } else if (stats.isSymbolicLink()) {
35804
- const targetPath = follow ? await (0, import_promises4.realpath)(path33) : path33;
35932
+ const targetPath = follow ? await (0, import_promises5.realpath)(path34) : path34;
35805
35933
  if (this.fsw.closed)
35806
35934
  return;
35807
- const parent = sp.dirname(wh.watchPath);
35935
+ const parent = sysPath.dirname(wh.watchPath);
35808
35936
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
35809
35937
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
35810
- closer = await this._handleDir(parent, stats, initialAdd, depth, path33, wh, targetPath);
35938
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path34, wh, targetPath);
35811
35939
  if (this.fsw.closed)
35812
35940
  return;
35813
35941
  if (targetPath !== void 0) {
35814
- this.fsw._symlinkPaths.set(sp.resolve(path33), targetPath);
35942
+ this.fsw._symlinkPaths.set(sysPath.resolve(path34), targetPath);
35815
35943
  }
35816
35944
  } else {
35817
35945
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
35818
35946
  }
35819
35947
  ready();
35820
35948
  if (closer)
35821
- this.fsw._addPathCloser(path33, closer);
35949
+ this.fsw._addPathCloser(path34, closer);
35822
35950
  return false;
35823
35951
  } catch (error48) {
35824
35952
  if (this.fsw._handleError(error48)) {
35825
35953
  ready();
35826
- return path33;
35954
+ return path34;
35827
35955
  }
35828
35956
  }
35829
35957
  }
@@ -35831,7 +35959,7 @@ var init_handler2 = __esm({
35831
35959
  }
35832
35960
  });
35833
35961
 
35834
- // ../../oss/packages/daemon-core/node_modules/chokidar/index.js
35962
+ // ../../oss/node_modules/chokidar/esm/index.js
35835
35963
  function arrify(item) {
35836
35964
  return Array.isArray(item) ? item : [item];
35837
35965
  }
@@ -35847,35 +35975,37 @@ function createPattern(matcher) {
35847
35975
  if (matcher.path === string4)
35848
35976
  return true;
35849
35977
  if (matcher.recursive) {
35850
- const relative5 = sp2.relative(matcher.path, string4);
35978
+ const relative5 = sysPath2.relative(matcher.path, string4);
35851
35979
  if (!relative5) {
35852
35980
  return false;
35853
35981
  }
35854
- return !relative5.startsWith("..") && !sp2.isAbsolute(relative5);
35982
+ return !relative5.startsWith("..") && !sysPath2.isAbsolute(relative5);
35855
35983
  }
35856
35984
  return false;
35857
35985
  };
35858
35986
  }
35859
35987
  return () => false;
35860
35988
  }
35861
- function normalizePath(path33) {
35862
- if (typeof path33 !== "string")
35989
+ function normalizePath(path34) {
35990
+ if (typeof path34 !== "string")
35863
35991
  throw new Error("string expected");
35864
- path33 = sp2.normalize(path33);
35865
- path33 = path33.replace(/\\/g, "/");
35992
+ path34 = sysPath2.normalize(path34);
35993
+ path34 = path34.replace(/\\/g, "/");
35866
35994
  let prepend = false;
35867
- if (path33.startsWith("//"))
35995
+ if (path34.startsWith("//"))
35868
35996
  prepend = true;
35869
- path33 = path33.replace(DOUBLE_SLASH_RE, "/");
35997
+ const DOUBLE_SLASH_RE2 = /\/\//;
35998
+ while (path34.match(DOUBLE_SLASH_RE2))
35999
+ path34 = path34.replace(DOUBLE_SLASH_RE2, "/");
35870
36000
  if (prepend)
35871
- path33 = "/" + path33;
35872
- return path33;
36001
+ path34 = "/" + path34;
36002
+ return path34;
35873
36003
  }
35874
36004
  function matchPatterns(patterns, testString, stats) {
35875
- const path33 = normalizePath(testString);
36005
+ const path34 = normalizePath(testString);
35876
36006
  for (let index = 0; index < patterns.length; index++) {
35877
36007
  const pattern = patterns[index];
35878
- if (pattern(path33, stats)) {
36008
+ if (pattern(path34, stats)) {
35879
36009
  return true;
35880
36010
  }
35881
36011
  }
@@ -35899,15 +36029,15 @@ function watch(paths, options = {}) {
35899
36029
  watcher.add(paths);
35900
36030
  return watcher;
35901
36031
  }
35902
- var import_node_events, import_node_fs3, import_promises5, sp2, SLASH, SLASH_SLASH, ONE_DOT, TWO_DOTS, STRING_TYPE, BACK_SLASH_RE, DOUBLE_SLASH_RE, DOT_RE, REPLACER_RE, isMatcherObject, unifyPaths, toUnix, normalizePathToUnix, normalizeIgnored, getAbsolutePath, EMPTY_SET, DirEntry, STAT_METHOD_F, STAT_METHOD_L, WatchHelper, FSWatcher;
35903
- var init_chokidar = __esm({
35904
- "../../oss/packages/daemon-core/node_modules/chokidar/index.js"() {
36032
+ var import_fs8, import_promises6, import_events, sysPath2, SLASH, SLASH_SLASH, ONE_DOT, TWO_DOTS, STRING_TYPE, BACK_SLASH_RE, DOUBLE_SLASH_RE, DOT_RE, REPLACER_RE, isMatcherObject, unifyPaths, toUnix, normalizePathToUnix, normalizeIgnored, getAbsolutePath, EMPTY_SET, DirEntry, STAT_METHOD_F, STAT_METHOD_L, WatchHelper, FSWatcher;
36033
+ var init_esm2 = __esm({
36034
+ "../../oss/node_modules/chokidar/esm/index.js"() {
35905
36035
  "use strict";
35906
- import_node_events = require("events");
35907
- import_node_fs3 = require("fs");
35908
- import_promises5 = require("fs/promises");
35909
- sp2 = __toESM(require("path"), 1);
35910
- init_readdirp();
36036
+ import_fs8 = require("fs");
36037
+ import_promises6 = require("fs/promises");
36038
+ import_events = require("events");
36039
+ sysPath2 = __toESM(require("path"), 1);
36040
+ init_esm();
35911
36041
  init_handler2();
35912
36042
  SLASH = "/";
35913
36043
  SLASH_SLASH = "//";
@@ -35915,7 +36045,7 @@ var init_chokidar = __esm({
35915
36045
  TWO_DOTS = "..";
35916
36046
  STRING_TYPE = "string";
35917
36047
  BACK_SLASH_RE = /\\/g;
35918
- DOUBLE_SLASH_RE = /\/\//g;
36048
+ DOUBLE_SLASH_RE = /\/\//;
35919
36049
  DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
35920
36050
  REPLACER_RE = /^\.[/\\]/;
35921
36051
  isMatcherObject = (matcher) => typeof matcher === "object" && matcher !== null && !(matcher instanceof RegExp);
@@ -35932,31 +36062,30 @@ var init_chokidar = __esm({
35932
36062
  if (str.startsWith(SLASH_SLASH)) {
35933
36063
  prepend = true;
35934
36064
  }
35935
- str = str.replace(DOUBLE_SLASH_RE, SLASH);
36065
+ while (str.match(DOUBLE_SLASH_RE)) {
36066
+ str = str.replace(DOUBLE_SLASH_RE, SLASH);
36067
+ }
35936
36068
  if (prepend) {
35937
36069
  str = SLASH + str;
35938
36070
  }
35939
36071
  return str;
35940
36072
  };
35941
- normalizePathToUnix = (path33) => toUnix(sp2.normalize(toUnix(path33)));
35942
- normalizeIgnored = (cwd = "") => (path33) => {
35943
- if (typeof path33 === "string") {
35944
- return normalizePathToUnix(sp2.isAbsolute(path33) ? path33 : sp2.join(cwd, path33));
36073
+ normalizePathToUnix = (path34) => toUnix(sysPath2.normalize(toUnix(path34)));
36074
+ normalizeIgnored = (cwd = "") => (path34) => {
36075
+ if (typeof path34 === "string") {
36076
+ return normalizePathToUnix(sysPath2.isAbsolute(path34) ? path34 : sysPath2.join(cwd, path34));
35945
36077
  } else {
35946
- return path33;
36078
+ return path34;
35947
36079
  }
35948
36080
  };
35949
- getAbsolutePath = (path33, cwd) => {
35950
- if (sp2.isAbsolute(path33)) {
35951
- return path33;
36081
+ getAbsolutePath = (path34, cwd) => {
36082
+ if (sysPath2.isAbsolute(path34)) {
36083
+ return path34;
35952
36084
  }
35953
- return sp2.join(cwd, path33);
36085
+ return sysPath2.join(cwd, path34);
35954
36086
  };
35955
36087
  EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
35956
36088
  DirEntry = class {
35957
- path;
35958
- _removeWatcher;
35959
- items;
35960
36089
  constructor(dir, removeWatcher) {
35961
36090
  this.path = dir;
35962
36091
  this._removeWatcher = removeWatcher;
@@ -35978,10 +36107,10 @@ var init_chokidar = __esm({
35978
36107
  return;
35979
36108
  const dir = this.path;
35980
36109
  try {
35981
- await (0, import_promises5.readdir)(dir);
36110
+ await (0, import_promises6.readdir)(dir);
35982
36111
  } catch (err) {
35983
36112
  if (this._removeWatcher) {
35984
- this._removeWatcher(sp2.dirname(dir), sp2.basename(dir));
36113
+ this._removeWatcher(sysPath2.dirname(dir), sysPath2.basename(dir));
35985
36114
  }
35986
36115
  }
35987
36116
  }
@@ -36008,19 +36137,12 @@ var init_chokidar = __esm({
36008
36137
  STAT_METHOD_F = "stat";
36009
36138
  STAT_METHOD_L = "lstat";
36010
36139
  WatchHelper = class {
36011
- fsw;
36012
- path;
36013
- watchPath;
36014
- fullWatchPath;
36015
- dirParts;
36016
- followSymlinks;
36017
- statMethod;
36018
- constructor(path33, follow, fsw) {
36140
+ constructor(path34, follow, fsw) {
36019
36141
  this.fsw = fsw;
36020
- const watchPath = path33;
36021
- this.path = path33 = path33.replace(REPLACER_RE, "");
36142
+ const watchPath = path34;
36143
+ this.path = path34 = path34.replace(REPLACER_RE, "");
36022
36144
  this.watchPath = watchPath;
36023
- this.fullWatchPath = sp2.resolve(watchPath);
36145
+ this.fullWatchPath = sysPath2.resolve(watchPath);
36024
36146
  this.dirParts = [];
36025
36147
  this.dirParts.forEach((parts) => {
36026
36148
  if (parts.length > 1)
@@ -36030,7 +36152,7 @@ var init_chokidar = __esm({
36030
36152
  this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
36031
36153
  }
36032
36154
  entryPath(entry) {
36033
- return sp2.join(this.watchPath, sp2.relative(this.watchPath, entry.fullPath));
36155
+ return sysPath2.join(this.watchPath, sysPath2.relative(this.watchPath, entry.fullPath));
36034
36156
  }
36035
36157
  filterPath(entry) {
36036
36158
  const { stats } = entry;
@@ -36043,25 +36165,7 @@ var init_chokidar = __esm({
36043
36165
  return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
36044
36166
  }
36045
36167
  };
36046
- FSWatcher = class extends import_node_events.EventEmitter {
36047
- closed;
36048
- options;
36049
- _closers;
36050
- _ignoredPaths;
36051
- _throttled;
36052
- _streams;
36053
- _symlinkPaths;
36054
- _watched;
36055
- _pendingWrites;
36056
- _pendingUnlinks;
36057
- _readyCount;
36058
- _emitReady;
36059
- _closePromise;
36060
- _userIgnored;
36061
- _readyEmitted;
36062
- _emitRaw;
36063
- _boundRemove;
36064
- _nodeFsHandler;
36168
+ FSWatcher = class extends import_events.EventEmitter {
36065
36169
  // Not indenting methods for history sake; for now.
36066
36170
  constructor(_opts = {}) {
36067
36171
  super();
@@ -36158,20 +36262,20 @@ var init_chokidar = __esm({
36158
36262
  this._closePromise = void 0;
36159
36263
  let paths = unifyPaths(paths_);
36160
36264
  if (cwd) {
36161
- paths = paths.map((path33) => {
36162
- const absPath = getAbsolutePath(path33, cwd);
36265
+ paths = paths.map((path34) => {
36266
+ const absPath = getAbsolutePath(path34, cwd);
36163
36267
  return absPath;
36164
36268
  });
36165
36269
  }
36166
- paths.forEach((path33) => {
36167
- this._removeIgnoredPath(path33);
36270
+ paths.forEach((path34) => {
36271
+ this._removeIgnoredPath(path34);
36168
36272
  });
36169
36273
  this._userIgnored = void 0;
36170
36274
  if (!this._readyCount)
36171
36275
  this._readyCount = 0;
36172
36276
  this._readyCount += paths.length;
36173
- Promise.all(paths.map(async (path33) => {
36174
- const res = await this._nodeFsHandler._addToNodeFs(path33, !_internal, void 0, 0, _origAdd);
36277
+ Promise.all(paths.map(async (path34) => {
36278
+ const res = await this._nodeFsHandler._addToNodeFs(path34, !_internal, void 0, 0, _origAdd);
36175
36279
  if (res)
36176
36280
  this._emitReady();
36177
36281
  return res;
@@ -36180,7 +36284,7 @@ var init_chokidar = __esm({
36180
36284
  return;
36181
36285
  results.forEach((item) => {
36182
36286
  if (item)
36183
- this.add(sp2.dirname(item), sp2.basename(_origAdd || item));
36287
+ this.add(sysPath2.dirname(item), sysPath2.basename(_origAdd || item));
36184
36288
  });
36185
36289
  });
36186
36290
  return this;
@@ -36193,17 +36297,17 @@ var init_chokidar = __esm({
36193
36297
  return this;
36194
36298
  const paths = unifyPaths(paths_);
36195
36299
  const { cwd } = this.options;
36196
- paths.forEach((path33) => {
36197
- if (!sp2.isAbsolute(path33) && !this._closers.has(path33)) {
36300
+ paths.forEach((path34) => {
36301
+ if (!sysPath2.isAbsolute(path34) && !this._closers.has(path34)) {
36198
36302
  if (cwd)
36199
- path33 = sp2.join(cwd, path33);
36200
- path33 = sp2.resolve(path33);
36303
+ path34 = sysPath2.join(cwd, path34);
36304
+ path34 = sysPath2.resolve(path34);
36201
36305
  }
36202
- this._closePath(path33);
36203
- this._addIgnoredPath(path33);
36204
- if (this._watched.has(path33)) {
36306
+ this._closePath(path34);
36307
+ this._addIgnoredPath(path34);
36308
+ if (this._watched.has(path34)) {
36205
36309
  this._addIgnoredPath({
36206
- path: path33,
36310
+ path: path34,
36207
36311
  recursive: true
36208
36312
  });
36209
36313
  }
@@ -36246,7 +36350,7 @@ var init_chokidar = __esm({
36246
36350
  getWatched() {
36247
36351
  const watchList = {};
36248
36352
  this._watched.forEach((entry, dir) => {
36249
- const key = this.options.cwd ? sp2.relative(this.options.cwd, dir) : dir;
36353
+ const key = this.options.cwd ? sysPath2.relative(this.options.cwd, dir) : dir;
36250
36354
  const index = key || ONE_DOT;
36251
36355
  watchList[index] = entry.getChildren().sort();
36252
36356
  });
@@ -36267,38 +36371,38 @@ var init_chokidar = __esm({
36267
36371
  * @param stats arguments to be passed with event
36268
36372
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
36269
36373
  */
36270
- async _emit(event, path33, stats) {
36374
+ async _emit(event, path34, stats) {
36271
36375
  if (this.closed)
36272
36376
  return;
36273
36377
  const opts = this.options;
36274
36378
  if (isWindows)
36275
- path33 = sp2.normalize(path33);
36379
+ path34 = sysPath2.normalize(path34);
36276
36380
  if (opts.cwd)
36277
- path33 = sp2.relative(opts.cwd, path33);
36278
- const args = [path33];
36381
+ path34 = sysPath2.relative(opts.cwd, path34);
36382
+ const args = [path34];
36279
36383
  if (stats != null)
36280
36384
  args.push(stats);
36281
36385
  const awf = opts.awaitWriteFinish;
36282
36386
  let pw;
36283
- if (awf && (pw = this._pendingWrites.get(path33))) {
36387
+ if (awf && (pw = this._pendingWrites.get(path34))) {
36284
36388
  pw.lastChange = /* @__PURE__ */ new Date();
36285
36389
  return this;
36286
36390
  }
36287
36391
  if (opts.atomic) {
36288
36392
  if (event === EVENTS.UNLINK) {
36289
- this._pendingUnlinks.set(path33, [event, ...args]);
36393
+ this._pendingUnlinks.set(path34, [event, ...args]);
36290
36394
  setTimeout(() => {
36291
- this._pendingUnlinks.forEach((entry, path34) => {
36395
+ this._pendingUnlinks.forEach((entry, path35) => {
36292
36396
  this.emit(...entry);
36293
36397
  this.emit(EVENTS.ALL, ...entry);
36294
- this._pendingUnlinks.delete(path34);
36398
+ this._pendingUnlinks.delete(path35);
36295
36399
  });
36296
36400
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
36297
36401
  return this;
36298
36402
  }
36299
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path33)) {
36403
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path34)) {
36300
36404
  event = EVENTS.CHANGE;
36301
- this._pendingUnlinks.delete(path33);
36405
+ this._pendingUnlinks.delete(path34);
36302
36406
  }
36303
36407
  }
36304
36408
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -36316,19 +36420,19 @@ var init_chokidar = __esm({
36316
36420
  this.emitWithAll(event, args);
36317
36421
  }
36318
36422
  };
36319
- this._awaitWriteFinish(path33, awf.stabilityThreshold, event, awfEmit);
36423
+ this._awaitWriteFinish(path34, awf.stabilityThreshold, event, awfEmit);
36320
36424
  return this;
36321
36425
  }
36322
36426
  if (event === EVENTS.CHANGE) {
36323
- const isThrottled = !this._throttle(EVENTS.CHANGE, path33, 50);
36427
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path34, 50);
36324
36428
  if (isThrottled)
36325
36429
  return this;
36326
36430
  }
36327
36431
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
36328
- const fullPath = opts.cwd ? sp2.join(opts.cwd, path33) : path33;
36432
+ const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path34) : path34;
36329
36433
  let stats2;
36330
36434
  try {
36331
- stats2 = await (0, import_promises5.stat)(fullPath);
36435
+ stats2 = await (0, import_promises6.stat)(fullPath);
36332
36436
  } catch (err) {
36333
36437
  }
36334
36438
  if (!stats2 || this.closed)
@@ -36356,23 +36460,23 @@ var init_chokidar = __esm({
36356
36460
  * @param timeout duration of time to suppress duplicate actions
36357
36461
  * @returns tracking object or false if action should be suppressed
36358
36462
  */
36359
- _throttle(actionType, path33, timeout) {
36463
+ _throttle(actionType, path34, timeout) {
36360
36464
  if (!this._throttled.has(actionType)) {
36361
36465
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
36362
36466
  }
36363
36467
  const action = this._throttled.get(actionType);
36364
36468
  if (!action)
36365
36469
  throw new Error("invalid throttle");
36366
- const actionPath = action.get(path33);
36470
+ const actionPath = action.get(path34);
36367
36471
  if (actionPath) {
36368
36472
  actionPath.count++;
36369
36473
  return false;
36370
36474
  }
36371
36475
  let timeoutObject;
36372
36476
  const clear = () => {
36373
- const item = action.get(path33);
36477
+ const item = action.get(path34);
36374
36478
  const count = item ? item.count : 0;
36375
- action.delete(path33);
36479
+ action.delete(path34);
36376
36480
  clearTimeout(timeoutObject);
36377
36481
  if (item)
36378
36482
  clearTimeout(item.timeoutObject);
@@ -36380,7 +36484,7 @@ var init_chokidar = __esm({
36380
36484
  };
36381
36485
  timeoutObject = setTimeout(clear, timeout);
36382
36486
  const thr = { timeoutObject, clear, count: 0 };
36383
- action.set(path33, thr);
36487
+ action.set(path34, thr);
36384
36488
  return thr;
36385
36489
  }
36386
36490
  _incrReadyCount() {
@@ -36394,44 +36498,44 @@ var init_chokidar = __esm({
36394
36498
  * @param event
36395
36499
  * @param awfEmit Callback to be called when ready for event to be emitted.
36396
36500
  */
36397
- _awaitWriteFinish(path33, threshold, event, awfEmit) {
36501
+ _awaitWriteFinish(path34, threshold, event, awfEmit) {
36398
36502
  const awf = this.options.awaitWriteFinish;
36399
36503
  if (typeof awf !== "object")
36400
36504
  return;
36401
36505
  const pollInterval = awf.pollInterval;
36402
36506
  let timeoutHandler;
36403
- let fullPath = path33;
36404
- if (this.options.cwd && !sp2.isAbsolute(path33)) {
36405
- fullPath = sp2.join(this.options.cwd, path33);
36507
+ let fullPath = path34;
36508
+ if (this.options.cwd && !sysPath2.isAbsolute(path34)) {
36509
+ fullPath = sysPath2.join(this.options.cwd, path34);
36406
36510
  }
36407
36511
  const now = /* @__PURE__ */ new Date();
36408
36512
  const writes = this._pendingWrites;
36409
36513
  function awaitWriteFinishFn(prevStat) {
36410
- (0, import_node_fs3.stat)(fullPath, (err, curStat) => {
36411
- if (err || !writes.has(path33)) {
36514
+ (0, import_fs8.stat)(fullPath, (err, curStat) => {
36515
+ if (err || !writes.has(path34)) {
36412
36516
  if (err && err.code !== "ENOENT")
36413
36517
  awfEmit(err);
36414
36518
  return;
36415
36519
  }
36416
36520
  const now2 = Number(/* @__PURE__ */ new Date());
36417
36521
  if (prevStat && curStat.size !== prevStat.size) {
36418
- writes.get(path33).lastChange = now2;
36522
+ writes.get(path34).lastChange = now2;
36419
36523
  }
36420
- const pw = writes.get(path33);
36524
+ const pw = writes.get(path34);
36421
36525
  const df = now2 - pw.lastChange;
36422
36526
  if (df >= threshold) {
36423
- writes.delete(path33);
36527
+ writes.delete(path34);
36424
36528
  awfEmit(void 0, curStat);
36425
36529
  } else {
36426
36530
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
36427
36531
  }
36428
36532
  });
36429
36533
  }
36430
- if (!writes.has(path33)) {
36431
- writes.set(path33, {
36534
+ if (!writes.has(path34)) {
36535
+ writes.set(path34, {
36432
36536
  lastChange: now,
36433
36537
  cancelWait: () => {
36434
- writes.delete(path33);
36538
+ writes.delete(path34);
36435
36539
  clearTimeout(timeoutHandler);
36436
36540
  return event;
36437
36541
  }
@@ -36442,8 +36546,8 @@ var init_chokidar = __esm({
36442
36546
  /**
36443
36547
  * Determines whether user has asked to ignore this path.
36444
36548
  */
36445
- _isIgnored(path33, stats) {
36446
- if (this.options.atomic && DOT_RE.test(path33))
36549
+ _isIgnored(path34, stats) {
36550
+ if (this.options.atomic && DOT_RE.test(path34))
36447
36551
  return true;
36448
36552
  if (!this._userIgnored) {
36449
36553
  const { cwd } = this.options;
@@ -36453,17 +36557,17 @@ var init_chokidar = __esm({
36453
36557
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
36454
36558
  this._userIgnored = anymatch(list, void 0);
36455
36559
  }
36456
- return this._userIgnored(path33, stats);
36560
+ return this._userIgnored(path34, stats);
36457
36561
  }
36458
- _isntIgnored(path33, stat5) {
36459
- return !this._isIgnored(path33, stat5);
36562
+ _isntIgnored(path34, stat5) {
36563
+ return !this._isIgnored(path34, stat5);
36460
36564
  }
36461
36565
  /**
36462
36566
  * Provides a set of common helpers and properties relating to symlink handling.
36463
36567
  * @param path file or directory pattern being watched
36464
36568
  */
36465
- _getWatchHelpers(path33) {
36466
- return new WatchHelper(path33, this.options.followSymlinks, this);
36569
+ _getWatchHelpers(path34) {
36570
+ return new WatchHelper(path34, this.options.followSymlinks, this);
36467
36571
  }
36468
36572
  // Directory helpers
36469
36573
  // -----------------
@@ -36472,7 +36576,7 @@ var init_chokidar = __esm({
36472
36576
  * @param directory path of the directory
36473
36577
  */
36474
36578
  _getWatchedDir(directory) {
36475
- const dir = sp2.resolve(directory);
36579
+ const dir = sysPath2.resolve(directory);
36476
36580
  if (!this._watched.has(dir))
36477
36581
  this._watched.set(dir, new DirEntry(dir, this._boundRemove));
36478
36582
  return this._watched.get(dir);
@@ -36495,63 +36599,63 @@ var init_chokidar = __esm({
36495
36599
  * @param item base path of item/directory
36496
36600
  */
36497
36601
  _remove(directory, item, isDirectory) {
36498
- const path33 = sp2.join(directory, item);
36499
- const fullPath = sp2.resolve(path33);
36500
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path33) || this._watched.has(fullPath);
36501
- if (!this._throttle("remove", path33, 100))
36602
+ const path34 = sysPath2.join(directory, item);
36603
+ const fullPath = sysPath2.resolve(path34);
36604
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path34) || this._watched.has(fullPath);
36605
+ if (!this._throttle("remove", path34, 100))
36502
36606
  return;
36503
36607
  if (!isDirectory && this._watched.size === 1) {
36504
36608
  this.add(directory, item, true);
36505
36609
  }
36506
- const wp = this._getWatchedDir(path33);
36610
+ const wp = this._getWatchedDir(path34);
36507
36611
  const nestedDirectoryChildren = wp.getChildren();
36508
- nestedDirectoryChildren.forEach((nested) => this._remove(path33, nested));
36612
+ nestedDirectoryChildren.forEach((nested) => this._remove(path34, nested));
36509
36613
  const parent = this._getWatchedDir(directory);
36510
36614
  const wasTracked = parent.has(item);
36511
36615
  parent.remove(item);
36512
36616
  if (this._symlinkPaths.has(fullPath)) {
36513
36617
  this._symlinkPaths.delete(fullPath);
36514
36618
  }
36515
- let relPath = path33;
36619
+ let relPath = path34;
36516
36620
  if (this.options.cwd)
36517
- relPath = sp2.relative(this.options.cwd, path33);
36621
+ relPath = sysPath2.relative(this.options.cwd, path34);
36518
36622
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
36519
36623
  const event = this._pendingWrites.get(relPath).cancelWait();
36520
36624
  if (event === EVENTS.ADD)
36521
36625
  return;
36522
36626
  }
36523
- this._watched.delete(path33);
36627
+ this._watched.delete(path34);
36524
36628
  this._watched.delete(fullPath);
36525
36629
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
36526
- if (wasTracked && !this._isIgnored(path33))
36527
- this._emit(eventName, path33);
36528
- this._closePath(path33);
36630
+ if (wasTracked && !this._isIgnored(path34))
36631
+ this._emit(eventName, path34);
36632
+ this._closePath(path34);
36529
36633
  }
36530
36634
  /**
36531
36635
  * Closes all watchers for a path
36532
36636
  */
36533
- _closePath(path33) {
36534
- this._closeFile(path33);
36535
- const dir = sp2.dirname(path33);
36536
- this._getWatchedDir(dir).remove(sp2.basename(path33));
36637
+ _closePath(path34) {
36638
+ this._closeFile(path34);
36639
+ const dir = sysPath2.dirname(path34);
36640
+ this._getWatchedDir(dir).remove(sysPath2.basename(path34));
36537
36641
  }
36538
36642
  /**
36539
36643
  * Closes only file-specific watchers
36540
36644
  */
36541
- _closeFile(path33) {
36542
- const closers = this._closers.get(path33);
36645
+ _closeFile(path34) {
36646
+ const closers = this._closers.get(path34);
36543
36647
  if (!closers)
36544
36648
  return;
36545
36649
  closers.forEach((closer) => closer());
36546
- this._closers.delete(path33);
36650
+ this._closers.delete(path34);
36547
36651
  }
36548
- _addPathCloser(path33, closer) {
36652
+ _addPathCloser(path34, closer) {
36549
36653
  if (!closer)
36550
36654
  return;
36551
- let list = this._closers.get(path33);
36655
+ let list = this._closers.get(path34);
36552
36656
  if (!list) {
36553
36657
  list = [];
36554
- this._closers.set(path33, list);
36658
+ this._closers.set(path34, list);
36555
36659
  }
36556
36660
  list.push(closer);
36557
36661
  }
@@ -36871,14 +36975,14 @@ var init_provider_schema = __esm({
36871
36975
  });
36872
36976
 
36873
36977
  // ../../oss/packages/daemon-core/src/providers/provider-loader.ts
36874
- var fs7, path17, os16, ProviderLoader;
36978
+ var fs7, path18, os16, ProviderLoader;
36875
36979
  var init_provider_loader = __esm({
36876
36980
  "../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
36877
36981
  "use strict";
36878
36982
  fs7 = __toESM(require("fs"));
36879
- path17 = __toESM(require("path"));
36983
+ path18 = __toESM(require("path"));
36880
36984
  os16 = __toESM(require("os"));
36881
- init_chokidar();
36985
+ init_esm2();
36882
36986
  init_ide_detector();
36883
36987
  init_logger();
36884
36988
  init_provider_schema();
@@ -36913,7 +37017,7 @@ var init_provider_loader = __esm({
36913
37017
  try {
36914
37018
  if (!fs7.existsSync(candidate) || !fs7.statSync(candidate).isDirectory()) return false;
36915
37019
  return ["ide", "extension", "cli", "acp"].some(
36916
- (category) => fs7.existsSync(path17.join(candidate, category))
37020
+ (category) => fs7.existsSync(path18.join(candidate, category))
36917
37021
  );
36918
37022
  } catch {
36919
37023
  return false;
@@ -36921,20 +37025,20 @@ var init_provider_loader = __esm({
36921
37025
  }
36922
37026
  static hasProviderRootMarker(candidate) {
36923
37027
  try {
36924
- return fs7.existsSync(path17.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
37028
+ return fs7.existsSync(path18.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
36925
37029
  } catch {
36926
37030
  return false;
36927
37031
  }
36928
37032
  }
36929
37033
  detectDefaultUserDir() {
36930
- const fallback2 = path17.join(os16.homedir(), ".adhdev", "providers");
37034
+ const fallback2 = path18.join(os16.homedir(), ".adhdev", "providers");
36931
37035
  const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
36932
37036
  const visited = /* @__PURE__ */ new Set();
36933
37037
  for (const start of this.probeStarts) {
36934
- let current = path17.resolve(start);
37038
+ let current = path18.resolve(start);
36935
37039
  while (!visited.has(current)) {
36936
37040
  visited.add(current);
36937
- const siblingCandidate = path17.join(path17.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
37041
+ const siblingCandidate = path18.join(path18.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
36938
37042
  if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
36939
37043
  const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
36940
37044
  if (envOptIn || hasMarker) {
@@ -36956,7 +37060,7 @@ var init_provider_loader = __esm({
36956
37060
  return { path: siblingCandidate, source };
36957
37061
  }
36958
37062
  }
36959
- const parent = path17.dirname(current);
37063
+ const parent = path18.dirname(current);
36960
37064
  if (parent === current) break;
36961
37065
  current = parent;
36962
37066
  }
@@ -36966,11 +37070,11 @@ var init_provider_loader = __esm({
36966
37070
  constructor(options) {
36967
37071
  this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
36968
37072
  this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
36969
- this.defaultProvidersDir = path17.join(os16.homedir(), ".adhdev", "providers");
37073
+ this.defaultProvidersDir = path18.join(os16.homedir(), ".adhdev", "providers");
36970
37074
  const detected = this.detectDefaultUserDir();
36971
37075
  this.userDir = detected.path;
36972
37076
  this.userDirSource = detected.source;
36973
- this.upstreamDir = path17.join(this.defaultProvidersDir, ".upstream");
37077
+ this.upstreamDir = path18.join(this.defaultProvidersDir, ".upstream");
36974
37078
  this.disableUpstream = false;
36975
37079
  this.applySourceConfig({
36976
37080
  userDir: options?.userDir,
@@ -37029,7 +37133,7 @@ var init_provider_loader = __esm({
37029
37133
  this.userDir = detected.path;
37030
37134
  this.userDirSource = detected.source;
37031
37135
  }
37032
- this.upstreamDir = path17.join(this.defaultProvidersDir, ".upstream");
37136
+ this.upstreamDir = path18.join(this.defaultProvidersDir, ".upstream");
37033
37137
  this.disableUpstream = this.sourceMode === "no-upstream";
37034
37138
  if (this.explicitProviderDir) {
37035
37139
  this.log(`Config 'providerDir' applied: ${this.userDir}`);
@@ -37043,7 +37147,7 @@ var init_provider_loader = __esm({
37043
37147
  * Canonical provider directory shape for a given root.
37044
37148
  */
37045
37149
  getProviderDir(root, category, type) {
37046
- return path17.join(root, category, type);
37150
+ return path18.join(root, category, type);
37047
37151
  }
37048
37152
  /**
37049
37153
  * Canonical user override directory for a provider.
@@ -37070,7 +37174,7 @@ var init_provider_loader = __esm({
37070
37174
  resolveProviderFile(type, ...segments) {
37071
37175
  const dir = this.findProviderDirInternal(type);
37072
37176
  if (!dir) return null;
37073
- return path17.join(dir, ...segments);
37177
+ return path18.join(dir, ...segments);
37074
37178
  }
37075
37179
  /**
37076
37180
  * Load all providers (3-tier priority)
@@ -37109,7 +37213,7 @@ var init_provider_loader = __esm({
37109
37213
  if (!fs7.existsSync(this.upstreamDir)) return false;
37110
37214
  try {
37111
37215
  return fs7.readdirSync(this.upstreamDir).some(
37112
- (d) => fs7.statSync(path17.join(this.upstreamDir, d)).isDirectory()
37216
+ (d) => fs7.statSync(path18.join(this.upstreamDir, d)).isDirectory()
37113
37217
  );
37114
37218
  } catch {
37115
37219
  return false;
@@ -37606,8 +37710,8 @@ var init_provider_loader = __esm({
37606
37710
  resolved._resolvedScriptDir = entry.scriptDir;
37607
37711
  resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
37608
37712
  if (providerDir) {
37609
- const fullDir = path17.join(providerDir, entry.scriptDir);
37610
- resolved._resolvedScriptsPath = fs7.existsSync(path17.join(fullDir, "scripts.js")) ? path17.join(fullDir, "scripts.js") : fullDir;
37713
+ const fullDir = path18.join(providerDir, entry.scriptDir);
37714
+ resolved._resolvedScriptsPath = fs7.existsSync(path18.join(fullDir, "scripts.js")) ? path18.join(fullDir, "scripts.js") : fullDir;
37611
37715
  }
37612
37716
  matched = true;
37613
37717
  }
@@ -37622,8 +37726,8 @@ var init_provider_loader = __esm({
37622
37726
  resolved._resolvedScriptDir = base.defaultScriptDir;
37623
37727
  resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
37624
37728
  if (providerDir) {
37625
- const fullDir = path17.join(providerDir, base.defaultScriptDir);
37626
- resolved._resolvedScriptsPath = fs7.existsSync(path17.join(fullDir, "scripts.js")) ? path17.join(fullDir, "scripts.js") : fullDir;
37729
+ const fullDir = path18.join(providerDir, base.defaultScriptDir);
37730
+ resolved._resolvedScriptsPath = fs7.existsSync(path18.join(fullDir, "scripts.js")) ? path18.join(fullDir, "scripts.js") : fullDir;
37627
37731
  }
37628
37732
  }
37629
37733
  resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
@@ -37640,8 +37744,8 @@ var init_provider_loader = __esm({
37640
37744
  resolved._resolvedScriptDir = dirOverride;
37641
37745
  resolved._resolvedScriptsSource = `versions:${range}`;
37642
37746
  if (providerDir) {
37643
- const fullDir = path17.join(providerDir, dirOverride);
37644
- resolved._resolvedScriptsPath = fs7.existsSync(path17.join(fullDir, "scripts.js")) ? path17.join(fullDir, "scripts.js") : fullDir;
37747
+ const fullDir = path18.join(providerDir, dirOverride);
37748
+ resolved._resolvedScriptsPath = fs7.existsSync(path18.join(fullDir, "scripts.js")) ? path18.join(fullDir, "scripts.js") : fullDir;
37645
37749
  }
37646
37750
  }
37647
37751
  } else if (override.scripts) {
@@ -37657,8 +37761,8 @@ var init_provider_loader = __esm({
37657
37761
  resolved._resolvedScriptDir = base.defaultScriptDir;
37658
37762
  resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
37659
37763
  if (providerDir) {
37660
- const fullDir = path17.join(providerDir, base.defaultScriptDir);
37661
- resolved._resolvedScriptsPath = fs7.existsSync(path17.join(fullDir, "scripts.js")) ? path17.join(fullDir, "scripts.js") : fullDir;
37764
+ const fullDir = path18.join(providerDir, base.defaultScriptDir);
37765
+ resolved._resolvedScriptsPath = fs7.existsSync(path18.join(fullDir, "scripts.js")) ? path18.join(fullDir, "scripts.js") : fullDir;
37662
37766
  }
37663
37767
  }
37664
37768
  }
@@ -37690,14 +37794,14 @@ var init_provider_loader = __esm({
37690
37794
  this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
37691
37795
  return null;
37692
37796
  }
37693
- const dir = path17.join(providerDir, scriptDir);
37797
+ const dir = path18.join(providerDir, scriptDir);
37694
37798
  if (!fs7.existsSync(dir)) {
37695
37799
  this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
37696
37800
  return null;
37697
37801
  }
37698
37802
  const cached2 = this.scriptsCache.get(dir);
37699
37803
  if (cached2) return cached2;
37700
- const scriptsJs = path17.join(dir, "scripts.js");
37804
+ const scriptsJs = path18.join(dir, "scripts.js");
37701
37805
  if (fs7.existsSync(scriptsJs)) {
37702
37806
  try {
37703
37807
  delete require.cache[require.resolve(scriptsJs)];
@@ -37739,7 +37843,7 @@ var init_provider_loader = __esm({
37739
37843
  return;
37740
37844
  }
37741
37845
  if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
37742
- this.log(`File changed: ${path17.basename(filePath)}, reloading...`);
37846
+ this.log(`File changed: ${path18.basename(filePath)}, reloading...`);
37743
37847
  this.reload();
37744
37848
  }
37745
37849
  };
@@ -37794,7 +37898,7 @@ var init_provider_loader = __esm({
37794
37898
  }
37795
37899
  const https = require("https");
37796
37900
  const { execSync: execSync7 } = require("child_process");
37797
- const metaPath = path17.join(this.upstreamDir, _ProviderLoader.META_FILE);
37901
+ const metaPath = path18.join(this.upstreamDir, _ProviderLoader.META_FILE);
37798
37902
  let prevEtag = "";
37799
37903
  let prevTimestamp = 0;
37800
37904
  try {
@@ -37854,17 +37958,17 @@ var init_provider_loader = __esm({
37854
37958
  return { updated: false };
37855
37959
  }
37856
37960
  this.log("Downloading latest providers from GitHub...");
37857
- const tmpTar = path17.join(os16.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
37858
- const tmpExtract = path17.join(os16.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
37961
+ const tmpTar = path18.join(os16.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
37962
+ const tmpExtract = path18.join(os16.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
37859
37963
  await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
37860
37964
  fs7.mkdirSync(tmpExtract, { recursive: true });
37861
37965
  execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
37862
37966
  const extracted = fs7.readdirSync(tmpExtract);
37863
37967
  const rootDir = extracted.find(
37864
- (d) => fs7.statSync(path17.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
37968
+ (d) => fs7.statSync(path18.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
37865
37969
  );
37866
37970
  if (!rootDir) throw new Error("Unexpected tarball structure");
37867
- const sourceDir = path17.join(tmpExtract, rootDir);
37971
+ const sourceDir = path18.join(tmpExtract, rootDir);
37868
37972
  const backupDir = this.upstreamDir + ".bak";
37869
37973
  if (fs7.existsSync(this.upstreamDir)) {
37870
37974
  if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
@@ -37939,8 +38043,8 @@ var init_provider_loader = __esm({
37939
38043
  copyDirRecursive(src, dest) {
37940
38044
  fs7.mkdirSync(dest, { recursive: true });
37941
38045
  for (const entry of fs7.readdirSync(src, { withFileTypes: true })) {
37942
- const srcPath = path17.join(src, entry.name);
37943
- const destPath = path17.join(dest, entry.name);
38046
+ const srcPath = path18.join(src, entry.name);
38047
+ const destPath = path18.join(dest, entry.name);
37944
38048
  if (entry.isDirectory()) {
37945
38049
  this.copyDirRecursive(srcPath, destPath);
37946
38050
  } else {
@@ -37951,7 +38055,7 @@ var init_provider_loader = __esm({
37951
38055
  /** .meta.json save */
37952
38056
  writeMeta(metaPath, etag, timestamp) {
37953
38057
  try {
37954
- fs7.mkdirSync(path17.dirname(metaPath), { recursive: true });
38058
+ fs7.mkdirSync(path18.dirname(metaPath), { recursive: true });
37955
38059
  fs7.writeFileSync(metaPath, JSON.stringify({
37956
38060
  etag,
37957
38061
  timestamp,
@@ -37968,7 +38072,7 @@ var init_provider_loader = __esm({
37968
38072
  const scan = (d) => {
37969
38073
  try {
37970
38074
  for (const entry of fs7.readdirSync(d, { withFileTypes: true })) {
37971
- if (entry.isDirectory()) scan(path17.join(d, entry.name));
38075
+ if (entry.isDirectory()) scan(path18.join(d, entry.name));
37972
38076
  else if (entry.name === "provider.json") count++;
37973
38077
  }
37974
38078
  } catch {
@@ -38196,17 +38300,17 @@ var init_provider_loader = __esm({
38196
38300
  for (const root of searchRoots) {
38197
38301
  if (!fs7.existsSync(root)) continue;
38198
38302
  const candidate = this.getProviderDir(root, cat, type);
38199
- if (fs7.existsSync(path17.join(candidate, "provider.json"))) return candidate;
38200
- const catDir = path17.join(root, cat);
38303
+ if (fs7.existsSync(path18.join(candidate, "provider.json"))) return candidate;
38304
+ const catDir = path18.join(root, cat);
38201
38305
  if (fs7.existsSync(catDir)) {
38202
38306
  try {
38203
38307
  for (const entry of fs7.readdirSync(catDir, { withFileTypes: true })) {
38204
38308
  if (!entry.isDirectory()) continue;
38205
- const jsonPath = path17.join(catDir, entry.name, "provider.json");
38309
+ const jsonPath = path18.join(catDir, entry.name, "provider.json");
38206
38310
  if (fs7.existsSync(jsonPath)) {
38207
38311
  try {
38208
38312
  const data = JSON.parse(fs7.readFileSync(jsonPath, "utf-8"));
38209
- if (data.type === type) return path17.join(catDir, entry.name);
38313
+ if (data.type === type) return path18.join(catDir, entry.name);
38210
38314
  } catch {
38211
38315
  }
38212
38316
  }
@@ -38223,7 +38327,7 @@ var init_provider_loader = __esm({
38223
38327
  * (template substitution is NOT applied here — scripts.js handles that)
38224
38328
  */
38225
38329
  buildScriptWrappersFromDir(dir) {
38226
- const scriptsJs = path17.join(dir, "scripts.js");
38330
+ const scriptsJs = path18.join(dir, "scripts.js");
38227
38331
  if (fs7.existsSync(scriptsJs)) {
38228
38332
  try {
38229
38333
  delete require.cache[require.resolve(scriptsJs)];
@@ -38237,7 +38341,7 @@ var init_provider_loader = __esm({
38237
38341
  for (const file2 of fs7.readdirSync(dir)) {
38238
38342
  if (!file2.endsWith(".js")) continue;
38239
38343
  const scriptName = toCamel(file2.replace(".js", ""));
38240
- const filePath = path17.join(dir, file2);
38344
+ const filePath = path18.join(dir, file2);
38241
38345
  result[scriptName] = (...args) => {
38242
38346
  try {
38243
38347
  let content = fs7.readFileSync(filePath, "utf-8");
@@ -38297,7 +38401,7 @@ var init_provider_loader = __esm({
38297
38401
  }
38298
38402
  const hasJson = entries.some((e) => e.name === "provider.json");
38299
38403
  if (hasJson) {
38300
- const jsonPath = path17.join(d, "provider.json");
38404
+ const jsonPath = path18.join(d, "provider.json");
38301
38405
  try {
38302
38406
  const raw = fs7.readFileSync(jsonPath, "utf-8");
38303
38407
  const mod = JSON.parse(raw);
@@ -38318,7 +38422,7 @@ var init_provider_loader = __esm({
38318
38422
  this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
38319
38423
  } else {
38320
38424
  const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
38321
- const scriptsPath = path17.join(d, "scripts.js");
38425
+ const scriptsPath = path18.join(d, "scripts.js");
38322
38426
  if (!hasCompatibility && fs7.existsSync(scriptsPath)) {
38323
38427
  try {
38324
38428
  delete require.cache[require.resolve(scriptsPath)];
@@ -38344,7 +38448,7 @@ var init_provider_loader = __esm({
38344
38448
  if (!entry.isDirectory()) continue;
38345
38449
  if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
38346
38450
  if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
38347
- scan(path17.join(d, entry.name));
38451
+ scan(path18.join(d, entry.name));
38348
38452
  }
38349
38453
  }
38350
38454
  };
@@ -38675,8 +38779,8 @@ function detectCurrentWorkspace(ideId) {
38675
38779
  const appNameMap = getMacAppIdentifiers();
38676
38780
  const appName = appNameMap[ideId];
38677
38781
  if (appName) {
38678
- const storagePath = path18.join(
38679
- process.env.APPDATA || path18.join(os17.homedir(), "AppData", "Roaming"),
38782
+ const storagePath = path19.join(
38783
+ process.env.APPDATA || path19.join(os17.homedir(), "AppData", "Roaming"),
38680
38784
  appName,
38681
38785
  "storage.json"
38682
38786
  );
@@ -38858,14 +38962,14 @@ async function launchLinux(ide, port, workspace, newWindow) {
38858
38962
  function getAvailableIdeIds() {
38859
38963
  return getProviderLoader().getAvailableIdeTypes();
38860
38964
  }
38861
- var import_child_process7, net2, os17, path18, _providerLoader;
38965
+ var import_child_process7, net2, os17, path19, _providerLoader;
38862
38966
  var init_launch = __esm({
38863
38967
  "../../oss/packages/daemon-core/src/launch.ts"() {
38864
38968
  "use strict";
38865
38969
  import_child_process7 = require("child_process");
38866
38970
  net2 = __toESM(require("net"));
38867
38971
  os17 = __toESM(require("os"));
38868
- path18 = __toESM(require("path"));
38972
+ path19 = __toESM(require("path"));
38869
38973
  init_ide_detector();
38870
38974
  init_provider_loader();
38871
38975
  init_macos_app_process();
@@ -38897,7 +39001,7 @@ function checkRotation() {
38897
39001
  const today = getDateStr2();
38898
39002
  if (today !== currentDate2) {
38899
39003
  currentDate2 = today;
38900
- currentFile = path19.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
39004
+ currentFile = path20.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
38901
39005
  cleanOldFiles();
38902
39006
  }
38903
39007
  }
@@ -38911,7 +39015,7 @@ function cleanOldFiles() {
38911
39015
  const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
38912
39016
  if (dateMatch && dateMatch[1] < cutoffStr) {
38913
39017
  try {
38914
- fs8.unlinkSync(path19.join(LOG_DIR2, file2));
39018
+ fs8.unlinkSync(path20.join(LOG_DIR2, file2));
38915
39019
  } catch {
38916
39020
  }
38917
39021
  }
@@ -38983,14 +39087,14 @@ function getRecentCommands(count = 50) {
38983
39087
  return [];
38984
39088
  }
38985
39089
  }
38986
- var fs8, path19, os18, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
39090
+ var fs8, path20, os18, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
38987
39091
  var init_command_log = __esm({
38988
39092
  "../../oss/packages/daemon-core/src/logging/command-log.ts"() {
38989
39093
  "use strict";
38990
39094
  fs8 = __toESM(require("fs"));
38991
- path19 = __toESM(require("path"));
39095
+ path20 = __toESM(require("path"));
38992
39096
  os18 = __toESM(require("os"));
38993
- LOG_DIR2 = process.platform === "win32" ? path19.join(process.env.LOCALAPPDATA || process.env.APPDATA || path19.join(os18.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path19.join(os18.homedir(), "Library", "Logs", "adhdev") : path19.join(os18.homedir(), ".local", "share", "adhdev", "logs");
39097
+ LOG_DIR2 = process.platform === "win32" ? path20.join(process.env.LOCALAPPDATA || process.env.APPDATA || path20.join(os18.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path20.join(os18.homedir(), "Library", "Logs", "adhdev") : path20.join(os18.homedir(), ".local", "share", "adhdev", "logs");
38994
39098
  MAX_FILE_SIZE = 5 * 1024 * 1024;
38995
39099
  MAX_DAYS = 7;
38996
39100
  try {
@@ -39009,7 +39113,7 @@ var init_command_log = __esm({
39009
39113
  "text"
39010
39114
  ]);
39011
39115
  currentDate2 = getDateStr2();
39012
- currentFile = path19.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
39116
+ currentFile = path20.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
39013
39117
  writeCount2 = 0;
39014
39118
  SKIP_COMMANDS = /* @__PURE__ */ new Set([
39015
39119
  "heartbeat",
@@ -39042,8 +39146,8 @@ function resolveMeshCoordinatorSetup(options) {
39042
39146
  }
39043
39147
  const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
39044
39148
  if (mcpConfig.mode === "auto_import") {
39045
- const path33 = mcpConfig.path?.trim();
39046
- if (!path33) {
39149
+ const path34 = mcpConfig.path?.trim();
39150
+ if (!path34) {
39047
39151
  return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
39048
39152
  }
39049
39153
  const mcpServer = resolveAdhdevMcpServerLaunch({
@@ -39060,7 +39164,7 @@ function resolveMeshCoordinatorSetup(options) {
39060
39164
  return {
39061
39165
  kind: "auto_import",
39062
39166
  serverName,
39063
- configPath: (0, import_node_path2.join)(workspace, path33),
39167
+ configPath: (0, import_node_path2.join)(workspace, path34),
39064
39168
  configFormat: mcpConfig.format,
39065
39169
  mcpServer
39066
39170
  };
@@ -39099,7 +39203,7 @@ function resolveAdhdevMcpServerLaunch(options) {
39099
39203
  if (!entryPath) return null;
39100
39204
  return {
39101
39205
  command: options.nodeExecutable?.trim() || process.execPath,
39102
- args: [entryPath, "--repo-mesh", options.meshId]
39206
+ args: [entryPath, "--mode", "ipc", "--repo-mesh", options.meshId]
39103
39207
  };
39104
39208
  }
39105
39209
  function resolveAdhdevMcpEntryPath(explicitPath) {
@@ -39137,17 +39241,17 @@ function resolveAdhdevMcpEntryPath(explicitPath) {
39137
39241
  }
39138
39242
  function normalizeExistingPath(filePath) {
39139
39243
  try {
39140
- if (!(0, import_node_fs4.existsSync)(filePath)) return null;
39141
- return import_node_fs4.realpathSync.native(filePath);
39244
+ if (!(0, import_node_fs3.existsSync)(filePath)) return null;
39245
+ return import_node_fs3.realpathSync.native(filePath);
39142
39246
  } catch {
39143
39247
  return null;
39144
39248
  }
39145
39249
  }
39146
- var import_node_fs4, import_node_module2, import_node_path2, DEFAULT_SERVER_NAME, DEFAULT_ADHDEV_MCP_COMMAND;
39250
+ var import_node_fs3, import_node_module2, import_node_path2, DEFAULT_SERVER_NAME, DEFAULT_ADHDEV_MCP_COMMAND;
39147
39251
  var init_mesh_coordinator = __esm({
39148
39252
  "../../oss/packages/daemon-core/src/commands/mesh-coordinator.ts"() {
39149
39253
  "use strict";
39150
- import_node_fs4 = require("fs");
39254
+ import_node_fs3 = require("fs");
39151
39255
  import_node_module2 = require("module");
39152
39256
  import_node_path2 = require("path");
39153
39257
  DEFAULT_SERVER_NAME = "adhdev-mesh";
@@ -39484,9 +39588,9 @@ var init_snapshot = __esm({
39484
39588
  // ../../oss/packages/daemon-core/src/commands/upgrade-helper.ts
39485
39589
  function getUpgradeLogPath() {
39486
39590
  const home = os20.homedir();
39487
- const dir = path20.join(home, ".adhdev");
39591
+ const dir = path21.join(home, ".adhdev");
39488
39592
  fs9.mkdirSync(dir, { recursive: true });
39489
- return path20.join(dir, "daemon-upgrade.log");
39593
+ return path21.join(dir, "daemon-upgrade.log");
39490
39594
  }
39491
39595
  function appendUpgradeLog(message) {
39492
39596
  const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
@@ -39497,14 +39601,14 @@ function appendUpgradeLog(message) {
39497
39601
  }
39498
39602
  }
39499
39603
  function resolveSiblingNpmInvocation(nodeExecutable, platform12 = process.platform) {
39500
- const binDir = path20.dirname(nodeExecutable);
39604
+ const binDir = path21.dirname(nodeExecutable);
39501
39605
  if (platform12 === "win32") {
39502
- const npmCliPath = path20.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
39606
+ const npmCliPath = path21.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
39503
39607
  if (fs9.existsSync(npmCliPath)) {
39504
39608
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
39505
39609
  }
39506
39610
  for (const candidate of ["npm.exe", "npm"]) {
39507
- const candidatePath = path20.join(binDir, candidate);
39611
+ const candidatePath = path21.join(binDir, candidate);
39508
39612
  if (fs9.existsSync(candidatePath)) {
39509
39613
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
39510
39614
  }
@@ -39512,7 +39616,7 @@ function resolveSiblingNpmInvocation(nodeExecutable, platform12 = process.platfo
39512
39616
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
39513
39617
  }
39514
39618
  for (const candidate of ["npm"]) {
39515
- const candidatePath = path20.join(binDir, candidate);
39619
+ const candidatePath = path21.join(binDir, candidate);
39516
39620
  if (fs9.existsSync(candidatePath)) {
39517
39621
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
39518
39622
  }
@@ -39529,13 +39633,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
39529
39633
  let currentDir = resolvedPath;
39530
39634
  try {
39531
39635
  if (fs9.statSync(resolvedPath).isFile()) {
39532
- currentDir = path20.dirname(resolvedPath);
39636
+ currentDir = path21.dirname(resolvedPath);
39533
39637
  }
39534
39638
  } catch {
39535
- currentDir = path20.dirname(resolvedPath);
39639
+ currentDir = path21.dirname(resolvedPath);
39536
39640
  }
39537
39641
  while (true) {
39538
- const packageJsonPath = path20.join(currentDir, "package.json");
39642
+ const packageJsonPath = path21.join(currentDir, "package.json");
39539
39643
  try {
39540
39644
  if (fs9.existsSync(packageJsonPath)) {
39541
39645
  const parsed = JSON.parse(fs9.readFileSync(packageJsonPath, "utf8"));
@@ -39546,7 +39650,7 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
39546
39650
  }
39547
39651
  } catch {
39548
39652
  }
39549
- const parentDir = path20.dirname(currentDir);
39653
+ const parentDir = path21.dirname(currentDir);
39550
39654
  if (parentDir === currentDir) {
39551
39655
  return null;
39552
39656
  }
@@ -39554,13 +39658,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
39554
39658
  }
39555
39659
  }
39556
39660
  function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
39557
- const nodeModulesDir = packageName.startsWith("@") ? path20.dirname(path20.dirname(packageRoot)) : path20.dirname(packageRoot);
39558
- if (path20.basename(nodeModulesDir) !== "node_modules") {
39661
+ const nodeModulesDir = packageName.startsWith("@") ? path21.dirname(path21.dirname(packageRoot)) : path21.dirname(packageRoot);
39662
+ if (path21.basename(nodeModulesDir) !== "node_modules") {
39559
39663
  return null;
39560
39664
  }
39561
- const maybeLibDir = path20.dirname(nodeModulesDir);
39562
- if (path20.basename(maybeLibDir) === "lib") {
39563
- return path20.dirname(maybeLibDir);
39665
+ const maybeLibDir = path21.dirname(nodeModulesDir);
39666
+ if (path21.basename(maybeLibDir) === "lib") {
39667
+ return path21.dirname(maybeLibDir);
39564
39668
  }
39565
39669
  return maybeLibDir;
39566
39670
  }
@@ -39675,7 +39779,7 @@ async function waitForPidExit(pid, timeoutMs) {
39675
39779
  }
39676
39780
  }
39677
39781
  function stopSessionHostProcesses(appName) {
39678
- const pidFile = path20.join(os20.homedir(), ".adhdev", `${appName}-session-host.pid`);
39782
+ const pidFile = path21.join(os20.homedir(), ".adhdev", `${appName}-session-host.pid`);
39679
39783
  try {
39680
39784
  if (fs9.existsSync(pidFile)) {
39681
39785
  const pid = Number.parseInt(fs9.readFileSync(pidFile, "utf8").trim(), 10);
@@ -39692,7 +39796,7 @@ function stopSessionHostProcesses(appName) {
39692
39796
  }
39693
39797
  }
39694
39798
  function removeDaemonPidFile() {
39695
- const pidFile = path20.join(os20.homedir(), ".adhdev", "daemon.pid");
39799
+ const pidFile = path21.join(os20.homedir(), ".adhdev", "daemon.pid");
39696
39800
  try {
39697
39801
  fs9.unlinkSync(pidFile);
39698
39802
  } catch {
@@ -39703,7 +39807,7 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
39703
39807
  const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
39704
39808
  if (!npmRoot) return;
39705
39809
  const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
39706
- const binDir = process.platform === "win32" ? npmPrefix : path20.join(npmPrefix, "bin");
39810
+ const binDir = process.platform === "win32" ? npmPrefix : path21.join(npmPrefix, "bin");
39707
39811
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
39708
39812
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
39709
39813
  if (pkgName === "@adhdev/daemon-standalone") {
@@ -39711,25 +39815,25 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
39711
39815
  }
39712
39816
  if (pkgName.startsWith("@")) {
39713
39817
  const [scope, name] = pkgName.split("/");
39714
- const scopeDir = path20.join(npmRoot, scope);
39818
+ const scopeDir = path21.join(npmRoot, scope);
39715
39819
  if (!fs9.existsSync(scopeDir)) return;
39716
39820
  for (const entry of fs9.readdirSync(scopeDir)) {
39717
39821
  if (!entry.startsWith(`.${name}-`)) continue;
39718
- fs9.rmSync(path20.join(scopeDir, entry), { recursive: true, force: true });
39719
- appendUpgradeLog(`Removed stale scoped staging dir: ${path20.join(scopeDir, entry)}`);
39822
+ fs9.rmSync(path21.join(scopeDir, entry), { recursive: true, force: true });
39823
+ appendUpgradeLog(`Removed stale scoped staging dir: ${path21.join(scopeDir, entry)}`);
39720
39824
  }
39721
39825
  } else {
39722
39826
  for (const entry of fs9.readdirSync(npmRoot)) {
39723
39827
  if (!entry.startsWith(`.${pkgName}-`)) continue;
39724
- fs9.rmSync(path20.join(npmRoot, entry), { recursive: true, force: true });
39725
- appendUpgradeLog(`Removed stale staging dir: ${path20.join(npmRoot, entry)}`);
39828
+ fs9.rmSync(path21.join(npmRoot, entry), { recursive: true, force: true });
39829
+ appendUpgradeLog(`Removed stale staging dir: ${path21.join(npmRoot, entry)}`);
39726
39830
  }
39727
39831
  }
39728
39832
  if (fs9.existsSync(binDir)) {
39729
39833
  for (const entry of fs9.readdirSync(binDir)) {
39730
39834
  if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
39731
- fs9.rmSync(path20.join(binDir, entry), { recursive: true, force: true });
39732
- appendUpgradeLog(`Removed stale bin staging entry: ${path20.join(binDir, entry)}`);
39835
+ fs9.rmSync(path21.join(binDir, entry), { recursive: true, force: true });
39836
+ appendUpgradeLog(`Removed stale bin staging entry: ${path21.join(binDir, entry)}`);
39733
39837
  }
39734
39838
  }
39735
39839
  }
@@ -39812,7 +39916,7 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
39812
39916
  process.exit(1);
39813
39917
  }
39814
39918
  }
39815
- var import_child_process8, import_child_process9, fs9, os20, path20, UPGRADE_HELPER_ENV;
39919
+ var import_child_process8, import_child_process9, fs9, os20, path21, UPGRADE_HELPER_ENV;
39816
39920
  var init_upgrade_helper = __esm({
39817
39921
  "../../oss/packages/daemon-core/src/commands/upgrade-helper.ts"() {
39818
39922
  "use strict";
@@ -39820,7 +39924,7 @@ var init_upgrade_helper = __esm({
39820
39924
  import_child_process9 = require("child_process");
39821
39925
  fs9 = __toESM(require("fs"));
39822
39926
  os20 = __toESM(require("os"));
39823
- path20 = __toESM(require("path"));
39927
+ path21 = __toESM(require("path"));
39824
39928
  UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
39825
39929
  }
39826
39930
  });
@@ -39917,7 +40021,7 @@ function summarizeSessionHostPruneResult(result) {
39917
40021
  keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : void 0
39918
40022
  };
39919
40023
  }
39920
- var fs10, CHANNEL_NPM_TAG, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
40024
+ var fs10, CHANNEL_NPM_TAG, CHANNEL_SERVER_URL, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
39921
40025
  var init_router = __esm({
39922
40026
  "../../oss/packages/daemon-core/src/commands/router.ts"() {
39923
40027
  "use strict";
@@ -39945,6 +40049,10 @@ var init_router = __esm({
39945
40049
  init_upgrade_helper();
39946
40050
  fs10 = __toESM(require("fs"));
39947
40051
  CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
40052
+ CHANNEL_SERVER_URL = {
40053
+ stable: "https://api.adhf.dev",
40054
+ preview: "https://api-preview.adhf.dev"
40055
+ };
39948
40056
  CHAT_COMMANDS = [
39949
40057
  "send_chat",
39950
40058
  "new_chat",
@@ -39962,6 +40070,40 @@ var init_router = __esm({
39962
40070
  constructor(deps) {
39963
40071
  this.deps = deps;
39964
40072
  }
40073
+ getCachedInlineMesh(meshId, inlineMesh) {
40074
+ if (inlineMesh && typeof inlineMesh === "object") {
40075
+ this.inlineMeshCache.set(meshId, inlineMesh);
40076
+ return inlineMesh;
40077
+ }
40078
+ return this.inlineMeshCache.get(meshId);
40079
+ }
40080
+ async getMeshForCommand(meshId, inlineMesh) {
40081
+ try {
40082
+ const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
40083
+ const mesh = getMesh3(meshId);
40084
+ if (mesh) return { mesh, inline: false };
40085
+ } catch {
40086
+ }
40087
+ const cached2 = this.getCachedInlineMesh(meshId, inlineMesh);
40088
+ return cached2 ? { mesh: cached2, inline: true } : null;
40089
+ }
40090
+ updateInlineMeshNode(meshId, mesh, node) {
40091
+ if (!mesh || !Array.isArray(mesh.nodes) || !node?.id) return;
40092
+ const idx = mesh.nodes.findIndex((entry) => entry?.id === node.id || entry?.nodeId === node.id);
40093
+ if (idx >= 0) mesh.nodes[idx] = node;
40094
+ else mesh.nodes.push(node);
40095
+ mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
40096
+ this.inlineMeshCache.set(meshId, mesh);
40097
+ }
40098
+ removeInlineMeshNode(meshId, mesh, nodeId) {
40099
+ if (!mesh || !Array.isArray(mesh.nodes)) return false;
40100
+ const idx = mesh.nodes.findIndex((entry) => entry?.id === nodeId || entry?.nodeId === nodeId);
40101
+ if (idx === -1) return false;
40102
+ mesh.nodes.splice(idx, 1);
40103
+ mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
40104
+ this.inlineMeshCache.set(meshId, mesh);
40105
+ return true;
40106
+ }
39965
40107
  async traceSessionHostAction(action, args, run, summarizeResult) {
39966
40108
  const interactionId = typeof args?._interactionId === "string" ? args._interactionId : void 0;
39967
40109
  const sessionId = typeof args?.sessionId === "string" ? args.sessionId : void 0;
@@ -40550,6 +40692,7 @@ var init_router = __esm({
40550
40692
  const npmTag = CHANNEL_NPM_TAG[channel];
40551
40693
  const latest = String(execNpmCommandSync(["view", `${pkgName}@${npmTag}`, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
40552
40694
  LOG.info("Upgrade", `Latest ${pkgName}@${npmTag}: v${latest}`);
40695
+ updateConfig({ updateChannel: channel, serverUrl: CHANNEL_SERVER_URL[channel] });
40553
40696
  let currentInstalled = null;
40554
40697
  try {
40555
40698
  const currentJson = String(execNpmCommandSync(["ls", "-g", pkgName, "--depth=0", "--json"], {
@@ -40660,13 +40803,94 @@ var init_router = __esm({
40660
40803
  const nodeId = typeof args?.nodeId === "string" ? args.nodeId.trim() : "";
40661
40804
  if (!meshId || !nodeId) return { success: false, error: "meshId and nodeId required" };
40662
40805
  try {
40663
- const { removeNode: removeNode3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
40664
- const removed = removeNode3(meshId, nodeId);
40806
+ const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh);
40807
+ const mesh = meshRecord?.mesh;
40808
+ const node = mesh?.nodes?.find((n) => n.id === nodeId || n.nodeId === nodeId);
40809
+ if (node?.isLocalWorktree && node.workspace) {
40810
+ try {
40811
+ const sourceNode = node.clonedFromNodeId ? mesh?.nodes.find((n) => n.id === node.clonedFromNodeId || n.nodeId === node.clonedFromNodeId) : mesh?.nodes.find((n) => !n.isLocalWorktree);
40812
+ const repoRoot = sourceNode?.repoRoot || sourceNode?.workspace;
40813
+ if (repoRoot) {
40814
+ const { removeWorktree: removeWorktree2 } = await Promise.resolve().then(() => (init_git_worktree(), git_worktree_exports));
40815
+ await removeWorktree2(repoRoot, node.workspace);
40816
+ }
40817
+ } catch (e) {
40818
+ LOG.warn("MeshNode", `Worktree cleanup failed for ${nodeId}: ${e.message}`);
40819
+ }
40820
+ }
40821
+ let removed = false;
40822
+ if (meshRecord?.inline) {
40823
+ removed = this.removeInlineMeshNode(meshId, mesh, nodeId);
40824
+ } else {
40825
+ const { removeNode: removeNode3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
40826
+ removed = removeNode3(meshId, nodeId);
40827
+ }
40665
40828
  return { success: true, removed };
40666
40829
  } catch (e) {
40667
40830
  return { success: false, error: e.message };
40668
40831
  }
40669
40832
  }
40833
+ case "clone_mesh_node": {
40834
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
40835
+ const sourceNodeId = typeof args?.sourceNodeId === "string" ? args.sourceNodeId.trim() : "";
40836
+ const branch = typeof args?.branch === "string" ? args.branch.trim() : "";
40837
+ const baseBranch = typeof args?.baseBranch === "string" ? args.baseBranch.trim() : void 0;
40838
+ if (!meshId) return { success: false, error: "meshId required" };
40839
+ if (!sourceNodeId) return { success: false, error: "sourceNodeId required" };
40840
+ if (!branch) return { success: false, error: "branch required" };
40841
+ try {
40842
+ const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh);
40843
+ const mesh = meshRecord?.mesh;
40844
+ if (!mesh) return { success: false, error: "Mesh not found" };
40845
+ const sourceNode = mesh.nodes?.find((n) => n.id === sourceNodeId || n.nodeId === sourceNodeId);
40846
+ if (!sourceNode) return { success: false, error: `Source node '${sourceNodeId}' not found in mesh` };
40847
+ const repoRoot = sourceNode.repoRoot || sourceNode.workspace;
40848
+ const { createWorktree: createWorktree2 } = await Promise.resolve().then(() => (init_git_worktree(), git_worktree_exports));
40849
+ const result = await createWorktree2({
40850
+ repoRoot,
40851
+ branch,
40852
+ baseBranch,
40853
+ meshName: mesh.name
40854
+ });
40855
+ let node;
40856
+ if (meshRecord.inline) {
40857
+ const { randomUUID: randomUUID9 } = await import("crypto");
40858
+ node = {
40859
+ id: `node_${randomUUID9().replace(/-/g, "")}`,
40860
+ workspace: result.worktreePath,
40861
+ repoRoot: result.worktreePath,
40862
+ daemonId: sourceNode.daemonId,
40863
+ userOverrides: { ...sourceNode.userOverrides || {} },
40864
+ policy: { ...sourceNode.policy || {} },
40865
+ isLocalWorktree: true,
40866
+ worktreeBranch: result.branch,
40867
+ clonedFromNodeId: sourceNodeId
40868
+ };
40869
+ this.updateInlineMeshNode(meshId, mesh, node);
40870
+ } else {
40871
+ const { addNode: addNode3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
40872
+ node = addNode3(meshId, {
40873
+ workspace: result.worktreePath,
40874
+ repoRoot: result.worktreePath,
40875
+ daemonId: sourceNode.daemonId,
40876
+ userOverrides: { ...sourceNode.userOverrides || {} },
40877
+ isLocalWorktree: true,
40878
+ worktreeBranch: result.branch,
40879
+ clonedFromNodeId: sourceNodeId,
40880
+ policy: { ...sourceNode.policy || {} }
40881
+ });
40882
+ if (!node) return { success: false, error: "Failed to register worktree node" };
40883
+ }
40884
+ return {
40885
+ success: true,
40886
+ node,
40887
+ worktreePath: result.worktreePath,
40888
+ branch: result.branch
40889
+ };
40890
+ } catch (e) {
40891
+ return { success: false, error: e.message };
40892
+ }
40893
+ }
40670
40894
  // ─── Mesh Coordinator Launch ───
40671
40895
  case "launch_mesh_coordinator": {
40672
40896
  const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
@@ -40735,9 +40959,24 @@ var init_router = __esm({
40735
40959
  workspace
40736
40960
  };
40737
40961
  }
40738
- const { existsSync: existsSync26, readFileSync: readFileSync20, writeFileSync: writeFileSync14, copyFileSync: copyFileSync4 } = await import("fs");
40962
+ let systemPrompt = "";
40963
+ try {
40964
+ systemPrompt = buildCoordinatorSystemPrompt2({ mesh, coordinatorCliType: cliType });
40965
+ } catch (error48) {
40966
+ const message = error48?.message || String(error48);
40967
+ LOG.error("MeshCoordinator", `Failed to build coordinator prompt: ${message}`);
40968
+ return {
40969
+ success: false,
40970
+ code: "mesh_coordinator_prompt_failed",
40971
+ error: `Failed to build Repo Mesh coordinator prompt: ${message}`,
40972
+ meshId,
40973
+ cliType,
40974
+ workspace
40975
+ };
40976
+ }
40977
+ const { existsSync: existsSync27, readFileSync: readFileSync20, writeFileSync: writeFileSync14, copyFileSync: copyFileSync4 } = await import("fs");
40739
40978
  const mcpConfigPath = coordinatorSetup.configPath;
40740
- const hadExistingMcpConfig = existsSync26(mcpConfigPath);
40979
+ const hadExistingMcpConfig = existsSync27(mcpConfigPath);
40741
40980
  let existingMcpConfig = {};
40742
40981
  if (hadExistingMcpConfig) {
40743
40982
  try {
@@ -40752,7 +40991,8 @@ var init_router = __esm({
40752
40991
  };
40753
40992
  if (args?.inlineMesh) {
40754
40993
  mcpServerEntry.env = {
40755
- ADHDEV_INLINE_MESH: JSON.stringify(mesh)
40994
+ ADHDEV_INLINE_MESH: JSON.stringify(mesh),
40995
+ ADHDEV_MCP_TRANSPORT: "ipc"
40756
40996
  };
40757
40997
  }
40758
40998
  const mcpConfig = {
@@ -40764,12 +41004,6 @@ var init_router = __esm({
40764
41004
  };
40765
41005
  writeFileSync14(mcpConfigPath, JSON.stringify(mcpConfig, null, 2), "utf-8");
40766
41006
  LOG.info("MeshCoordinator", `Wrote ${mcpConfigPath} with ${coordinatorSetup.serverName} server`);
40767
- let systemPrompt = "";
40768
- try {
40769
- systemPrompt = buildCoordinatorSystemPrompt2({ mesh });
40770
- } catch {
40771
- systemPrompt = `You are a Repo Mesh Coordinator for "${mesh.name}". Use the adhdev-mesh MCP tools (mesh_status, mesh_list_nodes, mesh_send_task, mesh_read_chat, mesh_launch_session, etc.) to orchestrate work across ${mesh.nodes.length} node(s).`;
40772
- }
40773
41007
  const cliArgs = [];
40774
41008
  if (systemPrompt) {
40775
41009
  cliArgs.push("--append-system-prompt", systemPrompt);
@@ -42532,7 +42766,7 @@ function runCommand(cmd, timeout = 1e4) {
42532
42766
  }
42533
42767
  }
42534
42768
  function findBinary2(name) {
42535
- const cmd = (0, import_os3.platform)() === "win32" ? `where ${name}` : `which ${name}`;
42769
+ const cmd = (0, import_os4.platform)() === "win32" ? `where ${name}` : `which ${name}`;
42536
42770
  const result = runCommand(cmd, 5e3);
42537
42771
  return result ? result.split("\n")[0] : null;
42538
42772
  }
@@ -42571,7 +42805,7 @@ function checkPathExists2(paths) {
42571
42805
  for (const p of paths) {
42572
42806
  if (p.includes("*")) {
42573
42807
  const home = os21.homedir();
42574
- const resolved = p.replace(/\*/g, home.split(path21.sep).pop() || "");
42808
+ const resolved = p.replace(/\*/g, home.split(path23.sep).pop() || "");
42575
42809
  if (fs11.existsSync(resolved)) return resolved;
42576
42810
  } else {
42577
42811
  if (fs11.existsSync(p)) return p;
@@ -42580,15 +42814,15 @@ function checkPathExists2(paths) {
42580
42814
  return null;
42581
42815
  }
42582
42816
  function getMacAppVersion(appPath) {
42583
- if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
42584
- const plistPath = path21.join(appPath, "Contents", "Info.plist");
42817
+ if ((0, import_os4.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
42818
+ const plistPath = path23.join(appPath, "Contents", "Info.plist");
42585
42819
  if (!fs11.existsSync(plistPath)) return null;
42586
42820
  const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
42587
42821
  return raw || null;
42588
42822
  }
42589
42823
  async function detectAllVersions(loader, archive) {
42590
42824
  const results = [];
42591
- const currentOs = (0, import_os3.platform)();
42825
+ const currentOs = (0, import_os4.platform)();
42592
42826
  for (const provider of loader.getAll()) {
42593
42827
  const info = {
42594
42828
  type: provider.type,
@@ -42607,7 +42841,7 @@ async function detectAllVersions(loader, archive) {
42607
42841
  const cliBin = provider.cli ? findBinary2(provider.cli) : null;
42608
42842
  let resolvedBin = cliBin;
42609
42843
  if (!resolvedBin && appPath && currentOs === "darwin") {
42610
- const bundled = path21.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
42844
+ const bundled = path23.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
42611
42845
  if (provider.cli && fs11.existsSync(bundled)) resolvedBin = bundled;
42612
42846
  }
42613
42847
  info.installed = !!(appPath || resolvedBin);
@@ -42644,16 +42878,16 @@ async function detectAllVersions(loader, archive) {
42644
42878
  }
42645
42879
  return results;
42646
42880
  }
42647
- var fs11, path21, os21, import_child_process10, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
42881
+ var fs11, path23, os21, import_child_process10, import_os4, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
42648
42882
  var init_version_archive = __esm({
42649
42883
  "../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
42650
42884
  "use strict";
42651
42885
  fs11 = __toESM(require("fs"));
42652
- path21 = __toESM(require("path"));
42886
+ path23 = __toESM(require("path"));
42653
42887
  os21 = __toESM(require("os"));
42654
42888
  import_child_process10 = require("child_process");
42655
- import_os3 = require("os");
42656
- ARCHIVE_PATH = path21.join(os21.homedir(), ".adhdev", "version-history.json");
42889
+ import_os4 = require("os");
42890
+ ARCHIVE_PATH = path23.join(os21.homedir(), ".adhdev", "version-history.json");
42657
42891
  MAX_ENTRIES_PER_PROVIDER = 20;
42658
42892
  VersionArchive = class {
42659
42893
  history = {};
@@ -42678,7 +42912,7 @@ var init_version_archive = __esm({
42678
42912
  entries.push({
42679
42913
  version: version2,
42680
42914
  detectedAt: (/* @__PURE__ */ new Date()).toISOString(),
42681
- os: (0, import_os3.platform)()
42915
+ os: (0, import_os4.platform)()
42682
42916
  });
42683
42917
  if (entries.length > MAX_ENTRIES_PER_PROVIDER) {
42684
42918
  this.history[type] = entries.slice(-MAX_ENTRIES_PER_PROVIDER);
@@ -42700,7 +42934,7 @@ var init_version_archive = __esm({
42700
42934
  }
42701
42935
  save() {
42702
42936
  try {
42703
- fs11.mkdirSync(path21.dirname(ARCHIVE_PATH), { recursive: true });
42937
+ fs11.mkdirSync(path23.dirname(ARCHIVE_PATH), { recursive: true });
42704
42938
  fs11.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
42705
42939
  } catch {
42706
42940
  }
@@ -43235,17 +43469,17 @@ async function handleScriptHints(ctx, type, _req, res) {
43235
43469
  return;
43236
43470
  }
43237
43471
  let scriptsPath = "";
43238
- const directScripts = path23.join(dir, "scripts.js");
43472
+ const directScripts = path24.join(dir, "scripts.js");
43239
43473
  if (fs12.existsSync(directScripts)) {
43240
43474
  scriptsPath = directScripts;
43241
43475
  } else {
43242
- const scriptsDir = path23.join(dir, "scripts");
43476
+ const scriptsDir = path24.join(dir, "scripts");
43243
43477
  if (fs12.existsSync(scriptsDir)) {
43244
43478
  const versions = fs12.readdirSync(scriptsDir).filter((d) => {
43245
- return fs12.statSync(path23.join(scriptsDir, d)).isDirectory();
43479
+ return fs12.statSync(path24.join(scriptsDir, d)).isDirectory();
43246
43480
  }).sort().reverse();
43247
43481
  for (const ver of versions) {
43248
- const p = path23.join(scriptsDir, ver, "scripts.js");
43482
+ const p = path24.join(scriptsDir, ver, "scripts.js");
43249
43483
  if (fs12.existsSync(p)) {
43250
43484
  scriptsPath = p;
43251
43485
  break;
@@ -44071,12 +44305,12 @@ async function handleDomContext(ctx, type, req, res) {
44071
44305
  ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
44072
44306
  }
44073
44307
  }
44074
- var fs12, path23;
44308
+ var fs12, path24;
44075
44309
  var init_dev_cdp_handlers = __esm({
44076
44310
  "../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
44077
44311
  "use strict";
44078
44312
  fs12 = __toESM(require("fs"));
44079
- path23 = __toESM(require("path"));
44313
+ path24 = __toESM(require("path"));
44080
44314
  init_logger();
44081
44315
  }
44082
44316
  });
@@ -44091,11 +44325,11 @@ function getCliFixtureDir(ctx, type) {
44091
44325
  if (!providerDir) {
44092
44326
  throw new Error(`Provider directory not found for '${type}'`);
44093
44327
  }
44094
- return path24.join(providerDir, "fixtures");
44328
+ return path25.join(providerDir, "fixtures");
44095
44329
  }
44096
44330
  function readCliFixture(ctx, type, name) {
44097
44331
  const fixtureDir = getCliFixtureDir(ctx, type);
44098
- const filePath = path24.join(fixtureDir, `${name}.json`);
44332
+ const filePath = path25.join(fixtureDir, `${name}.json`);
44099
44333
  if (!fs13.existsSync(filePath)) {
44100
44334
  throw new Error(`Fixture not found: ${filePath}`);
44101
44335
  }
@@ -44862,7 +45096,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
44862
45096
  },
44863
45097
  notes: typeof body?.notes === "string" ? body.notes : void 0
44864
45098
  };
44865
- const filePath = path24.join(fixtureDir, `${name}.json`);
45099
+ const filePath = path25.join(fixtureDir, `${name}.json`);
44866
45100
  fs13.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
44867
45101
  ctx.json(res, 200, {
44868
45102
  saved: true,
@@ -44886,7 +45120,7 @@ async function handleCliFixtureList(ctx, type, _req, res) {
44886
45120
  return;
44887
45121
  }
44888
45122
  const fixtures = fs13.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
44889
- const fullPath = path24.join(fixtureDir, file2);
45123
+ const fullPath = path25.join(fixtureDir, file2);
44890
45124
  try {
44891
45125
  const raw = JSON.parse(fs13.readFileSync(fullPath, "utf-8"));
44892
45126
  return {
@@ -45019,12 +45253,12 @@ async function handleCliRaw(ctx, req, res) {
45019
45253
  ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
45020
45254
  }
45021
45255
  }
45022
- var fs13, path24;
45256
+ var fs13, path25;
45023
45257
  var init_dev_cli_debug = __esm({
45024
45258
  "../../oss/packages/daemon-core/src/daemon/dev-cli-debug.ts"() {
45025
45259
  "use strict";
45026
45260
  fs13 = __toESM(require("fs"));
45027
- path24 = __toESM(require("path"));
45261
+ path25 = __toESM(require("path"));
45028
45262
  }
45029
45263
  });
45030
45264
 
@@ -45077,22 +45311,22 @@ function getLatestScriptVersionDir(scriptsDir) {
45077
45311
  if (!fs14.existsSync(scriptsDir)) return null;
45078
45312
  const versions = fs14.readdirSync(scriptsDir).filter((d) => {
45079
45313
  try {
45080
- return fs14.statSync(path25.join(scriptsDir, d)).isDirectory();
45314
+ return fs14.statSync(path26.join(scriptsDir, d)).isDirectory();
45081
45315
  } catch {
45082
45316
  return false;
45083
45317
  }
45084
45318
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
45085
45319
  if (versions.length === 0) return null;
45086
- return path25.join(scriptsDir, versions[0]);
45320
+ return path26.join(scriptsDir, versions[0]);
45087
45321
  }
45088
45322
  function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
45089
- const canonicalUserDir = path25.resolve(ctx.providerLoader.getUserProviderDir(category, type));
45090
- const desiredDir = requestedDir ? path25.resolve(requestedDir) : canonicalUserDir;
45091
- const upstreamRoot = path25.resolve(ctx.providerLoader.getUpstreamDir());
45092
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path25.sep}`)) {
45323
+ const canonicalUserDir = path26.resolve(ctx.providerLoader.getUserProviderDir(category, type));
45324
+ const desiredDir = requestedDir ? path26.resolve(requestedDir) : canonicalUserDir;
45325
+ const upstreamRoot = path26.resolve(ctx.providerLoader.getUpstreamDir());
45326
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path26.sep}`)) {
45093
45327
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
45094
45328
  }
45095
- if (path25.basename(desiredDir) !== type) {
45329
+ if (path26.basename(desiredDir) !== type) {
45096
45330
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
45097
45331
  }
45098
45332
  const sourceDir = ctx.findProviderDir(type);
@@ -45100,11 +45334,11 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
45100
45334
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
45101
45335
  }
45102
45336
  if (!fs14.existsSync(desiredDir)) {
45103
- fs14.mkdirSync(path25.dirname(desiredDir), { recursive: true });
45337
+ fs14.mkdirSync(path26.dirname(desiredDir), { recursive: true });
45104
45338
  fs14.cpSync(sourceDir, desiredDir, { recursive: true });
45105
45339
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
45106
45340
  }
45107
- const providerJson = path25.join(desiredDir, "provider.json");
45341
+ const providerJson = path26.join(desiredDir, "provider.json");
45108
45342
  if (!fs14.existsSync(providerJson)) {
45109
45343
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
45110
45344
  }
@@ -45115,13 +45349,13 @@ function loadAutoImplReferenceScripts(ctx, referenceType) {
45115
45349
  const refDir = ctx.findProviderDir(referenceType);
45116
45350
  if (!refDir || !fs14.existsSync(refDir)) return {};
45117
45351
  const referenceScripts = {};
45118
- const scriptsDir = path25.join(refDir, "scripts");
45352
+ const scriptsDir = path26.join(refDir, "scripts");
45119
45353
  const latestDir = getLatestScriptVersionDir(scriptsDir);
45120
45354
  if (!latestDir) return referenceScripts;
45121
45355
  for (const file2 of fs14.readdirSync(latestDir)) {
45122
45356
  if (!file2.endsWith(".js")) continue;
45123
45357
  try {
45124
- referenceScripts[file2] = fs14.readFileSync(path25.join(latestDir, file2), "utf-8");
45358
+ referenceScripts[file2] = fs14.readFileSync(path26.join(latestDir, file2), "utf-8");
45125
45359
  } catch {
45126
45360
  }
45127
45361
  }
@@ -45229,9 +45463,9 @@ async function handleAutoImplement(ctx, type, req, res) {
45229
45463
  });
45230
45464
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
45231
45465
  const prompt2 = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
45232
- const tmpDir = path25.join(os23.tmpdir(), "adhdev-autoimpl");
45466
+ const tmpDir = path26.join(os23.tmpdir(), "adhdev-autoimpl");
45233
45467
  if (!fs14.existsSync(tmpDir)) fs14.mkdirSync(tmpDir, { recursive: true });
45234
- const promptFile = path25.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
45468
+ const promptFile = path26.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
45235
45469
  fs14.writeFileSync(promptFile, prompt2, "utf-8");
45236
45470
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt2.length} chars)`);
45237
45471
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
@@ -45663,7 +45897,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
45663
45897
  setMode: "set_mode.js"
45664
45898
  };
45665
45899
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
45666
- const scriptsDir = path25.join(providerDir, "scripts");
45900
+ const scriptsDir = path26.join(providerDir, "scripts");
45667
45901
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
45668
45902
  if (latestScriptsDir) {
45669
45903
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -45674,7 +45908,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
45674
45908
  for (const file2 of fs14.readdirSync(latestScriptsDir)) {
45675
45909
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
45676
45910
  try {
45677
- const content = fs14.readFileSync(path25.join(latestScriptsDir, file2), "utf-8");
45911
+ const content = fs14.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
45678
45912
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
45679
45913
  lines.push("```javascript");
45680
45914
  lines.push(content);
@@ -45691,7 +45925,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
45691
45925
  lines.push("");
45692
45926
  for (const file2 of refFiles) {
45693
45927
  try {
45694
- const content = fs14.readFileSync(path25.join(latestScriptsDir, file2), "utf-8");
45928
+ const content = fs14.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
45695
45929
  lines.push(`### \`${file2}\` \u{1F512}`);
45696
45930
  lines.push("```javascript");
45697
45931
  lines.push(content);
@@ -45732,10 +45966,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
45732
45966
  lines.push("");
45733
45967
  }
45734
45968
  }
45735
- const docsDir = path25.join(providerDir, "../../docs");
45969
+ const docsDir = path26.join(providerDir, "../../docs");
45736
45970
  const loadGuide = (name) => {
45737
45971
  try {
45738
- const p = path25.join(docsDir, name);
45972
+ const p = path26.join(docsDir, name);
45739
45973
  if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
45740
45974
  } catch {
45741
45975
  }
@@ -45972,7 +46206,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
45972
46206
  parseApproval: "parse_approval.js"
45973
46207
  };
45974
46208
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
45975
- const scriptsDir = path25.join(providerDir, "scripts");
46209
+ const scriptsDir = path26.join(providerDir, "scripts");
45976
46210
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
45977
46211
  if (latestScriptsDir) {
45978
46212
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -45984,7 +46218,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
45984
46218
  if (!file2.endsWith(".js")) continue;
45985
46219
  if (!targetFileNames.has(file2)) continue;
45986
46220
  try {
45987
- const content = fs14.readFileSync(path25.join(latestScriptsDir, file2), "utf-8");
46221
+ const content = fs14.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
45988
46222
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
45989
46223
  lines.push("```javascript");
45990
46224
  lines.push(content);
@@ -46000,7 +46234,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
46000
46234
  lines.push("");
46001
46235
  for (const file2 of refFiles) {
46002
46236
  try {
46003
- const content = fs14.readFileSync(path25.join(latestScriptsDir, file2), "utf-8");
46237
+ const content = fs14.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
46004
46238
  lines.push(`### \`${file2}\` \u{1F512}`);
46005
46239
  lines.push("```javascript");
46006
46240
  lines.push(content);
@@ -46033,10 +46267,10 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
46033
46267
  lines.push("");
46034
46268
  }
46035
46269
  }
46036
- const docsDir = path25.join(providerDir, "../../docs");
46270
+ const docsDir = path26.join(providerDir, "../../docs");
46037
46271
  const loadGuide = (name) => {
46038
46272
  try {
46039
- const p = path25.join(docsDir, name);
46273
+ const p = path26.join(docsDir, name);
46040
46274
  if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
46041
46275
  } catch {
46042
46276
  }
@@ -46348,12 +46582,12 @@ data: ${JSON.stringify(msg.data)}
46348
46582
  }
46349
46583
  }
46350
46584
  }
46351
- var fs14, path25, os23;
46585
+ var fs14, path26, os23;
46352
46586
  var init_dev_auto_implement = __esm({
46353
46587
  "../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
46354
46588
  "use strict";
46355
46589
  fs14 = __toESM(require("fs"));
46356
- path25 = __toESM(require("path"));
46590
+ path26 = __toESM(require("path"));
46357
46591
  os23 = __toESM(require("os"));
46358
46592
  init_dev_server();
46359
46593
  init_dev_cli_debug();
@@ -46393,13 +46627,13 @@ function toProviderListEntry(provider) {
46393
46627
  }
46394
46628
  return base;
46395
46629
  }
46396
- var http2, fs15, path26, DEV_SERVER_PORT, DevServer;
46630
+ var http2, fs15, path27, DEV_SERVER_PORT, DevServer;
46397
46631
  var init_dev_server = __esm({
46398
46632
  "../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
46399
46633
  "use strict";
46400
46634
  http2 = __toESM(require("http"));
46401
46635
  fs15 = __toESM(require("fs"));
46402
- path26 = __toESM(require("path"));
46636
+ path27 = __toESM(require("path"));
46403
46637
  init_provider_schema();
46404
46638
  init_config();
46405
46639
  init_provider_source_config();
@@ -46512,8 +46746,8 @@ var init_dev_server = __esm({
46512
46746
  }
46513
46747
  getEndpointList() {
46514
46748
  return this.routes.map((r) => {
46515
- const path33 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
46516
- return `${r.method.padEnd(5)} ${path33}`;
46749
+ const path34 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
46750
+ return `${r.method.padEnd(5)} ${path34}`;
46517
46751
  });
46518
46752
  }
46519
46753
  async start(port = DEV_SERVER_PORT) {
@@ -46801,12 +47035,12 @@ var init_dev_server = __esm({
46801
47035
  // ─── DevConsole SPA ───
46802
47036
  getConsoleDistDir() {
46803
47037
  const candidates = [
46804
- path26.resolve(__dirname, "../../web-devconsole/dist"),
46805
- path26.resolve(__dirname, "../../../web-devconsole/dist"),
46806
- path26.join(process.cwd(), "packages/web-devconsole/dist")
47038
+ path27.resolve(__dirname, "../../web-devconsole/dist"),
47039
+ path27.resolve(__dirname, "../../../web-devconsole/dist"),
47040
+ path27.join(process.cwd(), "packages/web-devconsole/dist")
46807
47041
  ];
46808
47042
  for (const dir of candidates) {
46809
- if (fs15.existsSync(path26.join(dir, "index.html"))) return dir;
47043
+ if (fs15.existsSync(path27.join(dir, "index.html"))) return dir;
46810
47044
  }
46811
47045
  return null;
46812
47046
  }
@@ -46816,7 +47050,7 @@ var init_dev_server = __esm({
46816
47050
  this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
46817
47051
  return;
46818
47052
  }
46819
- const htmlPath = path26.join(distDir, "index.html");
47053
+ const htmlPath = path27.join(distDir, "index.html");
46820
47054
  try {
46821
47055
  const html = fs15.readFileSync(htmlPath, "utf-8");
46822
47056
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
@@ -46841,15 +47075,15 @@ var init_dev_server = __esm({
46841
47075
  this.json(res, 404, { error: "Not found" });
46842
47076
  return;
46843
47077
  }
46844
- const safePath = path26.normalize(pathname).replace(/^\.\.\//, "");
46845
- const filePath = path26.join(distDir, safePath);
47078
+ const safePath = path27.normalize(pathname).replace(/^\.\.\//, "");
47079
+ const filePath = path27.join(distDir, safePath);
46846
47080
  if (!filePath.startsWith(distDir)) {
46847
47081
  this.json(res, 403, { error: "Forbidden" });
46848
47082
  return;
46849
47083
  }
46850
47084
  try {
46851
47085
  const content = fs15.readFileSync(filePath);
46852
- const ext = path26.extname(filePath);
47086
+ const ext = path27.extname(filePath);
46853
47087
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
46854
47088
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
46855
47089
  res.end(content);
@@ -46962,9 +47196,9 @@ var init_dev_server = __esm({
46962
47196
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
46963
47197
  if (entry.isDirectory()) {
46964
47198
  files.push({ path: rel, size: 0, type: "dir" });
46965
- scan(path26.join(d, entry.name), rel);
47199
+ scan(path27.join(d, entry.name), rel);
46966
47200
  } else {
46967
- const stat5 = fs15.statSync(path26.join(d, entry.name));
47201
+ const stat5 = fs15.statSync(path27.join(d, entry.name));
46968
47202
  files.push({ path: rel, size: stat5.size, type: "file" });
46969
47203
  }
46970
47204
  }
@@ -46987,7 +47221,7 @@ var init_dev_server = __esm({
46987
47221
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
46988
47222
  return;
46989
47223
  }
46990
- const fullPath = path26.resolve(dir, path26.normalize(filePath));
47224
+ const fullPath = path27.resolve(dir, path27.normalize(filePath));
46991
47225
  if (!fullPath.startsWith(dir)) {
46992
47226
  this.json(res, 403, { error: "Forbidden" });
46993
47227
  return;
@@ -47012,14 +47246,14 @@ var init_dev_server = __esm({
47012
47246
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
47013
47247
  return;
47014
47248
  }
47015
- const fullPath = path26.resolve(dir, path26.normalize(filePath));
47249
+ const fullPath = path27.resolve(dir, path27.normalize(filePath));
47016
47250
  if (!fullPath.startsWith(dir)) {
47017
47251
  this.json(res, 403, { error: "Forbidden" });
47018
47252
  return;
47019
47253
  }
47020
47254
  try {
47021
47255
  if (fs15.existsSync(fullPath)) fs15.copyFileSync(fullPath, fullPath + ".bak");
47022
- fs15.mkdirSync(path26.dirname(fullPath), { recursive: true });
47256
+ fs15.mkdirSync(path27.dirname(fullPath), { recursive: true });
47023
47257
  fs15.writeFileSync(fullPath, content, "utf-8");
47024
47258
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
47025
47259
  this.providerLoader.reload();
@@ -47036,7 +47270,7 @@ var init_dev_server = __esm({
47036
47270
  return;
47037
47271
  }
47038
47272
  for (const name of ["scripts.js", "provider.json"]) {
47039
- const p = path26.join(dir, name);
47273
+ const p = path27.join(dir, name);
47040
47274
  if (fs15.existsSync(p)) {
47041
47275
  const source = fs15.readFileSync(p, "utf-8");
47042
47276
  this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
@@ -47057,8 +47291,8 @@ var init_dev_server = __esm({
47057
47291
  this.json(res, 404, { error: `Provider not found: ${type}` });
47058
47292
  return;
47059
47293
  }
47060
- const target = fs15.existsSync(path26.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
47061
- const targetPath = path26.join(dir, target);
47294
+ const target = fs15.existsSync(path27.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
47295
+ const targetPath = path27.join(dir, target);
47062
47296
  try {
47063
47297
  if (fs15.existsSync(targetPath)) fs15.copyFileSync(targetPath, targetPath + ".bak");
47064
47298
  fs15.writeFileSync(targetPath, source, "utf-8");
@@ -47205,7 +47439,7 @@ var init_dev_server = __esm({
47205
47439
  }
47206
47440
  let targetDir;
47207
47441
  targetDir = this.providerLoader.getUserProviderDir(category, type);
47208
- const jsonPath = path26.join(targetDir, "provider.json");
47442
+ const jsonPath = path27.join(targetDir, "provider.json");
47209
47443
  if (fs15.existsSync(jsonPath)) {
47210
47444
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
47211
47445
  return;
@@ -47217,8 +47451,8 @@ var init_dev_server = __esm({
47217
47451
  const createdFiles = ["provider.json"];
47218
47452
  if (result.files) {
47219
47453
  for (const [relPath, content] of Object.entries(result.files)) {
47220
- const fullPath = path26.join(targetDir, relPath);
47221
- fs15.mkdirSync(path26.dirname(fullPath), { recursive: true });
47454
+ const fullPath = path27.join(targetDir, relPath);
47455
+ fs15.mkdirSync(path27.dirname(fullPath), { recursive: true });
47222
47456
  fs15.writeFileSync(fullPath, content, "utf-8");
47223
47457
  createdFiles.push(relPath);
47224
47458
  }
@@ -47271,22 +47505,22 @@ var init_dev_server = __esm({
47271
47505
  if (!fs15.existsSync(scriptsDir)) return null;
47272
47506
  const versions = fs15.readdirSync(scriptsDir).filter((d) => {
47273
47507
  try {
47274
- return fs15.statSync(path26.join(scriptsDir, d)).isDirectory();
47508
+ return fs15.statSync(path27.join(scriptsDir, d)).isDirectory();
47275
47509
  } catch {
47276
47510
  return false;
47277
47511
  }
47278
47512
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
47279
47513
  if (versions.length === 0) return null;
47280
- return path26.join(scriptsDir, versions[0]);
47514
+ return path27.join(scriptsDir, versions[0]);
47281
47515
  }
47282
47516
  resolveAutoImplWritableProviderDir(category, type, requestedDir) {
47283
- const canonicalUserDir = path26.resolve(this.providerLoader.getUserProviderDir(category, type));
47284
- const desiredDir = requestedDir ? path26.resolve(requestedDir) : canonicalUserDir;
47285
- const upstreamRoot = path26.resolve(this.providerLoader.getUpstreamDir());
47286
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path26.sep}`)) {
47517
+ const canonicalUserDir = path27.resolve(this.providerLoader.getUserProviderDir(category, type));
47518
+ const desiredDir = requestedDir ? path27.resolve(requestedDir) : canonicalUserDir;
47519
+ const upstreamRoot = path27.resolve(this.providerLoader.getUpstreamDir());
47520
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path27.sep}`)) {
47287
47521
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
47288
47522
  }
47289
- if (path26.basename(desiredDir) !== type) {
47523
+ if (path27.basename(desiredDir) !== type) {
47290
47524
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
47291
47525
  }
47292
47526
  const sourceDir = this.findProviderDir(type);
@@ -47294,11 +47528,11 @@ var init_dev_server = __esm({
47294
47528
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
47295
47529
  }
47296
47530
  if (!fs15.existsSync(desiredDir)) {
47297
- fs15.mkdirSync(path26.dirname(desiredDir), { recursive: true });
47531
+ fs15.mkdirSync(path27.dirname(desiredDir), { recursive: true });
47298
47532
  fs15.cpSync(sourceDir, desiredDir, { recursive: true });
47299
47533
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
47300
47534
  }
47301
- const providerJson = path26.join(desiredDir, "provider.json");
47535
+ const providerJson = path27.join(desiredDir, "provider.json");
47302
47536
  if (!fs15.existsSync(providerJson)) {
47303
47537
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
47304
47538
  }
@@ -47334,7 +47568,7 @@ var init_dev_server = __esm({
47334
47568
  setMode: "set_mode.js"
47335
47569
  };
47336
47570
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
47337
- const scriptsDir = path26.join(providerDir, "scripts");
47571
+ const scriptsDir = path27.join(providerDir, "scripts");
47338
47572
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
47339
47573
  if (latestScriptsDir) {
47340
47574
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -47345,7 +47579,7 @@ var init_dev_server = __esm({
47345
47579
  for (const file2 of fs15.readdirSync(latestScriptsDir)) {
47346
47580
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
47347
47581
  try {
47348
- const content = fs15.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
47582
+ const content = fs15.readFileSync(path27.join(latestScriptsDir, file2), "utf-8");
47349
47583
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
47350
47584
  lines.push("```javascript");
47351
47585
  lines.push(content);
@@ -47362,7 +47596,7 @@ var init_dev_server = __esm({
47362
47596
  lines.push("");
47363
47597
  for (const file2 of refFiles) {
47364
47598
  try {
47365
- const content = fs15.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
47599
+ const content = fs15.readFileSync(path27.join(latestScriptsDir, file2), "utf-8");
47366
47600
  lines.push(`### \`${file2}\` \u{1F512}`);
47367
47601
  lines.push("```javascript");
47368
47602
  lines.push(content);
@@ -47403,10 +47637,10 @@ var init_dev_server = __esm({
47403
47637
  lines.push("");
47404
47638
  }
47405
47639
  }
47406
- const docsDir = path26.join(providerDir, "../../docs");
47640
+ const docsDir = path27.join(providerDir, "../../docs");
47407
47641
  const loadGuide = (name) => {
47408
47642
  try {
47409
- const p = path26.join(docsDir, name);
47643
+ const p = path27.join(docsDir, name);
47410
47644
  if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
47411
47645
  } catch {
47412
47646
  }
@@ -47580,7 +47814,7 @@ var init_dev_server = __esm({
47580
47814
  parseApproval: "parse_approval.js"
47581
47815
  };
47582
47816
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
47583
- const scriptsDir = path26.join(providerDir, "scripts");
47817
+ const scriptsDir = path27.join(providerDir, "scripts");
47584
47818
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
47585
47819
  if (latestScriptsDir) {
47586
47820
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -47592,7 +47826,7 @@ var init_dev_server = __esm({
47592
47826
  if (!file2.endsWith(".js")) continue;
47593
47827
  if (!targetFileNames.has(file2)) continue;
47594
47828
  try {
47595
- const content = fs15.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
47829
+ const content = fs15.readFileSync(path27.join(latestScriptsDir, file2), "utf-8");
47596
47830
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
47597
47831
  lines.push("```javascript");
47598
47832
  lines.push(content);
@@ -47608,7 +47842,7 @@ var init_dev_server = __esm({
47608
47842
  lines.push("");
47609
47843
  for (const file2 of refFiles) {
47610
47844
  try {
47611
- const content = fs15.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
47845
+ const content = fs15.readFileSync(path27.join(latestScriptsDir, file2), "utf-8");
47612
47846
  lines.push(`### \`${file2}\` \u{1F512}`);
47613
47847
  lines.push("```javascript");
47614
47848
  lines.push(content);
@@ -47641,10 +47875,10 @@ var init_dev_server = __esm({
47641
47875
  lines.push("");
47642
47876
  }
47643
47877
  }
47644
- const docsDir = path26.join(providerDir, "../../docs");
47878
+ const docsDir = path27.join(providerDir, "../../docs");
47645
47879
  const loadGuide = (name) => {
47646
47880
  try {
47647
- const p = path26.join(docsDir, name);
47881
+ const p = path27.join(docsDir, name);
47648
47882
  if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
47649
47883
  } catch {
47650
47884
  }
@@ -49053,6 +49287,7 @@ __export(src_exports, {
49053
49287
  createGitWorkspaceMonitor: () => createGitWorkspaceMonitor,
49054
49288
  createInteractionId: () => createInteractionId,
49055
49289
  createMesh: () => createMesh,
49290
+ createWorktree: () => createWorktree,
49056
49291
  deleteMesh: () => deleteMesh,
49057
49292
  detectAllVersions: () => detectAllVersions,
49058
49293
  detectCLIs: () => detectCLIs,
@@ -49105,6 +49340,7 @@ __export(src_exports, {
49105
49340
  launchWithCdp: () => launchWithCdp,
49106
49341
  listHostedCliRuntimes: () => listHostedCliRuntimes,
49107
49342
  listMeshes: () => listMeshes,
49343
+ listWorktrees: () => listWorktrees,
49108
49344
  loadConfig: () => loadConfig,
49109
49345
  loadState: () => loadState,
49110
49346
  logCommand: () => logCommand,
@@ -49124,6 +49360,7 @@ __export(src_exports, {
49124
49360
  normalizeSessionModalFields: () => normalizeSessionModalFields,
49125
49361
  parsePorcelainV2Status: () => parsePorcelainV2Status,
49126
49362
  parseProviderSourceConfigUpdate: () => parseProviderSourceConfigUpdate,
49363
+ parseWorktreeListOutput: () => parseWorktreeListOutput,
49127
49364
  partitionSessionHostDiagnosticsSessions: () => partitionSessionHostDiagnosticsSessions,
49128
49365
  partitionSessionHostRecords: () => partitionSessionHostRecords,
49129
49366
  prepareSessionChatTailUpdate: () => prepareSessionChatTailUpdate,
@@ -49133,6 +49370,7 @@ __export(src_exports, {
49133
49370
  recordDebugTrace: () => recordDebugTrace,
49134
49371
  registerExtensionProviders: () => registerExtensionProviders,
49135
49372
  removeNode: () => removeNode,
49373
+ removeWorktree: () => removeWorktree,
49136
49374
  resetConfig: () => resetConfig,
49137
49375
  resetDebugRuntimeConfig: () => resetDebugRuntimeConfig,
49138
49376
  resetState: () => resetState,
@@ -49142,6 +49380,7 @@ __export(src_exports, {
49142
49380
  resolveGitRepository: () => resolveGitRepository,
49143
49381
  resolveSessionHostAppName: () => resolveSessionHostAppName,
49144
49382
  resolveSessionHostAppNameResolution: () => resolveSessionHostAppNameResolution,
49383
+ resolveWorktreePath: () => resolveWorktreePath,
49145
49384
  runAsyncBatch: () => runAsyncBatch,
49146
49385
  runGit: () => runGit,
49147
49386
  saveConfig: () => saveConfig,
@@ -49347,13 +49586,14 @@ var init_server_connection = __esm({
49347
49586
  reject(new Error(`Mesh command timed out after ${timeoutMs}ms`));
49348
49587
  }, timeoutMs);
49349
49588
  const handler = (msg) => {
49350
- if (msg.payload?.requestId !== requestId) return;
49589
+ const body = msg.payload && typeof msg.payload === "object" ? { ...msg, ...msg.payload } : msg;
49590
+ if (body.requestId !== requestId) return;
49351
49591
  this.off("daemon_mesh_result", handler);
49352
49592
  clearTimeout(timer);
49353
- if (msg.payload?.success === false) {
49354
- reject(new Error(msg.payload?.error ?? "Mesh command failed"));
49593
+ if (body.success === false) {
49594
+ reject(new Error(body.error ?? "Mesh command failed"));
49355
49595
  } else {
49356
- resolve20(msg.payload?.result);
49596
+ resolve20(body.result);
49357
49597
  }
49358
49598
  };
49359
49599
  this.on("daemon_mesh_result", handler);
@@ -49455,17 +49695,19 @@ var init_server_connection = __esm({
49455
49695
  return;
49456
49696
  } else if (message.type === "version_mismatch") {
49457
49697
  const p = message.payload;
49698
+ const updateCommand = typeof p.updateCommand === "string" && p.updateCommand.trim() ? p.updateCommand.trim() : "adhdev daemon:upgrade";
49458
49699
  LOG.info("Server", `
49459
49700
  \u{1F504} Update available: v${p.current} \u2192 v${p.latest}`);
49460
- LOG.info("Server", ` Run: adhdev daemon:upgrade
49701
+ LOG.info("Server", ` Run: ${updateCommand}
49461
49702
  `);
49462
49703
  } else if (message.type === "force_update_required") {
49463
49704
  this.compatBlocked = true;
49464
49705
  const p = message.payload;
49706
+ const updateCommand = typeof p.updateCommand === "string" && p.updateCommand.trim() ? p.updateCommand.trim() : "adhdev daemon:upgrade";
49465
49707
  LOG.error("Server", `
49466
49708
  \u26D4 Daemon v${this.options.daemonVersion} is no longer compatible.`);
49467
49709
  LOG.error("Server", ` Minimum required: v${p.minVersion}`);
49468
- LOG.error("Server", ` Run: adhdev daemon:upgrade
49710
+ LOG.error("Server", ` Run: ${updateCommand}
49469
49711
  `);
49470
49712
  }
49471
49713
  const handlers = this.messageHandlers.get(message.type);
@@ -50660,12 +50902,12 @@ var init_peer_connection_manager = __esm({
50660
50902
  });
50661
50903
 
50662
50904
  // src/daemon-p2p/index.ts
50663
- var fs16, path27, import_node_module3, esmRequire, DaemonP2PSender;
50905
+ var fs16, path28, import_node_module3, esmRequire, DaemonP2PSender;
50664
50906
  var init_daemon_p2p = __esm({
50665
50907
  "src/daemon-p2p/index.ts"() {
50666
50908
  "use strict";
50667
50909
  fs16 = __toESM(require("fs"));
50668
- path27 = __toESM(require("path"));
50910
+ path28 = __toESM(require("path"));
50669
50911
  import_node_module3 = require("module");
50670
50912
  init_src();
50671
50913
  init_data_channel_router();
@@ -50744,15 +50986,15 @@ ${e?.stack || ""}`);
50744
50986
  const prebuildKey = `${platform12}-${arch3}`;
50745
50987
  try {
50746
50988
  const candidates = [
50747
- path27.join(__dirname, "node_modules", "node-datachannel"),
50748
- path27.join(__dirname, "..", "node_modules", "node-datachannel"),
50749
- path27.join(__dirname, "..", "..", "node_modules", "node-datachannel")
50989
+ path28.join(__dirname, "node_modules", "node-datachannel"),
50990
+ path28.join(__dirname, "..", "node_modules", "node-datachannel"),
50991
+ path28.join(__dirname, "..", "..", "node_modules", "node-datachannel")
50750
50992
  ];
50751
50993
  for (const candidate of candidates) {
50752
- const prebuildPath = path27.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
50994
+ const prebuildPath = path28.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
50753
50995
  if (fs16.existsSync(prebuildPath)) {
50754
- const targetDir = path27.join(candidate, "build", "Release");
50755
- const targetPath = path27.join(targetDir, "node_datachannel.node");
50996
+ const targetDir = path28.join(candidate, "build", "Release");
50997
+ const targetPath = path28.join(targetDir, "node_datachannel.node");
50756
50998
  fs16.mkdirSync(targetDir, { recursive: true });
50757
50999
  fs16.copyFileSync(prebuildPath, targetPath);
50758
51000
  try {
@@ -51141,16 +51383,16 @@ var require_filesystem = __commonJS({
51141
51383
  var LDD_PATH = "/usr/bin/ldd";
51142
51384
  var SELF_PATH = "/proc/self/exe";
51143
51385
  var MAX_LENGTH = 2048;
51144
- var readFileSync20 = (path33) => {
51145
- const fd = fs20.openSync(path33, "r");
51386
+ var readFileSync20 = (path34) => {
51387
+ const fd = fs20.openSync(path34, "r");
51146
51388
  const buffer = Buffer.alloc(MAX_LENGTH);
51147
51389
  const bytesRead = fs20.readSync(fd, buffer, 0, MAX_LENGTH, 0);
51148
51390
  fs20.close(fd, () => {
51149
51391
  });
51150
51392
  return buffer.subarray(0, bytesRead);
51151
51393
  };
51152
- var readFile2 = (path33) => new Promise((resolve20, reject) => {
51153
- fs20.open(path33, "r", (err, fd) => {
51394
+ var readFile2 = (path34) => new Promise((resolve20, reject) => {
51395
+ fs20.open(path34, "r", (err, fd) => {
51154
51396
  if (err) {
51155
51397
  reject(err);
51156
51398
  } else {
@@ -51269,11 +51511,11 @@ var require_detect_libc = __commonJS({
51269
51511
  }
51270
51512
  return null;
51271
51513
  };
51272
- var familyFromInterpreterPath = (path33) => {
51273
- if (path33) {
51274
- if (path33.includes("/ld-musl-")) {
51514
+ var familyFromInterpreterPath = (path34) => {
51515
+ if (path34) {
51516
+ if (path34.includes("/ld-musl-")) {
51275
51517
  return MUSL;
51276
- } else if (path33.includes("/ld-linux-")) {
51518
+ } else if (path34.includes("/ld-linux-")) {
51277
51519
  return GLIBC;
51278
51520
  }
51279
51521
  }
@@ -51320,8 +51562,8 @@ var require_detect_libc = __commonJS({
51320
51562
  cachedFamilyInterpreter = null;
51321
51563
  try {
51322
51564
  const selfContent = await readFile2(SELF_PATH);
51323
- const path33 = interpreterPath(selfContent);
51324
- cachedFamilyInterpreter = familyFromInterpreterPath(path33);
51565
+ const path34 = interpreterPath(selfContent);
51566
+ cachedFamilyInterpreter = familyFromInterpreterPath(path34);
51325
51567
  } catch (e) {
51326
51568
  }
51327
51569
  return cachedFamilyInterpreter;
@@ -51333,8 +51575,8 @@ var require_detect_libc = __commonJS({
51333
51575
  cachedFamilyInterpreter = null;
51334
51576
  try {
51335
51577
  const selfContent = readFileSync20(SELF_PATH);
51336
- const path33 = interpreterPath(selfContent);
51337
- cachedFamilyInterpreter = familyFromInterpreterPath(path33);
51578
+ const path34 = interpreterPath(selfContent);
51579
+ cachedFamilyInterpreter = familyFromInterpreterPath(path34);
51338
51580
  } catch (e) {
51339
51581
  }
51340
51582
  return cachedFamilyInterpreter;
@@ -53053,18 +53295,18 @@ var require_sharp = __commonJS({
53053
53295
  `@img/sharp-${runtimePlatform}/sharp.node`,
53054
53296
  "@img/sharp-wasm32/sharp.node"
53055
53297
  ];
53056
- var path33;
53298
+ var path34;
53057
53299
  var sharp;
53058
53300
  var errors = [];
53059
- for (path33 of paths) {
53301
+ for (path34 of paths) {
53060
53302
  try {
53061
- sharp = require(path33);
53303
+ sharp = require(path34);
53062
53304
  break;
53063
53305
  } catch (err) {
53064
53306
  errors.push(err);
53065
53307
  }
53066
53308
  }
53067
- if (sharp && path33.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
53309
+ if (sharp && path34.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
53068
53310
  const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
53069
53311
  err.code = "Unsupported CPU";
53070
53312
  errors.push(err);
@@ -55341,10 +55583,10 @@ var require_color = __commonJS({
55341
55583
  const b = srgbNonlinearTransformInv(rgb[2] / 255);
55342
55584
  const lp = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
55343
55585
  const mp = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
55344
- const sp3 = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
55345
- const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp3;
55346
- const aa = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp3;
55347
- const bb = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp3;
55586
+ const sp = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
55587
+ const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;
55588
+ const aa = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;
55589
+ const bb = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;
55348
55590
  return [l * 100, aa * 100, bb * 100];
55349
55591
  };
55350
55592
  convert.rgb.cmyk = function(rgb) {
@@ -55606,10 +55848,10 @@ var require_color = __commonJS({
55606
55848
  const z2 = xyz[2] / 100;
55607
55849
  const lp = Math.cbrt(0.8189330101 * x + 0.3618667424 * y - 0.1288597137 * z2);
55608
55850
  const mp = Math.cbrt(0.0329845436 * x + 0.9293118715 * y + 0.0361456387 * z2);
55609
- const sp3 = Math.cbrt(0.0482003018 * x + 0.2643662691 * y + 0.633851707 * z2);
55610
- const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp3;
55611
- const a = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp3;
55612
- const b = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp3;
55851
+ const sp = Math.cbrt(0.0482003018 * x + 0.2643662691 * y + 0.633851707 * z2);
55852
+ const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;
55853
+ const a = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;
55854
+ const b = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;
55613
55855
  return [l * 100, a * 100, b * 100];
55614
55856
  };
55615
55857
  convert.oklab.oklch = function(oklab) {
@@ -55973,15 +56215,15 @@ var require_color = __commonJS({
55973
56215
  };
55974
56216
  }
55975
56217
  function wrapConversion(toModel, graph) {
55976
- const path33 = [graph[toModel].parent, toModel];
56218
+ const path34 = [graph[toModel].parent, toModel];
55977
56219
  let fn = conversions_default[graph[toModel].parent][toModel];
55978
56220
  let cur = graph[toModel].parent;
55979
56221
  while (graph[cur].parent) {
55980
- path33.unshift(graph[cur].parent);
56222
+ path34.unshift(graph[cur].parent);
55981
56223
  fn = link(conversions_default[graph[cur].parent][cur], fn);
55982
56224
  cur = graph[cur].parent;
55983
56225
  }
55984
- fn.conversion = path33;
56226
+ fn.conversion = path34;
55985
56227
  return fn;
55986
56228
  }
55987
56229
  function route(fromModel) {
@@ -56598,7 +56840,7 @@ var require_channel = __commonJS({
56598
56840
  var require_output = __commonJS({
56599
56841
  "../../node_modules/sharp/lib/output.js"(exports2, module2) {
56600
56842
  "use strict";
56601
- var path33 = require("path");
56843
+ var path34 = require("path");
56602
56844
  var is = require_is();
56603
56845
  var sharp = require_sharp();
56604
56846
  var formats = /* @__PURE__ */ new Map([
@@ -56629,9 +56871,9 @@ var require_output = __commonJS({
56629
56871
  let err;
56630
56872
  if (!is.string(fileOut)) {
56631
56873
  err = new Error("Missing output file path");
56632
- } else if (is.string(this.options.input.file) && path33.resolve(this.options.input.file) === path33.resolve(fileOut)) {
56874
+ } else if (is.string(this.options.input.file) && path34.resolve(this.options.input.file) === path34.resolve(fileOut)) {
56633
56875
  err = new Error("Cannot use same file for input and output");
56634
- } else if (jp2Regex.test(path33.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
56876
+ } else if (jp2Regex.test(path34.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
56635
56877
  err = errJp2Save();
56636
56878
  }
56637
56879
  if (err) {
@@ -57908,11 +58150,11 @@ function quarantineLegacyStandaloneSessions(options) {
57908
58150
  const homeDir = options.homeDir || os24.homedir();
57909
58151
  const now = options.now || (() => /* @__PURE__ */ new Date());
57910
58152
  const isPidRunning = options.isPidRunning || defaultPidRunning;
57911
- const runtimesDir = path28.join(homeDir, ".adhdev", "session-host", options.appName, "runtimes");
58153
+ const runtimesDir = path29.join(homeDir, ".adhdev", "session-host", options.appName, "runtimes");
57912
58154
  if (!fs17.existsSync(runtimesDir)) {
57913
58155
  return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
57914
58156
  }
57915
- const candidates = fs17.readdirSync(runtimesDir).filter((name) => name.endsWith(".json")).map((name) => path28.join(runtimesDir, name));
58157
+ const candidates = fs17.readdirSync(runtimesDir).filter((name) => name.endsWith(".json")).map((name) => path29.join(runtimesDir, name));
57916
58158
  let movedCount = 0;
57917
58159
  let skippedActiveCount = 0;
57918
58160
  let backupDir = null;
@@ -57930,26 +58172,26 @@ function quarantineLegacyStandaloneSessions(options) {
57930
58172
  continue;
57931
58173
  }
57932
58174
  if (!backupDir) {
57933
- backupDir = path28.join(
58175
+ backupDir = path29.join(
57934
58176
  homeDir,
57935
58177
  ".adhdev",
57936
58178
  "session-host-backups",
57937
58179
  `legacy-standalone-${options.appName}-${formatTimestamp(now())}`
57938
58180
  );
57939
- fs17.mkdirSync(path28.join(backupDir, "runtimes"), { recursive: true });
58181
+ fs17.mkdirSync(path29.join(backupDir, "runtimes"), { recursive: true });
57940
58182
  }
57941
- fs17.renameSync(sourcePath, path28.join(backupDir, "runtimes", path28.basename(sourcePath)));
58183
+ fs17.renameSync(sourcePath, path29.join(backupDir, "runtimes", path29.basename(sourcePath)));
57942
58184
  movedCount += 1;
57943
58185
  }
57944
58186
  return { movedCount, skippedActiveCount, backupDir };
57945
58187
  }
57946
- var fs17, os24, path28, LEGACY_STANDALONE_MANAGER_TAG;
58188
+ var fs17, os24, path29, LEGACY_STANDALONE_MANAGER_TAG;
57947
58189
  var init_session_host_hygiene = __esm({
57948
58190
  "src/session-host-hygiene.ts"() {
57949
58191
  "use strict";
57950
58192
  fs17 = __toESM(require("fs"));
57951
58193
  os24 = __toESM(require("os"));
57952
- path28 = __toESM(require("path"));
58194
+ path29 = __toESM(require("path"));
57953
58195
  init_src();
57954
58196
  LEGACY_STANDALONE_MANAGER_TAG = "adhdev-standalone";
57955
58197
  }
@@ -57963,8 +58205,8 @@ function buildSessionHostEnv(baseEnv) {
57963
58205
  }
57964
58206
  function resolveSessionHostEntry() {
57965
58207
  const packagedCandidates = [
57966
- path29.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
57967
- path29.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
58208
+ path30.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
58209
+ path30.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
57968
58210
  ];
57969
58211
  for (const candidate of packagedCandidates) {
57970
58212
  if (fs18.existsSync(candidate)) {
@@ -57974,7 +58216,7 @@ function resolveSessionHostEntry() {
57974
58216
  return require.resolve("@adhdev/session-host-daemon");
57975
58217
  }
57976
58218
  function getSessionHostPidFile() {
57977
- return path29.join(os25.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
58219
+ return path30.join(os25.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
57978
58220
  }
57979
58221
  function killPid2(pid) {
57980
58222
  try {
@@ -58077,9 +58319,9 @@ async function ensureSessionHostReady2() {
58077
58319
  }
58078
58320
  const spawnHost = () => {
58079
58321
  const entry = resolveSessionHostEntry();
58080
- const logDir = path29.join(os25.homedir(), ".adhdev", "logs");
58322
+ const logDir = path30.join(os25.homedir(), ".adhdev", "logs");
58081
58323
  fs18.mkdirSync(logDir, { recursive: true });
58082
- const logFd = fs18.openSync(path29.join(logDir, "session-host.log"), "a");
58324
+ const logFd = fs18.openSync(path30.join(logDir, "session-host.log"), "a");
58083
58325
  const child = (0, import_child_process12.spawn)(process.execPath, [entry], {
58084
58326
  detached: true,
58085
58327
  stdio: ["ignore", logFd, logFd],
@@ -58114,14 +58356,14 @@ async function ensureSessionHostReady2() {
58114
58356
  async function listHostedCliRuntimes2(endpoint) {
58115
58357
  return listHostedCliRuntimes(endpoint);
58116
58358
  }
58117
- var import_child_process12, fs18, os25, path29, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
58359
+ var import_child_process12, fs18, os25, path30, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
58118
58360
  var init_session_host = __esm({
58119
58361
  "src/session-host.ts"() {
58120
58362
  "use strict";
58121
58363
  import_child_process12 = require("child_process");
58122
58364
  fs18 = __toESM(require("fs"));
58123
58365
  os25 = __toESM(require("os"));
58124
- path29 = __toESM(require("path"));
58366
+ path30 = __toESM(require("path"));
58125
58367
  init_src();
58126
58368
  init_dist();
58127
58369
  init_session_host_hygiene();
@@ -58531,7 +58773,7 @@ function _supportsColor2(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
58531
58773
  return min;
58532
58774
  }
58533
58775
  if (import_node_process2.default.platform === "win32") {
58534
- const osRelease = import_node_os3.default.release().split(".");
58776
+ const osRelease = import_node_os2.default.release().split(".");
58535
58777
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
58536
58778
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
58537
58779
  }
@@ -58590,12 +58832,12 @@ function createSupportsColor2(stream, options = {}) {
58590
58832
  });
58591
58833
  return translateLevel2(level);
58592
58834
  }
58593
- var import_node_process2, import_node_os3, import_node_tty2, env2, flagForceColor2, supportsColor2, supports_color_default2;
58835
+ var import_node_process2, import_node_os2, import_node_tty2, env2, flagForceColor2, supportsColor2, supports_color_default2;
58594
58836
  var init_supports_color2 = __esm({
58595
58837
  "../../node_modules/chalk/source/vendor/supports-color/index.js"() {
58596
58838
  "use strict";
58597
58839
  import_node_process2 = __toESM(require("process"), 1);
58598
- import_node_os3 = __toESM(require("os"), 1);
58840
+ import_node_os2 = __toESM(require("os"), 1);
58599
58841
  import_node_tty2 = __toESM(require("tty"), 1);
58600
58842
  ({ env: env2 } = import_node_process2.default);
58601
58843
  if (hasFlag2("no-color") || hasFlag2("no-colors") || hasFlag2("color=false") || hasFlag2("color=never")) {
@@ -58813,18 +59055,18 @@ function resolvePackageVersion(options) {
58813
59055
  ];
58814
59056
  for (const p of possiblePaths) {
58815
59057
  try {
58816
- const data = JSON.parse((0, import_fs7.readFileSync)(p, "utf-8"));
59058
+ const data = JSON.parse((0, import_fs9.readFileSync)(p, "utf-8"));
58817
59059
  if (data.version) return data.version;
58818
59060
  } catch {
58819
59061
  }
58820
59062
  }
58821
59063
  return injectedVersion;
58822
59064
  }
58823
- var import_fs7, import_path4;
59065
+ var import_fs9, import_path4;
58824
59066
  var init_version = __esm({
58825
59067
  "src/version.ts"() {
58826
59068
  "use strict";
58827
- import_fs7 = require("fs");
59069
+ import_fs9 = require("fs");
58828
59070
  import_path4 = require("path");
58829
59071
  }
58830
59072
  });
@@ -58863,7 +59105,9 @@ var init_daemon_mesh_manager = __esm({
58863
59105
  "read_chat",
58864
59106
  "git_status",
58865
59107
  "git_diff_summary",
58866
- "launch_cli"
59108
+ "launch_cli",
59109
+ "git_checkpoint",
59110
+ "resolve_action"
58867
59111
  ]);
58868
59112
  setRules(rules) {
58869
59113
  const valid = [];
@@ -58980,10 +59224,10 @@ function resolveDaemonPort(ref = {}) {
58980
59224
  return Number.isFinite(ref.port) && Number(ref.port) > 0 ? Number(ref.port) : DEFAULT_DAEMON_PORT;
58981
59225
  }
58982
59226
  function getDaemonPidFile(ref = {}) {
58983
- const dir = path30.join(ref.homeDir || os27.homedir(), ".adhdev");
59227
+ const dir = path31.join(ref.homeDir || os27.homedir(), ".adhdev");
58984
59228
  if (!fs19.existsSync(dir)) fs19.mkdirSync(dir, { recursive: true });
58985
59229
  const port = resolveDaemonPort(ref);
58986
- return path30.join(dir, port === DEFAULT_DAEMON_PORT ? "daemon.pid" : `daemon-${port}.pid`);
59230
+ return path31.join(dir, port === DEFAULT_DAEMON_PORT ? "daemon.pid" : `daemon-${port}.pid`);
58987
59231
  }
58988
59232
  function writeDaemonPid(pid, ref = {}) {
58989
59233
  const pidFile = getDaemonPidFile(ref);
@@ -59132,7 +59376,7 @@ function stopDaemon(ref = {}) {
59132
59376
  return false;
59133
59377
  }
59134
59378
  }
59135
- var os27, fs19, path30, import_http, import_child_process13, import_ws3, pkgVersion, AdhdevDaemon;
59379
+ var os27, fs19, path31, import_http, import_child_process13, import_ws3, pkgVersion, AdhdevDaemon;
59136
59380
  var init_adhdev_daemon = __esm({
59137
59381
  "src/adhdev-daemon.ts"() {
59138
59382
  "use strict";
@@ -59146,7 +59390,7 @@ var init_adhdev_daemon = __esm({
59146
59390
  init_session_host_controller();
59147
59391
  os27 = __toESM(require("os"));
59148
59392
  fs19 = __toESM(require("fs"));
59149
- path30 = __toESM(require("path"));
59393
+ path31 = __toESM(require("path"));
59150
59394
  import_http = require("http");
59151
59395
  import_child_process13 = require("child_process");
59152
59396
  import_ws3 = require("ws");
@@ -59154,7 +59398,7 @@ var init_adhdev_daemon = __esm({
59154
59398
  init_version();
59155
59399
  init_src();
59156
59400
  init_runtime_defaults();
59157
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.76-rc.1" });
59401
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.76-rc.11" });
59158
59402
  AdhdevDaemon = class _AdhdevDaemon {
59159
59403
  localHttpServer = null;
59160
59404
  localWss = null;
@@ -59990,6 +60234,19 @@ ${err?.stack || ""}`);
59990
60234
  void this.statusReporter?.sendUnifiedStatusReport({ forceServer: true, reason });
59991
60235
  void this.flushP2PDaemonMetadataSubscriptions();
59992
60236
  }
60237
+ emitMeshCheckpointCompleteIfNeeded(commandType, result, normalizedData) {
60238
+ if (commandType !== "git_checkpoint" || result?.success !== true || !this.meshManager) return;
60239
+ const workspace = String(normalizedData.workspace ?? "");
60240
+ const baseContext = {
60241
+ workspace,
60242
+ checkpoint_message: result.checkpoint?.message ?? String(normalizedData.message ?? ""),
60243
+ commit: result.checkpoint?.commit ?? "",
60244
+ source_session_id: String(normalizedData.targetSessionId ?? "")
60245
+ };
60246
+ void this.buildMeshCheckpointContext(workspace, baseContext).then((ctx) => {
60247
+ this.meshManager.emit({ trigger: "git_checkpoint_complete", context: ctx });
60248
+ });
60249
+ }
59993
60250
  async handleCommand(msg, cmd, args) {
59994
60251
  const normalizedArgs = this.ensureInteractionContext(args);
59995
60252
  const interactionId = String(normalizedArgs._interactionId);
@@ -60024,6 +60281,10 @@ ${err?.stack || ""}`);
60024
60281
  if (cmd === "resolve_action" || cmd === "send_chat" || cmd === "read_chat") {
60025
60282
  void this.flushP2PSessionModalSubscriptions();
60026
60283
  }
60284
+ if (cmd.startsWith("git_")) {
60285
+ void this.flushP2PWorkspaceGitSubscriptions();
60286
+ }
60287
+ this.emitMeshCheckpointCompleteIfNeeded(cmd, result, normalizedArgs);
60027
60288
  this.sendResult(msg, result.success, { ...result, interactionId });
60028
60289
  recordDebugTrace({
60029
60290
  interactionId,
@@ -60105,18 +60366,7 @@ ${err?.stack || ""}`);
60105
60366
  if (cmdType.startsWith("git_")) {
60106
60367
  void this.flushP2PWorkspaceGitSubscriptions();
60107
60368
  }
60108
- if (cmdType === "git_checkpoint" && routed.success && this.meshManager) {
60109
- const workspace = String(normalizedData.workspace ?? "");
60110
- const baseContext = {
60111
- workspace,
60112
- checkpoint_message: routed.checkpoint?.message ?? String(normalizedData.message ?? ""),
60113
- commit: routed.checkpoint?.commit ?? "",
60114
- source_session_id: String(normalizedData.targetSessionId ?? "")
60115
- };
60116
- void this.buildMeshCheckpointContext(workspace, baseContext).then((ctx) => {
60117
- this.meshManager.emit({ trigger: "git_checkpoint_complete", context: ctx });
60118
- });
60119
- }
60369
+ this.emitMeshCheckpointCompleteIfNeeded(cmdType, routed, normalizedData);
60120
60370
  return { ...routed, interactionId };
60121
60371
  } catch (e) {
60122
60372
  logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd: cmdType, source: "p2p", interactionId, success: false, error: e.message, durationMs: Date.now() - cmdStart });
@@ -60256,7 +60506,21 @@ ${err?.stack || ""}`);
60256
60506
  return;
60257
60507
  }
60258
60508
  try {
60259
- const result = await this.components.router.execute(command, normalizedArgs, "ipc");
60509
+ let result;
60510
+ if (command === "mesh_relay_command") {
60511
+ if (!this.meshManager) throw new Error("Mesh manager is not initialized");
60512
+ const targetDaemonId = typeof normalizedArgs.targetDaemonId === "string" ? normalizedArgs.targetDaemonId : "";
60513
+ const relayedCommand = typeof normalizedArgs.command === "string" ? normalizedArgs.command : "";
60514
+ const relayedArgs = normalizedArgs.args && typeof normalizedArgs.args === "object" ? normalizedArgs.args : {};
60515
+ if (!targetDaemonId || !relayedCommand) {
60516
+ throw new Error("mesh_relay_command requires targetDaemonId and command");
60517
+ }
60518
+ const relayResult = await this.meshManager.sendCommand(targetDaemonId, relayedCommand, relayedArgs);
60519
+ result = { success: true, result: relayResult };
60520
+ } else {
60521
+ result = await this.components.router.execute(command, normalizedArgs, "ipc");
60522
+ this.emitMeshCheckpointCompleteIfNeeded(command, result, normalizedArgs);
60523
+ }
60260
60524
  ws.send(JSON.stringify({
60261
60525
  type: "ext:command_result",
60262
60526
  payload: {
@@ -60587,7 +60851,7 @@ function isUnicodeSupported() {
60587
60851
  import_node_process3.default.env["TERM_PROGRAM"] === "Terminus-Sublime" || import_node_process3.default.env["TERM_PROGRAM"] === "vscode" || import_node_process3.default.env["TERM"] === "xterm-256color" || import_node_process3.default.env["TERM"] === "alacritty" || import_node_process3.default.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
60588
60852
  }
60589
60853
  var import_node_process3, common, specialMainSymbols, specialFallbackSymbols, mainSymbols, fallbackSymbols, shouldUseMain, figures, esm_default, replacements;
60590
- var init_esm = __esm({
60854
+ var init_esm3 = __esm({
60591
60855
  "../../node_modules/@inquirer/figures/dist/esm/index.js"() {
60592
60856
  "use strict";
60593
60857
  import_node_process3 = __toESM(require("process"), 1);
@@ -70508,7 +70772,7 @@ var init_separator = __esm({
70508
70772
  "../../node_modules/inquirer/lib/objects/separator.js"() {
70509
70773
  "use strict";
70510
70774
  import_yoctocolors_cjs2 = __toESM(require_yoctocolors_cjs(), 1);
70511
- init_esm();
70775
+ init_esm3();
70512
70776
  Separator = class {
70513
70777
  constructor(line) {
70514
70778
  this.type = "separator";
@@ -71716,15 +71980,15 @@ var require_route = __commonJS({
71716
71980
  };
71717
71981
  }
71718
71982
  function wrapConversion(toModel, graph) {
71719
- const path33 = [graph[toModel].parent, toModel];
71983
+ const path34 = [graph[toModel].parent, toModel];
71720
71984
  let fn = conversions[graph[toModel].parent][toModel];
71721
71985
  let cur = graph[toModel].parent;
71722
71986
  while (graph[cur].parent) {
71723
- path33.unshift(graph[cur].parent);
71987
+ path34.unshift(graph[cur].parent);
71724
71988
  fn = link(conversions[graph[cur].parent][cur], fn);
71725
71989
  cur = graph[cur].parent;
71726
71990
  }
71727
- fn.conversion = path33;
71991
+ fn.conversion = path34;
71728
71992
  return fn;
71729
71993
  }
71730
71994
  module2.exports = function(fromModel) {
@@ -75022,7 +75286,7 @@ var require_buffer_list = __commonJS({
75022
75286
  }
75023
75287
  }, {
75024
75288
  key: "join",
75025
- value: function join33(s) {
75289
+ value: function join34(s) {
75026
75290
  if (this.length === 0) return "";
75027
75291
  var p = this.head;
75028
75292
  var ret = "" + p.data;
@@ -78632,7 +78896,7 @@ var init_list = __esm({
78632
78896
  "use strict";
78633
78897
  import_ansi_escapes3 = __toESM(require_ansi_escapes(), 1);
78634
78898
  import_yoctocolors_cjs4 = __toESM(require_yoctocolors_cjs(), 1);
78635
- init_esm();
78899
+ init_esm3();
78636
78900
  import_run_async2 = __toESM(require_run_async(), 1);
78637
78901
  import_rxjs3 = __toESM(require_cjs(), 1);
78638
78902
  init_events();
@@ -79327,7 +79591,7 @@ var init_checkbox = __esm({
79327
79591
  "use strict";
79328
79592
  import_ansi_escapes4 = __toESM(require_ansi_escapes(), 1);
79329
79593
  import_yoctocolors_cjs9 = __toESM(require_yoctocolors_cjs(), 1);
79330
- init_esm();
79594
+ init_esm3();
79331
79595
  import_rxjs8 = __toESM(require_cjs(), 1);
79332
79596
  init_events();
79333
79597
  init_paginator();
@@ -89081,15 +89345,15 @@ function splitStringBySpace(str) {
89081
89345
  }
89082
89346
  return pieces;
89083
89347
  }
89084
- var import_chardet, import_child_process14, import_fs8, import_node_path3, import_node_os4, import_node_crypto2, import_iconv_lite, ExternalEditor;
89085
- var init_esm2 = __esm({
89348
+ var import_chardet, import_child_process14, import_fs10, import_node_path3, import_node_os3, import_node_crypto2, import_iconv_lite, ExternalEditor;
89349
+ var init_esm4 = __esm({
89086
89350
  "../../node_modules/@inquirer/external-editor/dist/esm/index.js"() {
89087
89351
  "use strict";
89088
89352
  import_chardet = __toESM(require_lib2(), 1);
89089
89353
  import_child_process14 = require("child_process");
89090
- import_fs8 = require("fs");
89354
+ import_fs10 = require("fs");
89091
89355
  import_node_path3 = __toESM(require("path"), 1);
89092
- import_node_os4 = __toESM(require("os"), 1);
89356
+ import_node_os3 = __toESM(require("os"), 1);
89093
89357
  import_node_crypto2 = require("crypto");
89094
89358
  import_iconv_lite = __toESM(require_lib3(), 1);
89095
89359
  init_CreateFileError();
@@ -89148,7 +89412,7 @@ var init_esm2 = __esm({
89148
89412
  }
89149
89413
  createTemporaryFile() {
89150
89414
  try {
89151
- const baseDir = this.fileOptions.dir ?? import_node_os4.default.tmpdir();
89415
+ const baseDir = this.fileOptions.dir ?? import_node_os3.default.tmpdir();
89152
89416
  const id = (0, import_node_crypto2.randomUUID)();
89153
89417
  const prefix = sanitizeAffix(this.fileOptions.prefix);
89154
89418
  const postfix = sanitizeAffix(this.fileOptions.postfix);
@@ -89163,14 +89427,14 @@ var init_esm2 = __esm({
89163
89427
  if (Object.prototype.hasOwnProperty.call(this.fileOptions, "mode")) {
89164
89428
  opt.mode = this.fileOptions.mode;
89165
89429
  }
89166
- (0, import_fs8.writeFileSync)(this.tempFile, this.text, opt);
89430
+ (0, import_fs10.writeFileSync)(this.tempFile, this.text, opt);
89167
89431
  } catch (createFileError) {
89168
89432
  throw new CreateFileError(createFileError);
89169
89433
  }
89170
89434
  }
89171
89435
  readTemporaryFile() {
89172
89436
  try {
89173
- const tempFileBuffer = (0, import_fs8.readFileSync)(this.tempFile);
89437
+ const tempFileBuffer = (0, import_fs10.readFileSync)(this.tempFile);
89174
89438
  if (tempFileBuffer.length === 0) {
89175
89439
  this.text = "";
89176
89440
  } else {
@@ -89186,7 +89450,7 @@ var init_esm2 = __esm({
89186
89450
  }
89187
89451
  removeTemporaryFile() {
89188
89452
  try {
89189
- (0, import_fs8.unlinkSync)(this.tempFile);
89453
+ (0, import_fs10.unlinkSync)(this.tempFile);
89190
89454
  } catch (removeFileError) {
89191
89455
  throw new RemoveFileError(removeFileError);
89192
89456
  }
@@ -89220,7 +89484,7 @@ var init_editor = __esm({
89220
89484
  "../../node_modules/inquirer/lib/prompts/editor.js"() {
89221
89485
  "use strict";
89222
89486
  import_yoctocolors_cjs11 = __toESM(require_yoctocolors_cjs(), 1);
89223
- init_esm2();
89487
+ init_esm4();
89224
89488
  import_rxjs10 = __toESM(require_cjs(), 1);
89225
89489
  init_events();
89226
89490
  init_base();
@@ -89594,9 +89858,9 @@ var init_prompt = __esm({
89594
89858
  init_utils();
89595
89859
  init_baseUI();
89596
89860
  _ = {
89597
- set: (obj, path33 = "", value) => {
89861
+ set: (obj, path34 = "", value) => {
89598
89862
  let pointer = obj;
89599
- path33.split(".").forEach((key, index, arr) => {
89863
+ path34.split(".").forEach((key, index, arr) => {
89600
89864
  if (key === "__proto__" || key === "constructor") return;
89601
89865
  if (index === arr.length - 1) {
89602
89866
  pointer[key] = value;
@@ -89606,8 +89870,8 @@ var init_prompt = __esm({
89606
89870
  pointer = pointer[key];
89607
89871
  });
89608
89872
  },
89609
- get: (obj, path33 = "", defaultValue) => {
89610
- const travel = (regexp) => String.prototype.split.call(path33, regexp).filter(Boolean).reduce(
89873
+ get: (obj, path34 = "", defaultValue) => {
89874
+ const travel = (regexp) => String.prototype.split.call(path34, regexp).filter(Boolean).reduce(
89611
89875
  // @ts-expect-error implicit any on res[key]
89612
89876
  (res, key) => res !== null && res !== void 0 ? res[key] : res,
89613
89877
  obj
@@ -90905,7 +91169,58 @@ init_lib();
90905
91169
  init_ora();
90906
91170
  init_src();
90907
91171
  init_version();
90908
- var SERVER_URL = process.env.ADHDEV_SERVER_URL || "https://api.adhf.dev";
91172
+ var CHANNEL_NPM_TAG2 = {
91173
+ stable: "latest",
91174
+ preview: "next"
91175
+ };
91176
+ var CHANNEL_SERVER_URL2 = {
91177
+ stable: "https://api.adhf.dev",
91178
+ preview: "https://api-preview.adhf.dev"
91179
+ };
91180
+ function normalizeSetupReleaseChannel(value) {
91181
+ if (typeof value !== "string") return null;
91182
+ const normalized = value.trim().toLowerCase();
91183
+ if (normalized === "stable" || normalized === "latest") return "stable";
91184
+ if (normalized === "preview" || normalized === "next") return "preview";
91185
+ return null;
91186
+ }
91187
+ function inferReleaseChannelFromServerUrl(serverUrl) {
91188
+ if (typeof serverUrl !== "string") return null;
91189
+ const normalized = serverUrl.trim().toLowerCase();
91190
+ if (!normalized) return null;
91191
+ if (normalized.includes("api-preview.adhf.dev") || normalized.includes("dev.adhf.dev")) return "preview";
91192
+ if (normalized.includes("api.adhf.dev") || normalized.includes("adhf.dev")) return "stable";
91193
+ return null;
91194
+ }
91195
+ function buildDashboardUrl(serverUrl, channel) {
91196
+ try {
91197
+ const url2 = new URL(serverUrl);
91198
+ if (url2.hostname === "api-preview.adhf.dev") return "https://dev.adhf.dev/dashboard";
91199
+ if (url2.hostname === "api.adhf.dev") return "https://adhf.dev/dashboard";
91200
+ if (url2.hostname === "127.0.0.1" || url2.hostname === "localhost") {
91201
+ url2.port = url2.port === "3100" ? "3000" : url2.port;
91202
+ url2.pathname = "/dashboard";
91203
+ url2.search = "";
91204
+ url2.hash = "";
91205
+ return url2.toString();
91206
+ }
91207
+ } catch {
91208
+ }
91209
+ return channel === "preview" ? "https://dev.adhf.dev/dashboard" : "https://adhf.dev/dashboard";
91210
+ }
91211
+ function buildSetupReleaseContext(options = {}) {
91212
+ const env3 = options.env || process.env;
91213
+ const envServerUrl = typeof env3.ADHDEV_SERVER_URL === "string" && env3.ADHDEV_SERVER_URL.trim() ? env3.ADHDEV_SERVER_URL.trim() : null;
91214
+ const config2 = options.config || {};
91215
+ const channel = normalizeSetupReleaseChannel(config2.updateChannel) || inferReleaseChannelFromServerUrl(envServerUrl) || inferReleaseChannelFromServerUrl(config2.serverUrl) || "stable";
91216
+ const serverUrl = envServerUrl || CHANNEL_SERVER_URL2[channel];
91217
+ return {
91218
+ channel,
91219
+ npmTag: CHANNEL_NPM_TAG2[channel],
91220
+ serverUrl,
91221
+ dashboardUrl: buildDashboardUrl(serverUrl, channel)
91222
+ };
91223
+ }
90909
91224
  var LOGO = `
90910
91225
  ${source_default2.cyan("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")}
90911
91226
  ${source_default2.cyan("\u2551")} ${source_default2.bold.white("\u{1F9A6} ADHDev Setup Wizard")} ${source_default2.cyan("\u2551")}
@@ -90921,10 +91236,10 @@ function hasCloudMachineAuth() {
90921
91236
  const config2 = loadConfig();
90922
91237
  return Boolean(config2.machineSecret && config2.machineSecret.trim());
90923
91238
  }
90924
- function readLatestPublishedCliVersion(execFileSyncLocal) {
91239
+ function readLatestPublishedCliVersion(execFileSyncLocal, npmTag = "latest") {
90925
91240
  const surface = resolveCurrentGlobalInstallSurface({ packageName: "adhdev" });
90926
91241
  try {
90927
- return execFileSyncLocal(surface.npmExecutable, [...surface.npmArgsPrefix || [], "view", "adhdev", "version"], {
91242
+ return execFileSyncLocal(surface.npmExecutable, [...surface.npmArgsPrefix || [], "view", `adhdev@${npmTag}`, "version"], {
90928
91243
  encoding: "utf-8",
90929
91244
  timeout: 5e3,
90930
91245
  stdio: ["pipe", "pipe", "pipe"],
@@ -90955,38 +91270,41 @@ function readInstalledGlobalCliVersion(execFileSyncLocal) {
90955
91270
  }
90956
91271
  async function runWizard(options = {}) {
90957
91272
  console.log(LOGO);
91273
+ const config2 = loadConfig();
91274
+ const releaseContext = buildSetupReleaseContext({ config: config2 });
90958
91275
  if (isSetupComplete() && hasCloudMachineAuth() && !options.force) {
90959
- const config2 = loadConfig();
90960
91276
  console.log(source_default2.green("\u2713") + " ADHDev is already configured.");
90961
91277
  console.log(source_default2.gray(` Account: ${config2.userEmail || "not logged in"}`));
91278
+ console.log(source_default2.gray(` Server: ${releaseContext.serverUrl}`));
90962
91279
  console.log();
90963
- await checkForUpdate();
90964
- await startDaemonFlow();
91280
+ await checkForUpdate(releaseContext);
91281
+ await startDaemonFlow(releaseContext);
90965
91282
  return;
90966
91283
  }
90967
- await quickSetup();
91284
+ await quickSetup(releaseContext);
90968
91285
  }
90969
- async function checkForUpdate() {
91286
+ async function checkForUpdate(releaseContext) {
90970
91287
  try {
90971
91288
  const { execFileSync: execFileSync5 } = await import("child_process");
90972
91289
  const currentVersion = resolvePackageVersion();
90973
- const latestVersion = readLatestPublishedCliVersion(execFileSync5);
91290
+ const latestVersion = readLatestPublishedCliVersion(execFileSync5, releaseContext.npmTag);
90974
91291
  if (!latestVersion) return;
90975
91292
  if (!currentVersion || !latestVersion || currentVersion === latestVersion) return;
90976
- console.log(source_default2.yellow(` Update available: ${currentVersion} \u2192 ${latestVersion}`));
91293
+ console.log(source_default2.yellow(` Update available (${releaseContext.channel}/${releaseContext.npmTag}): ${currentVersion} \u2192 ${latestVersion}`));
90977
91294
  const { doUpdate } = await (await Promise.resolve().then(() => (init_lib(), lib_exports))).default.prompt([{
90978
91295
  type: "confirm",
90979
91296
  name: "doUpdate",
90980
- message: `Update adhdev CLI to v${latestVersion}?`,
91297
+ message: `Update adhdev CLI to v${latestVersion} from ${releaseContext.npmTag}?`,
90981
91298
  default: true
90982
91299
  }]);
90983
91300
  if (!doUpdate) {
90984
- console.log(source_default2.gray(" Skipping update. Run: npm install -g adhdev@latest\n"));
91301
+ console.log(source_default2.gray(` Skipping update. Run: npm install -g adhdev@${releaseContext.npmTag}
91302
+ `));
90985
91303
  return;
90986
91304
  }
90987
91305
  const spinner = (await Promise.resolve().then(() => (init_ora(), ora_exports))).default("Updating adhdev CLI...").start();
90988
91306
  try {
90989
- const installCommand = buildPinnedGlobalInstallCommand({ packageName: "adhdev", targetVersion: "latest" });
91307
+ const installCommand = buildPinnedGlobalInstallCommand({ packageName: "adhdev", targetVersion: releaseContext.npmTag });
90990
91308
  execFileSync5(installCommand.command, installCommand.args, {
90991
91309
  encoding: "utf-8",
90992
91310
  timeout: 6e4,
@@ -90997,14 +91315,17 @@ async function checkForUpdate() {
90997
91315
  console.log();
90998
91316
  } catch (e) {
90999
91317
  spinner.fail("Update failed");
91000
- console.log(source_default2.gray(" Manual: npm install -g adhdev@latest\n"));
91318
+ console.log(source_default2.gray(` Manual: npm install -g adhdev@${releaseContext.npmTag}
91319
+ `));
91001
91320
  }
91002
91321
  } catch {
91003
91322
  }
91004
91323
  }
91005
- async function quickSetup() {
91324
+ async function quickSetup(releaseContext) {
91006
91325
  console.log(source_default2.bold("\n\u{1F680} Quick Setup\n"));
91007
- const loginResult = await loginFlow();
91326
+ console.log(source_default2.gray(` Channel: ${releaseContext.channel} (${releaseContext.npmTag})`));
91327
+ console.log(source_default2.gray(` Server: ${releaseContext.serverUrl}`));
91328
+ const loginResult = await loginFlow(releaseContext);
91008
91329
  const setupDate = (/* @__PURE__ */ new Date()).toISOString();
91009
91330
  if (!loginResult) {
91010
91331
  updateConfig({
@@ -91015,7 +91336,9 @@ async function quickSetup() {
91015
91336
  setupDate,
91016
91337
  userEmail: null,
91017
91338
  userName: null,
91018
- machineSecret: null
91339
+ machineSecret: null,
91340
+ updateChannel: releaseContext.channel,
91341
+ serverUrl: releaseContext.serverUrl
91019
91342
  });
91020
91343
  console.log(source_default2.yellow("\u26A0 Setup is not complete without login. Run `adhdev setup` after signing in."));
91021
91344
  }
@@ -91026,14 +91349,16 @@ async function quickSetup() {
91026
91349
  userEmail: loginResult.email,
91027
91350
  userName: loginResult.name,
91028
91351
  setupDate,
91352
+ updateChannel: releaseContext.channel,
91353
+ serverUrl: releaseContext.serverUrl,
91029
91354
  ...loginResult.registeredMachineId ? { registeredMachineId: loginResult.registeredMachineId } : {}
91030
91355
  };
91031
91356
  updateConfig(configUpdate);
91032
91357
  console.log(source_default2.green(` \u2713 Machine registered`));
91033
91358
  }
91034
- await installCliOnly();
91359
+ await installCliOnly(releaseContext);
91035
91360
  if (loginResult) {
91036
- await startDaemonFlow();
91361
+ await startDaemonFlow(releaseContext);
91037
91362
  } else {
91038
91363
  console.log(source_default2.gray(" Start daemon after login: adhdev setup"));
91039
91364
  console.log();
@@ -91042,6 +91367,7 @@ async function quickSetup() {
91042
91367
  console.log(source_default2.bold("\n\u{1F389} Setup Complete!\n"));
91043
91368
  console.log(` ${source_default2.bold("User:")} ${loginResult?.email || "not logged in"}`);
91044
91369
  console.log(` ${source_default2.bold("Status:")} ${loginResult ? source_default2.green("Ready to connect") : source_default2.yellow("Login required")}`);
91370
+ console.log(` ${source_default2.bold("Server:")} ${releaseContext.serverUrl}`);
91045
91371
  console.log();
91046
91372
  console.log(source_default2.gray(" Next steps:"));
91047
91373
  console.log(source_default2.gray(` ${loginResult ? "adhdev daemon \u2014 Start the main daemon (IDE / remote features)" : "adhdev setup \u2014 Sign in to finish setup and enable the daemon"}`));
@@ -91052,11 +91378,12 @@ async function quickSetup() {
91052
91378
  console.log(source_default2.gray(" adhdev launch claude \u2014 Start Claude Code agent"));
91053
91379
  console.log(source_default2.gray(" adhdev status \u2014 Check setup status"));
91054
91380
  console.log();
91055
- console.log(source_default2.cyan(" Dashboard: https://adhf.dev/dashboard"));
91381
+ console.log(source_default2.cyan(` Dashboard: ${releaseContext.dashboardUrl}`));
91056
91382
  console.log();
91057
91383
  }
91058
- async function loginFlow() {
91384
+ async function loginFlow(releaseContext) {
91059
91385
  console.log(source_default2.bold("\n\u{1F510} Login to ADHDev\n"));
91386
+ console.log(source_default2.gray(` Auth server: ${releaseContext.serverUrl}`));
91060
91387
  const { wantLogin } = await lib_default.prompt([
91061
91388
  {
91062
91389
  type: "confirm",
@@ -91073,7 +91400,7 @@ async function loginFlow() {
91073
91400
  try {
91074
91401
  const config2 = loadConfig();
91075
91402
  const os29 = await import("os");
91076
- const res = await fetch(`${SERVER_URL}/auth/cli/init`, {
91403
+ const res = await fetch(`${releaseContext.serverUrl}/auth/cli/init`, {
91077
91404
  method: "POST",
91078
91405
  headers: { "Content-Type": "application/json" },
91079
91406
  body: JSON.stringify({
@@ -91115,7 +91442,7 @@ async function loginFlow() {
91115
91442
  while (Date.now() - startTime < timeout) {
91116
91443
  await new Promise((r) => setTimeout(r, 3e3));
91117
91444
  try {
91118
- const res = await fetch(`${SERVER_URL}/auth/cli/poll`, {
91445
+ const res = await fetch(`${releaseContext.serverUrl}/auth/cli/poll`, {
91119
91446
  method: "POST",
91120
91447
  headers: { "Content-Type": "application/json" },
91121
91448
  body: JSON.stringify({ deviceCode })
@@ -91145,9 +91472,9 @@ async function loginFlow() {
91145
91472
  console.log();
91146
91473
  console.log(source_default2.yellow(" To fix this, do one of the following:"));
91147
91474
  console.log(source_default2.gray(" 1. Remove an unused machine from the dashboard:"));
91148
- console.log(source_default2.gray(" https://adhf.dev/account \u2192 Registered Machines \u2192 \u2715 Remove"));
91475
+ console.log(source_default2.gray(` ${releaseContext.dashboardUrl.replace(/\/dashboard$/, "/account")} \u2192 Registered Machines \u2192 \u2715 Remove`));
91149
91476
  console.log(source_default2.gray(" 2. Upgrade your plan:"));
91150
- console.log(source_default2.gray(" https://adhf.dev/account?tab=billing"));
91477
+ console.log(source_default2.gray(` ${releaseContext.dashboardUrl.replace(/\/dashboard$/, "/account?tab=billing")}`));
91151
91478
  console.log();
91152
91479
  console.log(source_default2.gray(" Then run `adhdev setup` again."));
91153
91480
  console.log();
@@ -91159,11 +91486,12 @@ async function loginFlow() {
91159
91486
  pollSpinner.fail("Authentication timed out");
91160
91487
  return null;
91161
91488
  }
91162
- async function startDaemonFlow() {
91489
+ async function startDaemonFlow(releaseContext) {
91163
91490
  const { isDaemonRunning: isDaemonRunning2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
91164
91491
  if (isDaemonRunning2()) {
91165
91492
  console.log(source_default2.green(" \u2713 Daemon is already running"));
91166
- console.log(source_default2.gray(" Dashboard: https://adhf.dev/dashboard\n"));
91493
+ console.log(source_default2.gray(` Dashboard: ${releaseContext.dashboardUrl}
91494
+ `));
91167
91495
  return;
91168
91496
  }
91169
91497
  const { startDaemon } = await lib_default.prompt([
@@ -91217,7 +91545,7 @@ async function startDaemonFlow() {
91217
91545
  } else {
91218
91546
  daemonSpinner.warn("Daemon starting in background (may take a few seconds)");
91219
91547
  }
91220
- console.log(source_default2.gray(" Dashboard: https://adhf.dev/dashboard"));
91548
+ console.log(source_default2.gray(` Dashboard: ${releaseContext.dashboardUrl}`));
91221
91549
  console.log(source_default2.gray(` Logs: ${logPath}`));
91222
91550
  console.log();
91223
91551
  } catch (e) {
@@ -91225,7 +91553,7 @@ async function startDaemonFlow() {
91225
91553
  console.log(source_default2.gray(" Manual: adhdev daemon\n"));
91226
91554
  }
91227
91555
  }
91228
- async function installCliOnly() {
91556
+ async function installCliOnly(releaseContext) {
91229
91557
  const { execFileSync: execFileSyncLocal } = await import("child_process");
91230
91558
  const currentVersion = readInstalledGlobalCliVersion(execFileSyncLocal);
91231
91559
  const isNpx = process.env.npm_execpath?.includes("npx") || process.argv[1]?.includes("npx") || process.argv[1]?.includes("_npx");
@@ -91238,7 +91566,7 @@ async function installCliOnly() {
91238
91566
  console.log();
91239
91567
  if (currentVersion) {
91240
91568
  console.log(source_default2.green(` \u2713 Currently installed: v${currentVersion}`));
91241
- const latestVersion = readLatestPublishedCliVersion(execFileSyncLocal);
91569
+ const latestVersion = readLatestPublishedCliVersion(execFileSyncLocal, releaseContext.npmTag);
91242
91570
  if (latestVersion && currentVersion === latestVersion) {
91243
91571
  console.log(source_default2.gray(" (Already up to date)"));
91244
91572
  return;
@@ -91247,12 +91575,12 @@ async function installCliOnly() {
91247
91575
  const { doUpdate } = await lib_default.prompt([{
91248
91576
  type: "confirm",
91249
91577
  name: "doUpdate",
91250
- message: `Update to latest version${latestVersion ? ` (v${latestVersion})` : ""}?`,
91578
+ message: `Update to ${releaseContext.npmTag} version${latestVersion ? ` (v${latestVersion})` : ""}?`,
91251
91579
  default: true
91252
91580
  }]);
91253
91581
  if (!doUpdate) return;
91254
91582
  } else {
91255
- console.log(source_default2.gray(" Updating to latest..."));
91583
+ console.log(source_default2.gray(` Updating to ${releaseContext.npmTag}...`));
91256
91584
  }
91257
91585
  } else {
91258
91586
  console.log(source_default2.yellow(" \u2717 Not installed globally"));
@@ -91260,7 +91588,7 @@ async function installCliOnly() {
91260
91588
  const { doInstall } = await lib_default.prompt([{
91261
91589
  type: "confirm",
91262
91590
  name: "doInstall",
91263
- message: "Install adhdev CLI globally? (npm install -g adhdev)",
91591
+ message: `Install adhdev CLI globally? (npm install -g adhdev@${releaseContext.npmTag})`,
91264
91592
  default: true
91265
91593
  }]);
91266
91594
  if (!doInstall) {
@@ -91273,14 +91601,14 @@ async function installCliOnly() {
91273
91601
  }
91274
91602
  const installSpinner = ora2("Installing adhdev CLI...").start();
91275
91603
  try {
91276
- const installCommand = buildPinnedGlobalInstallCommand({ packageName: "adhdev", targetVersion: "latest" });
91604
+ const installCommand = buildPinnedGlobalInstallCommand({ packageName: "adhdev", targetVersion: releaseContext.npmTag });
91277
91605
  execFileSyncLocal(installCommand.command, installCommand.args, {
91278
91606
  encoding: "utf-8",
91279
91607
  timeout: 6e4,
91280
91608
  stdio: ["pipe", "pipe", "pipe"],
91281
91609
  ...installCommand.execOptions
91282
91610
  });
91283
- const newVersion = readInstalledGlobalCliVersion(execFileSyncLocal) || "latest";
91611
+ const newVersion = readInstalledGlobalCliVersion(execFileSyncLocal) || releaseContext.npmTag;
91284
91612
  installSpinner.succeed(`adhdev CLI ${currentVersion ? "updated" : "installed"} \u2713 (v${newVersion})`);
91285
91613
  console.log(source_default2.gray(" Try: adhdev daemon"));
91286
91614
  console.log();
@@ -91291,7 +91619,7 @@ async function installCliOnly() {
91291
91619
  if (osModule.platform() === "win32") {
91292
91620
  console.log(source_default2.gray(" On Windows, run PowerShell as Administrator"));
91293
91621
  }
91294
- console.log(source_default2.gray(" Manual: npm install -g adhdev@latest"));
91622
+ console.log(source_default2.gray(` Manual: npm install -g adhdev@${releaseContext.npmTag}`));
91295
91623
  console.log();
91296
91624
  }
91297
91625
  }
@@ -91306,7 +91634,7 @@ async function installCliOnly() {
91306
91634
  });
91307
91635
  /*! Bundled license information:
91308
91636
 
91309
- chokidar/index.js:
91637
+ chokidar/esm/index.js:
91310
91638
  (*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
91311
91639
 
91312
91640
  sharp/lib/is.js: