@adhdev/daemon-core 0.9.82-rc.376 → 0.9.82-rc.377

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.
Files changed (41) hide show
  1. package/dist/commands/chat-commands-debug-bundle.d.ts +14 -0
  2. package/dist/commands/chat-commands-read.d.ts +7 -0
  3. package/dist/commands/chat-commands-scope.d.ts +39 -0
  4. package/dist/commands/chat-commands-shared.d.ts +33 -0
  5. package/dist/commands/chat-commands-write.d.ts +14 -0
  6. package/dist/commands/chat-commands.d.ts +9 -49
  7. package/dist/index.js +2976 -2943
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +2971 -2938
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/mesh/mesh-event-classify.d.ts +5 -0
  12. package/dist/mesh/mesh-event-forwarding.d.ts +18 -0
  13. package/dist/mesh/mesh-events-coordinator.d.ts +4 -92
  14. package/dist/mesh/mesh-events-utils.d.ts +3 -0
  15. package/dist/mesh/mesh-ledger-reconciliation.d.ts +0 -1
  16. package/dist/mesh/mesh-queue-assignment.d.ts +86 -0
  17. package/dist/mesh/mesh-runtime-store.d.ts +0 -3
  18. package/dist/providers/native-history/constants.d.ts +12 -0
  19. package/dist/runtime-defaults.d.ts +2 -0
  20. package/package.json +2 -2
  21. package/src/commands/chat-commands-debug-bundle.ts +398 -0
  22. package/src/commands/chat-commands-read.ts +2327 -0
  23. package/src/commands/chat-commands-scope.ts +54 -0
  24. package/src/commands/chat-commands-shared.ts +114 -0
  25. package/src/commands/chat-commands-write.ts +880 -0
  26. package/src/commands/chat-commands.ts +20 -3697
  27. package/src/commands/router.ts +5 -12
  28. package/src/mesh/mesh-event-classify.ts +51 -0
  29. package/src/mesh/mesh-event-forwarding.ts +1502 -0
  30. package/src/mesh/mesh-events-coordinator.ts +30 -2993
  31. package/src/mesh/mesh-events-pending.ts +1 -10
  32. package/src/mesh/mesh-events-stale.ts +3 -14
  33. package/src/mesh/mesh-events-utils.ts +52 -14
  34. package/src/mesh/mesh-ledger-reconciliation.ts +0 -2
  35. package/src/mesh/mesh-queue-assignment.ts +1457 -0
  36. package/src/mesh/mesh-runtime-store.ts +0 -37
  37. package/src/providers/cli-provider-instance.ts +40 -1
  38. package/src/providers/native-history/constants.ts +19 -0
  39. package/src/providers/native-history/dispatcher.ts +2 -3
  40. package/src/providers/spec/native-history-executor.ts +1 -9
  41. package/src/runtime-defaults.ts +39 -0
@@ -89,6 +89,7 @@ import * as fs from 'fs';
89
89
  import { execFileSync } from 'node:child_process';
90
90
  import { workingDirBasename } from '../providers/working-dir.js';
91
91
  import { resolveWin32Executable } from '../cli-adapters/resolve-executable.js';
92
+ import { readMeshTimeoutEnvMs, MESH_CONNECT_TIMEOUT_MS } from '../runtime-defaults.js';
92
93
 
