macro-agent 0.1.7 → 0.1.10

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 (259) hide show
  1. package/CLAUDE.md +179 -38
  2. package/README.md +781 -131
  3. package/dist/acp/claude-code-replay.d.ts +11 -0
  4. package/dist/acp/claude-code-replay.d.ts.map +1 -0
  5. package/dist/acp/claude-code-replay.js +190 -0
  6. package/dist/acp/claude-code-replay.js.map +1 -0
  7. package/dist/acp/macro-agent.d.ts.map +1 -1
  8. package/dist/acp/macro-agent.js +155 -6
  9. package/dist/acp/macro-agent.js.map +1 -1
  10. package/dist/acp/types.d.ts +9 -0
  11. package/dist/acp/types.d.ts.map +1 -1
  12. package/dist/acp/types.js.map +1 -1
  13. package/dist/agent/agent-manager-v2.d.ts +21 -0
  14. package/dist/agent/agent-manager-v2.d.ts.map +1 -1
  15. package/dist/agent/agent-manager-v2.js +234 -71
  16. package/dist/agent/agent-manager-v2.js.map +1 -1
  17. package/dist/agent/agent-manager.d.ts +12 -0
  18. package/dist/agent/agent-manager.d.ts.map +1 -1
  19. package/dist/agent/agent-manager.js.map +1 -1
  20. package/dist/agent/types.d.ts +15 -2
  21. package/dist/agent/types.d.ts.map +1 -1
  22. package/dist/agent/types.js.map +1 -1
  23. package/dist/boot-v2.d.ts +41 -0
  24. package/dist/boot-v2.d.ts.map +1 -1
  25. package/dist/boot-v2.js +34 -37
  26. package/dist/boot-v2.js.map +1 -1
  27. package/dist/cli/index.js +56 -0
  28. package/dist/cli/index.js.map +1 -1
  29. package/dist/cognitive/macro-agent-backend.d.ts.map +1 -1
  30. package/dist/cognitive/macro-agent-backend.js +40 -22
  31. package/dist/cognitive/macro-agent-backend.js.map +1 -1
  32. package/dist/integrations/skilltree.d.ts.map +1 -1
  33. package/dist/integrations/skilltree.js +1 -0
  34. package/dist/integrations/skilltree.js.map +1 -1
  35. package/dist/lifecycle/cleanup.d.ts +33 -2
  36. package/dist/lifecycle/cleanup.d.ts.map +1 -1
  37. package/dist/lifecycle/cleanup.js +28 -6
  38. package/dist/lifecycle/cleanup.js.map +1 -1
  39. package/dist/lifecycle/handlers-v2.d.ts +7 -0
  40. package/dist/lifecycle/handlers-v2.d.ts.map +1 -1
  41. package/dist/lifecycle/handlers-v2.js +28 -2
  42. package/dist/lifecycle/handlers-v2.js.map +1 -1
  43. package/dist/lifecycle/types.d.ts +11 -0
  44. package/dist/lifecycle/types.d.ts.map +1 -1
  45. package/dist/lifecycle/types.js.map +1 -1
  46. package/dist/map/acp-bridge.d.ts +9 -0
  47. package/dist/map/acp-bridge.d.ts.map +1 -1
  48. package/dist/map/acp-bridge.js +15 -2
  49. package/dist/map/acp-bridge.js.map +1 -1
  50. package/dist/map/cascade-bridge.d.ts +44 -0
  51. package/dist/map/cascade-bridge.d.ts.map +1 -0
  52. package/dist/map/cascade-bridge.js +257 -0
  53. package/dist/map/cascade-bridge.js.map +1 -0
  54. package/dist/map/lifecycle-bridge.d.ts +1 -8
  55. package/dist/map/lifecycle-bridge.d.ts.map +1 -1
  56. package/dist/map/lifecycle-bridge.js +76 -22
  57. package/dist/map/lifecycle-bridge.js.map +1 -1
  58. package/dist/map/server.d.ts.map +1 -1
  59. package/dist/map/server.js +47 -6
  60. package/dist/map/server.js.map +1 -1
  61. package/dist/map/sidecar.d.ts.map +1 -1
  62. package/dist/map/sidecar.js +33 -4
  63. package/dist/map/sidecar.js.map +1 -1
  64. package/dist/map/types.d.ts +20 -0
  65. package/dist/map/types.d.ts.map +1 -1
  66. package/dist/mcp/tools/done-v2.d.ts.map +1 -1
  67. package/dist/mcp/tools/done-v2.js +8 -0
  68. package/dist/mcp/tools/done-v2.js.map +1 -1
  69. package/dist/teams/team-manager-v2.d.ts.map +1 -1
  70. package/dist/teams/team-manager-v2.js +26 -0
  71. package/dist/teams/team-manager-v2.js.map +1 -1
  72. package/dist/teams/team-runtime-v2.d.ts.map +1 -1
  73. package/dist/teams/team-runtime-v2.js +16 -3
  74. package/dist/teams/team-runtime-v2.js.map +1 -1
  75. package/dist/workspace/config.d.ts +10 -10
  76. package/dist/workspace/config.d.ts.map +1 -1
  77. package/dist/workspace/config.js +4 -4
  78. package/dist/workspace/config.js.map +1 -1
  79. package/dist/workspace/git-cascade-adapter.d.ts +510 -0
  80. package/dist/workspace/git-cascade-adapter.d.ts.map +1 -0
  81. package/dist/workspace/git-cascade-adapter.js +908 -0
  82. package/dist/workspace/git-cascade-adapter.js.map +1 -0
  83. package/dist/workspace/index.d.ts +3 -3
  84. package/dist/workspace/index.d.ts.map +1 -1
  85. package/dist/workspace/index.js +4 -4
  86. package/dist/workspace/index.js.map +1 -1
  87. package/dist/workspace/landing/direct-push.d.ts +20 -0
  88. package/dist/workspace/landing/direct-push.d.ts.map +1 -0
  89. package/dist/workspace/landing/direct-push.js +74 -0
  90. package/dist/workspace/landing/direct-push.js.map +1 -0
  91. package/dist/workspace/landing/index.d.ts +29 -0
  92. package/dist/workspace/landing/index.d.ts.map +1 -0
  93. package/dist/workspace/landing/index.js +37 -0
  94. package/dist/workspace/landing/index.js.map +1 -0
  95. package/dist/workspace/landing/merge-to-parent.d.ts +41 -0
  96. package/dist/workspace/landing/merge-to-parent.d.ts.map +1 -0
  97. package/dist/workspace/landing/merge-to-parent.js +185 -0
  98. package/dist/workspace/landing/merge-to-parent.js.map +1 -0
  99. package/dist/workspace/landing/optimistic-push.d.ts +16 -0
  100. package/dist/workspace/landing/optimistic-push.d.ts.map +1 -0
  101. package/dist/workspace/landing/optimistic-push.js +27 -0
  102. package/dist/workspace/landing/optimistic-push.js.map +1 -0
  103. package/dist/workspace/landing/queue-to-branch.d.ts +24 -0
  104. package/dist/workspace/landing/queue-to-branch.d.ts.map +1 -0
  105. package/dist/workspace/landing/queue-to-branch.js +79 -0
  106. package/dist/workspace/landing/queue-to-branch.js.map +1 -0
  107. package/dist/workspace/merge-queue/merge-queue.d.ts +10 -0
  108. package/dist/workspace/merge-queue/merge-queue.d.ts.map +1 -1
  109. package/dist/workspace/merge-queue/merge-queue.js +10 -0
  110. package/dist/workspace/merge-queue/merge-queue.js.map +1 -1
  111. package/dist/workspace/merge-queue/types.d.ts +16 -2
  112. package/dist/workspace/merge-queue/types.d.ts.map +1 -1
  113. package/dist/workspace/merge-queue/types.js +9 -0
  114. package/dist/workspace/merge-queue/types.js.map +1 -1
  115. package/dist/workspace/pool/types.d.ts +1 -0
  116. package/dist/workspace/pool/types.d.ts.map +1 -1
  117. package/dist/workspace/pool/worktree-pool.d.ts.map +1 -1
  118. package/dist/workspace/pool/worktree-pool.js +1 -0
  119. package/dist/workspace/pool/worktree-pool.js.map +1 -1
  120. package/dist/workspace/recovery/abandon.d.ts +15 -0
  121. package/dist/workspace/recovery/abandon.d.ts.map +1 -0
  122. package/dist/workspace/recovery/abandon.js +45 -0
  123. package/dist/workspace/recovery/abandon.js.map +1 -0
  124. package/dist/workspace/recovery/auto-resolve.d.ts +27 -0
  125. package/dist/workspace/recovery/auto-resolve.d.ts.map +1 -0
  126. package/dist/workspace/recovery/auto-resolve.js +99 -0
  127. package/dist/workspace/recovery/auto-resolve.js.map +1 -0
  128. package/dist/workspace/recovery/defer.d.ts +15 -0
  129. package/dist/workspace/recovery/defer.d.ts.map +1 -0
  130. package/dist/workspace/recovery/defer.js +16 -0
  131. package/dist/workspace/recovery/defer.js.map +1 -0
  132. package/dist/workspace/recovery/escalate.d.ts +16 -0
  133. package/dist/workspace/recovery/escalate.d.ts.map +1 -0
  134. package/dist/workspace/recovery/escalate.js +24 -0
  135. package/dist/workspace/recovery/escalate.js.map +1 -0
  136. package/dist/workspace/recovery/index.d.ts +32 -0
  137. package/dist/workspace/recovery/index.d.ts.map +1 -0
  138. package/dist/workspace/recovery/index.js +45 -0
  139. package/dist/workspace/recovery/index.js.map +1 -0
  140. package/dist/workspace/recovery/spawn-resolver.d.ts +45 -0
  141. package/dist/workspace/recovery/spawn-resolver.d.ts.map +1 -0
  142. package/dist/workspace/recovery/spawn-resolver.js +111 -0
  143. package/dist/workspace/recovery/spawn-resolver.js.map +1 -0
  144. package/dist/workspace/recovery/types.d.ts +63 -0
  145. package/dist/workspace/recovery/types.d.ts.map +1 -0
  146. package/dist/workspace/recovery/types.js +12 -0
  147. package/dist/workspace/recovery/types.js.map +1 -0
  148. package/dist/workspace/topology/index.d.ts +9 -0
  149. package/dist/workspace/topology/index.d.ts.map +1 -0
  150. package/dist/workspace/topology/index.js +8 -0
  151. package/dist/workspace/topology/index.js.map +1 -0
  152. package/dist/workspace/topology/no-workspace.d.ts +18 -0
  153. package/dist/workspace/topology/no-workspace.d.ts.map +1 -0
  154. package/dist/workspace/topology/no-workspace.js +25 -0
  155. package/dist/workspace/topology/no-workspace.js.map +1 -0
  156. package/dist/workspace/topology/types.d.ts +97 -0
  157. package/dist/workspace/topology/types.d.ts.map +1 -0
  158. package/dist/workspace/topology/types.js +20 -0
  159. package/dist/workspace/topology/types.js.map +1 -0
  160. package/dist/workspace/topology/yaml-driven.d.ts +69 -0
  161. package/dist/workspace/topology/yaml-driven.d.ts.map +1 -0
  162. package/dist/workspace/topology/yaml-driven.js +273 -0
  163. package/dist/workspace/topology/yaml-driven.js.map +1 -0
  164. package/dist/workspace/types-v3.d.ts +110 -0
  165. package/dist/workspace/types-v3.d.ts.map +1 -0
  166. package/dist/workspace/types-v3.js +20 -0
  167. package/dist/workspace/types-v3.js.map +1 -0
  168. package/dist/workspace/types.d.ts +145 -17
  169. package/dist/workspace/types.d.ts.map +1 -1
  170. package/dist/workspace/workspace-manager.d.ts +92 -13
  171. package/dist/workspace/workspace-manager.d.ts.map +1 -1
  172. package/dist/workspace/workspace-manager.js +373 -13
  173. package/dist/workspace/workspace-manager.js.map +1 -1
  174. package/dist/workspace/yaml-schema.d.ts +254 -0
  175. package/dist/workspace/yaml-schema.d.ts.map +1 -0
  176. package/dist/workspace/yaml-schema.js +170 -0
  177. package/dist/workspace/yaml-schema.js.map +1 -0
  178. package/docs/conflict-recovery.md +472 -0
  179. package/docs/git-cascade-integration-gaps.md +678 -0
  180. package/docs/workspace-interfaces.md +731 -0
  181. package/docs/workspace-redesign-plan.md +302 -0
  182. package/package.json +4 -4
  183. package/src/__tests__/e2e/auto-sync.e2e.test.ts +257 -0
  184. package/src/__tests__/e2e/cascade-rebase.e2e.test.ts +254 -0
  185. package/src/__tests__/e2e/cli-run.e2e.test.ts +167 -0
  186. package/src/__tests__/e2e/self-driving-v3.e2e.test.ts +197 -0
  187. package/src/__tests__/e2e/spawn-resolver.e2e.test.ts +200 -0
  188. package/src/__tests__/e2e/workspace-lifecycle.e2e.test.ts +30 -22
  189. package/src/__tests__/e2e/workspace-v3.e2e.test.ts +413 -0
  190. package/src/acp/__tests__/claude-code-replay.test.ts +225 -0
  191. package/src/acp/__tests__/macro-agent.test.ts +39 -1
  192. package/src/acp/claude-code-replay.ts +208 -0
  193. package/src/acp/macro-agent.ts +167 -9
  194. package/src/acp/types.ts +10 -0
  195. package/src/agent/__tests__/agent-manager-topology.test.ts +73 -0
  196. package/src/agent/__tests__/agent-manager-v2.test.ts +71 -11
  197. package/src/agent/__tests__/task-ref-resolution.test.ts +231 -0
  198. package/src/agent/agent-manager-v2.ts +293 -77
  199. package/src/agent/agent-manager.ts +14 -0
  200. package/src/agent/types.ts +16 -2
  201. package/src/boot-v2.ts +87 -36
  202. package/src/cli/index.ts +61 -0
  203. package/src/cognitive/__tests__/macro-agent-backend.test.ts +47 -5
  204. package/src/cognitive/macro-agent-backend.ts +45 -29
  205. package/src/integrations/skilltree.ts +1 -0
  206. package/src/lifecycle/cleanup.ts +52 -3
  207. package/src/lifecycle/handlers-v2.ts +40 -3
  208. package/src/lifecycle/types.ts +12 -0
  209. package/src/map/__tests__/cascade-bridge.test.ts +229 -0
  210. package/src/map/__tests__/lifecycle-bridge.test.ts +165 -22
  211. package/src/map/acp-bridge.ts +26 -3
  212. package/src/map/cascade-bridge.ts +301 -0
  213. package/src/map/lifecycle-bridge.ts +77 -27
  214. package/src/map/server.ts +47 -6
  215. package/src/map/sidecar.ts +31 -3
  216. package/src/map/types.ts +20 -0
  217. package/src/mcp/tools/done-v2.ts +9 -0
  218. package/src/teams/team-manager-v2.ts +37 -0
  219. package/src/teams/team-runtime-v2.ts +23 -3
  220. package/src/workspace/__tests__/{dataplane-adapter.test.ts → git-cascade-adapter.test.ts} +209 -14
  221. package/src/workspace/__tests__/self-driving-yaml.test.ts +114 -0
  222. package/src/workspace/__tests__/shared-worktree-refcount.test.ts +154 -0
  223. package/src/workspace/__tests__/standalone-mode.test.ts +118 -0
  224. package/src/workspace/__tests__/workspace-manager-v3.test.ts +245 -0
  225. package/src/workspace/__tests__/yaml-schema.test.ts +210 -0
  226. package/src/workspace/config.ts +11 -11
  227. package/src/workspace/git-cascade-adapter.ts +1186 -0
  228. package/src/workspace/index.ts +11 -11
  229. package/src/workspace/landing/__tests__/strategies.test.ts +142 -0
  230. package/src/workspace/landing/direct-push.ts +91 -0
  231. package/src/workspace/landing/index.ts +40 -0
  232. package/src/workspace/landing/merge-to-parent.ts +228 -0
  233. package/src/workspace/landing/optimistic-push.ts +36 -0
  234. package/src/workspace/landing/queue-to-branch.ts +108 -0
  235. package/src/workspace/merge-queue/merge-queue.ts +10 -0
  236. package/src/workspace/merge-queue/types.ts +16 -2
  237. package/src/workspace/pool/__tests__/worktree-pool.integration.test.ts +5 -5
  238. package/src/workspace/pool/types.ts +1 -0
  239. package/src/workspace/pool/worktree-pool.ts +1 -0
  240. package/src/workspace/recovery/__tests__/auto-resolve-integration.test.ts +127 -0
  241. package/src/workspace/recovery/__tests__/spawn-resolver.test.ts +139 -0
  242. package/src/workspace/recovery/__tests__/strategies.test.ts +145 -0
  243. package/src/workspace/recovery/abandon.ts +51 -0
  244. package/src/workspace/recovery/auto-resolve.ts +119 -0
  245. package/src/workspace/recovery/defer.ts +23 -0
  246. package/src/workspace/recovery/escalate.ts +30 -0
  247. package/src/workspace/recovery/index.ts +58 -0
  248. package/src/workspace/recovery/spawn-resolver.ts +145 -0
  249. package/src/workspace/recovery/types.ts +54 -0
  250. package/src/workspace/topology/__tests__/yaml-driven.test.ts +345 -0
  251. package/src/workspace/topology/index.ts +18 -0
  252. package/src/workspace/topology/no-workspace.ts +39 -0
  253. package/src/workspace/topology/types.ts +116 -0
  254. package/src/workspace/topology/yaml-driven.ts +316 -0
  255. package/src/workspace/types-v3.ts +155 -0
  256. package/src/workspace/types.ts +191 -20
  257. package/src/workspace/workspace-manager.ts +474 -19
  258. package/src/workspace/yaml-schema.ts +216 -0
  259. package/src/workspace/dataplane-adapter.ts +0 -546
