macro-agent 0.1.8 → 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 (258) hide show
  1. package/CLAUDE.md +166 -33
  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 -43
  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 +16 -1
  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 -1
  55. package/dist/map/lifecycle-bridge.d.ts.map +1 -1
  56. package/dist/map/lifecycle-bridge.js +58 -23
  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 -2
  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 +66 -0
  197. package/src/agent/__tests__/task-ref-resolution.test.ts +231 -0
  198. package/src/agent/agent-manager-v2.ts +293 -48
  199. package/src/agent/agent-manager.ts +14 -0
  200. package/src/agent/types.ts +16 -2
  201. package/src/boot-v2.ts +68 -1
  202. package/src/cli/index.ts +61 -0
  203. package/src/cognitive/macro-agent-backend.ts +45 -29
  204. package/src/integrations/skilltree.ts +1 -0
  205. package/src/lifecycle/cleanup.ts +52 -3
  206. package/src/lifecycle/handlers-v2.ts +40 -3
  207. package/src/lifecycle/types.ts +12 -0
  208. package/src/map/__tests__/cascade-bridge.test.ts +229 -0
  209. package/src/map/__tests__/lifecycle-bridge.test.ts +86 -10
  210. package/src/map/acp-bridge.ts +26 -3
  211. package/src/map/cascade-bridge.ts +301 -0
  212. package/src/map/lifecycle-bridge.ts +52 -17
  213. package/src/map/server.ts +47 -6
  214. package/src/map/sidecar.ts +31 -1
  215. package/src/map/types.ts +20 -0
  216. package/src/mcp/tools/done-v2.ts +9 -0
  217. package/src/teams/team-manager-v2.ts +37 -0
  218. package/src/teams/team-runtime-v2.ts +23 -3
  219. package/src/workspace/__tests__/{dataplane-adapter.test.ts → git-cascade-adapter.test.ts} +209 -14
  220. package/src/workspace/__tests__/self-driving-yaml.test.ts +114 -0
  221. package/src/workspace/__tests__/shared-worktree-refcount.test.ts +154 -0
  222. package/src/workspace/__tests__/standalone-mode.test.ts +118 -0
  223. package/src/workspace/__tests__/workspace-manager-v3.test.ts +245 -0
  224. package/src/workspace/__tests__/yaml-schema.test.ts +210 -0
  225. package/src/workspace/config.ts +11 -11
  226. package/src/workspace/git-cascade-adapter.ts +1186 -0
  227. package/src/workspace/index.ts +11 -11
  228. package/src/workspace/landing/__tests__/strategies.test.ts +142 -0
  229. package/src/workspace/landing/direct-push.ts +91 -0
  230. package/src/workspace/landing/index.ts +40 -0
  231. package/src/workspace/landing/merge-to-parent.ts +228 -0
  232. package/src/workspace/landing/optimistic-push.ts +36 -0
  233. package/src/workspace/landing/queue-to-branch.ts +108 -0
  234. package/src/workspace/merge-queue/merge-queue.ts +10 -0
  235. package/src/workspace/merge-queue/types.ts +16 -2
  236. package/src/workspace/pool/__tests__/worktree-pool.integration.test.ts +5 -5
  237. package/src/workspace/pool/types.ts +1 -0
  238. package/src/workspace/pool/worktree-pool.ts +1 -0
  239. package/src/workspace/recovery/__tests__/auto-resolve-integration.test.ts +127 -0
  240. package/src/workspace/recovery/__tests__/spawn-resolver.test.ts +139 -0
  241. package/src/workspace/recovery/__tests__/strategies.test.ts +145 -0
  242. package/src/workspace/recovery/abandon.ts +51 -0
  243. package/src/workspace/recovery/auto-resolve.ts +119 -0
  244. package/src/workspace/recovery/defer.ts +23 -0
  245. package/src/workspace/recovery/escalate.ts +30 -0
  246. package/src/workspace/recovery/index.ts +58 -0
  247. package/src/workspace/recovery/spawn-resolver.ts +145 -0
  248. package/src/workspace/recovery/types.ts +54 -0
  249. package/src/workspace/topology/__tests__/yaml-driven.test.ts +345 -0
  250. package/src/workspace/topology/index.ts +18 -0
  251. package/src/workspace/topology/no-workspace.ts +39 -0
  252. package/src/workspace/topology/types.ts +116 -0
  253. package/src/workspace/topology/yaml-driven.ts +316 -0
  254. package/src/workspace/types-v3.ts +155 -0
  255. package/src/workspace/types.ts +191 -20
  256. package/src/workspace/workspace-manager.ts +474 -19
  257. package/src/workspace/yaml-schema.ts +216 -0
  258. package/src/workspace/dataplane-adapter.ts +0 -546
