@adhdev/daemon-core 0.9.82-rc.186 → 0.9.82-rc.188

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 (55) hide show
  1. package/dist/boot/daemon-lifecycle.d.ts +1 -0
  2. package/dist/commands/cli-manager.d.ts +2 -1
  3. package/dist/commands/mesh-coordinator.d.ts +13 -0
  4. package/dist/commands/router.d.ts +5 -1
  5. package/dist/config/chat-history.d.ts +1 -0
  6. package/dist/git/git-commands.d.ts +2 -0
  7. package/dist/git/git-types.d.ts +2 -0
  8. package/dist/index.d.ts +2 -2
  9. package/dist/index.js +15461 -14552
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +14411 -13502
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/mesh/beads-db.d.ts +1 -0
  14. package/dist/mesh/mesh-events.d.ts +46 -1
  15. package/dist/mesh/mesh-work-queue.d.ts +1 -0
  16. package/dist/providers/cli-provider-instance.d.ts +4 -0
  17. package/dist/providers/contracts.d.ts +32 -1
  18. package/dist/providers/native-history/dispatcher.d.ts +2 -0
  19. package/dist/providers/sdk/v1/types/common/index.d.ts +35 -1
  20. package/dist/providers/spec/cli-adapter.d.ts +1 -0
  21. package/dist/providers/spec/driver.d.ts +6 -1
  22. package/dist/providers/spec/native-history-executor.d.ts +2 -0
  23. package/dist/providers/spec/schema.gen.d.ts +22 -0
  24. package/dist/providers/spec/types.d.ts +10 -0
  25. package/dist/repo-mesh-types.d.ts +6 -0
  26. package/package.json +1 -1
  27. package/src/boot/daemon-lifecycle.ts +2 -0
  28. package/src/commands/chat-commands.ts +206 -18
  29. package/src/commands/cli-manager.ts +56 -14
  30. package/src/commands/mesh-coordinator.ts +110 -5
  31. package/src/commands/router.ts +146 -21
  32. package/src/config/chat-history.ts +4 -0
  33. package/src/git/git-commands.ts +20 -2
  34. package/src/git/git-status.ts +35 -6
  35. package/src/git/git-types.ts +2 -0
  36. package/src/index.ts +2 -2
  37. package/src/mesh/beads-db.ts +4 -0
  38. package/src/mesh/mesh-events.ts +264 -4
  39. package/src/mesh/mesh-work-queue.ts +4 -0
  40. package/src/providers/cli-provider-instance.ts +122 -13
  41. package/src/providers/contracts.d.ts +55 -0
  42. package/src/providers/contracts.ts +36 -1
  43. package/src/providers/native-history/dispatcher.ts +126 -17
  44. package/src/providers/provider-loader.ts +4 -7
  45. package/src/providers/provider-schema.ts +56 -1
  46. package/src/providers/sdk/v1/schemas/cli/provider.schema.json +46 -0
  47. package/src/providers/sdk/v1/types/common/index.ts +19 -0
  48. package/src/providers/spec/cli-adapter.ts +32 -5
  49. package/src/providers/spec/driver.ts +68 -1
  50. package/src/providers/spec/evaluator.ts +11 -1
  51. package/src/providers/spec/native-history-executor.ts +93 -27
  52. package/src/providers/spec/schema.gen.ts +12 -1
  53. package/src/providers/spec/schema.json +21 -1
  54. package/src/providers/spec/types.ts +10 -0
  55. package/src/repo-mesh-types.ts +6 -0
@@ -68,5 +68,6 @@ export declare class BeadsDB {
68
68
  }>;
69
69
  updateDirectDispatchStatus(meshId: string, sessionId: string, status: 'acked' | 'completed' | 'failed' | 'stale'): void;
70
70
  cleanupTerminalDirectDispatches(olderThanMs: number): void;
71
+ deleteDirectDispatches(meshId: string): void;
71
72
  markStaleDirectDispatches(meshId: string, olderThanMs: number): void;
72
73
  }
