@adhdev/daemon-core 0.9.82-rc.15 → 0.9.82-rc.151

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 (182) hide show
  1. package/dist/boot/process-hardening.d.ts +50 -0
  2. package/dist/chat/source-machine.d.ts +166 -0
  3. package/dist/chat/source-resolver.d.ts +104 -0
  4. package/dist/chat/subscription-updates.d.ts +1 -0
  5. package/dist/cli-adapter-types.d.ts +5 -1
  6. package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
  7. package/dist/cli-adapters/cli-state-engine.d.ts +178 -0
  8. package/dist/cli-adapters/provider-cli-adapter.d.ts +104 -63
  9. package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
  10. package/dist/cli-adapters/provider-cli-shared.d.ts +27 -0
  11. package/dist/commands/handler.d.ts +66 -0
  12. package/dist/commands/router.d.ts +22 -0
  13. package/dist/config/chat-history.d.ts +5 -0
  14. package/dist/config/config.d.ts +5 -0
  15. package/dist/config/mesh-config.d.ts +68 -1
  16. package/dist/git/git-commands.d.ts +5 -1
  17. package/dist/index.d.ts +20 -6
  18. package/dist/index.js +13153 -3031
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.mjs +13099 -3023
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/installer.d.ts +1 -4
  23. package/dist/ipc/local-ipc-server.d.ts +91 -0
  24. package/dist/launch.d.ts +1 -1
  25. package/dist/logging/async-batch-writer.d.ts +10 -0
  26. package/dist/mesh/beads-db.d.ts +72 -0
  27. package/dist/mesh/contracts.d.ts +164 -0
  28. package/dist/mesh/coordinator-registry.d.ts +25 -0
  29. package/dist/mesh/mesh-active-work.d.ts +90 -0
  30. package/dist/mesh/mesh-events.d.ts +77 -5
  31. package/dist/mesh/mesh-fast-forward.d.ts +39 -0
  32. package/dist/mesh/mesh-host-ownership.d.ts +9 -0
  33. package/dist/mesh/mesh-ledger.d.ts +58 -1
  34. package/dist/mesh/mesh-refine-status.d.ts +26 -0
  35. package/dist/mesh/mesh-work-queue.d.ts +44 -5
  36. package/dist/mesh/preview-freshness.d.ts +18 -0
  37. package/dist/mesh/refine-config.d.ts +193 -0
  38. package/dist/mesh/worktree-bootstrap-config.d.ts +113 -0
  39. package/dist/providers/approval-utils.d.ts +9 -0
  40. package/dist/providers/cli-provider-instance.d.ts +6 -1
  41. package/dist/providers/contracts.d.ts +50 -5
  42. package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
  43. package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
  44. package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
  45. package/dist/providers/native-history/index.d.ts +11 -0
  46. package/dist/providers/provider-loader.d.ts +19 -1
  47. package/dist/providers/read-chat-contract.d.ts +29 -0
  48. package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
  49. package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +85 -0
  50. package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
  51. package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +64 -0
  52. package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
  53. package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
  54. package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
  55. package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
  56. package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
  57. package/dist/providers/sdk/v1/index.d.ts +30 -0
  58. package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
  59. package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
  60. package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
  61. package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
  62. package/dist/providers/sdk/v1/types/common/index.d.ts +169 -0
  63. package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
  64. package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
  65. package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
  66. package/dist/providers/transcript-v2.d.ts +176 -0
  67. package/dist/repo-mesh-types.d.ts +67 -0
  68. package/dist/shared-types.d.ts +12 -0
  69. package/dist/status/reporter.d.ts +2 -0
  70. package/dist/status/snapshot.d.ts +1 -0
  71. package/dist/types.d.ts +5 -0
  72. package/package.json +6 -2
  73. package/src/boot/daemon-lifecycle.ts +17 -10
  74. package/src/boot/process-hardening.ts +89 -0
  75. package/src/chat/source-machine.ts +534 -0
  76. package/src/chat/source-resolver.ts +0 -0
  77. package/src/chat/subscription-updates.ts +14 -1
  78. package/src/cli-adapter-types.d.ts +1 -0
  79. package/src/cli-adapter-types.ts +3 -1
  80. package/src/cli-adapters/cli-script-runner.ts +421 -0
  81. package/src/cli-adapters/cli-state-engine.ts +1086 -0
  82. package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
  83. package/src/cli-adapters/provider-cli-adapter.ts +664 -1137
  84. package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
  85. package/src/cli-adapters/provider-cli-parse.ts +13 -0
  86. package/src/cli-adapters/provider-cli-runtime.ts +3 -1
  87. package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
  88. package/src/cli-adapters/provider-cli-shared.ts +57 -11
  89. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +17 -1
  90. package/src/cli-adapters/terminal-backends/xterm-backend.ts +8 -1
  91. package/src/commands/chat-commands.ts +1451 -52
  92. package/src/commands/cli-manager.ts +184 -3
  93. package/src/commands/handler.ts +547 -2
  94. package/src/commands/mesh-coordinator.ts +13 -143
  95. package/src/commands/router.ts +3273 -428
  96. package/src/config/chat-history.ts +79 -24
  97. package/src/config/config.ts +12 -0
  98. package/src/config/mesh-config.ts +249 -2
  99. package/src/config/recent-activity.ts +8 -2
  100. package/src/daemon/dev-cli-debug.ts +10 -1
  101. package/src/detection/ide-detector.ts +26 -16
  102. package/src/git/git-commands.ts +17 -5
  103. package/src/git/git-worktree.ts +8 -1
  104. package/src/index.ts +72 -5
  105. package/src/installer.d.ts +1 -1
  106. package/src/installer.ts +8 -6
  107. package/src/ipc/local-ipc-server.ts +278 -0
  108. package/src/launch.d.ts +1 -1
  109. package/src/launch.ts +37 -28
  110. package/src/logging/async-batch-writer.ts +55 -0
  111. package/src/logging/logger.ts +2 -1
  112. package/src/mesh/beads-db.ts +479 -0
  113. package/src/mesh/contracts.ts +329 -0
  114. package/src/mesh/coordinator-prompt.ts +40 -22
  115. package/src/mesh/coordinator-registry.ts +75 -0
  116. package/src/mesh/mesh-active-work.ts +437 -0
  117. package/src/mesh/mesh-events.ts +820 -61
  118. package/src/mesh/mesh-fast-forward.ts +430 -0
  119. package/src/mesh/mesh-host-ownership.ts +73 -0
  120. package/src/mesh/mesh-ledger.ts +457 -104
  121. package/src/mesh/mesh-refine-status.ts +144 -0
  122. package/src/mesh/mesh-work-queue.ts +216 -158
  123. package/src/mesh/preview-freshness.ts +118 -0
  124. package/src/mesh/refine-config.ts +366 -0
  125. package/src/mesh/worktree-bootstrap-config.ts +247 -0
  126. package/src/providers/approval-utils.ts +39 -5
  127. package/src/providers/chat-message-normalization.ts +4 -11
  128. package/src/providers/cli-provider-instance.ts +380 -44
  129. package/src/providers/contracts.ts +52 -5
  130. package/src/providers/ide-provider-instance.ts +17 -3
  131. package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
  132. package/src/providers/native-history/claude-cli-transcript.ts +396 -0
  133. package/src/providers/native-history/codex-cli-transcript.ts +419 -0
  134. package/src/providers/native-history/index.ts +23 -0
  135. package/src/providers/provider-loader.ts +294 -28
  136. package/src/providers/provider-schema.ts +31 -13
  137. package/src/providers/read-chat-contract.ts +76 -16
  138. package/src/providers/sdk/README.md +49 -0
  139. package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
  140. package/src/providers/sdk/v1/builders/cli/detect-status.ts +262 -0
  141. package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
  142. package/src/providers/sdk/v1/builders/cli/parse-approval.ts +245 -0
  143. package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
  144. package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
  145. package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
  146. package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
  147. package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
  148. package/src/providers/sdk/v1/index.ts +152 -0
  149. package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
  150. package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
  151. package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
  152. package/src/providers/sdk/v1/schemas/cli/provider.schema.json +444 -0
  153. package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
  154. package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
  155. package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
  156. package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
  157. package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
  158. package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
  159. package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
  160. package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
  161. package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +119 -0
  162. package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
  163. package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
  164. package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
  165. package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
  166. package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
  167. package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
  168. package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
  169. package/src/providers/sdk/v1/types/cli/index.ts +365 -0
  170. package/src/providers/sdk/v1/types/common/index.ts +210 -0
  171. package/src/providers/sdk/v1/validators/index.ts +19 -0
  172. package/src/providers/sdk/v1/validators/manifest.ts +110 -0
  173. package/src/providers/sdk/v1/validators/taint.ts +309 -0
  174. package/src/providers/transcript-v2.ts +567 -0
  175. package/src/providers/version-archive.ts +38 -20
  176. package/src/repo-mesh-types.ts +77 -0
  177. package/src/shared-types.ts +9 -0
  178. package/src/status/builders.ts +23 -6
  179. package/src/status/reporter.ts +15 -0
  180. package/src/status/snapshot.ts +35 -11
  181. package/src/system/host-memory.ts +29 -12
  182. package/src/types.ts +5 -0