@@ -29,7 +29,7 @@ export type TaskId = string;
29
29
  /**
30
30
  * Agent role types that require workspaces
31
31
  */
32
- export type WorkspaceRole = 'worker' | 'integrator' | 'coordinator';
32
+ export type WorkspaceRole = 'worker' | 'integrator' | 'coordinator' | 'v3';
33
33
 
34
34
  /**
35
35
  * Workspace represents an isolated git worktree assigned to an agent.
@@ -162,18 +162,22 @@ export interface CleanupStatus {
162
162
  /**
163
163
  * WorkspaceManager interface for managing agent workspaces.
164
164
  *
165
- * Bridges macro-agent roles to dataplane streams and worktrees.
165
+ * Bridges macro-agent roles to git-cascade streams and worktrees.
166
166
  *
167
167
  * @see [[s-7ktd]] WorkspaceManager API section
168
168
  */
169
169
  export interface WorkspaceManager {
170
170
  // ─────────────────────────────────────────────────────────────────────────────
171
- // Stream Management
171
+ // Stream Management (role-shaped; coexists with V3 stream-first surface below)
172
172
  // ─────────────────────────────────────────────────────────────────────────────
173
173
 
174
174
  /**
175
175
  * Create an integration stream for a coordinator.
176
176
  *
177
+ * Role-shaped convenience method. For stream-first semantics (fork from
178
+ * another stream, pseudo-principal ownership, richer metadata), prefer
179
+ * `createStreamV3({ name, ownerId, forkFrom, parent?, metadata? })`.
180
+ *
177
181
  * @param coordinatorId - ID of the coordinator agent
178
182
  * @param config - Stream configuration
179
183
  * @returns Stream ID
@@ -189,16 +193,14 @@ export interface WorkspaceManager {
189
193
  getStream(streamId: StreamId): Stream | null;
190
194
 
191
195
  // ─────────────────────────────────────────────────────────────────────────────
192
- // Worktree Management
196
+ // Worktree Management (role-shaped; V3 `allocateWorktree` is role-neutral)
193
197
  // ─────────────────────────────────────────────────────────────────────────────
194
198
 
195
199
  /**
196
200
  * Create a workspace for a worker agent.
197
201
  *
198
- * @param workerId - ID of the worker agent
199
- * @param taskId - ID of the task to work on
200
- * @param streamId - ID of the integration stream
201
- * @returns Worker workspace
202
+ * Role-shaped convenience. For role-neutral allocation, prefer
203
+ * `allocateWorktree({ agentId, streamId })`.
202
204
  */
203
205
  createWorkerWorkspace(
204
206
  workerId: AgentId,
@@ -209,9 +211,8 @@ export interface WorkspaceManager {
209
211
  /**
210
212
  * Create a workspace for an integrator agent.
211
213
  *
212
- * @param integratorId - ID of the integrator agent
213
- * @param streamId - ID of the integration stream
214
- * @returns Integrator workspace
214
+ * Role-shaped convenience. For role-neutral allocation, prefer
215
+ * `allocateWorktree({ agentId, streamId })`.
215
216
  */
216
217
  createIntegratorWorkspace(
217
218
  integratorId: AgentId,
@@ -221,9 +222,8 @@ export interface WorkspaceManager {
221
222
  /**
222
223
  * Create a workspace for a coordinator agent.
223
224
  *
224
- * @param coordinatorId - ID of the coordinator agent
225
- * @param streamId - ID of the integration stream
226
- * @returns Coordinator workspace
225
+ * Role-shaped convenience. For role-neutral allocation, prefer
226
+ * `allocateWorktree({ agentId, streamId })`.
227
227
  */
228
228
  createCoordinatorWorkspace(
229
229
  coordinatorId: AgentId,
@@ -238,12 +238,15 @@ export interface WorkspaceManager {
238
238
  deallocateWorkspace(agentId: AgentId): void;
239
239
 
240
240
  // ─────────────────────────────────────────────────────────────────────────────
241
- // Task Management
241
+ // Task Management (LEGACY — git-cascade task semantics; not used by V3)
242
242
  // ─────────────────────────────────────────────────────────────────────────────
243
243
 
244
244
  /**
245
245
  * Create a task under a stream.
246
246
  *
247
+ * @deprecated V3 does not use git-cascade's `workerTasks` layer for
248
+ * task tracking; use opentasks via `TasksAdapter` instead. This method
249
+ * exists only for the legacy capability-based dispatch path.
247
250
  * @param streamId - ID of the integration stream
248
251
  * @param options - Task creation options
249
252
  * @returns Task ID
@@ -253,6 +256,10 @@ export interface WorkspaceManager {
253
256
  /**
254
257
  * Claim a task for a worker.
255
258
  *
259
+ * @deprecated See `createTask` — V3 uses opentasks. This method cuts the
260
+ * git-cascade worker branch via `startTask`; V3 equivalent is
261
+ * `allocateWorktree({ agentId, streamId })` + `commitChanges` on the
262
+ * stream branch directly.
256
263
  * @param taskId - ID of the task to claim
257
264
  * @param workerId - ID of the worker agent
258
265
  * @param worktree - Path to the worker's worktree
@@ -263,6 +270,8 @@ export interface WorkspaceManager {
263
270
  /**
264
271
  * Get the next available task for a stream.
265
272
  *
273
+ * @deprecated Use opentasks for task queueing; git-cascade's worker task
274
+ * layer is redundant in V3.
266
275
  * @param streamId - ID of the integration stream
267
276
  * @returns Next task or null if none available
268
277
  */
@@ -308,13 +317,146 @@ export interface WorkspaceManager {
308
317
  /**
309
318
  * Get the merge queue for coordinating worker merges.
310
319
  *
311
- * The merge queue is shared across all streams and uses the same
312
- * database as the dataplane adapter.
320
+ * @deprecated Use git-cascade's built-in queue via the V3 surface
321
+ * `workspaceManager.addToMergeQueue` (when exposed) or the
322
+ * `queue-to-branch` `LandingStrategy`. This method returns the legacy
323
+ * macro-agent MergeQueue that duplicates git-cascade's schema; kept for
324
+ * legacy callers until teams migrate to `macro_agent.workspace` YAML.
313
325
  *
314
- * @returns MergeQueue instance
326
+ * @returns Legacy MergeQueue instance (duplicate of git-cascade's queue)
315
327
  */
316
328
  getMergeQueue(): MergeQueueInterface;
317
329
 
330
+ // ─────────────────────────────────────────────────────────────────────────────
331
+ // V3 — Stream-first surface (additive; coexists with role-shaped methods above)
332
+ // ─────────────────────────────────────────────────────────────────────────────
333
+
334
+ /**
335
+ * Create a new stream. Stream-first equivalent of `createIntegrationStream`;
336
+ * does not require a coordinator owner — any `Principal` (including pseudo
337
+ * principals like `team:<name>`) can own.
338
+ *
339
+ * @see docs/workspace-interfaces.md §5
340
+ */
341
+ createStreamV3(spec: import('./types-v3.js').StreamSpec): StreamId;
342
+
343
+ /**
344
+ * Fork a child stream from a parent. Enables stacking workflows (solo stack,
345
+ * long-lived feature + subtasks).
346
+ */
347
+ forkStream(opts: {
348
+ parentStreamId: StreamId;
349
+ name: string;
350
+ ownerId: import('./types-v3.js').Principal;
351
+ metadata?: Record<string, unknown>;
352
+ }): StreamId;
353
+
354
+ /**
355
+ * Merge a source stream into a target stream.
356
+ */
357
+ mergeStream(opts: {
358
+ sourceStreamId: StreamId;
359
+ targetStreamId: StreamId;
360
+ agentId: import('./types-v3.js').Principal;
361
+ worktree: string;
362
+ }): import('./types-v3.js').MergeResult;
363
+
364
+ /**
365
+ * Rebase a stream onto its parent.
366
+ */
367
+ syncWithParent(opts: {
368
+ streamId: StreamId;
369
+ agentId: import('./types-v3.js').Principal;
370
+ worktree: string;
371
+ onConflict?: import('./types-v3.js').ConflictStrategy;
372
+ }): import('./types-v3.js').RebaseResult;
373
+
374
+ /**
375
+ * Lifecycle transitions for streams.
376
+ */
377
+ abandonStream(streamId: StreamId, opts?: { cascade?: boolean; reason?: string }): void;
378
+ pauseStream(streamId: StreamId, reason?: string): void;
379
+ resumeStream(streamId: StreamId): void;
380
+
381
+ /**
382
+ * Stream queries.
383
+ */
384
+ listStreams(filter?: {
385
+ ownerId?: import('./types-v3.js').Principal;
386
+ status?: import('./types-v3.js').Stream['status'];
387
+ }): import('./types-v3.js').Stream[];
388
+
389
+ /**
390
+ * Commit with Change-Id tracking. Use this instead of raw `git commit` when
391
+ * committing on behalf of a streamed agent.
392
+ */
393
+ commitChanges(opts: {
394
+ agentId: import('./types-v3.js').Principal;
395
+ streamId: StreamId;
396
+ worktree: string;
397
+ message: string;
398
+ }): { commit: string; changeId: import('./types-v3.js').ChangeId };
399
+
400
+ /**
401
+ * Mark a set of changes as merged (e.g., after a landing strategy completes).
402
+ */
403
+ markChangesMerged(changeIds: import('./types-v3.js').ChangeId[]): void;
404
+
405
+ getChange(changeId: import('./types-v3.js').ChangeId): import('./types-v3.js').Change | null;
406
+ getChangeByCommit(commit: string): import('./types-v3.js').Change | null;
407
+
408
+ /**
409
+ * Allocate a worktree for an agent, optionally attached to a stream.
410
+ * Stream-first equivalent of `createWorker/Integrator/CoordinatorWorkspace`.
411
+ */
412
+ allocateWorktree(opts: import('./types-v3.js').AllocateWorktreeOpts): import('./types-v3.js').Worktree;
413
+
414
+ /**
415
+ * Get the worktree owned by a principal (if any).
416
+ */
417
+ getWorktreeForAgent(agentId: import('./types-v3.js').Principal): import('./types-v3.js').Worktree | null;
418
+
419
+ /**
420
+ * Register a landing strategy. Registered strategies can be referenced by
421
+ * name from role YAML (see Phase 5 — `LandingStrategy` integration).
422
+ */
423
+ registerLandingStrategy(strategy: import('./types-v3.js').LandingStrategy): void;
424
+
425
+ /**
426
+ * Run macro-level reconciliation:
427
+ * - Delegates to git-cascade's `reconcile()` for stream↔git sync.
428
+ * - Cleans up orphan worktrees and stale pool entries.
429
+ * Intended to be called once on boot.
430
+ */
431
+ reconcileV3(): import('./types-v3.js').MacroReconcileResult;
432
+
433
+ /**
434
+ * Resolve a conflict record (typically called by a resolver agent via the
435
+ * `resolve_conflict` MCP tool after it fixes conflict markers and commits).
436
+ * Emits `conflict:resolved` event.
437
+ */
438
+ resolveConflict(opts: {
439
+ conflictId: string;
440
+ resolvedBy: import('./types-v3.js').Principal;
441
+ resolutionCommit?: string;
442
+ /** How the conflict was resolved. Default 'agent'. */
443
+ method?:
444
+ | 'ours'
445
+ | 'theirs'
446
+ | 'manual'
447
+ | 'agent'
448
+ | 'auto-resolve'
449
+ | 'spawn-resolver'
450
+ | 'abandoned';
451
+ /** Human-readable resolution summary. */
452
+ summary?: string;
453
+ }): void;
454
+
455
+ /**
456
+ * Subscribe to workspace events. Returns an unsubscribe function.
457
+ */
458
+ onEvent(callback: WorkspaceEventCallback): () => void;
459
+
318
460
  // ─────────────────────────────────────────────────────────────────────────────
319
461
  // Lifecycle
320
462
  // ─────────────────────────────────────────────────────────────────────────────
@@ -326,14 +468,43 @@ export interface WorkspaceManager {
326
468
  }
327
469
 
328
470
  /**
329
- * Events emitted by WorkspaceManager
471
+ * Events emitted by WorkspaceManager.
472
+ *
473
+ * Legacy events (`workspace:*`, `child:*`, `branches:*`, `branch:*`) drive the
474
+ * existing role-shaped lifecycle. V3 events (`stream:*`, `worktree:*`,
475
+ * `change:*`, `conflict:*`, `landing:*`, `cascade:*`, `mergeQueue:*`) drive the
476
+ * stream-first redesign and are re-emitted from the underlying git-cascade
477
+ * adapter. Consumers narrow on the type string.
330
478
  */
331
479
  export type WorkspaceEventType =
332
480
  | 'workspace:created'
333
481
  | 'workspace:deallocated'
334
482
  | 'child:registered'
335
483
  | 'branches:cleaned'
336
- | 'branch:deleted';
484
+ | 'branch:deleted'
485
+ // V3 additions — stream-first lifecycle
486
+ | 'stream:created'
487
+ | 'stream:forked'
488
+ | 'stream:committed'
489
+ | 'stream:merged'
490
+ | 'stream:conflicted'
491
+ | 'stream:abandoned'
492
+ | 'stream:paused'
493
+ | 'stream:resumed'
494
+ | 'worktree:allocated'
495
+ | 'worktree:shared'
496
+ | 'worktree:released'
497
+ | 'change:merged'
498
+ | 'change:dropped'
499
+ | 'conflict:created'
500
+ | 'conflict:resolved'
501
+ | 'landing:started'
502
+ | 'landing:completed'
503
+ | 'cascade:completed'
504
+ | 'mergeQueue:added'
505
+ | 'mergeQueue:ready'
506
+ | 'mergeQueue:cancelled'
507
+ | 'mergeQueue:removed';
337
508
 
338
509
  /**
339
510
  * Event payload for workspace events