@adhdev/daemon-core 0.9.82-rc.235 → 0.9.82-rc.236

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.82-rc.235",
3
+ "version": "0.9.82-rc.236",
4
4
  "description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,7 +10,7 @@ import { buildMeshNodeCapabilityTags, nodeSatisfiesRequiredTags, claimNextTask,
10
10
  import { fastForwardMeshNode } from './mesh-fast-forward.js';
11
11
  import { createSessionDelivery, markSessionDeliveriesTerminal, updateSessionDeliveryStatus, recordCompletionConflict } from './mesh-delivery-policy.js';
12
12
  import { MeshRuntimeStore } from './mesh-runtime-store.js';
13
- import { queuePendingMeshCoordinatorEvent } from './mesh-events-pending.js';
13
+ import { queuePendingMeshCoordinatorEvent, drainPendingMeshCoordinatorEvents } from './mesh-events-pending.js';
14
14
  import type { PendingMeshCoordinatorEvent } from './mesh-events-pending.js';
15
15
  import {
16
16
  findRecentTerminalLedgerEvidence,
@@ -1488,4 +1488,36 @@ export function setupMeshEventForwarding(components: DaemonComponents) {
1488
1488
  metadataEvent: event,
1489
1489
  });
1490
1490
  });
1491
+
1492
+ // Auto-flush pending coordinator events when a coordinator session becomes idle.
1493
+ components.instanceManager.onEvent((event) => {
1494
+ if (event.event !== 'agent:ready' && event.event !== 'agent:generating_completed') return;
1495
+
1496
+ const instanceId = readNonEmptyString(event.instanceId);
1497
+ if (!instanceId) return;
1498
+
1499
+ const sourceInstance = components.instanceManager.getInstance(instanceId);
1500
+ if (!sourceInstance || sourceInstance.category !== 'cli') return;
1501
+ const state = sourceInstance.getState();
1502
+ const settings = state.settings && typeof state.settings === 'object' ? state.settings as Record<string, unknown> : {};
1503
+
1504
+ const coordinatorMeshId = readNonEmptyString(settings.meshCoordinatorFor);
1505
+ if (!coordinatorMeshId) return;
1506
+
1507
+ const status = readNonEmptyString(state.status).toLowerCase();
1508
+ if (status !== 'idle') return;
1509
+
1510
+ try {
1511
+ const localDaemonId = readNonEmptyString(loadConfig().machineId) || undefined;
1512
+ const pendingEvents = drainPendingMeshCoordinatorEvents(coordinatorMeshId, localDaemonId);
1513
+ if (pendingEvents.length === 0) return;
1514
+ LOG.info('MeshEvents', `Auto-flushing ${pendingEvents.length} pending coordinator event(s) for mesh ${coordinatorMeshId} on coordinator idle`);
1515
+ for (const pending of pendingEvents) {
1516
+ if (!pending.coordinatorMessage) continue;
1517
+ sourceInstance.onEvent('send_message', { input: { text: pending.coordinatorMessage, textFallback: pending.coordinatorMessage } });
1518
+ }
1519
+ } catch (e: any) {
1520
+ LOG.warn('MeshEvents', `Failed to auto-flush pending coordinator events: ${e?.message || e}`);
1521
+ }
1522
+ });
1491
1523
  }