@adhdev/daemon-core 0.9.82-rc.8 → 0.9.82-rc.81

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 (74) hide show
  1. package/dist/cli-adapters/provider-cli-adapter.d.ts +2 -0
  2. package/dist/cli-adapters/provider-cli-parse.d.ts +1 -0
  3. package/dist/cli-adapters/provider-cli-shared.d.ts +2 -0
  4. package/dist/commands/router.d.ts +22 -0
  5. package/dist/config/mesh-config.d.ts +66 -1
  6. package/dist/git/git-commands.d.ts +1 -0
  7. package/dist/git/git-status.d.ts +5 -0
  8. package/dist/git/git-types.d.ts +10 -0
  9. package/dist/index.d.ts +13 -6
  10. package/dist/index.js +5074 -1177
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +5038 -1163
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/installer.d.ts +1 -4
  15. package/dist/launch.d.ts +1 -1
  16. package/dist/logging/async-batch-writer.d.ts +10 -0
  17. package/dist/mesh/beads-db.d.ts +18 -0
  18. package/dist/mesh/mesh-active-work.d.ts +60 -0
  19. package/dist/mesh/mesh-events.d.ts +29 -5
  20. package/dist/mesh/mesh-fast-forward.d.ts +39 -0
  21. package/dist/mesh/mesh-host-ownership.d.ts +9 -0
  22. package/dist/mesh/mesh-ledger.d.ts +38 -1
  23. package/dist/mesh/mesh-work-queue.d.ts +27 -5
  24. package/dist/mesh/refine-config.d.ts +119 -0
  25. package/dist/providers/chat-message-normalization.d.ts +1 -0
  26. package/dist/providers/cli-provider-instance.d.ts +2 -1
  27. package/dist/repo-mesh-types.d.ts +39 -0
  28. package/dist/status/reporter.d.ts +2 -0
  29. package/package.json +3 -1
  30. package/src/boot/daemon-lifecycle.ts +1 -0
  31. package/src/cli-adapters/provider-cli-adapter.ts +91 -3
  32. package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
  33. package/src/cli-adapters/provider-cli-parse.ts +4 -0
  34. package/src/cli-adapters/provider-cli-runtime.ts +3 -1
  35. package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
  36. package/src/cli-adapters/provider-cli-shared.ts +20 -10
  37. package/src/commands/chat-commands.ts +310 -12
  38. package/src/commands/cli-manager.ts +101 -0
  39. package/src/commands/handler.ts +8 -1
  40. package/src/commands/mesh-coordinator.ts +13 -143
  41. package/src/commands/router.ts +2435 -414
  42. package/src/config/chat-history.ts +9 -7
  43. package/src/config/mesh-config.ts +244 -1
  44. package/src/daemon/dev-cli-debug.ts +10 -1
  45. package/src/detection/ide-detector.ts +26 -16
  46. package/src/git/git-commands.ts +3 -3
  47. package/src/git/git-status.ts +97 -6
  48. package/src/git/git-summary.ts +3 -0
  49. package/src/git/git-types.ts +11 -0
  50. package/src/index.ts +31 -5
  51. package/src/installer.d.ts +1 -1
  52. package/src/installer.ts +8 -6
  53. package/src/launch.d.ts +1 -1
  54. package/src/launch.ts +37 -28
  55. package/src/logging/async-batch-writer.ts +55 -0
  56. package/src/logging/logger.ts +2 -1
  57. package/src/mesh/beads-db.ts +176 -0
  58. package/src/mesh/coordinator-prompt.ts +27 -7
  59. package/src/mesh/mesh-active-work.ts +243 -0
  60. package/src/mesh/mesh-events.ts +398 -46
  61. package/src/mesh/mesh-fast-forward.ts +430 -0
  62. package/src/mesh/mesh-host-ownership.ts +73 -0
  63. package/src/mesh/mesh-ledger.ts +138 -1
  64. package/src/mesh/mesh-work-queue.ts +199 -137
  65. package/src/mesh/refine-config.ts +306 -0
  66. package/src/providers/chat-message-normalization.ts +3 -1
  67. package/src/providers/cli-provider-instance.ts +91 -13
  68. package/src/providers/ide-provider-instance.ts +17 -3
  69. package/src/providers/provider-loader.ts +10 -4
  70. package/src/providers/read-chat-contract.ts +1 -1
  71. package/src/providers/version-archive.ts +38 -20
  72. package/src/repo-mesh-types.ts +43 -0
  73. package/src/status/reporter.ts +15 -0
  74. package/src/system/host-memory.ts +29 -12
@@ -28,10 +28,7 @@ export interface InstallResult {
28
28
  alreadyInstalled: boolean;
29
29
  error?: string;
30
30
  }