@@ -1,4 +1,5 @@
1
1
  import type { DaemonComponents } from '../boot/daemon-lifecycle.js';
2
+ import type { MeshLedgerKind } from './mesh-ledger.js';
2
3
  export declare function __resetIdleAutoFastForwardForTests(): void;
3
4
  export interface PendingMeshCoordinatorEvent {
4
5
  event: string;
@@ -23,12 +24,56 @@ export declare function drainPendingMeshCoordinatorEvents(meshId?: string, coord
23
24
  export declare function getPendingMeshCoordinatorEvents(meshId?: string, coordinatorDaemonId?: string): readonly PendingMeshCoordinatorEvent[];
24
25
  /** Explicitly clear all pending coordinator events for a mesh (and coordinator if scoped). */
25
26
  export declare function clearPendingMeshCoordinatorEvents(meshId?: string, coordinatorDaemonId?: string): void;
27
+ export declare function reconcileDirectDispatchCompletionFromTranscript(args: {
28
+ meshId: string;
29
+ nodeId?: string;
30
+ sessionId: string;
31
+ providerType?: string;
32
+ providerSessionId?: string;
33
+ taskId: string;
34
+ finalSummary: string;
35
+ transcriptMessageAt?: string;
36
+ completedAt?: string;
37
+ targetCoordinatorDaemonId?: string;
38
+ source?: string;
39
+ }): {
40
+ reconciled: boolean;
41
+ kind?: MeshLedgerKind;
42
+ alreadyTerminal?: boolean;
43
+ workerResult?: unknown;
44
+ ledgerEntryId?: string;
45
+ reason?: string;
46
+ };
26
47
  export declare function tryAssignQueueTask(components: DaemonComponents, meshId: string, nodeId: string, sessionId: string, providerType: string): boolean;
48
+ export interface MeshQueueTriggerResult {
49
+ success: true;
50
+ meshId: string;
51
+ pendingBefore: number;
52
+ assignedBefore: number;
53
+ pendingAfter: number;
54
+ assignedAfter: number;
55
+ claimed: boolean;
56
+ newlyAssignedTasks: Array<{
57
+ id: string;
58
+ nodeId?: string;
59
+ sessionId?: string;
60
+ }>;
61
+ localIdleSessionsChecked: number;
62
+ remoteIdleSessionsChecked: number;
63
+ skippedSessions: Array<{
64
+ nodeId?: string;
65
+ sessionId?: string;
66
+ reason: string;
67
+ status?: string;
68
+ }>;
69
+ autoLaunchStarted: boolean;
70
+ noIdleMeshSessionAvailable?: boolean;
71
+ }
27
72
  /**
28
73
  * Triggers a queue check for all nodes in the mesh.
29
74
  * Called when a new task is enqueued, in case nodes are already idle.
30
75
  */
31
- export declare function triggerMeshQueue(components: DaemonComponents, meshId: string): Promise<void>;
76
+ export declare function triggerMeshQueue(components: DaemonComponents, meshId: string): Promise<MeshQueueTriggerResult>;
32
77
  export declare function handleMeshForwardEvent(components: DaemonComponents, payload: Record<string, unknown>): {
33
78
  success: boolean;
34
79
  forwarded: number;
@@ -136,6 +136,7 @@ export interface MeshWorkQueueStats {
136
136
  export declare function getMeshQueueStats(meshId: string): MeshWorkQueueStats;
137
137
  export declare function __replaceMeshQueueForTests(meshId: string, queue: MeshWorkQueueEntry[]): void;
138
138
  export declare function __clearMeshQueueForTests(meshId: string): void;
139
+ export declare function __clearDirectDispatchesForTests(meshId: string): void;
139
140
  export declare function __resetBeadsDBForTests(): void;
140
141
  export type DirectDispatchRecord = ReturnType<BeadsDB['getActiveDirectDispatches']>[number];
141
142
  export declare function insertDirectDispatch(meshId: string, data: {
@@ -55,6 +55,8 @@ export declare class CliProviderInstance implements ProviderInstance {
55
55
  private historyWriter;
56
56
  private runtimeMessages;
57
57
  private lastPersistedHistoryMessages;
58
+ private lastAcknowledgedUserInputAt;
59
+ private externalBusyIdleFingerprint;
58
60
  private lastNativeSourceCanonicalCheckAt;
59
61
  private lastNativeSourceCanonicalCacheKey;
60
62
  private cachedSqliteDb;
@@ -130,6 +132,8 @@ export declare class CliProviderInstance implements ProviderInstance {
130
132
  private readExternalCompletionMessages;
131
133
  private completionFinalAssistantEvidence;
132
134
  private completionFinalSummary;
135
+ private externalNativeFinalFingerprint;
136
+ private getExternalNativeFinalReconciliation;
133
137
  private buildCompletedFinalizationDiagnostic;
134
138
  private hasAdapterPendingResponse;
135
139
  private shouldSuppressStaleParsedBusyStatus;
@@ -302,7 +302,7 @@ export interface ProviderMeshCoordinatorConfig {
302
302
  requiresRestart?: boolean;
303
303
  /** User-facing setup explanation for manual modes. */
304
304
  instructions?: string;
305
- /** Copyable setup template. Supports {{meshId}}, {{adhdevMcpCommand}}, {{workspace}}, {{serverName}}. */
305
+ /** Copyable setup template. Supports {{meshId}}, {{adhdevMcpCommand}}, {{adhdevMcpArgs}}, {{workspace}}, {{serverName}}. */
306
306
  template?: string;
307
307
  };
308
308
  /**
@@ -315,7 +315,38 @@ export interface ProviderMeshCoordinatorConfig {
315
315
  * the CLI doesn't recognize).
316
316
  */
317
317
  systemPromptInjection?: MeshCoordinatorSystemPromptInjection;
318
+ /**
319
+ * How coordinator-launched worker sessions are isolated from coordinator-only
320
+ * MCP/tools/config. Provider-specific CLI quirks belong here, not in daemon
321
+ * launch code.
322
+ */
323
+ delegatedWorkerIsolation?: MeshCoordinatorDelegatedWorkerIsolation;
324
+ }
325
+ export interface MeshCoordinatorDelegatedWorkerIsolation {
326
+ /** Environment variables to unset for delegated worker sessions. */
327
+ env?: {
328
+ unset?: string[];
329
+ };
330
+ /** Spawn-argument rules applied before launching a delegated worker. */
331
+ args?: MeshCoordinatorDelegatedWorkerArgRule[];
318
332
  }
333
+ export type MeshCoordinatorDelegatedWorkerArgRule = {
334
+ mode: 'empty_mcp_config';
335
+ /** CLI flag that points at an MCP config file, e.g. '--mcp-config'. */
336
+ flag: string;
337
+ /** Optional CLI flag that forces only the provided MCP config to be used. */
338
+ strictFlag?: string;
339
+ } | {
340
+ mode: 'config_override';
341
+ /** CLI config flag, e.g. '-c' or '--config'. */
342
+ flag: string;
343
+ /** Config key to set for worker isolation. */
344
+ key: string;
345
+ /** Config value to set. */
346
+ value: string;
347
+ /** Optional broader key prefix used for duplicate detection. */
348
+ dedupeKey?: string;
349
+ };
319
350
  /**
320
351
  * Declarative description of how a CLI accepts a session-scoped system prompt.
321
352
  *
@@ -5,6 +5,7 @@ export interface NativeHistoryInput {
5
5
  providerSessionId?: string;
6
6
  historySessionId?: string;
7
7
  workspace?: string;
8
+ sessionStartedAtMs?: number;
8
9
  format?: string;
9
10
  watchPath?: string;
10
11
  forceRefresh?: boolean;
@@ -16,6 +17,7 @@ export interface NativeHistoryResult {
16
17
  content: string;
17
18
  receivedAt?: number;
18
19
  kind?: string;
20
+ workspace?: string;
19
21
  }>;
20
22
  providerSessionId?: string;
21
23
  sourcePath: string;
@@ -138,7 +138,41 @@ export interface McpConfigDef {
138
138
  export interface MeshCoordinatorDef {
139
139
  supported: boolean;
140
140
  mcpConfig?: McpConfigDef;
141
- }
141
+ systemPromptInjection?: MeshCoordinatorSystemPromptInjectionDef;
142
+ delegatedWorkerIsolation?: MeshCoordinatorDelegatedWorkerIsolationDef;
143
+ }
144
+ export type MeshCoordinatorSystemPromptInjectionDef = {
145
+ mode: 'cli_arg';
146
+ flag: string;
147
+ } | {
148
+ mode: 'config_override';
149
+ flag: string;
150
+ template: string;
151
+ } | {
152
+ mode: 'context_file';
153
+ path: string;
154
+ wrapper?: string;
155
+ } | {
156
+ mode: 'env_var';
157
+ name: string;
158
+ };
159
+ export interface MeshCoordinatorDelegatedWorkerIsolationDef {
160
+ env?: {
161
+ unset?: ReadonlyArray<string>;
162
+ };
163
+ args?: ReadonlyArray<MeshCoordinatorDelegatedWorkerArgRuleDef>;
164
+ }
165
+ export type MeshCoordinatorDelegatedWorkerArgRuleDef = {
166
+ mode: 'empty_mcp_config';
167
+ flag: string;
168
+ strictFlag?: string;
169
+ } | {
170
+ mode: 'config_override';
171
+ flag: string;
172
+ key: string;
173
+ value: string;
174
+ dedupeKey?: string;
175
+ };
142
176
  export interface CompatibilityEntryDef {
143
177
  /** SemVer range against the agent's own version. Optional. */
144
178
  ideVersion?: string;
@@ -90,6 +90,7 @@ export declare class SpecCliAdapter implements CliAdapter {
90
90
  private handleEvent;
91
91
  private detectInteractivePromptFromPtyChunk;
92
92
  private readCurrentScreenSections;
93
+ private extractProviderSessionIdFromScreen;
93
94
  private readClaudeScreenAssistantMessages;
94
95
  private maybeCaptureClaudeTuiPrompt;
95
96
  private readClaudeTuiHeaders;
@@ -1,5 +1,6 @@
1
1
  import type { PtyTransportFactory } from '../../cli-adapters/pty-transport.js';
2
- import { type TraceEntry } from './evaluator.js';
2
+ import { type SpecEvaluation, type TraceEntry } from './evaluator.js';
3
+ import type { CliSpec } from './types.js';
3
4
  export type DashboardEvent = {
4
5
  kind: 'pty_data';
5
6
  chunk: string;
@@ -96,6 +97,8 @@ export interface SpecDriverOpts {
96
97
  * embedded `\n`.
97
98
  */
98
99
  export declare function resolveSubmitDelayMs(specBeforeSubmit: number | undefined, text: string): number;
100
+ export declare function matchesCompletionIdleRule(spec: CliSpec, ev: SpecEvaluation, screen: string): string | null;
101
+ export declare function matchesCompletionIdleTargetState(spec: CliSpec, ev: SpecEvaluation, screen: string): boolean;
99
102
  export declare class SpecDriver {
100
103
  private readonly opts;
101
104
  private spec;
@@ -122,6 +125,8 @@ export declare class SpecDriver {
122
125
  * because the evaluator already moved past busy by the time the hold
123
126
  * kicks in. */
124
127
  private lastBusyState;
128
+ private completionIdleFirstSeenAt;
129
+ private completionIdleKey;
125
130
  /** Timer that re-runs evaluate() once the hold window expires. Needed
126
131
  * because the PTY stops emitting once the agent finishes; without an
127
132
  * explicit wake-up there's nothing to trigger the busy → idle
@@ -28,6 +28,7 @@ export interface NativeHistoryMessage {
28
28
  content: string;
29
29
  receivedAt: number;
30
30
  kind?: string;
31
+ workspace?: string;
31
32
  }
32
33
  export interface NativeHistoryResult {
33
34
  messages: NativeHistoryMessage[];
@@ -35,5 +36,6 @@ export interface NativeHistoryResult {
35
36
  sourcePath: string;
36
37
  sourceMtimeMs: number;
37
38
  nativeHistoryCoverage?: 'full' | 'partial' | 'best-effort';
39
+ workspace?: string;
38
40
  }
39
41
  export declare function executeNativeHistory(cfg: NativeHistoryConfig, input: NativeHistoryInput): NativeHistoryResult | null;
@@ -124,6 +124,28 @@ export declare const SCHEMA: {
124
124
  readonly type: "integer";
125
125
  readonly minimum: 0;
126
126
  };
127
+ readonly completion_idle_after: {
128
+ readonly type: "object";
129
+ readonly additionalProperties: false;
130
+ readonly required: readonly ["regex", "hold_ms"];
131
+ readonly properties: {
132
+ readonly section: {
133
+ readonly type: "string";
134
+ readonly minLength: 1;
135
+ };
136
+ readonly regex: {
137
+ readonly type: "string";
138
+ readonly minLength: 1;
139
+ };
140
+ readonly flags: {
141
+ readonly type: "string";
142
+ };
143
+ readonly hold_ms: {
144
+ readonly type: "integer";
145
+ readonly minimum: 0;
146
+ };
147
+ };
148
+ };
127
149
  };
128
150
  };
129
151
  };
@@ -208,5 +208,15 @@ export interface CliSpec {
208
208
  * once the window passes and an idle state has actually been
209
209
  * observed. */
210
210
  startup_grace_ms?: number;
211
+ /** Treat a provider-specific completion marker as idle after it has
212
+ * remained visible for hold_ms. This handles TUIs that leave their
213
+ * last spinner glyph next to a completed timer, causing the normal
214
+ * busy regex to keep matching after the turn is done. */
215
+ completion_idle_after?: {
216
+ section?: string;
217
+ regex: string;
218
+ flags?: string;
219
+ hold_ms: number;
220
+ };
211
221
  };
212
222
  }
@@ -305,11 +305,17 @@ export interface RepoMeshSessionStatus {
305
305
  sessionId: string;
306
306
  providerType?: string;
307
307
  state?: string;
308
+ chatStatus?: string;
308
309
  lifecycle?: 'starting' | 'running' | 'stopping' | 'stopped' | 'failed' | 'interrupted';
309
310
  surfaceKind?: 'live_runtime' | 'recovery_snapshot' | 'inactive_record';
310
311
  recoveryState?: string | null;
311
312
  workspace?: string | null;
312
313
  title?: string | null;
314
+ role?: string | null;
315
+ isSelfCoordinator?: boolean;
316
+ statusNote?: string | null;
317
+ createdAt?: string | null;
318
+ startedAt?: string | null;
313
319
  lastActivityAt?: string | null;
314
320
  isCached?: boolean;
315
321
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.82-rc.186",
3
+ "version": "0.9.82-rc.188",
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",
@@ -63,6 +63,7 @@ export interface DaemonInitConfig {
63
63
 
64
64
  /** Router transport-specific callbacks */
65
65
  onStatusChange?: () => void;
66
+ onMeshStateChange?: (meshId: string) => void;
66
67
  onPostChatCommand?: () => void;
67
68
  sessionHostControl?: SessionHostControlPlane | null;
68
69
  getCdpLogFn?: (ideType: string) => (msg: string) => void;
@@ -310,6 +311,7 @@ export async function initDaemonComponents(config: DaemonInitConfig): Promise<Da
310
311
  },
311
312
  onIdeConnected: () => poller?.start(),
312
313
  onStatusChange: config.onStatusChange,
314
+ onMeshStateChange: config.onMeshStateChange,
313
315
  onPostChatCommand: config.onPostChatCommand,
314
316
  sessionHostControl: config.sessionHostControl,
315
317
  statusInstanceId: config.statusInstanceId,