@@ -0,0 +1,908 @@
1
+ /**
2
+ * git-cascade Adapter
3
+ *
4
+ * Wraps git-cascade's MultiAgentRepoTracker to integrate with macro-agent's
5
+ * event system and provide a simplified interface for workspace management.
6
+ *
7
+ * @module workspace/git-cascade-adapter
8
+ */
9
+ import { MultiAgentRepoTracker, workerTasks, diffStacks, matchCascadeSuffix, } from 'git-cascade';
10
+ import { DEFAULT_GIT_CASCADE_CONFIG } from './config.js';
11
+ /**
12
+ * GitCascadeAdapter wraps MultiAgentRepoTracker for macro-agent integration.
13
+ *
14
+ * Key responsibilities:
15
+ * - Initialize tracker with shared or dedicated database
16
+ * - Emit events on tracker operations
17
+ * - Provide simplified API for workspace management
18
+ */
19
+ export class GitCascadeAdapter {
20
+ tracker;
21
+ config;
22
+ eventListeners = new Set();
23
+ ownsDb;
24
+ /**
25
+ * Create a new GitCascadeAdapter.
26
+ *
27
+ * @param config - git-cascade configuration
28
+ */
29
+ constructor(config) {
30
+ const mergedConfig = {
31
+ ...DEFAULT_GIT_CASCADE_CONFIG,
32
+ ...config,
33
+ repoPath: config.repoPath ?? process.cwd(),
34
+ };
35
+ this.config = {
36
+ enabled: mergedConfig.enabled ?? true,
37
+ repoPath: mergedConfig.repoPath,
38
+ tablePrefix: mergedConfig.tablePrefix ?? 'git_cascade_',
39
+ verbose: mergedConfig.verbose ?? false,
40
+ skipRecovery: mergedConfig.skipRecovery ?? false,
41
+ };
42
+ // Determine if we own the database connection
43
+ this.ownsDb = !config.db;
44
+ const trackerOptions = {
45
+ repoPath: this.config.repoPath,
46
+ tablePrefix: this.config.tablePrefix,
47
+ verbose: this.config.verbose,
48
+ skipRecovery: this.config.skipRecovery,
49
+ // Wire git-cascade's native event emitter (0.0.2+) so stream lifecycle
50
+ // events are re-published through our own onEvent channel.
51
+ emit: (method, params) => this.forwardCascadeEvent(method, params),
52
+ };
53
+ if (config.db) {
54
+ trackerOptions.db = config.db;
55
+ }
56
+ else if (config.dbPath) {
57
+ trackerOptions.dbPath = config.dbPath;
58
+ }
59
+ // If neither db nor dbPath provided, tracker uses default path
60
+ this.tracker = new MultiAgentRepoTracker(trackerOptions);
61
+ }
62
+ /**
63
+ * Get whether the adapter is enabled.
64
+ */
65
+ get enabled() {
66
+ return this.config.enabled;
67
+ }
68
+ /**
69
+ * Get the repository path.
70
+ */
71
+ get repoPath() {
72
+ return this.config.repoPath;
73
+ }
74
+ /**
75
+ * Get the underlying database connection.
76
+ * Use with caution - prefer adapter methods for operations.
77
+ */
78
+ get db() {
79
+ return this.tracker.db;
80
+ }
81
+ /**
82
+ * Get the underlying tracker.
83
+ * Use with caution - prefer adapter methods for operations.
84
+ */
85
+ get rawTracker() {
86
+ return this.tracker;
87
+ }
88
+ // ─────────────────────────────────────────────────────────────────────────────
89
+ // Event System
90
+ // ─────────────────────────────────────────────────────────────────────────────
91
+ /**
92
+ * Subscribe to git-cascade events.
93
+ *
94
+ * @param callback - Function called when events occur
95
+ * @returns Unsubscribe function
96
+ */
97
+ onEvent(callback) {
98
+ this.eventListeners.add(callback);
99
+ return () => this.eventListeners.delete(callback);
100
+ }
101
+ /**
102
+ * Emit an event to all listeners.
103
+ */
104
+ emit(type, data) {
105
+ const event = {
106
+ type,
107
+ timestamp: Date.now(),
108
+ data,
109
+ };
110
+ for (const listener of this.eventListeners) {
111
+ try {
112
+ listener(event);
113
+ }
114
+ catch (error) {
115
+ console.error('[GitCascadeAdapter] Event listener error:', error);
116
+ }
117
+ }
118
+ }
119
+ /**
120
+ * Forward events emitted by git-cascade (`x-cascade/stream.*`) into our
121
+ * structured `GitCascadeEvent` stream. Called via the `emit` callback wired
122
+ * into the tracker constructor.
123
+ *
124
+ * Note: `stream.opened` is mapped to `stream:created`. The local
125
+ * wrapper methods still emit their own events so consumers don't miss out
126
+ * on operations that don't round-trip through git-cascade's emit (e.g.,
127
+ * updateStream, pauseStream, mergeQueue events).
128
+ */
129
+ forwardCascadeEvent(method, params) {
130
+ const suffix = matchCascadeSuffix(method);
131
+ if (!suffix)
132
+ return;
133
+ switch (suffix) {
134
+ case 'stream.opened': {
135
+ const p = params;
136
+ this.emit('stream:created', {
137
+ streamId: p.stream_id,
138
+ name: p.name,
139
+ agentId: p.agent_id,
140
+ baseCommit: p.base_commit,
141
+ parentStream: p.parent_stream,
142
+ branchName: p.branch_name,
143
+ metadata: p.metadata,
144
+ });
145
+ break;
146
+ }
147
+ case 'stream.committed': {
148
+ const p = params;
149
+ this.emit('stream:committed', {
150
+ streamId: p.stream_id,
151
+ commit: p.commit_hash,
152
+ changeId: p.change_id,
153
+ agentId: p.agent_id,
154
+ messageSummary: p.message_summary,
155
+ filesTouched: p.files_touched,
156
+ parentCommit: p.parent_commit,
157
+ metadata: p.metadata,
158
+ });
159
+ break;
160
+ }
161
+ case 'stream.merged': {
162
+ const p = params;
163
+ this.emit('stream:merged', {
164
+ sourceStreamId: p.source_stream_id,
165
+ targetStreamId: p.target_stream_id,
166
+ mergeCommit: p.merge_commit,
167
+ agentId: p.agent_id,
168
+ strategy: p.strategy,
169
+ sourceCommit: p.source_commit,
170
+ metadata: p.metadata,
171
+ });
172
+ break;
173
+ }
174
+ case 'stream.conflicted': {
175
+ const p = params;
176
+ this.emit('stream:conflicted', {
177
+ streamId: p.stream_id,
178
+ conflictId: p.conflict_id,
179
+ conflictedFiles: p.conflicted_files,
180
+ agentId: p.agent_id,
181
+ conflictingCommit: p.conflicting_commit,
182
+ targetCommit: p.target_commit,
183
+ source: p.source,
184
+ metadata: p.metadata,
185
+ });
186
+ break;
187
+ }
188
+ case 'stream.conflict_resolved': {
189
+ const p = params;
190
+ this.emit('conflict:resolved', {
191
+ streamId: p.stream_id,
192
+ conflictId: p.conflict_id,
193
+ resolutionMethod: p.resolution_method,
194
+ resolvedBy: p.resolved_by,
195
+ resolutionSummary: p.resolution_summary,
196
+ metadata: p.metadata,
197
+ });
198
+ break;
199
+ }
200
+ case 'stream.abandoned': {
201
+ const p = params;
202
+ this.emit('stream:abandoned', {
203
+ streamId: p.stream_id,
204
+ reason: p.reason,
205
+ cascade: p.cascade,
206
+ metadata: p.metadata,
207
+ });
208
+ break;
209
+ }
210
+ case 'cascade.rebased': {
211
+ const p = params;
212
+ this.emit('cascade:rebased', {
213
+ streamId: p.stream_id,
214
+ agentId: p.agent_id,
215
+ triggeredByStreamId: p.triggered_by_stream_id,
216
+ triggeredByAgentId: p.triggered_by_agent_id,
217
+ newBaseCommit: p.new_base_commit,
218
+ newHead: p.new_head,
219
+ newCommits: p.new_commits,
220
+ metadata: p.metadata,
221
+ });
222
+ break;
223
+ }
224
+ case 'cascade.completed': {
225
+ const p = params;
226
+ this.emit('cascade:completed', {
227
+ rootStreamId: p.root_stream_id,
228
+ agentId: p.agent_id,
229
+ strategy: p.strategy,
230
+ updatedStreams: p.updated_streams,
231
+ failedStreams: p.failed_streams,
232
+ skippedStreams: p.skipped_streams,
233
+ deferredStreams: p.deferred_streams,
234
+ metadata: p.metadata,
235
+ });
236
+ break;
237
+ }
238
+ case 'queue.added': {
239
+ const p = params;
240
+ this.emit('mergeQueue:added', {
241
+ entryId: p.entry_id,
242
+ streamId: p.stream_id,
243
+ targetBranch: p.target_branch,
244
+ metadata: p.metadata,
245
+ });
246
+ break;
247
+ }
248
+ case 'queue.ready': {
249
+ const p = params;
250
+ this.emit('mergeQueue:ready', {
251
+ entryId: p.entry_id,
252
+ streamId: p.stream_id,
253
+ targetBranch: p.target_branch,
254
+ });
255
+ break;
256
+ }
257
+ case 'queue.cancelled': {
258
+ const p = params;
259
+ this.emit('mergeQueue:cancelled', {
260
+ entryId: p.entry_id,
261
+ streamId: p.stream_id,
262
+ targetBranch: p.target_branch,
263
+ reason: p.reason,
264
+ });
265
+ break;
266
+ }
267
+ case 'queue.removed': {
268
+ const p = params;
269
+ this.emit('mergeQueue:removed', {
270
+ entryId: p.entry_id,
271
+ streamId: p.stream_id,
272
+ targetBranch: p.target_branch,
273
+ outcome: p.outcome,
274
+ });
275
+ break;
276
+ }
277
+ }
278
+ }
279
+ // ─────────────────────────────────────────────────────────────────────────────
280
+ // Stream Operations
281
+ // ─────────────────────────────────────────────────────────────────────────────
282
+ /**
283
+ * Create a new stream (integration branch).
284
+ *
285
+ * Note: `stream:created` is emitted by the cascade event forwarder via
286
+ * git-cascade's `x-cascade/stream.opened`. We don't double-emit here.
287
+ *
288
+ * @param options - Stream creation options
289
+ * @returns Stream ID
290
+ */
291
+ createStream(options) {
292
+ return this.tracker.createStream(options);
293
+ }
294
+ /**
295
+ * Get a stream by ID.
296
+ */
297
+ getStream(streamId) {
298
+ return this.tracker.getStream(streamId);
299
+ }
300
+ /**
301
+ * List streams with optional filters.
302
+ */
303
+ listStreams(options) {
304
+ return this.tracker.listStreams(options);
305
+ }
306
+ /**
307
+ * Update a stream.
308
+ */
309
+ updateStream(streamId, updates) {
310
+ this.tracker.updateStream(streamId, updates);
311
+ this.emit('stream:updated', { streamId, updates });
312
+ }
313
+ /**
314
+ * Abandon a stream.
315
+ *
316
+ * Note: `stream:abandoned` is emitted by the cascade event forwarder.
317
+ */
318
+ abandonStream(streamId, options) {
319
+ this.tracker.abandonStream(streamId, options);
320
+ }
321
+ /**
322
+ * Get the git branch name for a stream.
323
+ */
324
+ getStreamBranchName(streamId) {
325
+ return this.tracker.getStreamBranchName(streamId);
326
+ }
327
+ /**
328
+ * Get the HEAD commit of a stream.
329
+ */
330
+ getStreamHead(streamId) {
331
+ return this.tracker.getStreamHead(streamId);
332
+ }
333
+ /**
334
+ * Fork a child stream off a parent.
335
+ */
336
+ forkStream(options) {
337
+ const streamId = this.tracker.forkStream(options);
338
+ this.emit('stream:forked', {
339
+ streamId,
340
+ parentStreamId: options.parentStreamId,
341
+ name: options.name,
342
+ agentId: options.agentId,
343
+ });
344
+ return streamId;
345
+ }
346
+ /**
347
+ * Merge source stream into target stream.
348
+ *
349
+ * Note: `stream:merged` is emitted by the cascade event forwarder on success.
350
+ * On conflict, `stream:conflicted` is also forwarded.
351
+ */
352
+ mergeStream(options) {
353
+ return this.tracker.mergeStream(options);
354
+ }
355
+ /**
356
+ * Rebase a stream onto its parent to pick up new commits.
357
+ */
358
+ syncWithParent(streamId, agentId, worktree, onConflict) {
359
+ return this.tracker.syncWithParent(streamId, agentId, worktree, onConflict);
360
+ }
361
+ /**
362
+ * Rebase a stream onto a specific target stream.
363
+ */
364
+ rebaseOntoStream(options) {
365
+ return this.tracker.rebaseOntoStream(options);
366
+ }
367
+ /**
368
+ * Async version of rebaseOntoStream — supports async conflict handlers.
369
+ */
370
+ rebaseOntoStreamAsync(options) {
371
+ return this.tracker.rebaseOntoStreamAsync(options);
372
+ }
373
+ /**
374
+ * Pause a stream (halt work without abandoning).
375
+ */
376
+ pauseStream(streamId, reason) {
377
+ this.tracker.pauseStream(streamId, reason);
378
+ this.emit('stream:paused', { streamId, reason });
379
+ }
380
+ /**
381
+ * Resume a paused stream.
382
+ */
383
+ resumeStream(streamId) {
384
+ this.tracker.resumeStream(streamId);
385
+ this.emit('stream:resumed', { streamId });
386
+ }
387
+ /**
388
+ * Track an existing branch as a stream (local mode — no new `stream/<id>` branch).
389
+ */
390
+ trackExistingBranch(options) {
391
+ return this.tracker.trackExistingBranch(options);
392
+ }
393
+ /**
394
+ * Get stream hierarchy as a tree.
395
+ */
396
+ getStreamHierarchy(rootStreamId) {
397
+ return this.tracker.getStreamHierarchy(rootStreamId);
398
+ }
399
+ /**
400
+ * Get child streams (direct children only).
401
+ */
402
+ getChildStreams(streamId) {
403
+ return this.tracker.getChildStreams(streamId);
404
+ }
405
+ /**
406
+ * Find the common ancestor of two streams.
407
+ */
408
+ findCommonAncestor(streamIdA, streamIdB) {
409
+ return this.tracker.findCommonAncestor(streamIdA, streamIdB);
410
+ }
411
+ // ─────────────────────────────────────────────────────────────────────────────
412
+ // Stream Dependencies
413
+ // ─────────────────────────────────────────────────────────────────────────────
414
+ /**
415
+ * Declare that one stream depends on another.
416
+ */
417
+ addDependency(streamId, dependsOnId) {
418
+ this.tracker.addDependency(streamId, dependsOnId);
419
+ }
420
+ /**
421
+ * Remove a dependency declaration.
422
+ */
423
+ removeDependency(streamId, dependsOnId) {
424
+ this.tracker.removeDependency(streamId, dependsOnId);
425
+ }
426
+ /**
427
+ * Get direct dependencies of a stream.
428
+ */
429
+ getDependencies(streamId) {
430
+ return this.tracker.getDependencies(streamId);
431
+ }
432
+ /**
433
+ * Get direct dependents of a stream.
434
+ */
435
+ getDependents(streamId) {
436
+ return this.tracker.getDependents(streamId);
437
+ }
438
+ // ─────────────────────────────────────────────────────────────────────────────
439
+ // Cascade Rebase (git-cascade 0.0.3+)
440
+ // ─────────────────────────────────────────────────────────────────────────────
441
+ /**
442
+ * Cascade-rebase all dependents of a root stream.
443
+ *
444
+ * Propagates rebases through the dependency graph. Uses a callback-based
445
+ * worktree provider so not every dependent needs a pre-allocated worktree.
446
+ *
447
+ * @param options - Cascade options including root stream, agent id, and worktree provider
448
+ * @returns CascadeResult with updated/failed/skipped stream lists
449
+ */
450
+ cascadeRebase(options) {
451
+ // Use tracker.cascadeRebase which threads the tracker's emit + eventPrefix
452
+ // into the cascade walk so `cascade.rebased` (per dependent) and
453
+ // `cascade.completed` (at end) both round-trip through our
454
+ // forwardCascadeEvent. No manual emit needed — events are driven by
455
+ // git-cascade 0.0.4+ from inside the walk.
456
+ return this.tracker.cascadeRebase(options);
457
+ }
458
+ // ─────────────────────────────────────────────────────────────────────────────
459
+ // Worktree Operations
460
+ // ─────────────────────────────────────────────────────────────────────────────
461
+ /**
462
+ * Create a worktree for an agent.
463
+ *
464
+ * @param options - Worktree creation options
465
+ * @returns Created worktree info
466
+ */
467
+ createWorktree(options) {
468
+ const worktree = this.tracker.createWorktree(options);
469
+ this.emit('worktree:created', { ...worktree });
470
+ return worktree;
471
+ }
472
+ /**
473
+ * Get a worktree by agent ID.
474
+ */
475
+ getWorktree(agentId) {
476
+ return this.tracker.getWorktree(agentId);
477
+ }
478
+ /**
479
+ * List all worktrees.
480
+ */
481
+ listWorktrees() {
482
+ return this.tracker.listWorktrees();
483
+ }
484
+ /**
485
+ * Update the stream associated with a worktree.
486
+ */
487
+ updateWorktreeStream(agentId, streamId) {
488
+ this.tracker.updateWorktreeStream(agentId, streamId);
489
+ }
490
+ /**
491
+ * Deallocate a worktree.
492
+ */
493
+ deallocateWorktree(agentId) {
494
+ this.tracker.deallocateWorktree(agentId);
495
+ this.emit('worktree:deallocated', { agentId });
496
+ }
497
+ // ─────────────────────────────────────────────────────────────────────────────
498
+ // Worker Task Operations
499
+ // ─────────────────────────────────────────────────────────────────────────────
500
+ /**
501
+ * Create a worker task under a stream.
502
+ *
503
+ * @param options - Task creation options
504
+ * @returns Task ID
505
+ */
506
+ createTask(options) {
507
+ const taskId = this.tracker.createTask(options);
508
+ this.emit('task:created', { taskId, ...options });
509
+ return taskId;
510
+ }
511
+ /**
512
+ * Get a task by ID.
513
+ */
514
+ getTask(taskId) {
515
+ return this.tracker.getTask(taskId);
516
+ }
517
+ /**
518
+ * List tasks for a stream.
519
+ */
520
+ listTasks(streamId, options) {
521
+ return this.tracker.listTasks(streamId, options);
522
+ }
523
+ /**
524
+ * Start a task - assigns agent and creates worker branch.
525
+ *
526
+ * @param options - Start task options
527
+ * @returns Branch name and start commit
528
+ */
529
+ startTask(options) {
530
+ const result = this.tracker.startTask(options);
531
+ this.emit('task:started', {
532
+ taskId: options.taskId,
533
+ agentId: options.agentId,
534
+ branchName: result.branchName,
535
+ startCommit: result.startCommit,
536
+ });
537
+ return result;
538
+ }
539
+ /**
540
+ * Complete a task - merges worker branch to stream.
541
+ *
542
+ * @param options - Complete task options
543
+ * @returns Merge result
544
+ */
545
+ completeTask(options) {
546
+ const result = this.tracker.completeTask(options);
547
+ this.emit('task:completed', { taskId: options.taskId, ...result });
548
+ return result;
549
+ }
550
+ /**
551
+ * Abandon a task.
552
+ *
553
+ * @param taskId - Task ID
554
+ * @param options - Options
555
+ */
556
+ abandonTask(taskId, options) {
557
+ this.tracker.abandonTask(taskId, options);
558
+ this.emit('task:abandoned', { taskId, ...options });
559
+ }
560
+ /**
561
+ * Release a task back to 'open' status.
562
+ */
563
+ releaseTask(taskId) {
564
+ this.tracker.releaseTask(taskId);
565
+ }
566
+ /**
567
+ * Detect conflicts for a task before completing.
568
+ *
569
+ * @param taskId - Task ID
570
+ * @param worktree - Worktree path
571
+ * @returns Array of conflicting file paths, empty if no conflicts
572
+ */
573
+ detectTaskConflicts(taskId, worktree) {
574
+ return workerTasks.detectTaskConflicts(this.tracker.db, this.config.repoPath, taskId, worktree);
575
+ }
576
+ /**
577
+ * Recover stale tasks that have been in_progress too long.
578
+ *
579
+ * @param thresholdMs - Tasks older than this are considered stale
580
+ * @returns Result with released task IDs
581
+ */
582
+ recoverStaleTasks(thresholdMs = 60 * 60 * 1000) {
583
+ return workerTasks.recoverStaleTasks(this.tracker.db, thresholdMs);
584
+ }
585
+ // ─────────────────────────────────────────────────────────────────────────────
586
+ // Checkpoint Operations
587
+ // ─────────────────────────────────────────────────────────────────────────────
588
+ /**
589
+ * Create checkpoints for commits made during a task.
590
+ *
591
+ * Creates a checkpoint for each commit between the task's startCommit and
592
+ * the current HEAD of the task's stream. This captures the work done during
593
+ * the task for future review and merge workflows.
594
+ *
595
+ * @param taskId - Task ID to create checkpoints for
596
+ * @param agentId - Agent ID (used as createdBy)
597
+ * @returns Array of created checkpoints
598
+ */
599
+ createCheckpointsForTask(taskId, agentId) {
600
+ const task = this.getTask(taskId);
601
+ if (!task) {
602
+ console.warn(`[GitCascadeAdapter] Task not found: ${taskId}`);
603
+ return [];
604
+ }
605
+ if (!task.streamId) {
606
+ console.warn(`[GitCascadeAdapter] Task ${taskId} has no streamId`);
607
+ return [];
608
+ }
609
+ if (!task.startCommit) {
610
+ console.warn(`[GitCascadeAdapter] Task ${taskId} has no startCommit`);
611
+ return [];
612
+ }
613
+ try {
614
+ // Create checkpoints from task's startCommit to stream's current HEAD
615
+ const checkpoints = diffStacks.createCheckpointsFromStream(this.tracker.db, this.config.repoPath, task.streamId, {
616
+ from: task.startCommit,
617
+ createdBy: agentId,
618
+ });
619
+ return checkpoints;
620
+ }
621
+ catch (error) {
622
+ console.error(`[GitCascadeAdapter] Failed to create checkpoints for task ${taskId}:`, error);
623
+ return [];
624
+ }
625
+ }
626
+ // ─────────────────────────────────────────────────────────────────────────────
627
+ // Commit Operations
628
+ // ─────────────────────────────────────────────────────────────────────────────
629
+ /**
630
+ * Commit changes in a worktree with Change tracking.
631
+ *
632
+ * @param options - Commit options
633
+ * @returns Commit hash and change ID
634
+ */
635
+ commitChanges(options) {
636
+ return this.tracker.commitChanges(options);
637
+ }
638
+ // ─────────────────────────────────────────────────────────────────────────────
639
+ // Maintenance Operations
640
+ // ─────────────────────────────────────────────────────────────────────────────
641
+ /**
642
+ * Clean up old worker branches.
643
+ *
644
+ * Deletes branches for:
645
+ * - Completed tasks older than threshold (default 24h)
646
+ * - Abandoned tasks
647
+ * - Orphaned branches (no task record)
648
+ *
649
+ * @param options - Cleanup options
650
+ * @returns Deleted branches and any errors
651
+ */
652
+ cleanupWorkerBranches(options) {
653
+ return workerTasks.cleanupWorkerBranches(this.tracker.db, this.config.repoPath, options);
654
+ }
655
+ /**
656
+ * Delete a specific worker branch.
657
+ *
658
+ * @param branchName - Branch name to delete
659
+ * @returns true if deleted, false if branch didn't exist
660
+ */
661
+ deleteWorkerBranch(branchName) {
662
+ try {
663
+ const { execSync } = require('child_process');
664
+ execSync(`git branch -D "${branchName}"`, {
665
+ cwd: this.config.repoPath,
666
+ stdio: 'pipe',
667
+ });
668
+ return true;
669
+ }
670
+ catch {
671
+ return false;
672
+ }
673
+ }
674
+ // ─────────────────────────────────────────────────────────────────────────────
675
+ // Change Operations (Change-Id tracking)
676
+ // ─────────────────────────────────────────────────────────────────────────────
677
+ /**
678
+ * Get a change by ID.
679
+ */
680
+ getChange(changeId) {
681
+ return this.tracker.getChange(changeId);
682
+ }
683
+ /**
684
+ * Get a change by its current commit hash.
685
+ */
686
+ getChangeByCommit(commit) {
687
+ return this.tracker.getChangeByCommit(commit);
688
+ }
689
+ /**
690
+ * Get a change by any of its historical commit hashes (survives rebases).
691
+ */
692
+ getChangeByHistoricalCommit(commit) {
693
+ return this.tracker.getChangeByHistoricalCommit(commit);
694
+ }
695
+ /**
696
+ * List changes for a stream, optionally filtered by status.
697
+ */
698
+ getChangesForStream(streamId, options) {
699
+ return this.tracker.getChangesForStream(streamId, options);
700
+ }
701
+ /**
702
+ * Mark changes as merged.
703
+ */
704
+ markChangesMerged(changeIds) {
705
+ this.tracker.markChangesMerged(changeIds);
706
+ for (const id of changeIds) {
707
+ this.emit('change:merged', { changeId: id });
708
+ }
709
+ }
710
+ /**
711
+ * Mark a single change as dropped.
712
+ */
713
+ markChangeDropped(changeId) {
714
+ this.tracker.markChangeDropped(changeId);
715
+ this.emit('change:dropped', { changeId });
716
+ }
717
+ // ─────────────────────────────────────────────────────────────────────────────
718
+ // Merge Queue (git-cascade built-in)
719
+ // ─────────────────────────────────────────────────────────────────────────────
720
+ /**
721
+ * Add a stream to the merge queue. Local `mergeQueue:added` event fires
722
+ * via forwardCascadeEvent (git-cascade 0.0.7+ emits queue.added natively).
723
+ */
724
+ addToMergeQueue(options) {
725
+ return this.tracker.addToMergeQueue(options);
726
+ }
727
+ /**
728
+ * Get a merge queue entry by id.
729
+ */
730
+ getMergeQueueEntry(entryId) {
731
+ return this.tracker.getMergeQueueEntry(entryId);
732
+ }
733
+ /**
734
+ * List merge queue entries with optional filters.
735
+ */
736
+ listMergeQueue(options) {
737
+ return this.tracker.getMergeQueue(options);
738
+ }
739
+ /**
740
+ * Mark a queue entry as ready to merge. Local `mergeQueue:ready` event
741
+ * fires via forwardCascadeEvent (git-cascade 0.0.7+).
742
+ */
743
+ markMergeQueueReady(entryId) {
744
+ this.tracker.markMergeQueueReady(entryId);
745
+ }
746
+ /**
747
+ * Cancel a queue entry. Local `mergeQueue:cancelled` event fires via
748
+ * forwardCascadeEvent (git-cascade 0.0.7+).
749
+ */
750
+ cancelMergeQueueEntry(entryId) {
751
+ this.tracker.cancelMergeQueueEntry(entryId);
752
+ }
753
+ /**
754
+ * Remove a queue entry. Local `mergeQueue:removed` event fires via
755
+ * forwardCascadeEvent (git-cascade 0.0.7+).
756
+ */
757
+ removeFromMergeQueue(entryId) {
758
+ this.tracker.removeFromMergeQueue(entryId);
759
+ }
760
+ /**
761
+ * Get the next entry to process for a target branch.
762
+ */
763
+ getNextToMerge(targetBranch) {
764
+ return this.tracker.getNextToMerge(targetBranch);
765
+ }
766
+ /**
767
+ * Process the merge queue — drains ready entries per provided handler.
768
+ */
769
+ processMergeQueue(options) {
770
+ return this.tracker.processMergeQueue(options);
771
+ }
772
+ /**
773
+ * Get a stream's position in the queue (lower = sooner).
774
+ */
775
+ getMergeQueuePosition(streamId, targetBranch) {
776
+ return this.tracker.getMergeQueuePosition(streamId, targetBranch);
777
+ }
778
+ // ─────────────────────────────────────────────────────────────────────────────
779
+ // Conflict Operations
780
+ // ─────────────────────────────────────────────────────────────────────────────
781
+ /**
782
+ * Create a conflict record.
783
+ *
784
+ * Usually conflicts are created implicitly by merge/rebase operations.
785
+ * This is for explicit creation (e.g., an external process detected a
786
+ * conflict that git-cascade didn't).
787
+ */
788
+ createConflict(options) {
789
+ const id = this.tracker.createConflict(options);
790
+ this.emit('conflict:created', {
791
+ conflictId: id,
792
+ streamId: options.streamId,
793
+ });
794
+ return id;
795
+ }
796
+ /**
797
+ * Get a conflict record by id.
798
+ */
799
+ getConflict(conflictId) {
800
+ return this.tracker.getConflict(conflictId);
801
+ }
802
+ /**
803
+ * Get the active conflict record for a stream, if any.
804
+ */
805
+ getConflictForStream(streamId) {
806
+ return this.tracker.getConflictForStream(streamId);
807
+ }
808
+ /**
809
+ * Emit a `stream:pushed` event for trunk-style landing strategies that push
810
+ * to a remote rather than merging into another stream. Strategies call this
811
+ * after a successful push so observers (the OpenHive cascade-bridge) can
812
+ * surface the push as `x-cascade/stream.pushed`.
813
+ */
814
+ notifyStreamPushed(args) {
815
+ this.emit('stream:pushed', {
816
+ streamId: args.streamId,
817
+ agentId: args.agentId,
818
+ pushedCommit: args.pushedCommit,
819
+ remote: args.remote,
820
+ remoteRef: args.remoteRef,
821
+ strategy: args.strategy,
822
+ metadata: args.metadata,
823
+ });
824
+ }
825
+ /**
826
+ * Mark a conflict as resolved. Routes through git-cascade's tracker so
827
+ * `x-cascade/stream.conflict_resolved` fires for hub observers (closes
828
+ * cascade_conflicts.status from pending → resolved on the OpenHive side).
829
+ */
830
+ resolveConflict(args) {
831
+ this.tracker.resolveConflict(args.conflictId, args.resolution, {
832
+ metadata: args.metadata,
833
+ });
834
+ }
835
+ /**
836
+ * Abandon a conflict (stream-level give-up). Emits a
837
+ * `stream.conflict_resolved` event with method='abandoned' so observers
838
+ * see the conflict is no longer pending.
839
+ */
840
+ abandonConflict(args) {
841
+ this.tracker.abandonConflict(args.conflictId, {
842
+ agentId: args.agentId,
843
+ reason: args.reason,
844
+ metadata: args.metadata,
845
+ });
846
+ }
847
+ // ─────────────────────────────────────────────────────────────────────────────
848
+ // Reconciliation
849
+ // ─────────────────────────────────────────────────────────────────────────────
850
+ /**
851
+ * Check if a stream's database state is in sync with its git branch.
852
+ */
853
+ checkStreamSync(streamId) {
854
+ return this.tracker.checkStreamSync(streamId);
855
+ }
856
+ /**
857
+ * Check all active streams for sync status.
858
+ */
859
+ checkAllStreamsSync(options) {
860
+ return this.tracker.checkAllStreamsSync(options);
861
+ }
862
+ /**
863
+ * Reconcile database state with git state. Fixes missing branches, resets
864
+ * diverged HEAD (per options), etc. Does NOT handle orphan worktrees — the
865
+ * macro-agent-level reconcile wrapper covers that.
866
+ */
867
+ reconcile(options) {
868
+ return this.tracker.reconcile(options);
869
+ }
870
+ /**
871
+ * Ensure a stream is in sync before performing an operation.
872
+ * @throws DesyncError if out of sync unless `force: true`.
873
+ */
874
+ ensureStreamInSync(streamId, options) {
875
+ this.tracker.ensureStreamInSync(streamId, options);
876
+ }
877
+ // ─────────────────────────────────────────────────────────────────────────────
878
+ // Health & Recovery
879
+ // ─────────────────────────────────────────────────────────────────────────────
880
+ /**
881
+ * Check system health.
882
+ */
883
+ healthCheck() {
884
+ return this.tracker.healthCheck();
885
+ }
886
+ // ─────────────────────────────────────────────────────────────────────────────
887
+ // Lifecycle
888
+ // ─────────────────────────────────────────────────────────────────────────────
889
+ /**
890
+ * Close the adapter and release resources.
891
+ *
892
+ * Only closes the database if we created it (not if using shared DB).
893
+ */
894
+ close() {
895
+ this.eventListeners.clear();
896
+ this.tracker.close();
897
+ }
898
+ }
899
+ /**
900
+ * Create a GitCascadeAdapter instance.
901
+ *
902
+ * @param config - Configuration options
903
+ * @returns GitCascadeAdapter instance
904
+ */
905
+ export function createGitCascadeAdapter(config) {
906
+ return new GitCascadeAdapter(config);
907
+ }
908
+ //# sourceMappingURL=git-cascade-adapter.js.map