93
94
  export function readProviderPriorityFromPolicy(policy: unknown): string[] {
94
95
  const record = policy && typeof policy === 'object' && !Array.isArray(policy)
@@ -1315,17 +1316,6 @@ export function finalizeMeshNodeStatus(args: {
1315
1316
  );
1316
1317
  }
1317
1318
 
1318
- // Reads a positive integer timeout (ms) from an env var, clamped to [1s, 120s];
1319
- // falls back to the default when unset or out of range. Lets slow cross-machine
1320
- // peers (e.g. a TURN-relayed Windows daemon whose git_status RTT is 10-18s) be
1321
- // tuned without a rebuild.
1322
- function readMeshTimeoutEnvMs(name: string, defaultMs: number): number {
1323
- const raw = process.env[name]?.trim();
1324
- if (!raw) return defaultMs;
1325
- const parsed = Number.parseInt(raw, 10);
1326
- if (Number.isFinite(parsed) && parsed >= 1_000 && parsed <= 120_000) return parsed;
1327
- return defaultMs;
1328
- }
1329
1319
 
1330
1320
  // Direct-peer git_status probe timeout for the dashboard's requireDirectPeerTruth
1331
1321
  // bootstrap. The previous hard-coded 8s/12s were shorter than the real P2P
@@ -1348,7 +1338,10 @@ export const MESH_DIRECT_PROBE_RETRY_TIMEOUT_MS = readMeshTimeoutEnvMs('MESH_DIR
1348
1338
  // so this never masks a real failure for the whole window; it only grants a
1349
1339
  // still-handshaking peer the time it legitimately needs. Matches the daemon-cloud
1350
1340
  // DaemonMeshManager CONNECT_TIMEOUT_MS (45s). Env-overridable for very slow links.
1351
- export const MESH_DIRECT_PROBE_CONNECT_TIMEOUT_MS = readMeshTimeoutEnvMs('MESH_DIRECT_PROBE_CONNECT_TIMEOUT_MS', 45_000);
1341
+ // Re-exported from the unified MESH_CONNECT_TIMEOUT_MS (runtime-defaults) so this
1342
+ // probe path and the coordinator's remote task-dispatch path share ONE
1343
+ // env-overridable connect budget instead of silently diverging when the env is set.
1344
+ export const MESH_DIRECT_PROBE_CONNECT_TIMEOUT_MS = MESH_CONNECT_TIMEOUT_MS;
1352
1345
  // How long a successful per-peer git_status probe stays fresh enough to be
1353
1346
  // reused instead of issuing another blocking `refreshUpstream:true` fan-out.
1354
1347
  // A slow (TURN-relayed) peer's probe can take 9-23s, and the dashboard's
@@ -0,0 +1,51 @@
1
+ import type { MeshLedgerKind } from './mesh-ledger.js';
2
+
3
+ // ---------------------------------------------------------------------------
4
+ // Core event injection
5
+ // ---------------------------------------------------------------------------
6
+
7
+ const MESH_COORDINATOR_EVENTS = new Set([
8
+ 'agent:generating_started',
9
+ 'agent:generating_completed',
10
+ 'agent:waiting_approval',
11
+ 'agent:stopped',
12
+ 'agent:ready',
13
+ 'monitor:no_progress',
14
+ 'refine:accepted',
15
+ 'refine:completed',
16
+ 'refine:failed',
17
+ 'worktree_bootstrap_complete',
18
+ 'worktree_bootstrap_failed',
19
+ ]);
20
+
21
+ export const EVENT_TO_LEDGER_KIND: Record<string, MeshLedgerKind> = {
22
+ 'agent:generating_completed': 'task_completed',
23
+ 'agent:waiting_approval': 'task_approval_needed',
24
+ 'agent:stopped': 'task_failed',
25
+ 'monitor:no_progress': 'task_stalled',
26
+ };
27
+
28
+ export function isMeshCoordinatorEvent(eventName: unknown): eventName is string {
29
+ return typeof eventName === 'string' && MESH_COORDINATOR_EVENTS.has(eventName);
30
+ }
31
+
32
+ // Terminal events that the coordinator is actively blocked waiting on. When the
33
+ // coordinator CLI session dispatches a task (e.g. mesh_send_task) it stays in
34
+ // `generating` until the result arrives — but a generating coordinator queues
35
+ // incoming send_message calls into its adapter's pendingOutboundQueue, which is
36
+ // only flushed on the coordinator's OWN idle transition. That transition can't
37
+ // happen until it receives this very event → deadlock. We force-inject these so
38
+ // they bypass the busy send-guard and land in the PTY while generating.
39
+ export const MESH_FORCE_INJECT_EVENTS: ReadonlySet<string> = new Set([
40
+ 'agent:generating_completed',
41
+ 'agent:stopped',
42
+ 'agent:waiting_approval',
43
+ 'refine:completed',
44
+ 'refine:failed',
45
+ 'worktree_bootstrap_complete',
46
+ 'worktree_bootstrap_failed',
47
+ ]);
48
+
49
+ export function shouldForceInjectMeshEvent(eventName: unknown): boolean {
50
+ return typeof eventName === 'string' && MESH_FORCE_INJECT_EVENTS.has(eventName);
51
+ }