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

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 (48) 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/commands/router.d.ts +3 -470
  8. package/dist/index.js +3166 -3115
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +3561 -3510
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/mesh/mesh-coordinator-config.d.ts +21 -0
  13. package/dist/mesh/mesh-event-classify.d.ts +5 -0
  14. package/dist/mesh/mesh-event-forwarding.d.ts +18 -0
  15. package/dist/mesh/mesh-events-coordinator.d.ts +4 -92
  16. package/dist/mesh/mesh-events-utils.d.ts +3 -0
  17. package/dist/mesh/mesh-ledger-reconciliation.d.ts +0 -1
  18. package/dist/mesh/mesh-node-identity.d.ts +289 -0
  19. package/dist/mesh/mesh-queue-assignment.d.ts +86 -0
  20. package/dist/mesh/mesh-refine-gates.d.ts +428 -0
  21. package/dist/mesh/mesh-runtime-store.d.ts +0 -3
  22. package/dist/providers/native-history/constants.d.ts +12 -0
  23. package/dist/runtime-defaults.d.ts +2 -0
  24. package/package.json +2 -2
  25. package/src/commands/chat-commands-debug-bundle.ts +398 -0
  26. package/src/commands/chat-commands-read.ts +2327 -0
  27. package/src/commands/chat-commands-scope.ts +54 -0
  28. package/src/commands/chat-commands-shared.ts +114 -0
  29. package/src/commands/chat-commands-write.ts +880 -0
  30. package/src/commands/chat-commands.ts +20 -3697
  31. package/src/commands/router.ts +59 -3631
  32. package/src/mesh/mesh-coordinator-config.ts +97 -0
  33. package/src/mesh/mesh-event-classify.ts +51 -0
  34. package/src/mesh/mesh-event-forwarding.ts +1502 -0
  35. package/src/mesh/mesh-events-coordinator.ts +30 -2993
  36. package/src/mesh/mesh-events-pending.ts +1 -10
  37. package/src/mesh/mesh-events-stale.ts +3 -14
  38. package/src/mesh/mesh-events-utils.ts +52 -14
  39. package/src/mesh/mesh-ledger-reconciliation.ts +0 -2
  40. package/src/mesh/mesh-node-identity.ts +1887 -0
  41. package/src/mesh/mesh-queue-assignment.ts +1457 -0
  42. package/src/mesh/mesh-refine-gates.ts +1652 -0
  43. package/src/mesh/mesh-runtime-store.ts +0 -37
  44. package/src/providers/cli-provider-instance.ts +40 -1
  45. package/src/providers/native-history/constants.ts +19 -0
  46. package/src/providers/native-history/dispatcher.ts +2 -3
  47. package/src/providers/spec/native-history-executor.ts +1 -9
  48. package/src/runtime-defaults.ts +39 -0
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Hermes / MCP coordinator config helpers
3
+ *
4
+ * Extracted from commands/router.ts (behavior-preserving move). Contains the
5
+ * MCP-server config parse/serialize helpers and the Hermes coordinator base
6
+ * config loading / temp-override stripping / credential-copy helpers.
7
+ *
8
+ * router.ts re-exports every public symbol from here so existing import paths
9
+ * keep working.
10
+ */
11
+
12
+ import { LOG } from '../logging/logger.js';
13
+ import * as yaml from 'js-yaml';
14
+ import { homedir } from 'os';
15
+ import { join as pathJoin, resolve as pathResolve } from 'path';
16
+ import * as fs from 'fs';
17
+ import type { MeshCoordinatorConfigFormat } from './mesh-refine-gates.js';
18
+
19
+ function loadYamlModule(): { load: (input: string) => any; dump: (input: any, options?: Record<string, any>) => string } {
20
+ return yaml as { load: (input: string) => any; dump: (input: any, options?: Record<string, any>) => string };
21
+ }
22
+
23
+ export function getMcpServersKey(format: MeshCoordinatorConfigFormat): 'mcpServers' | 'mcp_servers' {
24
+ return format === 'hermes_config_yaml' ? 'mcp_servers' : 'mcpServers';
25
+ }
26
+
27
+ export function parseMeshCoordinatorMcpConfig(text: string, format: MeshCoordinatorConfigFormat): Record<string, any> {
28
+ if (!text.trim()) return {};
29
+ if (format === 'claude_mcp_json') return JSON.parse(text);
30
+ const parsed = loadYamlModule().load(text);
31
+ return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {};
32
+ }
33
+
34
+ export function serializeMeshCoordinatorMcpConfig(config: Record<string, any>, format: MeshCoordinatorConfigFormat): string {
35
+ if (format === 'claude_mcp_json') return JSON.stringify(config, null, 2);
36
+ return loadYamlModule().dump(config, { noRefs: true, lineWidth: 120 });
37
+ }
38
+
39
+ function resolveHermesUserHome(): string {
40
+ const explicitHome = process.env.HERMES_HOME?.trim();
41
+ return explicitHome || pathJoin(homedir(), '.hermes');
42
+ }
43
+
44
+ export function loadHermesCoordinatorBaseConfig(targetConfigPath: string): { config: Record<string, any>; sourceHome: string; sourceConfigPath: string } {
45
+ const sourceHome = resolveHermesUserHome();
46
+ const sourceConfigPath = pathJoin(sourceHome, 'config.yaml');
47
+ if (!fs.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
48
+ if (pathResolve(sourceConfigPath) === pathResolve(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
49
+
50
+ const parsed = parseMeshCoordinatorMcpConfig(fs.readFileSync(sourceConfigPath, 'utf-8'), 'hermes_config_yaml');
51
+ const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
52
+ return { config: baseConfig, sourceHome, sourceConfigPath };
53
+ }
54
+
55
+ export function stripHermesCoordinatorTempModelProviderOverrides(config: Record<string, any>): Record<string, any> {
56
+ const {
57
+ model: _model,
58
+ provider: _provider,
59
+ default_model: _defaultModel,
60
+ defaultProvider: _defaultProvider,
61
+ default_provider: _defaultProviderSnake,
62
+ modelProvider: _modelProvider,
63
+ model_provider: _modelProviderSnake,
64
+ ...sanitized
65
+ } = config;
66
+ const delegation = sanitized.delegation;
67
+ if (delegation && typeof delegation === 'object' && !Array.isArray(delegation)) {
68
+ const {
69
+ model: _delegationModel,
70
+ provider: _delegationProvider,
71
+ modelProvider: _delegationModelProvider,
72
+ model_provider: _delegationModelProviderSnake,
73
+ ...delegationRest
74
+ } = delegation;
75
+ if (Object.keys(delegationRest).length > 0) {
76
+ sanitized.delegation = delegationRest;
77
+ } else {
78
+ delete sanitized.delegation;
79
+ }
80
+ }
81
+ return sanitized;
82
+ }
83
+
84
+ export function copyHermesCoordinatorCredentialFiles(sourceHome: string, targetHome: string) {
85
+ if (pathResolve(sourceHome) === pathResolve(targetHome)) return;
86
+ for (const fileName of ['.env', 'auth.json']) {
87
+ const sourcePath = pathJoin(sourceHome, fileName);
88
+ const targetPath = pathJoin(targetHome, fileName);
89
+ if (!fs.existsSync(sourcePath)) continue;
90
+ try {
91
+ fs.copyFileSync(sourcePath, targetPath);
92
+ } catch (error: any) {
93
+ LOG.warn('MeshCoordinator', `Could not copy Hermes ${fileName} into isolated coordinator home: ${error?.message || error}`);
94
+ }
95
+ }
96
+ }
97
+
@@ -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
+ }