@adhdev/daemon-core 0.9.82-rc.14 → 0.9.82-rc.141

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 (115) hide show
  1. package/dist/chat/source-machine.d.ts +166 -0
  2. package/dist/chat/source-resolver.d.ts +104 -0
  3. package/dist/chat/subscription-updates.d.ts +1 -0
  4. package/dist/cli-adapter-types.d.ts +5 -1
  5. package/dist/cli-adapters/cli-script-runner.d.ts +45 -0
  6. package/dist/cli-adapters/cli-state-engine.d.ts +178 -0
  7. package/dist/cli-adapters/provider-cli-adapter.d.ts +87 -63
  8. package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
  9. package/dist/cli-adapters/provider-cli-shared.d.ts +21 -0
  10. package/dist/commands/router.d.ts +22 -0
  11. package/dist/config/chat-history.d.ts +5 -0
  12. package/dist/config/config.d.ts +5 -0
  13. package/dist/config/mesh-config.d.ts +68 -1
  14. package/dist/git/git-commands.d.ts +5 -1
  15. package/dist/index.d.ts +18 -6
  16. package/dist/index.js +10431 -2827
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +10376 -2811
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/installer.d.ts +1 -4
  21. package/dist/launch.d.ts +1 -1
  22. package/dist/logging/async-batch-writer.d.ts +10 -0
  23. package/dist/mesh/beads-db.d.ts +72 -0
  24. package/dist/mesh/contracts.d.ts +164 -0
  25. package/dist/mesh/coordinator-registry.d.ts +25 -0
  26. package/dist/mesh/mesh-active-work.d.ts +90 -0
  27. package/dist/mesh/mesh-events.d.ts +77 -5
  28. package/dist/mesh/mesh-fast-forward.d.ts +39 -0
  29. package/dist/mesh/mesh-host-ownership.d.ts +9 -0
  30. package/dist/mesh/mesh-ledger.d.ts +58 -1
  31. package/dist/mesh/mesh-refine-status.d.ts +26 -0
  32. package/dist/mesh/mesh-work-queue.d.ts +44 -5
  33. package/dist/mesh/preview-freshness.d.ts +18 -0
  34. package/dist/mesh/refine-config.d.ts +193 -0
  35. package/dist/mesh/worktree-bootstrap-config.d.ts +113 -0
  36. package/dist/providers/approval-utils.d.ts +9 -0
  37. package/dist/providers/chat-message-normalization.d.ts +1 -0
  38. package/dist/providers/cli-provider-instance.d.ts +6 -1
  39. package/dist/providers/contracts.d.ts +19 -0
  40. package/dist/providers/read-chat-contract.d.ts +29 -0
  41. package/dist/providers/transcript-v2.d.ts +176 -0
  42. package/dist/repo-mesh-types.d.ts +67 -0
  43. package/dist/shared-types.d.ts +12 -0
  44. package/dist/status/reporter.d.ts +2 -0
  45. package/dist/status/snapshot.d.ts +1 -0
  46. package/dist/types.d.ts +5 -0
  47. package/package.json +3 -1
  48. package/src/boot/daemon-lifecycle.ts +3 -0
  49. package/src/chat/source-machine.ts +534 -0
  50. package/src/chat/source-resolver.ts +0 -0
  51. package/src/chat/subscription-updates.ts +14 -1
  52. package/src/cli-adapter-types.d.ts +1 -0
  53. package/src/cli-adapter-types.ts +3 -1
  54. package/src/cli-adapters/cli-script-runner.ts +145 -0
  55. package/src/cli-adapters/cli-state-engine.ts +1083 -0
  56. package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
  57. package/src/cli-adapters/provider-cli-adapter.ts +630 -1137
  58. package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
  59. package/src/cli-adapters/provider-cli-parse.ts +13 -0
  60. package/src/cli-adapters/provider-cli-runtime.ts +3 -1
  61. package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
  62. package/src/cli-adapters/provider-cli-shared.ts +51 -11
  63. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +17 -1
  64. package/src/cli-adapters/terminal-backends/xterm-backend.ts +8 -1
  65. package/src/commands/chat-commands.ts +1428 -50
  66. package/src/commands/cli-manager.ts +145 -3
  67. package/src/commands/handler.ts +8 -1
  68. package/src/commands/mesh-coordinator.ts +13 -143
  69. package/src/commands/router.ts +3271 -427
  70. package/src/config/chat-history.ts +79 -24
  71. package/src/config/config.ts +12 -0
  72. package/src/config/mesh-config.ts +249 -2
  73. package/src/config/recent-activity.ts +8 -2
  74. package/src/daemon/dev-cli-debug.ts +10 -1
  75. package/src/detection/ide-detector.ts +26 -16
  76. package/src/git/git-commands.ts +17 -5
  77. package/src/git/git-worktree.ts +8 -1
  78. package/src/index.ts +45 -5
  79. package/src/installer.d.ts +1 -1
  80. package/src/installer.ts +8 -6
  81. package/src/launch.d.ts +1 -1
  82. package/src/launch.ts +37 -28
  83. package/src/logging/async-batch-writer.ts +55 -0
  84. package/src/logging/logger.ts +2 -1
  85. package/src/mesh/beads-db.ts +479 -0
  86. package/src/mesh/contracts.ts +329 -0
  87. package/src/mesh/coordinator-prompt.ts +40 -22
  88. package/src/mesh/coordinator-registry.ts +75 -0
  89. package/src/mesh/mesh-active-work.ts +437 -0
  90. package/src/mesh/mesh-events.ts +799 -56
  91. package/src/mesh/mesh-fast-forward.ts +430 -0
  92. package/src/mesh/mesh-host-ownership.ts +73 -0
  93. package/src/mesh/mesh-ledger.ts +457 -104
  94. package/src/mesh/mesh-refine-status.ts +144 -0
  95. package/src/mesh/mesh-work-queue.ts +216 -158
  96. package/src/mesh/preview-freshness.ts +118 -0
  97. package/src/mesh/refine-config.ts +366 -0
  98. package/src/mesh/worktree-bootstrap-config.ts +247 -0
  99. package/src/providers/approval-utils.ts +39 -5
  100. package/src/providers/chat-message-normalization.ts +7 -12
  101. package/src/providers/cli-provider-instance.ts +362 -41
  102. package/src/providers/contracts.ts +19 -0
  103. package/src/providers/ide-provider-instance.ts +17 -3
  104. package/src/providers/provider-loader.ts +31 -11
  105. package/src/providers/provider-schema.ts +12 -0
  106. package/src/providers/read-chat-contract.ts +76 -16
  107. package/src/providers/transcript-v2.ts +567 -0
  108. package/src/providers/version-archive.ts +38 -20
  109. package/src/repo-mesh-types.ts +77 -0
  110. package/src/shared-types.ts +9 -0
  111. package/src/status/builders.ts +23 -6
  112. package/src/status/reporter.ts +15 -0
  113. package/src/status/snapshot.ts +35 -11
  114. package/src/system/host-memory.ts +29 -12
  115. package/src/types.ts +5 -0
