@adhdev/daemon-core 1.0.9 → 1.0.10-rc.1

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
@@ -43,6 +43,9 @@ function resolveNodeSchedulingPriority(nodePolicy) {
43
43
  function resolveAutoConvergeCodeChange(policy) {
44
44
  return policy?.autoConvergeCodeChange === true;
45
45
  }
46
+ function resolveCoordinatorIdlePushPolicy(meshPolicy) {
47
+ return meshPolicy?.coordinatorIdlePushPolicy === "auto_silent_on_dispatch" ? "auto_silent_on_dispatch" : "always";
48
+ }
46
49
  function resolveMagiSessionCleanupMode(value) {
47
50
  if (value === void 0 || value === null) return DEFAULT_MESH_POLICY.magiSessionCleanup;
48
51
  if (typeof value === "boolean") return value ? "stop_and_delete" : "preserve";
@@ -113,6 +116,11 @@ function mergeAndNormalizePolicy(base, patch) {
113
116
  } else {
114
117
  delete policy.autoConvergeCodeChange;
115
118
  }
119
+ if (policy.coordinatorIdlePushPolicy === "auto_silent_on_dispatch") {
120
+ policy.coordinatorIdlePushPolicy = "auto_silent_on_dispatch";
121
+ } else {
122
+ delete policy.coordinatorIdlePushPolicy;
123
+ }
116
124
  return policy;
117
125
  }
118
126
  function resolveDelegatedWorkerAutoApprove(meshPolicy, nodePolicy) {
@@ -148,7 +156,7 @@ function resolveProviderMaxParallel(slots, providerType) {
148
156
  }
149
157
  return total;
150
158
  }
151
- var MESH_SCHEDULING_STRATEGIES, DEFAULT_MESH_SCHEDULING_STRATEGY, MESH_CONVERGE_REFINE_TAG, MESH_CONVERGE_FAST_FORWARD_TAG, DEFAULT_MESH_POLICY, SESSION_CLEANUP_MODES, SPAWNED_SESSION_VISIBILITY_MODES, DIRTY_WORKSPACE_BEHAVIORS, MESH_MAX_PARALLEL_TASKS_MIN, MESH_MAX_PARALLEL_TASKS_MAX, DEFAULT_MESH_READONLY_MULTIPLIER;
159
+ var MESH_SCHEDULING_STRATEGIES, DEFAULT_MESH_SCHEDULING_STRATEGY, MESH_CONVERGE_REFINE_TAG, MESH_CONVERGE_FAST_FORWARD_TAG, DEFAULT_MESH_POLICY, SILENT_IDLE_PUSH_TTL_MS, SESSION_CLEANUP_MODES, SPAWNED_SESSION_VISIBILITY_MODES, DIRTY_WORKSPACE_BEHAVIORS, MESH_MAX_PARALLEL_TASKS_MIN, MESH_MAX_PARALLEL_TASKS_MAX, DEFAULT_MESH_READONLY_MULTIPLIER;
152
160
  var init_repo_mesh_types = __esm({
153
161
  "src/repo-mesh-types.ts"() {
154
162
  "use strict";
@@ -189,8 +197,14 @@ var init_repo_mesh_types = __esm({
189
197
  maxTaskRetries: 1,
190
198
  // Nudge the coordinator when the mesh is fully idle but active missions linger,
191
199
  // so a mission is never left drifting in `active` after its work is really done.
192
- idleActiveMissionReminder: true
200
+ idleActiveMissionReminder: true,
201
+ // Conservative default: every coordinator-dispatched worker completion still
202
+ // notifies the owner. Opt into 'auto_silent_on_dispatch' to one-shot-silence the
203
+ // routine idle push for a coordinator-driven task (approval/failure notifications
204
+ // are never affected — see coordinatorIdlePushPolicy).
205
+ coordinatorIdlePushPolicy: "always"
193
206
  };
207
+ SILENT_IDLE_PUSH_TTL_MS = 10 * 60 * 1e3;
194
208
  SESSION_CLEANUP_MODES = /* @__PURE__ */ new Set([
195
209
  "preserve",
196
210
  "stop",
@@ -428,10 +442,10 @@ function readInjected(value) {
428
442
  }
429
443
  function getDaemonBuildInfo() {
430
444
  if (cached) return cached;
431
- const commit = readInjected(true ? "90ea4b1b6f757c6e04138534d78952c22fb04a46" : void 0) ?? "unknown";
432
- const commitShort = readInjected(true ? "90ea4b1" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
433
- const version = readInjected(true ? "1.0.9" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
434
- const builtAt = readInjected(true ? "2026-07-20T06:31:22.466Z" : void 0);
445
+ const commit = readInjected(true ? "0eb6e094bf393362ce12dee81e2b08683f7b16b0" : void 0) ?? "unknown";
446
+ const commitShort = readInjected(true ? "0eb6e094" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
447
+ const version = readInjected(true ? "1.0.10-rc.1" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
448
+ const builtAt = readInjected(true ? "2026-07-20T10:57:00.620Z" : void 0);
435
449
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
436
450
  return cached;
437
451
  }
@@ -4076,6 +4090,9 @@ function buildPolicySection(policy) {
4076
4090
  }[policy.dirtyWorkspaceBehavior] || "";
4077
4091
  if (dirtyBehavior) rules.push(dirtyBehavior);
4078
4092
  rules.push(`- Maximum **${policy.maxParallelTasks}** tasks running in parallel`);
4093
+ if (policy.coordinatorIdlePushPolicy === "auto_silent_on_dispatch") {
4094
+ rules.push("- Delegated-worker completions are **auto-silenced**: the routine idle/completion push for a task you dispatch is suppressed once (approval-needed, failure, and long-running alerts still notify the owner normally)");
4095
+ }
4079
4096
  return `## Policy
4080
4097
  ${rules.join("\n")}`;
4081
4098
  }
@@ -9481,7 +9498,12 @@ function drainPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId, opts) {
9481
9498
  }
9482
9499
  }
9483
9500
  } catch (e) {
9484
- LOG.warn("MeshEvents", `SQLite pending-event drain failed for mesh ${meshId}; JSONL fallback only: ${e?.message || e}`);
9501
+ if (!loggedSqlitePendingDrainFailure) {
9502
+ loggedSqlitePendingDrainFailure = true;
9503
+ LOG.warn("MeshEvents", `SQLite pending-event drain failed for mesh ${meshId}; JSONL fallback only (further occurrences at debug): ${e?.message || e}`);
9504
+ } else {
9505
+ LOG.debug("MeshEvents", `SQLite pending-event drain failed for mesh ${meshId}; JSONL fallback only: ${e?.message || e}`);
9506
+ }
9485
9507
  }
9486
9508
  const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
9487
9509
  for (const path45 of paths) {
@@ -9672,7 +9694,7 @@ function clearPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId) {
9672
9694
  }
9673
9695
  }
9674
9696
  }
9675
- var import_fs6, import_path6, import_crypto7, REFINE_TERMINAL_EVENTS, meshV2DrainCounters, warnedV2Violations, TERMINAL_COMPLETION_EVENTS, MAX_PENDING_EVENTS_BYTES, MAX_PENDING_EVENTS_KEEP, PENDING_EVENTS_DRAINED_RETENTION_MS, PENDING_EVENTS_UNDRAINED_RETENTION_MS;
9697
+ var import_fs6, import_path6, import_crypto7, REFINE_TERMINAL_EVENTS, meshV2DrainCounters, warnedV2Violations, loggedSqlitePendingDrainFailure, TERMINAL_COMPLETION_EVENTS, MAX_PENDING_EVENTS_BYTES, MAX_PENDING_EVENTS_KEEP, PENDING_EVENTS_DRAINED_RETENTION_MS, PENDING_EVENTS_UNDRAINED_RETENTION_MS;
9676
9698
  var init_mesh_events_pending = __esm({
9677
9699
  "src/mesh/mesh-events-pending.ts"() {
9678
9700
  "use strict";
@@ -9713,6 +9735,7 @@ var init_mesh_events_pending = __esm({
9713
9735
  v1UnversionedQuarantined: 0
9714
9736
  };
9715
9737
  warnedV2Violations = /* @__PURE__ */ new Set();
9738
+ loggedSqlitePendingDrainFailure = false;
9716
9739
  TERMINAL_COMPLETION_EVENTS = /* @__PURE__ */ new Set(["agent:generating_completed", "agent:stopped"]);
9717
9740
  MAX_PENDING_EVENTS_BYTES = 100 * 1024;
9718
9741
  MAX_PENDING_EVENTS_KEEP = 50;
@@ -16330,6 +16353,7 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
16330
16353
  LOG.info("MeshQueue", `Node ${nodeId} (${sessionId}) pulled task ${task.id}`);
16331
16354
  retractActionableSkipIfPreviouslyNotified(meshId, task.id);
16332
16355
  beginTaskDispatchInFlight(meshId, task.id);
16356
+ const silentIdlePushOnDispatch = resolveCoordinatorIdlePushPolicy(mesh?.policy) === "auto_silent_on_dispatch";
16333
16357
  const remoteDaemonId = readMeshNodeDaemonId(node ?? {});
16334
16358
  if (remoteDaemonId && components.dispatchMeshCommand) {
16335
16359
  const isLocalNode = components.cliManager.adapters.has(sessionId);
@@ -16352,7 +16376,8 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
16352
16376
  // already-in-flight stale inject rejectable on arrival.
16353
16377
  ...typeof task.dispatchNonce === "number" ? { dispatchNonce: task.dispatchNonce } : {},
16354
16378
  ...localDaemonIdForDispatch ? { coordinatorDaemonId: localDaemonIdForDispatch } : {},
16355
- ...sourceCoordinatorSessionId ? { coordinatorSessionId: sourceCoordinatorSessionId } : {}
16379
+ ...sourceCoordinatorSessionId ? { coordinatorSessionId: sourceCoordinatorSessionId } : {},
16380
+ ...silentIdlePushOnDispatch ? { silentIdlePush: true } : {}
16356
16381
  }
16357
16382
  }),
16358
16383
  {
@@ -16412,7 +16437,8 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
16412
16437
  // REDRIVE-DUP: carry the current dispatch nonce (see remote branch above).
16413
16438
  ...typeof task.dispatchNonce === "number" ? { dispatchNonce: task.dispatchNonce } : {},
16414
16439
  ...localCoordinatorDaemonId() ? { coordinatorDaemonId: localCoordinatorDaemonId() } : {},
16415
- ...readNonEmptyString2(task.sourceCoordinatorSessionId) ? { coordinatorSessionId: readNonEmptyString2(task.sourceCoordinatorSessionId) } : {}
16440
+ ...readNonEmptyString2(task.sourceCoordinatorSessionId) ? { coordinatorSessionId: readNonEmptyString2(task.sourceCoordinatorSessionId) } : {},
16441
+ ...silentIdlePushOnDispatch ? { silentIdlePush: true } : {}
16416
16442
  }
16417
16443
  }),
16418
16444
  {
@@ -19468,8 +19494,18 @@ function resolveSurfaceHidden(settings) {
19468
19494
  if (settings.userHidden === false) return false;
19469
19495
  return settings.spawnedSessionVisibility === "hidden" || isCoordinatorSpawnedHiddenWorker(settings);
19470
19496
  }
19471
- function resolveMuted(settings) {
19497
+ function isSilentIdlePushArmActive(settings, status) {
19498
+ if (!settings || settings.silentNextIdlePush !== true) return false;
19499
+ if (status !== "idle") return false;
19500
+ const armedAt = Number(settings.silentNextIdlePushArmedAt);
19501
+ if (!Number.isFinite(armedAt) || armedAt <= 0) {
19502
+ return true;
19503
+ }
19504
+ return Date.now() - armedAt <= SILENT_IDLE_PUSH_TTL_MS;
19505
+ }
19506
+ function resolveMuted(settings, status) {
19472
19507
  if (!settings) return false;
19508
+ if (isSilentIdlePushArmActive(settings, status)) return true;
19473
19509
  if (settings.userMuted === true) return true;
19474
19510
  if (settings.userMuted === false) return false;
19475
19511
  return isCoordinatorSpawnedHiddenWorker(settings);
@@ -19643,6 +19679,7 @@ function buildCliSession(state, options) {
19643
19679
  const effectiveMeshId = meshCoordinatorFor || registryEntry?.meshId;
19644
19680
  const coordinator = effectiveMeshId ? { meshId: effectiveMeshId, role: "coordinator" } : void 0;
19645
19681
  const meshQueueStats = effectiveMeshId ? getMeshQueueStats(effectiveMeshId) : void 0;
19682
+ const resolvedStatus = resolveSessionStatus(activeChat, state.status);
19646
19683
  return {
19647
19684
  id: state.instanceId,
19648
19685
  parentId: null,
@@ -19651,7 +19688,7 @@ function buildCliSession(state, options) {
19651
19688
  providerSessionId: state.providerSessionId,
19652
19689
  kind: "agent",
19653
19690
  transport: "pty",
19654
- status: resolveSessionStatus(activeChat, state.status),
19691
+ status: resolvedStatus,
19655
19692
  title: activeChat?.title || state.name,
19656
19693
  workspace,
19657
19694
  ...git && { git },
@@ -19690,7 +19727,9 @@ function buildCliSession(state, options) {
19690
19727
  // `!== undefined` fields, so an absent field on false never overwrote a prior true —
19691
19728
  // the toggle-off direction silently stuck. See session-entry-merge.ts.
19692
19729
  surfaceHidden: resolveSurfaceHidden(state.settings),
19693
- muted: resolveMuted(state.settings)
19730
+ // status-gated so a one-shot silent-idle arm mutes ONLY the idle/completion
19731
+ // snapshot, never an approval/generating frame in the same turn.
19732
+ muted: resolveMuted(state.settings, resolvedStatus)
19694
19733
  };
19695
19734
  }
19696
19735
  function buildAcpSession(state, options) {
@@ -19707,6 +19746,7 @@ function buildAcpSession(state, options) {
19707
19746
  const effectiveMeshId = meshCoordinatorFor || registryEntry?.meshId;
19708
19747
  const coordinator = effectiveMeshId ? { meshId: effectiveMeshId, role: "coordinator" } : void 0;
19709
19748
  const meshQueueStats = effectiveMeshId ? getMeshQueueStats(effectiveMeshId) : void 0;
19749
+ const resolvedStatus = resolveSessionStatus(activeChat, state.status);
19710
19750
  return {
19711
19751
  id: state.instanceId,
19712
19752
  parentId: null,
@@ -19714,7 +19754,7 @@ function buildAcpSession(state, options) {
19714
19754
  providerName: state.name,
19715
19755
  kind: "agent",
19716
19756
  transport: "acp",
19717
- status: resolveSessionStatus(activeChat, state.status),
19757
+ status: resolvedStatus,
19718
19758
  title: activeChat?.title || state.name,
19719
19759
  workspace,
19720
19760
  ...git && { git },
@@ -19734,7 +19774,8 @@ function buildAcpSession(state, options) {
19734
19774
  // Emit explicitly (including false) so un-hide/un-mute clears a prior true downstream —
19735
19775
  // see buildCliSession above and session-entry-merge.ts.
19736
19776
  surfaceHidden: resolveSurfaceHidden(state.settings),
19737
- muted: resolveMuted(state.settings)
19777
+ // status-gated one-shot silent-idle arm — see buildCliSession above.
19778
+ muted: resolveMuted(state.settings, resolvedStatus)
19738
19779
  };
19739
19780
  }
19740
19781
  function buildSessionEntries(allStates, cdpManagers, options = {}) {
@@ -19771,6 +19812,7 @@ var init_builders = __esm({
19771
19812
  "use strict";
19772
19813
  init_normalize();
19773
19814
  init_mesh_work_queue();
19815
+ init_repo_mesh_types();
19774
19816
  init_coordinator_registry();
19775
19817
  init_provider_patch_state();
19776
19818
  init_summary_metadata();
@@ -22742,19 +22784,19 @@ async function runMeshReconcileTick(components) {
22742
22784
  }
22743
22785
  }
22744
22786
  }
22745
- for (const mesh of listMeshes()) {
22746
- const selfIds = resolveCoordinatorSelfIds(mesh, drainDaemonIds);
22747
- if (!daemonHostsMesh(mesh, selfIds)) continue;
22748
- if (store) {
22787
+ if (store) {
22788
+ for (const mesh of listMeshes()) {
22789
+ const selfIds = resolveCoordinatorSelfIds(mesh, drainDaemonIds);
22790
+ if (!daemonHostsMesh(mesh, selfIds)) continue;
22749
22791
  try {
22750
22792
  if (store.pendingQueueTaskCount(mesh.id) === 0) continue;
22751
22793
  } catch {
22752
22794
  }
22753
- }
22754
- try {
22755
- await triggerMeshQueue(components, mesh.id);
22756
- } catch (e) {
22757
- LOG.warn("MeshReconcile", `Pending-claim recovery trigger failed for mesh ${mesh.id}: ${e?.message || e}`);
22795
+ try {
22796
+ await triggerMeshQueue(components, mesh.id);
22797
+ } catch (e) {
22798
+ LOG.warn("MeshReconcile", `Pending-claim recovery trigger failed for mesh ${mesh.id}: ${e?.message || e}`);
22799
+ }
22758
22800
  }
22759
22801
  }
22760
22802
  for (const mesh of listMeshes()) {
@@ -49733,6 +49775,9 @@ var CliProviderInstance = class _CliProviderInstance {
49733
49775
  ...opts.evidenceLevel !== void 0 ? { evidenceLevel: opts.evidenceLevel } : {},
49734
49776
  ...opts.completionDiagnostic !== void 0 ? { completionDiagnostic: opts.completionDiagnostic } : {}
49735
49777
  });
49778
+ if (this.settings?.silentNextIdlePush === true) {
49779
+ this.updateSettings({ silentNextIdlePush: void 0, silentNextIdlePushArmedAt: void 0 });
49780
+ }
49736
49781
  }
49737
49782
  /**
49738
49783
  * AUTOAPPROVE-FLAP-INBOX-MISSING sticky-approval overlay. Returns the adapterStatus a
@@ -53262,6 +53307,18 @@ Run 'adhdev doctor' for detailed diagnostics.`
53262
53307
  if (stampResult && stampResult.stamped === false && stampResult.reason === "task_already_stamped_on_live_instance") {
53263
53308
  throw new Error(`Refusing duplicate mesh dispatch: task ${meshContext.taskId} is already being worked by a live session on this daemon`);
53264
53309
  }
53310
+ if (meshContext.silentIdlePush === true) {
53311
+ try {
53312
+ const workerInst = this.deps.getInstanceManager()?.getInstance(targetInstanceId);
53313
+ if (workerInst && typeof workerInst.updateSettings === "function") {
53314
+ workerInst.updateSettings({
53315
+ silentNextIdlePush: true,
53316
+ silentNextIdlePushArmedAt: Date.now()
53317
+ });
53318
+ }
53319
+ } catch {
53320
+ }
53321
+ }
53265
53322
  }
53266
53323
  const input = normalizeInputEnvelope(args?.input ? { input: args.input } : args);
53267
53324
  const provider = this.providerLoader.resolve(agentType) || this.providerLoader.getMeta(agentType);