@@ -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' | 'p2p_dispatch_failed' | '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,27 @@ export interface AppendRemoteLedgerResult {
115
151
  }
116
152
  export declare const MAX_LEDGER_SLICE_LIMIT = 500;
117
153
  export declare function getLedgerDir(): string;
154
+ /**
155
+ * Footer to append to worker task messages so workers output structured results
156
+ * that the daemon parses via extractJsonObjectFromSummary / normalizeMeshWorkerResult.
157
+ *
158
+ * Usage: append buildWorkerTaskFooter() to the task message in mesh_send_task /
159
+ * mesh_enqueue_task. The coordinator prompt rules instruct coordinators to do this.
160
+ */
161
+ export declare function buildWorkerTaskFooter(): string;
162
+ /**
163
+ * Compact the active ledger file for a mesh by moving old terminal entries
164
+ * (task_completed, task_failed, task_stalled, recovery_attempted older than 7 days)
165
+ * to <meshId>.archive.jsonl, keeping the active file lean.
166
+ *
167
+ * Non-terminal entries (dispatch, sessions, node lifecycle) are always retained.
168
+ * Called automatically from appendLedgerEntry when the file exceeds COMPACT_THRESHOLD_BYTES.
169
+ */
170
+ export declare function compactLedger(meshId: string): {
171
+ archivedCount: number;
172
+ retainedCount: number;
173
+ };
174
+ export declare function normalizeMeshWorkerResult(input?: Record<string, unknown>, source?: MeshWorkerResultArtifact['source']): MeshWorkerResultArtifact;
118
175
  export declare function buildTaskCompletionEvidence(opts: BuildTaskCompletionEvidenceOptions): MeshTaskCompletionEvidence;