31
- /**
32
- * Check if an extension is already installed
33
- */
34
- export declare function isExtensionInstalled(ide: IDEInfo, marketplaceId: string): boolean;
31
+ export declare function isExtensionInstalled(ide: IDEInfo, marketplaceId: string): Promise<boolean>;
35
32
  /**
36
33
  * Install a single extension
37
34
  */
package/dist/launch.d.ts CHANGED
@@ -18,7 +18,7 @@
18
18
  /** Kill IDE process (graceful → force) */
19
19
  export declare function killIdeProcess(ideId: string): Promise<boolean>;
20
20
  /** Check if IDE process is running */
21
- export declare function isIdeRunning(ideId: string): boolean;
21
+ export declare function isIdeRunning(ideId: string): Promise<boolean>;
22
22
  export interface LaunchOptions {
23
23
  ideId?: string;
24
24
  workspace?: string;
@@ -0,0 +1,10 @@
1
+ export declare class AsyncBatchWriter {
2
+ private static buffers;
3
+ private static writePromises;
4
+ private static flushTimer;
5
+ /**
6
+ * Queues data to be written to a file asynchronously in a batch.
7
+ */
8
+ static write(filePath: string, data: string): void;
9
+ private static flushAll;
10
+ }
@@ -0,0 +1,18 @@
1
+ import type { MeshTaskStatus, MeshWorkQueueEntry } from './mesh-work-queue.js';
2
+ export declare class BeadsDB {
3
+ private static instance;
4
+ private readonly db;
5
+ private readonly migratedMeshIds;
6
+ private constructor();
7
+ static getInstance(): BeadsDB;
8
+ static resetForTests(): void;
9
+ close(): void;
10
+ transaction<T>(fn: () => T): T;
11
+ private migrate;
12
+ private ensureLegacyQueueMigrated;
13
+ getQueueEntries(meshId: string, statuses?: MeshTaskStatus[]): MeshWorkQueueEntry[];
14
+ getQueueRevision(meshId: string): string;
15
+ replaceQueue(meshId: string, queue: MeshWorkQueueEntry[]): void;
16
+ deleteQueue(meshId: string): void;
17
+ private toRow;
18
+ }
@@ -0,0 +1,60 @@
1
+ import type { MeshLedgerEntry } from './mesh-ledger.js';
2
+ import type { MeshWorkQueueEntry } from './mesh-work-queue.js';
3
+ export type MeshActiveWorkSource = 'queue' | 'direct';
4
+ export type MeshActiveWorkStatus = 'pending' | 'assigned' | 'generating' | 'idle' | 'failed' | 'awaiting_approval';
5
+ export interface MeshActiveWorkRecord {
6
+ taskId: string;
7
+ source: MeshActiveWorkSource;
8
+ status: MeshActiveWorkStatus;
9
+ nodeId?: string;
10
+ sessionId?: string;
11
+ providerType?: string;
12
+ taskTitle: string;
13
+ taskSummary: string;
14
+ message?: string;
15
+ taskMode?: string;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ dispatchedAt?: string;
19
+ elapsedMs: number;
20
+ terminal?: boolean;
21
+ terminalKind?: string;
22
+ terminalAt?: string;
23
+ staleReason?: string;
24
+ }
25
+ export interface MeshActiveWorkSummary {
26
+ totalActiveCount: number;
27
+ queueActiveCount: number;
28
+ directActiveCount: number;
29
+ awaitingApprovalCount: number;
30
+ generatingCount: number;
31
+ failedCount: number;
32
+ idleCount: number;
33
+ sourceCounts: Record<MeshActiveWorkSource, number>;
34
+ statusCounts: Record<MeshActiveWorkStatus, number>;
35
+ staleDirectCount: number;
36
+ /**
37
+ * When staleDirectCount > 0, this note clarifies that stale direct records are
38
+ * historical/recovery evidence — orphaned ledger entries whose original node or session
39
+ * is no longer present in the live mesh. They are NOT active or unresolved work items.
40
+ * The active queue (queue source) is the authoritative source for pending/assigned work.
41
+ */
42
+ staleDirectNote?: string;
43
+ }
44
+ export interface BuildMeshActiveWorkOptions {
45
+ meshId: string;
46
+ queue?: MeshWorkQueueEntry[];
47
+ ledgerEntries?: MeshLedgerEntry[];
48
+ nodes?: any[];
49
+ now?: number;
50
+ /** Include terminal direct rows (idle/failed) for handoff/recent-work surfaces. Defaults false. */
51
+ includeTerminalDirect?: boolean;
52
+ }
53
+ export declare function buildMeshActiveWorkSummary(activeWork: MeshActiveWorkRecord[]): MeshActiveWorkSummary;
54
+ export declare function buildMeshActiveWork(opts: BuildMeshActiveWorkOptions): {
55
+ activeWork: MeshActiveWorkRecord[];
56
+ staleDirectWork: MeshActiveWorkRecord[];
57
+ staleDirectWorkNote?: string;
58
+ terminalDirectWork: MeshActiveWorkRecord[];
59
+ summary: MeshActiveWorkSummary;
60
+ };
@@ -3,15 +3,19 @@ export interface PendingMeshCoordinatorEvent {
3
3
  event: string;
4
4
  meshId: string;
5
5
  nodeLabel: string;
6
+ nodeId?: string;
7
+ workspace?: string;
6
8
  metadataEvent: Record<string, unknown>;
9
+ coordinatorMessage?: string;
7
10
  queuedAt: number;
8
11
  }
9
- /** Drain and return all pending coordinator events, clearing the queue. */
10
- export declare function drainPendingMeshCoordinatorEvents(): PendingMeshCoordinatorEvent[];
12
+ export declare function queuePendingMeshCoordinatorEvent(event: PendingMeshCoordinatorEvent): boolean;
13
+ /** Drain and return all pending coordinator events for meshId, removing them from disk. */
14
+ export declare function drainPendingMeshCoordinatorEvents(meshId?: string): PendingMeshCoordinatorEvent[];
11
15
  /** Peek at pending coordinator events without draining (non-destructive). */
12
- export declare function getPendingMeshCoordinatorEvents(): readonly PendingMeshCoordinatorEvent[];
13
- /** Explicitly clear all pending coordinator events. */
14
- export declare function clearPendingMeshCoordinatorEvents(): void;
16
+ export declare function getPendingMeshCoordinatorEvents(meshId?: string): readonly PendingMeshCoordinatorEvent[];
17
+ /** Explicitly clear all pending coordinator events for a mesh. */
18
+ export declare function clearPendingMeshCoordinatorEvents(meshId?: string): void;
15
19
  export declare function tryAssignQueueTask(components: DaemonComponents, meshId: string, nodeId: string, sessionId: string, providerType: string): boolean;
16
20
  /**
17
21
  * Triggers a queue check for all nodes in the mesh.
@@ -23,12 +27,32 @@ export declare function handleMeshForwardEvent(components: DaemonComponents, pay
23
27
  forwarded: number;
24
28
  suppressed: boolean;
25
29
  intentionalCleanupStop: boolean;
30
+ duplicateRefineTerminalEvent?: undefined;
31
+ duplicateCompletion?: undefined;
32
+ error?: undefined;
33
+ } | {
34
+ success: boolean;
35
+ forwarded: number;
36
+ suppressed: boolean;
37
+ duplicateRefineTerminalEvent: boolean;
38
+ intentionalCleanupStop?: undefined;
39
+ duplicateCompletion?: undefined;
40
+ error?: undefined;
41
+ } | {
42
+ success: boolean;
43
+ forwarded: number;
44
+ suppressed: boolean;
45
+ duplicateCompletion: boolean;
46
+ intentionalCleanupStop?: undefined;
47
+ duplicateRefineTerminalEvent?: undefined;
26
48
  error?: undefined;
27
49
  } | {
28
50
  success: boolean;
29
51
  forwarded: number;
30
52
  suppressed?: undefined;
31
53
  intentionalCleanupStop?: undefined;
54
+ duplicateRefineTerminalEvent?: undefined;
55
+ duplicateCompletion?: undefined;
32
56
  error?: undefined;
33
57
  } | {
34
58
  success: boolean;
@@ -0,0 +1,39 @@
1
+ import type { GitRepoStatus } from '../git/git-types.js';
2
+ export interface MeshFastForwardNodeArgs {
3
+ nodeId?: string;
4
+ meshId?: string;
5
+ workspace: string;
6
+ branch?: string;
7
+ execute?: boolean;
8
+ dryRun?: boolean;
9
+ updateSubmodules?: boolean;
10
+ submoduleIgnorePaths?: string[];
11
+ timeoutMs?: number;
12
+ }
13
+ export interface MeshFastForwardPlannedStep {
14
+ operation: 'refresh_upstream' | 'verify_clean_worktree' | 'verify_fast_forward' | 'merge_ff_only' | 'submodule_update' | 'verify_post_status';
15
+ description: string;
16
+ safe: true;
17
+ willMutateWorktree: boolean;
18
+ }
19
+ export interface MeshFastForwardResult {
20
+ success: boolean;
21
+ code: string;
22
+ nodeId?: string;
23
+ meshId?: string;
24
+ workspace: string;
25
+ allowed: boolean;
26
+ dryRun: boolean;
27
+ willRun: boolean;
28
+ executed: boolean;
29
+ updateSubmodules: boolean;
30
+ blockingReasons: string[];
31
+ plannedSteps: MeshFastForwardPlannedStep[];
32
+ current?: GitRepoStatus;
33
+ preStatus?: GitRepoStatus;
34
+ postStatus?: GitRepoStatus;
35
+ finalBranchConvergenceState?: Record<string, unknown>;
36
+ operationError?: string;
37
+ ledgerError?: string;
38
+ }
39
+ export declare function fastForwardMeshNode(args: MeshFastForwardNodeArgs): Promise<MeshFastForwardResult>;
@@ -0,0 +1,9 @@
1
+ import type { RepoMeshDaemonRole, RepoMeshHostMetadata, RepoMeshHostStatus } from '../repo-mesh-types.js';
2
+ export declare function normalizeMeshDaemonRole(value: unknown): RepoMeshDaemonRole | undefined;
3
+ export declare function resolveMeshHostStatus(mesh: unknown): RepoMeshHostStatus;
4
+ export declare function isMeshHostOwner(mesh: unknown): boolean;
5
+ export declare function buildMeshHostRequiredFailure(mesh: unknown, operation: string): Record<string, unknown>;
6
+ export declare function requireMeshHostQueueOwner(opts?: {
7
+ ownerRole?: RepoMeshDaemonRole;
8
+ }): void;
9
+ export declare function createDefaultMeshHostMetadata(): RepoMeshHostMetadata;
@@ -13,7 +13,7 @@
13
13
  * Safety: mode 0o600, atomic append via appendFileSync
14
14
  */
15
15
  import { EventEmitter } from 'events';
16
- export type MeshLedgerKind = 'task_dispatched' | 'task_completed' | 'task_failed' | 'task_stalled' | 'task_approval_needed' | 'session_launched' | 'session_auto_launch' | 'session_stopped' | 'checkpoint_created' | 'node_cloned' | 'node_removed' | 'coordinator_started' | 'recovery_attempted' | 'ledger_replicated' | 'ledger_reconciled';
16
+ export type MeshLedgerKind = 'task_dispatched' | 'task_completed' | 'task_failed' | 'task_stalled' | 'task_approval_needed' | 'session_launched' | 'session_auto_launch' | 'session_stopped' | 'checkpoint_created' | 'node_cloned' | 'node_joined' | 'node_removed' | 'coordinator_started' | 'recovery_attempted' | 'ledger_replicated' | 'ledger_reconciled' | 'direct_fast_forward';
17
17
  export interface MeshLedgerEntry {
18
18
  id: string;
19
19
  meshId: string;
@@ -25,6 +25,40 @@ export interface MeshLedgerEntry {
25
25
  payload: Record<string, unknown>;
26
26
  }
27
27
  export declare function isIntentionalCleanupStopEntry(entry: Pick<MeshLedgerEntry, 'kind' | 'payload'>): boolean;
28
+ export type MeshWorkerResultStatus = 'completed' | 'failed' | 'blocked' | 'partial' | 'unknown';
29
+ export type MeshProcessArtifactKind = 'process' | 'log' | 'port' | 'window' | 'session' | 'file' | 'url' | 'other';
30
+ export interface MeshValidationResultArtifact {
31
+ command?: string;
32
+ status: 'passed' | 'failed' | 'skipped' | 'unknown';
33
+ durationMs?: number;
34
+ outputPath?: string;
35
+ summary?: string;
36
+ }
37
+ export interface MeshProcessArtifact {
38
+ kind: MeshProcessArtifactKind;
39
+ id?: string;
40
+ label?: string;
41
+ locator?: string;
42
+ pid?: number;
43
+ port?: number;
44
+ url?: string;
45
+ path?: string;
46
+ sessionId?: string;
47
+ keepRunning?: boolean;
48
+ metadata?: Record<string, unknown>;
49
+ }
50
+ export interface MeshWorkerResultArtifact {
51
+ status: MeshWorkerResultStatus;
52
+ classification?: string;
53
+ changedFiles: string[];
54
+ validationResults: MeshValidationResultArtifact[];
55
+ gitStatus?: Record<string, unknown>;
56
+ processArtifacts: MeshProcessArtifact[];
57
+ errors: string[];
58
+ nextAction?: string;
59
+ requiresUserAction: boolean;
60
+ source: 'explicit_metadata' | 'final_summary_json' | 'default';
61
+ }
28
62
  export interface MeshTaskCompletionEvidence {
29
63
  source: 'agent_status_event';
30
64
  event: 'agent:generating_completed' | 'agent:ready';
@@ -38,6 +72,7 @@ export interface MeshTaskCompletionEvidence {
38
72
  providerSessionId?: string;
39
73
  finalSummaryAvailable: boolean;
40
74
  };
75
+ workerResult: MeshWorkerResultArtifact;
41
76
  git: {
42
77
  status: 'deferred';
43
78
  reason: string;
@@ -59,6 +94,7 @@ export interface BuildTaskCompletionEvidenceOptions {
59
94
  providerType?: string;
60
95
  providerSessionId?: string;
61
96
  finalSummary?: string;
97
+ workerResult?: Record<string, unknown>;
62
98
  completedAt?: string;
63
99
  }
64
100
  export interface MeshLedgerSummary {
@@ -115,6 +151,7 @@ export interface AppendRemoteLedgerResult {
115
151
  }
116
152
  export declare const MAX_LEDGER_SLICE_LIMIT = 500;
117
153
  export declare function getLedgerDir(): string;
154
+ export declare function normalizeMeshWorkerResult(input?: Record<string, unknown>, source?: MeshWorkerResultArtifact['source']): MeshWorkerResultArtifact;
118
155
  export declare function buildTaskCompletionEvidence(opts: BuildTaskCompletionEvidenceOptions): MeshTaskCompletionEvidence;
119
156
  /**
120
157
  * Append a new entry to the mesh ledger.
@@ -1,13 +1,25 @@
1
+ import type { RepoMeshDaemonRole } from '../repo-mesh-types.js';
1
2
  export type MeshTaskStatus = 'pending' | 'assigned' | 'completed' | 'failed' | 'cancelled';
2
3
  export type MeshActiveTaskStatus = Extract<MeshTaskStatus, 'pending' | 'assigned'>;
3
4
  export type MeshHistoricalTaskStatus = Extract<MeshTaskStatus, 'completed' | 'failed' | 'cancelled'>;
5
+ export type MeshTaskMode = 'code_change' | 'validation' | 'live_debug_readonly' | 'launch_app' | 'convergence';
4
6
  export declare const ACTIVE_MESH_QUEUE_STATUSES: MeshActiveTaskStatus[];
5
7
  export declare const HISTORICAL_MESH_QUEUE_STATUSES: MeshHistoricalTaskStatus[];
8
+ export declare const MESH_TASK_MODES: MeshTaskMode[];
9
+ export interface MeshTaskModeValidationResult {
10
+ valid: boolean;
11
+ taskMode?: MeshTaskMode;
12
+ violations: string[];
13
+ allowedOperations?: string[];
14
+ }
15
+ export declare function normalizeMeshTaskMode(value: unknown): MeshTaskMode | undefined;
16
+ export declare function validateMeshTaskModeRequest(mode: unknown, message: string): MeshTaskModeValidationResult;
6
17
  export interface MeshWorkQueueEntry {
7
18
  id: string;
8
19
  meshId: string;
9
20
  message: string;
10
21
  status: MeshTaskStatus;
22
+ taskMode?: MeshTaskMode;
11
23
  /** If specified, only this node can claim the task (used by legacy mesh_send_task) */
12
24
  targetNodeId?: string;
13
25
  /** If specified, only this runtime session can claim the task */
@@ -37,19 +49,24 @@ export interface MeshWorkQueueEntry {
37
49
  createdAt: string;
38
50
  updatedAt: string;
39
51
  }
52
+ export interface MeshQueueMutationOptions {
53
+ ownerRole?: RepoMeshDaemonRole;
54
+ }
40
55
  /**
41
56
  * Add a new task to the mesh queue.
42
57
  */
43
58
  export declare function enqueueTask(meshId: string, message: string, opts?: {
44
59
  targetNodeId?: string;
45
60
  targetSessionId?: string;
46
- }): MeshWorkQueueEntry;
61
+ taskMode?: MeshTaskMode | string;
62
+ } & MeshQueueMutationOptions): MeshWorkQueueEntry;
47
63
  /**
48
64
  * Get all tasks in the queue, optionally filtered by status.
49
65
  */
50
66
  export declare function getQueue(meshId: string, opts?: {
51
67
  status?: MeshTaskStatus[];
52
68
  }): MeshWorkQueueEntry[];
69
+ export declare function getMeshQueueRevision(meshId: string): string;
53
70
  /**
54
71
  * Find the next pending task that this node is allowed to claim, and mark it as assigned.
55
72
  */
@@ -58,14 +75,14 @@ export declare function claimNextTask(meshId: string, nodeId: string, sessionId:
58
75
  * Update the status of a specific task.
59
76
  * Used when a session completes, fails, or stalls.
60
77
  */
61
- export declare function updateTaskStatus(meshId: string, taskId: string, status: MeshTaskStatus): MeshWorkQueueEntry | null;
78
+ export declare function updateTaskStatus(meshId: string, taskId: string, status: MeshTaskStatus, opts?: MeshQueueMutationOptions): MeshWorkQueueEntry | null;
62
79
  export declare function recordTaskAutoLaunch(meshId: string, taskId: string, autoLaunch: Omit<NonNullable<MeshWorkQueueEntry['autoLaunch']>, 'updatedAt'>): MeshWorkQueueEntry | null;
63
80
  /**
64
81
  * Mark a queue task as manually cancelled without deleting audit history.
65
82
  */
66
83
  export declare function cancelTask(meshId: string, taskId: string, opts?: {
67
84
  reason?: string;
68
- }): MeshWorkQueueEntry | null;
85
+ } & MeshQueueMutationOptions): MeshWorkQueueEntry | null;
69
86
  /**
70
87
  * Return a queue task to pending for retry. By default, dead session targeting
71
88
  * and assigned ownership are cleared so stale assignments do not strand again.
@@ -76,11 +93,13 @@ export declare function requeueTask(meshId: string, taskId: string, opts?: {
76
93
  targetSessionId?: string;
77
94
  clearTargetNode?: boolean;
78
95
  clearTargetSession?: boolean;
79
- }): MeshWorkQueueEntry | null;
96
+ } & MeshQueueMutationOptions): MeshWorkQueueEntry | null;
80
97
  /**
81
98
  * Update the status of the task currently assigned to a specific session.
82
99
  */
83
- export declare function updateSessionTaskStatus(meshId: string, sessionId: string, status: MeshTaskStatus): MeshWorkQueueEntry | null;
100
+ export declare function updateSessionTaskStatus(meshId: string, sessionId: string, status: MeshTaskStatus, opts?: {
101
+ occurredAt?: string;
102
+ }): MeshWorkQueueEntry | null;
84
103
  export interface MeshWorkQueueStats {
85
104
  total: number;
86
105
  active: number;
@@ -105,3 +124,6 @@ export interface MeshWorkQueueStats {
105
124
  * Return aggregate queue statistics for the given mesh.
106
125
  */
107
126
  export declare function getMeshQueueStats(meshId: string): MeshWorkQueueStats;
127
+ export declare function __replaceMeshQueueForTests(meshId: string, queue: MeshWorkQueueEntry[]): void;
128
+ export declare function __clearMeshQueueForTests(meshId: string): void;
129
+ export declare function __resetBeadsDBForTests(): void;
@@ -0,0 +1,119 @@
1
+ export declare const MESH_REFINE_VALIDATION_CATEGORIES: readonly ["typecheck", "test", "lint", "build"];
2
+ export type MeshRefineValidationCategory = typeof MESH_REFINE_VALIDATION_CATEGORIES[number];
3
+ export interface RepoMeshRefineValidationCommandConfig {
4
+ /** Executable name or a whitespace-tokenized command string. Never executed through a shell. */
5
+ command: string;
6
+ /** Optional explicit argv. Prefer this over shell-like command strings. */
7
+ args?: string[];
8
+ category?: MeshRefineValidationCategory;
9
+ cwd?: string;
10
+ timeoutMs?: number;
11
+ env?: Record<string, string>;
12
+ }
13
+ export interface RepoMeshRefineConfig {
14
+ version: 1;
15
+ validation?: {
16
+ required?: boolean;
17
+ commands?: RepoMeshRefineValidationCommandConfig[];
18
+ };
19
+ }
20
+ export interface MeshRefineValidationCommandPlan {
21
+ command: string;
22
+ args: string[];
23
+ displayCommand: string;
24
+ category: MeshRefineValidationCategory | 'custom';
25
+ source: string;
26
+ cwd?: string;
27
+ timeoutMs?: number;
28
+ env?: Record<string, string>;
29
+ }
30
+ export interface MeshRefineConfigLoadResult {
31
+ config?: RepoMeshRefineConfig;
32
+ source: string;
33
+ sourceType: 'mesh_policy' | 'repo_file' | 'unavailable' | 'invalid';
34
+ path?: string;
35
+ error?: string;
36
+ }
37
+ export interface MeshRefineValidationPlan {
38
+ source: string;
39
+ sourceType: MeshRefineConfigLoadResult['sourceType'];
40
+ commands: MeshRefineValidationCommandPlan[];
41
+ rejectedCommands: Array<Record<string, unknown>>;
42
+ suggestions: RepoMeshRefineValidationCommandConfig[];
43
+ suggestedConfig?: RepoMeshRefineConfig;
44
+ unavailableReason?: string;
45
+ }
46
+ export declare const MESH_REFINE_CONFIG_LOCATIONS: string[];
47
+ export declare const MESH_REFINE_CONFIG_SCHEMA: {
48
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
49
+ readonly title: "ADHDev Repo Mesh Refinery Config";
50
+ readonly type: "object";
51
+ readonly additionalProperties: false;
52
+ readonly required: readonly ["version"];
53
+ readonly properties: {
54
+ readonly version: {
55
+ readonly const: 1;
56
+ };
57
+ readonly validation: {
58
+ readonly type: "object";
59
+ readonly additionalProperties: false;
60
+ readonly properties: {
61
+ readonly required: {
62
+ readonly type: "boolean";
63
+ readonly default: true;
64
+ };
65
+ readonly commands: {
66
+ readonly type: "array";
67
+ readonly minItems: 1;
68
+ readonly maxItems: 8;
69
+ readonly items: {
70
+ readonly type: "object";
71
+ readonly additionalProperties: false;
72
+ readonly required: readonly ["command"];
73
+ readonly properties: {
74
+ readonly command: {
75
+ readonly type: "string";
76
+ readonly minLength: 1;
77
+ };
78
+ readonly args: {
79
+ readonly type: "array";
80
+ readonly items: {
81
+ readonly type: "string";
82
+ };
83
+ };
84
+ readonly category: {
85
+ readonly enum: readonly ["typecheck", "test", "lint", "build", "custom"];
86
+ };
87
+ readonly cwd: {
88
+ readonly type: "string";
89
+ };
90
+ readonly timeoutMs: {
91
+ readonly type: "number";
92
+ readonly minimum: 1000;
93
+ readonly maximum: 600000;
94
+ };
95
+ readonly env: {
96
+ readonly type: "object";
97
+ readonly additionalProperties: {
98
+ readonly type: "string";
99
+ };
100
+ };
101
+ };
102
+ };
103
+ };
104
+ };
105
+ };
106
+ };
107
+ };
108
+ export declare function validateMeshRefineConfig(config: unknown, source?: string): {
109
+ valid: boolean;
110
+ errors: string[];
111
+ commands: MeshRefineValidationCommandPlan[];
112
+ rejectedCommands: Array<Record<string, unknown>>;
113
+ };
114
+ export declare function loadMeshRefineConfig(mesh: any, workspace: string): MeshRefineConfigLoadResult;
115
+ export declare function suggestMeshRefineConfig(mesh: any, workspace: string): {
116
+ suggestions: RepoMeshRefineValidationCommandConfig[];
117
+ suggestedConfig?: RepoMeshRefineConfig;
118
+ };
119
+ export declare function resolveMeshRefineValidationPlan(mesh: any, workspace: string): MeshRefineValidationPlan;
@@ -1,4 +1,5 @@
1
1
  import type { ChatMessage } from '../types.js';
2
+ export declare const DEFAULT_FINAL_SUMMARY_MAX_CHARS = 4000;
2
3
  export declare function extractFinalSummaryFromMessages(messages: ChatMessage[] | null | undefined, maxChars?: number): string;
3
4
  export declare const BUILTIN_CHAT_MESSAGE_KINDS: readonly ["standard", "thought", "tool", "terminal", "system"];
4
5
  export type BuiltinChatMessageKind = typeof BUILTIN_CHAT_MESSAGE_KINDS[number];
@@ -101,9 +101,10 @@ export declare class CliProviderInstance implements ProviderInstance {
101
101
  private completedDebouncePending;
102
102
  private enforceFreshSessionLaunchIfNeeded;
103
103
  private completionHasFinalAssistantMessage;
104
+ private buildCompletedFinalizationDiagnostic;
104
105
  private hasAdapterPendingResponse;
105
106
  private shouldSuppressStaleParsedBusyStatus;
106
- private getCompletedFinalizationBlockReason;
107
+ private getCompletedFinalizationBlock;
107
108
  private scheduleCompletedDebounceFlush;
108
109
  private flushCompletedDebounceIfFinalized;
109
110
  private maybeAutoApproveStatus;
@@ -19,10 +19,37 @@ export interface RepoMesh {
19
19
  defaultBranch?: string;
20
20
  policy: RepoMeshPolicy;
21
21
  coordinator: RepoMeshCoordinatorConfig;
22
+ meshHost?: RepoMeshHostMetadata;
22
23
  projectContext: ProjectContextSnapshot;
23
24
  nodes: RepoMeshNode[];
24
25
  status: 'active' | 'archived' | 'deleted';
25
26
  }
27
+ export type RepoMeshDaemonRole = 'host' | 'member';
28
+ export interface RepoMeshHostPairingMetadata {
29
+ status: 'not_configured' | 'pairing' | 'paired' | 'rejected' | 'revoked';
30
+ tokenId?: string;
31
+ joinedAt?: string;
32
+ lastPairedAt?: string;
33
+ lastRejectedAt?: string;
34
+ expiresAt?: string;
35
+ }
36
+ export interface RepoMeshHostMetadata {
37
+ /** Local daemon role for this mesh. Missing metadata defaults to host for standalone compatibility. */
38
+ role: RepoMeshDaemonRole;
39
+ /** Daemon that owns mesh truth/status/git/queue/session/ledger/coordinator ownership. */
40
+ hostDaemonId?: string;
41
+ /** Mesh node that represents the host daemon, when known. */
42
+ hostNodeId?: string;
43
+ /** Future standalone manual pairing endpoint entered by member daemons. */
44
+ hostAddress?: string;
45
+ /** Redacted pairing state only; raw join tokens must not be persisted here. */
46
+ pairing?: RepoMeshHostPairingMetadata;
47
+ }
48
+ export interface RepoMeshHostStatus extends RepoMeshHostMetadata {
49
+ canOwnCoordinator: boolean;
50
+ canOwnQueue: boolean;
51
+ defaulted: boolean;
52
+ }
26
53
  export interface RepoMeshNode {
27
54
  id: string;
28
55
  daemonId: string;
@@ -37,6 +64,7 @@ export interface RepoMeshNode {
37
64
  effectiveCapabilities: RepoMeshNodeCapabilities;
38
65
  policy: RepoMeshNodePolicy;
39
66
  health: RepoMeshNodeHealth;
67
+ role?: RepoMeshDaemonRole;
40
68
  status: 'enabled' | 'disabled' | 'removed';
41
69
  }
42
70
  export type RepoMeshNodeHealth = 'online' | 'offline' | 'degraded' | 'dirty' | 'wrong_branch' | 'unknown';
@@ -185,6 +213,7 @@ export interface LocalMeshEntry {
185
213
  defaultBranch?: string;
186
214
  policy: RepoMeshPolicy;
187
215
  coordinator: RepoMeshCoordinatorConfig;
216
+ meshHost?: RepoMeshHostMetadata;
188
217
  nodes: LocalMeshNodeEntry[];
189
218
  createdAt: string;
190
219
  updatedAt: string;
@@ -206,12 +235,15 @@ export interface LocalMeshNodeEntry {
206
235
  clonedFromNodeId?: string;
207
236
  /** Optional associated/external repos configured as node metadata. */
208
237
  relatedRepos?: RepoMeshRelatedRepo[];
238
+ role?: RepoMeshDaemonRole;
209
239
  }
210
240
  export interface RepoMeshStatus {
211
241
  meshId: string;
212
242
  meshName: string;
213
243
  repoIdentity: string;
244
+ defaultBranch?: string;
214
245
  refreshedAt: string;
246
+ meshHost?: RepoMeshHostStatus;
215
247
  nodes: RepoMeshNodeStatus[];
216
248
  queue?: RepoMeshQueueStatus;
217
249
  ledger?: RepoMeshLedgerStatus;
@@ -248,11 +280,18 @@ export interface RepoMeshNodeStatus {
248
280
  repoRoot?: string;
249
281
  daemonId?: string;
250
282
  machineId?: string;
283
+ role?: RepoMeshDaemonRole;
251
284
  machineStatus?: string;
252
285
  isLocalWorktree?: boolean;
253
286
  worktreeBranch?: string;
254
287
  health: RepoMeshNodeHealth;
255
288
  git?: GitRepoStatus;
289
+ /**
290
+ * True when the selected coordinator has evidence that a peer git probe is still
291
+ * in flight or just timed out during initial mesh handshake, so callers should
292
+ * treat missing git data as pending instead of authoritative absence.
293
+ */
294
+ gitProbePending?: boolean;
256
295
  providers: string[];
257
296
  activeSessions: string[];
258
297
  activeSessionDetails?: RepoMeshSessionStatus[];
@@ -46,6 +46,8 @@ export declare class DaemonStatusReporter {
46
46
  private lastStatusSentAt;
47
47
  private statusPendingThrottle;
48
48
  private lastP2PStatusHash;
49
+ private lastP2PStatusSentAt;
50
+ private p2pDebounceTimer;
49
51
  private lastServerStatusHash;
50
52
  private lastStatusSummary;
51
53
  private statusTimer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.82-rc.8",
3
+ "version": "0.9.82-rc.81",
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",
@@ -49,6 +49,7 @@
49
49
  "@adhdev/session-host-core": "*",
50
50
  "@agentclientprotocol/sdk": "^0.16.1",
51
51
  "@xterm/xterm": "^6.0.0",
52
+ "better-sqlite3": "^12.10.0",
52
53
  "chalk": "^5.3.0",
53
54
  "chokidar": "^4.0.3",
54
55
  "conf": "^13.0.0",
@@ -60,6 +61,7 @@
60
61
  "@adhdev/ghostty-vt-node": "*"
61
62
  },
62
63
  "devDependencies": {
64
+ "@types/better-sqlite3": "^7.6.13",
63
65
  "@types/js-yaml": "^4.0.9",
64
66
  "@types/node": "^22.0.0",
65
67
  "@types/ws": "^8.18.1",
@@ -309,6 +309,7 @@ export async function initDaemonComponents(config: DaemonInitConfig): Promise<Da
309
309
  statusInstanceId: config.statusInstanceId,
310
310
  statusVersion: config.statusVersion,
311
311
  getMeshPeerConnectionStatus: config.getMeshPeerConnectionStatus,
312
+ dispatchMeshCommand: config.dispatchMeshCommand,
312
313
  getCdpLogFn: config.getCdpLogFn || ((ideType: string) => LOG.forComponent(`CDP:${ideType}`).asLogFn()),
313
314
  });
314
315