@adhdev/daemon-core 0.9.82-rc.412 → 0.9.82-rc.413

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.mjs CHANGED
@@ -17,9 +17,9 @@ var __export = (target, all) => {
17
17
  };
18
18
  var __copyProps = (to, from, except, desc) => {
19
19
  if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ for (let key2 of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key2) && key2 !== except)
22
+ __defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
23
23
  }
24
24
  return to;
25
25
  };
@@ -384,10 +384,10 @@ function readInjected(value) {
384
384
  }
385
385
  function getDaemonBuildInfo() {
386
386
  if (cached) return cached;
387
- const commit = readInjected(true ? "f8bbe838081c3b3e14df690b3ed24568979f635e" : void 0) ?? "unknown";
388
- const commitShort = readInjected(true ? "f8bbe838" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
389
- const version = readInjected(true ? "0.9.82-rc.412" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
390
- const builtAt = readInjected(true ? "2026-06-28T10:27:03.423Z" : void 0);
387
+ const commit = readInjected(true ? "7a774e95a82354f5357197b3c84f63e68b5f7a5d" : void 0) ?? "unknown";
388
+ const commitShort = readInjected(true ? "7a774e95" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
389
+ const version = readInjected(true ? "0.9.82-rc.413" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
390
+ const builtAt = readInjected(true ? "2026-06-28T11:48:26.300Z" : void 0);
391
391
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
392
392
  return cached;
393
393
  }
@@ -408,18 +408,18 @@ function isRecord(value) {
408
408
  function isStringArray(value) {
409
409
  return Array.isArray(value) && value.every((v) => typeof v === "string" && v.length > 0);
410
410
  }
411
- function validateTarget(value, key, errors) {
411
+ function validateTarget(value, key2, errors) {
412
412
  if (!isRecord(value)) {
413
- errors.push(`impactTargets.${key} must be an object`);
413
+ errors.push(`impactTargets.${key2} must be an object`);
414
414
  return void 0;
415
415
  }
416
416
  const { recommendedCommand } = value;
417
417
  if (typeof recommendedCommand !== "string" || !recommendedCommand.length) {
418
- errors.push(`impactTargets.${key}.recommendedCommand must be a non-empty string`);
418
+ errors.push(`impactTargets.${key2}.recommendedCommand must be a non-empty string`);
419
419
  return void 0;
420
420
  }
421
421
  for (const k of Object.keys(value)) {
422
- if (k !== "recommendedCommand") errors.push(`impactTargets.${key}.${k} is not a recognized field (only recommendedCommand)`);
422
+ if (k !== "recommendedCommand") errors.push(`impactTargets.${key2}.${k} is not a recognized field (only recommendedCommand)`);
423
423
  }
424
424
  return { recommendedCommand };
425
425
  }
@@ -446,20 +446,20 @@ function validateChangeImpactConfig(raw, source = "inline") {
446
446
  errors.push("impactTargets must be an object");
447
447
  } else {
448
448
  const targets = {};
449
- for (const key of Object.keys(raw.impactTargets)) {
450
- if (key !== "daemon" && key !== "web" && key !== "none") {
451
- errors.push(`impactTargets.${key} is not a recognized impact kind (daemon|web|none)`);
449
+ for (const key2 of Object.keys(raw.impactTargets)) {
450
+ if (key2 !== "daemon" && key2 !== "web" && key2 !== "none") {
451
+ errors.push(`impactTargets.${key2} is not a recognized impact kind (daemon|web|none)`);
452
452
  continue;
453
453
  }
454
- const target = validateTarget(raw.impactTargets[key], key, errors);
455
- if (target) targets[key] = target;
454
+ const target = validateTarget(raw.impactTargets[key2], key2, errors);
455
+ if (target) targets[key2] = target;
456
456
  }
457
457
  if (Object.keys(targets).length) config.impactTargets = targets;
458
458
  }
459
459
  }
460
- for (const key of Object.keys(raw)) {
461
- if (!["daemonRuntimePackages", "webOnlyPackages", "nonRuntimeRootFilePatterns", "impactTargets"].includes(key)) {
462
- errors.push(`unknown config key '${key}'`);
460
+ for (const key2 of Object.keys(raw)) {
461
+ if (!["daemonRuntimePackages", "webOnlyPackages", "nonRuntimeRootFilePatterns", "impactTargets"].includes(key2)) {
462
+ errors.push(`unknown config key '${key2}'`);
463
463
  }
464
464
  }
465
465
  return { valid: errors.length === 0, errors, config: errors.length === 0 ? config : void 0 };
@@ -788,12 +788,12 @@ function resolveChangeImpactConfigForRepo(repoRoot, options) {
788
788
  return { config: null, sourceKey: "forced-default" };
789
789
  }
790
790
  if (options.changeImpactConfig !== void 0) {
791
- let key = "injected";
791
+ let key2 = "injected";
792
792
  try {
793
- key = `injected:${JSON.stringify(options.changeImpactConfig)}`;
793
+ key2 = `injected:${JSON.stringify(options.changeImpactConfig)}`;
794
794
  } catch {
795
795
  }
796
- return { config: options.changeImpactConfig, sourceKey: key };
796
+ return { config: options.changeImpactConfig, sourceKey: key2 };
797
797
  }
798
798
  if (!repoRoot) {
799
799
  return { config: null, sourceKey: "no-repo-root" };
@@ -2355,9 +2355,9 @@ function dismissSessionNotification(state, sessionId, notificationId, providerSe
2355
2355
  ].filter(Boolean)));
2356
2356
  const nextSessionNotificationDismissals = { ...state.sessionNotificationDismissals || {} };
2357
2357
  const nextSessionNotificationUnreadOverrides = { ...state.sessionNotificationUnreadOverrides || {} };
2358
- for (const key of dismissalKeys) {
2359
- nextSessionNotificationDismissals[key] = dismissalId;
2360
- delete nextSessionNotificationUnreadOverrides[key];
2358
+ for (const key2 of dismissalKeys) {
2359
+ nextSessionNotificationDismissals[key2] = dismissalId;
2360
+ delete nextSessionNotificationUnreadOverrides[key2];
2361
2361
  }
2362
2362
  return {
2363
2363
  ...state,
@@ -2374,9 +2374,9 @@ function markSessionNotificationUnread(state, sessionId, notificationId, provide
2374
2374
  ].filter(Boolean)));
2375
2375
  const nextSessionNotificationDismissals = { ...state.sessionNotificationDismissals || {} };
2376
2376
  const nextSessionNotificationUnreadOverrides = { ...state.sessionNotificationUnreadOverrides || {} };
2377
- for (const key of unreadKeys) {
2378
- nextSessionNotificationUnreadOverrides[key] = unreadId;
2379
- delete nextSessionNotificationDismissals[key];
2377
+ for (const key2 of unreadKeys) {
2378
+ nextSessionNotificationUnreadOverrides[key2] = unreadId;
2379
+ delete nextSessionNotificationDismissals[key2];
2380
2380
  }
2381
2381
  return {
2382
2382
  ...state,
@@ -2440,11 +2440,11 @@ function markSessionSeen(state, sessionId, seenAt = Date.now(), completionMarker
2440
2440
  const nextSessionReadMarkers = { ...prevMarkers };
2441
2441
  const nextSessionNotificationDismissals = { ...state.sessionNotificationDismissals || {} };
2442
2442
  const nextSessionNotificationUnreadOverrides = { ...state.sessionNotificationUnreadOverrides || {} };
2443
- for (const key of readKeys) {
2444
- nextSessionReads[key] = Math.max(prev[key] || 0, seenAt);
2445
- if (nextMarker) nextSessionReadMarkers[key] = nextMarker;
2446
- delete nextSessionNotificationDismissals[key];
2447
- delete nextSessionNotificationUnreadOverrides[key];
2443
+ for (const key2 of readKeys) {
2444
+ nextSessionReads[key2] = Math.max(prev[key2] || 0, seenAt);
2445
+ if (nextMarker) nextSessionReadMarkers[key2] = nextMarker;
2446
+ delete nextSessionNotificationDismissals[key2];
2447
+ delete nextSessionNotificationUnreadOverrides[key2];
2448
2448
  }
2449
2449
  return {
2450
2450
  ...state,
@@ -3147,6 +3147,12 @@ function machineCoreFromDaemonId(id) {
3147
3147
  }
3148
3148
  return trimmed;
3149
3149
  }
3150
+ function canonicalDaemonId(id) {
3151
+ const core = machineCoreFromDaemonId(id);
3152
+ if (!core) return void 0;
3153
+ if (!core.startsWith("mach_")) return core;
3154
+ return `daemon_${core}`;
3155
+ }
3150
3156
  function daemonIdsEquivalent(a, b) {
3151
3157
  const coreA = machineCoreFromDaemonId(a);
3152
3158
  const coreB = machineCoreFromDaemonId(b);
@@ -3311,8 +3317,8 @@ function expandPromptPlaceholders(template, ctx) {
3311
3317
  rules: buildRulesSection(coordinatorCliType),
3312
3318
  toolExposurePreflight: TOOL_EXPOSURE_PREFLIGHT_SECTION
3313
3319
  };
3314
- return template.replace(/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g, (m, key) => {
3315
- return Object.prototype.hasOwnProperty.call(replacements, key) ? replacements[key] : m;
3320
+ return template.replace(/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g, (m, key2) => {
3321
+ return Object.prototype.hasOwnProperty.call(replacements, key2) ? replacements[key2] : m;
3316
3322
  });
3317
3323
  }
3318
3324
  function buildNodeStatusSection(nodes) {
@@ -4711,6 +4717,33 @@ var init_mesh_delivery_policy = __esm({
4711
4717
  }
4712
4718
  });
4713
4719
 
4720
+ // src/mesh/mesh-task-inflight.ts
4721
+ function key(meshId, taskId) {
4722
+ return `${meshId}::${taskId}`;
4723
+ }
4724
+ function beginTaskDispatchInFlight(meshId, taskId) {
4725
+ if (!meshId || !taskId) return false;
4726
+ const k = key(meshId, taskId);
4727
+ if (inFlight.has(k)) return false;
4728
+ inFlight.add(k);
4729
+ return true;
4730
+ }
4731
+ function isTaskDispatchInFlight(meshId, taskId) {
4732
+ if (!meshId || !taskId) return false;
4733
+ return inFlight.has(key(meshId, taskId));
4734
+ }
4735
+ function endTaskDispatchInFlight(meshId, taskId) {
4736
+ if (!meshId || !taskId) return;
4737
+ inFlight.delete(key(meshId, taskId));
4738
+ }
4739
+ var inFlight;
4740
+ var init_mesh_task_inflight = __esm({
4741
+ "src/mesh/mesh-task-inflight.ts"() {
4742
+ "use strict";
4743
+ inFlight = /* @__PURE__ */ new Set();
4744
+ }
4745
+ });
4746
+
4714
4747
  // src/mesh/mesh-work-queue.ts
4715
4748
  var mesh_work_queue_exports = {};
4716
4749
  __export(mesh_work_queue_exports, {
@@ -4978,14 +5011,14 @@ function firstProviderPriority(policy) {
4978
5011
  if (!Array.isArray(raw)) return void 0;
4979
5012
  return raw.find((type) => typeof type === "string" && type.trim())?.trim();
4980
5013
  }
4981
- function readNodeOverride(node, key) {
5014
+ function readNodeOverride(node, key2) {
4982
5015
  const overrides = node?.userOverrides;
4983
5016
  if (!overrides || typeof overrides !== "object" || Array.isArray(overrides)) return null;
4984
- const value = overrides[key];
5017
+ const value = overrides[key2];
4985
5018
  return typeof value === "string" && value.trim() ? value.trim() : null;
4986
5019
  }
4987
- function readNodeReporter(node, key) {
4988
- const value = key === "platform" ? node?.reportedPlatform : node?.reportedArch;
5020
+ function readNodeReporter(node, key2) {
5021
+ const value = key2 === "platform" ? node?.reportedPlatform : node?.reportedArch;
4989
5022
  return typeof value === "string" && value.trim() ? value.trim() : null;
4990
5023
  }
4991
5024
  function buildMeshNodeCapabilityTags(node, providerType) {
@@ -5204,6 +5237,7 @@ function updateTaskStatus(meshId, taskId, status, opts) {
5204
5237
  if (!entry) return null;
5205
5238
  entry.status = status;
5206
5239
  MeshRuntimeStore.getInstance().updateQueueEntry(entry);
5240
+ if (status !== "assigned") endTaskDispatchInFlight(meshId, taskId);
5207
5241
  if (DEPENDENCY_FAILURE_TERMINALS.has(status)) propagateDependencyFailure(meshId, taskId);
5208
5242
  return entry;
5209
5243
  });
@@ -5228,6 +5262,7 @@ function cancelTask(meshId, taskId, opts) {
5228
5262
  entry.cancelledAt = now;
5229
5263
  if (opts?.reason) entry.cancelReason = opts.reason;
5230
5264
  MeshRuntimeStore.getInstance().updateQueueEntry(entry);
5265
+ endTaskDispatchInFlight(meshId, taskId);
5231
5266
  propagateDependencyFailure(meshId, taskId);
5232
5267
  return entry;
5233
5268
  });
@@ -5237,6 +5272,11 @@ function requeueTask(meshId, taskId, opts) {
5237
5272
  return withQueueLock(meshId, () => {
5238
5273
  const entry = MeshRuntimeStore.getInstance().findQueueEntryById(meshId, taskId);
5239
5274
  if (!entry) return null;
5275
+ if (!opts?.force && isTaskDispatchInFlight(meshId, taskId)) {
5276
+ LOG.warn("MeshQueue", `Refusing to requeue task ${taskId} on mesh ${meshId}: it is actively dispatched/generating (single-flight in-flight). Requeueing now would open a duplicate second dispatch into another session. Pass force to override.`);
5277
+ return entry;
5278
+ }
5279
+ endTaskDispatchInFlight(meshId, taskId);
5240
5280
  const currentCount = entry.requeueCount || 0;
5241
5281
  const maxRetries = opts?.maxRetries ?? entry.maxRetries ?? 1;
5242
5282
  if (!opts?.force && currentCount >= maxRetries) {
@@ -5281,6 +5321,7 @@ function reclaimStrandedAssignedTask(meshId, taskId, opts) {
5281
5321
  delete entry.dispatchTimestamp;
5282
5322
  entry.strandedReclaimCount = reclaims;
5283
5323
  entry.updatedAt = now;
5324
+ endTaskDispatchInFlight(meshId, taskId);
5284
5325
  if (reclaims > MAX_STRANDED_RECLAIMS) {
5285
5326
  entry.status = "failed";
5286
5327
  entry.cancelReason = `stranded_dispatch_unrecovered: reclaimed ${reclaims - 1} time(s) without a confirmed dispatch`;
@@ -5324,6 +5365,7 @@ function updateSessionTaskStatus(meshId, sessionId, status, opts) {
5324
5365
  }
5325
5366
  entry.status = status;
5326
5367
  store.updateQueueEntry(entry);
5368
+ if (status !== "assigned") endTaskDispatchInFlight(meshId, entry.id);
5327
5369
  if (DEPENDENCY_FAILURE_TERMINALS.has(status)) propagateDependencyFailure(meshId, entry.id);
5328
5370
  return entry;
5329
5371
  });
@@ -5437,6 +5479,7 @@ var init_mesh_work_queue = __esm({
5437
5479
  init_logger();
5438
5480
  init_mesh_ledger();
5439
5481
  init_mesh_delivery_policy();
5482
+ init_mesh_task_inflight();
5440
5483
  ACTIVE_MESH_QUEUE_STATUSES = ["pending", "assigned"];
5441
5484
  HISTORICAL_MESH_QUEUE_STATUSES = ["completed", "failed", "cancelled"];
5442
5485
  MESH_TASK_MODES = ["code_change", "validation", "live_debug_readonly", "launch_app", "convergence"];
@@ -7502,7 +7545,7 @@ function resolveNodeEvidence(nodeId, ledgerEntries) {
7502
7545
  timestamp: entry.timestamp,
7503
7546
  ...entry.sessionId ? { sessionId: entry.sessionId } : {},
7504
7547
  bootstrap: readRecord3(validationSummary?.bootstrap),
7505
- validation: validationSummary ? Object.fromEntries(Object.entries(validationSummary).filter(([key]) => key !== "bootstrap")) : null,
7548
+ validation: validationSummary ? Object.fromEntries(Object.entries(validationSummary).filter(([key2]) => key2 !== "bootstrap")) : null,
7506
7549
  checkpoint: readRecord3(result?.checkpoint),
7507
7550
  worker: null,
7508
7551
  ...readRecord3(payload.finalBranchConvergenceState) ?? readRecord3(result?.finalBranchConvergenceState) ? { finalBranchConvergenceState: readRecord3(payload.finalBranchConvergenceState) ?? readRecord3(result?.finalBranchConvergenceState) } : {},
@@ -7771,7 +7814,7 @@ function resolveMeshCoordinatorSetup(options) {
7771
7814
  };
7772
7815
  }
7773
7816
  function renderMeshCoordinatorTemplate(template, values) {
7774
- return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand|adhdevMcpArgs)\s*\}\}/g, (_, key) => values[key] || "");
7817
+ return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand|adhdevMcpArgs)\s*\}\}/g, (_, key2) => values[key2] || "");
7775
7818
  }
7776
7819
  function replaceLegacyCliCommandMcpArgs(command, args) {
7777
7820
  return command.replace(
@@ -7780,9 +7823,9 @@ function replaceLegacyCliCommandMcpArgs(command, args) {
7780
7823
  );
7781
7824
  }
7782
7825
  function resolveHermesCoordinatorHome(meshId, workspace) {
7783
- const key = `${meshId || "mesh"}
7826
+ const key2 = `${meshId || "mesh"}
7784
7827
  ${resolve7(workspace || os4.tmpdir())}`;
7785
- const hash = shortHash(key);
7828
+ const hash = shortHash(key2);
7786
7829
  return join10(os4.tmpdir(), `adhdev-hermes-mesh-coordinator-${hash}`);
7787
7830
  }
7788
7831
  function resolveMcpConfigPath(configPath, workspace) {
@@ -8252,9 +8295,9 @@ function suggestMeshRefineConfig(mesh, workspace) {
8252
8295
  const seen = /* @__PURE__ */ new Set();
8253
8296
  const suggestions = [];
8254
8297
  for (const entry of [...collectProjectContextSuggestions(mesh), ...collectPackageScriptSuggestions(workspace)]) {
8255
- const key = `${entry.command} ${(entry.args || []).join(" ")}`.trim();
8256
- if (seen.has(key)) continue;
8257
- seen.add(key);
8298
+ const key2 = `${entry.command} ${(entry.args || []).join(" ")}`.trim();
8299
+ if (seen.has(key2)) continue;
8300
+ seen.add(key2);
8258
8301
  suggestions.push(entry);
8259
8302
  }
8260
8303
  return {
@@ -11748,6 +11791,9 @@ var init_mesh_warmup_deadline = __esm({
11748
11791
 
11749
11792
  // src/mesh/mesh-queue-assignment.ts
11750
11793
  import { existsSync as existsSync17 } from "fs";
11794
+ function localCoordinatorDaemonId() {
11795
+ return canonicalDaemonId(readNonEmptyString2(loadConfig().machineId));
11796
+ }
11751
11797
  function __resetIdleAutoFastForwardForTests() {
11752
11798
  idleAutoFastForwardLastAttempt.clear();
11753
11799
  }
@@ -11833,6 +11879,7 @@ function deliverTaskToSession(dispatchThunk, ctx, warmup) {
11833
11879
  if (timer) clearTimeout(timer);
11834
11880
  LOG.error("MeshQueue", `Failed to dispatch task via ${ctx.transport} to node ${ctx.nodeId}: ${e?.message}`);
11835
11881
  updateSessionDeliveryStatus(delivery.id, "failed", { lastError: e?.message, incrementAttempt: true });
11882
+ endTaskDispatchInFlight(ctx.meshId, ctx.task.id);
11836
11883
  updateTaskStatus(ctx.meshId, ctx.task.id, "pending");
11837
11884
  try {
11838
11885
  appendLedgerEntry(ctx.meshId, {
@@ -11906,10 +11953,11 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
11906
11953
  return false;
11907
11954
  }
11908
11955
  LOG.info("MeshQueue", `Node ${nodeId} (${sessionId}) pulled task ${task.id}`);
11956
+ beginTaskDispatchInFlight(meshId, task.id);
11909
11957
  if (node?.daemonId && components.dispatchMeshCommand) {
11910
11958
  const isLocalNode = components.cliManager.adapters.has(sessionId);
11911
11959
  if (!isLocalNode) {
11912
- const localDaemonIdForDispatch = readNonEmptyString2(loadConfig().machineId) || void 0;
11960
+ const localDaemonIdForDispatch = localCoordinatorDaemonId();
11913
11961
  const sourceCoordinatorSessionId = readNonEmptyString2(task.sourceCoordinatorSessionId) || void 0;
11914
11962
  const dispatchMeshCommand = components.dispatchMeshCommand;
11915
11963
  const remoteDaemonId = node.daemonId;
@@ -11948,7 +11996,7 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
11948
11996
  try {
11949
11997
  const inst = components.instanceManager.getInstance(sessionId);
11950
11998
  if (inst && typeof inst.updateSettings === "function") {
11951
- const localDaemonId = readNonEmptyString2(loadConfig().machineId);
11999
+ const localDaemonId = localCoordinatorDaemonId();
11952
12000
  const localSourceCoordinatorSessionId = readNonEmptyString2(task.sourceCoordinatorSessionId);
11953
12001
  inst.updateSettings({
11954
12002
  meshNodeFor: meshId,
@@ -11973,7 +12021,7 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
11973
12021
  meshId,
11974
12022
  nodeId,
11975
12023
  taskId: task.id,
11976
- ...readNonEmptyString2(loadConfig().machineId) ? { coordinatorDaemonId: readNonEmptyString2(loadConfig().machineId) } : {},
12024
+ ...localCoordinatorDaemonId() ? { coordinatorDaemonId: localCoordinatorDaemonId() } : {},
11977
12025
  ...readNonEmptyString2(task.sourceCoordinatorSessionId) ? { coordinatorSessionId: readNonEmptyString2(task.sourceCoordinatorSessionId) } : {}
11978
12026
  }
11979
12027
  }),
@@ -11985,7 +12033,7 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
11985
12033
  task,
11986
12034
  transport: "local",
11987
12035
  ...readNonEmptyString2(task.sourceCoordinatorSessionId) ? { sourceCoordinatorSessionId: readNonEmptyString2(task.sourceCoordinatorSessionId) } : {},
11988
- ...readNonEmptyString2(loadConfig().machineId) ? { sourceCoordinatorDaemonId: readNonEmptyString2(loadConfig().machineId) } : {}
12036
+ ...localCoordinatorDaemonId() ? { sourceCoordinatorDaemonId: localCoordinatorDaemonId() } : {}
11989
12037
  }
11990
12038
  );
11991
12039
  return true;
@@ -12067,8 +12115,8 @@ function notifyCoordinatorOfActionableSkip(meshId, taskId, reason, nodeId) {
12067
12115
  }
12068
12116
  function sweepExpiredCooldowns() {
12069
12117
  const now = Date.now();
12070
- for (const [key, until] of autoLaunchCooldownUntil) {
12071
- if (now >= until) autoLaunchCooldownUntil.delete(key);
12118
+ for (const [key2, until] of autoLaunchCooldownUntil) {
12119
+ if (now >= until) autoLaunchCooldownUntil.delete(key2);
12072
12120
  }
12073
12121
  }
12074
12122
  function normalizeProviderPriority(policy) {
@@ -12114,7 +12162,7 @@ function nodeHasActiveMeshWork(components, meshId, nodeId, currentSessionId) {
12114
12162
  const settings = state.settings || {};
12115
12163
  if (readNonEmptyString2(settings.meshNodeFor) !== meshId) return false;
12116
12164
  const instNodeId = readNonEmptyString2(settings.meshNodeId) || readNonEmptyString2(settings.nodeId);
12117
- if (instNodeId !== nodeId) return false;
12165
+ if (!daemonIdsEquivalent(instNodeId, nodeId)) return false;
12118
12166
  const sessionId = readNonEmptyString2(state.instanceId);
12119
12167
  if (currentSessionId && sessionId === currentSessionId && isIdleSessionState(state)) return false;
12120
12168
  return sessionStateLooksActive(state);
@@ -12146,7 +12194,7 @@ function resolveAutoLaunchTarget(components, node) {
12146
12194
  const daemonId = readNonEmptyString2(node?.daemonId);
12147
12195
  if (!daemonId) return { mode: "skip", reason: "remote_auto_launch_unsupported" };
12148
12196
  if (!components.dispatchMeshCommand) return { mode: "skip", reason: "remote_auto_launch_unsupported" };
12149
- const coordinatorDaemonId = readNonEmptyString2(loadConfig().machineId);
12197
+ const coordinatorDaemonId = localCoordinatorDaemonId();
12150
12198
  if (!coordinatorDaemonId) return { mode: "skip", reason: "remote_auto_launch_no_coordinator_daemon_id" };
12151
12199
  return { mode: "remote", daemonId, coordinatorDaemonId };
12152
12200
  }
@@ -12157,7 +12205,7 @@ function activeReadonlyAssignedCount(meshId) {
12157
12205
  return getQueue(meshId, { status: ["assigned"] }).filter(isTaskReadonly).length;
12158
12206
  }
12159
12207
  function nodeHasActiveAssignment(meshId, nodeId) {
12160
- return getQueue(meshId, { status: ["assigned"] }).some((task) => task.assignedNodeId === nodeId);
12208
+ return getQueue(meshId, { status: ["assigned"] }).some((task) => daemonIdsEquivalent(task.assignedNodeId, nodeId));
12161
12209
  }
12162
12210
  function nodeActiveLoad(meshId, nodeId) {
12163
12211
  return MeshRuntimeStore.getInstance().nodeActiveAssignmentCount(meshId, nodeId);
@@ -12187,7 +12235,7 @@ function orderEligibleNodes(meshId, strategy, nodes, opts) {
12187
12235
  });
12188
12236
  }
12189
12237
  function activeProviderAssignedCount(meshId, nodeId, providerType) {
12190
- return getQueue(meshId, { status: ["assigned"] }).filter((task) => task.assignedNodeId === nodeId && task.assignedProviderType === providerType).length;
12238
+ return getQueue(meshId, { status: ["assigned"] }).filter((task) => daemonIdsEquivalent(task.assignedNodeId, nodeId) && task.assignedProviderType === providerType).length;
12191
12239
  }
12192
12240
  function sessionHasActiveAssignment(meshId, sessionId) {
12193
12241
  if (getQueue(meshId, { status: ["assigned"] }).some((task) => task.assignedSessionId === sessionId)) {
@@ -12206,7 +12254,7 @@ function liveSessionCountForNode(components, meshId, nodeId) {
12206
12254
  const settings = state.settings || {};
12207
12255
  if (readNonEmptyString2(settings.meshNodeFor) !== meshId) return false;
12208
12256
  const instNodeId = readNonEmptyString2(settings.meshNodeId) || readNonEmptyString2(settings.nodeId);
12209
- if (instNodeId !== nodeId) return false;
12257
+ if (!daemonIdsEquivalent(instNodeId, nodeId)) return false;
12210
12258
  const status = readNonEmptyString2(state.status).toLowerCase();
12211
12259
  return !isTerminalSessionStatus(status);
12212
12260
  }).length;
@@ -12724,6 +12772,7 @@ var init_mesh_queue_assignment = __esm({
12724
12772
  init_mesh_events_utils();
12725
12773
  init_mesh_events_pending();
12726
12774
  init_worktree_bootstrap_config();
12775
+ init_mesh_task_inflight();
12727
12776
  IDLE_AUTO_FAST_FORWARD_THROTTLE_MS = 30 * 60 * 1e3;
12728
12777
  idleAutoFastForwardLastAttempt = /* @__PURE__ */ new Map();
12729
12778
  DISPATCH_CONFIRM_TIMEOUT_MS = 12e4;
@@ -12824,8 +12873,8 @@ function recordUnroutableDelegateEvent(routing, eventName) {
12824
12873
  if (last !== void 0 && now - last < UNROUTABLE_DIAGNOSTIC_DEDUP_MS) return false;
12825
12874
  recentUnroutableDiagnostics.set(dedupKey, now);
12826
12875
  if (recentUnroutableDiagnostics.size > 256) {
12827
- for (const [key, ts2] of recentUnroutableDiagnostics) {
12828
- if (now - ts2 >= UNROUTABLE_DIAGNOSTIC_DEDUP_MS) recentUnroutableDiagnostics.delete(key);
12876
+ for (const [key2, ts2] of recentUnroutableDiagnostics) {
12877
+ if (now - ts2 >= UNROUTABLE_DIAGNOSTIC_DEDUP_MS) recentUnroutableDiagnostics.delete(key2);
12829
12878
  }
12830
12879
  }
12831
12880
  try {
@@ -13090,9 +13139,9 @@ async function updateDarwinMemoryCache() {
13090
13139
  for (const line of stdout.split("\n")) {
13091
13140
  const m = line.match(/^\s*Pages\s+([^:]+):\s+([\d,]+)\s*\.?/);
13092
13141
  if (!m) continue;
13093
- const key = m[1].trim().toLowerCase().replace(/\s+/g, "_");
13142
+ const key2 = m[1].trim().toLowerCase().replace(/\s+/g, "_");
13094
13143
  const n = parseInt(m[2].replace(/,/g, ""), 10);
13095
- if (!Number.isNaN(n)) counts[key] = n;
13144
+ if (!Number.isNaN(n)) counts[key2] = n;
13096
13145
  }
13097
13146
  const free = counts["free"] ?? 0;
13098
13147
  const inactive = counts["inactive"] ?? 0;
@@ -13316,7 +13365,7 @@ function trimStructuredStrings(value, maxChars) {
13316
13365
  if (Array.isArray(value)) return value.map((item) => trimStructuredStrings(item, maxChars));
13317
13366
  if (!value || typeof value !== "object") return value;
13318
13367
  return Object.fromEntries(
13319
- Object.entries(value).map(([key, nested]) => [key, trimStructuredStrings(nested, maxChars)])
13368
+ Object.entries(value).map(([key2, nested]) => [key2, trimStructuredStrings(nested, maxChars)])
13320
13369
  );
13321
13370
  }
13322
13371
  function estimateBytes(value) {
@@ -13907,9 +13956,9 @@ function readMessageMeta(message) {
13907
13956
  function readStringField(value) {
13908
13957
  return typeof value === "string" ? value.trim().toLowerCase() : "";
13909
13958
  }
13910
- function readRecordField(message, meta, key) {
13959
+ function readRecordField(message, meta, key2) {
13911
13960
  const record = message;
13912
- return record[key] ?? meta?.[key];
13961
+ return record[key2] ?? meta?.[key2];
13913
13962
  }
13914
13963
  function readVisibilityField(message, meta) {
13915
13964
  return readStringField(readRecordField(message, meta, "visibility"));
@@ -13920,7 +13969,7 @@ function readTranscriptVisibilityField(message, meta) {
13920
13969
  }
13921
13970
  function hasBooleanMarker(message, meta, keys) {
13922
13971
  const record = message;
13923
- return keys.some((key) => record[key] === true || meta?.[key] === true);
13972
+ return keys.some((key2) => record[key2] === true || meta?.[key2] === true);
13924
13973
  }
13925
13974
  function isActivityKind(kind) {
13926
13975
  return kind === "thought" || kind === "tool" || kind === "terminal";
@@ -14112,9 +14161,9 @@ function extractProviderControlValues(controls, data) {
14112
14161
  const values = {};
14113
14162
  const explicit = data.controlValues;
14114
14163
  if (explicit && typeof explicit === "object") {
14115
- for (const [key, value] of Object.entries(explicit)) {
14164
+ for (const [key2, value] of Object.entries(explicit)) {
14116
14165
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
14117
- values[key] = value;
14166
+ values[key2] = value;
14118
14167
  }
14119
14168
  }
14120
14169
  }
@@ -14578,26 +14627,26 @@ function getGitSummaryForWorkspace(workspace, options) {
14578
14627
  if (!workspace) return void 0;
14579
14628
  return options.getGitSummaryForWorkspace?.(workspace) || void 0;
14580
14629
  }
14581
- function findCdpManager(cdpManagers, key) {
14582
- const exact = cdpManagers.get(key);
14630
+ function findCdpManager(cdpManagers, key2) {
14631
+ const exact = cdpManagers.get(key2);
14583
14632
  if (exact) return exact.isConnected ? exact : null;
14584
- const prefix = key + "_";
14633
+ const prefix = key2 + "_";
14585
14634
  const matches = [...cdpManagers.entries()].filter(([k, m]) => m.isConnected && k.startsWith(prefix));
14586
14635
  if (matches.length === 1) return matches[0][1];
14587
14636
  return null;
14588
14637
  }
14589
- function hasCdpManager(cdpManagers, key) {
14590
- if (cdpManagers.has(key)) return true;
14591
- const prefix = key + "_";
14638
+ function hasCdpManager(cdpManagers, key2) {
14639
+ if (cdpManagers.has(key2)) return true;
14640
+ const prefix = key2 + "_";
14592
14641
  for (const k of cdpManagers.keys()) {
14593
14642
  if (k.startsWith(prefix)) return true;
14594
14643
  }
14595
14644
  return false;
14596
14645
  }
14597
- function isCdpConnected(cdpManagers, key) {
14598
- const exact = cdpManagers.get(key);
14646
+ function isCdpConnected(cdpManagers, key2) {
14647
+ const exact = cdpManagers.get(key2);
14599
14648
  if (exact?.isConnected) return true;
14600
- const prefix = key + "_";
14649
+ const prefix = key2 + "_";
14601
14650
  for (const [k, m] of cdpManagers.entries()) {
14602
14651
  if (m.isConnected && k.startsWith(prefix)) return true;
14603
14652
  }
@@ -16493,9 +16542,9 @@ function recordHeldTerminalEventsToLedger(meshId, drainDaemonIds, reason, heldFo
16493
16542
  for (const event of pending) {
16494
16543
  if (!shouldForceInjectMeshEvent(event.event)) continue;
16495
16544
  const fingerprint = buildPendingEventFingerprint(event);
16496
- const key = `${meshId}::${fingerprint || `${event.event}::${event.nodeId || ""}::${event.queuedAt}`}`;
16497
- if (heldEventLedgerRecorded.has(key)) continue;
16498
- heldEventLedgerRecorded.add(key);
16545
+ const key2 = `${meshId}::${fingerprint || `${event.event}::${event.nodeId || ""}::${event.queuedAt}`}`;
16546
+ if (heldEventLedgerRecorded.has(key2)) continue;
16547
+ heldEventLedgerRecorded.add(key2);
16499
16548
  const finalSummary = readMeshCompletionSummary(event.metadataEvent);
16500
16549
  try {
16501
16550
  appendLedgerEntry(meshId, {
@@ -16516,7 +16565,7 @@ function recordHeldTerminalEventsToLedger(meshId, drainDaemonIds, reason, heldFo
16516
16565
  });
16517
16566
  LOG.info("MeshReconcile", `Ledger-recorded held ${event.event} for mesh ${meshId} (reason ${reason}) \u2014 recoverable from ledger`);
16518
16567
  } catch (e) {
16519
- heldEventLedgerRecorded.delete(key);
16568
+ heldEventLedgerRecorded.delete(key2);
16520
16569
  LOG.warn("MeshReconcile", `Failed to ledger-record held ${event.event} for mesh ${meshId}: ${e?.message || e}`);
16521
16570
  }
16522
16571
  }
@@ -16981,9 +17030,9 @@ async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds,
16981
17030
  const activeTaskKeys = new Set(
16982
17031
  dispatches.map((d) => readNonEmptyString2(d.taskId)).filter(Boolean).map((taskId) => inFlightSynthKey(mesh.id, taskId))
16983
17032
  );
16984
- for (const key of inFlightAckedHoldState.keys()) {
16985
- if (key.startsWith(`${mesh.id}::`) && !activeTaskKeys.has(key)) {
16986
- inFlightAckedHoldState.delete(key);
17033
+ for (const key2 of inFlightAckedHoldState.keys()) {
17034
+ if (key2.startsWith(`${mesh.id}::`) && !activeTaskKeys.has(key2)) {
17035
+ inFlightAckedHoldState.delete(key2);
16987
17036
  }
16988
17037
  }
16989
17038
  const dispatchMeshCommand = components.dispatchMeshCommand;
@@ -18569,8 +18618,8 @@ function extractButtonsFromRule(rule, hay) {
18569
18618
  label += " " + next.trim();
18570
18619
  j += 1;
18571
18620
  }
18572
- const key = keyTemplate.replace(/\{index\}/g, String(idx));
18573
- buttons.push({ index: idx, label, key, current });
18621
+ const key2 = keyTemplate.replace(/\{index\}/g, String(idx));
18622
+ buttons.push({ index: idx, label, key: key2, current });
18574
18623
  i = j - 1;
18575
18624
  }
18576
18625
  } else {
@@ -18580,8 +18629,8 @@ function extractButtonsFromRule(rule, hay) {
18580
18629
  const idx = Number(m[1]);
18581
18630
  const label = String(m[2] ?? "").trim();
18582
18631
  if (!Number.isFinite(idx) || idx <= 0 || !label) continue;
18583
- const key = keyTemplate.replace(/\{index\}/g, String(idx));
18584
- buttons.push({ index: idx, label, key, current: hasCursorMarker(m[0]) });
18632
+ const key2 = keyTemplate.replace(/\{index\}/g, String(idx));
18633
+ buttons.push({ index: idx, label, key: key2, current: hasCursorMarker(m[0]) });
18585
18634
  }
18586
18635
  }
18587
18636
  const block2 = lastContiguousNumberedBlock(buttons);
@@ -18661,12 +18710,12 @@ function evalCond(cond, sections, fullScreen, cursor, prevLines, clock, legacyTr
18661
18710
  return { kind: "elapsed", result, detail: `elapsed ${age}ms / ${cond.elapsed_ms}ms`, remainingMs };
18662
18711
  }
18663
18712
  if (isStable(cond)) {
18664
- const key = regionKey(cond.cursor_above);
18665
- const lastChanged = clock.regionLastChangedAt.get(key) ?? clock.stateEnteredAt;
18713
+ const key2 = regionKey(cond.cursor_above);
18714
+ const lastChanged = clock.regionLastChangedAt.get(key2) ?? clock.stateEnteredAt;
18666
18715
  const stableFor = clock.now - lastChanged;
18667
18716
  const result = stableFor >= cond.stable_ms;
18668
18717
  const remainingMs = result ? 0 : cond.stable_ms - stableFor;
18669
- const where = key === WHOLE_SCREEN ? "screen" : `cursor_above=${cond.cursor_above}`;
18718
+ const where = key2 === WHOLE_SCREEN ? "screen" : `cursor_above=${cond.cursor_above}`;
18670
18719
  return { kind: "stable", result, detail: `stable ${where} ${stableFor}ms / ${cond.stable_ms}ms`, remainingMs };
18671
18720
  }
18672
18721
  if (isRegex(cond) || isChanged(cond)) {
@@ -22610,16 +22659,16 @@ function normalizeModuleName(request) {
22610
22659
  }
22611
22660
  function buildFsShim() {
22612
22661
  const shim = {};
22613
- for (const key of FS_READ_ONLY_MEMBERS) {
22614
- if (key === "promises") continue;
22615
- const real = nodeFs[key];
22616
- if (real !== void 0) shim[key] = real;
22662
+ for (const key2 of FS_READ_ONLY_MEMBERS) {
22663
+ if (key2 === "promises") continue;
22664
+ const real = nodeFs[key2];
22665
+ if (real !== void 0) shim[key2] = real;
22617
22666
  }
22618
22667
  const realPromises = nodeFs.promises || {};
22619
22668
  const promisesShim = {};
22620
- for (const key of FS_PROMISES_READ_ONLY_MEMBERS) {
22621
- const real = realPromises[key];
22622
- if (real !== void 0) promisesShim[key] = real;
22669
+ for (const key2 of FS_PROMISES_READ_ONLY_MEMBERS) {
22670
+ const real = realPromises[key2];
22671
+ if (real !== void 0) promisesShim[key2] = real;
22623
22672
  }
22624
22673
  shim.promises = promisesShim;
22625
22674
  return shim;
@@ -22702,10 +22751,10 @@ function _uninstallProviderProcessShimForTest() {
22702
22751
  function buildProcessShim() {
22703
22752
  const real = globalThis.process;
22704
22753
  const shim = /* @__PURE__ */ Object.create(null);
22705
- for (const key of Object.keys(real)) {
22706
- if (DANGEROUS_PROCESS_METHODS.has(String(key))) continue;
22754
+ for (const key2 of Object.keys(real)) {
22755
+ if (DANGEROUS_PROCESS_METHODS.has(String(key2))) continue;
22707
22756
  try {
22708
- shim[key] = real[key];
22757
+ shim[key2] = real[key2];
22709
22758
  } catch {
22710
22759
  }
22711
22760
  }
@@ -23510,10 +23559,10 @@ var GitWorkspaceMonitor = class {
23510
23559
  const compactSummary = createGitCompactSummary(status, diffSummary);
23511
23560
  const timestamp = this.now();
23512
23561
  const seq = ++this.seq;
23513
- const key = this.keyForWorkspace(normalized.workspace);
23562
+ const key2 = this.keyForWorkspace(normalized.workspace);
23514
23563
  const update = {
23515
23564
  topic: "workspace.git",
23516
- key,
23565
+ key: key2,
23517
23566
  workspace: normalized.workspace,
23518
23567
  status,
23519
23568
  diffSummary,
@@ -23521,7 +23570,7 @@ var GitWorkspaceMonitor = class {
23521
23570
  timestamp
23522
23571
  };
23523
23572
  const cacheEntry = {
23524
- key,
23573
+ key: key2,
23525
23574
  workspace: normalized.workspace,
23526
23575
  status,
23527
23576
  diffSummary,
@@ -23665,11 +23714,11 @@ function validateRepoPath(args) {
23665
23714
  }
23666
23715
  return { path: args.path.trim() };
23667
23716
  }
23668
- function validateSnapshotId(args, key) {
23669
- if (typeof args?.[key] !== "string" || !args[key].trim()) {
23670
- return failure("invalid_args", `${key} must be a non-empty string`);
23717
+ function validateSnapshotId(args, key2) {
23718
+ if (typeof args?.[key2] !== "string" || !args[key2].trim()) {
23719
+ return failure("invalid_args", `${key2} must be a non-empty string`);
23671
23720
  }
23672
- return args[key].trim();
23721
+ return args[key2].trim();
23673
23722
  }
23674
23723
  function parseSnapshotReason(args) {
23675
23724
  if (args?.reason === void 0 || args?.reason === null || args?.reason === "") {
@@ -26081,10 +26130,10 @@ var StatusMonitor = class {
26081
26130
  return events;
26082
26131
  }
26083
26132
  /** Cooldown check — prevent sending the same notification too frequently */
26084
- shouldAlert(key, now) {
26085
- const last = this.lastAlertTime.get(key) || 0;
26133
+ shouldAlert(key2, now) {
26134
+ const last = this.lastAlertTime.get(key2) || 0;
26086
26135
  if (now - last > this.config.alertCooldownSec * 1e3) {
26087
- this.lastAlertTime.set(key, now);
26136
+ this.lastAlertTime.set(key2, now);
26088
26137
  return true;
26089
26138
  }
26090
26139
  return false;
@@ -26132,16 +26181,16 @@ var savedHistoryBackgroundRefresh = /* @__PURE__ */ new Set();
26132
26181
  var savedHistoryRollupInFlight = /* @__PURE__ */ new Set();
26133
26182
  var BOUNDED_TAIL_CACHE_MAX_ENTRIES = 64;
26134
26183
  var boundedTailReadCache = /* @__PURE__ */ new Map();
26135
- function readBoundedTailCache(key, signature) {
26136
- const cached3 = boundedTailReadCache.get(key);
26184
+ function readBoundedTailCache(key2, signature) {
26185
+ const cached3 = boundedTailReadCache.get(key2);
26137
26186
  if (!cached3 || cached3.signature !== signature) return null;
26138
- boundedTailReadCache.delete(key);
26139
- boundedTailReadCache.set(key, cached3);
26187
+ boundedTailReadCache.delete(key2);
26188
+ boundedTailReadCache.set(key2, cached3);
26140
26189
  return cached3.result;
26141
26190
  }
26142
- function writeBoundedTailCache(key, signature, result) {
26143
- boundedTailReadCache.delete(key);
26144
- boundedTailReadCache.set(key, { signature, result });
26191
+ function writeBoundedTailCache(key2, signature, result) {
26192
+ boundedTailReadCache.delete(key2);
26193
+ boundedTailReadCache.set(key2, { signature, result });
26145
26194
  while (boundedTailReadCache.size > BOUNDED_TAIL_CACHE_MAX_ENTRIES) {
26146
26195
  const oldest = boundedTailReadCache.keys().next().value;
26147
26196
  if (oldest === void 0) break;
@@ -26577,21 +26626,21 @@ function shouldScheduleSavedHistoryRollupForSignature(signature) {
26577
26626
  return shouldScheduleSavedHistoryRollup(size);
26578
26627
  }
26579
26628
  function scheduleSavedHistoryRollup(agentType, historySessionId) {
26580
- const key = `${agentType}:${historySessionId}`;
26581
- if (!historySessionId || savedHistoryRollupInFlight.has(key)) return;
26582
- savedHistoryRollupInFlight.add(key);
26629
+ const key2 = `${agentType}:${historySessionId}`;
26630
+ if (!historySessionId || savedHistoryRollupInFlight.has(key2)) return;
26631
+ savedHistoryRollupInFlight.add(key2);
26583
26632
  setTimeout(() => {
26584
26633
  try {
26585
26634
  new ChatHistoryWriter().compactHistorySession(agentType, historySessionId);
26586
26635
  } finally {
26587
- savedHistoryRollupInFlight.delete(key);
26636
+ savedHistoryRollupInFlight.delete(key2);
26588
26637
  }
26589
26638
  }, 0);
26590
26639
  }
26591
26640
  function scheduleSavedHistoryBackgroundRefresh(agentType, dir) {
26592
- const key = `${agentType}:${dir}`;
26593
- if (savedHistoryBackgroundRefresh.has(key)) return;
26594
- savedHistoryBackgroundRefresh.add(key);
26641
+ const key2 = `${agentType}:${dir}`;
26642
+ if (savedHistoryBackgroundRefresh.has(key2)) return;
26643
+ savedHistoryBackgroundRefresh.add(key2);
26595
26644
  setTimeout(() => {
26596
26645
  try {
26597
26646
  if (!fs6.existsSync(dir)) return;
@@ -26611,7 +26660,7 @@ function scheduleSavedHistoryBackgroundRefresh(agentType, dir) {
26611
26660
  }
26612
26661
  } catch {
26613
26662
  } finally {
26614
- savedHistoryBackgroundRefresh.delete(key);
26663
+ savedHistoryBackgroundRefresh.delete(key2);
26615
26664
  }
26616
26665
  }, 0);
26617
26666
  }
@@ -27377,14 +27426,14 @@ function rewriteCanonicalSavedHistory(agentType, historySessionId, records) {
27377
27426
  return false;
27378
27427
  }
27379
27428
  }
27380
- function getNativeHistoryScriptName(canonicalHistory, key) {
27381
- const configured = canonicalHistory?.scripts?.[key];
27429
+ function getNativeHistoryScriptName(canonicalHistory, key2) {
27430
+ const configured = canonicalHistory?.scripts?.[key2];
27382
27431
  if (typeof configured === "string" && configured.trim()) return configured.trim();
27383
- return key === "readSession" ? "readNativeHistory" : "listNativeHistory";
27432
+ return key2 === "readSession" ? "readNativeHistory" : "listNativeHistory";
27384
27433
  }
27385
- function getProviderNativeHistoryScript(scripts, canonicalHistory, key) {
27434
+ function getProviderNativeHistoryScript(scripts, canonicalHistory, key2) {
27386
27435
  if (!canonicalHistory?.scripts) return null;
27387
- const fn = scripts?.[getNativeHistoryScriptName(canonicalHistory, key)];
27436
+ const fn = scripts?.[getNativeHistoryScriptName(canonicalHistory, key2)];
27388
27437
  return typeof fn === "function" ? fn : null;
27389
27438
  }
27390
27439
  function normalizeProviderNativeHistoryRecords(agentType, historySessionId, records) {
@@ -28118,11 +28167,11 @@ function validateControlValues(controlValues, source) {
28118
28167
  throw new Error(`${source}: controlValues must be an object when provided`);
28119
28168
  }
28120
28169
  const normalized = {};
28121
- for (const [key, value] of Object.entries(controlValues)) {
28170
+ for (const [key2, value] of Object.entries(controlValues)) {
28122
28171
  if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
28123
- throw new Error(`${source}: controlValues.${key} must be string, number, or boolean`);
28172
+ throw new Error(`${source}: controlValues.${key2} must be string, number, or boolean`);
28124
28173
  }
28125
- normalized[key] = value;
28174
+ normalized[key2] = value;
28126
28175
  }
28127
28176
  return normalized;
28128
28177
  }
@@ -28875,7 +28924,7 @@ var DaemonCdpScanner = class {
28875
28924
  for (const [ide, ports] of Object.entries(portMap)) {
28876
28925
  const primaryPort = ports[0];
28877
28926
  const alreadyConnected = [...this.ctx.cdpManagers.entries()].some(
28878
- ([key, m]) => m.isConnected && (key === ide || key.startsWith(ide + "_"))
28927
+ ([key2, m]) => m.isConnected && (key2 === ide || key2.startsWith(ide + "_"))
28879
28928
  );
28880
28929
  if (alreadyConnected) continue;
28881
28930
  if (this.opts.multiWindow) {
@@ -29049,8 +29098,8 @@ var DaemonCdpInitializer = class {
29049
29098
  for (let i = 0; i < targets.length; i++) {
29050
29099
  const target = targets[i];
29051
29100
  let alreadyTracked = false;
29052
- for (const [key, m] of cdpManagers.entries()) {
29053
- if ((key === ide || key.startsWith(`${ide}_`)) && m.targetId === target.id) {
29101
+ for (const [key2, m] of cdpManagers.entries()) {
29102
+ if ((key2 === ide || key2.startsWith(`${ide}_`)) && m.targetId === target.id) {
29054
29103
  alreadyTracked = true;
29055
29104
  break;
29056
29105
  }
@@ -29082,29 +29131,29 @@ var DaemonCdpInitializer = class {
29082
29131
  async pruneStaleManagers(port, ide, targets) {
29083
29132
  const trackedTargetIds = new Set(targets.map((target) => target.id));
29084
29133
  const removals = [];
29085
- for (const [key, manager] of this.config.cdpManagers.entries()) {
29086
- if (!(key === ide || key.startsWith(`${ide}_`))) continue;
29134
+ for (const [key2, manager] of this.config.cdpManagers.entries()) {
29135
+ if (!(key2 === ide || key2.startsWith(`${ide}_`))) continue;
29087
29136
  if (manager.getPort() !== port) continue;
29088
29137
  if (targets.length === 0) {
29089
- removals.push({ key, manager, reason: "ide_closed" });
29138
+ removals.push({ key: key2, manager, reason: "ide_closed" });
29090
29139
  continue;
29091
29140
  }
29092
29141
  if (manager.targetId && !trackedTargetIds.has(manager.targetId)) {
29093
- removals.push({ key, manager, reason: "target_closed" });
29142
+ removals.push({ key: key2, manager, reason: "target_closed" });
29094
29143
  continue;
29095
29144
  }
29096
- if (key === ide && !manager.targetId && targets.length > 1) {
29097
- removals.push({ key, manager, reason: "target_rekeyed" });
29145
+ if (key2 === ide && !manager.targetId && targets.length > 1) {
29146
+ removals.push({ key: key2, manager, reason: "target_rekeyed" });
29098
29147
  }
29099
29148
  }
29100
- for (const { key, manager, reason } of removals) {
29149
+ for (const { key: key2, manager, reason } of removals) {
29101
29150
  try {
29102
29151
  manager.disconnect();
29103
29152
  } catch {
29104
29153
  }
29105
- this.config.cdpManagers.delete(key);
29106
- LOG.info("IDE", `Detached window: ${key} (${reason})`);
29107
- await this.config.onDisconnected?.(ide, manager, key, reason);
29154
+ this.config.cdpManagers.delete(key2);
29155
+ LOG.info("IDE", `Detached window: ${key2} (${reason})`);
29156
+ await this.config.onDisconnected?.(ide, manager, key2, reason);
29108
29157
  }
29109
29158
  }
29110
29159
  // ─── Periodic scanning ───
@@ -29430,7 +29479,7 @@ function sanitizeTraceValue(value, traceContent) {
29430
29479
  if (Array.isArray(value)) return value.map((entry) => sanitizeTraceValue(entry, traceContent));
29431
29480
  if (value && typeof value === "object") {
29432
29481
  return Object.fromEntries(
29433
- Object.entries(value).map(([key, nested]) => [key, sanitizeTraceValue(nested, traceContent)])
29482
+ Object.entries(value).map(([key2, nested]) => [key2, sanitizeTraceValue(nested, traceContent)])
29434
29483
  );
29435
29484
  }
29436
29485
  return value;
@@ -29439,7 +29488,7 @@ function sanitizeTraceValue(value, traceContent) {
29439
29488
  if (Array.isArray(value)) return value.map((entry) => sanitizeTraceValue(entry, traceContent));
29440
29489
  if (value && typeof value === "object") {
29441
29490
  return Object.fromEntries(
29442
- Object.entries(value).map(([key, nested]) => [key, sanitizeTraceValue(nested, traceContent)])
29491
+ Object.entries(value).map(([key2, nested]) => [key2, sanitizeTraceValue(nested, traceContent)])
29443
29492
  );
29444
29493
  }
29445
29494
  return value;
@@ -29747,8 +29796,8 @@ function maxSequence(messages) {
29747
29796
  }
29748
29797
  function isSupersetOf(candidate, required) {
29749
29798
  if (required.size === 0) return true;
29750
- for (const key of required) {
29751
- if (!candidate.has(key)) return false;
29799
+ for (const key2 of required) {
29800
+ if (!candidate.has(key2)) return false;
29752
29801
  }
29753
29802
  return true;
29754
29803
  }
@@ -29761,17 +29810,17 @@ function chatSourceSessionKey(providerType, sessionId) {
29761
29810
  var ChatSourceRegistry = class {
29762
29811
  records = /* @__PURE__ */ new Map();
29763
29812
  /** Snapshot of current state for diagnostics. Does not mutate. */
29764
- getState(key) {
29765
- return this.records.get(key)?.state ?? INITIAL_CHAT_SOURCE_STATE;
29813
+ getState(key2) {
29814
+ return this.records.get(key2)?.state ?? INITIAL_CHAT_SOURCE_STATE;
29766
29815
  }
29767
29816
  /** Recent transitions, newest last. Empty array when nothing has happened. */
29768
- getTransitions(key) {
29769
- return this.records.get(key)?.transitions ?? [];
29817
+ getTransitions(key2) {
29818
+ return this.records.get(key2)?.transitions ?? [];
29770
29819
  }
29771
29820
  /** Drop a session. Caller should invoke this when the session is destroyed
29772
29821
  * to avoid unbounded growth across long-lived daemons. */
29773
- clear(key) {
29774
- this.records.delete(key);
29822
+ clear(key2) {
29823
+ this.records.delete(key2);
29775
29824
  }
29776
29825
  /** Drop all sessions. Test helper. */
29777
29826
  clearAll() {
@@ -29783,15 +29832,15 @@ var ChatSourceRegistry = class {
29783
29832
  * under `key`; callers may treat the decision as authoritative without
29784
29833
  * re-reading.
29785
29834
  */
29786
- observe(key, observation, at = Date.now()) {
29787
- const prev = this.records.get(key);
29835
+ observe(key2, observation, at = Date.now()) {
29836
+ const prev = this.records.get(key2);
29788
29837
  const prevState = prev?.state ?? INITIAL_CHAT_SOURCE_STATE;
29789
29838
  const prevLockedSince = prev?.lockedSince;
29790
29839
  const result = transitionChatSourceState(prevState, observation, at, prevLockedSince);
29791
29840
  const transitions = prev?.transitions ?? [];
29792
29841
  const nextTransitions = appendTransition(transitions, result.transition);
29793
29842
  const lockedSince = result.lockState.lockedSince;
29794
- this.records.set(key, {
29843
+ this.records.set(key2, {
29795
29844
  state: result.next,
29796
29845
  lockedSince,
29797
29846
  transitions: nextTransitions
@@ -30474,8 +30523,8 @@ function readLiveCodexWorkspaceNativeHistory(agentStr, args) {
30474
30523
  });
30475
30524
  return { ...history, lookup: "workspace" };
30476
30525
  }
30477
- function shouldPreserveReadChatPayloadField(key) {
30478
- return key === "messageSource" || key === "transcriptProvenance";
30526
+ function shouldPreserveReadChatPayloadField(key2) {
30527
+ return key2 === "messageSource" || key2 === "transcriptProvenance";
30479
30528
  }
30480
30529
  function updateMessageSourceReturnedCount(value, returnedMessageCount) {
30481
30530
  if (!value || typeof value !== "object" || Array.isArray(value)) return value;
@@ -30645,7 +30694,7 @@ function buildReadChatCommandResult(payload, args, h) {
30645
30694
  const visibleMessages = includeActivity ? filteredMessages.filter((m) => isUserFacingChatMessage(m) || isActivityChatMessage(m)) : filterUserFacingChatMessages(filteredMessages);
30646
30695
  const sync = buildFullTail(visibleMessages, normalizeReadChatTailLimit(args));
30647
30696
  const hiddenMsgCount = Math.max(0, messages.length - visibleMessages.length);
30648
- const preservedPayloadFields = Object.fromEntries(Object.entries(payload).filter(([key]) => shouldPreserveReadChatPayloadField(key)));
30697
+ const preservedPayloadFields = Object.fromEntries(Object.entries(payload).filter(([key2]) => shouldPreserveReadChatPayloadField(key2)));
30649
30698
  if (preservedPayloadFields.messageSource) {
30650
30699
  preservedPayloadFields.messageSource = updateMessageSourceReturnedCount(preservedPayloadFields.messageSource, sync.messages.length);
30651
30700
  }
@@ -31397,8 +31446,8 @@ function sanitizeDebugBundleValue(value, options = {}, depth = 0, keyHint = "")
31397
31446
  const record = value;
31398
31447
  const result = {};
31399
31448
  const entries = Object.entries(record).slice(0, normalizedOptions.maxObjectKeys);
31400
- for (const [key, item] of entries) {
31401
- result[key] = sanitizeDebugBundleValue(item, normalizedOptions, depth + 1, key);
31449
+ for (const [key2, item] of entries) {
31450
+ result[key2] = sanitizeDebugBundleValue(item, normalizedOptions, depth + 1, key2);
31402
31451
  }
31403
31452
  const remaining = Object.keys(record).length - entries.length;
31404
31453
  if (remaining > 0) result.__truncatedKeys = remaining;
@@ -31724,14 +31773,14 @@ function callLegacyTextScript(script, text) {
31724
31773
  if (typeof script !== "function") return null;
31725
31774
  return script(text);
31726
31775
  }
31727
- function isRecentDuplicateSend(key) {
31776
+ function isRecentDuplicateSend(key2) {
31728
31777
  const now = Date.now();
31729
31778
  for (const [candidate, ts2] of recentSendByTarget.entries()) {
31730
31779
  if (now - ts2 > RECENT_SEND_WINDOW_MS) recentSendByTarget.delete(candidate);
31731
31780
  }
31732
- const previous = recentSendByTarget.get(key);
31781
+ const previous = recentSendByTarget.get(key2);
31733
31782
  if (previous && now - previous <= RECENT_SEND_WINDOW_MS) return true;
31734
- recentSendByTarget.set(key, now);
31783
+ recentSendByTarget.set(key2, now);
31735
31784
  return false;
31736
31785
  }
31737
31786
  function didProviderConfirmSend(result) {
@@ -32594,23 +32643,23 @@ async function handleCdpRemoteAction(h, args) {
32594
32643
  try {
32595
32644
  switch (action) {
32596
32645
  case "input_key": {
32597
- const { type: evType, key, code, text, unmodifiedText, modifiers } = params;
32646
+ const { type: evType, key: key2, code, text, unmodifiedText, modifiers } = params;
32598
32647
  const mod = typeof modifiers === "number" ? modifiers : 0;
32599
- const vk = KEY_TO_VK[key] || (key.length === 1 ? key.charCodeAt(0) : 0);
32648
+ const vk = KEY_TO_VK[key2] || (key2.length === 1 ? key2.charCodeAt(0) : 0);
32600
32649
  if (evType === "char") {
32601
32650
  await h.getCdp().send("Input.dispatchKeyEvent", {
32602
32651
  type: "char",
32603
- key,
32652
+ key: key2,
32604
32653
  code,
32605
- text: text || key,
32606
- unmodifiedText: unmodifiedText || text || key,
32654
+ text: text || key2,
32655
+ unmodifiedText: unmodifiedText || text || key2,
32607
32656
  ...vk ? { windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk } : {},
32608
32657
  ...mod ? { modifiers: mod } : {}
32609
32658
  });
32610
32659
  } else {
32611
32660
  await h.getCdp().send("Input.dispatchKeyEvent", {
32612
32661
  type: "rawKeyDown",
32613
- key,
32662
+ key: key2,
32614
32663
  code,
32615
32664
  ...text ? { text } : {},
32616
32665
  ...vk ? { windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk } : {},
@@ -32618,7 +32667,7 @@ async function handleCdpRemoteAction(h, args) {
32618
32667
  });
32619
32668
  await h.getCdp().send("Input.dispatchKeyEvent", {
32620
32669
  type: "keyUp",
32621
- key,
32670
+ key: key2,
32622
32671
  code,
32623
32672
  ...vk ? { windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk } : {},
32624
32673
  ...mod ? { modifiers: mod } : {}
@@ -33017,21 +33066,21 @@ function handleGetProviderSettings(h, args) {
33017
33066
  }
33018
33067
  async function handleSetProviderSetting(h, args) {
33019
33068
  const loader = h.ctx.providerLoader;
33020
- const { providerType, key, value } = args || {};
33021
- if (!providerType || !key || value === void 0) {
33069
+ const { providerType, key: key2, value } = args || {};
33070
+ if (!providerType || !key2 || value === void 0) {
33022
33071
  return { success: false, error: "providerType, key, and value are required" };
33023
33072
  }
33024
- const result = loader?.setSetting(providerType, key, value);
33073
+ const result = loader?.setSetting(providerType, key2, value);
33025
33074
  if (result) {
33026
33075
  if (h.ctx.instanceManager) {
33027
33076
  const allSettings = loader?.getSettings(providerType) || {};
33028
33077
  const updated = h.ctx.instanceManager.updateInstanceSettings(providerType, allSettings);
33029
- LOG.info("Command", `[set_provider_setting] ${providerType}.${key}=${JSON.stringify(value)} \u2192 ${updated} instance(s) updated`);
33078
+ LOG.info("Command", `[set_provider_setting] ${providerType}.${key2}=${JSON.stringify(value)} \u2192 ${updated} instance(s) updated`);
33030
33079
  }
33031
- await h.ctx.onProviderSettingChanged?.(providerType, key, value);
33032
- return { success: true, providerType, key, value };
33080
+ await h.ctx.onProviderSettingChanged?.(providerType, key2, value);
33081
+ return { success: true, providerType, key: key2, value };
33033
33082
  }
33034
- return { success: false, error: `Failed to set ${providerType}.${key} \u2014 invalid key, value, or not a public setting` };
33083
+ return { success: false, error: `Failed to set ${providerType}.${key2} \u2014 invalid key, value, or not a public setting` };
33035
33084
  }
33036
33085
  function handleGetProviderSourceConfig(h, _args) {
33037
33086
  const loader = h.ctx.providerLoader;
@@ -33077,9 +33126,9 @@ function normalizeProviderScriptArgs(args, scriptName) {
33077
33126
  normalizedArgs.mode = normalizedArgs.value;
33078
33127
  }
33079
33128
  }
33080
- for (const key of ["mode", "model", "message", "action", "button", "text", "sessionId", "value"]) {
33081
- if (key in normalizedArgs && !(key.toUpperCase() in normalizedArgs)) {
33082
- normalizedArgs[key.toUpperCase()] = normalizedArgs[key];
33129
+ for (const key2 of ["mode", "model", "message", "action", "button", "text", "sessionId", "value"]) {
33130
+ if (key2 in normalizedArgs && !(key2.toUpperCase() in normalizedArgs)) {
33131
+ normalizedArgs[key2.toUpperCase()] = normalizedArgs[key2];
33083
33132
  }
33084
33133
  }
33085
33134
  return normalizedArgs;
@@ -33479,10 +33528,10 @@ function summarizeCommandArgs(args) {
33479
33528
  "value"
33480
33529
  ];
33481
33530
  const entries = [];
33482
- for (const key of preferredKeys) {
33483
- if (!(key in args) || args[key] === void 0) continue;
33484
- const value = key === "text" || key === "message" ? `${String(args[key] || "").length} chars` : key === "data" ? `${String(args[key] || "").length} chars` : summarizeLogValue(args[key]);
33485
- entries.push(`${key}=${value}`);
33531
+ for (const key2 of preferredKeys) {
33532
+ if (!(key2 in args) || args[key2] === void 0) continue;
33533
+ const value = key2 === "text" || key2 === "message" ? `${String(args[key2] || "").length} chars` : key2 === "data" ? `${String(args[key2] || "").length} chars` : summarizeLogValue(args[key2]);
33534
+ entries.push(`${key2}=${value}`);
33486
33535
  }
33487
33536
  return entries.length ? entries.join(" ") : "{...}";
33488
33537
  }
@@ -33534,12 +33583,12 @@ var DaemonCommandHandler = class {
33534
33583
  * Get provider module — _currentProviderType (agentType priority) use.
33535
33584
  */
33536
33585
  getProvider(overrideType) {
33537
- const key = overrideType || this._currentRoute.providerType || this._currentRoute.session?.providerType || this._currentRoute.managerKey;
33538
- if (!key || !this._ctx.providerLoader) return void 0;
33539
- const result = this._ctx.providerLoader.resolve(key);
33586
+ const key2 = overrideType || this._currentRoute.providerType || this._currentRoute.session?.providerType || this._currentRoute.managerKey;
33587
+ if (!key2 || !this._ctx.providerLoader) return void 0;
33588
+ const result = this._ctx.providerLoader.resolve(key2);
33540
33589
  if (result) return result;
33541
- const baseType = key.split("_")[0];
33542
- if (baseType !== key) return this._ctx.providerLoader.resolve(baseType);
33590
+ const baseType = key2.split("_")[0];
33591
+ if (baseType !== key2) return this._ctx.providerLoader.resolve(baseType);
33543
33592
  return void 0;
33544
33593
  }
33545
33594
  /** Get a provider script by name from ProviderLoader. */
@@ -33597,11 +33646,11 @@ var DaemonCommandHandler = class {
33597
33646
  return this._ctx.adapters.get(target) || null;
33598
33647
  }
33599
33648
  // ─── Private helpers ──────────────────────────────
33600
- inferProviderType(key) {
33601
- if (!key) return void 0;
33602
- const session = this._ctx.sessionRegistry?.get(key);
33649
+ inferProviderType(key2) {
33650
+ if (!key2) return void 0;
33651
+ const session = this._ctx.sessionRegistry?.get(key2);
33603
33652
  if (session?.providerType) return session.providerType;
33604
- return key.split("_")[0];
33653
+ return key2.split("_")[0];
33605
33654
  }
33606
33655
  resolveRoute(args) {
33607
33656
  const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
@@ -35299,16 +35348,16 @@ var coordinatorPromptHandlers = {
35299
35348
  const m = matchAppend || matchOverride;
35300
35349
  if (!m) continue;
35301
35350
  const isAppend = !!matchAppend;
35302
- const key = m[1];
35351
+ const key2 = m[1];
35303
35352
  const full = path43.join(dir, name);
35304
35353
  let content = "";
35305
35354
  try {
35306
35355
  content = fs38.readFileSync(full, "utf8");
35307
35356
  } catch {
35308
35357
  }
35309
- if (!entries[key]) entries[key] = { override: "", append: "" };
35310
- if (isAppend) entries[key].append = content;
35311
- else entries[key].override = content;
35358
+ if (!entries[key2]) entries[key2] = { override: "", append: "" };
35359
+ if (isAppend) entries[key2].append = content;
35360
+ else entries[key2].override = content;
35312
35361
  }
35313
35362
  }
35314
35363
  } catch (error) {
@@ -35320,14 +35369,14 @@ var coordinatorPromptHandlers = {
35320
35369
  const fs38 = await import("fs");
35321
35370
  const path43 = await import("path");
35322
35371
  const os30 = await import("os");
35323
- const key = typeof args?.key === "string" ? args.key.trim() : "";
35372
+ const key2 = typeof args?.key === "string" ? args.key.trim() : "";
35324
35373
  const kind = args?.kind === "append" ? "append" : "override";
35325
35374
  const content = typeof args?.content === "string" ? args.content : "";
35326
- if (!key || !/^[a-zA-Z0-9_.-]+$/.test(key)) {
35375
+ if (!key2 || !/^[a-zA-Z0-9_.-]+$/.test(key2)) {
35327
35376
  return { success: false, error: "key must match [a-zA-Z0-9_.-]+" };
35328
35377
  }
35329
35378
  const dir = path43.join(os30.homedir(), ".adhdev", "coordinator-prompts");
35330
- const filename = kind === "append" ? `${key}.append.md` : `${key}.md`;
35379
+ const filename = kind === "append" ? `${key2}.append.md` : `${key2}.md`;
35331
35380
  const full = path43.join(dir, filename);
35332
35381
  try {
35333
35382
  fs38.mkdirSync(dir, { recursive: true });
@@ -35336,7 +35385,7 @@ var coordinatorPromptHandlers = {
35336
35385
  } else if (fs38.existsSync(full)) {
35337
35386
  fs38.unlinkSync(full);
35338
35387
  }
35339
- return { success: true, path: full, kind, key };
35388
+ return { success: true, path: full, kind, key: key2 };
35340
35389
  } catch (error) {
35341
35390
  return { success: false, error: error?.message || String(error) };
35342
35391
  }
@@ -36281,7 +36330,7 @@ var RULES = [
36281
36330
  {
36282
36331
  name: "key_value_secret",
36283
36332
  pattern: /\b([A-Z0-9_]*(?:SECRET|TOKEN|API[_-]?KEY|PASSWORD|PASSWD|PRIVATE[_-]?KEY|CREDENTIAL|CLIENT[_-]?SECRET)[A-Z0-9_]*)(\s*[:=]\s*)(["']?)([^\s"',;]+)\3/gi,
36284
- replace: (_m, key, delim, quote) => `${key}${delim}${quote}${MASK}${quote}`
36333
+ replace: (_m, key2, delim, quote) => `${key2}${delim}${quote}${MASK}${quote}`
36285
36334
  },
36286
36335
  // Authorization: Bearer <token>
36287
36336
  {
@@ -36631,7 +36680,7 @@ function realWorkspacePath(workingDir) {
36631
36680
  }
36632
36681
  function applyPreLaunchTrust(trust, workingDir) {
36633
36682
  const settingsPath = expandHome2(trust.settings_path);
36634
- const key = trust.key;
36683
+ const key2 = trust.key;
36635
36684
  const real = realWorkspacePath(workingDir);
36636
36685
  try {
36637
36686
  let parsed = {};
@@ -36644,18 +36693,18 @@ function applyPreLaunchTrust(trust, workingDir) {
36644
36693
  }
36645
36694
  }
36646
36695
  }
36647
- const existing = parsed[key];
36696
+ const existing = parsed[key2];
36648
36697
  const list = Array.isArray(existing) ? existing.filter((v) => typeof v === "string") : [];
36649
36698
  if (list.includes(real)) {
36650
36699
  LOG.debug("pre-launch-trust", `[${trust.settings_path}] ${real} already trusted \u2014 no change`);
36651
36700
  return null;
36652
36701
  }
36653
36702
  list.push(real);
36654
- parsed[key] = list;
36703
+ parsed[key2] = list;
36655
36704
  fs14.mkdirSync(path22.dirname(settingsPath), { recursive: true });
36656
36705
  fs14.writeFileSync(settingsPath, `${JSON.stringify(parsed, null, 2)}
36657
36706
  `, "utf8");
36658
- LOG.info("pre-launch-trust", `pre-trusted workspace in ${trust.settings_path} (key="${key}")`);
36707
+ LOG.info("pre-launch-trust", `pre-trusted workspace in ${trust.settings_path} (key="${key2}")`);
36659
36708
  return real;
36660
36709
  } catch (err) {
36661
36710
  LOG.warn("pre-launch-trust", `failed to pre-trust workspace in ${trust.settings_path}: ${err.message}`);
@@ -38266,8 +38315,8 @@ function jsonPathGet(record, expr) {
38266
38315
  }
38267
38316
  let end = i;
38268
38317
  while (end < expr.length && expr[end] !== "." && expr[end] !== "[") end += 1;
38269
- const key = expr.slice(i, end);
38270
- cur = cur[key];
38318
+ const key2 = expr.slice(i, end);
38319
+ cur = cur[key2];
38271
38320
  i = end;
38272
38321
  }
38273
38322
  return cur;
@@ -40242,8 +40291,8 @@ var CliProviderInstance = class _CliProviderInstance {
40242
40291
  /** Drop user-input ack entries older than the dedup window so the map can't grow unbounded. */
40243
40292
  pruneRecentUserInputAcks(now) {
40244
40293
  if (this.recentUserInputAcks.size <= 1) return;
40245
- for (const [key, at] of this.recentUserInputAcks) {
40246
- if (now - at > USER_INPUT_ACK_DEDUP_WINDOW_MS) this.recentUserInputAcks.delete(key);
40294
+ for (const [key2, at] of this.recentUserInputAcks) {
40295
+ if (now - at > USER_INPUT_ACK_DEDUP_WINDOW_MS) this.recentUserInputAcks.delete(key2);
40247
40296
  }
40248
40297
  }
40249
40298
  dispose() {
@@ -41447,8 +41496,8 @@ ${effect.notification.body || ""}`.trim();
41447
41496
  };
41448
41497
  const isRuntimeOverlay = (entry) => {
41449
41498
  if (entry.source !== "runtime") return false;
41450
- const key = typeof entry.runtimeKey === "string" ? entry.runtimeKey.trim().toLowerCase() : "";
41451
- if (key.startsWith("auto_approval:")) return true;
41499
+ const key2 = typeof entry.runtimeKey === "string" ? entry.runtimeKey.trim().toLowerCase() : "";
41500
+ if (key2.startsWith("auto_approval:")) return true;
41452
41501
  return !isUserFacingChatMessage(entry.message);
41453
41502
  };
41454
41503
  const shouldKeepParsedBeforeUntimedRuntime = (message) => {
@@ -43058,16 +43107,16 @@ var DEFAULT_COORDINATOR_DELEGATED_ENV_UNSETS = [
43058
43107
  function hasCliArg(args, flag) {
43059
43108
  return args.some((arg) => arg === flag || arg.startsWith(`${flag}=`));
43060
43109
  }
43061
- function hasConfigOverride(args, key) {
43110
+ function hasConfigOverride(args, key2) {
43062
43111
  for (let index = 0; index < args.length; index += 1) {
43063
43112
  const arg = args[index];
43064
43113
  const next = args[index + 1];
43065
43114
  if ((arg === "-c" || arg === "--config") && typeof next === "string") {
43066
- if (next === key || next.startsWith(`${key}=`) || next.startsWith(`${key}.`)) return true;
43115
+ if (next === key2 || next.startsWith(`${key2}=`) || next.startsWith(`${key2}.`)) return true;
43067
43116
  }
43068
43117
  if (arg.startsWith("--config=")) {
43069
43118
  const value = arg.slice("--config=".length);
43070
- if (value === key || value.startsWith(`${key}=`) || value.startsWith(`${key}.`)) return true;
43119
+ if (value === key2 || value.startsWith(`${key2}=`) || value.startsWith(`${key2}.`)) return true;
43071
43120
  }
43072
43121
  }
43073
43122
  return false;
@@ -43084,10 +43133,10 @@ function buildCoordinatorDelegatedCliLaunchOptions(input) {
43084
43133
  const cliArgs = Array.isArray(input.cliArgs) ? [...input.cliArgs] : [];
43085
43134
  const env = { ...input.env || {} };
43086
43135
  const envUnsets = new Set(DEFAULT_COORDINATOR_DELEGATED_ENV_UNSETS);
43087
- for (const key of input.isolation?.env?.unset || []) {
43088
- if (typeof key === "string" && key.trim()) envUnsets.add(key.trim());
43136
+ for (const key2 of input.isolation?.env?.unset || []) {
43137
+ if (typeof key2 === "string" && key2.trim()) envUnsets.add(key2.trim());
43089
43138
  }
43090
- for (const key of envUnsets) env[key] = "";
43139
+ for (const key2 of envUnsets) env[key2] = "";
43091
43140
  for (const rule of input.isolation?.args || []) {
43092
43141
  if (!rule || typeof rule !== "object") continue;
43093
43142
  if (rule.mode === "empty_mcp_config") {
@@ -43100,9 +43149,9 @@ function buildCoordinatorDelegatedCliLaunchOptions(input) {
43100
43149
  continue;
43101
43150
  }
43102
43151
  if (rule.mode === "config_override") {
43103
- const key = String(rule.dedupeKey || rule.key || "").trim();
43152
+ const key2 = String(rule.dedupeKey || rule.key || "").trim();
43104
43153
  const flag = String(rule.flag || "").trim();
43105
- if (!key || !flag || hasConfigOverride(cliArgs, key)) continue;
43154
+ if (!key2 || !flag || hasConfigOverride(cliArgs, key2)) continue;
43106
43155
  cliArgs.unshift(flag, `${rule.key}=${rule.value}`);
43107
43156
  }
43108
43157
  }
@@ -43308,12 +43357,12 @@ var DaemonCliManager = class {
43308
43357
  }
43309
43358
  throw new Error(`No CLI provider found for '${cliType}'. Create a provider.js in providers/cli/${cliType}/`);
43310
43359
  }
43311
- startCliExitMonitor(key, cliType) {
43360
+ startCliExitMonitor(key2, cliType) {
43312
43361
  const sessionRegistry = this.deps.getSessionRegistry?.() || null;
43313
43362
  const instanceManager = this.deps.getInstanceManager();
43314
43363
  const checkStopped = setInterval(() => {
43315
43364
  try {
43316
- const adapter = this.adapters.get(key);
43365
+ const adapter = this.adapters.get(key2);
43317
43366
  if (!adapter) {
43318
43367
  clearInterval(checkStopped);
43319
43368
  return;
@@ -43322,12 +43371,12 @@ var DaemonCliManager = class {
43322
43371
  if (status?.status === "stopped" || status?.status === "error") {
43323
43372
  clearInterval(checkStopped);
43324
43373
  setTimeout(() => {
43325
- if (this.adapters.has(key)) {
43326
- this.adapters.delete(key);
43327
- this.deps.removeAgentTracking(key);
43328
- sessionRegistry?.unregisterByInstanceKey(key);
43329
- instanceManager?.removeInstance(key);
43330
- unregisterMeshCoordinator(key);
43374
+ if (this.adapters.has(key2)) {
43375
+ this.adapters.delete(key2);
43376
+ this.deps.removeAgentTracking(key2);
43377
+ sessionRegistry?.unregisterByInstanceKey(key2);
43378
+ instanceManager?.removeInstance(key2);
43379
+ unregisterMeshCoordinator(key2);
43331
43380
  LOG.info("CLI", `\u{1F9F9} Auto-cleaned ${status.status} CLI: ${cliType}`);
43332
43381
  this.deps.onStatusChange();
43333
43382
  }
@@ -43337,21 +43386,21 @@ var DaemonCliManager = class {
43337
43386
  }
43338
43387
  }, 3e3);
43339
43388
  }
43340
- async registerCliInstance(key, normalizedType, cliType, resolvedDir, cliArgs, provider, settings, attachExisting = false, options) {
43389
+ async registerCliInstance(key2, normalizedType, cliType, resolvedDir, cliArgs, provider, settings, attachExisting = false, options) {
43341
43390
  const instanceManager = this.deps.getInstanceManager();
43342
43391
  const sessionRegistry = this.deps.getSessionRegistry?.() || null;
43343
43392
  if (!instanceManager) throw new Error("InstanceManager not available");
43344
43393
  const transportFactory = this.getTransportFactory(
43345
- key,
43394
+ key2,
43346
43395
  normalizedType,
43347
43396
  resolvedDir,
43348
43397
  cliArgs,
43349
43398
  options?.providerSessionId,
43350
43399
  attachExisting
43351
43400
  );
43352
- const cliInstance = new CliProviderInstance(provider, resolvedDir, cliArgs, key, transportFactory, options);
43401
+ const cliInstance = new CliProviderInstance(provider, resolvedDir, cliArgs, key2, transportFactory, options);
43353
43402
  try {
43354
- await instanceManager.addInstance(key, cliInstance, {
43403
+ await instanceManager.addInstance(key2, cliInstance, {
43355
43404
  serverConn: this.deps.getServerConn(),
43356
43405
  settings,
43357
43406
  onPtyData: (data) => {
@@ -43363,8 +43412,8 @@ var DaemonCliManager = class {
43363
43412
  parentSessionId: null,
43364
43413
  providerType: normalizedType,
43365
43414
  transport: "pty",
43366
- adapterKey: key,
43367
- instanceKey: key,
43415
+ adapterKey: key2,
43416
+ instanceKey: key2,
43368
43417
  workspace: resolvedDir,
43369
43418
  // attachExisting === true means we're restoring an already-spawned
43370
43419
  // hosted runtime after a daemon restart, not starting a fresh PTY.
@@ -43380,10 +43429,10 @@ var DaemonCliManager = class {
43380
43429
  });
43381
43430
  } catch (spawnErr) {
43382
43431
  LOG.error("CLI", `[${cliType}] Spawn failed: ${spawnErr?.message}`);
43383
- instanceManager.removeInstance(key);
43432
+ instanceManager.removeInstance(key2);
43384
43433
  throw new Error(`Failed to start ${provider.displayName || provider.name || cliType}: ${spawnErr?.message}`);
43385
43434
  }
43386
- this.adapters.set(key, cliInstance.getAdapter());
43435
+ this.adapters.set(key2, cliInstance.getAdapter());
43387
43436
  const launchMeshNodeId = typeof settings?.meshNodeId === "string" ? settings.meshNodeId.trim() : "";
43388
43437
  const launchMeshNodeFor = typeof settings?.meshNodeFor === "string" ? settings.meshNodeFor.trim() : "";
43389
43438
  if (launchMeshNodeId || launchMeshNodeFor) {
@@ -43396,7 +43445,7 @@ var DaemonCliManager = class {
43396
43445
  } catch {
43397
43446
  }
43398
43447
  }
43399
- this.startCliExitMonitor(key, cliType);
43448
+ this.startCliExitMonitor(key2, cliType);
43400
43449
  }
43401
43450
  // ─── Session start/management ──────────────────────────────
43402
43451
  async startSession(cliType, workingDir, cliArgs, initialModel, options) {
@@ -43413,11 +43462,11 @@ var DaemonCliManager = class {
43413
43462
  Enable and detect this provider from the Machine Providers page before starting a runtime.`
43414
43463
  );
43415
43464
  }
43416
- const key = crypto5.randomUUID();
43465
+ const key2 = crypto5.randomUUID();
43417
43466
  {
43418
43467
  const coordinatorMeshId = options?.settingsOverride?.meshCoordinatorFor;
43419
43468
  if (typeof coordinatorMeshId === "string" && coordinatorMeshId.trim()) {
43420
- options = { ...options, extraEnv: { ...options?.extraEnv || {}, ADHDEV_COORDINATOR_SESSION_ID: key } };
43469
+ options = { ...options, extraEnv: { ...options?.extraEnv || {}, ADHDEV_COORDINATOR_SESSION_ID: key2 } };
43421
43470
  }
43422
43471
  }
43423
43472
  const sessionRegistry = this.deps.getSessionRegistry?.() || null;
@@ -43437,7 +43486,7 @@ ${installInfo}`
43437
43486
  }
43438
43487
  console.log(colorize("cyan", ` \u{1F50C} Starting ACP agent: ${provider.name} (${provider.type}) in ${resolvedDir}`));
43439
43488
  const acpInstance = new AcpProviderInstance(resolvedProvider, resolvedDir, cliArgs);
43440
- await instanceManager2.addInstance(key, acpInstance, {
43489
+ await instanceManager2.addInstance(key2, acpInstance, {
43441
43490
  settings: this.providerLoader.getSettings(normalizedType)
43442
43491
  });
43443
43492
  const sessionId = acpInstance.getInstanceId();
@@ -43446,11 +43495,11 @@ ${installInfo}`
43446
43495
  parentSessionId: null,
43447
43496
  providerType: normalizedType,
43448
43497
  transport: "acp",
43449
- adapterKey: key,
43450
- instanceKey: key,
43498
+ adapterKey: key2,
43499
+ instanceKey: key2,
43451
43500
  workspace: resolvedDir
43452
43501
  });
43453
- this.adapters.set(key, {
43502
+ this.adapters.set(key2, {
43454
43503
  cliType: normalizedType,
43455
43504
  cliName: provider.name,
43456
43505
  workingDir: resolvedDir,
@@ -43458,7 +43507,7 @@ ${installInfo}`
43458
43507
  spawn: async () => {
43459
43508
  },
43460
43509
  shutdown: () => {
43461
- instanceManager2.removeInstance(key);
43510
+ instanceManager2.removeInstance(key2);
43462
43511
  },
43463
43512
  sendMessage: async (text) => {
43464
43513
  const input = normalizeInputEnvelope(text);
@@ -43474,7 +43523,7 @@ ${installInfo}`
43474
43523
  },
43475
43524
  getPartialResponse: () => "",
43476
43525
  cancel: () => {
43477
- instanceManager2.removeInstance(key);
43526
+ instanceManager2.removeInstance(key2);
43478
43527
  },
43479
43528
  isProcessing: () => false,
43480
43529
  isReady: () => true,
@@ -43528,7 +43577,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
43528
43577
  if (provider && instanceManager) {
43529
43578
  const resolvedProvider = this.providerLoader.resolve(cliType, { version: cliInfo.version }) || provider;
43530
43579
  await this.registerCliInstance(
43531
- key,
43580
+ key2,
43532
43581
  normalizedType,
43533
43582
  cliType,
43534
43583
  resolvedDir,
@@ -43558,7 +43607,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
43558
43607
  cliType,
43559
43608
  resolvedDir,
43560
43609
  resolvedCliArgs,
43561
- key,
43610
+ key2,
43562
43611
  sessionBinding.providerSessionId,
43563
43612
  false,
43564
43613
  options?.extraEnv
@@ -43578,9 +43627,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
43578
43627
  const status = adapter.getStatus?.();
43579
43628
  if (status?.status === "stopped" || status?.status === "error") {
43580
43629
  setTimeout(() => {
43581
- if (this.adapters.get(key) === adapter) {
43582
- this.adapters.delete(key);
43583
- this.deps.removeAgentTracking(key);
43630
+ if (this.adapters.get(key2) === adapter) {
43631
+ this.adapters.delete(key2);
43632
+ this.deps.removeAgentTracking(key2);
43584
43633
  LOG.info("CLI", `\u{1F9F9} Auto-cleaned ${status.status} CLI: ${adapter.cliType}`);
43585
43634
  this.deps.onStatusChange();
43586
43635
  }
@@ -43589,10 +43638,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
43589
43638
  });
43590
43639
  if (typeof adapter.setOnPtyData === "function") {
43591
43640
  adapter.setOnPtyData((data) => {
43592
- this.deps.getP2p()?.broadcastSessionOutput(key, data);
43641
+ this.deps.getP2p()?.broadcastSessionOutput(key2, data);
43593
43642
  });
43594
43643
  }
43595
- this.adapters.set(key, adapter);
43644
+ this.adapters.set(key2, adapter);
43596
43645
  console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
43597
43646
  }
43598
43647
  this.persistRecentActivity({
@@ -43602,20 +43651,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
43602
43651
  providerSessionId: sessionBinding.providerSessionId,
43603
43652
  workspace: resolvedDir,
43604
43653
  summaryMetadata: buildLegacyModelModeSummaryMetadata({ model: initialModel }),
43605
- sessionId: key,
43654
+ sessionId: key2,
43606
43655
  title: provider?.displayName || provider?.name || normalizedType
43607
43656
  });
43608
43657
  this.deps.onStatusChange();
43609
43658
  return {
43610
- runtimeSessionId: key,
43659
+ runtimeSessionId: key2,
43611
43660
  providerSessionId: sessionBinding.providerSessionId
43612
43661
  };
43613
43662
  }
43614
- async stopSession(key) {
43615
- return this.stopSessionWithMode(key, "hard");
43663
+ async stopSession(key2) {
43664
+ return this.stopSessionWithMode(key2, "hard");
43616
43665
  }
43617
- async stopSessionWithMode(key, mode) {
43618
- const adapter = this.adapters.get(key);
43666
+ async stopSessionWithMode(key2, mode) {
43667
+ const adapter = this.adapters.get(key2);
43619
43668
  if (adapter) {
43620
43669
  try {
43621
43670
  if (mode === "save" && typeof adapter.saveAndStop === "function") {
@@ -43626,21 +43675,21 @@ Run 'adhdev doctor' for detailed diagnostics.`
43626
43675
  } catch (e) {
43627
43676
  LOG.warn("CLI", `Shutdown error for ${adapter.cliType}: ${e?.message} (force-cleaning)`);
43628
43677
  }
43629
- this.adapters.delete(key);
43630
- this.deps.removeAgentTracking(key);
43631
- this.deps.getSessionRegistry?.()?.unregisterByInstanceKey(key);
43632
- this.deps.getInstanceManager()?.removeInstance(key);
43633
- unregisterMeshCoordinator(key);
43678
+ this.adapters.delete(key2);
43679
+ this.deps.removeAgentTracking(key2);
43680
+ this.deps.getSessionRegistry?.()?.unregisterByInstanceKey(key2);
43681
+ this.deps.getInstanceManager()?.removeInstance(key2);
43682
+ unregisterMeshCoordinator(key2);
43634
43683
  LOG.info("CLI", `\u{1F6D1} Agent stopped: ${adapter.cliType} in ${adapter.workingDir}`);
43635
43684
  this.deps.onStatusChange();
43636
43685
  } else {
43637
43686
  const im = this.deps.getInstanceManager();
43638
43687
  if (im) {
43639
- this.deps.getSessionRegistry?.()?.unregisterByInstanceKey(key);
43640
- im.removeInstance(key);
43641
- this.deps.removeAgentTracking(key);
43642
- unregisterMeshCoordinator(key);
43643
- LOG.warn("CLI", `\u{1F9F9} Force-removed orphan entry: ${key}`);
43688
+ this.deps.getSessionRegistry?.()?.unregisterByInstanceKey(key2);
43689
+ im.removeInstance(key2);
43690
+ this.deps.removeAgentTracking(key2);
43691
+ unregisterMeshCoordinator(key2);
43692
+ LOG.warn("CLI", `\u{1F9F9} Force-removed orphan entry: ${key2}`);
43644
43693
  this.deps.onStatusChange();
43645
43694
  }
43646
43695
  }
@@ -43668,8 +43717,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
43668
43717
  for (const r of sessions) {
43669
43718
  if (!r?.runtimeId || !r?.cliType || !r?.workspace) continue;
43670
43719
  restoredRuntimeIds.add(r.runtimeId);
43671
- const key = `${r.workspace}::${r.cliType}`;
43672
- workspaceTypeCounts.set(key, (workspaceTypeCounts.get(key) || 0) + 1);
43720
+ const key2 = `${r.workspace}::${r.cliType}`;
43721
+ workspaceTypeCounts.set(key2, (workspaceTypeCounts.get(key2) || 0) + 1);
43673
43722
  }
43674
43723
  for (const record of sessions) {
43675
43724
  if (!record?.runtimeId || !record?.cliType || !record?.workspace) continue;
@@ -44023,7 +44072,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
44023
44072
  });
44024
44073
  }
44025
44074
  if (!found) throw new Error(`CLI agent not running: ${agentType}`);
44026
- const { adapter, key } = found;
44075
+ const { adapter, key: key2 } = found;
44027
44076
  if (action === "send_chat") {
44028
44077
  let currentStatus = getEffectiveAgentSendStatus(adapter);
44029
44078
  if (currentStatus === "starting" && await waitForZeroMessageStartingLaunch(adapter)) {
@@ -44033,7 +44082,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
44033
44082
  }
44034
44083
  const meshContext = args?.meshContext;
44035
44084
  if (meshContext && typeof meshContext === "object" && typeof meshContext.meshId === "string" && meshContext.meshId) {
44036
- const targetInstanceId = key;
44085
+ const targetInstanceId = key2;
44037
44086
  try {
44038
44087
  this.deps.getInstanceManager()?.attachMeshAssignmentToInstance(targetInstanceId, {
44039
44088
  meshId: meshContext.meshId,
@@ -44065,7 +44114,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
44065
44114
  } else {
44066
44115
  await adapter.sendMessage(message);
44067
44116
  }
44068
- const targetInstance = this.deps.getInstanceManager()?.getInstance(key);
44117
+ const targetInstance = this.deps.getInstanceManager()?.getInstance(key2);
44069
44118
  targetInstance?.recordAcknowledgedUserInput?.(input);
44070
44119
  return {
44071
44120
  success: true,
@@ -44077,7 +44126,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
44077
44126
  if (typeof adapter.clearHistory === "function") adapter.clearHistory();
44078
44127
  return { success: true, cleared: true };
44079
44128
  } else if (action === "stop") {
44080
- await this.stopSession(key);
44129
+ await this.stopSession(key2);
44081
44130
  return { success: true, stopped: true };
44082
44131
  }
44083
44132
  throw new Error(`Unknown action: ${action}`);
@@ -44349,9 +44398,9 @@ function validateProviderDefinition(raw) {
44349
44398
  } else if (!["ide", "extension", "cli", "acp"].includes(String(provider.category))) {
44350
44399
  errors.push(`Invalid category: ${String(provider.category)}`);
44351
44400
  }
44352
- for (const key of Object.keys(provider)) {
44353
- if (!KNOWN_PROVIDER_FIELDS.has(key)) {
44354
- warnings.push(`Unknown provider field: ${key}`);
44401
+ for (const key2 of Object.keys(provider)) {
44402
+ if (!KNOWN_PROVIDER_FIELDS.has(key2)) {
44403
+ warnings.push(`Unknown provider field: ${key2}`);
44355
44404
  }
44356
44405
  }
44357
44406
  if (provider.disableUpstream !== void 0) {
@@ -44496,10 +44545,10 @@ function validateNativeHistory(raw, errors) {
44496
44545
  return;
44497
44546
  }
44498
44547
  const scriptConfig = scripts;
44499
- for (const key of ["readSession", "listSessions"]) {
44500
- const value = scriptConfig[key];
44548
+ for (const key2 of ["readSession", "listSessions"]) {
44549
+ const value = scriptConfig[key2];
44501
44550
  if (typeof value !== "string" || !value.trim()) {
44502
- errors.push(`nativeHistory.scripts.${key} must be a non-empty string`);
44551
+ errors.push(`nativeHistory.scripts.${key2} must be a non-empty string`);
44503
44552
  }
44504
44553
  }
44505
44554
  }
@@ -44534,10 +44583,10 @@ function validateMeshCoordinatorMcpConfig(mcpConfig, errors) {
44534
44583
  if (format !== void 0 && !["claude_mcp_json", "hermes_config_yaml"].includes(String(format))) {
44535
44584
  errors.push("meshCoordinator.mcpConfig.format must be one of: claude_mcp_json, hermes_config_yaml");
44536
44585
  }
44537
- for (const key of ["path", "serverName", "configPathCommand", "instructions", "template"]) {
44538
- const value = config[key];
44586
+ for (const key2 of ["path", "serverName", "configPathCommand", "instructions", "template"]) {
44587
+ const value = config[key2];
44539
44588
  if (value !== void 0 && (typeof value !== "string" || !value.trim())) {
44540
- errors.push(`meshCoordinator.mcpConfig.${key} must be a non-empty string when provided`);
44589
+ errors.push(`meshCoordinator.mcpConfig.${key2} must be a non-empty string when provided`);
44541
44590
  }
44542
44591
  }
44543
44592
  if (config.requiresRestart !== void 0 && typeof config.requiresRestart !== "boolean") {
@@ -44573,7 +44622,7 @@ function validateMeshCoordinatorDelegatedWorkerIsolation(raw, errors) {
44573
44622
  errors.push("meshCoordinator.delegatedWorkerIsolation.env must be an object");
44574
44623
  } else {
44575
44624
  const unset = env.unset;
44576
- if (unset !== void 0 && (!Array.isArray(unset) || unset.some((key) => typeof key !== "string" || !key.trim()))) {
44625
+ if (unset !== void 0 && (!Array.isArray(unset) || unset.some((key2) => typeof key2 !== "string" || !key2.trim()))) {
44577
44626
  errors.push("meshCoordinator.delegatedWorkerIsolation.env.unset must be an array of non-empty strings");
44578
44627
  }
44579
44628
  }
@@ -44596,16 +44645,16 @@ function validateMeshCoordinatorDelegatedWorkerIsolation(raw, errors) {
44596
44645
  errors.push(`${prefix}.mode must be one of: empty_mcp_config, config_override`);
44597
44646
  continue;
44598
44647
  }
44599
- for (const key of mode === "empty_mcp_config" ? ["flag"] : ["flag", "key", "value"]) {
44600
- const value = item[key];
44648
+ for (const key2 of mode === "empty_mcp_config" ? ["flag"] : ["flag", "key", "value"]) {
44649
+ const value = item[key2];
44601
44650
  if (typeof value !== "string" || !value.trim()) {
44602
- errors.push(`${prefix}.${key} must be a non-empty string`);
44651
+ errors.push(`${prefix}.${key2} must be a non-empty string`);
44603
44652
  }
44604
44653
  }
44605
- for (const key of ["strictFlag", "dedupeKey"]) {
44606
- const value = item[key];
44654
+ for (const key2 of ["strictFlag", "dedupeKey"]) {
44655
+ const value = item[key2];
44607
44656
  if (value !== void 0 && (typeof value !== "string" || !value.trim())) {
44608
- errors.push(`${prefix}.${key} must be a non-empty string when provided`);
44657
+ errors.push(`${prefix}.${key2} must be a non-empty string when provided`);
44609
44658
  }
44610
44659
  }
44611
44660
  }
@@ -46828,9 +46877,9 @@ var ProviderLoader = class _ProviderLoader {
46828
46877
  reload() {
46829
46878
  this.log("Reloading all providers...");
46830
46879
  this.scriptsCache.clear();
46831
- for (const key of Object.keys(__require.cache)) {
46832
- if (key.includes("providers") && (key.endsWith(".js") || key.endsWith(".json"))) {
46833
- delete __require.cache[key];
46880
+ for (const key2 of Object.keys(__require.cache)) {
46881
+ if (key2.includes("providers") && (key2.endsWith(".js") || key2.endsWith(".json"))) {
46882
+ delete __require.cache[key2];
46834
46883
  }
46835
46884
  }
46836
46885
  this.loadAll();
@@ -47138,7 +47187,7 @@ var ProviderLoader = class _ProviderLoader {
47138
47187
  */
47139
47188
  getPublicSettings(type) {
47140
47189
  const settings = this.getSettingsSchema(type);
47141
- return Object.entries(settings).filter(([, def]) => def.public === true).map(([key, def]) => ({ key, ...def }));
47190
+ return Object.entries(settings).filter(([, def]) => def.public === true).map(([key2, def]) => ({ key: key2, ...def }));
47142
47191
  }
47143
47192
  /**
47144
47193
  * Get public settings schema for all providers
@@ -47154,23 +47203,23 @@ var ProviderLoader = class _ProviderLoader {
47154
47203
  /**
47155
47204
  * Resolved setting value for a provider (default + user override)
47156
47205
  */
47157
- getSettingValue(type, key) {
47206
+ getSettingValue(type, key2) {
47158
47207
  const providerType = this.resolveAlias(type);
47159
47208
  const machineConfig = this.getMachineProviderConfig(providerType);
47160
- if (key === "enabled") {
47209
+ if (key2 === "enabled") {
47161
47210
  return machineConfig.enabled === true;
47162
47211
  }
47163
- if (key === "executablePath") {
47212
+ if (key2 === "executablePath") {
47164
47213
  return machineConfig.executable || "";
47165
47214
  }
47166
- if (key === "executableArgs") {
47215
+ if (key2 === "executableArgs") {
47167
47216
  const args = machineConfig.args;
47168
47217
  return args ? args.map((arg) => /\s/.test(arg) ? JSON.stringify(arg) : arg).join(" ") : "";
47169
47218
  }
47170
- const schemaDef = this.getSettingsSchema(providerType)[key];
47219
+ const schemaDef = this.getSettingsSchema(providerType)[key2];
47171
47220
  const defaultVal = schemaDef ? schemaDef.default : void 0;
47172
47221
  const config = this.readConfig();
47173
- const userVal = config?.providerSettings?.[providerType]?.[key];
47222
+ const userVal = config?.providerSettings?.[providerType]?.[key2];
47174
47223
  return userVal !== void 0 ? userVal : defaultVal;
47175
47224
  }
47176
47225
  /**
@@ -47180,17 +47229,17 @@ var ProviderLoader = class _ProviderLoader {
47180
47229
  const providerType = this.resolveAlias(type);
47181
47230
  const settings = this.getSettingsSchema(providerType);
47182
47231
  const result = {};
47183
- for (const [key] of Object.entries(settings)) {
47184
- result[key] = this.getSettingValue(providerType, key);
47232
+ for (const [key2] of Object.entries(settings)) {
47233
+ result[key2] = this.getSettingValue(providerType, key2);
47185
47234
  }
47186
47235
  return result;
47187
47236
  }
47188
47237
  /**
47189
47238
  * Save provider setting value (writes to config.json)
47190
47239
  */
47191
- setSetting(type, key, value) {
47240
+ setSetting(type, key2, value) {
47192
47241
  const providerType = this.resolveAlias(type);
47193
- const schemaDef = this.getSettingsSchema(providerType)[key];
47242
+ const schemaDef = this.getSettingsSchema(providerType)[key2];
47194
47243
  if (!schemaDef) return false;
47195
47244
  if (!schemaDef.public) return false;
47196
47245
  if (schemaDef.type === "boolean" && typeof value !== "boolean") return false;
@@ -47201,13 +47250,13 @@ var ProviderLoader = class _ProviderLoader {
47201
47250
  if (schemaDef.max !== void 0 && value > schemaDef.max) return false;
47202
47251
  }
47203
47252
  if (schemaDef.type === "select" && schemaDef.options && !schemaDef.options.includes(value)) return false;
47204
- if (key === "enabled") {
47253
+ if (key2 === "enabled") {
47205
47254
  return this.setMachineProviderEnabled(providerType, value);
47206
47255
  }
47207
- if (key === "executablePath") {
47256
+ if (key2 === "executablePath") {
47208
47257
  return this.setMachineProviderConfig(providerType, { executable: value });
47209
47258
  }
47210
- if (key === "executableArgs") {
47259
+ if (key2 === "executableArgs") {
47211
47260
  return this.setMachineProviderConfig(providerType, {
47212
47261
  args: value.trim() ? this.parseArgsSetting(value) : void 0
47213
47262
  });
@@ -47217,17 +47266,17 @@ var ProviderLoader = class _ProviderLoader {
47217
47266
  try {
47218
47267
  if (!config.providerSettings) config.providerSettings = {};
47219
47268
  if (!config.providerSettings[providerType]) config.providerSettings[providerType] = {};
47220
- config.providerSettings[providerType][key] = value;
47269
+ config.providerSettings[providerType][key2] = value;
47221
47270
  this.writeConfig(config);
47222
- this.log(`Setting updated: ${providerType}.${key} = ${JSON.stringify(value)}`);
47271
+ this.log(`Setting updated: ${providerType}.${key2} = ${JSON.stringify(value)}`);
47223
47272
  return true;
47224
47273
  } catch (e) {
47225
47274
  this.log(`Failed to save setting: ${e.message}`);
47226
47275
  return false;
47227
47276
  }
47228
47277
  }
47229
- getOptionalStringSetting(type, key) {
47230
- const value = this.getSettingValue(type, key);
47278
+ getOptionalStringSetting(type, key2) {
47279
+ const value = this.getSettingValue(type, key2);
47231
47280
  if (typeof value !== "string") return null;
47232
47281
  const trimmed = value.trim();
47233
47282
  return trimmed ? trimmed : null;
@@ -47407,7 +47456,7 @@ var ProviderLoader = class _ProviderLoader {
47407
47456
  try {
47408
47457
  let content = fs25.readFileSync(filePath, "utf-8");
47409
47458
  if (args[0] && typeof args[0] === "object") {
47410
- for (const [key, val] of Object.entries(args[0])) {
47459
+ for (const [key2, val] of Object.entries(args[0])) {
47411
47460
  let v = val;
47412
47461
  if (typeof v === "string") {
47413
47462
  if (!v.startsWith('"') && !v.startsWith("'") && !v.startsWith("`")) {
@@ -47416,7 +47465,7 @@ var ProviderLoader = class _ProviderLoader {
47416
47465
  } else {
47417
47466
  v = JSON.stringify(v);
47418
47467
  }
47419
- const re = new RegExp(`\\$\\{\\s*${key}\\s*\\}`, "g");
47468
+ const re = new RegExp(`\\$\\{\\s*${key2}\\s*\\}`, "g");
47420
47469
  content = content.replace(re, String(v));
47421
47470
  }
47422
47471
  } else if (typeof args[0] === "string") {
@@ -49168,9 +49217,20 @@ var meshQueueHandlers = {
49168
49217
  targetNodeId: typeof args?.targetNodeId === "string" ? args.targetNodeId.trim() : void 0,
49169
49218
  targetSessionId: typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : void 0,
49170
49219
  clearTargetNode: args?.clearTargetNode === true,
49171
- clearTargetSession: args?.clearTargetSession !== false
49220
+ clearTargetSession: args?.clearTargetSession !== false,
49221
+ // CANON-IDENTITY: an in-flight (actively-generating) task is refused by
49222
+ // default to avoid a duplicate second dispatch; an explicit operator
49223
+ // force overrides that guard (and the retry cap).
49224
+ force: args?.force === true
49172
49225
  });
49173
49226
  if (!task) return { success: false, error: `Queue task '${taskId}' not found` };
49227
+ if (task.status === "assigned" && args?.force !== true) {
49228
+ return {
49229
+ success: false,
49230
+ error: `Task '${taskId}' is actively dispatched/generating; requeue refused to avoid a duplicate second dispatch. Pass force:true to override, or cancel and re-enqueue.`,
49231
+ task
49232
+ };
49233
+ }
49174
49234
  return { success: true, task };
49175
49235
  } catch (e) {
49176
49236
  return { success: false, error: e.message };
@@ -50701,15 +50761,15 @@ var SENSITIVE_KEYS = /* @__PURE__ */ new Set([
50701
50761
  function maskArgs(args) {
50702
50762
  if (!args || typeof args !== "object") return void 0;
50703
50763
  const masked = {};
50704
- for (const [key, value] of Object.entries(args)) {
50705
- if (SENSITIVE_KEYS.has(key)) {
50706
- masked[key] = typeof value === "string" ? `[${value.length} chars]` : "[masked]";
50707
- } else if (key.startsWith("_")) {
50708
- masked[key] = value;
50764
+ for (const [key2, value] of Object.entries(args)) {
50765
+ if (SENSITIVE_KEYS.has(key2)) {
50766
+ masked[key2] = typeof value === "string" ? `[${value.length} chars]` : "[masked]";
50767
+ } else if (key2.startsWith("_")) {
50768
+ masked[key2] = value;
50709
50769
  } else if (typeof value === "object" && value !== null) {
50710
- masked[key] = Array.isArray(value) ? `[Array(${value.length})]` : `[Object]`;
50770
+ masked[key2] = Array.isArray(value) ? `[Array(${value.length})]` : `[Object]`;
50711
50771
  } else {
50712
- masked[key] = value;
50772
+ masked[key2] = value;
50713
50773
  }
50714
50774
  }
50715
50775
  return masked;
@@ -51806,23 +51866,23 @@ var MeshGitProbeCache = class {
51806
51866
  * neither gate is satisfied.
51807
51867
  */
51808
51868
  async probe(daemonId, workspace, probe) {
51809
- const key = this.key(daemonId, workspace);
51810
- const cached3 = this.recent.get(key);
51869
+ const key2 = this.key(daemonId, workspace);
51870
+ const cached3 = this.recent.get(key2);
51811
51871
  if (cached3 && this.now() - cached3.at < this.reuseMs) {
51812
51872
  return cached3.value;
51813
51873
  }
51814
- const existing = this.inflight.get(key);
51874
+ const existing = this.inflight.get(key2);
51815
51875
  if (existing) return existing;
51816
51876
  const pending = (async () => {
51817
51877
  const result = await probe();
51818
- if (result) this.recent.set(key, { at: this.now(), value: result });
51878
+ if (result) this.recent.set(key2, { at: this.now(), value: result });
51819
51879
  return result;
51820
51880
  })();
51821
- this.inflight.set(key, pending);
51881
+ this.inflight.set(key2, pending);
51822
51882
  try {
51823
51883
  return await pending;
51824
51884
  } finally {
51825
- if (this.inflight.get(key) === pending) this.inflight.delete(key);
51885
+ if (this.inflight.get(key2) === pending) this.inflight.delete(key2);
51826
51886
  }
51827
51887
  }
51828
51888
  };
@@ -54520,8 +54580,8 @@ var DaemonCommandRouter = class {
54520
54580
  if (source !== "refine_mesh_node_async_job") continue;
54521
54581
  const jobId = e.payload?.refineJob?.jobId;
54522
54582
  if (!jobId || terminal.has(`${e.nodeId}:${jobId}`)) continue;
54523
- const key = this.buildRefineJobKey(meshId, e.nodeId);
54524
- if (this.runningRefineJobs.has(key)) continue;
54583
+ const key2 = this.buildRefineJobKey(meshId, e.nodeId);
54584
+ if (this.runningRefineJobs.has(key2)) continue;
54525
54585
  const coordinatorDaemonId = e.payload?.refineJob?.targetCoordinatorDaemonId;
54526
54586
  LOG.info("Mesh", `[Refinery] Auto-resuming interrupted refine job for node ${e.nodeId} (jobId=${jobId})`);
54527
54587
  void this.startMeshRefineJob(meshId, e.nodeId, {
@@ -55604,7 +55664,7 @@ ${hintLines.join("\n")}` : "",
55604
55664
  }
55605
55665
  }
55606
55666
  async finishMeshRefineBatchJob(handle, orderedNodes, ordering, args) {
55607
- const key = this.buildRefineBatchJobKey(handle.meshId);
55667
+ const key2 = this.buildRefineBatchJobKey(handle.meshId);
55608
55668
  let result;
55609
55669
  try {
55610
55670
  result = await this.runMeshRefineBatchConvergence(handle.meshId, orderedNodes, ordering, args);
@@ -55636,8 +55696,8 @@ ${hintLines.join("\n")}` : "",
55636
55696
  coordinatorDaemonId: handle.targetCoordinatorDaemonId
55637
55697
  });
55638
55698
  const terminal = { ...terminalHandle, result: normalizedResult };
55639
- this.terminalRefineBatchJobs.set(key, terminal);
55640
- this.runningRefineBatchJobs.delete(key);
55699
+ this.terminalRefineBatchJobs.set(key2, terminal);
55700
+ this.runningRefineBatchJobs.delete(key2);
55641
55701
  this.invalidateAggregateMeshStatus(handle.meshId);
55642
55702
  await this.appendRefineBatchJobLedger(isTerminalSuccess ? "task_completed" : "task_failed", terminalHandle, normalizedResult);
55643
55703
  this.queueRefineBatchJobEvent(isTerminalSuccess ? "refine:completed" : "refine:failed", terminalHandle, normalizedResult);
@@ -55661,8 +55721,8 @@ ${hintLines.join("\n")}` : "",
55661
55721
  if (nodeIds.length === 0) {
55662
55722
  return { ...planRecord, success: true, batch: true, dryRun: false, async: false };
55663
55723
  }
55664
- const key = this.buildRefineBatchJobKey(meshId);
55665
- const running = this.runningRefineBatchJobs.get(key);
55724
+ const key2 = this.buildRefineBatchJobKey(meshId);
55725
+ const running = this.runningRefineBatchJobs.get(key2);
55666
55726
  if (running) return { ...running, duplicate: true };
55667
55727
  const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
55668
55728
  const mesh = meshRecord?.mesh;
@@ -55677,7 +55737,7 @@ ${hintLines.join("\n")}` : "",
55677
55737
  };
55678
55738
  const coordinatorDaemonId = typeof args?.coordinatorDaemonId === "string" && args.coordinatorDaemonId.trim() ? args.coordinatorDaemonId.trim() : this.deps.statusInstanceId || void 0;
55679
55739
  const handle = this.buildRefineBatchJobHandle({ meshId, nodeIds, order, coordinatorDaemonId });
55680
- this.runningRefineBatchJobs.set(key, handle);
55740
+ this.runningRefineBatchJobs.set(key2, handle);
55681
55741
  await this.appendRefineBatchJobLedger("task_dispatched", handle);
55682
55742
  this.queueRefineBatchJobEvent("refine:accepted", handle);
55683
55743
  setImmediate(() => {
@@ -55692,7 +55752,7 @@ ${hintLines.join("\n")}` : "",
55692
55752
  };
55693
55753
  }
55694
55754
  async finishMeshRefineJob(handle, args) {
55695
- const key = this.buildRefineJobKey(handle.meshId, handle.targetNodeId);
55755
+ const key2 = this.buildRefineJobKey(handle.meshId, handle.targetNodeId);
55696
55756
  let result;
55697
55757
  try {
55698
55758
  result = await this.executeMeshRefineNodeSynchronously(handle.meshId, handle.targetNodeId, args);
@@ -55760,17 +55820,17 @@ ${hintLines.join("\n")}` : "",
55760
55820
  coordinatorDaemonId: handle.targetCoordinatorDaemonId
55761
55821
  });
55762
55822
  const terminal = { ...terminalHandle, result: normalizedResult };
55763
- this.terminalRefineJobs.set(key, terminal);
55764
- this.runningRefineJobs.delete(key);
55823
+ this.terminalRefineJobs.set(key2, terminal);
55824
+ this.runningRefineJobs.delete(key2);
55765
55825
  this.invalidateAggregateMeshStatus(handle.meshId);
55766
55826
  await this.appendRefineJobLedger(isTerminalSuccess ? "task_completed" : "task_failed", terminalHandle, normalizedResult);
55767
55827
  this.queueRefineJobEvent(isTerminalSuccess ? "refine:completed" : "refine:failed", terminalHandle, normalizedResult);
55768
55828
  }
55769
55829
  async startMeshRefineJob(meshId, nodeId, args) {
55770
- const key = this.buildRefineJobKey(meshId, nodeId);
55771
- const running = this.runningRefineJobs.get(key);
55830
+ const key2 = this.buildRefineJobKey(meshId, nodeId);
55831
+ const running = this.runningRefineJobs.get(key2);
55772
55832
  if (running) return { ...running, duplicate: true };
55773
- const terminal = this.terminalRefineJobs.get(key);
55833
+ const terminal = this.terminalRefineJobs.get(key2);
55774
55834
  const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
55775
55835
  const mesh = meshRecord?.mesh;
55776
55836
  const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
@@ -55778,7 +55838,7 @@ ${hintLines.join("\n")}` : "",
55778
55838
  if (!node.isLocalWorktree || !node.workspace) return { success: false, error: `Refinery requires a local worktree node` };
55779
55839
  const coordinatorDaemonId = typeof args?.coordinatorDaemonId === "string" && args.coordinatorDaemonId.trim() ? args.coordinatorDaemonId.trim() : this.deps.statusInstanceId || void 0;
55780
55840
  const handle = this.buildRefineJobHandle({ meshId, nodeId, node, retryOfJobId: terminal?.jobId, coordinatorDaemonId });
55781
- this.runningRefineJobs.set(key, handle);
55841
+ this.runningRefineJobs.set(key2, handle);
55782
55842
  await this.appendRefineJobLedger("task_dispatched", handle);
55783
55843
  this.queueRefineJobEvent("refine:accepted", handle);
55784
55844
  setImmediate(() => {
@@ -55834,27 +55894,27 @@ ${hintLines.join("\n")}` : "",
55834
55894
  */
55835
55895
  async stopIde(ideType, killProcess = false) {
55836
55896
  const cdpKeysToRemove = [];
55837
- for (const key of this.deps.cdpManagers.keys()) {
55838
- if (key === ideType || key.startsWith(`${ideType}_`)) {
55839
- cdpKeysToRemove.push(key);
55897
+ for (const key2 of this.deps.cdpManagers.keys()) {
55898
+ if (key2 === ideType || key2.startsWith(`${ideType}_`)) {
55899
+ cdpKeysToRemove.push(key2);
55840
55900
  }
55841
55901
  }
55842
- for (const key of cdpKeysToRemove) {
55843
- const cdp = this.deps.cdpManagers.get(key);
55902
+ for (const key2 of cdpKeysToRemove) {
55903
+ const cdp = this.deps.cdpManagers.get(key2);
55844
55904
  if (cdp) {
55845
55905
  try {
55846
55906
  cdp.disconnect();
55847
55907
  } catch {
55848
55908
  }
55849
- this.deps.cdpManagers.delete(key);
55850
- this.deps.sessionRegistry.unregisterByManagerKey(key);
55851
- LOG.info("StopIDE", `CDP disconnected: ${key}`);
55909
+ this.deps.cdpManagers.delete(key2);
55910
+ this.deps.sessionRegistry.unregisterByManagerKey(key2);
55911
+ LOG.info("StopIDE", `CDP disconnected: ${key2}`);
55852
55912
  }
55853
55913
  }
55854
55914
  const keysToRemove = [];
55855
- for (const key of this.deps.instanceManager.listInstanceIds()) {
55856
- if (key === `ide:${ideType}` || typeof key === "string" && key.startsWith(`ide:${ideType}_`)) {
55857
- keysToRemove.push(key);
55915
+ for (const key2 of this.deps.instanceManager.listInstanceIds()) {
55916
+ if (key2 === `ide:${ideType}` || typeof key2 === "string" && key2.startsWith(`ide:${ideType}_`)) {
55917
+ keysToRemove.push(key2);
55858
55918
  }
55859
55919
  }
55860
55920
  for (const instanceKey of keysToRemove) {
@@ -60547,9 +60607,9 @@ async function handleAutoImplement(ctx, type, req, res) {
60547
60607
  }
60548
60608
  if (Date.now() - lastApprovalTime < 2e3) return;
60549
60609
  if (approvalPatterns.some((p) => p.test(approvalBuffer))) {
60550
- const key = approvalKeys[1] || approvalKeys[0] || "a\r";
60551
- writeFn(key);
60552
- ctx.log(`Auto-Implement auto-approved prompt! Sending: ${JSON.stringify(key)}`);
60610
+ const key2 = approvalKeys[1] || approvalKeys[0] || "a\r";
60611
+ writeFn(key2);
60612
+ ctx.log(`Auto-Implement auto-approved prompt! Sending: ${JSON.stringify(key2)}`);
60553
60613
  sendAutoImplSSE(ctx, { event: "output", data: { chunk: `
60554
60614
  [\u{1F916} ADHDev Auto-Approve] CLI Action Approved
60555
60615
  `, stream: "stdout" } });
@@ -61801,8 +61861,8 @@ var DevServer = class _DevServer {
61801
61861
  category: p.category
61802
61862
  }));
61803
61863
  const cdpStatus = {};
61804
- for (const [key, cdp] of this.cdpManagers.entries()) {
61805
- cdpStatus[key] = { connected: cdp.isConnected };
61864
+ for (const [key2, cdp] of this.cdpManagers.entries()) {
61865
+ cdpStatus[key2] = { connected: cdp.isConnected };
61806
61866
  }
61807
61867
  this.json(res, 200, {
61808
61868
  devMode: true,
@@ -62122,16 +62182,16 @@ var DevServer = class _DevServer {
62122
62182
  errors.push(...validation.errors);
62123
62183
  warnings.push(...validation.warnings);
62124
62184
  if (config.settings) {
62125
- for (const [key, val] of Object.entries(config.settings)) {
62185
+ for (const [key2, val] of Object.entries(config.settings)) {
62126
62186
  const s2 = val;
62127
- if (!s2.type) errors.push(`settings.${key}: missing type`);
62187
+ if (!s2.type) errors.push(`settings.${key2}: missing type`);
62128
62188
  else if (!["boolean", "number", "string", "select"].includes(s2.type))
62129
- errors.push(`settings.${key}: invalid type '${s2.type}'`);
62130
- if (s2.default === void 0) warnings.push(`settings.${key}: no default value`);
62189
+ errors.push(`settings.${key2}: invalid type '${s2.type}'`);
62190
+ if (s2.default === void 0) warnings.push(`settings.${key2}: no default value`);
62131
62191
  if (s2.type === "number" && s2.min !== void 0 && s2.max !== void 0 && s2.min > s2.max)
62132
- errors.push(`settings.${key}: min (${s2.min}) > max (${s2.max})`);
62192
+ errors.push(`settings.${key2}: min (${s2.min}) > max (${s2.max})`);
62133
62193
  if (s2.type === "select" && (!s2.options || !Array.isArray(s2.options) || s2.options.length === 0))
62134
- errors.push(`settings.${key}: select type requires options[]`);
62194
+ errors.push(`settings.${key2}: select type requires options[]`);
62135
62195
  }
62136
62196
  }
62137
62197
  if (config.cdpPorts && Array.isArray(config.cdpPorts)) {
@@ -62919,21 +62979,21 @@ function isLowercaseLetter(value) {
62919
62979
  function encodeControlLetter(letter) {
62920
62980
  return String.fromCharCode(letter.charCodeAt(0) - 96);
62921
62981
  }
62922
- function encodeShiftedKey(key) {
62923
- if (isLowercaseLetter(key)) return key.toUpperCase();
62924
- if (key.startsWith("ctrl+") && isLowercaseLetter(key.slice(5))) {
62925
- return encodeControlLetter(key.slice(5));
62982
+ function encodeShiftedKey(key2) {
62983
+ if (isLowercaseLetter(key2)) return key2.toUpperCase();
62984
+ if (key2.startsWith("ctrl+") && isLowercaseLetter(key2.slice(5))) {
62985
+ return encodeControlLetter(key2.slice(5));
62926
62986
  }
62927
- if (key.startsWith("alt+") && isLowercaseLetter(key.slice(4))) {
62928
- return `\x1B${key.slice(4).toUpperCase()}`;
62987
+ if (key2.startsWith("alt+") && isLowercaseLetter(key2.slice(4))) {
62988
+ return `\x1B${key2.slice(4).toUpperCase()}`;
62929
62989
  }
62930
- if (key === "tab") return "\x1B[Z";
62931
- if (key in SHIFTED_CSI_KEYS) return SHIFTED_CSI_KEYS[key];
62932
- if (key in BASE_KEY_SEQUENCES) return BASE_KEY_SEQUENCES[key];
62933
- throw new Error(`Unsupported named key: shift+${key}`);
62990
+ if (key2 === "tab") return "\x1B[Z";
62991
+ if (key2 in SHIFTED_CSI_KEYS) return SHIFTED_CSI_KEYS[key2];
62992
+ if (key2 in BASE_KEY_SEQUENCES) return BASE_KEY_SEQUENCES[key2];
62993
+ throw new Error(`Unsupported named key: shift+${key2}`);
62934
62994
  }
62935
- function namedKeyToAnsi(key) {
62936
- const normalized = String(key || "").trim().toLowerCase();
62995
+ function namedKeyToAnsi(key2) {
62996
+ const normalized = String(key2 || "").trim().toLowerCase();
62937
62997
  if (normalized in BASE_KEY_SEQUENCES) return BASE_KEY_SEQUENCES[normalized];
62938
62998
  if (normalized.startsWith("ctrl+") && isLowercaseLetter(normalized.slice(5))) {
62939
62999
  return encodeControlLetter(normalized.slice(5));
@@ -62942,7 +63002,7 @@ function namedKeyToAnsi(key) {
62942
63002
  return `\x1B${normalized.slice(4)}`;
62943
63003
  }
62944
63004
  if (normalized.startsWith("shift+")) return encodeShiftedKey(normalized.slice(6));
62945
- throw new Error(`Unsupported named key: ${key}`);
63005
+ throw new Error(`Unsupported named key: ${key2}`);
62946
63006
  }
62947
63007
  function namedKeysToAnsi(keys) {
62948
63008
  if (!Array.isArray(keys)) throw new Error("keys must be an array");
@@ -63423,19 +63483,19 @@ var SessionRegistry = class {
63423
63483
  if (!ids) return [];
63424
63484
  return [...ids].map((id) => this.bySessionId.get(id)).filter(Boolean);
63425
63485
  }
63426
- addIndex(index, key, sessionId) {
63427
- let set = index.get(key);
63486
+ addIndex(index, key2, sessionId) {
63487
+ let set = index.get(key2);
63428
63488
  if (!set) {
63429
63489
  set = /* @__PURE__ */ new Set();
63430
- index.set(key, set);
63490
+ index.set(key2, set);
63431
63491
  }
63432
63492
  set.add(sessionId);
63433
63493
  }
63434
- removeIndex(index, key, sessionId) {
63435
- const set = index.get(key);
63494
+ removeIndex(index, key2, sessionId) {
63495
+ const set = index.get(key2);
63436
63496
  if (!set) return;
63437
63497
  set.delete(sessionId);
63438
- if (set.size === 0) index.delete(key);
63498
+ if (set.size === 0) index.delete(key2);
63439
63499
  }
63440
63500
  };
63441
63501
 
@@ -64095,6 +64155,7 @@ export {
64095
64155
  buildToolChatMessage,
64096
64156
  buildUserChatMessage,
64097
64157
  cancelTask,
64158
+ canonicalDaemonId,
64098
64159
  claimNextTask,
64099
64160
  classifyChatMessageVisibility,
64100
64161
  classifyHotChatSessionsForSubscriptionFlush,