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.
- package/CLAUDE.md +179 -38
- package/README.md +781 -131
- package/dist/acp/claude-code-replay.d.ts +11 -0
- package/dist/acp/claude-code-replay.d.ts.map +1 -0
- package/dist/acp/claude-code-replay.js +190 -0
- package/dist/acp/claude-code-replay.js.map +1 -0
- package/dist/acp/macro-agent.d.ts.map +1 -1
- package/dist/acp/macro-agent.js +155 -6
- package/dist/acp/macro-agent.js.map +1 -1
- package/dist/acp/types.d.ts +9 -0
- package/dist/acp/types.d.ts.map +1 -1
- package/dist/acp/types.js.map +1 -1
- package/dist/agent/agent-manager-v2.d.ts +21 -0
- package/dist/agent/agent-manager-v2.d.ts.map +1 -1
- package/dist/agent/agent-manager-v2.js +234 -71
- package/dist/agent/agent-manager-v2.js.map +1 -1
- package/dist/agent/agent-manager.d.ts +12 -0
- package/dist/agent/agent-manager.d.ts.map +1 -1
- package/dist/agent/agent-manager.js.map +1 -1
- package/dist/agent/types.d.ts +15 -2
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/boot-v2.d.ts +41 -0
- package/dist/boot-v2.d.ts.map +1 -1
- package/dist/boot-v2.js +34 -37
- package/dist/boot-v2.js.map +1 -1
- package/dist/cli/index.js +56 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cognitive/macro-agent-backend.d.ts.map +1 -1
- package/dist/cognitive/macro-agent-backend.js +40 -22
- package/dist/cognitive/macro-agent-backend.js.map +1 -1
- package/dist/integrations/skilltree.d.ts.map +1 -1
- package/dist/integrations/skilltree.js +1 -0
- package/dist/integrations/skilltree.js.map +1 -1
- package/dist/lifecycle/cleanup.d.ts +33 -2
- package/dist/lifecycle/cleanup.d.ts.map +1 -1
- package/dist/lifecycle/cleanup.js +28 -6
- package/dist/lifecycle/cleanup.js.map +1 -1
- package/dist/lifecycle/handlers-v2.d.ts +7 -0
- package/dist/lifecycle/handlers-v2.d.ts.map +1 -1
- package/dist/lifecycle/handlers-v2.js +28 -2
- package/dist/lifecycle/handlers-v2.js.map +1 -1
- package/dist/lifecycle/types.d.ts +11 -0
- package/dist/lifecycle/types.d.ts.map +1 -1
- package/dist/lifecycle/types.js.map +1 -1
- package/dist/map/acp-bridge.d.ts +9 -0
- package/dist/map/acp-bridge.d.ts.map +1 -1
- package/dist/map/acp-bridge.js +15 -2
- package/dist/map/acp-bridge.js.map +1 -1
- package/dist/map/cascade-bridge.d.ts +44 -0
- package/dist/map/cascade-bridge.d.ts.map +1 -0
- package/dist/map/cascade-bridge.js +257 -0
- package/dist/map/cascade-bridge.js.map +1 -0
- package/dist/map/lifecycle-bridge.d.ts +1 -8
- package/dist/map/lifecycle-bridge.d.ts.map +1 -1
- package/dist/map/lifecycle-bridge.js +76 -22
- package/dist/map/lifecycle-bridge.js.map +1 -1
- package/dist/map/server.d.ts.map +1 -1
- package/dist/map/server.js +47 -6
- package/dist/map/server.js.map +1 -1
- package/dist/map/sidecar.d.ts.map +1 -1
- package/dist/map/sidecar.js +33 -4
- package/dist/map/sidecar.js.map +1 -1
- package/dist/map/types.d.ts +20 -0
- package/dist/map/types.d.ts.map +1 -1
- package/dist/mcp/tools/done-v2.d.ts.map +1 -1
- package/dist/mcp/tools/done-v2.js +8 -0
- package/dist/mcp/tools/done-v2.js.map +1 -1
- package/dist/teams/team-manager-v2.d.ts.map +1 -1
- package/dist/teams/team-manager-v2.js +26 -0
- package/dist/teams/team-manager-v2.js.map +1 -1
- package/dist/teams/team-runtime-v2.d.ts.map +1 -1
- package/dist/teams/team-runtime-v2.js +16 -3
- package/dist/teams/team-runtime-v2.js.map +1 -1
- package/dist/workspace/config.d.ts +10 -10
- package/dist/workspace/config.d.ts.map +1 -1
- package/dist/workspace/config.js +4 -4
- package/dist/workspace/config.js.map +1 -1
- package/dist/workspace/git-cascade-adapter.d.ts +510 -0
- package/dist/workspace/git-cascade-adapter.d.ts.map +1 -0
- package/dist/workspace/git-cascade-adapter.js +908 -0
- package/dist/workspace/git-cascade-adapter.js.map +1 -0
- package/dist/workspace/index.d.ts +3 -3
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +4 -4
- package/dist/workspace/index.js.map +1 -1
- package/dist/workspace/landing/direct-push.d.ts +20 -0
- package/dist/workspace/landing/direct-push.d.ts.map +1 -0
- package/dist/workspace/landing/direct-push.js +74 -0
- package/dist/workspace/landing/direct-push.js.map +1 -0
- package/dist/workspace/landing/index.d.ts +29 -0
- package/dist/workspace/landing/index.d.ts.map +1 -0
- package/dist/workspace/landing/index.js +37 -0
- package/dist/workspace/landing/index.js.map +1 -0
- package/dist/workspace/landing/merge-to-parent.d.ts +41 -0
- package/dist/workspace/landing/merge-to-parent.d.ts.map +1 -0
- package/dist/workspace/landing/merge-to-parent.js +185 -0
- package/dist/workspace/landing/merge-to-parent.js.map +1 -0
- package/dist/workspace/landing/optimistic-push.d.ts +16 -0
- package/dist/workspace/landing/optimistic-push.d.ts.map +1 -0
- package/dist/workspace/landing/optimistic-push.js +27 -0
- package/dist/workspace/landing/optimistic-push.js.map +1 -0
- package/dist/workspace/landing/queue-to-branch.d.ts +24 -0
- package/dist/workspace/landing/queue-to-branch.d.ts.map +1 -0
- package/dist/workspace/landing/queue-to-branch.js +79 -0
- package/dist/workspace/landing/queue-to-branch.js.map +1 -0
- package/dist/workspace/merge-queue/merge-queue.d.ts +10 -0
- package/dist/workspace/merge-queue/merge-queue.d.ts.map +1 -1
- package/dist/workspace/merge-queue/merge-queue.js +10 -0
- package/dist/workspace/merge-queue/merge-queue.js.map +1 -1
- package/dist/workspace/merge-queue/types.d.ts +16 -2
- package/dist/workspace/merge-queue/types.d.ts.map +1 -1
- package/dist/workspace/merge-queue/types.js +9 -0
- package/dist/workspace/merge-queue/types.js.map +1 -1
- package/dist/workspace/pool/types.d.ts +1 -0
- package/dist/workspace/pool/types.d.ts.map +1 -1
- package/dist/workspace/pool/worktree-pool.d.ts.map +1 -1
- package/dist/workspace/pool/worktree-pool.js +1 -0
- package/dist/workspace/pool/worktree-pool.js.map +1 -1
- package/dist/workspace/recovery/abandon.d.ts +15 -0
- package/dist/workspace/recovery/abandon.d.ts.map +1 -0
- package/dist/workspace/recovery/abandon.js +45 -0
- package/dist/workspace/recovery/abandon.js.map +1 -0
- package/dist/workspace/recovery/auto-resolve.d.ts +27 -0
- package/dist/workspace/recovery/auto-resolve.d.ts.map +1 -0
- package/dist/workspace/recovery/auto-resolve.js +99 -0
- package/dist/workspace/recovery/auto-resolve.js.map +1 -0
- package/dist/workspace/recovery/defer.d.ts +15 -0
- package/dist/workspace/recovery/defer.d.ts.map +1 -0
- package/dist/workspace/recovery/defer.js +16 -0
- package/dist/workspace/recovery/defer.js.map +1 -0
- package/dist/workspace/recovery/escalate.d.ts +16 -0
- package/dist/workspace/recovery/escalate.d.ts.map +1 -0
- package/dist/workspace/recovery/escalate.js +24 -0
- package/dist/workspace/recovery/escalate.js.map +1 -0
- package/dist/workspace/recovery/index.d.ts +32 -0
- package/dist/workspace/recovery/index.d.ts.map +1 -0
- package/dist/workspace/recovery/index.js +45 -0
- package/dist/workspace/recovery/index.js.map +1 -0
- package/dist/workspace/recovery/spawn-resolver.d.ts +45 -0
- package/dist/workspace/recovery/spawn-resolver.d.ts.map +1 -0
- package/dist/workspace/recovery/spawn-resolver.js +111 -0
- package/dist/workspace/recovery/spawn-resolver.js.map +1 -0
- package/dist/workspace/recovery/types.d.ts +63 -0
- package/dist/workspace/recovery/types.d.ts.map +1 -0
- package/dist/workspace/recovery/types.js +12 -0
- package/dist/workspace/recovery/types.js.map +1 -0
- package/dist/workspace/topology/index.d.ts +9 -0
- package/dist/workspace/topology/index.d.ts.map +1 -0
- package/dist/workspace/topology/index.js +8 -0
- package/dist/workspace/topology/index.js.map +1 -0
- package/dist/workspace/topology/no-workspace.d.ts +18 -0
- package/dist/workspace/topology/no-workspace.d.ts.map +1 -0
- package/dist/workspace/topology/no-workspace.js +25 -0
- package/dist/workspace/topology/no-workspace.js.map +1 -0
- package/dist/workspace/topology/types.d.ts +97 -0
- package/dist/workspace/topology/types.d.ts.map +1 -0
- package/dist/workspace/topology/types.js +20 -0
- package/dist/workspace/topology/types.js.map +1 -0
- package/dist/workspace/topology/yaml-driven.d.ts +69 -0
- package/dist/workspace/topology/yaml-driven.d.ts.map +1 -0
- package/dist/workspace/topology/yaml-driven.js +273 -0
- package/dist/workspace/topology/yaml-driven.js.map +1 -0
- package/dist/workspace/types-v3.d.ts +110 -0
- package/dist/workspace/types-v3.d.ts.map +1 -0
- package/dist/workspace/types-v3.js +20 -0
- package/dist/workspace/types-v3.js.map +1 -0
- package/dist/workspace/types.d.ts +145 -17
- package/dist/workspace/types.d.ts.map +1 -1
- package/dist/workspace/workspace-manager.d.ts +92 -13
- package/dist/workspace/workspace-manager.d.ts.map +1 -1
- package/dist/workspace/workspace-manager.js +373 -13
- package/dist/workspace/workspace-manager.js.map +1 -1
- package/dist/workspace/yaml-schema.d.ts +254 -0
- package/dist/workspace/yaml-schema.d.ts.map +1 -0
- package/dist/workspace/yaml-schema.js +170 -0
- package/dist/workspace/yaml-schema.js.map +1 -0
- package/docs/conflict-recovery.md +472 -0
- package/docs/git-cascade-integration-gaps.md +678 -0
- package/docs/workspace-interfaces.md +731 -0
- package/docs/workspace-redesign-plan.md +302 -0
- package/package.json +4 -4
- package/src/__tests__/e2e/auto-sync.e2e.test.ts +257 -0
- package/src/__tests__/e2e/cascade-rebase.e2e.test.ts +254 -0
- package/src/__tests__/e2e/cli-run.e2e.test.ts +167 -0
- package/src/__tests__/e2e/self-driving-v3.e2e.test.ts +197 -0
- package/src/__tests__/e2e/spawn-resolver.e2e.test.ts +200 -0
- package/src/__tests__/e2e/workspace-lifecycle.e2e.test.ts +30 -22
- package/src/__tests__/e2e/workspace-v3.e2e.test.ts +413 -0
- package/src/acp/__tests__/claude-code-replay.test.ts +225 -0
- package/src/acp/__tests__/macro-agent.test.ts +39 -1
- package/src/acp/claude-code-replay.ts +208 -0
- package/src/acp/macro-agent.ts +167 -9
- package/src/acp/types.ts +10 -0
- package/src/agent/__tests__/agent-manager-topology.test.ts +73 -0
- package/src/agent/__tests__/agent-manager-v2.test.ts +71 -11
- package/src/agent/__tests__/task-ref-resolution.test.ts +231 -0
- package/src/agent/agent-manager-v2.ts +293 -77
- package/src/agent/agent-manager.ts +14 -0
- package/src/agent/types.ts +16 -2
- package/src/boot-v2.ts +87 -36
- package/src/cli/index.ts +61 -0
- package/src/cognitive/__tests__/macro-agent-backend.test.ts +47 -5
- package/src/cognitive/macro-agent-backend.ts +45 -29
- package/src/integrations/skilltree.ts +1 -0
- package/src/lifecycle/cleanup.ts +52 -3
- package/src/lifecycle/handlers-v2.ts +40 -3
- package/src/lifecycle/types.ts +12 -0
- package/src/map/__tests__/cascade-bridge.test.ts +229 -0
- package/src/map/__tests__/lifecycle-bridge.test.ts +165 -22
- package/src/map/acp-bridge.ts +26 -3
- package/src/map/cascade-bridge.ts +301 -0
- package/src/map/lifecycle-bridge.ts +77 -27
- package/src/map/server.ts +47 -6
- package/src/map/sidecar.ts +31 -3
- package/src/map/types.ts +20 -0
- package/src/mcp/tools/done-v2.ts +9 -0
- package/src/teams/team-manager-v2.ts +37 -0
- package/src/teams/team-runtime-v2.ts +23 -3
- package/src/workspace/__tests__/{dataplane-adapter.test.ts → git-cascade-adapter.test.ts} +209 -14
- package/src/workspace/__tests__/self-driving-yaml.test.ts +114 -0
- package/src/workspace/__tests__/shared-worktree-refcount.test.ts +154 -0
- package/src/workspace/__tests__/standalone-mode.test.ts +118 -0
- package/src/workspace/__tests__/workspace-manager-v3.test.ts +245 -0
- package/src/workspace/__tests__/yaml-schema.test.ts +210 -0
- package/src/workspace/config.ts +11 -11
- package/src/workspace/git-cascade-adapter.ts +1186 -0
- package/src/workspace/index.ts +11 -11
- package/src/workspace/landing/__tests__/strategies.test.ts +142 -0
- package/src/workspace/landing/direct-push.ts +91 -0
- package/src/workspace/landing/index.ts +40 -0
- package/src/workspace/landing/merge-to-parent.ts +228 -0
- package/src/workspace/landing/optimistic-push.ts +36 -0
- package/src/workspace/landing/queue-to-branch.ts +108 -0
- package/src/workspace/merge-queue/merge-queue.ts +10 -0
- package/src/workspace/merge-queue/types.ts +16 -2
- package/src/workspace/pool/__tests__/worktree-pool.integration.test.ts +5 -5
- package/src/workspace/pool/types.ts +1 -0
- package/src/workspace/pool/worktree-pool.ts +1 -0
- package/src/workspace/recovery/__tests__/auto-resolve-integration.test.ts +127 -0
- package/src/workspace/recovery/__tests__/spawn-resolver.test.ts +139 -0
- package/src/workspace/recovery/__tests__/strategies.test.ts +145 -0
- package/src/workspace/recovery/abandon.ts +51 -0
- package/src/workspace/recovery/auto-resolve.ts +119 -0
- package/src/workspace/recovery/defer.ts +23 -0
- package/src/workspace/recovery/escalate.ts +30 -0
- package/src/workspace/recovery/index.ts +58 -0
- package/src/workspace/recovery/spawn-resolver.ts +145 -0
- package/src/workspace/recovery/types.ts +54 -0
- package/src/workspace/topology/__tests__/yaml-driven.test.ts +345 -0
- package/src/workspace/topology/index.ts +18 -0
- package/src/workspace/topology/no-workspace.ts +39 -0
- package/src/workspace/topology/types.ts +116 -0
- package/src/workspace/topology/yaml-driven.ts +316 -0
- package/src/workspace/types-v3.ts +155 -0
- package/src/workspace/types.ts +191 -20
- package/src/workspace/workspace-manager.ts +474 -19
- package/src/workspace/yaml-schema.ts +216 -0
- package/src/workspace/dataplane-adapter.ts +0 -546
package/CLAUDE.md
CHANGED
|
@@ -7,9 +7,10 @@ A multi-agent orchestration system for spawning and managing hierarchical AI cod
|
|
|
7
7
|
macro-agent enables coordinated work across multiple AI agents with:
|
|
8
8
|
- **Role-based agents** (Worker, Integrator, Coordinator, Monitor, Analyst + custom team roles)
|
|
9
9
|
- **Team templates** for declarative multi-agent topologies (YAML config)
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
10
|
+
- **Stream-first workspace layer (V3)** — YAML-driven `TopologyPolicy` compiles role config into per-spawn workspace decisions; falls back to capability-based dispatch for programmatic callers
|
|
11
|
+
- **Pluggable `LandingStrategy`** — `merge-to-parent`, `queue-to-branch`, `direct-push`, `optimistic-push` built-ins; registered on WorkspaceManager, selected per-role via YAML
|
|
12
|
+
- **Pluggable `ConflictRecoveryStrategy`** — `defer`, `abandon`, `escalate`, `auto-resolve` (real git `-X` merge), `spawn-resolver` (LLM resolver agent)
|
|
13
|
+
- **Workspace isolation** via git worktrees + Change-Id tracking (powered by git-cascade 0.0.3+)
|
|
13
14
|
- **Messaging** via agent-inbox (structured inbox/outbox, threading, federation)
|
|
14
15
|
- **Task management** via opentasks (graph-based dependencies, providers, claiming)
|
|
15
16
|
- **Control socket** for MCP subprocess lifecycle RPC (NDJSON over UNIX socket)
|
|
@@ -58,7 +59,6 @@ macro-agent enables coordinated work across multiple AI agents with:
|
|
|
58
59
|
│ - Spawns agents via acp-factory (AgentFactory) │
|
|
59
60
|
│ - Manages lifecycle (spawn, prompt, stop, continue, fork) │
|
|
60
61
|
│ - Registers agents in agent-inbox on spawn │
|
|
61
|
-
│ - Creates tasks in opentasks on spawn │
|
|
62
62
|
│ - Workspace allocation via WorkspaceManager │
|
|
63
63
|
│ - Cascade termination with change consolidation │
|
|
64
64
|
│ - Spawn interceptor hook (set by TeamManager) │
|
|
@@ -272,26 +272,46 @@ src/
|
|
|
272
272
|
│ │ └── index.ts
|
|
273
273
|
│ └── index.ts # Public exports
|
|
274
274
|
│
|
|
275
|
-
└── workspace/ # Workspace isolation
|
|
276
|
-
├── workspace-manager.ts # WorkspaceManager implementation
|
|
277
|
-
├──
|
|
278
|
-
├── config.ts #
|
|
279
|
-
├── types.ts #
|
|
275
|
+
└── workspace/ # Workspace isolation — V3 stream-first + legacy role-shaped
|
|
276
|
+
├── workspace-manager.ts # WorkspaceManager implementation (legacy + V3 surfaces)
|
|
277
|
+
├── git-cascade-adapter.ts # Wraps git-cascade tracker (40+ primitives surfaced)
|
|
278
|
+
├── config.ts # GitCascadeConfig + pool config
|
|
279
|
+
├── types.ts # WorkspaceManager interface (legacy + V3), events
|
|
280
|
+
├── types-v3.ts # V3 types: Principal, StreamSpec, LandingStrategy, etc.
|
|
281
|
+
├── yaml-schema.ts # Zod schema for `macro_agent.workspace`
|
|
282
|
+
├── topology/ # TopologyPolicy — compiles YAML → spawn decisions
|
|
283
|
+
│ ├── types.ts # TopologyPolicy, WorkspaceDecision, contexts
|
|
284
|
+
│ ├── yaml-driven.ts # YamlDrivenTopology (primary)
|
|
285
|
+
│ ├── no-workspace.ts # NoWorkspaceTopology (null policy)
|
|
286
|
+
│ └── index.ts
|
|
287
|
+
├── landing/ # LandingStrategy — pluggable merge/push algorithms
|
|
288
|
+
│ ├── merge-to-parent.ts # mergeStream into parent + optional cascadeRebase
|
|
289
|
+
│ ├── queue-to-branch.ts # git-cascade built-in merge queue
|
|
290
|
+
│ ├── direct-push.ts # rebase + push
|
|
291
|
+
│ ├── optimistic-push.ts # direct-push + validation event
|
|
292
|
+
│ └── index.ts # registerBuiltinLandingStrategies()
|
|
293
|
+
├── recovery/ # ConflictRecoveryStrategy
|
|
294
|
+
│ ├── types.ts # ConflictContext, ConflictResolution
|
|
295
|
+
│ ├── defer.ts # Leave conflict record; no-op
|
|
296
|
+
│ ├── abandon.ts # Abandon the conflicted stream
|
|
297
|
+
│ ├── escalate.ts # Pause + notify human
|
|
298
|
+
│ ├── auto-resolve.ts # Replay merge with -X ours|theirs|union
|
|
299
|
+
│ ├── spawn-resolver.ts # Spawn a resolver agent (requires AgentManager)
|
|
300
|
+
│ └── index.ts # buildBuiltinRecoveryRegistry()
|
|
280
301
|
├── pool/ # Worktree pool management
|
|
281
302
|
│ ├── worktree-pool.ts
|
|
282
303
|
│ ├── types.ts
|
|
283
304
|
│ └── index.ts
|
|
284
|
-
├── merge-queue/ # SQLite-backed
|
|
285
|
-
│ ├── merge-queue.ts
|
|
286
|
-
│ ├── schema.ts
|
|
287
|
-
│ ├── types.ts
|
|
305
|
+
├── merge-queue/ # @deprecated — legacy SQLite-backed queue,
|
|
306
|
+
│ ├── merge-queue.ts # duplicates git-cascade's built-in. Use
|
|
307
|
+
│ ├── schema.ts # GitCascadeAdapter.addToMergeQueue for
|
|
308
|
+
│ ├── types.ts # new code (via QueueToBranchStrategy).
|
|
288
309
|
│ └── index.ts
|
|
289
|
-
├── strategies/ #
|
|
290
|
-
│ ├── types.ts #
|
|
291
|
-
│ ├──
|
|
292
|
-
│ ├──
|
|
293
|
-
│ ├──
|
|
294
|
-
│ ├── optimistic.ts # Optimistic strategy (push + validation event)
|
|
310
|
+
├── strategies/ # @deprecated — old IntegrationStrategy.
|
|
311
|
+
│ ├── types.ts # Superseded by workspace/landing/.
|
|
312
|
+
│ ├── queue.ts # Scheduled for removal once all teams
|
|
313
|
+
│ ├── trunk.ts # migrate to macro_agent.workspace YAML.
|
|
314
|
+
│ ├── optimistic.ts
|
|
295
315
|
│ └── index.ts
|
|
296
316
|
└── index.ts # Public exports
|
|
297
317
|
```
|
|
@@ -303,7 +323,7 @@ src/
|
|
|
303
323
|
macro-agent delegates two major concerns to external subsystems:
|
|
304
324
|
|
|
305
325
|
- **agent-inbox**: All messaging (send/receive, threading, conversations, federation). Embedded in-process for zero-latency events, with IPC server for agent MCP subprocesses.
|
|
306
|
-
- **opentasks**:
|
|
326
|
+
- **opentasks**: Task management for pull-mode workflows (claiming, dependencies, state transitions). Connected via IPC to opentasks daemon (auto-started if needed). Note: AgentManagerV2 does **not** create opentasks nodes on spawn or transition them on terminate — that was removed to avoid polluting the task graph with per-session noise. Opentasks is used only for explicit task operations (pull-mode claim/unclaim/list, team task coordination).
|
|
307
327
|
|
|
308
328
|
macro-agent owns: agent lifecycle, workspace isolation, team topology, role system, trigger/wake, control socket.
|
|
309
329
|
|
|
@@ -372,16 +392,98 @@ Agents are assigned roles that determine their capabilities:
|
|
|
372
392
|
|
|
373
393
|
Teams can define custom roles (e.g., planner, grinder, judge) that extend built-in roles via `extends` in `roles/<name>.yaml`. Tool filtering is role-based — `isToolAllowedForRole()` checks the role's capabilities before registering each MCP tool.
|
|
374
394
|
|
|
375
|
-
###
|
|
395
|
+
### Workspace Layer (V3 Stream-First)
|
|
396
|
+
|
|
397
|
+
The workspace layer went through a v3 redesign. Two paths coexist:
|
|
398
|
+
|
|
399
|
+
**V3 path (YAML-driven, recommended for teams):**
|
|
400
|
+
- `macro_agent.workspace` block in `team.yaml` declares per-role workspace decisions
|
|
401
|
+
- `TopologyPolicy` (`workspace/topology/`) compiles YAML → `WorkspaceDecision` per spawn
|
|
402
|
+
- `LandingStrategy` (`workspace/landing/`) finalizes work at `done()` time
|
|
403
|
+
- `ConflictRecoveryStrategy` (`workspace/recovery/`) dispatches on conflicts
|
|
404
|
+
- Auto-wired by `TeamManagerV2.startTeam()` when workspace config is present
|
|
405
|
+
|
|
406
|
+
**Legacy path (programmatic / capability-based):**
|
|
407
|
+
- Direct `agentManager.spawn({ capabilities: ['workspace.worktree'|'workspace.stream'|'workspace.integrate'], streamId, streamConfig })`
|
|
408
|
+
- `capabilityBasedDispatch` in `AgentManagerV2` routes to role-shaped `WorkspaceManager` methods (`createWorkerWorkspace`, etc.)
|
|
409
|
+
- Retained for programmatic callers (tools, libraries, tests that don't load team YAML)
|
|
410
|
+
|
|
411
|
+
**Dispatch priority in `AgentManagerV2.createWorkspaceForRole()`:**
|
|
412
|
+
1. If `topologyPolicy` is set → V3 path via `executeWorkspaceDecision`
|
|
413
|
+
2. Else → `capabilityBasedDispatch` using role-shaped methods
|
|
414
|
+
|
|
415
|
+
### TopologyPolicy (V3)
|
|
416
|
+
|
|
417
|
+
`TopologyPolicy` (`workspace/topology/types.ts`) is the contract for compiling
|
|
418
|
+
team YAML into per-spawn workspace decisions. Three built-ins:
|
|
419
|
+
|
|
420
|
+
| Policy | Module | Purpose |
|
|
421
|
+
|---|---|---|
|
|
422
|
+
| **YamlDrivenTopology** | `topology/yaml-driven.ts` | Primary; reads `macro_agent.workspace` |
|
|
423
|
+
| **NoWorkspaceTopology** | `topology/no-workspace.ts` | Null policy; returns `share-parent-cwd` for all |
|
|
424
|
+
|
|
425
|
+
Hook methods:
|
|
426
|
+
- `onTeamStart(ctx)` → creates team-root stream if any role needs it
|
|
427
|
+
- `onAgentSpawn(ctx)` → returns `WorkspaceDecision` (`none` / `share-parent-cwd` / `share-with-agent` / `attach-to-stream` / `new-stream`)
|
|
428
|
+
- `onAgentComplete(ctx)` → deallocates the agent's worktree
|
|
429
|
+
- `onTeamStop(ctx)` → applies `on_team_complete` action (`keep` / `merge_to_main` / `abandon`)
|
|
430
|
+
|
|
431
|
+
The YAML schema (`workspace/yaml-schema.ts`) supports:
|
|
432
|
+
- `workspace`: `none` / `attach_to_team_root` / `share_with_agent` / `share_parent_cwd` / `new_stream`
|
|
433
|
+
- `stream_lineage`: `from_team_root` / `fork_from_team_root` / `fork_from_parent` / `independent` / `track_existing_branch`
|
|
434
|
+
- `allocation`, `landing`, `landing_config`, `on_conflict`, `on_conflict_recovery`, `conflict_recovery_config`, `cascade_on_parent_update`, `on_parent_advanced`, `share_with`, `track_branch`, `capabilities`
|
|
435
|
+
|
|
436
|
+
### LandingStrategies (V3)
|
|
437
|
+
|
|
438
|
+
`LandingStrategy` (`workspace/types-v3.ts`) is how a streamed agent finalizes
|
|
439
|
+
its work. Registered on `WorkspaceManager` via `registerLandingStrategy(s)`
|
|
440
|
+
and selected per-role via YAML `landing:`. Four built-ins registered by
|
|
441
|
+
`registerBuiltinLandingStrategies()`:
|
|
442
|
+
|
|
443
|
+
| Strategy | Module | Semantics |
|
|
444
|
+
|---|---|---|
|
|
445
|
+
| **merge-to-parent** | `landing/merge-to-parent.ts` | `mergeStream(source → parent)`, optional `cascadeRebase` via `strategyConfig.cascade: true` |
|
|
446
|
+
| **queue-to-branch** | `landing/queue-to-branch.ts` | `GitCascadeAdapter.addToMergeQueue(streamId, targetBranch)` — drained by integrator-capable agents |
|
|
447
|
+
| **direct-push** | `landing/direct-push.ts` | Rebase + `git push` with retries (trunk flow) |
|
|
448
|
+
| **optimistic-push** | `landing/optimistic-push.ts` | `direct-push` + emits validation event |
|
|
449
|
+
|
|
450
|
+
`LandingContext` carries: `agentId`, `streamId`, `sourceWorktree`,
|
|
451
|
+
`targetStreamId`, `strategyConfig` (from YAML `landing_config`), and a back-
|
|
452
|
+
reference to `WorkspaceManager`.
|
|
453
|
+
|
|
454
|
+
### Conflict Recovery (V3)
|
|
376
455
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
- **Optimistic** (`optimistic.ts`): Same as trunk + emits validation event
|
|
456
|
+
When a landing returns a conflict, the agent's `done()` flow dispatches to a
|
|
457
|
+
`ConflictRecoveryStrategy` (`workspace/recovery/types.ts`) selected via YAML
|
|
458
|
+
`on_conflict_recovery:` or team default. Five built-ins:
|
|
381
459
|
|
|
382
|
-
|
|
460
|
+
| Strategy | Mode | Behavior |
|
|
461
|
+
|---|---|---|
|
|
462
|
+
| **defer** | sync | No-op — leaves conflict record for later manual recovery |
|
|
463
|
+
| **abandon** | sync | `abandonStream(streamId)` — throwaway work |
|
|
464
|
+
| **escalate** | async | `pauseStream` + emit escalation — awaits external `resolve_conflict` MCP call |
|
|
465
|
+
| **auto-resolve** | sync | Replays merge with `-X ours|theirs|union` in the agent's worktree, commits, notifies `workspaceManager.resolveConflict` |
|
|
466
|
+
| **spawn-resolver** | async | Spawns a resolver agent on the conflicted stream; awaits `conflict:resolved` event or timeout |
|
|
383
467
|
|
|
384
|
-
|
|
468
|
+
`spawn-resolver` requires `AgentManager` injection (not in default registry;
|
|
469
|
+
register via `createSpawnResolverStrategy({ agentManager })`). Max concurrent
|
|
470
|
+
resolvers per stream is configurable; timeout falls back to `escalated`.
|
|
471
|
+
|
|
472
|
+
`ConflictContext` carries: `conflictId`, `streamId`, `paths`, `operation`
|
|
473
|
+
(`merge` | `sync` | `rebase` | `cascade`), `worktree?` (required for
|
|
474
|
+
`auto-resolve`), `landingAgentId?`, `recoveryDepth`, `strategyConfig`.
|
|
475
|
+
|
|
476
|
+
### Workspace Isolation (shared across paths)
|
|
477
|
+
|
|
478
|
+
Each streamed agent gets an isolated git worktree via `WorkspaceManager`,
|
|
479
|
+
backed by git-cascade's `MultiAgentRepoTracker`. V3 agents use
|
|
480
|
+
`allocateWorktree({ agentId, streamId })`; legacy agents use role-specific
|
|
481
|
+
`createWorkerWorkspace` / `createIntegratorWorkspace` / `createCoordinatorWorkspace`.
|
|
482
|
+
Both produce the same underlying git worktree structure.
|
|
483
|
+
|
|
484
|
+
Change-Id tracking via `commitChanges({ agentId, streamId, worktree, message })`
|
|
485
|
+
(v3) — each commit gets a stable `Change-Id: c-xxxxxxxx` trailer that survives
|
|
486
|
+
rebases. Legacy callers that use raw `git commit` bypass this tracking.
|
|
385
487
|
|
|
386
488
|
### MCP Tool Surface
|
|
387
489
|
|
|
@@ -441,15 +543,24 @@ The `acp/` module bridges the Agent Client Protocol (ACP) to macro-agent's V2 se
|
|
|
441
543
|
|
|
442
544
|
### MAP Capabilities
|
|
443
545
|
|
|
444
|
-
|
|
546
|
+
Capabilities are declared at two levels:
|
|
547
|
+
|
|
548
|
+
**Connection-level** (sidecar, `src/map/sidecar.ts`): Declared when the sidecar connects to the OpenHive MAP hub. These describe the swarm's general capabilities:
|
|
445
549
|
|
|
446
550
|
- `messaging: { canSend: true, canReceive: true }` — can exchange MAP scope messages
|
|
447
551
|
- `mail: { canCreate: true, canJoin: true, canViewHistory: true }` — supports agent-inbox conversations (enables Mail chat mode in OpenHive)
|
|
448
|
-
- `protocols: ['acp']` — advertises ACP protocol support (enables ACP streaming chat in OpenHive)
|
|
449
|
-
- `acp: { version: '2024-10-07' }` — ACP version details
|
|
450
552
|
- `trajectory: { canReport: true, canServeContent: false }` — reports checkpoints (does not serve content on demand)
|
|
451
553
|
- `tasks: { canCreate, canAssign, canUpdate, canList }` — task management
|
|
452
554
|
|
|
555
|
+
**Per-agent** (lifecycle bridge, `src/map/lifecycle-bridge.ts`): Declared when agents register on the hub via `map/agents/register`. ACP is per-agent because you connect to a specific agent, not to the swarm:
|
|
556
|
+
|
|
557
|
+
- **Coordinators** (head managers): `protocols: ['acp']`, `acp: { version: '2024-10-07' }`, `messaging: { canReceive: true }` — enables ACP streaming chat in OpenHive
|
|
558
|
+
- **Workers**: `messaging: { canReceive: true }` — no ACP
|
|
559
|
+
|
|
560
|
+
The hub aggregates per-agent capabilities into the swarm record (union semantics). OpenHive resolves the ACP target by finding the first registered agent with `protocols: ['acp']` on the live connection.
|
|
561
|
+
|
|
562
|
+
The lifecycle bridge uses `map/agents/register` (not `map/agents/spawn`) to register agents on the hub, because `spawn` drops the `capabilities` field. The bridge tracks MAP-assigned ULIDs (`mapId`) for correct unregistration.
|
|
563
|
+
|
|
453
564
|
Message delivery is **push-based**: `InboxAdapter.onDelivery()` fires immediately on message receipt, the trigger system maps importance → wake action, and `WakeManager` injects into the active session via inject/interrupt/prompt fallback chain.
|
|
454
565
|
|
|
455
566
|
### REST API Server
|
|
@@ -507,15 +618,16 @@ Teams configure communication via:
|
|
|
507
618
|
|
|
508
619
|
All filtering is adapter-side — agent-inbox is a dumb pipe, macro-agent enforces policy via composite filters on the InboxAdapter.
|
|
509
620
|
|
|
510
|
-
### Done Handler Flow
|
|
621
|
+
### Done Handler Flow
|
|
511
622
|
|
|
512
623
|
1. Agent calls `done()` MCP tool with status + summary
|
|
513
624
|
2. MCPServerV2 dispatches to `createDoneHandlerV2()` which builds a handler using `HandlerDepsV2` (InboxAdapter, TasksAdapter, AgentManager)
|
|
514
625
|
3. Role-specific handler runs:
|
|
515
|
-
- **Worker**: Commits changes
|
|
626
|
+
- **Worker / V3 streamed agent**: Commits changes via `commitChanges` (Change-Id tracked), invokes `LandingStrategy.land()` per YAML config, emits `work:done` signal
|
|
516
627
|
- **Coordinator**: Emits completion signal, cascade-terminates children if needed
|
|
517
628
|
- **Monitor**: Emits health report
|
|
518
|
-
4. If `
|
|
629
|
+
4. If landing returns a conflict, the recovery dispatcher selects a `ConflictRecoveryStrategy` per role's `on_conflict_recovery` YAML (or team default); strategy runs sync or async
|
|
630
|
+
5. If `shouldTerminate`, AgentManagerV2 handles termination: `TopologyPolicy.onAgentComplete` deallocates the worktree; cascade termination consolidates changes for child agents
|
|
519
631
|
|
|
520
632
|
## Conventions
|
|
521
633
|
|
|
@@ -534,8 +646,8 @@ All filtering is adapter-side — agent-inbox is a dumb pipe, macro-agent enforc
|
|
|
534
646
|
|
|
535
647
|
### Testing
|
|
536
648
|
|
|
537
|
-
- **Unit tests**: `*.test.ts` — Fast, mocked dependencies (~
|
|
538
|
-
- **E2E tests**: `*.e2e.test.ts` — Full system tests
|
|
649
|
+
- **Unit tests**: `*.test.ts` — Fast tests, mixed real-git and mocked dependencies (~58 test files, ~990 tests)
|
|
650
|
+
- **E2E tests**: `*.e2e.test.ts` — Full system tests gated by `RUN_E2E_TESTS=true`
|
|
539
651
|
|
|
540
652
|
Run tests:
|
|
541
653
|
```bash
|
|
@@ -545,11 +657,12 @@ npm run test:e2e # E2E tests (mocked agent sessions)
|
|
|
545
657
|
npm run test:e2e-full-agents # E2E tests with real agent spawning (RUN_FULL_AGENT_TESTS=true)
|
|
546
658
|
```
|
|
547
659
|
|
|
548
|
-
E2E test files:
|
|
660
|
+
E2E test files (selected):
|
|
549
661
|
- `agent-lifecycle.e2e.test.ts` — Spawn, prompt, terminate flows
|
|
662
|
+
- `workspace-lifecycle.e2e.test.ts` — Legacy capability-based workspace path (programmatic API)
|
|
663
|
+
- `workspace-v3.e2e.test.ts` — V3 YAML-driven path: peer swarm, merge-to-parent landing, conflict recovery, legacy regression guard
|
|
550
664
|
- `cognitive-workspace.e2e.test.ts` — Cognitive-core backend workspace operations
|
|
551
665
|
- `done-scenarios.e2e.test.ts` — Done handler scenarios per role
|
|
552
|
-
- `workspace-lifecycle.e2e.test.ts` — Worktree allocation and cleanup
|
|
553
666
|
- `trigger-wake.e2e.test.ts` — Trigger delivery and wake flows
|
|
554
667
|
- `resume-continue.e2e.test.ts` — Session continuation
|
|
555
668
|
- `pull-mode.e2e.test.ts` — Task claiming workflows
|
|
@@ -594,6 +707,27 @@ E2E test files:
|
|
|
594
707
|
3. Register with `triggerSystem.router.registerStrategy(strategy)`
|
|
595
708
|
4. Optionally set as default: `triggerSystem.router.setDefaultStrategy(name)`
|
|
596
709
|
|
|
710
|
+
### Adding a Landing Strategy (V3)
|
|
711
|
+
|
|
712
|
+
1. Implement the `LandingStrategy` interface from `src/workspace/types-v3.ts`
|
|
713
|
+
2. Define `name`, `land(ctx)`, optionally `canLand(ctx)`, `initialize()`, `close()`
|
|
714
|
+
3. Register via `workspaceManager.registerLandingStrategy(new YourStrategy())` (typically at boot after built-ins)
|
|
715
|
+
4. Reference from team YAML: `roles.<role>.landing: your_strategy_name`; pass config via `landing_config`
|
|
716
|
+
|
|
717
|
+
### Adding a Conflict Recovery Strategy (V3)
|
|
718
|
+
|
|
719
|
+
1. Implement the `ConflictRecoveryStrategy` interface from `src/workspace/recovery/types.ts`
|
|
720
|
+
2. Define `name`, `mode` (`sync` | `async`), `recover(ctx)`, optionally `canHandle(ctx)`
|
|
721
|
+
3. If the strategy needs `AgentManager` (like `spawn-resolver`), expose a factory that accepts it
|
|
722
|
+
4. Register into the team's recovery registry; selected per-role via `on_conflict_recovery:` or team default
|
|
723
|
+
|
|
724
|
+
### Adding a Topology Policy (V3)
|
|
725
|
+
|
|
726
|
+
1. Implement the `TopologyPolicy` interface from `src/workspace/topology/types.ts`
|
|
727
|
+
2. Define `onTeamStart`, `onAgentSpawn`, `onAgentComplete`, `onTeamStop`
|
|
728
|
+
3. Return `WorkspaceDecision` values from `onAgentSpawn` (`none` / `share-parent-cwd` / `share-with-agent` / `attach-to-stream` / `new-stream`)
|
|
729
|
+
4. Inject via `agentManager.setTopologyPolicy(policy)` — or have `TeamManagerV2.startTeam` auto-wire from YAML via `YamlDrivenTopology`
|
|
730
|
+
|
|
597
731
|
### Adding a Control Command
|
|
598
732
|
|
|
599
733
|
1. Add the command type to `ControlCommand` union in `src/control/types.ts`
|
|
@@ -657,7 +791,7 @@ E2E test files:
|
|
|
657
791
|
| `opentasks` | Task graph, dependencies, providers (IPC to daemon) |
|
|
658
792
|
| `acp-factory` | Agent process management (Claude Code sessions) |
|
|
659
793
|
| `openteams` | Team template loading and resolution |
|
|
660
|
-
| `git-cascade` | Git worktree
|
|
794
|
+
| `git-cascade` | Git worktree, stream/fork/merge/rebase, Change-Id tracking, cascade namespace, event emitter (0.0.3+) |
|
|
661
795
|
| `better-sqlite3` | AgentStore + InboxAdapter persistence |
|
|
662
796
|
| `@modelcontextprotocol/sdk` | MCP server implementation |
|
|
663
797
|
| `@multi-agent-protocol/sdk` | MAP protocol types |
|
|
@@ -681,5 +815,12 @@ E2E test files:
|
|
|
681
815
|
|
|
682
816
|
## References
|
|
683
817
|
|
|
818
|
+
### Team configuration
|
|
684
819
|
- [docs/teams.md](docs/teams.md) - Team template schema reference
|
|
685
820
|
- [docs/team-templates.md](docs/team-templates.md) - Team template format and examples
|
|
821
|
+
|
|
822
|
+
### Workspace redesign (V3)
|
|
823
|
+
- [docs/workspace-redesign-plan.md](docs/workspace-redesign-plan.md) - Implementation plan + status
|
|
824
|
+
- [docs/workspace-interfaces.md](docs/workspace-interfaces.md) - V3 interface contracts (TypeScript)
|
|
825
|
+
- [docs/git-cascade-integration-gaps.md](docs/git-cascade-integration-gaps.md) - Design narrative, workflow traces, migration plan
|
|
826
|
+
- [docs/conflict-recovery.md](docs/conflict-recovery.md) - Conflict recovery strategy design
|