macro-agent 0.1.5 → 0.1.7
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/settings.json +128 -1
- package/.sessionlog/settings.json +4 -0
- package/CLAUDE.md +125 -10
- package/README.md +93 -31
- package/dist/acp/macro-agent.d.ts.map +1 -1
- package/dist/acp/macro-agent.js +1 -3
- package/dist/acp/macro-agent.js.map +1 -1
- package/dist/boot-v2.d.ts +1 -0
- package/dist/boot-v2.d.ts.map +1 -1
- package/dist/boot-v2.js +1 -0
- package/dist/boot-v2.js.map +1 -1
- package/dist/cognitive/workspace-handler.d.ts +17 -9
- package/dist/cognitive/workspace-handler.d.ts.map +1 -1
- package/dist/cognitive/workspace-handler.js +10 -11
- package/dist/cognitive/workspace-handler.js.map +1 -1
- package/dist/map/coordination-handler.d.ts +7 -23
- package/dist/map/coordination-handler.d.ts.map +1 -1
- package/dist/map/coordination-handler.js +124 -100
- package/dist/map/coordination-handler.js.map +1 -1
- package/dist/map/server.d.ts.map +1 -1
- package/dist/map/server.js +13 -3
- package/dist/map/server.js.map +1 -1
- package/dist/map/sidecar.d.ts.map +1 -1
- package/dist/map/sidecar.js +13 -15
- package/dist/map/sidecar.js.map +1 -1
- package/dist/map/trajectory-reporter.d.ts +4 -9
- package/dist/map/trajectory-reporter.d.ts.map +1 -1
- package/dist/map/trajectory-reporter.js +15 -129
- package/dist/map/trajectory-reporter.js.map +1 -1
- package/dist/map/types.d.ts +39 -0
- package/dist/map/types.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/__tests__/e2e/cognitive-workspace.e2e.test.ts +1 -1
- package/src/acp/macro-agent.ts +1 -4
- package/src/boot-v2.ts +2 -0
- package/src/cognitive/__tests__/workspace-handler.test.ts +2 -10
- package/src/cognitive/workspace-handler.ts +18 -15
- package/src/map/__tests__/trajectory-reporter.test.ts +2 -254
- package/src/map/coordination-handler.ts +137 -120
- package/src/map/server.ts +14 -2
- package/src/map/sidecar.ts +13 -20
- package/src/map/trajectory-reporter.ts +16 -154
- package/src/map/types.ts +43 -2
- package/src/__tests__/e2e/trajectory-content.e2e.test.ts +0 -708
- package/src/map/__tests__/coordination-handler.test.ts +0 -598
package/.claude/settings.json
CHANGED
|
@@ -1,6 +1,133 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
2
|
+
"attribution": {
|
|
3
3
|
"commit": "",
|
|
4
4
|
"pr": ""
|
|
5
|
+
},
|
|
6
|
+
"hooks": {
|
|
7
|
+
"SessionStart": [
|
|
8
|
+
{
|
|
9
|
+
"matcher": "",
|
|
10
|
+
"hooks": [
|
|
11
|
+
{
|
|
12
|
+
"type": "command",
|
|
13
|
+
"command": "sessionlog hooks claude-code session-start"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"SessionEnd": [
|
|
19
|
+
{
|
|
20
|
+
"matcher": "",
|
|
21
|
+
"hooks": [
|
|
22
|
+
{
|
|
23
|
+
"type": "command",
|
|
24
|
+
"command": "sessionlog hooks claude-code session-end"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"UserPromptSubmit": [
|
|
30
|
+
{
|
|
31
|
+
"matcher": "",
|
|
32
|
+
"hooks": [
|
|
33
|
+
{
|
|
34
|
+
"type": "command",
|
|
35
|
+
"command": "sessionlog hooks claude-code user-prompt-submit"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"Stop": [
|
|
41
|
+
{
|
|
42
|
+
"matcher": "",
|
|
43
|
+
"hooks": [
|
|
44
|
+
{
|
|
45
|
+
"type": "command",
|
|
46
|
+
"command": "sessionlog hooks claude-code stop"
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"PreToolUse": [
|
|
52
|
+
{
|
|
53
|
+
"matcher": "Task",
|
|
54
|
+
"hooks": [
|
|
55
|
+
{
|
|
56
|
+
"type": "command",
|
|
57
|
+
"command": "sessionlog hooks claude-code pre-task"
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"PostToolUse": [
|
|
63
|
+
{
|
|
64
|
+
"matcher": "Task",
|
|
65
|
+
"hooks": [
|
|
66
|
+
{
|
|
67
|
+
"type": "command",
|
|
68
|
+
"command": "sessionlog hooks claude-code post-task"
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"matcher": "TodoWrite",
|
|
74
|
+
"hooks": [
|
|
75
|
+
{
|
|
76
|
+
"type": "command",
|
|
77
|
+
"command": "sessionlog hooks claude-code post-todo"
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"matcher": "TaskCreate",
|
|
83
|
+
"hooks": [
|
|
84
|
+
{
|
|
85
|
+
"type": "command",
|
|
86
|
+
"command": "sessionlog hooks claude-code post-task-create"
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"matcher": "TaskUpdate",
|
|
92
|
+
"hooks": [
|
|
93
|
+
{
|
|
94
|
+
"type": "command",
|
|
95
|
+
"command": "sessionlog hooks claude-code post-task-update"
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"matcher": "EnterPlanMode",
|
|
101
|
+
"hooks": [
|
|
102
|
+
{
|
|
103
|
+
"type": "command",
|
|
104
|
+
"command": "sessionlog hooks claude-code post-plan-enter"
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"matcher": "ExitPlanMode",
|
|
110
|
+
"hooks": [
|
|
111
|
+
{
|
|
112
|
+
"type": "command",
|
|
113
|
+
"command": "sessionlog hooks claude-code post-plan-exit"
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"matcher": "Skill",
|
|
119
|
+
"hooks": [
|
|
120
|
+
{
|
|
121
|
+
"type": "command",
|
|
122
|
+
"command": "sessionlog hooks claude-code post-skill"
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
},
|
|
128
|
+
"permissions": {
|
|
129
|
+
"deny": [
|
|
130
|
+
"Read(./.sessionlog/metadata/**)"
|
|
131
|
+
]
|
|
5
132
|
}
|
|
6
133
|
}
|
package/CLAUDE.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# macro-agent
|
|
2
2
|
|
|
3
|
-
A multi-agent orchestration system for spawning and managing hierarchical
|
|
3
|
+
A multi-agent orchestration system for spawning and managing hierarchical AI coding agents. Delegates messaging to **agent-inbox** and task management to **opentasks**. Exposes ACP (WebSocket) and REST API servers, supports cross-instance federation, and can serve as a compute backend for cognitive-core/OpenHive.
|
|
4
4
|
|
|
5
5
|
## Project Overview
|
|
6
6
|
|
|
7
7
|
macro-agent enables coordinated work across multiple AI agents with:
|
|
8
|
-
- **Role-based agents** (Worker, Integrator, Coordinator, Monitor + custom team roles)
|
|
8
|
+
- **Role-based agents** (Worker, Integrator, Coordinator, Monitor, Analyst + custom team roles)
|
|
9
9
|
- **Team templates** for declarative multi-agent topologies (YAML config)
|
|
10
10
|
- **Pluggable integration strategies** (queue, trunk, optimistic)
|
|
11
11
|
- **Workspace isolation** via git worktrees (powered by git-cascade)
|
|
@@ -14,24 +14,30 @@ macro-agent enables coordinated work across multiple AI agents with:
|
|
|
14
14
|
- **Task management** via opentasks (graph-based dependencies, providers, claiming)
|
|
15
15
|
- **Control socket** for MCP subprocess lifecycle RPC (NDJSON over UNIX socket)
|
|
16
16
|
- **Composite signal filtering and emission enforcement** for multi-team communication topology
|
|
17
|
-
- **Trigger system** with pluggable routing strategies, wake management, cron, and webhooks
|
|
17
|
+
- **Trigger system** with pluggable routing strategies (including AI router), wake management, cron, and webhooks
|
|
18
18
|
- **Agent detection** for discovering installed CLI coding agents (Claude Code, Codex, etc.)
|
|
19
19
|
- **Health check heartbeats** from MCP subprocesses to the control server
|
|
20
|
+
- **ACP protocol server** with WebSocket transport for external client integration
|
|
21
|
+
- **REST API server** for HTTP-based agent, task, team, and metrics management
|
|
22
|
+
- **Federation** for cross-instance communication between macro-agent instances
|
|
23
|
+
- **Cognitive-core backend** for serving as compute backend for OpenHive
|
|
24
|
+
- **Metrics collection** for point-in-time system observability
|
|
20
25
|
|
|
21
26
|
## Architecture
|
|
22
27
|
|
|
23
28
|
```
|
|
24
29
|
┌─────────────────────────────────────────────────────────────┐
|
|
25
30
|
│ External Clients │
|
|
26
|
-
│
|
|
31
|
+
│ (CLI, ACP stdio, WebSocket, REST API) │
|
|
27
32
|
└───────────────────────────┬─────────────────────────────────┘
|
|
28
33
|
│
|
|
29
34
|
┌───────────────────────────▼─────────────────────────────────┐
|
|
30
35
|
│ boot-v2.ts (System Wiring) │
|
|
31
|
-
│ 1. AgentStore (SQLite)
|
|
32
|
-
│ 2. InboxAdapter (embedded)
|
|
33
|
-
│ 3. TasksAdapter (IPC)
|
|
34
|
-
│ 4. RoleRegistry
|
|
36
|
+
│ 1. AgentStore (SQLite) 6. TriggerSystemV2 │
|
|
37
|
+
│ 2. InboxAdapter (embedded) 7. ControlServer │
|
|
38
|
+
│ 3. TasksAdapter (IPC) 8. Federation (optional) │
|
|
39
|
+
│ 4. RoleRegistry 9. REST API server (optional) │
|
|
40
|
+
│ 5. AgentManagerV2 10. ACP WebSocket (optional) │
|
|
35
41
|
└───────────────────────────┬─────────────────────────────────┘
|
|
36
42
|
│
|
|
37
43
|
┌───────────────────────────▼─────────────────────────────────┐
|
|
@@ -116,12 +122,21 @@ macro-agent enables coordinated work across multiple AI agents with:
|
|
|
116
122
|
|
|
117
123
|
```
|
|
118
124
|
src/
|
|
125
|
+
├── acp/ # ACP protocol server
|
|
126
|
+
│ ├── macro-agent.ts # ACP-to-macro-agent bridge (session/new, session/prompt, extensions)
|
|
127
|
+
│ ├── websocket-server.ts # WebSocket server for ACP clients
|
|
128
|
+
│ ├── session-mapper.ts # Maps ACP sessions to agent states
|
|
129
|
+
│ ├── map-bridge.ts # Bridges between MAP and macro-agent protocols
|
|
130
|
+
│ ├── types.ts # Protocol type definitions (MacroAgentInitConfig, ACPError)
|
|
131
|
+
│ └── index.ts # Public exports
|
|
132
|
+
│
|
|
119
133
|
├── adapters/ # Subsystem integration layer
|
|
120
134
|
│ ├── types.ts # InboxAdapter + TasksAdapter interfaces
|
|
121
135
|
│ ├── inbox-adapter.ts # Wraps agent-inbox (embedded, hybrid IPC)
|
|
122
136
|
│ ├── inbox-client-adapter.ts # IPC-only client for MCP subprocesses
|
|
123
137
|
│ ├── tasks-adapter.ts # Wraps opentasks client (IPC to daemon)
|
|
124
138
|
│ ├── opentasks-daemon.ts # Daemon lifecycle helper (start/stop/probe)
|
|
139
|
+
│ ├── federation.ts # Cross-instance communication via federated inboxes
|
|
125
140
|
│ └── index.ts # Public exports
|
|
126
141
|
│
|
|
127
142
|
├── agent/ # Agent lifecycle
|
|
@@ -142,6 +157,11 @@ src/
|
|
|
142
157
|
│ ├── command-builder.ts # Builds headless invocation commands
|
|
143
158
|
│ └── index.ts # Public exports
|
|
144
159
|
│
|
|
160
|
+
├── api/ # REST API server
|
|
161
|
+
│ ├── server.ts # HTTP endpoints for agents, tasks, teams, metrics
|
|
162
|
+
│ ├── types.ts # ApiServer, ApiServerConfig interfaces
|
|
163
|
+
│ └── index.ts # Public exports
|
|
164
|
+
│
|
|
145
165
|
├── auth/ # Authentication
|
|
146
166
|
│ ├── token.ts # AgentTokenManager for per-agent auth tokens
|
|
147
167
|
│ └── index.ts # Public exports
|
|
@@ -155,6 +175,14 @@ src/
|
|
|
155
175
|
│ ├── parse-args.ts # Argument parsing helpers
|
|
156
176
|
│ └── stable-instance-id.ts # Stable instance ID generation
|
|
157
177
|
│
|
|
178
|
+
├── cognitive/ # cognitive-core backend integration
|
|
179
|
+
│ ├── macro-agent-backend.ts # Implements cognitive-core AgentBackend interface
|
|
180
|
+
│ ├── session-converter.ts # Converts sessions between cognitive-core and macro-agent formats
|
|
181
|
+
│ ├── workspace-handler.ts # Workspace operations for cognitive backend
|
|
182
|
+
│ ├── analyst-role.ts # Analyst role definition for cognitive system
|
|
183
|
+
│ ├── types.ts # CognitiveAgentSession, CognitiveBatchConfig, etc.
|
|
184
|
+
│ └── index.ts # Public exports
|
|
185
|
+
│
|
|
158
186
|
├── config/ # Project configuration
|
|
159
187
|
│ ├── project-config.ts # .multiagent/config.json loader
|
|
160
188
|
│ └── index.ts # Public exports
|
|
@@ -181,6 +209,11 @@ src/
|
|
|
181
209
|
│ ├── types.ts # ToolContext, HierarchyNode, MCPToolError
|
|
182
210
|
│ └── index.ts # Public exports
|
|
183
211
|
│
|
|
212
|
+
├── metrics/ # Metrics collection and reporting
|
|
213
|
+
│ ├── metrics.ts # collectMetrics() — point-in-time agent/task/system snapshot
|
|
214
|
+
│ ├── types.ts # AgentMetrics, TaskMetrics, SystemMetrics, MetricsSnapshot
|
|
215
|
+
│ └── index.ts # Public exports
|
|
216
|
+
│
|
|
184
217
|
├── roles/ # Role system
|
|
185
218
|
│ ├── types.ts # RoleDefinition, RoleRegistry, Capability types
|
|
186
219
|
│ ├── capabilities.ts # Capability constants (AGENT_CAPABILITIES, WORKSPACE_CAPABILITIES)
|
|
@@ -224,6 +257,8 @@ src/
|
|
|
224
257
|
│ │ ├── wake-manager.ts # Heartbeat + coalesce + inject→interrupt→prompt
|
|
225
258
|
│ │ ├── types.ts
|
|
226
259
|
│ │ └── index.ts
|
|
260
|
+
│ ├── strategies/ # Pluggable routing strategies
|
|
261
|
+
│ │ └── ai-router.ts # AI-powered routing via temporary Claude session
|
|
227
262
|
│ ├── sources/ # Trigger event sources
|
|
228
263
|
│ │ ├── cron/
|
|
229
264
|
│ │ │ ├── cron-service.ts
|
|
@@ -396,6 +431,71 @@ The `agent-detection/` module discovers installed CLI coding agents on the syste
|
|
|
396
431
|
- Builds headless invocation commands with proper flags
|
|
397
432
|
- Supports custom agent definitions via `additionalAgents` config
|
|
398
433
|
|
|
434
|
+
### ACP Protocol Server
|
|
435
|
+
|
|
436
|
+
The `acp/` module bridges the Agent Client Protocol (ACP) to macro-agent's V2 services:
|
|
437
|
+
- **MacroAgent** (`macro-agent.ts`): Implements the ACP Agent interface — maps `session/new` → `agentManager.getOrCreateHeadManager()`, `session/prompt` → streaming `agentManager.prompt()`, and extension methods for spawn/mount/fork/hierarchy/tasks
|
|
438
|
+
- **WebSocketACPServer** (`websocket-server.ts`): Optional WebSocket transport for ACP clients (enabled via `config.acp.enabled` in boot)
|
|
439
|
+
- **SessionMapper** (`session-mapper.ts`): Maps ACP sessions to macro-agent agent states
|
|
440
|
+
- **MAPBridge** (`map-bridge.ts`): Bridges MAP protocol to macro-agent for external observability
|
|
441
|
+
|
|
442
|
+
### MAP Capabilities
|
|
443
|
+
|
|
444
|
+
The MAP sidecar (`src/map/sidecar.ts`) declares these capabilities at registration, following the MAP `ParticipantCapabilities` schema:
|
|
445
|
+
|
|
446
|
+
- `messaging: { canSend: true, canReceive: true }` — can exchange MAP scope messages
|
|
447
|
+
- `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
|
+
- `trajectory: { canReport: true, canServeContent: false }` — reports checkpoints (does not serve content on demand)
|
|
451
|
+
- `tasks: { canCreate, canAssign, canUpdate, canList }` — task management
|
|
452
|
+
|
|
453
|
+
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
|
+
|
|
455
|
+
### REST API Server
|
|
456
|
+
|
|
457
|
+
The `api/` module provides HTTP endpoints for external integration:
|
|
458
|
+
- Agent CRUD and listing
|
|
459
|
+
- Task operations
|
|
460
|
+
- Team management
|
|
461
|
+
- Metrics endpoint (powered by `metrics/` module)
|
|
462
|
+
- Enabled via `config.api.enabled` in boot, configurable host/port
|
|
463
|
+
|
|
464
|
+
### Cognitive-Core Backend
|
|
465
|
+
|
|
466
|
+
The `cognitive/` module implements cognitive-core's `AgentBackend` interface, enabling macro-agent to serve as a compute backend for OpenHive:
|
|
467
|
+
- **MacroAgentBackend** (`macro-agent-backend.ts`): Spawns analyst agents, tracks sessions, manages timeouts, reports completion via callbacks and InboxAdapter
|
|
468
|
+
- **AnalystRole** (`analyst-role.ts`): Custom role definition for cognitive analysis tasks
|
|
469
|
+
- **SessionConverter** (`session-converter.ts`): Converts between cognitive-core and macro-agent session formats
|
|
470
|
+
- **WorkspaceHandler** (`workspace-handler.ts`): Workspace operations for cognitive backend tasks
|
|
471
|
+
- Design principle: the swarm is pure compute — receive task, execute agent, return result. Atlas, trajectory extraction, and team coordination are handled by OpenHive.
|
|
472
|
+
|
|
473
|
+
### Federation
|
|
474
|
+
|
|
475
|
+
The `adapters/federation.ts` module enables cross-instance communication:
|
|
476
|
+
- Multiple macro-agent instances federate their embedded agent-inbox instances
|
|
477
|
+
- Federated addressing: `agentId@systemId` (e.g., `coordinator@dev-laptop`)
|
|
478
|
+
- Cross-instance spawn via convention-based inbox messages (`remote_spawn_request` events)
|
|
479
|
+
- Trust policy: configurable `allowedSystems` whitelist
|
|
480
|
+
- Setup via `config.federation` in boot, cleanup on shutdown
|
|
481
|
+
|
|
482
|
+
### Metrics
|
|
483
|
+
|
|
484
|
+
The `metrics/` module provides point-in-time system observability:
|
|
485
|
+
- `collectMetrics()` gathers agent, task, and system metrics into a `MetricsSnapshot`
|
|
486
|
+
- Agent metrics: total/running/stopped/failed counts, unhealthy agent detection
|
|
487
|
+
- Task metrics: total/open/in-progress/closed counts
|
|
488
|
+
- System metrics: uptime, health check status
|
|
489
|
+
- Used by the REST API server's `/metrics` endpoint
|
|
490
|
+
|
|
491
|
+
### AI Router Strategy
|
|
492
|
+
|
|
493
|
+
The `trigger/strategies/ai-router.ts` provides an AI-powered routing strategy:
|
|
494
|
+
- Spawns a temporary Claude session to make routing decisions for trigger events
|
|
495
|
+
- Falls back to "head" strategy if spawning fails or times out
|
|
496
|
+
- Selected when `routing.target.type === "ai-router"`
|
|
497
|
+
- Expensive — intended for events that genuinely need intelligent routing
|
|
498
|
+
|
|
399
499
|
### Communication Topology
|
|
400
500
|
|
|
401
501
|
Teams configure communication via:
|
|
@@ -434,8 +534,8 @@ All filtering is adapter-side — agent-inbox is a dumb pipe, macro-agent enforc
|
|
|
434
534
|
|
|
435
535
|
### Testing
|
|
436
536
|
|
|
437
|
-
- **Unit tests**: `*.test.ts` — Fast, mocked dependencies (
|
|
438
|
-
- **E2E tests**: `*.e2e.test.ts` — Full system tests (
|
|
537
|
+
- **Unit tests**: `*.test.ts` — Fast, mocked dependencies (~40 test files)
|
|
538
|
+
- **E2E tests**: `*.e2e.test.ts` — Full system tests (11 test files)
|
|
439
539
|
|
|
440
540
|
Run tests:
|
|
441
541
|
```bash
|
|
@@ -447,6 +547,7 @@ npm run test:e2e-full-agents # E2E tests with real agent spawning (RUN_
|
|
|
447
547
|
|
|
448
548
|
E2E test files:
|
|
449
549
|
- `agent-lifecycle.e2e.test.ts` — Spawn, prompt, terminate flows
|
|
550
|
+
- `cognitive-workspace.e2e.test.ts` — Cognitive-core backend workspace operations
|
|
450
551
|
- `done-scenarios.e2e.test.ts` — Done handler scenarios per role
|
|
451
552
|
- `workspace-lifecycle.e2e.test.ts` — Worktree allocation and cleanup
|
|
452
553
|
- `trigger-wake.e2e.test.ts` — Trigger delivery and wake flows
|
|
@@ -511,6 +612,18 @@ E2E test files:
|
|
|
511
612
|
| `MACRO_TEAMS` | Comma-separated team templates to auto-start | -- |
|
|
512
613
|
| `MACRO_AGENT_HOME` | Alternative base directory (used by CLI clear) | `~/.macro-agent` |
|
|
513
614
|
|
|
615
|
+
### Boot config options (BootV2Config)
|
|
616
|
+
|
|
617
|
+
| Option | Description | Default |
|
|
618
|
+
|--------|-------------|---------|
|
|
619
|
+
| `api.enabled` | Start REST API server | `false` |
|
|
620
|
+
| `api.port` | REST API port | -- |
|
|
621
|
+
| `acp.enabled` | Start ACP WebSocket server | `false` |
|
|
622
|
+
| `acp.port` | ACP WebSocket port | -- |
|
|
623
|
+
| `federation.systemId` | Unique instance ID for federation | -- |
|
|
624
|
+
| `federation.peers` | Peer instances to federate with | `[]` |
|
|
625
|
+
| `federation.trust.allowedSystems` | Trusted system ID whitelist | -- |
|
|
626
|
+
|
|
514
627
|
### Injected into MCP subprocesses (by AgentManagerV2)
|
|
515
628
|
|
|
516
629
|
| Variable | Description |
|
|
@@ -555,6 +668,8 @@ E2E test files:
|
|
|
555
668
|
| `js-yaml` | Team YAML config parsing |
|
|
556
669
|
| `nanoid` | ID generation |
|
|
557
670
|
| `unique-names-generator` | Human-readable agent names |
|
|
671
|
+
| `express` | REST API server |
|
|
672
|
+
| `ws` | ACP WebSocket transport |
|
|
558
673
|
|
|
559
674
|
### Dev
|
|
560
675
|
|
package/README.md
CHANGED
|
@@ -2,20 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
A multi-agent orchestration system for spawning and managing hierarchical AI coding agents. Interact with multiple agents as if they were one.
|
|
4
4
|
|
|
5
|
-
macro-agent handles **orchestration** (agent lifecycle, team topology, workspace isolation, trigger/wake) and delegates **messaging** to [agent-inbox](https://github.com/alexngai/agent-inbox) and **task management** to [opentasks](https://github.com/alexngai/opentasks).
|
|
5
|
+
macro-agent handles **orchestration** (agent lifecycle, team topology, workspace isolation, trigger/wake) and delegates **messaging** to [agent-inbox](https://github.com/alexngai/agent-inbox) and **task management** to [opentasks](https://github.com/alexngai/opentasks). It exposes ACP (WebSocket) and REST API servers, supports cross-instance federation, and can serve as a compute backend for [cognitive-core](https://github.com/alexngai/cognitive-core)/OpenHive.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
- **Hierarchical Agent Management** — Head manager spawns and coordinates child agents via acp-factory
|
|
10
|
-
- **Role-Based Agents** — Worker, Integrator, Coordinator, Monitor roles with distinct capabilities
|
|
10
|
+
- **Role-Based Agents** — Worker, Integrator, Coordinator, Monitor, Analyst roles with distinct capabilities
|
|
11
11
|
- **Team Templates** — Declarative YAML configs for multi-agent topologies with composite signal filtering
|
|
12
12
|
- **Workspace Isolation** — Each worker gets an isolated git worktree via git-cascade
|
|
13
13
|
- **Merge Queue** — Serialized integration of worker changes with conflict resolution
|
|
14
14
|
- **Control Socket** — NDJSON-over-UNIX-socket RPC for MCP subprocess lifecycle operations
|
|
15
|
-
- **Trigger System** — Pluggable routing strategies for wake, cron, and webhook-based agent activation
|
|
15
|
+
- **Trigger System** — Pluggable routing strategies (direct, role, head, AI router) for wake, cron, and webhook-based agent activation
|
|
16
16
|
- **MCP Tools** — 5 core orchestration tools + 3 pull-mode claim tools per agent
|
|
17
17
|
- **Task Modes** — Push (coordinator assigns) or pull (agents claim from pool)
|
|
18
18
|
- **Agent Detection** — Auto-discovers installed CLI coding agents (Claude Code, Codex, etc.)
|
|
19
|
+
- **ACP Protocol Server** — WebSocket transport bridging ACP protocol to macro-agent services
|
|
20
|
+
- **REST API** — HTTP endpoints for agents, tasks, teams, and metrics
|
|
21
|
+
- **Federation** — Cross-instance communication via federated agent-inbox (addressable as `agentId@systemId`)
|
|
22
|
+
- **Cognitive-Core Backend** — Serves as compute backend for OpenHive (analyst agent spawning, batch execution)
|
|
23
|
+
- **Metrics** — Point-in-time snapshots of agent, task, and system health
|
|
19
24
|
|
|
20
25
|
## Installation
|
|
21
26
|
|
|
@@ -77,37 +82,37 @@ npx multiagent --acp
|
|
|
77
82
|
## Architecture
|
|
78
83
|
|
|
79
84
|
```
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
│
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
│
|
|
102
|
-
│
|
|
103
|
-
│
|
|
104
|
-
|
|
105
|
-
|
|
85
|
+
CLI / ACP stdio / WebSocket / REST API
|
|
86
|
+
│
|
|
87
|
+
┌────▼────┐
|
|
88
|
+
│ bootV2 │ Wires all components
|
|
89
|
+
└────┬────┘
|
|
90
|
+
│
|
|
91
|
+
┌──────────┬───────────┼───────────┬──────────┐
|
|
92
|
+
│ │ │ │ │
|
|
93
|
+
┌─────▼─────┐ ┌─▼───────┐ ┌▼────────┐ ┌▼───────┐ ┌▼──────────┐
|
|
94
|
+
│ Agent │ │ Trigger │ │ Control │ │ ACP │ │ REST API │
|
|
95
|
+
│ Manager │ │ System │ │ Socket │ │ Server │ │ Server │
|
|
96
|
+
│ │ │ │ │ (RPC) │ │ (WS) │ │ (HTTP) │
|
|
97
|
+
│ spawn │ │ router │ └────┬────┘ └────────┘ └───────────┘
|
|
98
|
+
│ prompt │ │ wake │ │
|
|
99
|
+
│ terminate│ │ cron │ MCP subprocesses
|
|
100
|
+
└─────┬─────┘ │ webhook │ (per agent)
|
|
101
|
+
│ │ ai-router│
|
|
102
|
+
┌─────┼───────┘──────────┐
|
|
103
|
+
│ │ │
|
|
104
|
+
┌▼────┐┌▼──────────┐ ┌───▼────────┐
|
|
105
|
+
│Roles││ Workspace │ │ Adapters │
|
|
106
|
+
│ ││ Worktrees │ │ │
|
|
107
|
+
│ ││ Strategies │ │ InboxAdapter ──► agent-inbox (embedded)
|
|
108
|
+
│ ││ MergeQueue │ │ TasksAdapter ──► opentasks (IPC daemon)
|
|
109
|
+
└────┘└────────────┘ │ Federation ──► remote instances
|
|
110
|
+
└────────────┘
|
|
106
111
|
```
|
|
107
112
|
|
|
108
113
|
**Three subsystems:**
|
|
109
|
-
- **macro-agent** — Orchestration, lifecycle, teams, workspace, triggers
|
|
110
|
-
- **agent-inbox** — Messaging (embedded in-process, IPC server for subprocesses)
|
|
114
|
+
- **macro-agent** — Orchestration, lifecycle, teams, workspace, triggers, ACP/REST servers, federation, cognitive backend, metrics
|
|
115
|
+
- **agent-inbox** — Messaging (embedded in-process, IPC server for subprocesses, federation)
|
|
111
116
|
- **opentasks** — Task management (separate daemon, IPC client)
|
|
112
117
|
|
|
113
118
|
## Team Templates
|
|
@@ -163,6 +168,61 @@ Each agent gets tools from three sources:
|
|
|
163
168
|
|
|
164
169
|
Custom roles extend built-in roles via YAML with `capabilities_add`/`capabilities_remove`.
|
|
165
170
|
|
|
171
|
+
## ACP Protocol Server
|
|
172
|
+
|
|
173
|
+
The ACP server bridges the [Agent Client Protocol](https://github.com/anthropics/acp) to macro-agent:
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
const system = await bootV2({
|
|
177
|
+
acp: { enabled: true, port: 8080 },
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
- Maps `session/new` → head manager creation, `session/prompt` → streaming responses
|
|
182
|
+
- Extension methods: `_macro/spawnAgent`, `_macro/getHierarchy`, `_macro/mountAgent`, `_macro/forkAgent`, etc.
|
|
183
|
+
- WebSocket transport for real-time communication
|
|
184
|
+
|
|
185
|
+
## REST API
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
const system = await bootV2({
|
|
189
|
+
api: { enabled: true, port: 3000 },
|
|
190
|
+
});
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
HTTP endpoints for agents, tasks, teams, and metrics. Used for dashboards and external tooling.
|
|
194
|
+
|
|
195
|
+
## Federation
|
|
196
|
+
|
|
197
|
+
Connect multiple macro-agent instances for cross-instance agent communication:
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
const system = await bootV2({
|
|
201
|
+
federation: {
|
|
202
|
+
systemId: 'dev-laptop',
|
|
203
|
+
peers: [{ systemId: 'ci-server', url: 'ws://ci:8080' }],
|
|
204
|
+
trust: { allowedSystems: ['ci-server'] },
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Agents address across instances with `agentId@systemId` (e.g., `coordinator@ci-server`).
|
|
210
|
+
|
|
211
|
+
## Cognitive-Core Backend
|
|
212
|
+
|
|
213
|
+
macro-agent can serve as a compute backend for [cognitive-core](https://github.com/alexngai/cognitive-core) / OpenHive:
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
import { MacroAgentBackend } from 'macro-agent/cognitive';
|
|
217
|
+
|
|
218
|
+
const backend = new MacroAgentBackend(system.agentManager, {
|
|
219
|
+
tasksAdapter: system.tasksAdapter,
|
|
220
|
+
inboxAdapter: system.inboxAdapter,
|
|
221
|
+
});
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Spawns analyst agents, manages sessions with timeouts, and reports completion. The swarm is pure compute — atlas, trajectory extraction, and team coordination are handled by OpenHive.
|
|
225
|
+
|
|
166
226
|
## Dependencies
|
|
167
227
|
|
|
168
228
|
| Package | Purpose |
|
|
@@ -172,6 +232,8 @@ Custom roles extend built-in roles via YAML with `capabilities_add`/`capabilitie
|
|
|
172
232
|
| [acp-factory](https://github.com/alexngai/acp-factory) | Agent process management |
|
|
173
233
|
| [openteams](https://github.com/alexngai/openteams) | Team template resolution |
|
|
174
234
|
| [git-cascade](https://github.com/alexngai/git-cascade) | Git worktree and merge operations |
|
|
235
|
+
| [express](https://expressjs.com/) | REST API server |
|
|
236
|
+
| [ws](https://github.com/websockets/ws) | ACP WebSocket transport |
|
|
175
237
|
|
|
176
238
|
## Testing
|
|
177
239
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"macro-agent.d.ts","sourceRoot":"","sources":["../../src/acp/macro-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,KAAK,IAAI,QAAQ,EAclB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAKpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAQvD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,UAAU,CAAC,EAAE,oBAAoB,CAAC;CACnC;AAoFD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,mBAAmB,EAC/B,MAAM,EAAE,gBAAgB,GACvB,QAAQ,
|
|
1
|
+
{"version":3,"file":"macro-agent.d.ts","sourceRoot":"","sources":["../../src/acp/macro-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,KAAK,IAAI,QAAQ,EAclB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAKpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAQvD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,UAAU,CAAC,EAAE,oBAAoB,CAAC;CACnC;AAoFD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,mBAAmB,EAC/B,MAAM,EAAE,gBAAgB,GACvB,QAAQ,CAiqBV;AAED;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/acp/macro-agent.js
CHANGED
|
@@ -290,9 +290,7 @@ export function createMacroAgent(connection, config) {
|
|
|
290
290
|
async newSession(params) {
|
|
291
291
|
const cwd = params.cwd ?? defaultCwd;
|
|
292
292
|
// Get or create a head manager for this workspace
|
|
293
|
-
const headManager = await agentManager.getOrCreateHeadManager({
|
|
294
|
-
cwd,
|
|
295
|
-
});
|
|
293
|
+
const headManager = await agentManager.getOrCreateHeadManager({ cwd });
|
|
296
294
|
// Create session mapping
|
|
297
295
|
const mapping = sessionMapper.createMapping(headManager.session_id, headManager.id);
|
|
298
296
|
// Annotate sessionlog with swarm metadata (best effort)
|