119
176
  /**
120
177
  * Append a new entry to the mesh ledger.
@@ -0,0 +1,26 @@
1
+ import type { MeshLedgerEntry } from './mesh-ledger.js';
2
+ import type { PendingMeshCoordinatorEvent } from './mesh-events.js';
3
+ import type { MeshAsyncJobLifecycle } from '../repo-mesh-types.js';
4
+ export type MeshAsyncRefineJobStatus = 'accepted' | 'running' | 'completed' | 'failed';
5
+ export interface MeshAsyncRefineJobSummary extends MeshAsyncJobLifecycle {
6
+ jobId: string;
7
+ interactionId?: string;
8
+ status: MeshAsyncRefineJobStatus;
9
+ meshId?: string;
10
+ nodeId?: string;
11
+ targetNodeId?: string;
12
+ targetDaemonId?: string;
13
+ workspace?: string;
14
+ branch?: string;
15
+ into?: string;
16
+ retryOfJobId?: string;
17
+ lastEvent?: string;
18
+ lastLedgerKind?: string;
19
+ lastUpdatedAt?: string;
20
+ instruction: string;
21
+ }
22
+ export declare function buildMeshAsyncRefineJobs(args: {
23
+ meshId?: string;
24
+ ledgerEntries?: MeshLedgerEntry[];
25
+ pendingEvents?: PendingMeshCoordinatorEvent[];
26
+ }): MeshAsyncRefineJobSummary[];
@@ -1,13 +1,26 @@
1
+ import type { RepoMeshDaemonRole } from '../repo-mesh-types.js';
2
+ import { BeadsDB } from './beads-db.js';
1
3
  export type MeshTaskStatus = 'pending' | 'assigned' | 'completed' | 'failed' | 'cancelled';
2
4
  export type MeshActiveTaskStatus = Extract<MeshTaskStatus, 'pending' | 'assigned'>;
3
5
  export type MeshHistoricalTaskStatus = Extract<MeshTaskStatus, 'completed' | 'failed' | 'cancelled'>;
6
+ export type MeshTaskMode = 'code_change' | 'validation' | 'live_debug_readonly' | 'launch_app' | 'convergence';
4
7
  export declare const ACTIVE_MESH_QUEUE_STATUSES: MeshActiveTaskStatus[];
5
8
  export declare const HISTORICAL_MESH_QUEUE_STATUSES: MeshHistoricalTaskStatus[];
9
+ export declare const MESH_TASK_MODES: MeshTaskMode[];
10
+ export interface MeshTaskModeValidationResult {
11
+ valid: boolean;
12
+ taskMode?: MeshTaskMode;
13
+ violations: string[];
14
+ allowedOperations?: string[];
15
+ }
16
+ export declare function normalizeMeshTaskMode(value: unknown): MeshTaskMode | undefined;
17
+ export declare function validateMeshTaskModeRequest(mode: unknown, message: string): MeshTaskModeValidationResult;
6
18
  export interface MeshWorkQueueEntry {
7
19
  id: string;
8
20
  meshId: string;
9
21
  message: string;
10
22
  status: MeshTaskStatus;
23
+ taskMode?: MeshTaskMode;
11
24
  /** If specified, only this node can claim the task (used by legacy mesh_send_task) */
