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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -14,9 +14,9 @@ var __export = (target, all) => {
14
14
  };
15
15
  var __copyProps = (to, from, except, desc) => {
16
16
  if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ for (let key2 of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key2) && key2 !== except)
19
+ __defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
20
20
  }
21
21
  return to;
22
22
  };
@@ -389,10 +389,10 @@ function readInjected(value) {
389
389
  }
390
390
  function getDaemonBuildInfo() {
391
391
  if (cached) return cached;
392
- const commit = readInjected(true ? "f8bbe838081c3b3e14df690b3ed24568979f635e" : void 0) ?? "unknown";
393
- const commitShort = readInjected(true ? "f8bbe838" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
394
- const version = readInjected(true ? "0.9.82-rc.412" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
395
- const builtAt = readInjected(true ? "2026-06-28T10:27:03.423Z" : void 0);
392
+ const commit = readInjected(true ? "7a774e95a82354f5357197b3c84f63e68b5f7a5d" : void 0) ?? "unknown";
393
+ const commitShort = readInjected(true ? "7a774e95" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
394
+ const version = readInjected(true ? "0.9.82-rc.414" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
395
+ const builtAt = readInjected(true ? "2026-06-28T11:50:52.585Z" : void 0);
396
396
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
397
397
  return cached;
398
398
  }
@@ -410,18 +410,18 @@ function isRecord(value) {
410
410
  function isStringArray(value) {
411
411
  return Array.isArray(value) && value.every((v) => typeof v === "string" && v.length > 0);
412
412
  }
413
- function validateTarget(value, key, errors) {
413
+ function validateTarget(value, key2, errors) {
414
414
  if (!isRecord(value)) {
415
- errors.push(`impactTargets.${key} must be an object`);
415
+ errors.push(`impactTargets.${key2} must be an object`);
416
416
  return void 0;
417
417
  }
418
418
  const { recommendedCommand } = value;
419
419
  if (typeof recommendedCommand !== "string" || !recommendedCommand.length) {
420
- errors.push(`impactTargets.${key}.recommendedCommand must be a non-empty string`);
420
+ errors.push(`impactTargets.${key2}.recommendedCommand must be a non-empty string`);
421
421
  return void 0;
422
422
  }
423
423
  for (const k of Object.keys(value)) {
424
- if (k !== "recommendedCommand") errors.push(`impactTargets.${key}.${k} is not a recognized field (only recommendedCommand)`);
424
+ if (k !== "recommendedCommand") errors.push(`impactTargets.${key2}.${k} is not a recognized field (only recommendedCommand)`);
425
425
  }
426
426
  return { recommendedCommand };
427
427
  }
@@ -448,20 +448,20 @@ function validateChangeImpactConfig(raw, source = "inline") {
448
448
  errors.push("impactTargets must be an object");
449
449
  } else {
450
450
  const targets = {};
451
- for (const key of Object.keys(raw.impactTargets)) {
452
- if (key !== "daemon" && key !== "web" && key !== "none") {
453
- errors.push(`impactTargets.${key} is not a recognized impact kind (daemon|web|none)`);
451
+ for (const key2 of Object.keys(raw.impactTargets)) {
452
+ if (key2 !== "daemon" && key2 !== "web" && key2 !== "none") {
453
+ errors.push(`impactTargets.${key2} is not a recognized impact kind (daemon|web|none)`);
454
454
  continue;
455
455
  }
456
- const target = validateTarget(raw.impactTargets[key], key, errors);
457
- if (target) targets[key] = target;
456
+ const target = validateTarget(raw.impactTargets[key2], key2, errors);
457
+ if (target) targets[key2] = target;
458
458
  }
459
459
  if (Object.keys(targets).length) config.impactTargets = targets;
460
460
  }
461
461
  }
462
- for (const key of Object.keys(raw)) {
463
- if (!["daemonRuntimePackages", "webOnlyPackages", "nonRuntimeRootFilePatterns", "impactTargets"].includes(key)) {
464
- errors.push(`unknown config key '${key}'`);
462
+ for (const key2 of Object.keys(raw)) {
463
+ if (!["daemonRuntimePackages", "webOnlyPackages", "nonRuntimeRootFilePatterns", "impactTargets"].includes(key2)) {
464
+ errors.push(`unknown config key '${key2}'`);
465
465
  }
466
466
  }
467
467
  return { valid: errors.length === 0, errors, config: errors.length === 0 ? config : void 0 };
@@ -793,12 +793,12 @@ function resolveChangeImpactConfigForRepo(repoRoot, options) {
793
793
  return { config: null, sourceKey: "forced-default" };
794
794
  }
795
795
  if (options.changeImpactConfig !== void 0) {
796
- let key = "injected";
796
+ let key2 = "injected";
797
797
  try {
798
- key = `injected:${JSON.stringify(options.changeImpactConfig)}`;
798
+ key2 = `injected:${JSON.stringify(options.changeImpactConfig)}`;
799
799
  } catch {
800
800
  }
801
- return { config: options.changeImpactConfig, sourceKey: key };
801
+ return { config: options.changeImpactConfig, sourceKey: key2 };
802
802
  }
803
803
  if (!repoRoot) {
804
804
  return { config: null, sourceKey: "no-repo-root" };
@@ -2359,9 +2359,9 @@ function dismissSessionNotification(state, sessionId, notificationId, providerSe
2359
2359
  ].filter(Boolean)));
2360
2360
  const nextSessionNotificationDismissals = { ...state.sessionNotificationDismissals || {} };
2361
2361
  const nextSessionNotificationUnreadOverrides = { ...state.sessionNotificationUnreadOverrides || {} };
2362
- for (const key of dismissalKeys) {
2363
- nextSessionNotificationDismissals[key] = dismissalId;
2364
- delete nextSessionNotificationUnreadOverrides[key];
2362
+ for (const key2 of dismissalKeys) {
2363
+ nextSessionNotificationDismissals[key2] = dismissalId;
2364
+ delete nextSessionNotificationUnreadOverrides[key2];
2365
2365
  }
2366
2366
  return {
2367
2367
  ...state,
@@ -2378,9 +2378,9 @@ function markSessionNotificationUnread(state, sessionId, notificationId, provide
2378
2378
  ].filter(Boolean)));
2379
2379
  const nextSessionNotificationDismissals = { ...state.sessionNotificationDismissals || {} };
2380
2380
  const nextSessionNotificationUnreadOverrides = { ...state.sessionNotificationUnreadOverrides || {} };
2381
- for (const key of unreadKeys) {
2382
- nextSessionNotificationUnreadOverrides[key] = unreadId;
2383
- delete nextSessionNotificationDismissals[key];
2381
+ for (const key2 of unreadKeys) {
2382
+ nextSessionNotificationUnreadOverrides[key2] = unreadId;
2383
+ delete nextSessionNotificationDismissals[key2];
2384
2384
  }
2385
2385
  return {
2386
2386
  ...state,
@@ -2444,11 +2444,11 @@ function markSessionSeen(state, sessionId, seenAt = Date.now(), completionMarker
2444
2444
  const nextSessionReadMarkers = { ...prevMarkers };
2445
2445
  const nextSessionNotificationDismissals = { ...state.sessionNotificationDismissals || {} };
2446
2446
  const nextSessionNotificationUnreadOverrides = { ...state.sessionNotificationUnreadOverrides || {} };
2447
- for (const key of readKeys) {
2448
- nextSessionReads[key] = Math.max(prev[key] || 0, seenAt);
2449
- if (nextMarker) nextSessionReadMarkers[key] = nextMarker;
2450
- delete nextSessionNotificationDismissals[key];
2451
- delete nextSessionNotificationUnreadOverrides[key];
2447
+ for (const key2 of readKeys) {
2448
+ nextSessionReads[key2] = Math.max(prev[key2] || 0, seenAt);
2449
+ if (nextMarker) nextSessionReadMarkers[key2] = nextMarker;
2450
+ delete nextSessionNotificationDismissals[key2];
2451
+ delete nextSessionNotificationUnreadOverrides[key2];
2452
2452
  }
2453
2453
  return {
2454
2454
  ...state,
@@ -3153,6 +3153,12 @@ function machineCoreFromDaemonId(id) {
3153
3153
  }
3154
3154
  return trimmed;
3155
3155
  }
3156
+ function canonicalDaemonId(id) {
3157
+ const core = machineCoreFromDaemonId(id);
3158
+ if (!core) return void 0;
3159
+ if (!core.startsWith("mach_")) return core;
3160
+ return `daemon_${core}`;
3161
+ }
3156
3162
  function daemonIdsEquivalent(a, b) {
3157
3163
  const coreA = machineCoreFromDaemonId(a);
3158
3164
  const coreB = machineCoreFromDaemonId(b);
@@ -3314,8 +3320,8 @@ function expandPromptPlaceholders(template, ctx) {
3314
3320
  rules: buildRulesSection(coordinatorCliType),
3315
3321
  toolExposurePreflight: TOOL_EXPOSURE_PREFLIGHT_SECTION
3316
3322
  };
3317
- return template.replace(/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g, (m, key) => {
3318
- return Object.prototype.hasOwnProperty.call(replacements, key) ? replacements[key] : m;
3323
+ return template.replace(/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g, (m, key2) => {
3324
+ return Object.prototype.hasOwnProperty.call(replacements, key2) ? replacements[key2] : m;
3319
3325
  });
3320
3326
  }
3321
3327
  function buildNodeStatusSection(nodes) {
@@ -4718,6 +4724,33 @@ var init_mesh_delivery_policy = __esm({
4718
4724
  }
4719
4725
  });
4720
4726
 
4727
+ // src/mesh/mesh-task-inflight.ts
4728
+ function key(meshId, taskId) {
4729
+ return `${meshId}::${taskId}`;
4730
+ }
4731
+ function beginTaskDispatchInFlight(meshId, taskId) {
4732
+ if (!meshId || !taskId) return false;
4733
+ const k = key(meshId, taskId);
4734
+ if (inFlight.has(k)) return false;
4735
+ inFlight.add(k);
4736
+ return true;
4737
+ }
4738
+ function isTaskDispatchInFlight(meshId, taskId) {
4739
+ if (!meshId || !taskId) return false;
4740
+ return inFlight.has(key(meshId, taskId));
4741
+ }
4742
+ function endTaskDispatchInFlight(meshId, taskId) {
4743
+ if (!meshId || !taskId) return;
4744
+ inFlight.delete(key(meshId, taskId));
4745
+ }
4746
+ var inFlight;
4747
+ var init_mesh_task_inflight = __esm({
4748
+ "src/mesh/mesh-task-inflight.ts"() {
4749
+ "use strict";
4750
+ inFlight = /* @__PURE__ */ new Set();
4751
+ }
4752
+ });
4753
+
4721
4754
  // src/mesh/mesh-work-queue.ts
4722
4755
  var mesh_work_queue_exports = {};
4723
4756
  __export(mesh_work_queue_exports, {
@@ -4984,14 +5017,14 @@ function firstProviderPriority(policy) {
4984
5017
  if (!Array.isArray(raw)) return void 0;
4985
5018
  return raw.find((type) => typeof type === "string" && type.trim())?.trim();
4986
5019
  }
4987
- function readNodeOverride(node, key) {
5020
+ function readNodeOverride(node, key2) {
4988
5021
  const overrides = node?.userOverrides;
4989
5022
  if (!overrides || typeof overrides !== "object" || Array.isArray(overrides)) return null;
4990
- const value = overrides[key];
5023
+ const value = overrides[key2];
4991
5024
  return typeof value === "string" && value.trim() ? value.trim() : null;
4992
5025
  }
4993
- function readNodeReporter(node, key) {
4994
- const value = key === "platform" ? node?.reportedPlatform : node?.reportedArch;
5026
+ function readNodeReporter(node, key2) {
5027
+ const value = key2 === "platform" ? node?.reportedPlatform : node?.reportedArch;
4995
5028
  return typeof value === "string" && value.trim() ? value.trim() : null;
4996
5029
  }
4997
5030
  function buildMeshNodeCapabilityTags(node, providerType) {
@@ -5210,6 +5243,7 @@ function updateTaskStatus(meshId, taskId, status, opts) {
5210
5243
  if (!entry) return null;
5211
5244
  entry.status = status;
5212
5245
  MeshRuntimeStore.getInstance().updateQueueEntry(entry);
5246
+ if (status !== "assigned") endTaskDispatchInFlight(meshId, taskId);
5213
5247
  if (DEPENDENCY_FAILURE_TERMINALS.has(status)) propagateDependencyFailure(meshId, taskId);
5214
5248
  return entry;
5215
5249
  });
@@ -5234,6 +5268,7 @@ function cancelTask(meshId, taskId, opts) {
5234
5268
  entry.cancelledAt = now;
5235
5269
  if (opts?.reason) entry.cancelReason = opts.reason;
5236
5270
  MeshRuntimeStore.getInstance().updateQueueEntry(entry);
5271
+ endTaskDispatchInFlight(meshId, taskId);
5237
5272
  propagateDependencyFailure(meshId, taskId);
5238
5273
  return entry;
5239
5274
  });
@@ -5243,6 +5278,11 @@ function requeueTask(meshId, taskId, opts) {
5243
5278
  return withQueueLock(meshId, () => {
5244
5279
  const entry = MeshRuntimeStore.getInstance().findQueueEntryById(meshId, taskId);
5245
5280
  if (!entry) return null;
5281
+ if (!opts?.force && isTaskDispatchInFlight(meshId, taskId)) {
5282
+ 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.`);
5283
+ return entry;
5284
+ }
5285
+ endTaskDispatchInFlight(meshId, taskId);
5246
5286
  const currentCount = entry.requeueCount || 0;
5247
5287
  const maxRetries = opts?.maxRetries ?? entry.maxRetries ?? 1;
5248
5288
  if (!opts?.force && currentCount >= maxRetries) {
@@ -5287,6 +5327,7 @@ function reclaimStrandedAssignedTask(meshId, taskId, opts) {
5287
5327
  delete entry.dispatchTimestamp;
5288
5328
  entry.strandedReclaimCount = reclaims;
5289
5329
  entry.updatedAt = now;
5330
+ endTaskDispatchInFlight(meshId, taskId);
5290
5331
  if (reclaims > MAX_STRANDED_RECLAIMS) {
5291
5332
  entry.status = "failed";
5292
5333
  entry.cancelReason = `stranded_dispatch_unrecovered: reclaimed ${reclaims - 1} time(s) without a confirmed dispatch`;
@@ -5330,6 +5371,7 @@ function updateSessionTaskStatus(meshId, sessionId, status, opts) {
5330
5371
  }
5331
5372
  entry.status = status;
5332
5373
  store.updateQueueEntry(entry);
5374
+ if (status !== "assigned") endTaskDispatchInFlight(meshId, entry.id);
5333
5375
  if (DEPENDENCY_FAILURE_TERMINALS.has(status)) propagateDependencyFailure(meshId, entry.id);
5334
5376
  return entry;
5335
5377
  });
@@ -5444,6 +5486,7 @@ var init_mesh_work_queue = __esm({
5444
5486
  init_logger();
5445
5487
  init_mesh_ledger();
5446
5488
  init_mesh_delivery_policy();
5489
+ init_mesh_task_inflight();
5447
5490
  ACTIVE_MESH_QUEUE_STATUSES = ["pending", "assigned"];
5448
5491
  HISTORICAL_MESH_QUEUE_STATUSES = ["completed", "failed", "cancelled"];
5449
5492
  MESH_TASK_MODES = ["code_change", "validation", "live_debug_readonly", "launch_app", "convergence"];
@@ -7509,7 +7552,7 @@ function resolveNodeEvidence(nodeId, ledgerEntries) {
7509
7552
  timestamp: entry.timestamp,
7510
7553
  ...entry.sessionId ? { sessionId: entry.sessionId } : {},
7511
7554
  bootstrap: readRecord3(validationSummary?.bootstrap),
7512
- validation: validationSummary ? Object.fromEntries(Object.entries(validationSummary).filter(([key]) => key !== "bootstrap")) : null,
7555
+ validation: validationSummary ? Object.fromEntries(Object.entries(validationSummary).filter(([key2]) => key2 !== "bootstrap")) : null,
7513
7556
  checkpoint: readRecord3(result?.checkpoint),
7514
7557
  worker: null,
7515
7558
  ...readRecord3(payload.finalBranchConvergenceState) ?? readRecord3(result?.finalBranchConvergenceState) ? { finalBranchConvergenceState: readRecord3(payload.finalBranchConvergenceState) ?? readRecord3(result?.finalBranchConvergenceState) } : {},
@@ -7774,7 +7817,7 @@ function resolveMeshCoordinatorSetup(options) {
7774
7817
  };
7775
7818
  }
7776
7819
  function renderMeshCoordinatorTemplate(template, values) {
7777
- return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand|adhdevMcpArgs)\s*\}\}/g, (_, key) => values[key] || "");
7820
+ return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand|adhdevMcpArgs)\s*\}\}/g, (_, key2) => values[key2] || "");
7778
7821
  }
7779
7822
  function replaceLegacyCliCommandMcpArgs(command, args) {
7780
7823
  return command.replace(
@@ -7783,9 +7826,9 @@ function replaceLegacyCliCommandMcpArgs(command, args) {
7783
7826
  );
7784
7827
  }
7785
7828
  function resolveHermesCoordinatorHome(meshId, workspace) {
7786
- const key = `${meshId || "mesh"}
7829
+ const key2 = `${meshId || "mesh"}
7787
7830
  ${(0, import_node_path.resolve)(workspace || os4.tmpdir())}`;
7788
- const hash = shortHash(key);
7831
+ const hash = shortHash(key2);
7789
7832
  return (0, import_node_path.join)(os4.tmpdir(), `adhdev-hermes-mesh-coordinator-${hash}`);
7790
7833
  }
7791
7834
  function resolveMcpConfigPath(configPath, workspace) {
@@ -8256,9 +8299,9 @@ function suggestMeshRefineConfig(mesh, workspace) {
8256
8299
  const seen = /* @__PURE__ */ new Set();
8257
8300
  const suggestions = [];
8258
8301
  for (const entry of [...collectProjectContextSuggestions(mesh), ...collectPackageScriptSuggestions(workspace)]) {
8259
- const key = `${entry.command} ${(entry.args || []).join(" ")}`.trim();
8260
- if (seen.has(key)) continue;
8261
- seen.add(key);
8302
+ const key2 = `${entry.command} ${(entry.args || []).join(" ")}`.trim();
8303
+ if (seen.has(key2)) continue;
8304
+ seen.add(key2);
8262
8305
  suggestions.push(entry);
8263
8306
  }
8264
8307
  return {
@@ -11752,6 +11795,9 @@ var init_mesh_warmup_deadline = __esm({
11752
11795
  });
11753
11796
 
11754
11797
  // src/mesh/mesh-queue-assignment.ts
11798
+ function localCoordinatorDaemonId() {
11799
+ return canonicalDaemonId(readNonEmptyString2(loadConfig().machineId));
11800
+ }
11755
11801
  function __resetIdleAutoFastForwardForTests() {
11756
11802
  idleAutoFastForwardLastAttempt.clear();
11757
11803
  }
@@ -11837,6 +11883,7 @@ function deliverTaskToSession(dispatchThunk, ctx, warmup) {
11837
11883
  if (timer) clearTimeout(timer);
11838
11884
  LOG.error("MeshQueue", `Failed to dispatch task via ${ctx.transport} to node ${ctx.nodeId}: ${e?.message}`);
11839
11885
  updateSessionDeliveryStatus(delivery.id, "failed", { lastError: e?.message, incrementAttempt: true });
11886
+ endTaskDispatchInFlight(ctx.meshId, ctx.task.id);
11840
11887
  updateTaskStatus(ctx.meshId, ctx.task.id, "pending");
11841
11888
  try {
11842
11889
  appendLedgerEntry(ctx.meshId, {
@@ -11910,10 +11957,11 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
11910
11957
  return false;
11911
11958
  }
11912
11959
  LOG.info("MeshQueue", `Node ${nodeId} (${sessionId}) pulled task ${task.id}`);
11960
+ beginTaskDispatchInFlight(meshId, task.id);
11913
11961
  if (node?.daemonId && components.dispatchMeshCommand) {
11914
11962
  const isLocalNode = components.cliManager.adapters.has(sessionId);
11915
11963
  if (!isLocalNode) {
11916
- const localDaemonIdForDispatch = readNonEmptyString2(loadConfig().machineId) || void 0;
11964
+ const localDaemonIdForDispatch = localCoordinatorDaemonId();
11917
11965
  const sourceCoordinatorSessionId = readNonEmptyString2(task.sourceCoordinatorSessionId) || void 0;
11918
11966
  const dispatchMeshCommand = components.dispatchMeshCommand;
11919
11967
  const remoteDaemonId = node.daemonId;
@@ -11952,7 +12000,7 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
11952
12000
  try {
11953
12001
  const inst = components.instanceManager.getInstance(sessionId);
11954
12002
  if (inst && typeof inst.updateSettings === "function") {
11955
- const localDaemonId = readNonEmptyString2(loadConfig().machineId);
12003
+ const localDaemonId = localCoordinatorDaemonId();
11956
12004
  const localSourceCoordinatorSessionId = readNonEmptyString2(task.sourceCoordinatorSessionId);
11957
12005
  inst.updateSettings({
11958
12006
  meshNodeFor: meshId,
@@ -11977,7 +12025,7 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
11977
12025
  meshId,
11978
12026
  nodeId,
11979
12027
  taskId: task.id,
11980
- ...readNonEmptyString2(loadConfig().machineId) ? { coordinatorDaemonId: readNonEmptyString2(loadConfig().machineId) } : {},
12028
+ ...localCoordinatorDaemonId() ? { coordinatorDaemonId: localCoordinatorDaemonId() } : {},
11981
12029
  ...readNonEmptyString2(task.sourceCoordinatorSessionId) ? { coordinatorSessionId: readNonEmptyString2(task.sourceCoordinatorSessionId) } : {}
11982
12030
  }
11983
12031
  }),
@@ -11989,7 +12037,7 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
11989
12037
  task,
11990
12038
  transport: "local",
11991
12039
  ...readNonEmptyString2(task.sourceCoordinatorSessionId) ? { sourceCoordinatorSessionId: readNonEmptyString2(task.sourceCoordinatorSessionId) } : {},
11992
- ...readNonEmptyString2(loadConfig().machineId) ? { sourceCoordinatorDaemonId: readNonEmptyString2(loadConfig().machineId) } : {}
12040
+ ...localCoordinatorDaemonId() ? { sourceCoordinatorDaemonId: localCoordinatorDaemonId() } : {}
11993
12041
  }
11994
12042
  );
11995
12043
  return true;
@@ -12071,8 +12119,8 @@ function notifyCoordinatorOfActionableSkip(meshId, taskId, reason, nodeId) {
12071
12119
  }
12072
12120
  function sweepExpiredCooldowns() {
12073
12121
  const now = Date.now();
12074
- for (const [key, until] of autoLaunchCooldownUntil) {
12075
- if (now >= until) autoLaunchCooldownUntil.delete(key);
12122
+ for (const [key2, until] of autoLaunchCooldownUntil) {
12123
+ if (now >= until) autoLaunchCooldownUntil.delete(key2);
12076
12124
  }
12077
12125
  }
12078
12126
  function normalizeProviderPriority(policy) {
@@ -12118,7 +12166,7 @@ function nodeHasActiveMeshWork(components, meshId, nodeId, currentSessionId) {
12118
12166
  const settings = state.settings || {};
12119
12167
  if (readNonEmptyString2(settings.meshNodeFor) !== meshId) return false;
12120
12168
  const instNodeId = readNonEmptyString2(settings.meshNodeId) || readNonEmptyString2(settings.nodeId);
12121
- if (instNodeId !== nodeId) return false;
12169
+ if (!daemonIdsEquivalent(instNodeId, nodeId)) return false;
12122
12170
  const sessionId = readNonEmptyString2(state.instanceId);
12123
12171
  if (currentSessionId && sessionId === currentSessionId && isIdleSessionState(state)) return false;
12124
12172
  return sessionStateLooksActive(state);
@@ -12150,7 +12198,7 @@ function resolveAutoLaunchTarget(components, node) {
12150
12198
  const daemonId = readNonEmptyString2(node?.daemonId);
12151
12199
  if (!daemonId) return { mode: "skip", reason: "remote_auto_launch_unsupported" };
12152
12200
  if (!components.dispatchMeshCommand) return { mode: "skip", reason: "remote_auto_launch_unsupported" };
12153
- const coordinatorDaemonId = readNonEmptyString2(loadConfig().machineId);
12201
+ const coordinatorDaemonId = localCoordinatorDaemonId();
12154
12202
  if (!coordinatorDaemonId) return { mode: "skip", reason: "remote_auto_launch_no_coordinator_daemon_id" };
12155
12203
  return { mode: "remote", daemonId, coordinatorDaemonId };
12156
12204
  }
@@ -12161,7 +12209,7 @@ function activeReadonlyAssignedCount(meshId) {
12161
12209
  return getQueue(meshId, { status: ["assigned"] }).filter(isTaskReadonly).length;
12162
12210
  }
12163
12211
  function nodeHasActiveAssignment(meshId, nodeId) {
12164
- return getQueue(meshId, { status: ["assigned"] }).some((task) => task.assignedNodeId === nodeId);
12212
+ return getQueue(meshId, { status: ["assigned"] }).some((task) => daemonIdsEquivalent(task.assignedNodeId, nodeId));
12165
12213
  }
12166
12214
  function nodeActiveLoad(meshId, nodeId) {
12167
12215
  return MeshRuntimeStore.getInstance().nodeActiveAssignmentCount(meshId, nodeId);
@@ -12191,7 +12239,7 @@ function orderEligibleNodes(meshId, strategy, nodes, opts) {
12191
12239
  });
12192
12240
  }
12193
12241
  function activeProviderAssignedCount(meshId, nodeId, providerType) {
12194
- return getQueue(meshId, { status: ["assigned"] }).filter((task) => task.assignedNodeId === nodeId && task.assignedProviderType === providerType).length;
12242
+ return getQueue(meshId, { status: ["assigned"] }).filter((task) => daemonIdsEquivalent(task.assignedNodeId, nodeId) && task.assignedProviderType === providerType).length;
12195
12243
  }
12196
12244
  function sessionHasActiveAssignment(meshId, sessionId) {
12197
12245
  if (getQueue(meshId, { status: ["assigned"] }).some((task) => task.assignedSessionId === sessionId)) {
@@ -12210,7 +12258,7 @@ function liveSessionCountForNode(components, meshId, nodeId) {
12210
12258
  const settings = state.settings || {};
12211
12259
  if (readNonEmptyString2(settings.meshNodeFor) !== meshId) return false;
12212
12260
  const instNodeId = readNonEmptyString2(settings.meshNodeId) || readNonEmptyString2(settings.nodeId);
12213
- if (instNodeId !== nodeId) return false;
12261
+ if (!daemonIdsEquivalent(instNodeId, nodeId)) return false;
12214
12262
  const status = readNonEmptyString2(state.status).toLowerCase();
12215
12263
  return !isTerminalSessionStatus(status);
12216
12264
  }).length;
@@ -12729,6 +12777,7 @@ var init_mesh_queue_assignment = __esm({
12729
12777
  init_mesh_events_utils();
12730
12778
  init_mesh_events_pending();
12731
12779
  init_worktree_bootstrap_config();
12780
+ init_mesh_task_inflight();
12732
12781
  IDLE_AUTO_FAST_FORWARD_THROTTLE_MS = 30 * 60 * 1e3;
12733
12782
  idleAutoFastForwardLastAttempt = /* @__PURE__ */ new Map();
12734
12783
  DISPATCH_CONFIRM_TIMEOUT_MS = 12e4;
@@ -12829,8 +12878,8 @@ function recordUnroutableDelegateEvent(routing, eventName) {
12829
12878
  if (last !== void 0 && now - last < UNROUTABLE_DIAGNOSTIC_DEDUP_MS) return false;
12830
12879
  recentUnroutableDiagnostics.set(dedupKey, now);
12831
12880
  if (recentUnroutableDiagnostics.size > 256) {
12832
- for (const [key, ts2] of recentUnroutableDiagnostics) {
12833
- if (now - ts2 >= UNROUTABLE_DIAGNOSTIC_DEDUP_MS) recentUnroutableDiagnostics.delete(key);
12881
+ for (const [key2, ts2] of recentUnroutableDiagnostics) {
12882
+ if (now - ts2 >= UNROUTABLE_DIAGNOSTIC_DEDUP_MS) recentUnroutableDiagnostics.delete(key2);
12834
12883
  }
12835
12884
  }
12836
12885
  try {
@@ -13092,9 +13141,9 @@ async function updateDarwinMemoryCache() {
13092
13141
  for (const line of stdout.split("\n")) {
13093
13142
  const m = line.match(/^\s*Pages\s+([^:]+):\s+([\d,]+)\s*\.?/);
13094
13143
  if (!m) continue;
13095
- const key = m[1].trim().toLowerCase().replace(/\s+/g, "_");
13144
+ const key2 = m[1].trim().toLowerCase().replace(/\s+/g, "_");
13096
13145
  const n = parseInt(m[2].replace(/,/g, ""), 10);
13097
- if (!Number.isNaN(n)) counts[key] = n;
13146
+ if (!Number.isNaN(n)) counts[key2] = n;
13098
13147
  }
13099
13148
  const free = counts["free"] ?? 0;
13100
13149
  const inactive = counts["inactive"] ?? 0;
@@ -13321,7 +13370,7 @@ function trimStructuredStrings(value, maxChars) {
13321
13370
  if (Array.isArray(value)) return value.map((item) => trimStructuredStrings(item, maxChars));
13322
13371
  if (!value || typeof value !== "object") return value;
13323
13372
  return Object.fromEntries(
13324
- Object.entries(value).map(([key, nested]) => [key, trimStructuredStrings(nested, maxChars)])
13373
+ Object.entries(value).map(([key2, nested]) => [key2, trimStructuredStrings(nested, maxChars)])
13325
13374
  );
13326
13375
  }
13327
13376
  function estimateBytes(value) {
@@ -13912,9 +13961,9 @@ function readMessageMeta(message) {
13912
13961
  function readStringField(value) {
13913
13962
  return typeof value === "string" ? value.trim().toLowerCase() : "";
13914
13963
  }
13915
- function readRecordField(message, meta, key) {
13964
+ function readRecordField(message, meta, key2) {
13916
13965
  const record = message;
13917
- return record[key] ?? meta?.[key];
13966
+ return record[key2] ?? meta?.[key2];
13918
13967
  }
13919
13968
  function readVisibilityField(message, meta) {
13920
13969
  return readStringField(readRecordField(message, meta, "visibility"));
@@ -13925,7 +13974,7 @@ function readTranscriptVisibilityField(message, meta) {
13925
13974
  }
13926
13975
  function hasBooleanMarker(message, meta, keys) {
13927
13976
  const record = message;
13928
- return keys.some((key) => record[key] === true || meta?.[key] === true);
13977
+ return keys.some((key2) => record[key2] === true || meta?.[key2] === true);
13929
13978
  }
13930
13979
  function isActivityKind(kind) {
13931
13980
  return kind === "thought" || kind === "tool" || kind === "terminal";
@@ -14117,9 +14166,9 @@ function extractProviderControlValues(controls, data) {
14117
14166
  const values = {};
14118
14167
  const explicit = data.controlValues;
14119
14168
  if (explicit && typeof explicit === "object") {
14120
- for (const [key, value] of Object.entries(explicit)) {
14169
+ for (const [key2, value] of Object.entries(explicit)) {
14121
14170
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
14122
- values[key] = value;
14171
+ values[key2] = value;
14123
14172
  }
14124
14173
  }
14125
14174
  }
@@ -14583,26 +14632,26 @@ function getGitSummaryForWorkspace(workspace, options) {
14583
14632
  if (!workspace) return void 0;
14584
14633
  return options.getGitSummaryForWorkspace?.(workspace) || void 0;
14585
14634
  }
14586
- function findCdpManager(cdpManagers, key) {
14587
- const exact = cdpManagers.get(key);
14635
+ function findCdpManager(cdpManagers, key2) {
14636
+ const exact = cdpManagers.get(key2);
14588
14637
  if (exact) return exact.isConnected ? exact : null;
14589
- const prefix = key + "_";
14638
+ const prefix = key2 + "_";
14590
14639
  const matches = [...cdpManagers.entries()].filter(([k, m]) => m.isConnected && k.startsWith(prefix));
14591
14640
  if (matches.length === 1) return matches[0][1];
14592
14641
  return null;
14593
14642
  }
14594
- function hasCdpManager(cdpManagers, key) {
14595
- if (cdpManagers.has(key)) return true;
14596
- const prefix = key + "_";
14643
+ function hasCdpManager(cdpManagers, key2) {
14644
+ if (cdpManagers.has(key2)) return true;
14645
+ const prefix = key2 + "_";
14597
14646
  for (const k of cdpManagers.keys()) {
14598
14647
  if (k.startsWith(prefix)) return true;
14599
14648
  }
14600
14649
  return false;
14601
14650
  }
14602
- function isCdpConnected(cdpManagers, key) {
14603
- const exact = cdpManagers.get(key);
14651
+ function isCdpConnected(cdpManagers, key2) {
14652
+ const exact = cdpManagers.get(key2);
14604
14653
  if (exact?.isConnected) return true;
14605
- const prefix = key + "_";
14654
+ const prefix = key2 + "_";
14606
14655
  for (const [k, m] of cdpManagers.entries()) {
14607
14656
  if (m.isConnected && k.startsWith(prefix)) return true;
14608
14657
  }
@@ -16498,9 +16547,9 @@ function recordHeldTerminalEventsToLedger(meshId, drainDaemonIds, reason, heldFo
16498
16547
  for (const event of pending) {
16499
16548
  if (!shouldForceInjectMeshEvent(event.event)) continue;
16500
16549
  const fingerprint = buildPendingEventFingerprint(event);
16501
- const key = `${meshId}::${fingerprint || `${event.event}::${event.nodeId || ""}::${event.queuedAt}`}`;
16502
- if (heldEventLedgerRecorded.has(key)) continue;
16503
- heldEventLedgerRecorded.add(key);
16550
+ const key2 = `${meshId}::${fingerprint || `${event.event}::${event.nodeId || ""}::${event.queuedAt}`}`;
16551
+ if (heldEventLedgerRecorded.has(key2)) continue;
16552
+ heldEventLedgerRecorded.add(key2);
16504
16553
  const finalSummary = readMeshCompletionSummary(event.metadataEvent);
16505
16554
  try {
16506
16555
  appendLedgerEntry(meshId, {
@@ -16521,7 +16570,7 @@ function recordHeldTerminalEventsToLedger(meshId, drainDaemonIds, reason, heldFo
16521
16570
  });
16522
16571
  LOG.info("MeshReconcile", `Ledger-recorded held ${event.event} for mesh ${meshId} (reason ${reason}) \u2014 recoverable from ledger`);
16523
16572
  } catch (e) {
16524
- heldEventLedgerRecorded.delete(key);
16573
+ heldEventLedgerRecorded.delete(key2);
16525
16574
  LOG.warn("MeshReconcile", `Failed to ledger-record held ${event.event} for mesh ${meshId}: ${e?.message || e}`);
16526
16575
  }
16527
16576
  }
@@ -16986,9 +17035,9 @@ async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds,
16986
17035
  const activeTaskKeys = new Set(
16987
17036
  dispatches.map((d) => readNonEmptyString2(d.taskId)).filter(Boolean).map((taskId) => inFlightSynthKey(mesh.id, taskId))
16988
17037
  );
16989
- for (const key of inFlightAckedHoldState.keys()) {
16990
- if (key.startsWith(`${mesh.id}::`) && !activeTaskKeys.has(key)) {
16991
- inFlightAckedHoldState.delete(key);
17038
+ for (const key2 of inFlightAckedHoldState.keys()) {
17039
+ if (key2.startsWith(`${mesh.id}::`) && !activeTaskKeys.has(key2)) {
17040
+ inFlightAckedHoldState.delete(key2);
16992
17041
  }
16993
17042
  }
16994
17043
  const dispatchMeshCommand = components.dispatchMeshCommand;
@@ -18575,8 +18624,8 @@ function extractButtonsFromRule(rule, hay) {
18575
18624
  label += " " + next.trim();
18576
18625
  j += 1;
18577
18626
  }
18578
- const key = keyTemplate.replace(/\{index\}/g, String(idx));
18579
- buttons.push({ index: idx, label, key, current });
18627
+ const key2 = keyTemplate.replace(/\{index\}/g, String(idx));
18628
+ buttons.push({ index: idx, label, key: key2, current });
18580
18629
  i = j - 1;
18581
18630
  }
18582
18631
  } else {
@@ -18586,8 +18635,8 @@ function extractButtonsFromRule(rule, hay) {
18586
18635
  const idx = Number(m[1]);
18587
18636
  const label = String(m[2] ?? "").trim();
18588
18637
  if (!Number.isFinite(idx) || idx <= 0 || !label) continue;
18589
- const key = keyTemplate.replace(/\{index\}/g, String(idx));
18590
- buttons.push({ index: idx, label, key, current: hasCursorMarker(m[0]) });
18638
+ const key2 = keyTemplate.replace(/\{index\}/g, String(idx));
18639
+ buttons.push({ index: idx, label, key: key2, current: hasCursorMarker(m[0]) });
18591
18640
  }
18592
18641
  }
18593
18642
  const block2 = lastContiguousNumberedBlock(buttons);
@@ -18667,12 +18716,12 @@ function evalCond(cond, sections, fullScreen, cursor, prevLines, clock, legacyTr
18667
18716
  return { kind: "elapsed", result, detail: `elapsed ${age}ms / ${cond.elapsed_ms}ms`, remainingMs };
18668
18717
  }
18669
18718
  if (isStable(cond)) {
18670
- const key = regionKey(cond.cursor_above);
18671
- const lastChanged = clock.regionLastChangedAt.get(key) ?? clock.stateEnteredAt;
18719
+ const key2 = regionKey(cond.cursor_above);
18720
+ const lastChanged = clock.regionLastChangedAt.get(key2) ?? clock.stateEnteredAt;
18672
18721
  const stableFor = clock.now - lastChanged;
18673
18722
  const result = stableFor >= cond.stable_ms;
18674
18723
  const remainingMs = result ? 0 : cond.stable_ms - stableFor;
18675
- const where = key === WHOLE_SCREEN ? "screen" : `cursor_above=${cond.cursor_above}`;
18724
+ const where = key2 === WHOLE_SCREEN ? "screen" : `cursor_above=${cond.cursor_above}`;
18676
18725
  return { kind: "stable", result, detail: `stable ${where} ${stableFor}ms / ${cond.stable_ms}ms`, remainingMs };
18677
18726
  }
18678
18727
  if (isRegex(cond) || isChanged(cond)) {
@@ -22613,16 +22662,16 @@ function normalizeModuleName(request) {
22613
22662
  }
22614
22663
  function buildFsShim() {
22615
22664
  const shim = {};
22616
- for (const key of FS_READ_ONLY_MEMBERS) {
22617
- if (key === "promises") continue;
22618
- const real = nodeFs[key];
22619
- if (real !== void 0) shim[key] = real;
22665
+ for (const key2 of FS_READ_ONLY_MEMBERS) {
22666
+ if (key2 === "promises") continue;
22667
+ const real = nodeFs[key2];
22668
+ if (real !== void 0) shim[key2] = real;
22620
22669
  }
22621
22670
  const realPromises = nodeFs.promises || {};
22622
22671
  const promisesShim = {};
22623
- for (const key of FS_PROMISES_READ_ONLY_MEMBERS) {
22624
- const real = realPromises[key];
22625
- if (real !== void 0) promisesShim[key] = real;
22672
+ for (const key2 of FS_PROMISES_READ_ONLY_MEMBERS) {
22673
+ const real = realPromises[key2];
22674
+ if (real !== void 0) promisesShim[key2] = real;
22626
22675
  }
22627
22676
  shim.promises = promisesShim;
22628
22677
  return shim;
@@ -22705,10 +22754,10 @@ function _uninstallProviderProcessShimForTest() {
22705
22754
  function buildProcessShim() {
22706
22755
  const real = globalThis.process;
22707
22756
  const shim = /* @__PURE__ */ Object.create(null);
22708
- for (const key of Object.keys(real)) {
22709
- if (DANGEROUS_PROCESS_METHODS.has(String(key))) continue;
22757
+ for (const key2 of Object.keys(real)) {
22758
+ if (DANGEROUS_PROCESS_METHODS.has(String(key2))) continue;
22710
22759
  try {
22711
- shim[key] = real[key];
22760
+ shim[key2] = real[key2];
22712
22761
  } catch {
22713
22762
  }
22714
22763
  }
@@ -23029,6 +23078,7 @@ __export(index_exports, {
23029
23078
  buildToolChatMessage: () => buildToolChatMessage,
23030
23079
  buildUserChatMessage: () => buildUserChatMessage,
23031
23080
  cancelTask: () => cancelTask,
23081
+ canonicalDaemonId: () => canonicalDaemonId,
23032
23082
  claimNextTask: () => claimNextTask,
23033
23083
  classifyChatMessageVisibility: () => classifyChatMessageVisibility,
23034
23084
  classifyHotChatSessionsForSubscriptionFlush: () => classifyHotChatSessionsForSubscriptionFlush,
@@ -23893,10 +23943,10 @@ var GitWorkspaceMonitor = class {
23893
23943
  const compactSummary = createGitCompactSummary(status, diffSummary);
23894
23944
  const timestamp = this.now();
23895
23945
  const seq = ++this.seq;
23896
- const key = this.keyForWorkspace(normalized.workspace);
23946
+ const key2 = this.keyForWorkspace(normalized.workspace);
23897
23947
  const update = {
23898
23948
  topic: "workspace.git",
23899
- key,
23949
+ key: key2,
23900
23950
  workspace: normalized.workspace,
23901
23951
  status,
23902
23952
  diffSummary,
@@ -23904,7 +23954,7 @@ var GitWorkspaceMonitor = class {
23904
23954
  timestamp
23905
23955
  };
23906
23956
  const cacheEntry = {
23907
- key,
23957
+ key: key2,
23908
23958
  workspace: normalized.workspace,
23909
23959
  status,
23910
23960
  diffSummary,
@@ -24048,11 +24098,11 @@ function validateRepoPath(args) {
24048
24098
  }
24049
24099
  return { path: args.path.trim() };
24050
24100
  }
24051
- function validateSnapshotId(args, key) {
24052
- if (typeof args?.[key] !== "string" || !args[key].trim()) {
24053
- return failure("invalid_args", `${key} must be a non-empty string`);
24101
+ function validateSnapshotId(args, key2) {
24102
+ if (typeof args?.[key2] !== "string" || !args[key2].trim()) {
24103
+ return failure("invalid_args", `${key2} must be a non-empty string`);
24054
24104
  }
24055
- return args[key].trim();
24105
+ return args[key2].trim();
24056
24106
  }
24057
24107
  function parseSnapshotReason(args) {
24058
24108
  if (args?.reason === void 0 || args?.reason === null || args?.reason === "") {
@@ -26464,10 +26514,10 @@ var StatusMonitor = class {
26464
26514
  return events;
26465
26515
  }
26466
26516
  /** Cooldown check — prevent sending the same notification too frequently */
26467
- shouldAlert(key, now) {
26468
- const last = this.lastAlertTime.get(key) || 0;
26517
+ shouldAlert(key2, now) {
26518
+ const last = this.lastAlertTime.get(key2) || 0;
26469
26519
  if (now - last > this.config.alertCooldownSec * 1e3) {
26470
- this.lastAlertTime.set(key, now);
26520
+ this.lastAlertTime.set(key2, now);
26471
26521
  return true;
26472
26522
  }
26473
26523
  return false;
@@ -26515,16 +26565,16 @@ var savedHistoryBackgroundRefresh = /* @__PURE__ */ new Set();
26515
26565
  var savedHistoryRollupInFlight = /* @__PURE__ */ new Set();
26516
26566
  var BOUNDED_TAIL_CACHE_MAX_ENTRIES = 64;
26517
26567
  var boundedTailReadCache = /* @__PURE__ */ new Map();
26518
- function readBoundedTailCache(key, signature) {
26519
- const cached3 = boundedTailReadCache.get(key);
26568
+ function readBoundedTailCache(key2, signature) {
26569
+ const cached3 = boundedTailReadCache.get(key2);
26520
26570
  if (!cached3 || cached3.signature !== signature) return null;
26521
- boundedTailReadCache.delete(key);
26522
- boundedTailReadCache.set(key, cached3);
26571
+ boundedTailReadCache.delete(key2);
26572
+ boundedTailReadCache.set(key2, cached3);
26523
26573
  return cached3.result;
26524
26574
  }
26525
- function writeBoundedTailCache(key, signature, result) {
26526
- boundedTailReadCache.delete(key);
26527
- boundedTailReadCache.set(key, { signature, result });
26575
+ function writeBoundedTailCache(key2, signature, result) {
26576
+ boundedTailReadCache.delete(key2);
26577
+ boundedTailReadCache.set(key2, { signature, result });
26528
26578
  while (boundedTailReadCache.size > BOUNDED_TAIL_CACHE_MAX_ENTRIES) {
26529
26579
  const oldest = boundedTailReadCache.keys().next().value;
26530
26580
  if (oldest === void 0) break;
@@ -26960,21 +27010,21 @@ function shouldScheduleSavedHistoryRollupForSignature(signature) {
26960
27010
  return shouldScheduleSavedHistoryRollup(size);
26961
27011
  }
26962
27012
  function scheduleSavedHistoryRollup(agentType, historySessionId) {
26963
- const key = `${agentType}:${historySessionId}`;
26964
- if (!historySessionId || savedHistoryRollupInFlight.has(key)) return;
26965
- savedHistoryRollupInFlight.add(key);
27013
+ const key2 = `${agentType}:${historySessionId}`;
27014
+ if (!historySessionId || savedHistoryRollupInFlight.has(key2)) return;
27015
+ savedHistoryRollupInFlight.add(key2);
26966
27016
  setTimeout(() => {
26967
27017
  try {
26968
27018
  new ChatHistoryWriter().compactHistorySession(agentType, historySessionId);
26969
27019
  } finally {
26970
- savedHistoryRollupInFlight.delete(key);
27020
+ savedHistoryRollupInFlight.delete(key2);
26971
27021
  }
26972
27022
  }, 0);
26973
27023
  }
26974
27024
  function scheduleSavedHistoryBackgroundRefresh(agentType, dir) {
26975
- const key = `${agentType}:${dir}`;
26976
- if (savedHistoryBackgroundRefresh.has(key)) return;
26977
- savedHistoryBackgroundRefresh.add(key);
27025
+ const key2 = `${agentType}:${dir}`;
27026
+ if (savedHistoryBackgroundRefresh.has(key2)) return;
27027
+ savedHistoryBackgroundRefresh.add(key2);
26978
27028
  setTimeout(() => {
26979
27029
  try {
26980
27030
  if (!fs6.existsSync(dir)) return;
@@ -26994,7 +27044,7 @@ function scheduleSavedHistoryBackgroundRefresh(agentType, dir) {
26994
27044
  }
26995
27045
  } catch {
26996
27046
  } finally {
26997
- savedHistoryBackgroundRefresh.delete(key);
27047
+ savedHistoryBackgroundRefresh.delete(key2);
26998
27048
  }
26999
27049
  }, 0);
27000
27050
  }
@@ -27760,14 +27810,14 @@ function rewriteCanonicalSavedHistory(agentType, historySessionId, records) {
27760
27810
  return false;
27761
27811
  }
27762
27812
  }
27763
- function getNativeHistoryScriptName(canonicalHistory, key) {
27764
- const configured = canonicalHistory?.scripts?.[key];
27813
+ function getNativeHistoryScriptName(canonicalHistory, key2) {
27814
+ const configured = canonicalHistory?.scripts?.[key2];
27765
27815
  if (typeof configured === "string" && configured.trim()) return configured.trim();
27766
- return key === "readSession" ? "readNativeHistory" : "listNativeHistory";
27816
+ return key2 === "readSession" ? "readNativeHistory" : "listNativeHistory";
27767
27817
  }
27768
- function getProviderNativeHistoryScript(scripts, canonicalHistory, key) {
27818
+ function getProviderNativeHistoryScript(scripts, canonicalHistory, key2) {
27769
27819
  if (!canonicalHistory?.scripts) return null;
27770
- const fn = scripts?.[getNativeHistoryScriptName(canonicalHistory, key)];
27820
+ const fn = scripts?.[getNativeHistoryScriptName(canonicalHistory, key2)];
27771
27821
  return typeof fn === "function" ? fn : null;
27772
27822
  }
27773
27823
  function normalizeProviderNativeHistoryRecords(agentType, historySessionId, records) {
@@ -28501,11 +28551,11 @@ function validateControlValues(controlValues, source) {
28501
28551
  throw new Error(`${source}: controlValues must be an object when provided`);
28502
28552
  }
28503
28553
  const normalized = {};
28504
- for (const [key, value] of Object.entries(controlValues)) {
28554
+ for (const [key2, value] of Object.entries(controlValues)) {
28505
28555
  if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
28506
- throw new Error(`${source}: controlValues.${key} must be string, number, or boolean`);
28556
+ throw new Error(`${source}: controlValues.${key2} must be string, number, or boolean`);
28507
28557
  }
28508
- normalized[key] = value;
28558
+ normalized[key2] = value;
28509
28559
  }
28510
28560
  return normalized;
28511
28561
  }
@@ -29258,7 +29308,7 @@ var DaemonCdpScanner = class {
29258
29308
  for (const [ide, ports] of Object.entries(portMap)) {
29259
29309
  const primaryPort = ports[0];
29260
29310
  const alreadyConnected = [...this.ctx.cdpManagers.entries()].some(
29261
- ([key, m]) => m.isConnected && (key === ide || key.startsWith(ide + "_"))
29311
+ ([key2, m]) => m.isConnected && (key2 === ide || key2.startsWith(ide + "_"))
29262
29312
  );
29263
29313
  if (alreadyConnected) continue;
29264
29314
  if (this.opts.multiWindow) {
@@ -29432,8 +29482,8 @@ var DaemonCdpInitializer = class {
29432
29482
  for (let i = 0; i < targets.length; i++) {
29433
29483
  const target = targets[i];
29434
29484
  let alreadyTracked = false;
29435
- for (const [key, m] of cdpManagers.entries()) {
29436
- if ((key === ide || key.startsWith(`${ide}_`)) && m.targetId === target.id) {
29485
+ for (const [key2, m] of cdpManagers.entries()) {
29486
+ if ((key2 === ide || key2.startsWith(`${ide}_`)) && m.targetId === target.id) {
29437
29487
  alreadyTracked = true;
29438
29488
  break;
29439
29489
  }
@@ -29465,29 +29515,29 @@ var DaemonCdpInitializer = class {
29465
29515
  async pruneStaleManagers(port, ide, targets) {
29466
29516
  const trackedTargetIds = new Set(targets.map((target) => target.id));
29467
29517
  const removals = [];
29468
- for (const [key, manager] of this.config.cdpManagers.entries()) {
29469
- if (!(key === ide || key.startsWith(`${ide}_`))) continue;
29518
+ for (const [key2, manager] of this.config.cdpManagers.entries()) {
29519
+ if (!(key2 === ide || key2.startsWith(`${ide}_`))) continue;
29470
29520
  if (manager.getPort() !== port) continue;
29471
29521
  if (targets.length === 0) {
29472
- removals.push({ key, manager, reason: "ide_closed" });
29522
+ removals.push({ key: key2, manager, reason: "ide_closed" });
29473
29523
  continue;
29474
29524
  }
29475
29525
  if (manager.targetId && !trackedTargetIds.has(manager.targetId)) {
29476
- removals.push({ key, manager, reason: "target_closed" });
29526
+ removals.push({ key: key2, manager, reason: "target_closed" });
29477
29527
  continue;
29478
29528
  }
29479
- if (key === ide && !manager.targetId && targets.length > 1) {
29480
- removals.push({ key, manager, reason: "target_rekeyed" });
29529
+ if (key2 === ide && !manager.targetId && targets.length > 1) {
29530
+ removals.push({ key: key2, manager, reason: "target_rekeyed" });
29481
29531
  }
29482
29532
  }
29483
- for (const { key, manager, reason } of removals) {
29533
+ for (const { key: key2, manager, reason } of removals) {
29484
29534
  try {
29485
29535
  manager.disconnect();
29486
29536
  } catch {
29487
29537
  }
29488
- this.config.cdpManagers.delete(key);
29489
- LOG.info("IDE", `Detached window: ${key} (${reason})`);
29490
- await this.config.onDisconnected?.(ide, manager, key, reason);
29538
+ this.config.cdpManagers.delete(key2);
29539
+ LOG.info("IDE", `Detached window: ${key2} (${reason})`);
29540
+ await this.config.onDisconnected?.(ide, manager, key2, reason);
29491
29541
  }
29492
29542
  }
29493
29543
  // ─── Periodic scanning ───
@@ -29813,7 +29863,7 @@ function sanitizeTraceValue(value, traceContent) {
29813
29863
  if (Array.isArray(value)) return value.map((entry) => sanitizeTraceValue(entry, traceContent));
29814
29864
  if (value && typeof value === "object") {
29815
29865
  return Object.fromEntries(
29816
- Object.entries(value).map(([key, nested]) => [key, sanitizeTraceValue(nested, traceContent)])
29866
+ Object.entries(value).map(([key2, nested]) => [key2, sanitizeTraceValue(nested, traceContent)])
29817
29867
  );
29818
29868
  }
29819
29869
  return value;
@@ -29822,7 +29872,7 @@ function sanitizeTraceValue(value, traceContent) {
29822
29872
  if (Array.isArray(value)) return value.map((entry) => sanitizeTraceValue(entry, traceContent));
29823
29873
  if (value && typeof value === "object") {
29824
29874
  return Object.fromEntries(
29825
- Object.entries(value).map(([key, nested]) => [key, sanitizeTraceValue(nested, traceContent)])
29875
+ Object.entries(value).map(([key2, nested]) => [key2, sanitizeTraceValue(nested, traceContent)])
29826
29876
  );
29827
29877
  }
29828
29878
  return value;
@@ -30130,8 +30180,8 @@ function maxSequence(messages) {
30130
30180
  }
30131
30181
  function isSupersetOf(candidate, required) {
30132
30182
  if (required.size === 0) return true;
30133
- for (const key of required) {
30134
- if (!candidate.has(key)) return false;
30183
+ for (const key2 of required) {
30184
+ if (!candidate.has(key2)) return false;
30135
30185
  }
30136
30186
  return true;
30137
30187
  }
@@ -30144,17 +30194,17 @@ function chatSourceSessionKey(providerType, sessionId) {
30144
30194
  var ChatSourceRegistry = class {
30145
30195
  records = /* @__PURE__ */ new Map();
30146
30196
  /** Snapshot of current state for diagnostics. Does not mutate. */
30147
- getState(key) {
30148
- return this.records.get(key)?.state ?? INITIAL_CHAT_SOURCE_STATE;
30197
+ getState(key2) {
30198
+ return this.records.get(key2)?.state ?? INITIAL_CHAT_SOURCE_STATE;
30149
30199
  }
30150
30200
  /** Recent transitions, newest last. Empty array when nothing has happened. */
30151
- getTransitions(key) {
30152
- return this.records.get(key)?.transitions ?? [];
30201
+ getTransitions(key2) {
30202
+ return this.records.get(key2)?.transitions ?? [];
30153
30203
  }
30154
30204
  /** Drop a session. Caller should invoke this when the session is destroyed
30155
30205
  * to avoid unbounded growth across long-lived daemons. */
30156
- clear(key) {
30157
- this.records.delete(key);
30206
+ clear(key2) {
30207
+ this.records.delete(key2);
30158
30208
  }
30159
30209
  /** Drop all sessions. Test helper. */
30160
30210
  clearAll() {
@@ -30166,15 +30216,15 @@ var ChatSourceRegistry = class {
30166
30216
  * under `key`; callers may treat the decision as authoritative without
30167
30217
  * re-reading.
30168
30218
  */
30169
- observe(key, observation, at = Date.now()) {
30170
- const prev = this.records.get(key);
30219
+ observe(key2, observation, at = Date.now()) {
30220
+ const prev = this.records.get(key2);
30171
30221
  const prevState = prev?.state ?? INITIAL_CHAT_SOURCE_STATE;
30172
30222
  const prevLockedSince = prev?.lockedSince;
30173
30223
  const result = transitionChatSourceState(prevState, observation, at, prevLockedSince);
30174
30224
  const transitions = prev?.transitions ?? [];
30175
30225
  const nextTransitions = appendTransition(transitions, result.transition);
30176
30226
  const lockedSince = result.lockState.lockedSince;
30177
- this.records.set(key, {
30227
+ this.records.set(key2, {
30178
30228
  state: result.next,
30179
30229
  lockedSince,
30180
30230
  transitions: nextTransitions
@@ -30857,8 +30907,8 @@ function readLiveCodexWorkspaceNativeHistory(agentStr, args) {
30857
30907
  });
30858
30908
  return { ...history, lookup: "workspace" };
30859
30909
  }
30860
- function shouldPreserveReadChatPayloadField(key) {
30861
- return key === "messageSource" || key === "transcriptProvenance";
30910
+ function shouldPreserveReadChatPayloadField(key2) {
30911
+ return key2 === "messageSource" || key2 === "transcriptProvenance";
30862
30912
  }
30863
30913
  function updateMessageSourceReturnedCount(value, returnedMessageCount) {
30864
30914
  if (!value || typeof value !== "object" || Array.isArray(value)) return value;
@@ -31028,7 +31078,7 @@ function buildReadChatCommandResult(payload, args, h) {
31028
31078
  const visibleMessages = includeActivity ? filteredMessages.filter((m) => isUserFacingChatMessage(m) || isActivityChatMessage(m)) : filterUserFacingChatMessages(filteredMessages);
31029
31079
  const sync = buildFullTail(visibleMessages, normalizeReadChatTailLimit(args));
31030
31080
  const hiddenMsgCount = Math.max(0, messages.length - visibleMessages.length);
31031
- const preservedPayloadFields = Object.fromEntries(Object.entries(payload).filter(([key]) => shouldPreserveReadChatPayloadField(key)));
31081
+ const preservedPayloadFields = Object.fromEntries(Object.entries(payload).filter(([key2]) => shouldPreserveReadChatPayloadField(key2)));
31032
31082
  if (preservedPayloadFields.messageSource) {
31033
31083
  preservedPayloadFields.messageSource = updateMessageSourceReturnedCount(preservedPayloadFields.messageSource, sync.messages.length);
31034
31084
  }
@@ -31780,8 +31830,8 @@ function sanitizeDebugBundleValue(value, options = {}, depth = 0, keyHint = "")
31780
31830
  const record = value;
31781
31831
  const result = {};
31782
31832
  const entries = Object.entries(record).slice(0, normalizedOptions.maxObjectKeys);
31783
- for (const [key, item] of entries) {
31784
- result[key] = sanitizeDebugBundleValue(item, normalizedOptions, depth + 1, key);
31833
+ for (const [key2, item] of entries) {
31834
+ result[key2] = sanitizeDebugBundleValue(item, normalizedOptions, depth + 1, key2);
31785
31835
  }
31786
31836
  const remaining = Object.keys(record).length - entries.length;
31787
31837
  if (remaining > 0) result.__truncatedKeys = remaining;
@@ -32107,14 +32157,14 @@ function callLegacyTextScript(script, text) {
32107
32157
  if (typeof script !== "function") return null;
32108
32158
  return script(text);
32109
32159
  }
32110
- function isRecentDuplicateSend(key) {
32160
+ function isRecentDuplicateSend(key2) {
32111
32161
  const now = Date.now();
32112
32162
  for (const [candidate, ts2] of recentSendByTarget.entries()) {
32113
32163
  if (now - ts2 > RECENT_SEND_WINDOW_MS) recentSendByTarget.delete(candidate);
32114
32164
  }
32115
- const previous = recentSendByTarget.get(key);
32165
+ const previous = recentSendByTarget.get(key2);
32116
32166
  if (previous && now - previous <= RECENT_SEND_WINDOW_MS) return true;
32117
- recentSendByTarget.set(key, now);
32167
+ recentSendByTarget.set(key2, now);
32118
32168
  return false;
32119
32169
  }
32120
32170
  function didProviderConfirmSend(result) {
@@ -32977,23 +33027,23 @@ async function handleCdpRemoteAction(h, args) {
32977
33027
  try {
32978
33028
  switch (action) {
32979
33029
  case "input_key": {
32980
- const { type: evType, key, code, text, unmodifiedText, modifiers } = params;
33030
+ const { type: evType, key: key2, code, text, unmodifiedText, modifiers } = params;
32981
33031
  const mod = typeof modifiers === "number" ? modifiers : 0;
32982
- const vk = KEY_TO_VK[key] || (key.length === 1 ? key.charCodeAt(0) : 0);
33032
+ const vk = KEY_TO_VK[key2] || (key2.length === 1 ? key2.charCodeAt(0) : 0);
32983
33033
  if (evType === "char") {
32984
33034
  await h.getCdp().send("Input.dispatchKeyEvent", {
32985
33035
  type: "char",
32986
- key,
33036
+ key: key2,
32987
33037
  code,
32988
- text: text || key,
32989
- unmodifiedText: unmodifiedText || text || key,
33038
+ text: text || key2,
33039
+ unmodifiedText: unmodifiedText || text || key2,
32990
33040
  ...vk ? { windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk } : {},
32991
33041
  ...mod ? { modifiers: mod } : {}
32992
33042
  });
32993
33043
  } else {
32994
33044
  await h.getCdp().send("Input.dispatchKeyEvent", {
32995
33045
  type: "rawKeyDown",
32996
- key,
33046
+ key: key2,
32997
33047
  code,
32998
33048
  ...text ? { text } : {},
32999
33049
  ...vk ? { windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk } : {},
@@ -33001,7 +33051,7 @@ async function handleCdpRemoteAction(h, args) {
33001
33051
  });
33002
33052
  await h.getCdp().send("Input.dispatchKeyEvent", {
33003
33053
  type: "keyUp",
33004
- key,
33054
+ key: key2,
33005
33055
  code,
33006
33056
  ...vk ? { windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk } : {},
33007
33057
  ...mod ? { modifiers: mod } : {}
@@ -33400,21 +33450,21 @@ function handleGetProviderSettings(h, args) {
33400
33450
  }
33401
33451
  async function handleSetProviderSetting(h, args) {
33402
33452
  const loader = h.ctx.providerLoader;
33403
- const { providerType, key, value } = args || {};
33404
- if (!providerType || !key || value === void 0) {
33453
+ const { providerType, key: key2, value } = args || {};
33454
+ if (!providerType || !key2 || value === void 0) {
33405
33455
  return { success: false, error: "providerType, key, and value are required" };
33406
33456
  }
33407
- const result = loader?.setSetting(providerType, key, value);
33457
+ const result = loader?.setSetting(providerType, key2, value);
33408
33458
  if (result) {
33409
33459
  if (h.ctx.instanceManager) {
33410
33460
  const allSettings = loader?.getSettings(providerType) || {};
33411
33461
  const updated = h.ctx.instanceManager.updateInstanceSettings(providerType, allSettings);
33412
- LOG.info("Command", `[set_provider_setting] ${providerType}.${key}=${JSON.stringify(value)} \u2192 ${updated} instance(s) updated`);
33462
+ LOG.info("Command", `[set_provider_setting] ${providerType}.${key2}=${JSON.stringify(value)} \u2192 ${updated} instance(s) updated`);
33413
33463
  }
33414
- await h.ctx.onProviderSettingChanged?.(providerType, key, value);
33415
- return { success: true, providerType, key, value };
33464
+ await h.ctx.onProviderSettingChanged?.(providerType, key2, value);
33465
+ return { success: true, providerType, key: key2, value };
33416
33466
  }
33417
- return { success: false, error: `Failed to set ${providerType}.${key} \u2014 invalid key, value, or not a public setting` };
33467
+ return { success: false, error: `Failed to set ${providerType}.${key2} \u2014 invalid key, value, or not a public setting` };
33418
33468
  }
33419
33469
  function handleGetProviderSourceConfig(h, _args) {
33420
33470
  const loader = h.ctx.providerLoader;
@@ -33460,9 +33510,9 @@ function normalizeProviderScriptArgs(args, scriptName) {
33460
33510
  normalizedArgs.mode = normalizedArgs.value;
33461
33511
  }
33462
33512
  }
33463
- for (const key of ["mode", "model", "message", "action", "button", "text", "sessionId", "value"]) {
33464
- if (key in normalizedArgs && !(key.toUpperCase() in normalizedArgs)) {
33465
- normalizedArgs[key.toUpperCase()] = normalizedArgs[key];
33513
+ for (const key2 of ["mode", "model", "message", "action", "button", "text", "sessionId", "value"]) {
33514
+ if (key2 in normalizedArgs && !(key2.toUpperCase() in normalizedArgs)) {
33515
+ normalizedArgs[key2.toUpperCase()] = normalizedArgs[key2];
33466
33516
  }
33467
33517
  }
33468
33518
  return normalizedArgs;
@@ -33862,10 +33912,10 @@ function summarizeCommandArgs(args) {
33862
33912
  "value"
33863
33913
  ];
33864
33914
  const entries = [];
33865
- for (const key of preferredKeys) {
33866
- if (!(key in args) || args[key] === void 0) continue;
33867
- const value = key === "text" || key === "message" ? `${String(args[key] || "").length} chars` : key === "data" ? `${String(args[key] || "").length} chars` : summarizeLogValue(args[key]);
33868
- entries.push(`${key}=${value}`);
33915
+ for (const key2 of preferredKeys) {
33916
+ if (!(key2 in args) || args[key2] === void 0) continue;
33917
+ const value = key2 === "text" || key2 === "message" ? `${String(args[key2] || "").length} chars` : key2 === "data" ? `${String(args[key2] || "").length} chars` : summarizeLogValue(args[key2]);
33918
+ entries.push(`${key2}=${value}`);
33869
33919
  }
33870
33920
  return entries.length ? entries.join(" ") : "{...}";
33871
33921
  }
@@ -33917,12 +33967,12 @@ var DaemonCommandHandler = class {
33917
33967
  * Get provider module — _currentProviderType (agentType priority) use.
33918
33968
  */
33919
33969
  getProvider(overrideType) {
33920
- const key = overrideType || this._currentRoute.providerType || this._currentRoute.session?.providerType || this._currentRoute.managerKey;
33921
- if (!key || !this._ctx.providerLoader) return void 0;
33922
- const result = this._ctx.providerLoader.resolve(key);
33970
+ const key2 = overrideType || this._currentRoute.providerType || this._currentRoute.session?.providerType || this._currentRoute.managerKey;
33971
+ if (!key2 || !this._ctx.providerLoader) return void 0;
33972
+ const result = this._ctx.providerLoader.resolve(key2);
33923
33973
  if (result) return result;
33924
- const baseType = key.split("_")[0];
33925
- if (baseType !== key) return this._ctx.providerLoader.resolve(baseType);
33974
+ const baseType = key2.split("_")[0];
33975
+ if (baseType !== key2) return this._ctx.providerLoader.resolve(baseType);
33926
33976
  return void 0;
33927
33977
  }
33928
33978
  /** Get a provider script by name from ProviderLoader. */
@@ -33980,11 +34030,11 @@ var DaemonCommandHandler = class {
33980
34030
  return this._ctx.adapters.get(target) || null;
33981
34031
  }
33982
34032
  // ─── Private helpers ──────────────────────────────
33983
- inferProviderType(key) {
33984
- if (!key) return void 0;
33985
- const session = this._ctx.sessionRegistry?.get(key);
34033
+ inferProviderType(key2) {
34034
+ if (!key2) return void 0;
34035
+ const session = this._ctx.sessionRegistry?.get(key2);
33986
34036
  if (session?.providerType) return session.providerType;
33987
- return key.split("_")[0];
34037
+ return key2.split("_")[0];
33988
34038
  }
33989
34039
  resolveRoute(args) {
33990
34040
  const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
@@ -35682,16 +35732,16 @@ var coordinatorPromptHandlers = {
35682
35732
  const m = matchAppend || matchOverride;
35683
35733
  if (!m) continue;
35684
35734
  const isAppend = !!matchAppend;
35685
- const key = m[1];
35735
+ const key2 = m[1];
35686
35736
  const full = path43.join(dir, name);
35687
35737
  let content = "";
35688
35738
  try {
35689
35739
  content = fs38.readFileSync(full, "utf8");
35690
35740
  } catch {
35691
35741
  }
35692
- if (!entries[key]) entries[key] = { override: "", append: "" };
35693
- if (isAppend) entries[key].append = content;
35694
- else entries[key].override = content;
35742
+ if (!entries[key2]) entries[key2] = { override: "", append: "" };
35743
+ if (isAppend) entries[key2].append = content;
35744
+ else entries[key2].override = content;
35695
35745
  }
35696
35746
  }
35697
35747
  } catch (error) {
@@ -35703,14 +35753,14 @@ var coordinatorPromptHandlers = {
35703
35753
  const fs38 = await import("fs");
35704
35754
  const path43 = await import("path");
35705
35755
  const os30 = await import("os");
35706
- const key = typeof args?.key === "string" ? args.key.trim() : "";
35756
+ const key2 = typeof args?.key === "string" ? args.key.trim() : "";
35707
35757
  const kind = args?.kind === "append" ? "append" : "override";
35708
35758
  const content = typeof args?.content === "string" ? args.content : "";
35709
- if (!key || !/^[a-zA-Z0-9_.-]+$/.test(key)) {
35759
+ if (!key2 || !/^[a-zA-Z0-9_.-]+$/.test(key2)) {
35710
35760
  return { success: false, error: "key must match [a-zA-Z0-9_.-]+" };
35711
35761
  }
35712
35762
  const dir = path43.join(os30.homedir(), ".adhdev", "coordinator-prompts");
35713
- const filename = kind === "append" ? `${key}.append.md` : `${key}.md`;
35763
+ const filename = kind === "append" ? `${key2}.append.md` : `${key2}.md`;
35714
35764
  const full = path43.join(dir, filename);
35715
35765
  try {
35716
35766
  fs38.mkdirSync(dir, { recursive: true });
@@ -35719,7 +35769,7 @@ var coordinatorPromptHandlers = {
35719
35769
  } else if (fs38.existsSync(full)) {
35720
35770
  fs38.unlinkSync(full);
35721
35771
  }
35722
- return { success: true, path: full, kind, key };
35772
+ return { success: true, path: full, kind, key: key2 };
35723
35773
  } catch (error) {
35724
35774
  return { success: false, error: error?.message || String(error) };
35725
35775
  }
@@ -36664,7 +36714,7 @@ var RULES = [
36664
36714
  {
36665
36715
  name: "key_value_secret",
36666
36716
  pattern: /\b([A-Z0-9_]*(?:SECRET|TOKEN|API[_-]?KEY|PASSWORD|PASSWD|PRIVATE[_-]?KEY|CREDENTIAL|CLIENT[_-]?SECRET)[A-Z0-9_]*)(\s*[:=]\s*)(["']?)([^\s"',;]+)\3/gi,
36667
- replace: (_m, key, delim, quote) => `${key}${delim}${quote}${MASK}${quote}`
36717
+ replace: (_m, key2, delim, quote) => `${key2}${delim}${quote}${MASK}${quote}`
36668
36718
  },
36669
36719
  // Authorization: Bearer <token>
36670
36720
  {
@@ -37014,7 +37064,7 @@ function realWorkspacePath(workingDir) {
37014
37064
  }
37015
37065
  function applyPreLaunchTrust(trust, workingDir) {
37016
37066
  const settingsPath = expandHome2(trust.settings_path);
37017
- const key = trust.key;
37067
+ const key2 = trust.key;
37018
37068
  const real = realWorkspacePath(workingDir);
37019
37069
  try {
37020
37070
  let parsed = {};
@@ -37027,18 +37077,18 @@ function applyPreLaunchTrust(trust, workingDir) {
37027
37077
  }
37028
37078
  }
37029
37079
  }
37030
- const existing = parsed[key];
37080
+ const existing = parsed[key2];
37031
37081
  const list = Array.isArray(existing) ? existing.filter((v) => typeof v === "string") : [];
37032
37082
  if (list.includes(real)) {
37033
37083
  LOG.debug("pre-launch-trust", `[${trust.settings_path}] ${real} already trusted \u2014 no change`);
37034
37084
  return null;
37035
37085
  }
37036
37086
  list.push(real);
37037
- parsed[key] = list;
37087
+ parsed[key2] = list;
37038
37088
  fs14.mkdirSync(path22.dirname(settingsPath), { recursive: true });
37039
37089
  fs14.writeFileSync(settingsPath, `${JSON.stringify(parsed, null, 2)}
37040
37090
  `, "utf8");
37041
- LOG.info("pre-launch-trust", `pre-trusted workspace in ${trust.settings_path} (key="${key}")`);
37091
+ LOG.info("pre-launch-trust", `pre-trusted workspace in ${trust.settings_path} (key="${key2}")`);
37042
37092
  return real;
37043
37093
  } catch (err) {
37044
37094
  LOG.warn("pre-launch-trust", `failed to pre-trust workspace in ${trust.settings_path}: ${err.message}`);
@@ -38649,8 +38699,8 @@ function jsonPathGet(record, expr) {
38649
38699
  }
38650
38700
  let end = i;
38651
38701
  while (end < expr.length && expr[end] !== "." && expr[end] !== "[") end += 1;
38652
- const key = expr.slice(i, end);
38653
- cur = cur[key];
38702
+ const key2 = expr.slice(i, end);
38703
+ cur = cur[key2];
38654
38704
  i = end;
38655
38705
  }
38656
38706
  return cur;
@@ -40625,8 +40675,8 @@ var CliProviderInstance = class _CliProviderInstance {
40625
40675
  /** Drop user-input ack entries older than the dedup window so the map can't grow unbounded. */
40626
40676
  pruneRecentUserInputAcks(now) {
40627
40677
  if (this.recentUserInputAcks.size <= 1) return;
40628
- for (const [key, at] of this.recentUserInputAcks) {
40629
- if (now - at > USER_INPUT_ACK_DEDUP_WINDOW_MS) this.recentUserInputAcks.delete(key);
40678
+ for (const [key2, at] of this.recentUserInputAcks) {
40679
+ if (now - at > USER_INPUT_ACK_DEDUP_WINDOW_MS) this.recentUserInputAcks.delete(key2);
40630
40680
  }
40631
40681
  }
40632
40682
  dispose() {
@@ -41830,8 +41880,8 @@ ${effect.notification.body || ""}`.trim();
41830
41880
  };
41831
41881
  const isRuntimeOverlay = (entry) => {
41832
41882
  if (entry.source !== "runtime") return false;
41833
- const key = typeof entry.runtimeKey === "string" ? entry.runtimeKey.trim().toLowerCase() : "";
41834
- if (key.startsWith("auto_approval:")) return true;
41883
+ const key2 = typeof entry.runtimeKey === "string" ? entry.runtimeKey.trim().toLowerCase() : "";
41884
+ if (key2.startsWith("auto_approval:")) return true;
41835
41885
  return !isUserFacingChatMessage(entry.message);
41836
41886
  };
41837
41887
  const shouldKeepParsedBeforeUntimedRuntime = (message) => {
@@ -43436,16 +43486,16 @@ var DEFAULT_COORDINATOR_DELEGATED_ENV_UNSETS = [
43436
43486
  function hasCliArg(args, flag) {
43437
43487
  return args.some((arg) => arg === flag || arg.startsWith(`${flag}=`));
43438
43488
  }
43439
- function hasConfigOverride(args, key) {
43489
+ function hasConfigOverride(args, key2) {
43440
43490
  for (let index = 0; index < args.length; index += 1) {
43441
43491
  const arg = args[index];
43442
43492
  const next = args[index + 1];
43443
43493
  if ((arg === "-c" || arg === "--config") && typeof next === "string") {
43444
- if (next === key || next.startsWith(`${key}=`) || next.startsWith(`${key}.`)) return true;
43494
+ if (next === key2 || next.startsWith(`${key2}=`) || next.startsWith(`${key2}.`)) return true;
43445
43495
  }
43446
43496
  if (arg.startsWith("--config=")) {
43447
43497
  const value = arg.slice("--config=".length);
43448
- if (value === key || value.startsWith(`${key}=`) || value.startsWith(`${key}.`)) return true;
43498
+ if (value === key2 || value.startsWith(`${key2}=`) || value.startsWith(`${key2}.`)) return true;
43449
43499
  }
43450
43500
  }
43451
43501
  return false;
@@ -43462,10 +43512,10 @@ function buildCoordinatorDelegatedCliLaunchOptions(input) {
43462
43512
  const cliArgs = Array.isArray(input.cliArgs) ? [...input.cliArgs] : [];
43463
43513
  const env = { ...input.env || {} };
43464
43514
  const envUnsets = new Set(DEFAULT_COORDINATOR_DELEGATED_ENV_UNSETS);
43465
- for (const key of input.isolation?.env?.unset || []) {
43466
- if (typeof key === "string" && key.trim()) envUnsets.add(key.trim());
43515
+ for (const key2 of input.isolation?.env?.unset || []) {
43516
+ if (typeof key2 === "string" && key2.trim()) envUnsets.add(key2.trim());
43467
43517
  }
43468
- for (const key of envUnsets) env[key] = "";
43518
+ for (const key2 of envUnsets) env[key2] = "";
43469
43519
  for (const rule of input.isolation?.args || []) {
43470
43520
  if (!rule || typeof rule !== "object") continue;
43471
43521
  if (rule.mode === "empty_mcp_config") {
@@ -43478,9 +43528,9 @@ function buildCoordinatorDelegatedCliLaunchOptions(input) {
43478
43528
  continue;
43479
43529
  }
43480
43530
  if (rule.mode === "config_override") {
43481
- const key = String(rule.dedupeKey || rule.key || "").trim();
43531
+ const key2 = String(rule.dedupeKey || rule.key || "").trim();
43482
43532
  const flag = String(rule.flag || "").trim();
43483
- if (!key || !flag || hasConfigOverride(cliArgs, key)) continue;
43533
+ if (!key2 || !flag || hasConfigOverride(cliArgs, key2)) continue;
43484
43534
  cliArgs.unshift(flag, `${rule.key}=${rule.value}`);
43485
43535
  }
43486
43536
  }
@@ -43686,12 +43736,12 @@ var DaemonCliManager = class {
43686
43736
  }
43687
43737
  throw new Error(`No CLI provider found for '${cliType}'. Create a provider.js in providers/cli/${cliType}/`);
43688
43738
  }
43689
- startCliExitMonitor(key, cliType) {
43739
+ startCliExitMonitor(key2, cliType) {
43690
43740
  const sessionRegistry = this.deps.getSessionRegistry?.() || null;
43691
43741
  const instanceManager = this.deps.getInstanceManager();
43692
43742
  const checkStopped = setInterval(() => {
43693
43743
  try {
43694
- const adapter = this.adapters.get(key);
43744
+ const adapter = this.adapters.get(key2);
43695
43745
  if (!adapter) {
43696
43746
  clearInterval(checkStopped);
43697
43747
  return;
@@ -43700,12 +43750,12 @@ var DaemonCliManager = class {
43700
43750
  if (status?.status === "stopped" || status?.status === "error") {
43701
43751
  clearInterval(checkStopped);
43702
43752
  setTimeout(() => {
43703
- if (this.adapters.has(key)) {
43704
- this.adapters.delete(key);
43705
- this.deps.removeAgentTracking(key);
43706
- sessionRegistry?.unregisterByInstanceKey(key);
43707
- instanceManager?.removeInstance(key);
43708
- unregisterMeshCoordinator(key);
43753
+ if (this.adapters.has(key2)) {
43754
+ this.adapters.delete(key2);
43755
+ this.deps.removeAgentTracking(key2);
43756
+ sessionRegistry?.unregisterByInstanceKey(key2);
43757
+ instanceManager?.removeInstance(key2);
43758
+ unregisterMeshCoordinator(key2);
43709
43759
  LOG.info("CLI", `\u{1F9F9} Auto-cleaned ${status.status} CLI: ${cliType}`);
43710
43760
  this.deps.onStatusChange();
43711
43761
  }
@@ -43715,21 +43765,21 @@ var DaemonCliManager = class {
43715
43765
  }
43716
43766
  }, 3e3);
43717
43767
  }
43718
- async registerCliInstance(key, normalizedType, cliType, resolvedDir, cliArgs, provider, settings, attachExisting = false, options) {
43768
+ async registerCliInstance(key2, normalizedType, cliType, resolvedDir, cliArgs, provider, settings, attachExisting = false, options) {
43719
43769
  const instanceManager = this.deps.getInstanceManager();
43720
43770
  const sessionRegistry = this.deps.getSessionRegistry?.() || null;
43721
43771
  if (!instanceManager) throw new Error("InstanceManager not available");
43722
43772
  const transportFactory = this.getTransportFactory(
43723
- key,
43773
+ key2,
43724
43774
  normalizedType,
43725
43775
  resolvedDir,
43726
43776
  cliArgs,
43727
43777
  options?.providerSessionId,
43728
43778
  attachExisting
43729
43779
  );
43730
- const cliInstance = new CliProviderInstance(provider, resolvedDir, cliArgs, key, transportFactory, options);
43780
+ const cliInstance = new CliProviderInstance(provider, resolvedDir, cliArgs, key2, transportFactory, options);
43731
43781
  try {
43732
- await instanceManager.addInstance(key, cliInstance, {
43782
+ await instanceManager.addInstance(key2, cliInstance, {
43733
43783
  serverConn: this.deps.getServerConn(),
43734
43784
  settings,
43735
43785
  onPtyData: (data) => {
@@ -43741,8 +43791,8 @@ var DaemonCliManager = class {
43741
43791
  parentSessionId: null,
43742
43792
  providerType: normalizedType,
43743
43793
  transport: "pty",
43744
- adapterKey: key,
43745
- instanceKey: key,
43794
+ adapterKey: key2,
43795
+ instanceKey: key2,
43746
43796
  workspace: resolvedDir,
43747
43797
  // attachExisting === true means we're restoring an already-spawned
43748
43798
  // hosted runtime after a daemon restart, not starting a fresh PTY.
@@ -43758,10 +43808,10 @@ var DaemonCliManager = class {
43758
43808
  });
43759
43809
  } catch (spawnErr) {
43760
43810
  LOG.error("CLI", `[${cliType}] Spawn failed: ${spawnErr?.message}`);
43761
- instanceManager.removeInstance(key);
43811
+ instanceManager.removeInstance(key2);
43762
43812
  throw new Error(`Failed to start ${provider.displayName || provider.name || cliType}: ${spawnErr?.message}`);
43763
43813
  }
43764
- this.adapters.set(key, cliInstance.getAdapter());
43814
+ this.adapters.set(key2, cliInstance.getAdapter());
43765
43815
  const launchMeshNodeId = typeof settings?.meshNodeId === "string" ? settings.meshNodeId.trim() : "";
43766
43816
  const launchMeshNodeFor = typeof settings?.meshNodeFor === "string" ? settings.meshNodeFor.trim() : "";
43767
43817
  if (launchMeshNodeId || launchMeshNodeFor) {
@@ -43774,7 +43824,7 @@ var DaemonCliManager = class {
43774
43824
  } catch {
43775
43825
  }
43776
43826
  }
43777
- this.startCliExitMonitor(key, cliType);
43827
+ this.startCliExitMonitor(key2, cliType);
43778
43828
  }
43779
43829
  // ─── Session start/management ──────────────────────────────
43780
43830
  async startSession(cliType, workingDir, cliArgs, initialModel, options) {
@@ -43791,11 +43841,11 @@ var DaemonCliManager = class {
43791
43841
  Enable and detect this provider from the Machine Providers page before starting a runtime.`
43792
43842
  );
43793
43843
  }
43794
- const key = crypto5.randomUUID();
43844
+ const key2 = crypto5.randomUUID();
43795
43845
  {
43796
43846
  const coordinatorMeshId = options?.settingsOverride?.meshCoordinatorFor;
43797
43847
  if (typeof coordinatorMeshId === "string" && coordinatorMeshId.trim()) {
43798
- options = { ...options, extraEnv: { ...options?.extraEnv || {}, ADHDEV_COORDINATOR_SESSION_ID: key } };
43848
+ options = { ...options, extraEnv: { ...options?.extraEnv || {}, ADHDEV_COORDINATOR_SESSION_ID: key2 } };
43799
43849
  }
43800
43850
  }
43801
43851
  const sessionRegistry = this.deps.getSessionRegistry?.() || null;
@@ -43815,7 +43865,7 @@ ${installInfo}`
43815
43865
  }
43816
43866
  console.log(colorize("cyan", ` \u{1F50C} Starting ACP agent: ${provider.name} (${provider.type}) in ${resolvedDir}`));
43817
43867
  const acpInstance = new AcpProviderInstance(resolvedProvider, resolvedDir, cliArgs);
43818
- await instanceManager2.addInstance(key, acpInstance, {
43868
+ await instanceManager2.addInstance(key2, acpInstance, {
43819
43869
  settings: this.providerLoader.getSettings(normalizedType)
43820
43870
  });
43821
43871
  const sessionId = acpInstance.getInstanceId();
@@ -43824,11 +43874,11 @@ ${installInfo}`
43824
43874
  parentSessionId: null,
43825
43875
  providerType: normalizedType,
43826
43876
  transport: "acp",
43827
- adapterKey: key,
43828
- instanceKey: key,
43877
+ adapterKey: key2,
43878
+ instanceKey: key2,
43829
43879
  workspace: resolvedDir
43830
43880
  });
43831
- this.adapters.set(key, {
43881
+ this.adapters.set(key2, {
43832
43882
  cliType: normalizedType,
43833
43883
  cliName: provider.name,
43834
43884
  workingDir: resolvedDir,
@@ -43836,7 +43886,7 @@ ${installInfo}`
43836
43886
  spawn: async () => {
43837
43887
  },
43838
43888
  shutdown: () => {
43839
- instanceManager2.removeInstance(key);
43889
+ instanceManager2.removeInstance(key2);
43840
43890
  },
43841
43891
  sendMessage: async (text) => {
43842
43892
  const input = normalizeInputEnvelope(text);
@@ -43852,7 +43902,7 @@ ${installInfo}`
43852
43902
  },
43853
43903
  getPartialResponse: () => "",
43854
43904
  cancel: () => {
43855
- instanceManager2.removeInstance(key);
43905
+ instanceManager2.removeInstance(key2);
43856
43906
  },
43857
43907
  isProcessing: () => false,
43858
43908
  isReady: () => true,
@@ -43906,7 +43956,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
43906
43956
  if (provider && instanceManager) {
43907
43957
  const resolvedProvider = this.providerLoader.resolve(cliType, { version: cliInfo.version }) || provider;
43908
43958
  await this.registerCliInstance(
43909
- key,
43959
+ key2,
43910
43960
  normalizedType,
43911
43961
  cliType,
43912
43962
  resolvedDir,
@@ -43936,7 +43986,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
43936
43986
  cliType,
43937
43987
  resolvedDir,
43938
43988
  resolvedCliArgs,
43939
- key,
43989
+ key2,
43940
43990
  sessionBinding.providerSessionId,
43941
43991
  false,
43942
43992
  options?.extraEnv
@@ -43956,9 +44006,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
43956
44006
  const status = adapter.getStatus?.();
43957
44007
  if (status?.status === "stopped" || status?.status === "error") {
43958
44008
  setTimeout(() => {
43959
- if (this.adapters.get(key) === adapter) {
43960
- this.adapters.delete(key);
43961
- this.deps.removeAgentTracking(key);
44009
+ if (this.adapters.get(key2) === adapter) {
44010
+ this.adapters.delete(key2);
44011
+ this.deps.removeAgentTracking(key2);
43962
44012
  LOG.info("CLI", `\u{1F9F9} Auto-cleaned ${status.status} CLI: ${adapter.cliType}`);
43963
44013
  this.deps.onStatusChange();
43964
44014
  }
@@ -43967,10 +44017,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
43967
44017
  });
43968
44018
  if (typeof adapter.setOnPtyData === "function") {
43969
44019
  adapter.setOnPtyData((data) => {
43970
- this.deps.getP2p()?.broadcastSessionOutput(key, data);
44020
+ this.deps.getP2p()?.broadcastSessionOutput(key2, data);
43971
44021
  });
43972
44022
  }
43973
- this.adapters.set(key, adapter);
44023
+ this.adapters.set(key2, adapter);
43974
44024
  console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
43975
44025
  }
43976
44026
  this.persistRecentActivity({
@@ -43980,20 +44030,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
43980
44030
  providerSessionId: sessionBinding.providerSessionId,
43981
44031
  workspace: resolvedDir,
43982
44032
  summaryMetadata: buildLegacyModelModeSummaryMetadata({ model: initialModel }),
43983
- sessionId: key,
44033
+ sessionId: key2,
43984
44034
  title: provider?.displayName || provider?.name || normalizedType
43985
44035
  });
43986
44036
  this.deps.onStatusChange();
43987
44037
  return {
43988
- runtimeSessionId: key,
44038
+ runtimeSessionId: key2,
43989
44039
  providerSessionId: sessionBinding.providerSessionId
43990
44040
  };
43991
44041
  }
43992
- async stopSession(key) {
43993
- return this.stopSessionWithMode(key, "hard");
44042
+ async stopSession(key2) {
44043
+ return this.stopSessionWithMode(key2, "hard");
43994
44044
  }
43995
- async stopSessionWithMode(key, mode) {
43996
- const adapter = this.adapters.get(key);
44045
+ async stopSessionWithMode(key2, mode) {
44046
+ const adapter = this.adapters.get(key2);
43997
44047
  if (adapter) {
43998
44048
  try {
43999
44049
  if (mode === "save" && typeof adapter.saveAndStop === "function") {
@@ -44004,21 +44054,21 @@ Run 'adhdev doctor' for detailed diagnostics.`
44004
44054
  } catch (e) {
44005
44055
  LOG.warn("CLI", `Shutdown error for ${adapter.cliType}: ${e?.message} (force-cleaning)`);
44006
44056
  }
44007
- this.adapters.delete(key);
44008
- this.deps.removeAgentTracking(key);
44009
- this.deps.getSessionRegistry?.()?.unregisterByInstanceKey(key);
44010
- this.deps.getInstanceManager()?.removeInstance(key);
44011
- unregisterMeshCoordinator(key);
44057
+ this.adapters.delete(key2);
44058
+ this.deps.removeAgentTracking(key2);
44059
+ this.deps.getSessionRegistry?.()?.unregisterByInstanceKey(key2);
44060
+ this.deps.getInstanceManager()?.removeInstance(key2);
44061
+ unregisterMeshCoordinator(key2);
44012
44062
  LOG.info("CLI", `\u{1F6D1} Agent stopped: ${adapter.cliType} in ${adapter.workingDir}`);
44013
44063
  this.deps.onStatusChange();
44014
44064
  } else {
44015
44065
  const im = this.deps.getInstanceManager();
44016
44066
  if (im) {
44017
- this.deps.getSessionRegistry?.()?.unregisterByInstanceKey(key);
44018
- im.removeInstance(key);
44019
- this.deps.removeAgentTracking(key);
44020
- unregisterMeshCoordinator(key);
44021
- LOG.warn("CLI", `\u{1F9F9} Force-removed orphan entry: ${key}`);
44067
+ this.deps.getSessionRegistry?.()?.unregisterByInstanceKey(key2);
44068
+ im.removeInstance(key2);
44069
+ this.deps.removeAgentTracking(key2);
44070
+ unregisterMeshCoordinator(key2);
44071
+ LOG.warn("CLI", `\u{1F9F9} Force-removed orphan entry: ${key2}`);
44022
44072
  this.deps.onStatusChange();
44023
44073
  }
44024
44074
  }
@@ -44046,8 +44096,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
44046
44096
  for (const r of sessions) {
44047
44097
  if (!r?.runtimeId || !r?.cliType || !r?.workspace) continue;
44048
44098
  restoredRuntimeIds.add(r.runtimeId);
44049
- const key = `${r.workspace}::${r.cliType}`;
44050
- workspaceTypeCounts.set(key, (workspaceTypeCounts.get(key) || 0) + 1);
44099
+ const key2 = `${r.workspace}::${r.cliType}`;
44100
+ workspaceTypeCounts.set(key2, (workspaceTypeCounts.get(key2) || 0) + 1);
44051
44101
  }
44052
44102
  for (const record of sessions) {
44053
44103
  if (!record?.runtimeId || !record?.cliType || !record?.workspace) continue;
@@ -44401,7 +44451,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
44401
44451
  });
44402
44452
  }
44403
44453
  if (!found) throw new Error(`CLI agent not running: ${agentType}`);
44404
- const { adapter, key } = found;
44454
+ const { adapter, key: key2 } = found;
44405
44455
  if (action === "send_chat") {
44406
44456
  let currentStatus = getEffectiveAgentSendStatus(adapter);
44407
44457
  if (currentStatus === "starting" && await waitForZeroMessageStartingLaunch(adapter)) {
@@ -44411,7 +44461,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
44411
44461
  }
44412
44462
  const meshContext = args?.meshContext;
44413
44463
  if (meshContext && typeof meshContext === "object" && typeof meshContext.meshId === "string" && meshContext.meshId) {
44414
- const targetInstanceId = key;
44464
+ const targetInstanceId = key2;
44415
44465
  try {
44416
44466
  this.deps.getInstanceManager()?.attachMeshAssignmentToInstance(targetInstanceId, {
44417
44467
  meshId: meshContext.meshId,
@@ -44443,7 +44493,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
44443
44493
  } else {
44444
44494
  await adapter.sendMessage(message);
44445
44495
  }
44446
- const targetInstance = this.deps.getInstanceManager()?.getInstance(key);
44496
+ const targetInstance = this.deps.getInstanceManager()?.getInstance(key2);
44447
44497
  targetInstance?.recordAcknowledgedUserInput?.(input);
44448
44498
  return {
44449
44499
  success: true,
@@ -44455,7 +44505,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
44455
44505
  if (typeof adapter.clearHistory === "function") adapter.clearHistory();
44456
44506
  return { success: true, cleared: true };
44457
44507
  } else if (action === "stop") {
44458
- await this.stopSession(key);
44508
+ await this.stopSession(key2);
44459
44509
  return { success: true, stopped: true };
44460
44510
  }
44461
44511
  throw new Error(`Unknown action: ${action}`);
@@ -44727,9 +44777,9 @@ function validateProviderDefinition(raw) {
44727
44777
  } else if (!["ide", "extension", "cli", "acp"].includes(String(provider.category))) {
44728
44778
  errors.push(`Invalid category: ${String(provider.category)}`);
44729
44779
  }
44730
- for (const key of Object.keys(provider)) {
44731
- if (!KNOWN_PROVIDER_FIELDS.has(key)) {
44732
- warnings.push(`Unknown provider field: ${key}`);
44780
+ for (const key2 of Object.keys(provider)) {
44781
+ if (!KNOWN_PROVIDER_FIELDS.has(key2)) {
44782
+ warnings.push(`Unknown provider field: ${key2}`);
44733
44783
  }
44734
44784
  }
44735
44785
  if (provider.disableUpstream !== void 0) {
@@ -44874,10 +44924,10 @@ function validateNativeHistory(raw, errors) {
44874
44924
  return;
44875
44925
  }
44876
44926
  const scriptConfig = scripts;
44877
- for (const key of ["readSession", "listSessions"]) {
44878
- const value = scriptConfig[key];
44927
+ for (const key2 of ["readSession", "listSessions"]) {
44928
+ const value = scriptConfig[key2];
44879
44929
  if (typeof value !== "string" || !value.trim()) {
44880
- errors.push(`nativeHistory.scripts.${key} must be a non-empty string`);
44930
+ errors.push(`nativeHistory.scripts.${key2} must be a non-empty string`);
44881
44931
  }
44882
44932
  }
44883
44933
  }
@@ -44912,10 +44962,10 @@ function validateMeshCoordinatorMcpConfig(mcpConfig, errors) {
44912
44962
  if (format !== void 0 && !["claude_mcp_json", "hermes_config_yaml"].includes(String(format))) {
44913
44963
  errors.push("meshCoordinator.mcpConfig.format must be one of: claude_mcp_json, hermes_config_yaml");
44914
44964
  }
44915
- for (const key of ["path", "serverName", "configPathCommand", "instructions", "template"]) {
44916
- const value = config[key];
44965
+ for (const key2 of ["path", "serverName", "configPathCommand", "instructions", "template"]) {
44966
+ const value = config[key2];
44917
44967
  if (value !== void 0 && (typeof value !== "string" || !value.trim())) {
44918
- errors.push(`meshCoordinator.mcpConfig.${key} must be a non-empty string when provided`);
44968
+ errors.push(`meshCoordinator.mcpConfig.${key2} must be a non-empty string when provided`);
44919
44969
  }
44920
44970
  }
44921
44971
  if (config.requiresRestart !== void 0 && typeof config.requiresRestart !== "boolean") {
@@ -44951,7 +45001,7 @@ function validateMeshCoordinatorDelegatedWorkerIsolation(raw, errors) {
44951
45001
  errors.push("meshCoordinator.delegatedWorkerIsolation.env must be an object");
44952
45002
  } else {
44953
45003
  const unset = env.unset;
44954
- if (unset !== void 0 && (!Array.isArray(unset) || unset.some((key) => typeof key !== "string" || !key.trim()))) {
45004
+ if (unset !== void 0 && (!Array.isArray(unset) || unset.some((key2) => typeof key2 !== "string" || !key2.trim()))) {
44955
45005
  errors.push("meshCoordinator.delegatedWorkerIsolation.env.unset must be an array of non-empty strings");
44956
45006
  }
44957
45007
  }
@@ -44974,16 +45024,16 @@ function validateMeshCoordinatorDelegatedWorkerIsolation(raw, errors) {
44974
45024
  errors.push(`${prefix}.mode must be one of: empty_mcp_config, config_override`);
44975
45025
  continue;
44976
45026
  }
44977
- for (const key of mode === "empty_mcp_config" ? ["flag"] : ["flag", "key", "value"]) {
44978
- const value = item[key];
45027
+ for (const key2 of mode === "empty_mcp_config" ? ["flag"] : ["flag", "key", "value"]) {
45028
+ const value = item[key2];
44979
45029
  if (typeof value !== "string" || !value.trim()) {
44980
- errors.push(`${prefix}.${key} must be a non-empty string`);
45030
+ errors.push(`${prefix}.${key2} must be a non-empty string`);
44981
45031
  }
44982
45032
  }
44983
- for (const key of ["strictFlag", "dedupeKey"]) {
44984
- const value = item[key];
45033
+ for (const key2 of ["strictFlag", "dedupeKey"]) {
45034
+ const value = item[key2];
44985
45035
  if (value !== void 0 && (typeof value !== "string" || !value.trim())) {
44986
- errors.push(`${prefix}.${key} must be a non-empty string when provided`);
45036
+ errors.push(`${prefix}.${key2} must be a non-empty string when provided`);
44987
45037
  }
44988
45038
  }
44989
45039
  }
@@ -47206,9 +47256,9 @@ var ProviderLoader = class _ProviderLoader {
47206
47256
  reload() {
47207
47257
  this.log("Reloading all providers...");
47208
47258
  this.scriptsCache.clear();
47209
- for (const key of Object.keys(require.cache)) {
47210
- if (key.includes("providers") && (key.endsWith(".js") || key.endsWith(".json"))) {
47211
- delete require.cache[key];
47259
+ for (const key2 of Object.keys(require.cache)) {
47260
+ if (key2.includes("providers") && (key2.endsWith(".js") || key2.endsWith(".json"))) {
47261
+ delete require.cache[key2];
47212
47262
  }
47213
47263
  }
47214
47264
  this.loadAll();
@@ -47516,7 +47566,7 @@ var ProviderLoader = class _ProviderLoader {
47516
47566
  */
47517
47567
  getPublicSettings(type) {
47518
47568
  const settings = this.getSettingsSchema(type);
47519
- return Object.entries(settings).filter(([, def]) => def.public === true).map(([key, def]) => ({ key, ...def }));
47569
+ return Object.entries(settings).filter(([, def]) => def.public === true).map(([key2, def]) => ({ key: key2, ...def }));
47520
47570
  }
47521
47571
  /**
47522
47572
  * Get public settings schema for all providers
@@ -47532,23 +47582,23 @@ var ProviderLoader = class _ProviderLoader {
47532
47582
  /**
47533
47583
  * Resolved setting value for a provider (default + user override)
47534
47584
  */
47535
- getSettingValue(type, key) {
47585
+ getSettingValue(type, key2) {
47536
47586
  const providerType = this.resolveAlias(type);
47537
47587
  const machineConfig = this.getMachineProviderConfig(providerType);
47538
- if (key === "enabled") {
47588
+ if (key2 === "enabled") {
47539
47589
  return machineConfig.enabled === true;
47540
47590
  }
47541
- if (key === "executablePath") {
47591
+ if (key2 === "executablePath") {
47542
47592
  return machineConfig.executable || "";
47543
47593
  }
47544
- if (key === "executableArgs") {
47594
+ if (key2 === "executableArgs") {
47545
47595
  const args = machineConfig.args;
47546
47596
  return args ? args.map((arg) => /\s/.test(arg) ? JSON.stringify(arg) : arg).join(" ") : "";
47547
47597
  }
47548
- const schemaDef = this.getSettingsSchema(providerType)[key];
47598
+ const schemaDef = this.getSettingsSchema(providerType)[key2];
47549
47599
  const defaultVal = schemaDef ? schemaDef.default : void 0;
47550
47600
  const config = this.readConfig();
47551
- const userVal = config?.providerSettings?.[providerType]?.[key];
47601
+ const userVal = config?.providerSettings?.[providerType]?.[key2];
47552
47602
  return userVal !== void 0 ? userVal : defaultVal;
47553
47603
  }
47554
47604
  /**
@@ -47558,17 +47608,17 @@ var ProviderLoader = class _ProviderLoader {
47558
47608
  const providerType = this.resolveAlias(type);
47559
47609
  const settings = this.getSettingsSchema(providerType);
47560
47610
  const result = {};
47561
- for (const [key] of Object.entries(settings)) {
47562
- result[key] = this.getSettingValue(providerType, key);
47611
+ for (const [key2] of Object.entries(settings)) {
47612
+ result[key2] = this.getSettingValue(providerType, key2);
47563
47613
  }
47564
47614
  return result;
47565
47615
  }
47566
47616
  /**
47567
47617
  * Save provider setting value (writes to config.json)
47568
47618
  */
47569
- setSetting(type, key, value) {
47619
+ setSetting(type, key2, value) {
47570
47620
  const providerType = this.resolveAlias(type);
47571
- const schemaDef = this.getSettingsSchema(providerType)[key];
47621
+ const schemaDef = this.getSettingsSchema(providerType)[key2];
47572
47622
  if (!schemaDef) return false;
47573
47623
  if (!schemaDef.public) return false;
47574
47624
  if (schemaDef.type === "boolean" && typeof value !== "boolean") return false;
@@ -47579,13 +47629,13 @@ var ProviderLoader = class _ProviderLoader {
47579
47629
  if (schemaDef.max !== void 0 && value > schemaDef.max) return false;
47580
47630
  }
47581
47631
  if (schemaDef.type === "select" && schemaDef.options && !schemaDef.options.includes(value)) return false;
47582
- if (key === "enabled") {
47632
+ if (key2 === "enabled") {
47583
47633
  return this.setMachineProviderEnabled(providerType, value);
47584
47634
  }
47585
- if (key === "executablePath") {
47635
+ if (key2 === "executablePath") {
47586
47636
  return this.setMachineProviderConfig(providerType, { executable: value });
47587
47637
  }
47588
- if (key === "executableArgs") {
47638
+ if (key2 === "executableArgs") {
47589
47639
  return this.setMachineProviderConfig(providerType, {
47590
47640
  args: value.trim() ? this.parseArgsSetting(value) : void 0
47591
47641
  });
@@ -47595,17 +47645,17 @@ var ProviderLoader = class _ProviderLoader {
47595
47645
  try {
47596
47646
  if (!config.providerSettings) config.providerSettings = {};
47597
47647
  if (!config.providerSettings[providerType]) config.providerSettings[providerType] = {};
47598
- config.providerSettings[providerType][key] = value;
47648
+ config.providerSettings[providerType][key2] = value;
47599
47649
  this.writeConfig(config);
47600
- this.log(`Setting updated: ${providerType}.${key} = ${JSON.stringify(value)}`);
47650
+ this.log(`Setting updated: ${providerType}.${key2} = ${JSON.stringify(value)}`);
47601
47651
  return true;
47602
47652
  } catch (e) {
47603
47653
  this.log(`Failed to save setting: ${e.message}`);
47604
47654
  return false;
47605
47655
  }
47606
47656
  }
47607
- getOptionalStringSetting(type, key) {
47608
- const value = this.getSettingValue(type, key);
47657
+ getOptionalStringSetting(type, key2) {
47658
+ const value = this.getSettingValue(type, key2);
47609
47659
  if (typeof value !== "string") return null;
47610
47660
  const trimmed = value.trim();
47611
47661
  return trimmed ? trimmed : null;
@@ -47785,7 +47835,7 @@ var ProviderLoader = class _ProviderLoader {
47785
47835
  try {
47786
47836
  let content = fs25.readFileSync(filePath, "utf-8");
47787
47837
  if (args[0] && typeof args[0] === "object") {
47788
- for (const [key, val] of Object.entries(args[0])) {
47838
+ for (const [key2, val] of Object.entries(args[0])) {
47789
47839
  let v = val;
47790
47840
  if (typeof v === "string") {
47791
47841
  if (!v.startsWith('"') && !v.startsWith("'") && !v.startsWith("`")) {
@@ -47794,7 +47844,7 @@ var ProviderLoader = class _ProviderLoader {
47794
47844
  } else {
47795
47845
  v = JSON.stringify(v);
47796
47846
  }
47797
- const re = new RegExp(`\\$\\{\\s*${key}\\s*\\}`, "g");
47847
+ const re = new RegExp(`\\$\\{\\s*${key2}\\s*\\}`, "g");
47798
47848
  content = content.replace(re, String(v));
47799
47849
  }
47800
47850
  } else if (typeof args[0] === "string") {
@@ -49546,9 +49596,20 @@ var meshQueueHandlers = {
49546
49596
  targetNodeId: typeof args?.targetNodeId === "string" ? args.targetNodeId.trim() : void 0,
49547
49597
  targetSessionId: typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : void 0,
49548
49598
  clearTargetNode: args?.clearTargetNode === true,
49549
- clearTargetSession: args?.clearTargetSession !== false
49599
+ clearTargetSession: args?.clearTargetSession !== false,
49600
+ // CANON-IDENTITY: an in-flight (actively-generating) task is refused by
49601
+ // default to avoid a duplicate second dispatch; an explicit operator
49602
+ // force overrides that guard (and the retry cap).
49603
+ force: args?.force === true
49550
49604
  });
49551
49605
  if (!task) return { success: false, error: `Queue task '${taskId}' not found` };
49606
+ if (task.status === "assigned" && args?.force !== true) {
49607
+ return {
49608
+ success: false,
49609
+ 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.`,
49610
+ task
49611
+ };
49612
+ }
49552
49613
  return { success: true, task };
49553
49614
  } catch (e) {
49554
49615
  return { success: false, error: e.message };
@@ -51079,15 +51140,15 @@ var SENSITIVE_KEYS = /* @__PURE__ */ new Set([
51079
51140
  function maskArgs(args) {
51080
51141
  if (!args || typeof args !== "object") return void 0;
51081
51142
  const masked = {};
51082
- for (const [key, value] of Object.entries(args)) {
51083
- if (SENSITIVE_KEYS.has(key)) {
51084
- masked[key] = typeof value === "string" ? `[${value.length} chars]` : "[masked]";
51085
- } else if (key.startsWith("_")) {
51086
- masked[key] = value;
51143
+ for (const [key2, value] of Object.entries(args)) {
51144
+ if (SENSITIVE_KEYS.has(key2)) {
51145
+ masked[key2] = typeof value === "string" ? `[${value.length} chars]` : "[masked]";
51146
+ } else if (key2.startsWith("_")) {
51147
+ masked[key2] = value;
51087
51148
  } else if (typeof value === "object" && value !== null) {
51088
- masked[key] = Array.isArray(value) ? `[Array(${value.length})]` : `[Object]`;
51149
+ masked[key2] = Array.isArray(value) ? `[Array(${value.length})]` : `[Object]`;
51089
51150
  } else {
51090
- masked[key] = value;
51151
+ masked[key2] = value;
51091
51152
  }
51092
51153
  }
51093
51154
  return masked;
@@ -52184,23 +52245,23 @@ var MeshGitProbeCache = class {
52184
52245
  * neither gate is satisfied.
52185
52246
  */
52186
52247
  async probe(daemonId, workspace, probe) {
52187
- const key = this.key(daemonId, workspace);
52188
- const cached3 = this.recent.get(key);
52248
+ const key2 = this.key(daemonId, workspace);
52249
+ const cached3 = this.recent.get(key2);
52189
52250
  if (cached3 && this.now() - cached3.at < this.reuseMs) {
52190
52251
  return cached3.value;
52191
52252
  }
52192
- const existing = this.inflight.get(key);
52253
+ const existing = this.inflight.get(key2);
52193
52254
  if (existing) return existing;
52194
52255
  const pending = (async () => {
52195
52256
  const result = await probe();
52196
- if (result) this.recent.set(key, { at: this.now(), value: result });
52257
+ if (result) this.recent.set(key2, { at: this.now(), value: result });
52197
52258
  return result;
52198
52259
  })();
52199
- this.inflight.set(key, pending);
52260
+ this.inflight.set(key2, pending);
52200
52261
  try {
52201
52262
  return await pending;
52202
52263
  } finally {
52203
- if (this.inflight.get(key) === pending) this.inflight.delete(key);
52264
+ if (this.inflight.get(key2) === pending) this.inflight.delete(key2);
52204
52265
  }
52205
52266
  }
52206
52267
  };
@@ -54898,8 +54959,8 @@ var DaemonCommandRouter = class {
54898
54959
  if (source !== "refine_mesh_node_async_job") continue;
54899
54960
  const jobId = e.payload?.refineJob?.jobId;
54900
54961
  if (!jobId || terminal.has(`${e.nodeId}:${jobId}`)) continue;
54901
- const key = this.buildRefineJobKey(meshId, e.nodeId);
54902
- if (this.runningRefineJobs.has(key)) continue;
54962
+ const key2 = this.buildRefineJobKey(meshId, e.nodeId);
54963
+ if (this.runningRefineJobs.has(key2)) continue;
54903
54964
  const coordinatorDaemonId = e.payload?.refineJob?.targetCoordinatorDaemonId;
54904
54965
  LOG.info("Mesh", `[Refinery] Auto-resuming interrupted refine job for node ${e.nodeId} (jobId=${jobId})`);
54905
54966
  void this.startMeshRefineJob(meshId, e.nodeId, {
@@ -55982,7 +56043,7 @@ ${hintLines.join("\n")}` : "",
55982
56043
  }
55983
56044
  }
55984
56045
  async finishMeshRefineBatchJob(handle, orderedNodes, ordering, args) {
55985
- const key = this.buildRefineBatchJobKey(handle.meshId);
56046
+ const key2 = this.buildRefineBatchJobKey(handle.meshId);
55986
56047
  let result;
55987
56048
  try {
55988
56049
  result = await this.runMeshRefineBatchConvergence(handle.meshId, orderedNodes, ordering, args);
@@ -56014,8 +56075,8 @@ ${hintLines.join("\n")}` : "",
56014
56075
  coordinatorDaemonId: handle.targetCoordinatorDaemonId
56015
56076
  });
56016
56077
  const terminal = { ...terminalHandle, result: normalizedResult };
56017
- this.terminalRefineBatchJobs.set(key, terminal);
56018
- this.runningRefineBatchJobs.delete(key);
56078
+ this.terminalRefineBatchJobs.set(key2, terminal);
56079
+ this.runningRefineBatchJobs.delete(key2);
56019
56080
  this.invalidateAggregateMeshStatus(handle.meshId);
56020
56081
  await this.appendRefineBatchJobLedger(isTerminalSuccess ? "task_completed" : "task_failed", terminalHandle, normalizedResult);
56021
56082
  this.queueRefineBatchJobEvent(isTerminalSuccess ? "refine:completed" : "refine:failed", terminalHandle, normalizedResult);
@@ -56039,8 +56100,8 @@ ${hintLines.join("\n")}` : "",
56039
56100
  if (nodeIds.length === 0) {
56040
56101
  return { ...planRecord, success: true, batch: true, dryRun: false, async: false };
56041
56102
  }
56042
- const key = this.buildRefineBatchJobKey(meshId);
56043
- const running = this.runningRefineBatchJobs.get(key);
56103
+ const key2 = this.buildRefineBatchJobKey(meshId);
56104
+ const running = this.runningRefineBatchJobs.get(key2);
56044
56105
  if (running) return { ...running, duplicate: true };
56045
56106
  const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
56046
56107
  const mesh = meshRecord?.mesh;
@@ -56055,7 +56116,7 @@ ${hintLines.join("\n")}` : "",
56055
56116
  };
56056
56117
  const coordinatorDaemonId = typeof args?.coordinatorDaemonId === "string" && args.coordinatorDaemonId.trim() ? args.coordinatorDaemonId.trim() : this.deps.statusInstanceId || void 0;
56057
56118
  const handle = this.buildRefineBatchJobHandle({ meshId, nodeIds, order, coordinatorDaemonId });
56058
- this.runningRefineBatchJobs.set(key, handle);
56119
+ this.runningRefineBatchJobs.set(key2, handle);
56059
56120
  await this.appendRefineBatchJobLedger("task_dispatched", handle);
56060
56121
  this.queueRefineBatchJobEvent("refine:accepted", handle);
56061
56122
  setImmediate(() => {
@@ -56070,7 +56131,7 @@ ${hintLines.join("\n")}` : "",
56070
56131
  };
56071
56132
  }
56072
56133
  async finishMeshRefineJob(handle, args) {
56073
- const key = this.buildRefineJobKey(handle.meshId, handle.targetNodeId);
56134
+ const key2 = this.buildRefineJobKey(handle.meshId, handle.targetNodeId);
56074
56135
  let result;
56075
56136
  try {
56076
56137
  result = await this.executeMeshRefineNodeSynchronously(handle.meshId, handle.targetNodeId, args);
@@ -56138,17 +56199,17 @@ ${hintLines.join("\n")}` : "",
56138
56199
  coordinatorDaemonId: handle.targetCoordinatorDaemonId
56139
56200
  });
56140
56201
  const terminal = { ...terminalHandle, result: normalizedResult };
56141
- this.terminalRefineJobs.set(key, terminal);
56142
- this.runningRefineJobs.delete(key);
56202
+ this.terminalRefineJobs.set(key2, terminal);
56203
+ this.runningRefineJobs.delete(key2);
56143
56204
  this.invalidateAggregateMeshStatus(handle.meshId);
56144
56205
  await this.appendRefineJobLedger(isTerminalSuccess ? "task_completed" : "task_failed", terminalHandle, normalizedResult);
56145
56206
  this.queueRefineJobEvent(isTerminalSuccess ? "refine:completed" : "refine:failed", terminalHandle, normalizedResult);
56146
56207
  }
56147
56208
  async startMeshRefineJob(meshId, nodeId, args) {
56148
- const key = this.buildRefineJobKey(meshId, nodeId);
56149
- const running = this.runningRefineJobs.get(key);
56209
+ const key2 = this.buildRefineJobKey(meshId, nodeId);
56210
+ const running = this.runningRefineJobs.get(key2);
56150
56211
  if (running) return { ...running, duplicate: true };
56151
- const terminal = this.terminalRefineJobs.get(key);
56212
+ const terminal = this.terminalRefineJobs.get(key2);
56152
56213
  const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
56153
56214
  const mesh = meshRecord?.mesh;
56154
56215
  const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
@@ -56156,7 +56217,7 @@ ${hintLines.join("\n")}` : "",
56156
56217
  if (!node.isLocalWorktree || !node.workspace) return { success: false, error: `Refinery requires a local worktree node` };
56157
56218
  const coordinatorDaemonId = typeof args?.coordinatorDaemonId === "string" && args.coordinatorDaemonId.trim() ? args.coordinatorDaemonId.trim() : this.deps.statusInstanceId || void 0;
56158
56219
  const handle = this.buildRefineJobHandle({ meshId, nodeId, node, retryOfJobId: terminal?.jobId, coordinatorDaemonId });
56159
- this.runningRefineJobs.set(key, handle);
56220
+ this.runningRefineJobs.set(key2, handle);
56160
56221
  await this.appendRefineJobLedger("task_dispatched", handle);
56161
56222
  this.queueRefineJobEvent("refine:accepted", handle);
56162
56223
  setImmediate(() => {
@@ -56212,27 +56273,27 @@ ${hintLines.join("\n")}` : "",
56212
56273
  */
56213
56274
  async stopIde(ideType, killProcess = false) {
56214
56275
  const cdpKeysToRemove = [];
56215
- for (const key of this.deps.cdpManagers.keys()) {
56216
- if (key === ideType || key.startsWith(`${ideType}_`)) {
56217
- cdpKeysToRemove.push(key);
56276
+ for (const key2 of this.deps.cdpManagers.keys()) {
56277
+ if (key2 === ideType || key2.startsWith(`${ideType}_`)) {
56278
+ cdpKeysToRemove.push(key2);
56218
56279
  }
56219
56280
  }
56220
- for (const key of cdpKeysToRemove) {
56221
- const cdp = this.deps.cdpManagers.get(key);
56281
+ for (const key2 of cdpKeysToRemove) {
56282
+ const cdp = this.deps.cdpManagers.get(key2);
56222
56283
  if (cdp) {
56223
56284
  try {
56224
56285
  cdp.disconnect();
56225
56286
  } catch {
56226
56287
  }
56227
- this.deps.cdpManagers.delete(key);
56228
- this.deps.sessionRegistry.unregisterByManagerKey(key);
56229
- LOG.info("StopIDE", `CDP disconnected: ${key}`);
56288
+ this.deps.cdpManagers.delete(key2);
56289
+ this.deps.sessionRegistry.unregisterByManagerKey(key2);
56290
+ LOG.info("StopIDE", `CDP disconnected: ${key2}`);
56230
56291
  }
56231
56292
  }
56232
56293
  const keysToRemove = [];
56233
- for (const key of this.deps.instanceManager.listInstanceIds()) {
56234
- if (key === `ide:${ideType}` || typeof key === "string" && key.startsWith(`ide:${ideType}_`)) {
56235
- keysToRemove.push(key);
56294
+ for (const key2 of this.deps.instanceManager.listInstanceIds()) {
56295
+ if (key2 === `ide:${ideType}` || typeof key2 === "string" && key2.startsWith(`ide:${ideType}_`)) {
56296
+ keysToRemove.push(key2);
56236
56297
  }
56237
56298
  }
56238
56299
  for (const instanceKey of keysToRemove) {
@@ -60925,9 +60986,9 @@ async function handleAutoImplement(ctx, type, req, res) {
60925
60986
  }
60926
60987
  if (Date.now() - lastApprovalTime < 2e3) return;
60927
60988
  if (approvalPatterns.some((p) => p.test(approvalBuffer))) {
60928
- const key = approvalKeys[1] || approvalKeys[0] || "a\r";
60929
- writeFn(key);
60930
- ctx.log(`Auto-Implement auto-approved prompt! Sending: ${JSON.stringify(key)}`);
60989
+ const key2 = approvalKeys[1] || approvalKeys[0] || "a\r";
60990
+ writeFn(key2);
60991
+ ctx.log(`Auto-Implement auto-approved prompt! Sending: ${JSON.stringify(key2)}`);
60931
60992
  sendAutoImplSSE(ctx, { event: "output", data: { chunk: `
60932
60993
  [\u{1F916} ADHDev Auto-Approve] CLI Action Approved
60933
60994
  `, stream: "stdout" } });
@@ -62179,8 +62240,8 @@ var DevServer = class _DevServer {
62179
62240
  category: p.category
62180
62241
  }));
62181
62242
  const cdpStatus = {};
62182
- for (const [key, cdp] of this.cdpManagers.entries()) {
62183
- cdpStatus[key] = { connected: cdp.isConnected };
62243
+ for (const [key2, cdp] of this.cdpManagers.entries()) {
62244
+ cdpStatus[key2] = { connected: cdp.isConnected };
62184
62245
  }
62185
62246
  this.json(res, 200, {
62186
62247
  devMode: true,
@@ -62500,16 +62561,16 @@ var DevServer = class _DevServer {
62500
62561
  errors.push(...validation.errors);
62501
62562
  warnings.push(...validation.warnings);
62502
62563
  if (config.settings) {
62503
- for (const [key, val] of Object.entries(config.settings)) {
62564
+ for (const [key2, val] of Object.entries(config.settings)) {
62504
62565
  const s2 = val;
62505
- if (!s2.type) errors.push(`settings.${key}: missing type`);
62566
+ if (!s2.type) errors.push(`settings.${key2}: missing type`);
62506
62567
  else if (!["boolean", "number", "string", "select"].includes(s2.type))
62507
- errors.push(`settings.${key}: invalid type '${s2.type}'`);
62508
- if (s2.default === void 0) warnings.push(`settings.${key}: no default value`);
62568
+ errors.push(`settings.${key2}: invalid type '${s2.type}'`);
62569
+ if (s2.default === void 0) warnings.push(`settings.${key2}: no default value`);
62509
62570
  if (s2.type === "number" && s2.min !== void 0 && s2.max !== void 0 && s2.min > s2.max)
62510
- errors.push(`settings.${key}: min (${s2.min}) > max (${s2.max})`);
62571
+ errors.push(`settings.${key2}: min (${s2.min}) > max (${s2.max})`);
62511
62572
  if (s2.type === "select" && (!s2.options || !Array.isArray(s2.options) || s2.options.length === 0))
62512
- errors.push(`settings.${key}: select type requires options[]`);
62573
+ errors.push(`settings.${key2}: select type requires options[]`);
62513
62574
  }
62514
62575
  }
62515
62576
  if (config.cdpPorts && Array.isArray(config.cdpPorts)) {
@@ -63293,21 +63354,21 @@ function isLowercaseLetter(value) {
63293
63354
  function encodeControlLetter(letter) {
63294
63355
  return String.fromCharCode(letter.charCodeAt(0) - 96);
63295
63356
  }
63296
- function encodeShiftedKey(key) {
63297
- if (isLowercaseLetter(key)) return key.toUpperCase();
63298
- if (key.startsWith("ctrl+") && isLowercaseLetter(key.slice(5))) {
63299
- return encodeControlLetter(key.slice(5));
63357
+ function encodeShiftedKey(key2) {
63358
+ if (isLowercaseLetter(key2)) return key2.toUpperCase();
63359
+ if (key2.startsWith("ctrl+") && isLowercaseLetter(key2.slice(5))) {
63360
+ return encodeControlLetter(key2.slice(5));
63300
63361
  }
63301
- if (key.startsWith("alt+") && isLowercaseLetter(key.slice(4))) {
63302
- return `\x1B${key.slice(4).toUpperCase()}`;
63362
+ if (key2.startsWith("alt+") && isLowercaseLetter(key2.slice(4))) {
63363
+ return `\x1B${key2.slice(4).toUpperCase()}`;
63303
63364
  }
63304
- if (key === "tab") return "\x1B[Z";
63305
- if (key in SHIFTED_CSI_KEYS) return SHIFTED_CSI_KEYS[key];
63306
- if (key in BASE_KEY_SEQUENCES) return BASE_KEY_SEQUENCES[key];
63307
- throw new Error(`Unsupported named key: shift+${key}`);
63365
+ if (key2 === "tab") return "\x1B[Z";
63366
+ if (key2 in SHIFTED_CSI_KEYS) return SHIFTED_CSI_KEYS[key2];
63367
+ if (key2 in BASE_KEY_SEQUENCES) return BASE_KEY_SEQUENCES[key2];
63368
+ throw new Error(`Unsupported named key: shift+${key2}`);
63308
63369
  }
63309
- function namedKeyToAnsi(key) {
63310
- const normalized = String(key || "").trim().toLowerCase();
63370
+ function namedKeyToAnsi(key2) {
63371
+ const normalized = String(key2 || "").trim().toLowerCase();
63311
63372
  if (normalized in BASE_KEY_SEQUENCES) return BASE_KEY_SEQUENCES[normalized];
63312
63373
  if (normalized.startsWith("ctrl+") && isLowercaseLetter(normalized.slice(5))) {
63313
63374
  return encodeControlLetter(normalized.slice(5));
@@ -63316,7 +63377,7 @@ function namedKeyToAnsi(key) {
63316
63377
  return `\x1B${normalized.slice(4)}`;
63317
63378
  }
63318
63379
  if (normalized.startsWith("shift+")) return encodeShiftedKey(normalized.slice(6));
63319
- throw new Error(`Unsupported named key: ${key}`);
63380
+ throw new Error(`Unsupported named key: ${key2}`);
63320
63381
  }
63321
63382
  function namedKeysToAnsi(keys) {
63322
63383
  if (!Array.isArray(keys)) throw new Error("keys must be an array");
@@ -63794,19 +63855,19 @@ var SessionRegistry = class {
63794
63855
  if (!ids) return [];
63795
63856
  return [...ids].map((id) => this.bySessionId.get(id)).filter(Boolean);
63796
63857
  }
63797
- addIndex(index, key, sessionId) {
63798
- let set = index.get(key);
63858
+ addIndex(index, key2, sessionId) {
63859
+ let set = index.get(key2);
63799
63860
  if (!set) {
63800
63861
  set = /* @__PURE__ */ new Set();
63801
- index.set(key, set);
63862
+ index.set(key2, set);
63802
63863
  }
63803
63864
  set.add(sessionId);
63804
63865
  }
63805
- removeIndex(index, key, sessionId) {
63806
- const set = index.get(key);
63866
+ removeIndex(index, key2, sessionId) {
63867
+ const set = index.get(key2);
63807
63868
  if (!set) return;
63808
63869
  set.delete(sessionId);
63809
- if (set.size === 0) index.delete(key);
63870
+ if (set.size === 0) index.delete(key2);
63810
63871
  }
63811
63872
  };
63812
63873
 
@@ -64467,6 +64528,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
64467
64528
  buildToolChatMessage,
64468
64529
  buildUserChatMessage,
64469
64530
  cancelTask,
64531
+ canonicalDaemonId,
64470
64532
  claimNextTask,
64471
64533
  classifyChatMessageVisibility,
64472
64534
  classifyHotChatSessionsForSubscriptionFlush,