@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.mjs CHANGED
@@ -38,6 +38,9 @@ function resolveNodeSchedulingPriority(nodePolicy) {
38
38
  function resolveAutoConvergeCodeChange(policy) {
39
39
  return policy?.autoConvergeCodeChange === true;
40
40
  }
41
+ function resolveCoordinatorIdlePushPolicy(meshPolicy) {
42
+ return meshPolicy?.coordinatorIdlePushPolicy === "auto_silent_on_dispatch" ? "auto_silent_on_dispatch" : "always";
43
+ }
41
44
  function resolveMagiSessionCleanupMode(value) {
42
45
  if (value === void 0 || value === null) return DEFAULT_MESH_POLICY.magiSessionCleanup;
43
46
  if (typeof value === "boolean") return value ? "stop_and_delete" : "preserve";
@@ -108,6 +111,11 @@ function mergeAndNormalizePolicy(base, patch) {
108
111
  } else {
109
112
  delete policy.autoConvergeCodeChange;
110
113
  }
114
+ if (policy.coordinatorIdlePushPolicy === "auto_silent_on_dispatch") {
115
+ policy.coordinatorIdlePushPolicy = "auto_silent_on_dispatch";
116
+ } else {
117
+ delete policy.coordinatorIdlePushPolicy;
118
+ }
111
119
  return policy;
112
120
  }
113
121
  function resolveDelegatedWorkerAutoApprove(meshPolicy, nodePolicy) {
@@ -143,7 +151,7 @@ function resolveProviderMaxParallel(slots, providerType) {
143
151
  }
144
152
  return total;
145
153
  }
146
- 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;
154
+ 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;
147
155
  var init_repo_mesh_types = __esm({
148
156
  "src/repo-mesh-types.ts"() {
149
157
  "use strict";
@@ -184,8 +192,14 @@ var init_repo_mesh_types = __esm({
184
192
  maxTaskRetries: 1,
185
193
  // Nudge the coordinator when the mesh is fully idle but active missions linger,
186
194
  // so a mission is never left drifting in `active` after its work is really done.
187
- idleActiveMissionReminder: true
195
+ idleActiveMissionReminder: true,
196
+ // Conservative default: every coordinator-dispatched worker completion still
197
+ // notifies the owner. Opt into 'auto_silent_on_dispatch' to one-shot-silence the
198
+ // routine idle push for a coordinator-driven task (approval/failure notifications
199
+ // are never affected — see coordinatorIdlePushPolicy).
200
+ coordinatorIdlePushPolicy: "always"
188
201
  };
202
+ SILENT_IDLE_PUSH_TTL_MS = 10 * 60 * 1e3;
189
203
  SESSION_CLEANUP_MODES = /* @__PURE__ */ new Set([
190
204
  "preserve",
191
205
  "stop",
@@ -423,10 +437,10 @@ function readInjected(value) {
423
437
  }
424
438
  function getDaemonBuildInfo() {
425
439
  if (cached) return cached;
426
- const commit = readInjected(true ? "90ea4b1b6f757c6e04138534d78952c22fb04a46" : void 0) ?? "unknown";
427
- const commitShort = readInjected(true ? "90ea4b1" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
428
- const version = readInjected(true ? "1.0.9" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
429
- const builtAt = readInjected(true ? "2026-07-20T06:31:22.466Z" : void 0);
440
+ const commit = readInjected(true ? "0eb6e094bf393362ce12dee81e2b08683f7b16b0" : void 0) ?? "unknown";
441
+ const commitShort = readInjected(true ? "0eb6e094" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
442
+ const version = readInjected(true ? "1.0.10-rc.1" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
443
+ const builtAt = readInjected(true ? "2026-07-20T10:57:00.620Z" : void 0);
430
444
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
431
445
  return cached;
432
446
  }
@@ -4073,6 +4087,9 @@ function buildPolicySection(policy) {
4073
4087
  }[policy.dirtyWorkspaceBehavior] || "";
4074
4088
  if (dirtyBehavior) rules.push(dirtyBehavior);
4075
4089
  rules.push(`- Maximum **${policy.maxParallelTasks}** tasks running in parallel`);
4090
+ if (policy.coordinatorIdlePushPolicy === "auto_silent_on_dispatch") {
4091
+ 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)");
4092
+ }
4076
4093
  return `## Policy
4077
4094
  ${rules.join("\n")}`;
4078
4095
  }
@@ -9477,7 +9494,12 @@ function drainPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId, opts) {
9477
9494
  }
9478
9495
  }
9479
9496
  } catch (e) {
9480
- LOG.warn("MeshEvents", `SQLite pending-event drain failed for mesh ${meshId}; JSONL fallback only: ${e?.message || e}`);
9497
+ if (!loggedSqlitePendingDrainFailure) {
9498
+ loggedSqlitePendingDrainFailure = true;
9499
+ LOG.warn("MeshEvents", `SQLite pending-event drain failed for mesh ${meshId}; JSONL fallback only (further occurrences at debug): ${e?.message || e}`);
9500
+ } else {
9501
+ LOG.debug("MeshEvents", `SQLite pending-event drain failed for mesh ${meshId}; JSONL fallback only: ${e?.message || e}`);
9502
+ }
9481
9503
  }
9482
9504
  const paths = primaryDaemonId ? [getPendingEventsPath(meshId, primaryDaemonId), getPendingEventsPath(meshId)] : [getPendingEventsPath(meshId)];
9483
9505
  for (const path45 of paths) {
@@ -9668,7 +9690,7 @@ function clearPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId) {
9668
9690
  }
9669
9691
  }
9670
9692
  }
9671
- var 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;
9693
+ var 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;
9672
9694
  var init_mesh_events_pending = __esm({
9673
9695
  "src/mesh/mesh-events-pending.ts"() {
9674
9696
  "use strict";
@@ -9706,6 +9728,7 @@ var init_mesh_events_pending = __esm({
9706
9728
  v1UnversionedQuarantined: 0
9707
9729
  };
9708
9730
  warnedV2Violations = /* @__PURE__ */ new Set();
9731
+ loggedSqlitePendingDrainFailure = false;
9709
9732
  TERMINAL_COMPLETION_EVENTS = /* @__PURE__ */ new Set(["agent:generating_completed", "agent:stopped"]);
9710
9733
  MAX_PENDING_EVENTS_BYTES = 100 * 1024;
9711
9734
  MAX_PENDING_EVENTS_KEEP = 50;
@@ -16333,6 +16356,7 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
16333
16356
  LOG.info("MeshQueue", `Node ${nodeId} (${sessionId}) pulled task ${task.id}`);
16334
16357
  retractActionableSkipIfPreviouslyNotified(meshId, task.id);
16335
16358
  beginTaskDispatchInFlight(meshId, task.id);
16359
+ const silentIdlePushOnDispatch = resolveCoordinatorIdlePushPolicy(mesh?.policy) === "auto_silent_on_dispatch";
16336
16360
  const remoteDaemonId = readMeshNodeDaemonId(node ?? {});
16337
16361
  if (remoteDaemonId && components.dispatchMeshCommand) {
16338
16362
  const isLocalNode = components.cliManager.adapters.has(sessionId);
@@ -16355,7 +16379,8 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
16355
16379
  // already-in-flight stale inject rejectable on arrival.
16356
16380
  ...typeof task.dispatchNonce === "number" ? { dispatchNonce: task.dispatchNonce } : {},
16357
16381
  ...localDaemonIdForDispatch ? { coordinatorDaemonId: localDaemonIdForDispatch } : {},
16358
- ...sourceCoordinatorSessionId ? { coordinatorSessionId: sourceCoordinatorSessionId } : {}
16382
+ ...sourceCoordinatorSessionId ? { coordinatorSessionId: sourceCoordinatorSessionId } : {},
16383
+ ...silentIdlePushOnDispatch ? { silentIdlePush: true } : {}
16359
16384
  }
16360
16385
  }),
16361
16386
  {
@@ -16415,7 +16440,8 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
16415
16440
  // REDRIVE-DUP: carry the current dispatch nonce (see remote branch above).
16416
16441
  ...typeof task.dispatchNonce === "number" ? { dispatchNonce: task.dispatchNonce } : {},
16417
16442
  ...localCoordinatorDaemonId() ? { coordinatorDaemonId: localCoordinatorDaemonId() } : {},
16418
- ...readNonEmptyString2(task.sourceCoordinatorSessionId) ? { coordinatorSessionId: readNonEmptyString2(task.sourceCoordinatorSessionId) } : {}
16443
+ ...readNonEmptyString2(task.sourceCoordinatorSessionId) ? { coordinatorSessionId: readNonEmptyString2(task.sourceCoordinatorSessionId) } : {},
16444
+ ...silentIdlePushOnDispatch ? { silentIdlePush: true } : {}
16419
16445
  }
16420
16446
  }),
16421
16447
  {
@@ -19470,8 +19496,18 @@ function resolveSurfaceHidden(settings) {
19470
19496
  if (settings.userHidden === false) return false;
19471
19497
  return settings.spawnedSessionVisibility === "hidden" || isCoordinatorSpawnedHiddenWorker(settings);
19472
19498
  }
19473
- function resolveMuted(settings) {
19499
+ function isSilentIdlePushArmActive(settings, status) {
19500
+ if (!settings || settings.silentNextIdlePush !== true) return false;
19501
+ if (status !== "idle") return false;
19502
+ const armedAt = Number(settings.silentNextIdlePushArmedAt);
19503
+ if (!Number.isFinite(armedAt) || armedAt <= 0) {
19504
+ return true;
19505
+ }
19506
+ return Date.now() - armedAt <= SILENT_IDLE_PUSH_TTL_MS;
19507
+ }
19508
+ function resolveMuted(settings, status) {
19474
19509
  if (!settings) return false;
19510
+ if (isSilentIdlePushArmActive(settings, status)) return true;
19475
19511
  if (settings.userMuted === true) return true;
19476
19512
  if (settings.userMuted === false) return false;
19477
19513
  return isCoordinatorSpawnedHiddenWorker(settings);
@@ -19645,6 +19681,7 @@ function buildCliSession(state, options) {
19645
19681
  const effectiveMeshId = meshCoordinatorFor || registryEntry?.meshId;
19646
19682
  const coordinator = effectiveMeshId ? { meshId: effectiveMeshId, role: "coordinator" } : void 0;
19647
19683
  const meshQueueStats = effectiveMeshId ? getMeshQueueStats(effectiveMeshId) : void 0;
19684
+ const resolvedStatus = resolveSessionStatus(activeChat, state.status);
19648
19685
  return {
19649
19686
  id: state.instanceId,
19650
19687
  parentId: null,
@@ -19653,7 +19690,7 @@ function buildCliSession(state, options) {
19653
19690
  providerSessionId: state.providerSessionId,
19654
19691
  kind: "agent",
19655
19692
  transport: "pty",
19656
- status: resolveSessionStatus(activeChat, state.status),
19693
+ status: resolvedStatus,
19657
19694
  title: activeChat?.title || state.name,
19658
19695
  workspace,
19659
19696
  ...git && { git },
@@ -19692,7 +19729,9 @@ function buildCliSession(state, options) {
19692
19729
  // `!== undefined` fields, so an absent field on false never overwrote a prior true —
19693
19730
  // the toggle-off direction silently stuck. See session-entry-merge.ts.
19694
19731
  surfaceHidden: resolveSurfaceHidden(state.settings),
19695
- muted: resolveMuted(state.settings)
19732
+ // status-gated so a one-shot silent-idle arm mutes ONLY the idle/completion
19733
+ // snapshot, never an approval/generating frame in the same turn.
19734
+ muted: resolveMuted(state.settings, resolvedStatus)
19696
19735
  };
19697
19736
  }
19698
19737
  function buildAcpSession(state, options) {
@@ -19709,6 +19748,7 @@ function buildAcpSession(state, options) {
19709
19748
  const effectiveMeshId = meshCoordinatorFor || registryEntry?.meshId;
19710
19749
  const coordinator = effectiveMeshId ? { meshId: effectiveMeshId, role: "coordinator" } : void 0;
19711
19750
  const meshQueueStats = effectiveMeshId ? getMeshQueueStats(effectiveMeshId) : void 0;
19751
+ const resolvedStatus = resolveSessionStatus(activeChat, state.status);
19712
19752
  return {
19713
19753
  id: state.instanceId,
19714
19754
  parentId: null,
@@ -19716,7 +19756,7 @@ function buildAcpSession(state, options) {
19716
19756
  providerName: state.name,
19717
19757
  kind: "agent",
19718
19758
  transport: "acp",
19719
- status: resolveSessionStatus(activeChat, state.status),
19759
+ status: resolvedStatus,
19720
19760
  title: activeChat?.title || state.name,
19721
19761
  workspace,
19722
19762
  ...git && { git },
@@ -19736,7 +19776,8 @@ function buildAcpSession(state, options) {
19736
19776
  // Emit explicitly (including false) so un-hide/un-mute clears a prior true downstream —
19737
19777
  // see buildCliSession above and session-entry-merge.ts.
19738
19778
  surfaceHidden: resolveSurfaceHidden(state.settings),
19739
- muted: resolveMuted(state.settings)
19779
+ // status-gated one-shot silent-idle arm — see buildCliSession above.
19780
+ muted: resolveMuted(state.settings, resolvedStatus)
19740
19781
  };
19741
19782
  }
19742
19783
  function buildSessionEntries(allStates, cdpManagers, options = {}) {
@@ -19773,6 +19814,7 @@ var init_builders = __esm({
19773
19814
  "use strict";
19774
19815
  init_normalize();
19775
19816
  init_mesh_work_queue();
19817
+ init_repo_mesh_types();
19776
19818
  init_coordinator_registry();
19777
19819
  init_provider_patch_state();
19778
19820
  init_summary_metadata();
@@ -22744,19 +22786,19 @@ async function runMeshReconcileTick(components) {
22744
22786
  }
22745
22787
  }
22746
22788
  }
22747
- for (const mesh of listMeshes()) {
22748
- const selfIds = resolveCoordinatorSelfIds(mesh, drainDaemonIds);
22749
- if (!daemonHostsMesh(mesh, selfIds)) continue;
22750
- if (store) {
22789
+ if (store) {
22790
+ for (const mesh of listMeshes()) {
22791
+ const selfIds = resolveCoordinatorSelfIds(mesh, drainDaemonIds);
22792
+ if (!daemonHostsMesh(mesh, selfIds)) continue;
22751
22793
  try {
22752
22794
  if (store.pendingQueueTaskCount(mesh.id) === 0) continue;
22753
22795
  } catch {
22754
22796
  }
22755
- }
22756
- try {
22757
- await triggerMeshQueue(components, mesh.id);
22758
- } catch (e) {
22759
- LOG.warn("MeshReconcile", `Pending-claim recovery trigger failed for mesh ${mesh.id}: ${e?.message || e}`);
22797
+ try {
22798
+ await triggerMeshQueue(components, mesh.id);
22799
+ } catch (e) {
22800
+ LOG.warn("MeshReconcile", `Pending-claim recovery trigger failed for mesh ${mesh.id}: ${e?.message || e}`);
22801
+ }
22760
22802
  }
22761
22803
  }
22762
22804
  for (const mesh of listMeshes()) {
@@ -49300,6 +49342,9 @@ var CliProviderInstance = class _CliProviderInstance {
49300
49342
  ...opts.evidenceLevel !== void 0 ? { evidenceLevel: opts.evidenceLevel } : {},
49301
49343
  ...opts.completionDiagnostic !== void 0 ? { completionDiagnostic: opts.completionDiagnostic } : {}
49302
49344
  });
49345
+ if (this.settings?.silentNextIdlePush === true) {
49346
+ this.updateSettings({ silentNextIdlePush: void 0, silentNextIdlePushArmedAt: void 0 });
49347
+ }
49303
49348
  }
49304
49349
  /**
49305
49350
  * AUTOAPPROVE-FLAP-INBOX-MISSING sticky-approval overlay. Returns the adapterStatus a
@@ -52834,6 +52879,18 @@ Run 'adhdev doctor' for detailed diagnostics.`
52834
52879
  if (stampResult && stampResult.stamped === false && stampResult.reason === "task_already_stamped_on_live_instance") {
52835
52880
  throw new Error(`Refusing duplicate mesh dispatch: task ${meshContext.taskId} is already being worked by a live session on this daemon`);
52836
52881
  }
52882
+ if (meshContext.silentIdlePush === true) {
52883
+ try {
52884
+ const workerInst = this.deps.getInstanceManager()?.getInstance(targetInstanceId);
52885
+ if (workerInst && typeof workerInst.updateSettings === "function") {
52886
+ workerInst.updateSettings({
52887
+ silentNextIdlePush: true,
52888
+ silentNextIdlePushArmedAt: Date.now()
52889
+ });
52890
+ }
52891
+ } catch {
52892
+ }
52893
+ }
52837
52894
  }
52838
52895
  const input = normalizeInputEnvelope(args?.input ? { input: args.input } : args);
52839
52896
  const provider = this.providerLoader.resolve(agentType) || this.providerLoader.getMeta(agentType);