12
25
  targetNodeId?: string;
13
26
  /** If specified, only this runtime session can claim the task */
@@ -37,19 +50,24 @@ export interface MeshWorkQueueEntry {
37
50
  createdAt: string;
38
51
  updatedAt: string;
39
52
  }
53
+ export interface MeshQueueMutationOptions {
54
+ ownerRole?: RepoMeshDaemonRole;
55
+ }
40
56
  /**
41
57
  * Add a new task to the mesh queue.
42
58
  */
43
59
  export declare function enqueueTask(meshId: string, message: string, opts?: {
44
60
  targetNodeId?: string;
45
61
  targetSessionId?: string;
46
- }): MeshWorkQueueEntry;
62
+ taskMode?: MeshTaskMode | string;
63
+ } & MeshQueueMutationOptions): MeshWorkQueueEntry;
47
64
  /**
48
65
  * Get all tasks in the queue, optionally filtered by status.
49
66
  */
50
67
  export declare function getQueue(meshId: string, opts?: {
51
68
  status?: MeshTaskStatus[];
52
69
  }): MeshWorkQueueEntry[];
70
+ export declare function getMeshQueueRevision(meshId: string): string;
53
71
  /**
54
72
  * Find the next pending task that this node is allowed to claim, and mark it as assigned.
55
73
  */
@@ -58,14 +76,14 @@ export declare function claimNextTask(meshId: string, nodeId: string, sessionId:
58
76
  * Update the status of a specific task.
59
77
  * Used when a session completes, fails, or stalls.
60
78
  */
61
- export declare function updateTaskStatus(meshId: string, taskId: string, status: MeshTaskStatus): MeshWorkQueueEntry | null;
79
+ export declare function updateTaskStatus(meshId: string, taskId: string, status: MeshTaskStatus, opts?: MeshQueueMutationOptions): MeshWorkQueueEntry | null;
62
80
  export declare function recordTaskAutoLaunch(meshId: string, taskId: string, autoLaunch: Omit<NonNullable<MeshWorkQueueEntry['autoLaunch']>, 'updatedAt'>): MeshWorkQueueEntry | null;
63
81
  /**
64
82
  * Mark a queue task as manually cancelled without deleting audit history.
65
83
  */
66
84
  export declare function cancelTask(meshId: string, taskId: string, opts?: {
67
85
  reason?: string;
68
- }): MeshWorkQueueEntry | null;
86
+ } & MeshQueueMutationOptions): MeshWorkQueueEntry | null;
69
87
  /**
70
88
  * Return a queue task to pending for retry. By default, dead session targeting
71
89
  * and assigned ownership are cleared so stale assignments do not strand again.
@@ -76,11 +94,13 @@ export declare function requeueTask(meshId: string, taskId: string, opts?: {
76
94
  targetSessionId?: string;
77
95
  clearTargetNode?: boolean;
78
96
  clearTargetSession?: boolean;
79
- }): MeshWorkQueueEntry | null;
97
+ } & MeshQueueMutationOptions): MeshWorkQueueEntry | null;
80
98
  /**
81
99
  * Update the status of the task currently assigned to a specific session.
82
100
  */