@@ -15,28 +15,28 @@
15
15
  */
16
16
  import type { CliAdapter } from '../cli-adapter-types.js';
17
17
  import { type PtyRuntimeMetadata, type PtyTransportFactory } from './pty-transport.js';
18
- import { type CliProviderModule, type CliScripts, type CliSessionStatus } from './provider-cli-shared.js';
18
+ import { type CliProviderModule, type CliScripts, type CliSessionStatus, type CliTraceEntry, type ParsedSession } from './provider-cli-shared.js';
19
+ import { CliStateEngine, type CliBufferSnapshot } from './cli-state-engine.js';
20
+ import { type TurnParseScope } from './provider-cli-parse.js';
19
21
  import { type ProviderResolutionMeta } from './provider-cli-config.js';
20
22
  export { normalizeCliProviderForRuntime, type CliApprovalInput, type CliChatMessage, type CliProviderModule, type CliScreenLine, type CliScreenSnapshot, type CliScriptInput, type CliScripts, type CliSessionStatus, type CliStatusInput, type CliTraceEntry, } from './provider-cli-shared.js';
21
23
  export declare function appendBoundedText(current: string, chunk: string, maxChars: number): string;
22
24
  export declare class ProviderCliAdapter implements CliAdapter {
23
25
  private extraArgs;
24
26
  private extraEnv;
25
- readonly cliType: string;
27
+ cliType: string;
26
28
  readonly cliName: string;
27
29
  workingDir: string;
28
30
  private provider;
29
31
  private ptyProcess;
30
32
  private transportFactory;
31
- private currentStatus;
32
33
  private onStatusChange;
34
+ readonly engine: CliStateEngine;
33
35
  private responseBuffer;
34
36
  private recentOutputBuffer;
35
- private isWaitingForResponse;
36
- private activeModal;
37
- private parseErrorMessage;
37
+ private get parseErrorMessage();
38
+ private providerSessionId;
38
39
  private responseTimeout;
39
- private idleTimeout;
40
40
  private ready;
41
41
  private startupBuffer;
42
42
  private startupParseGate;
@@ -57,28 +57,15 @@ export declare class ProviderCliAdapter implements CliAdapter {
57
57
  private lastScreenSnapshotReadAt;
58
58
  private serverConn;
59
59
  private logBuffer;
60
- private lastApprovalResolvedAt;
61
- private approvalTransitionBuffer;
62
- private approvalExitTimeout;
63
- private pendingScriptStatus;
64
- private pendingScriptStatusSince;
65
- private pendingScriptStatusTimer;
66
- private settleTimer;
67
- private settledBuffer;
68
- private submitPendingUntil;
69
- private responseSettleIgnoreUntil;
70
- private responseEpoch;
60
+ private pendingOutboundQueue;
61
+ private pendingOutboundFlushTimer;
62
+ private pendingOutboundFlushInFlight;
71
63
  private submitRetryTimer;
72
- private submitRetryUsed;
73
- private submitRetryPromptSnippet;
74
- private idleFinishCandidate;
75
- private finishRetryTimer;
76
- private finishRetryCount;
77
64
  private resizeSuppressUntil;
78
- private statusHistory;
79
- private cliScripts;
80
- /** Per-session opaque state object created by cliScripts.createState(), reset on stop. */
81
- private scriptState;
65
+ private readonly runner;
66
+ /** @deprecated use runner.cliScripts for direct script access */
67
+ get cliScripts(): CliScripts;
68
+ set cliScripts(scripts: CliScripts);
82
69
  private runtimeSettings;
83
70
  /** Full accumulated rendered PTY transcript for parser/readback use */
84
71
  private accumulatedBuffer;
@@ -98,16 +85,9 @@ export declare class ProviderCliAdapter implements CliAdapter {
98
85
  * Hermes turn (tool calls + reasoning + final bubble) without the
99
86
  * rolling window pushing the turn's ╭─ opening line out of view. */
100
87
  private static readonly MAX_ACCUMULATED_BUFFER;
101
- private currentTurnScope;
102
- private traceEntries;
103
- private traceSeq;
104
- private traceSessionId;
105
88
  private parsedStatusCache;
106
89
  private static readonly SCREEN_SNAPSHOT_MIN_INTERVAL_MS;
107
- private static readonly MAX_TRACE_ENTRIES;
108
90
  private readonly providerResolutionMeta;
109
- private static readonly FINISH_RETRY_DELAY_MS;
110
- private static readonly MAX_FINISH_RETRIES;
111
91
  private getBufferState;
112
92
  private recordBoundedAppendDrop;
113
93
  private readTerminalScreenText;
@@ -120,18 +100,12 @@ export declare class ProviderCliAdapter implements CliAdapter {
120
100
  private shouldUseFullProviderTranscriptContext;
121
101
  private getIdleFinishConfirmMs;
122
102
  private getStatusActivityHoldMs;
123
- private setStatus;
124
- private clearIdleFinishCandidate;
125
- private armIdleFinishCandidate;
126
- private recordTrace;
127
- private resetTraceSession;
128
103
  private readonly timeouts;
129
104
  private readonly approvalKeys;
130
105
  private readonly sendDelayMs;
131
106
  private readonly sendKey;
132
107
  private readonly submitStrategy;
133
108
  private readonly requirePromptEchoBeforeSubmit;
134
- private static readonly SCRIPT_STATUS_DEBOUNCE_MS;
135
109
  constructor(provider: CliProviderModule, workingDir: string, extraArgs?: string[], extraEnv?: Record<string, string>, transportFactory?: PtyTransportFactory);
136
110
  /** Inject CLI scripts after construction (e.g. when resolved by ProviderLoader) */
137
111
  setCliScripts(scripts: CliScripts): void;
@@ -146,29 +120,15 @@ export declare class ProviderCliAdapter implements CliAdapter {
146
120
  private handleOutput;
147
121
  private resolveStartupState;
148
122
  private scheduleStartupSettleCheck;
149
- private scheduleSettle;
150
- private armApprovalExitTimeout;
151
- private shouldRetryFinishResponse;
152
- private hasRecentInteractiveActivity;
153
- private shouldDeferIdleTimeoutFinish;
154
123
  private waitForInteractivePrompt;
155
124
  private clearAllTimers;
156
- private clearStaleIdleResponseGuard;
157
- private hasMeaningfulResponseBuffer;
158
- private evaluateSettled;
159
- private applyPendingScriptStatusDebounce;
160
- private applyHoldGenerating;
161
- private applyWaitingApproval;
162
- private applyGenerating;
163
- private applyIdle;
164
- private finishResponse;
165
- private maybeCommitVisibleIdleTranscript;
166
- private commitCurrentTranscript;
167
- private invokeCliScript;
168
- private runParseSession;
169
- private runDetectStatus;
170
- private runParseApproval;
171
- private hasActionableApproval;
125
+ runParseSession(): ParsedSession | null;
126
+ runDetectStatus(text: string): string | null;
127
+ runParseApproval(tail: string): {
128
+ message: string;
129
+ buttons: string[];
130
+ } | null;
131
+ private applyParsedSessionMetadata;
172
132
  private projectEffectiveStatus;
173
133
  getStatus(options?: {
174
134
  allowParse?: boolean;
@@ -188,6 +148,7 @@ export declare class ProviderCliAdapter implements CliAdapter {
188
148
  */
189
149
  resolveAction(data: any): Promise<void>;
190
150
  private isSubmitStuck;
151
+ private hasMeaningfulResponseBufferLocal;
191
152
  private writeToPty;
192
153
  private resetPendingSendState;
193
154
  private commitSendUserTurn;
@@ -198,7 +159,15 @@ export declare class ProviderCliAdapter implements CliAdapter {
198
159
  private submitSendKey;
199
160
  private submitImmediatePrompt;
200
161
  private waitForEchoAndSubmit;
201
- sendMessage(text: string): Promise<void>;
162
+ sendMessage(text: string, options?: {
163
+ force?: boolean;
164
+ }): Promise<void>;
165
+ forceSendMessage(text: string): Promise<void>;
166
+ private enqueuePendingOutboundMessage;
167
+ private shouldQueuePendingOutboundMessage;
168
+ private schedulePendingOutboundFlush;
169
+ private flushPendingOutboundQueue;
170
+ private sendMessageNow;
202
171
  getPartialResponse(): string;
203
172
  getDebugSnapshot(): Record<string, unknown>;
204
173
  getRuntimeMetadata(): PtyRuntimeMetadata | null;
@@ -211,8 +180,63 @@ export declare class ProviderCliAdapter implements CliAdapter {
211
180
  clearHistory(): void;
212
181
  isProcessing(): boolean;
213
182
  isReady(): boolean;
214
- writeRaw(data: string): Promise<void>;
183
+ get currentStatus(): CliSessionStatus['status'];
184
+ set currentStatus(v: CliSessionStatus['status']);
185
+ get isWaitingForResponse(): boolean;
186
+ set isWaitingForResponse(v: boolean);
187
+ get activeModal(): {
188
+ message: string;
189
+ buttons: string[];
190
+ } | null;
191
+ set activeModal(v: {
192
+ message: string;
193
+ buttons: string[];
194
+ } | null);
195
+ get currentTurnScope(): TurnParseScope | null;
196
+ set currentTurnScope(v: TurnParseScope | null);
197
+ get responseEpoch(): number;
198
+ set responseEpoch(v: number);
199
+ get submitRetryUsed(): boolean;
200
+ set submitRetryUsed(v: boolean);
201
+ get submitRetryPromptSnippet(): string;
202
+ set submitRetryPromptSnippet(v: string);
203
+ get responseSettleIgnoreUntil(): number;
204
+ set responseSettleIgnoreUntil(v: number);
205
+ get submitPendingUntil(): number;
206
+ set submitPendingUntil(v: number);
207
+ get lastApprovalResolvedAt(): number;
208
+ set lastApprovalResolvedAt(v: number);
209
+ get providerErrorMessage(): string | null;
210
+ get providerErrorReason(): string | null;
211
+ get pendingScriptStatus(): 'generating' | 'waiting_approval' | null;
212
+ get pendingScriptStatusSince(): number;
213
+ get finishRetryCount(): number;
214
+ set finishRetryCount(v: number);
215
+ get traceSessionId(): string;
216
+ get traceEntries(): CliTraceEntry[];
217
+ get statusHistory(): {
218
+ status: string;
219
+ at: number;
220
+ trigger?: string;
221
+ }[];
222
+ get traceSeq(): number;
223
+ /** Expose engine's evaluateSettled for test access */
224
+ evaluateSettled(): void;
225
+ /** Expose engine's scheduleSettle for test access */
226
+ scheduleSettle(): void;
227
+ /** Expose engine's clearIdleFinishCandidate for test access */
228
+ clearIdleFinishCandidate(reason: string): void;
229
+ /** Expose engine's finishResponse for test access */
230
+ finishResponse(): void;
231
+ /** Returns a point-in-time snapshot of all buffer/screen state for external consumers (e.g. CliStateEngine). */
232
+ getSnapshot(): CliBufferSnapshot;
233
+ isAlive(): boolean;
234
+ flushOutboundQueue(): void;
235
+ writeRaw(data: string | Buffer): Promise<void>;
215
236
  resolveModal(buttonIndex: number): void;
237
+ getApprovalKeyForIndex(buttonIndex: number): string | undefined;
238
+ /** Returns true if an approval was resolved within the adapter's cooldown window. */
239
+ isApprovalRecentlyResolved(): boolean;
216
240
  resize(cols: number, rows: number): void;
217
241
  private getParsedDebugState;
218
242
  getDebugState(): Record<string, any>;
@@ -15,11 +15,15 @@ export declare function buildCliParseInput(options: {
15
15
  accumulatedRawBuffer: string;
16
16
  recentOutputBuffer: string;
17
17
  terminalScreenText: string;
18
+ workingDir?: string;
19
+ providerSessionId?: string;
20
+ historySessionId?: string;
18
21
  baseMessages: CliChatMessage[];
19
22
  partialResponse: string;
20
23
  isWaitingForResponse?: boolean;
21
24
  scope?: TurnParseScope | null;
22
25
  runtimeSettings: Record<string, any>;
26
+ spawnAt?: number;
23
27
  }): CliScriptInput;
24
28
  export declare function summarizeCliTraceText(text: string, max?: number): string;
25
29
  export declare function summarizeCliTraceMessages(messages: CliChatMessage[], limit?: number): {
@@ -26,8 +26,17 @@ export interface CliSessionStatus {
26
26
  message: string;
27
27
  buttons: string[];
28
28
  } | null;
29
+ pendingOutboundCount?: number;
30
+ pendingOutboundMessages?: Array<{
31
+ id: string;
32
+ role: 'user';
33
+ content: string;
34
+ queuedAt: number;
35
+ source: string;
36
+ }>;
29
37
  errorMessage?: string;
30
38
  errorReason?: string;
39
+ providerSessionId?: string;
31
40
  bufferState?: {
32
41
  responseBuffer?: {
33
42
  truncated: boolean;
@@ -59,6 +68,9 @@ export interface ParsedSession {
59
68
  buttons: string[];
60
69
  } | null;
61
70
  parsedStatus: string | null;
71
+ errorMessage?: string;
72
+ errorReason?: string;
73
+ providerSessionId?: string;
62
74
  transcriptAuthority?: 'provider' | 'daemon';
63
75
  coverage?: 'full' | 'tail' | 'current-turn';
64
76
  }
@@ -112,6 +124,10 @@ export interface CliScriptInput {
112
124
  rawBuffer: string;
113
125
  recentBuffer: string;
114
126
  screenText: string;
127
+ workspace?: string;
128
+ workingDir?: string;
129
+ providerSessionId?: string;
130
+ historySessionId?: string;
115
131
  screen: CliScreenSnapshot;
116
132
  bufferScreen: CliScreenSnapshot;
117
133
  recentScreen: CliScreenSnapshot;
@@ -121,6 +137,7 @@ export interface CliScriptInput {
121
137
  promptText?: string;
122
138
  settings?: Record<string, any>;
123
139
  args?: Record<string, any>;
140
+ spawnAt?: number;
124
141
  }
125
142
  export interface CliStatusInput {
126
143
  tail: string;
@@ -164,6 +181,10 @@ export interface CliProviderModule {
164
181
  requirePromptEchoBeforeSubmit?: boolean;
165
182
  /** Allow sending another prompt while the CLI is still generating so users can intervene mid-turn. */
166
183
  allowInputDuringGeneration?: boolean;
184
+ /** When true, only transition to idle after the parsed transcript includes a final standard assistant message. */
185
+ requiresFinalAssistantBeforeIdle?: boolean;
186
+ /** When true, allow providers to augment stale snapshot data before parse. Reserved for future use. */
187
+ augmentStaleSnapshot?: boolean;
167
188
  /** When provider-owned, daemon treats provider parser output as canonical transcript authority. */
168
189
  transcriptAuthority?: 'provider' | 'daemon';
169
190
  /** Full context lets provider-owned parsers canonicalize retained history instead of daemon prefix stitching. */
@@ -74,6 +74,8 @@ export interface CommandRouterDeps {
74
74
  sessionHostControl?: SessionHostControlPlane | null;
75
75
  /** Selected-coordinator mesh peer telemetry surface for target daemons, when supported by the runtime. */
76
76
  getMeshPeerConnectionStatus?: (daemonId: string) => Record<string, unknown> | null;
77
+ /** Dispatch a command to a remote mesh node via P2P/relay. Injected by cloud runtime; absent in standalone. */
78
+ dispatchMeshCommand?: (daemonId: string, cmd: string, args: Record<string, unknown>) => Promise<unknown>;
77
79
  }
78
80
  export interface CommandRouterResult {
79
81
  success: boolean;
@@ -85,9 +87,22 @@ export declare class DaemonCommandRouter {
85
87
  * Allows the MCP server to query mesh data via get_mesh even when
86
88
  * the mesh doesn't exist in the local meshes.json file. */
87
89
  private inlineMeshCache;
90
+ /** Coordinator-owned whole-mesh aggregate status snapshots. Browser callers read this by default. */
91
+ private aggregateMeshStatusCache;
92
+ /** In-memory async Refinery jobs keyed by meshId:nodeId to reject/return duplicate in-flight requests. */
93
+ private runningRefineJobs;
94
+ /** Terminal async Refinery jobs preserve a clear answer after the worktree node has been removed. */
95
+ private terminalRefineJobs;
88
96
  constructor(deps: CommandRouterDeps);
97
+ private cloneJsonValue;
98
+ private hydrateCachedAggregateMeshStatusFromInline;
99
+ private getCachedAggregateMeshStatus;
100
+ private rememberAggregateMeshStatus;
89
101
  getCachedInlineMesh(meshId: string, inlineMesh?: unknown): any | undefined;
102
+ private warmInlineMeshCache;
90
103
  private getMeshForCommand;
104
+ private invalidateAggregateMeshStatus;
105
+ private requireMeshHostMutationOwner;
91
106
  private updateInlineMeshNode;
92
107
  private removeInlineMeshNode;
93
108
  private normalizeMeshSessionCleanupMode;
@@ -110,6 +125,13 @@ export declare class DaemonCommandRouter {
110
125
  * @param source Log source ('ws' | 'p2p' | 'standalone' | etc.)
111
126
  */
112
127
  execute(cmd: string, args: any, source?: string): Promise<CommandRouterResult>;
128
+ private buildRefineJobKey;
129
+ private buildRefineJobHandle;
130
+ private queueRefineJobEvent;
131
+ private appendRefineJobLedger;
132
+ private executeMeshRefineNodeSynchronously;
133
+ private finishMeshRefineJob;
134
+ private startMeshRefineJob;
113
135
  /**
114
136
  * Daemon-level command execution (IDE start/stop/restart, CLI, detect, logs).
115
137
  * Returns null if not handled at this level → caller delegates to CommandHandler.
@@ -110,12 +110,17 @@ export declare function readProviderChatHistory(agentType: string, options?: {
110
110
  excludeRecentCount?: number;
111
111
  historyBehavior?: ProviderHistoryBehavior;
112
112
  scripts?: ProviderNativeHistoryScripts;
113
+ excludeInProgressTurn?: boolean;
113
114
  }): {
114
115
  messages: HistoryMessage[];
115
116
  hasMore: boolean;
116
117
  source: 'provider-native' | 'adhdev-mirror' | 'native-unavailable';
117
118
  sourcePath?: string;
118
119
  sourceMtimeMs?: number;
120
+ providerSessionId?: string;
121
+ nativeHistoryCoverage?: string;
122
+ partialReason?: string;
123
+ unavailableReason?: string;
119
124
  };
120
125
  export declare function listProviderHistorySessions(agentType: string, options?: {
121
126
  canonicalHistory?: ProviderCanonicalHistoryConfig;
@@ -86,6 +86,11 @@ export declare function isStableMachineId(machineId?: string | null): boolean;
86
86
  * Get the config directory path
87
87
  */
88
88
  export declare function getConfigDir(): string;
89
+ /**
90
+ * Get the daemon runtime data directory (~/.adhdev/daemon/).
91
+ * Distinct from the user-config dir so runtime state can be cleared independently.
92
+ */
93
+ export declare function getDaemonDataDir(): string;
89
94
  /**
90
95
  * Load configuration from disk
91
96
  */
@@ -5,7 +5,7 @@
5
5
  * Cloud mode syncs these to D1 via server routes; standalone mode
6
6
  * uses this file as the single source of truth.
7
7
  */
8
- import type { LocalMeshEntry, LocalMeshNodeEntry, RepoMeshPolicy, RepoMeshNodePolicy, RepoMeshNodeCapabilities, RepoMeshCoordinatorConfig } from '../repo-mesh-types.js';
8
+ import type { LocalMeshEntry, LocalMeshNodeEntry, RepoMeshPolicy, RepoMeshNodePolicy, RepoMeshNodeCapabilities, RepoMeshCoordinatorConfig, RepoMeshHostMetadata, RepoMeshDaemonRole } from '../repo-mesh-types.js';
9
9
  /**
10
10
  * Normalize a Git remote URL into a stable identity string.
11
11
  * e.g. "git@github.com:user/repo.git" → "github.com/user/repo"
@@ -22,6 +22,7 @@ export interface CreateMeshOptions {
22
22
  defaultBranch?: string;
23
23
  policy?: Partial<RepoMeshPolicy>;
24
24
  coordinator?: RepoMeshCoordinatorConfig;
25
+ meshHost?: RepoMeshHostMetadata;
25
26
  }
26
27
  export declare function createMesh(opts: CreateMeshOptions): LocalMeshEntry;
27
28
  export interface UpdateMeshOptions {
@@ -29,9 +30,72 @@ export interface UpdateMeshOptions {
29
30
  defaultBranch?: string;
30
31
  policy?: Partial<RepoMeshPolicy>;
31
32
  coordinator?: RepoMeshCoordinatorConfig;
33
+ meshHost?: RepoMeshHostMetadata;
32
34
  }
33
35
  export declare function updateMesh(meshId: string, opts: UpdateMeshOptions): LocalMeshEntry | undefined;
34
36
  export declare function deleteMesh(meshId: string): boolean;
37
+ export declare function tokenIdForManualPairing(token: string): string;
38
+ export interface ConfigureMeshHostPairingOptions {
39
+ hostAddress: string;
40
+ token: string;
41
+ now?: string;
42
+ }
43
+ export declare function configureMeshHostPairing(meshId: string, opts: ConfigureMeshHostPairingOptions): {
44
+ mesh: LocalMeshEntry;
45
+ meshHost: RepoMeshHostMetadata;
46
+ hostAddress: string;
47
+ } | undefined;
48
+ export interface CreateMeshHostPairingTokenOptions {
49
+ token?: string;
50
+ expiresAt?: string;
51
+ now?: string;
52
+ }
53
+ export declare function createMeshHostPairingToken(meshId: string, opts?: CreateMeshHostPairingTokenOptions): {
54
+ mesh: LocalMeshEntry;
55
+ meshHost: RepoMeshHostMetadata;
56
+ token: string;
57
+ tokenId: string;
58
+ expiresAt?: string;
59
+ } | undefined;
60
+ export interface MeshHostJoinMemberNodeInput {
61
+ id?: string;
62
+ workspace: string;
63
+ repoRoot?: string;
64
+ daemonId?: string;
65
+ machineId?: string;
66
+ userOverrides?: Partial<RepoMeshNodeCapabilities>;
67
+ policy?: RepoMeshNodePolicy;
68
+ role?: RepoMeshDaemonRole;
69
+ }
70
+ export interface ApplyMeshHostJoinOptions {
71
+ token: string;
72
+ memberNode: MeshHostJoinMemberNodeInput;
73
+ memberMeshId?: string;
74
+ now?: string;
75
+ }
76
+ export declare function applyMeshHostJoinRequest(meshId: string, opts: ApplyMeshHostJoinOptions): {
77
+ accepted: true;
78
+ mesh: LocalMeshEntry;
79
+ meshHost: RepoMeshHostMetadata;
80
+ node: LocalMeshNodeEntry;
81
+ tokenId: string;
82
+ } | {
83
+ accepted: false;
84
+ mesh?: LocalMeshEntry;
85
+ meshHost?: RepoMeshHostMetadata;
86
+ tokenId?: string;
87
+ reason: string;
88
+ } | undefined;
89
+ export declare function markMeshHostPairingJoined(meshId: string, opts: {
90
+ hostDaemonId?: string;
91
+ hostNodeId?: string;
92
+ joinedAt?: string;
93
+ token?: string;
94
+ tokenId?: string;
95
+ }): {
96
+ mesh: LocalMeshEntry;
97
+ meshHost: RepoMeshHostMetadata;
98
+ } | undefined;
35
99
  export interface AddNodeOptions {
36
100
  workspace: string;
37
101
  repoRoot?: string;
@@ -42,10 +106,13 @@ export interface AddNodeOptions {
42
106
  isLocalWorktree?: boolean;
43
107
  worktreeBranch?: string;
44
108
  clonedFromNodeId?: string;
109
+ worktreeBootstrap?: LocalMeshNodeEntry['worktreeBootstrap'];
110
+ role?: RepoMeshDaemonRole;
45
111
  }
46
112
  export declare function addNode(meshId: string, opts: AddNodeOptions): LocalMeshNodeEntry | undefined;
47
113
  export declare function removeNode(meshId: string, nodeId: string): boolean;
48
114
  export declare function updateNode(meshId: string, nodeId: string, opts: {
49
115
  userOverrides?: Partial<RepoMeshNodeCapabilities>;
50
116
  policy?: RepoMeshNodePolicy;
117
+ worktreeBootstrap?: LocalMeshNodeEntry['worktreeBootstrap'];
51
118
  }): LocalMeshNodeEntry | undefined;
@@ -23,8 +23,12 @@ export interface GitLogResult extends GitRepoIdentity {
23
23
  lastCheckedAt: number;
24
24
  }
25
25
  export interface GitCheckpointResult extends GitRepoIdentity {
26
- commit: string;
26
+ commit?: string;
27
27
  message: string;
28
+ status?: 'created' | 'skipped';
29
+ skipped?: boolean;
30
+ noop?: boolean;
31
+ reason?: 'nothing_to_commit';
28
32
  lastCheckedAt: number;
29
33
  }
30
34
  export interface GitStashPushResult extends GitRepoIdentity {
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  export type { ChatBubbleState, ChatMessage, ExtensionInfo, CommandResult as CoreCommandResult, ProviderConfig, DaemonEvent, StatusResponse, SystemInfo, DetectedIde, ProviderInfo, AgentEntry, } from './types.js';
7
7
  export type { SessionEntry, CompactSessionEntry, CompactDaemonEntry, CloudDaemonSummaryEntry, DashboardBootstrapDaemonEntry, VersionUpdateReason, CloudStatusReportPayload, DaemonStatusEventPayload, DashboardStatusEventPayload, SessionTransport, SessionKind, SessionCapability, AgentSessionStream, ReadChatCursor, ReadChatSyncResult, TransportTopic, SessionChatTailSubscriptionParams, SessionRuntimeOutputSubscriptionParams, MachineRuntimeSubscriptionParams, SessionHostDiagnosticsSubscriptionParams, SessionModalSubscriptionParams, DaemonMetadataSubscriptionParams, WorkspaceGitSubscriptionParams, SessionChatTailUpdate, MachineRuntimeUpdate, SessionHostDiagnosticsUpdate, SessionModalUpdate, DaemonMetadataUpdate, TopicUpdateEnvelope, SubscribeRequest, UnsubscribeRequest, StandaloneWsStatusPayload, AvailableProviderInfo, AcpConfigOption, AcpMode, ProviderControlSchema, StatusReportPayload, MachineInfo, SessionHostDiagnosticsSnapshot, SessionHostRecord, SessionHostWriteOwner, SessionHostAttachedClient, SessionHostLogEntry, SessionHostRequestTrace, SessionHostRuntimeTransition, DetectedIdeInfo, WorkspaceEntry, ProviderSummaryItem, ProviderSummaryMetadata, ProviderState, ProviderStatus, ProviderErrorReason, SessionActiveChatData, ActiveChatData, IdeProviderState, CliProviderState, AcpProviderState, ExtensionProviderState, MessageInputSupport, InputMediaStrategyDescriptor, InputAttachmentStrategy, InputMediaType, } from './shared-types.js';
8
- export type { RepoMesh, RepoMeshNode, RepoMeshNodeHealth, RepoMeshPolicy, RepoMeshNodePolicy, RepoMeshRelatedRepo, RepoMeshNodeCapabilities, DetectedCommand, ProjectContextSnapshot, ProjectContextSource, RepoMeshCoordinatorConfig, LocalMeshConfig, LocalMeshEntry, LocalMeshNodeEntry, RepoMeshStatus, RepoMeshNodeStatus, RepoMeshSessionStatus, RepoMeshQueueTask, RepoMeshQueueTaskStatus, RepoMeshQueueSummary, RepoMeshQueueStatus, RepoMeshLedgerEntryStatus, RepoMeshLedgerSummaryStatus, RepoMeshLedgerStatus, } from './repo-mesh-types.js';
8
+ export type { RepoMesh, RepoMeshDaemonRole, RepoMeshHostMetadata, RepoMeshHostPairingMetadata, RepoMeshHostStatus, RepoMeshNode, RepoMeshNodeHealth, RepoMeshPolicy, RepoMeshNodePolicy, RepoMeshRelatedRepo, RepoMeshNodeCapabilities, DetectedCommand, ProjectContextSnapshot, ProjectContextSource, RepoMeshCoordinatorConfig, LocalMeshConfig, LocalMeshEntry, LocalMeshNodeEntry, RepoMeshStatus, RepoMeshNodeStatus, RepoMeshSessionStatus, RepoMeshQueueTask, RepoMeshQueueTaskStatus, RepoMeshQueueSummary, RepoMeshQueueStatus, RepoMeshLedgerEntryStatus, RepoMeshLedgerSummaryStatus, RepoMeshLedgerStatus, MeshAsyncJobLifecycle, } from './repo-mesh-types.js';
9
9
  export { DEFAULT_MESH_POLICY } from './repo-mesh-types.js';
10
10
  export * from './git/index.js';
11
11
  import type { RuntimeWriteOwner as _RuntimeWriteOwner } from './shared-types-extra.js';
@@ -20,7 +20,7 @@ export type { SessionHostEndpoint } from '@adhdev/session-host-core';
20
20
  export type SessionStatus = 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting' | 'panel_hidden' | 'not_monitored' | 'disconnected';
21
21
  export type RecentSessionBucket = 'needs_attention' | 'working' | 'task_complete' | 'idle';
22
22
  export type { IDaemonCore, DaemonCoreOptions } from './daemon-core.js';
23
- export { loadConfig, saveConfig, resetConfig, isSetupComplete, markSetupComplete, updateConfig } from './config/config.js';
23
+ export { loadConfig, saveConfig, resetConfig, isSetupComplete, markSetupComplete, updateConfig, getDaemonDataDir } from './config/config.js';
24
24
  export { getWorkspaceState } from './config/workspaces.js';
25
25
  export { appendRecentActivity, getRecentActivity } from './config/recent-activity.js';
26
26
  export type { RecentActivityEntry } from './config/recent-activity.js';
@@ -30,14 +30,26 @@ export { listMeshes, getMesh, getMeshByRepo, createMesh, updateMesh, deleteMesh,
30
30
  export type { CreateMeshOptions, UpdateMeshOptions, AddNodeOptions } from './config/mesh-config.js';
31
31
  export { buildCoordinatorSystemPrompt } from './mesh/coordinator-prompt.js';
32
32
  export type { CoordinatorPromptContext } from './mesh/coordinator-prompt.js';
33
+ export { loadMeshCoordinatorRegistry, registerMeshCoordinator, unregisterMeshCoordinator, getCoordinatorForSession, listCoordinatorsForWorkspace } from './mesh/coordinator-registry.js';
34
+ export type { CoordinatorRegistryEntry } from './mesh/coordinator-registry.js';
35
+ export { MESH_REFINE_CONFIG_LOCATIONS, MESH_REFINE_CONFIG_SCHEMA, loadMeshRefineConfig, resolveMeshRefineValidationPlan, suggestMeshRefineConfig, validateMeshRefineConfig, } from './mesh/refine-config.js';
36
+ export { MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS, MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA, loadMeshWorktreeBootstrapConfig, runMeshWorktreeBootstrap, validateMeshWorktreeBootstrapConfig, type RepoMeshWorktreeBootstrapConfig, type WorktreeBootstrapState, } from './mesh/worktree-bootstrap-config.js';
37
+ export type { MeshRefineValidationCategory, MeshRefineValidationCommandPlan, MeshRefineValidationPlan, RepoMeshRefineConfig, RepoMeshRefineValidationCommandConfig, } from './mesh/refine-config.js';
33
38
  export { syncMeshes } from './mesh/mesh-sync.js';
34
39
  export type { MeshSyncTransport, MeshSyncResult, RemoteMeshRecord } from './mesh/mesh-sync.js';
35
- export { appendLedgerEntry, appendRemoteLedgerEntries, readLedgerEntries, readLedgerSlice, getLedgerSummary, getLedgerDir, getSessionRecoveryContext, MAX_LEDGER_SLICE_LIMIT } from './mesh/mesh-ledger.js';
36
- export type { AppendRemoteLedgerResult, MeshLedgerEntry, MeshLedgerKind, MeshLedgerSlice, MeshLedgerSummary, ReadLedgerOptions, ReadLedgerSliceOptions, SessionRecoveryContext } from './mesh/mesh-ledger.js';
40
+ export { appendLedgerEntry, appendRemoteLedgerEntries, buildTaskCompletionEvidence, normalizeMeshWorkerResult, readLedgerEntries, readLedgerSlice, getLedgerSummary, getLedgerDir, getSessionRecoveryContext, MAX_LEDGER_SLICE_LIMIT } from './mesh/mesh-ledger.js';
41
+ export type { AppendRemoteLedgerResult, MeshLedgerEntry, MeshLedgerKind, MeshLedgerSlice, MeshLedgerSummary, ReadLedgerOptions, ReadLedgerSliceOptions, SessionRecoveryContext, MeshTaskCompletionEvidence, MeshWorkerResultArtifact, MeshProcessArtifact, MeshValidationResultArtifact } from './mesh/mesh-ledger.js';
42
+ export { fastForwardMeshNode } from './mesh/mesh-fast-forward.js';
43
+ export type { MeshFastForwardNodeArgs, MeshFastForwardPlannedStep, MeshFastForwardResult } from './mesh/mesh-fast-forward.js';
37
44
  export { buildMeshLedgerReconciliationEvidence, buildMeshLedgerReplicaEvidence } from './mesh/mesh-ledger-reconciliation.js';
38
45
  export type { MeshLedgerReconciliationEvidence, MeshLedgerReplicaEvidence, MeshLedgerReplicaStatus } from './mesh/mesh-ledger-reconciliation.js';
39
- export { enqueueTask, getQueue, claimNextTask, updateTaskStatus, updateSessionTaskStatus, cancelTask, requeueTask, getMeshQueueStats } from './mesh/mesh-work-queue.js';
40
- export type { MeshWorkQueueEntry, MeshTaskStatus, MeshWorkQueueStats } from './mesh/mesh-work-queue.js';
46
+ export { enqueueTask, getQueue, claimNextTask, updateTaskStatus, updateSessionTaskStatus, cancelTask, requeueTask, getMeshQueueStats, getMeshQueueRevision, normalizeMeshTaskMode, validateMeshTaskModeRequest, insertDirectDispatch, getActiveDirectDispatches, updateDirectDispatchStatus, cleanupTerminalDirectDispatches, markStaleDirectDispatches } from './mesh/mesh-work-queue.js';
47
+ export type { MeshWorkQueueEntry, MeshTaskStatus, MeshTaskMode, MeshWorkQueueStats, MeshQueueMutationOptions, MeshTaskModeValidationResult, DirectDispatchRecord } from './mesh/mesh-work-queue.js';
48
+ export { buildCompactStaleDirectWorkSummary, buildMeshActiveWork, buildMeshActiveWorkSummary } from './mesh/mesh-active-work.js';
49
+ export type { MeshActiveWorkRecord, MeshActiveWorkStatus, MeshActiveWorkSummary, MeshActiveWorkSource, MeshStaleDirectWorkSummary } from './mesh/mesh-active-work.js';
50
+ export { buildMeshAsyncRefineJobs } from './mesh/mesh-refine-status.js';
51
+ export type { MeshAsyncRefineJobStatus, MeshAsyncRefineJobSummary } from './mesh/mesh-refine-status.js';
52
+ export { buildMeshHostRequiredFailure, createDefaultMeshHostMetadata, isMeshHostOwner, normalizeMeshDaemonRole, requireMeshHostQueueOwner, resolveMeshHostStatus } from './mesh/mesh-host-ownership.js';
41
53
  export { triggerMeshQueue, drainPendingMeshCoordinatorEvents, getPendingMeshCoordinatorEvents, clearPendingMeshCoordinatorEvents, queuePendingMeshCoordinatorEvent } from './mesh/mesh-events.js';
42
54
  export type { PendingMeshCoordinatorEvent } from './mesh/mesh-events.js';
43
55
  export { P2pRelayFailureError, buildP2pRelayFailurePayload, classifyP2pRelayFailure, isP2pRelayTransportFailure, } from './mesh/p2p-relay-failure.js';