83
- export declare function updateSessionTaskStatus(meshId: string, sessionId: string, status: MeshTaskStatus): MeshWorkQueueEntry | null;
101
+ export declare function updateSessionTaskStatus(meshId: string, sessionId: string, status: MeshTaskStatus, opts?: {
102
+ occurredAt?: string;
103
+ }): MeshWorkQueueEntry | null;
84
104
  export interface MeshWorkQueueStats {
85
105
  total: number;
86
106
  active: number;
@@ -105,3 +125,22 @@ export interface MeshWorkQueueStats {
105
125
  * Return aggregate queue statistics for the given mesh.
106
126
  */
107
127
  export declare function getMeshQueueStats(meshId: string): MeshWorkQueueStats;
128
+ export declare function __replaceMeshQueueForTests(meshId: string, queue: MeshWorkQueueEntry[]): void;
129
+ export declare function __clearMeshQueueForTests(meshId: string): void;
130
+ export declare function __resetBeadsDBForTests(): void;
131
+ export type DirectDispatchRecord = ReturnType<BeadsDB['getActiveDirectDispatches']>[number];
132
+ export declare function insertDirectDispatch(meshId: string, data: {
133
+ taskId: string;
134
+ nodeId?: string;
135
+ sessionId?: string;
136
+ providerType?: string;
137
+ message: string;
138
+ taskMode?: string;
139
+ via: string;
140
+ dispatchedToIdleSession?: boolean;
141
+ dispatchedAt: string;
142
+ }): void;
143
+ export declare function getActiveDirectDispatches(meshId: string): DirectDispatchRecord[];
144
+ export declare function updateDirectDispatchStatus(meshId: string, sessionId: string, status: 'acked' | 'completed' | 'failed' | 'stale'): void;
145
+ export declare function cleanupTerminalDirectDispatches(olderThanMs?: number): void;
146
+ export declare function markStaleDirectDispatches(meshId: string, olderThanMs?: number): void;
@@ -0,0 +1,18 @@
1
+ export type PreviewFreshnessStatus = 'fresh' | 'stale' | 'unknown' | 'not_configured';
2
+ export interface PreviewFreshness {
3
+ status: PreviewFreshnessStatus;
4
+ lastPreviewCommit: string | null;
5
+ currentMainCommit: string | null;
6
+ currentMainCommitSource: 'origin/main' | 'HEAD' | 'unknown';
7
+ recordPath: string;
8
+ lastDeployedAt?: string;
9
+ lastTarget?: string;
10
+ previewVersion?: string;
11
+ targets: Record<'npm' | 'server' | 'web', {
12
+ commit: string | null;
13
+ deployedAt?: string;
14
+ status: PreviewFreshnessStatus;
15
+ }>;
16
+ nextAction: string;
17
+ }
18
+ export declare function buildPreviewFreshness(repoRoot: string): PreviewFreshness;
@@ -0,0 +1,193 @@
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
+ outputLimitBytes?: number;
12
+ env?: Record<string, string>;
13
+ }
14
+ export interface RepoMeshRefineConfig {
15
+ version: 1;
16
+ /**
17
+ * Narrow Refinery opt-in for monorepos with submodule gitlinks.
18
+ * When true, Refinery may non-force publish unreachable submodule gitlink
19
+ * commits to the submodule remote main branch after validation and
20
+ * patch-equivalence pass, then verify remote-main reachability.
21
+ */
22
+ allowAutoPublishSubmoduleMainCommits?: boolean;
23
+ validation?: {
24
+ required?: boolean;
25
+ /**
26
+ * Optional dependency/bootstrap commands that Refinery runs before
27
+ * validation commands. Refinery never infers installs on its own.
28
+ */
29
+ bootstrapCommands?: RepoMeshRefineValidationCommandConfig[];
30
+ commands?: RepoMeshRefineValidationCommandConfig[];
31
+ };
32
+ }
33
+ export interface MeshRefineValidationCommandPlan {
34
+ command: string;
35
+ args: string[];
36
+ displayCommand: string;
37
+ category: MeshRefineValidationCategory | 'custom';
38
+ source: string;
39
+ cwd?: string;
40
+ timeoutMs?: number;
41
+ outputLimitBytes?: number;
42
+ env?: Record<string, string>;
43
+ }
44
+ export interface MeshRefineConfigLoadResult {
45
+ config?: RepoMeshRefineConfig;
46
+ source: string;
47
+ sourceType: 'mesh_policy' | 'repo_file' | 'unavailable' | 'invalid';
48
+ path?: string;
49
+ error?: string;
50
+ }
51
+ export interface MeshRefineValidationPlan {
52
+ source: string;
53
+ sourceType: MeshRefineConfigLoadResult['sourceType'];
54
+ bootstrapCommands: MeshRefineValidationCommandPlan[];
55
+ commands: MeshRefineValidationCommandPlan[];
56
+ rejectedCommands: Array<Record<string, unknown>>;
57
+ suggestions: RepoMeshRefineValidationCommandConfig[];
58
+ suggestedConfig?: RepoMeshRefineConfig;
59
+ unavailableReason?: string;
60
+ }
61
+ export declare const MESH_REFINE_CONFIG_LOCATIONS: string[];
62
+ export declare const MESH_REFINE_CONFIG_SCHEMA: {
63
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
64
+ readonly title: "ADHDev Repo Mesh Refinery Config";
65
+ readonly type: "object";
66
+ readonly additionalProperties: false;
67
+ readonly required: readonly ["version"];
68
+ readonly properties: {
69
+ readonly version: {
70
+ readonly const: 1;
71
+ };
72
+ readonly allowAutoPublishSubmoduleMainCommits: {
73
+ readonly type: "boolean";
74
+ readonly default: false;
75
+ readonly description: "When true, Refinery may non-force publish submodule gitlink commits referenced by the refined root tree to each submodule origin/main after validation and patch-equivalence pass, then verify reachability.";
76
+ };
77
+ readonly validation: {
78
+ readonly type: "object";
79
+ readonly additionalProperties: false;
80
+ readonly properties: {
81
+ readonly required: {
82
+ readonly type: "boolean";
83
+ readonly default: true;
84
+ };
85
+ readonly commands: {
86
+ readonly type: "array";
87
+ readonly minItems: 1;
88
+ readonly maxItems: 8;
89
+ readonly items: {
90
+ readonly type: "object";
91
+ readonly additionalProperties: false;
92
+ readonly required: readonly ["command"];
93
+ readonly properties: {
94
+ readonly command: {
95
+ readonly type: "string";
96
+ readonly minLength: 1;
97
+ };
98
+ readonly args: {
99
+ readonly type: "array";
100
+ readonly items: {
101
+ readonly type: "string";
102
+ };
103
+ };
104
+ readonly category: {
105
+ readonly enum: readonly ["typecheck", "test", "lint", "build", "custom"];
106
+ };
107
+ readonly cwd: {
108
+ readonly type: "string";
109
+ };
110
+ readonly timeoutMs: {
111
+ readonly type: "number";
112
+ readonly minimum: 1000;
113
+ readonly maximum: 600000;
114
+ };
115
+ readonly outputLimitBytes: {
116
+ readonly type: "number";
117
+ readonly minimum: 1024;
118
+ readonly maximum: 1048576;
119
+ };
120
+ readonly env: {
121
+ readonly type: "object";
122
+ readonly additionalProperties: {
123
+ readonly type: "string";
124
+ };
125
+ };
126
+ };
127
+ };
128
+ };
129
+ readonly bootstrapCommands: {
130
+ readonly type: "array";
131
+ readonly maxItems: 4;
132
+ readonly items: {
133
+ readonly type: "object";
134
+ readonly additionalProperties: false;
135
+ readonly required: readonly ["command"];
136
+ readonly properties: {
137
+ readonly command: {
138
+ readonly type: "string";
139
+ readonly minLength: 1;
140
+ };
141
+ readonly args: {
142
+ readonly type: "array";
143
+ readonly items: {
144
+ readonly type: "string";
145
+ };
146
+ };
147
+ readonly category: {
148
+ readonly enum: readonly ["typecheck", "test", "lint", "build", "custom"];
149
+ };
150
+ readonly cwd: {
151
+ readonly type: "string";
152
+ };
153
+ readonly timeoutMs: {
154
+ readonly type: "number";
155
+ readonly minimum: 1000;
156
+ readonly maximum: 600000;
157
+ };
158
+ readonly outputLimitBytes: {
159
+ readonly type: "number";
160
+ readonly minimum: 1024;
161
+ readonly maximum: 1048576;
162
+ };
163
+ readonly env: {
164
+ readonly type: "object";
165
+ readonly additionalProperties: {
166
+ readonly type: "string";
167
+ };
168
+ };
169
+ };
170
+ };
171
+ };
172
+ };
173
+ };
174
+ };
175
+ };
176
+ export declare function isMeshConfigRecord(value: unknown): value is Record<string, unknown>;
177
+ export declare function normalizeMeshCommandConfig(entry: unknown, source: string): {
178
+ command?: MeshRefineValidationCommandPlan;
179
+ rejected?: Record<string, unknown>;
180
+ };
181
+ export declare function validateMeshRefineConfig(config: unknown, source?: string): {
182
+ valid: boolean;
183
+ errors: string[];
184
+ bootstrapCommands: MeshRefineValidationCommandPlan[];
185
+ commands: MeshRefineValidationCommandPlan[];
186
+ rejectedCommands: Array<Record<string, unknown>>;
187
+ };
188
+ export declare function loadMeshRefineConfig(mesh: any, workspace: string): MeshRefineConfigLoadResult;
189
+ export declare function suggestMeshRefineConfig(mesh: any, workspace: string): {
190
+ suggestions: RepoMeshRefineValidationCommandConfig[];
191
+ suggestedConfig?: RepoMeshRefineConfig;
192
+ };
193
+ export declare function resolveMeshRefineValidationPlan(mesh: any, workspace: string): MeshRefineValidationPlan;
@@ -0,0 +1,113 @@
1
+ import { type MeshRefineValidationCommandPlan, type RepoMeshRefineValidationCommandConfig } from './refine-config.js';
2
+ import type { MeshAsyncJobLifecycle } from '../repo-mesh-types.js';
3
+ export type WorktreeBootstrapStatus = 'ready' | 'running' | 'failed' | 'not_configured' | 'disabled' | 'stale';
4
+ export interface RepoMeshWorktreeBootstrapConfig {
5
+ version: 1;
6
+ enabled?: boolean;
7
+ runOnClone?: boolean;
8
+ required?: boolean;
9
+ commands?: RepoMeshRefineValidationCommandConfig[];
10
+ staleInputs?: string[];
11
+ }
12
+ export interface WorktreeBootstrapState extends MeshAsyncJobLifecycle {
13
+ status: WorktreeBootstrapStatus;
14
+ required: boolean;
15
+ configSource?: string;
16
+ configSourceType?: 'repo_file' | 'mesh_policy' | 'unavailable' | 'invalid';
17
+ lastCommand?: string;
18
+ exitCode?: number | null;
19
+ commandsRun?: Array<Record<string, unknown>>;
20
+ staleInputs?: string[];
21
+ }
22
+ export interface WorktreeBootstrapConfigLoadResult {
23
+ config?: RepoMeshWorktreeBootstrapConfig;
24
+ source: string;
25
+ sourceType: 'repo_file' | 'mesh_policy' | 'unavailable' | 'invalid';
26
+ path?: string;
27
+ error?: string;
28
+ }
29
+ export declare const MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS: string[];
30
+ export declare const MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA: {
31
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
32
+ readonly title: "ADHDev Repo Mesh Worktree Bootstrap Config";
33
+ readonly type: "object";
34
+ readonly additionalProperties: false;
35
+ readonly required: readonly ["version"];
36
+ readonly properties: {
37
+ readonly version: {
38
+ readonly const: 1;
39
+ };
40
+ readonly enabled: {
41
+ readonly type: "boolean";
42
+ readonly default: true;
43
+ };
44
+ readonly runOnClone: {
45
+ readonly type: "boolean";
46
+ readonly default: true;
47
+ };
48
+ readonly required: {
49
+ readonly type: "boolean";
50
+ readonly default: true;
51
+ };
52
+ readonly staleInputs: {
53
+ readonly type: "array";
54
+ readonly maxItems: 16;
55
+ readonly items: {
56
+ readonly type: "string";
57
+ readonly minLength: 1;
58
+ };
59
+ };
60
+ readonly commands: {
61
+ readonly type: "array";
62
+ readonly minItems: 1;
63
+ readonly maxItems: 4;
64
+ readonly items: {
65
+ readonly type: "object";
66
+ readonly additionalProperties: false;
67
+ readonly required: readonly ["command"];
68
+ readonly properties: {
69
+ readonly command: {
70
+ readonly type: "string";
71
+ readonly minLength: 1;
72
+ };
73
+ readonly args: {
74
+ readonly type: "array";
75
+ readonly items: {
76
+ readonly type: "string";
77
+ };
78
+ };
79
+ readonly category: {
80
+ readonly enum: readonly ["typecheck", "test", "lint", "build", "custom"];
81
+ };
82
+ readonly cwd: {
83
+ readonly type: "string";
84
+ };
85
+ readonly timeoutMs: {
86
+ readonly type: "number";
87
+ readonly minimum: 1000;
88
+ readonly maximum: 600000;
89
+ };
90
+ readonly outputLimitBytes: {
91
+ readonly type: "number";
92
+ readonly minimum: 1024;
93
+ readonly maximum: 1048576;
94
+ };
95
+ readonly env: {
96
+ readonly type: "object";
97
+ readonly additionalProperties: {
98
+ readonly type: "string";
99
+ };
100
+ };
101
+ };
102
+ };
103
+ };
104
+ };
105
+ };
106
+ export declare function validateMeshWorktreeBootstrapConfig(config: unknown, source?: string): {
107
+ valid: boolean;
108
+ errors: string[];
109
+ commands: MeshRefineValidationCommandPlan[];
110
+ rejectedCommands: Array<Record<string, unknown>>;
111
+ };
112
+ export declare function loadMeshWorktreeBootstrapConfig(mesh: any, workspace: string): WorktreeBootstrapConfigLoadResult;
113
+ export declare function runMeshWorktreeBootstrap(mesh: any, workspace: string): Promise<WorktreeBootstrapState>;
@@ -5,3 +5,12 @@ export declare function pickApprovalButton(buttons: string[] | null | undefined,
5
5
  label: string;
6
6
  };
7
7
  export declare function formatAutoApprovalMessage(modalMessage?: string, buttonLabel?: string): string;
8
+ /**
9
+ * Returns true when the given text (e.g. last assistant message content, or
10
+ * the tail of the PTY screen) looks like an active approval/input prompt
11
+ * rather than a completed assistant response. Used to prevent false
12
+ * idle/completion events when Claude Code surfaces a "Do you want to proceed?"
13
+ * style prompt that the PTY parser captures as an assistant turn while the
14
+ * session is still awaiting user input.
15
+ */
16
+ export declare function looksLikeActiveApprovalPromptText(content: string): boolean;
@@ -48,6 +48,7 @@ export declare class CliProviderInstance implements ProviderInstance {
48
48
  private lastApprovalEventAt;
49
49
  private autoApproveBusy;
50
50
  private autoApproveBusyTimer;
51
+ private lastAutoApprovalSignature;
51
52
  private controlValues;
52
53
  private summaryMetadata;
53
54
  private appliedEffectKeys;
@@ -96,14 +97,16 @@ export declare class CliProviderInstance implements ProviderInstance {
96
97
  getSessionModalState(): SessionModalState;
97
98
  updateSettings(newSettings: Record<string, any>): void;
98
99
  onEvent(event: string, data?: any): void;
100
+ recordAcknowledgedUserInput(input: InputEnvelope | string): void;
99
101
  dispose(): void;
100
102
  private completedDebounceTimer;
101
103
  private completedDebouncePending;
102
104
  private enforceFreshSessionLaunchIfNeeded;
103
105
  private completionHasFinalAssistantMessage;
106
+ private buildCompletedFinalizationDiagnostic;
104
107
  private hasAdapterPendingResponse;
105
108
  private shouldSuppressStaleParsedBusyStatus;
106
- private getCompletedFinalizationBlockReason;
109
+ private getCompletedFinalizationBlock;
107
110
  private scheduleCompletedDebounceFlush;
108
111
  private flushCompletedDebounceIfFinalized;
109
112
  private maybeAutoApproveStatus;
@@ -127,6 +130,8 @@ export declare class CliProviderInstance implements ProviderInstance {
127
130
  private mergeConversationMessages;
128
131
  private formatApprovalRequestMessage;
129
132
  private promoteProviderSessionId;
133
+ private shouldHydrateExistingProviderHistory;
134
+ private shouldSuppressFreshLaunchStartupReplay;
130
135
  private syncCanonicalSavedHistoryIfNeeded;
131
136
  private restorePersistedHistoryFromCurrentSession;
132
137
  private getProbeDirectories;