multi-agent-protocol 0.0.1 → 0.0.3
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/README.md +96 -8
- package/docs/00-design-specification.md +460 -0
- package/docs/01-open-questions.md +1055 -0
- package/docs/02-wire-protocol.md +296 -0
- package/docs/03-streaming-semantics.md +252 -0
- package/docs/04-error-handling.md +231 -0
- package/docs/05-connection-model.md +244 -0
- package/docs/06-visibility-permissions.md +243 -0
- package/docs/07-federation.md +259 -0
- package/docs/08-macro-agent-migration.md +253 -0
- package/package.json +28 -30
- package/schema/meta.json +337 -0
- package/schema/schema.json +1828 -0
- package/dist/index.d.mts +0 -37
- package/dist/index.d.ts +0 -37
- package/dist/index.js +0 -16
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -13
- package/dist/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,21 +1,109 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Multi-Agent Protocol (MAP)
|
|
2
2
|
|
|
3
|
-
A protocol for
|
|
3
|
+
A JSON-RPC based protocol for observing, coordinating, and routing messages within multi-agent AI systems.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Unlike protocols designed for single-agent interaction (ACP) or peer-to-peer agent delegation (A2A), MAP provides a **window into** a multi-agent system with visibility into its internal structure, agent relationships, and message flows.
|
|
8
|
+
|
|
9
|
+
MAP provides a standardized way for:
|
|
10
|
+
- **Clients** to observe and interact with agent systems (with configurable visibility)
|
|
11
|
+
- **Agents** to communicate, form hierarchies, and join scopes
|
|
12
|
+
- **Systems** to federate and route messages across boundaries
|
|
13
|
+
|
|
14
|
+
### Protocol Landscape
|
|
15
|
+
|
|
16
|
+
| Protocol | Relationship | Visibility | Primary Use |
|
|
17
|
+
|----------|--------------|------------|-------------|
|
|
18
|
+
| MCP | Agent → Tool | N/A | Tool invocation |
|
|
19
|
+
| ACP | Client → Agent | Opaque | Single-agent sessions |
|
|
20
|
+
| A2A | Agent → Agent (peer) | Opaque | Cross-org delegation |
|
|
21
|
+
| **MAP** | Client → System | Transparent | Internal orchestration |
|
|
22
|
+
|
|
23
|
+
## Packages
|
|
24
|
+
|
|
25
|
+
| Package | Description |
|
|
26
|
+
|---------|-------------|
|
|
27
|
+
| [@multi-agent-protocol/sdk](./ts-sdk) | TypeScript SDK for MAP |
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
6
30
|
|
|
7
31
|
```bash
|
|
8
|
-
npm install multi-agent-protocol
|
|
32
|
+
npm install @multi-agent-protocol/sdk
|
|
9
33
|
```
|
|
10
34
|
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
35
|
```typescript
|
|
14
|
-
import {
|
|
36
|
+
import { ClientConnection, createStreamPair } from '@multi-agent-protocol/sdk';
|
|
15
37
|
|
|
16
|
-
//
|
|
38
|
+
// Connect to a MAP server
|
|
39
|
+
const client = new ClientConnection(stream, { name: 'My Client' });
|
|
40
|
+
await client.connect();
|
|
41
|
+
|
|
42
|
+
// Subscribe to events
|
|
43
|
+
const subscription = await client.subscribe({
|
|
44
|
+
eventTypes: ['agent.registered', 'agent.state.changed'],
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
for await (const event of subscription) {
|
|
48
|
+
console.log(event.type, event.data);
|
|
49
|
+
}
|
|
17
50
|
```
|
|
18
51
|
|
|
52
|
+
## Features
|
|
53
|
+
|
|
54
|
+
- **Real-time streaming** - Subscribe to events with backpressure support
|
|
55
|
+
- **Auto-reconnection** - Exponential backoff with subscription restoration
|
|
56
|
+
- **Permission system** - 4-layer access control (system, participant, scope, agent)
|
|
57
|
+
- **Federation** - Connect multiple MAP systems with envelope-based routing
|
|
58
|
+
- **Causal ordering** - Events released in dependency order
|
|
59
|
+
|
|
60
|
+
## Documentation
|
|
61
|
+
|
|
62
|
+
### Schema
|
|
63
|
+
|
|
64
|
+
The protocol schema is defined in [`schema/`](./schema/):
|
|
65
|
+
- [`schema.json`](./schema/schema.json) - Complete JSON Schema for all MAP message types
|
|
66
|
+
- [`meta.json`](./schema/meta.json) - Method metadata, tiers, and error codes
|
|
67
|
+
|
|
68
|
+
## Repository Structure
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
multi-agent-protocol/
|
|
72
|
+
├── docs/ # Design specifications
|
|
73
|
+
├── schema/ # JSON Schema and metadata
|
|
74
|
+
│ ├── schema.json # Protocol message schemas
|
|
75
|
+
│ └── meta.json # Method tiers and error codes
|
|
76
|
+
└── ts-sdk/ # TypeScript SDK implementation
|
|
77
|
+
├── src/ # Source code
|
|
78
|
+
└── docs/ # SDK-specific docs (gap analysis)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Development
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Install dependencies
|
|
85
|
+
npm install
|
|
86
|
+
|
|
87
|
+
# Build SDK
|
|
88
|
+
npm run build -w ts-sdk
|
|
89
|
+
|
|
90
|
+
# Run tests
|
|
91
|
+
npm test -w ts-sdk
|
|
92
|
+
|
|
93
|
+
# Type check
|
|
94
|
+
npm run typecheck -w ts-sdk
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Protocol Methods
|
|
98
|
+
|
|
99
|
+
The protocol defines 27 methods across three tiers:
|
|
100
|
+
|
|
101
|
+
**Core (Required):** `map/connect`, `map/disconnect`, `map/send`, `map/subscribe`, `map/unsubscribe`, `map/agents/list`, `map/agents/get`
|
|
102
|
+
|
|
103
|
+
**Structure (Recommended):** Agent lifecycle (`register`, `spawn`, `unregister`, `update`, `stop`, `suspend`, `resume`), scope management (`scopes/create`, `join`, `leave`), and structure queries
|
|
104
|
+
|
|
105
|
+
**Extensions (Optional):** Federation (`federation/connect`, `federation/route`), session management, and steering (`map/inject`)
|
|
106
|
+
|
|
19
107
|
## License
|
|
20
108
|
|
|
21
109
|
MIT
|
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
# Multi-Agent Protocol (MAP) Design Specification
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
MAP (Multi-Agent Protocol) is a communication protocol for **observing, coordinating, and routing messages within multi-agent AI systems**. Unlike protocols designed for single-agent interaction (ACP) or peer-to-peer agent delegation (A2A), MAP provides a **window into** a multi-agent system with visibility into its internal structure, agent relationships, and message flows.
|
|
6
|
+
|
|
7
|
+
### Design Philosophy
|
|
8
|
+
|
|
9
|
+
**Primary Abstraction**: The agent and its relationships to other agents, followed by the messages that flow between them.
|
|
10
|
+
|
|
11
|
+
**Core Principle**: MAP treats the multi-agent system as a **transparent, observable entity** rather than an opaque black box. Clients connecting via MAP can see (with appropriate permissions) the internal structure and activity of the system.
|
|
12
|
+
|
|
13
|
+
**Key Design Principles**:
|
|
14
|
+
1. **Topology is configuration, not protocol** - The same protocol supports hierarchical orchestration (like Claude Code's Task agents) and peer collaboration (like macro-agent workers)
|
|
15
|
+
2. **Unified messaging with metadata** - One message type with metadata that specializes behavior (task delegation, peer messaging, broadcast)
|
|
16
|
+
3. **Visibility is first-class** - Agents and scopes have explicit visibility settings; "parent-only" visibility enables hidden sub-agents
|
|
17
|
+
4. **Lifecycle is descriptive, not prescriptive** - Protocol records lifecycle metadata; implementations decide how to enforce it
|
|
18
|
+
5. **Extensibility at every layer** - States, lifecycle patterns, visibility levels, and message metadata are all extensible
|
|
19
|
+
6. **Unified participant model** - Agents and clients speak the same protocol; difference is in capabilities and visibility, not in the wire format
|
|
20
|
+
|
|
21
|
+
### What MAP Is NOT
|
|
22
|
+
|
|
23
|
+
- **Not ACP**: ACP is client ↔ single agent. MAP is client ↔ multi-agent system.
|
|
24
|
+
- **Not A2A**: A2A is peer agent ↔ peer agent (opaque). MAP is for internal systems with visibility.
|
|
25
|
+
- **Not a replacement**: MAP complements ACP/A2A. Agents can use ACP for client interaction, A2A for external peers, and MAP for internal coordination.
|
|
26
|
+
|
|
27
|
+
### Reference Implementation: Claude Code as Multi-Agent System
|
|
28
|
+
|
|
29
|
+
Claude Code demonstrates the "orchestration pattern" - a multi-agent system where:
|
|
30
|
+
- User interacts with one main agent
|
|
31
|
+
- Sub-agents (Task tool) are spawned for specific work
|
|
32
|
+
- Sub-agents are invisible to the user
|
|
33
|
+
- Communication is hierarchical (parent ↔ child)
|
|
34
|
+
- Agents are task-scoped (ephemeral)
|
|
35
|
+
|
|
36
|
+
MAP should support this pattern as naturally as it supports the full-visibility "collaboration pattern" of macro-agent.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Protocol Landscape & Relationships
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
44
|
+
│ Agent Protocol Ecosystem │
|
|
45
|
+
├─────────────────────────────────────────────────────────────────────────────┤
|
|
46
|
+
│ │
|
|
47
|
+
│ Protocol Relationship Visibility Primary Use │
|
|
48
|
+
│ ──────── ──────────── ────────── ─────────── │
|
|
49
|
+
│ MCP Agent → Tool N/A Tool invocation │
|
|
50
|
+
│ ACP Client → Agent Opaque Single-agent sessions │
|
|
51
|
+
│ A2A Agent → Agent (peer) Opaque Cross-org delegation │
|
|
52
|
+
│ MAP Client → System Transparent Internal orchestration │
|
|
53
|
+
│ Agent → Agent (internal) │
|
|
54
|
+
│ │
|
|
55
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
56
|
+
|
|
57
|
+
Human/Client
|
|
58
|
+
│
|
|
59
|
+
┌──────────────┼──────────────┐
|
|
60
|
+
│ │ │
|
|
61
|
+
ACP MAP (direct)
|
|
62
|
+
│ │ │
|
|
63
|
+
▼ ▼ ▼
|
|
64
|
+
┌─────────┐ ┌───────────────────────────┐
|
|
65
|
+
│ Single │ │ Multi-Agent System │
|
|
66
|
+
│ Agent │ │ ┌─────┐ ┌─────┐ │
|
|
67
|
+
└─────────┘ │ │Agent│◄─MAP─►│Agent│ │
|
|
68
|
+
│ └──┬──┘ └──┬──┘ │
|
|
69
|
+
│ │ MAP │ │
|
|
70
|
+
│ └──────┬──────┘ │
|
|
71
|
+
│ │ │
|
|
72
|
+
│ ┌─────▼─────┐ │
|
|
73
|
+
│ │ Agent │ │──── A2A ────► External
|
|
74
|
+
│ └───────────┘ │ Peers
|
|
75
|
+
└───────────────────────────┘
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Integration Patterns
|
|
79
|
+
|
|
80
|
+
**Pattern 1: MAP + ACP (Hybrid Client)**
|
|
81
|
+
```
|
|
82
|
+
Client uses ACP for single-agent focus, MAP for system awareness.
|
|
83
|
+
The MAP SDK can convert MAP streams into ACP-compatible sessions.
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Pattern 2: MAP + A2A (Federated Systems)**
|
|
87
|
+
```
|
|
88
|
+
Internal coordination via MAP.
|
|
89
|
+
External peer communication via A2A.
|
|
90
|
+
Individual agents can participate in both.
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Pattern 3: MAP-to-MAP (System Federation)**
|
|
94
|
+
```
|
|
95
|
+
Two MAP systems can communicate via their exposed message channels.
|
|
96
|
+
Each system remains internally transparent, externally opaque.
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Unified Participant Model
|
|
102
|
+
|
|
103
|
+
A core design principle of MAP is that **agents and clients speak the same protocol**. The difference is not in the wire format, but in:
|
|
104
|
+
- **Capabilities**: What actions they can perform
|
|
105
|
+
- **Visibility**: What they can see
|
|
106
|
+
- **Transport**: How they connect
|
|
107
|
+
|
|
108
|
+
This enables:
|
|
109
|
+
- Consistent semantics across all participants
|
|
110
|
+
- Federation as a natural extension (remote agents are just participants)
|
|
111
|
+
- Hierarchical composition (agents can be servers to their children)
|
|
112
|
+
- Transport optimization without protocol changes
|
|
113
|
+
|
|
114
|
+
### Participants
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
// PARTICIPANT: The base abstraction for all MAP entities
|
|
118
|
+
// Both agents and clients are participants in the protocol
|
|
119
|
+
interface MAPParticipant {
|
|
120
|
+
id: string;
|
|
121
|
+
type: "agent" | "client" | "system" | "gateway";
|
|
122
|
+
|
|
123
|
+
// What this participant can see (determined by role, scope, grants)
|
|
124
|
+
visibility: MAPParticipantVisibility;
|
|
125
|
+
|
|
126
|
+
// What this participant can do
|
|
127
|
+
capabilities: MAPParticipantCapabilities;
|
|
128
|
+
|
|
129
|
+
// How this participant is connected
|
|
130
|
+
transport: MAPTransport;
|
|
131
|
+
|
|
132
|
+
// Session information
|
|
133
|
+
session?: MAPSession;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface MAPParticipantCapabilities {
|
|
137
|
+
// Observation
|
|
138
|
+
canObserve: boolean; // Can subscribe to events
|
|
139
|
+
canQuery: boolean; // Can query agents/structure
|
|
140
|
+
|
|
141
|
+
// Messaging
|
|
142
|
+
canSend: boolean; // Can send messages
|
|
143
|
+
canReceive: boolean; // Can receive messages addressed to it
|
|
144
|
+
canBroadcast: boolean; // Can send to scopes/roles
|
|
145
|
+
|
|
146
|
+
// Agent management
|
|
147
|
+
canSpawn: boolean; // Can create child agents
|
|
148
|
+
canRegister: boolean; // Can register agents (not as children)
|
|
149
|
+
canUnregister: boolean; // Can remove agents
|
|
150
|
+
|
|
151
|
+
// Control
|
|
152
|
+
canSteer: boolean; // Can inject context/control agents
|
|
153
|
+
canStop: boolean; // Can request agent termination
|
|
154
|
+
|
|
155
|
+
// Scope management
|
|
156
|
+
canCreateScopes: boolean;
|
|
157
|
+
canManageScopes: boolean;
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Capability Matrix
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
165
|
+
│ Capability Matrix │
|
|
166
|
+
├─────────────────────────────────────────────────────────────────────────────┤
|
|
167
|
+
│ │
|
|
168
|
+
│ Capability │ Client │ Agent │ System │ Gateway │
|
|
169
|
+
│ │ (observer)│ (worker) │ │ (federation) │
|
|
170
|
+
│ ──────────────────┼──────────┼──────────┼──────────┼────────────────────── │
|
|
171
|
+
│ canObserve │ ✓ │ ✓* │ ✓ │ ✓* │
|
|
172
|
+
│ canQuery │ ✓ │ ✓* │ ✓ │ ✓* │
|
|
173
|
+
│ canSend │ ✓* │ ✓ │ ✓ │ ✓ │
|
|
174
|
+
│ canReceive │ ✗ │ ✓ │ ✓ │ ✓ │
|
|
175
|
+
│ canBroadcast │ ✗ │ ✓* │ ✓ │ ✗ │
|
|
176
|
+
│ canSpawn │ ✗ │ ✓ │ ✓ │ ✗ │
|
|
177
|
+
│ canRegister │ ✗ │ ✓* │ ✓ │ ✗ │
|
|
178
|
+
│ canUnregister │ ✗ │ ✓* │ ✓ │ ✗ │
|
|
179
|
+
│ canSteer │ ✓* │ ✓* │ ✓ │ ✗ │
|
|
180
|
+
│ canStop │ ✓* │ ✓* │ ✓ │ ✗ │
|
|
181
|
+
│ canCreateScopes │ ✗ │ ✓* │ ✓ │ ✗ │
|
|
182
|
+
│ canManageScopes │ ✗ │ ✓* │ ✓ │ ✗ │
|
|
183
|
+
│ │
|
|
184
|
+
│ ✓ = default yes ✗ = default no * = depends on role/permissions │
|
|
185
|
+
│ │
|
|
186
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Hierarchical Composition
|
|
190
|
+
|
|
191
|
+
Agents can be both clients (to their parent/system) and servers (to their children):
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
195
|
+
│ Hierarchical Composition │
|
|
196
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
197
|
+
│ │
|
|
198
|
+
│ External Client (dashboard) │
|
|
199
|
+
│ │ │
|
|
200
|
+
│ │ MAP (websocket) │
|
|
201
|
+
│ ▼ │
|
|
202
|
+
│ ┌─────────────────────────────────────────────────────────┐ │
|
|
203
|
+
│ │ Coordinator │ │
|
|
204
|
+
│ │ - Is a participant (receives from client) │ │
|
|
205
|
+
│ │ - Acts as MAP router for children │ │
|
|
206
|
+
│ └─────────────────────────────────────────────────────────┘ │
|
|
207
|
+
│ │ │ │
|
|
208
|
+
│ │ MAP (inprocess) │ MAP (inprocess) │
|
|
209
|
+
│ ▼ ▼ │
|
|
210
|
+
│ ┌──────────────┐ ┌──────────────┐ │
|
|
211
|
+
│ │ Worker A │ │ Worker B │ │
|
|
212
|
+
│ │ - Participant│ │ - Participant│ │
|
|
213
|
+
│ │ - Has children│ └──────────────┘ │
|
|
214
|
+
│ └──────────────┘ │
|
|
215
|
+
│ │ │
|
|
216
|
+
│ │ MAP (stdio) │
|
|
217
|
+
│ ▼ │
|
|
218
|
+
│ ┌──────────────┐ │
|
|
219
|
+
│ │ Sub-agent │ (Claude Code pattern) │
|
|
220
|
+
│ │ - Leaf node │ │
|
|
221
|
+
│ └──────────────┘ │
|
|
222
|
+
│ │
|
|
223
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Transport Layer
|
|
229
|
+
|
|
230
|
+
MAP is transport-agnostic. The protocol defines message format and semantics; the transport layer handles delivery.
|
|
231
|
+
|
|
232
|
+
### Transport Bindings
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
interface MAPTransport {
|
|
236
|
+
type: string;
|
|
237
|
+
|
|
238
|
+
// Send a message or request
|
|
239
|
+
send(frame: MAPFrame): Promise<void>;
|
|
240
|
+
|
|
241
|
+
// Receive messages/events
|
|
242
|
+
receive(): AsyncIterable<MAPFrame>;
|
|
243
|
+
|
|
244
|
+
// Connection lifecycle
|
|
245
|
+
close(): Promise<void>;
|
|
246
|
+
|
|
247
|
+
// Connection state
|
|
248
|
+
state: "connecting" | "connected" | "disconnected" | "error";
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Built-in Transport Bindings
|
|
253
|
+
|
|
254
|
+
| Transport | Use Case | Framing |
|
|
255
|
+
|-----------|----------|---------|
|
|
256
|
+
| WebSocket | Remote clients, federation | JSON messages |
|
|
257
|
+
| stdio | Subprocess agents (Claude Code) | NDJSON (newline-delimited) |
|
|
258
|
+
| In-process | Co-located agents | Direct object passing |
|
|
259
|
+
| HTTP + SSE | Stateless clients | POST + Server-Sent Events |
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Core Objects
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
// AGENT: The fundamental unit in the system
|
|
267
|
+
interface MAPAgent {
|
|
268
|
+
id: string;
|
|
269
|
+
name?: string;
|
|
270
|
+
|
|
271
|
+
// Relationships
|
|
272
|
+
parent?: string; // Hierarchical parent
|
|
273
|
+
relationships?: MAPRelationship[]; // Other connections (peers, custom)
|
|
274
|
+
|
|
275
|
+
// State (extensible - implementations can add custom states)
|
|
276
|
+
state: MAPAgentState;
|
|
277
|
+
|
|
278
|
+
// Classification
|
|
279
|
+
role?: string; // Role identifier
|
|
280
|
+
scopes: string[]; // Scope memberships
|
|
281
|
+
|
|
282
|
+
// Visibility (who can see/address this agent)
|
|
283
|
+
visibility?: MAPVisibility;
|
|
284
|
+
|
|
285
|
+
// Lifecycle (descriptive, not prescriptive)
|
|
286
|
+
lifecycle?: MAPAgentLifecycle;
|
|
287
|
+
|
|
288
|
+
// Metadata
|
|
289
|
+
metadata?: Record<string, unknown>;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Agent states - extensible for implementations
|
|
293
|
+
type MAPAgentState =
|
|
294
|
+
| "registered" // Known to system, not yet active
|
|
295
|
+
| "active" // Running and responsive
|
|
296
|
+
| "busy" // Active but processing
|
|
297
|
+
| "idle" // Active but waiting
|
|
298
|
+
| "suspended" // Paused, can be resumed
|
|
299
|
+
| "stopping" // Shutting down gracefully
|
|
300
|
+
| "stopped" // Terminated, may have result
|
|
301
|
+
| "failed" // Terminated abnormally
|
|
302
|
+
| string; // Extensible for custom states
|
|
303
|
+
|
|
304
|
+
// MESSAGE: Unified communication with metadata specialization
|
|
305
|
+
interface MAPMessage {
|
|
306
|
+
id: string;
|
|
307
|
+
from: string; // Sender (agent, client, system)
|
|
308
|
+
to: MAPAddress; // Target address
|
|
309
|
+
|
|
310
|
+
// Payload - flexible structure
|
|
311
|
+
payload: unknown;
|
|
312
|
+
|
|
313
|
+
meta: {
|
|
314
|
+
timestamp: number;
|
|
315
|
+
relationship?: "parent-to-child" | "child-to-parent" | "peer" | "broadcast";
|
|
316
|
+
expectsResponse?: boolean;
|
|
317
|
+
correlationId?: string;
|
|
318
|
+
isResult?: boolean;
|
|
319
|
+
priority?: "urgent" | "high" | "normal" | "low";
|
|
320
|
+
delivery?: "fire-and-forget" | "acknowledged" | "guaranteed";
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Addressing Model
|
|
326
|
+
|
|
327
|
+
```typescript
|
|
328
|
+
// Flexible addressing for any topology
|
|
329
|
+
type MAPAddress =
|
|
330
|
+
// Direct addressing
|
|
331
|
+
| string // Shorthand: agent ID
|
|
332
|
+
| { agent: string } // Single agent
|
|
333
|
+
| { agents: string[] } // Multiple agents
|
|
334
|
+
|
|
335
|
+
// Structural addressing
|
|
336
|
+
| { scope: string } // All in scope
|
|
337
|
+
| { role: string; within?: string } // Role, optionally scoped
|
|
338
|
+
|
|
339
|
+
// Hierarchical addressing (relative to sender)
|
|
340
|
+
| { parent: true } // Sender's parent
|
|
341
|
+
| { children: true; depth?: number } // Sender's children
|
|
342
|
+
| { ancestors: true; depth?: number } // Up the tree
|
|
343
|
+
| { descendants: true; depth?: number } // Down the tree
|
|
344
|
+
| { siblings: true } // Same parent
|
|
345
|
+
|
|
346
|
+
// Special
|
|
347
|
+
| { broadcast: true } // All agents in system
|
|
348
|
+
| { system: true } // The system/router itself
|
|
349
|
+
| { participant: string } // Any participant by ID
|
|
350
|
+
| { participants: "all" | "agents" | "clients" }; // Categories
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## Protocol Methods
|
|
356
|
+
|
|
357
|
+
### Tier 1: Core (Required)
|
|
358
|
+
|
|
359
|
+
```typescript
|
|
360
|
+
// SYSTEM
|
|
361
|
+
"map/connect" // Connect to system, negotiate capabilities
|
|
362
|
+
"map/disconnect" // Graceful disconnect
|
|
363
|
+
|
|
364
|
+
// SESSION
|
|
365
|
+
"map/session/list" // List participant's sessions
|
|
366
|
+
"map/session/load" // Load/reconnect to existing session
|
|
367
|
+
"map/session/close" // Explicitly end session
|
|
368
|
+
|
|
369
|
+
// AGENTS (read)
|
|
370
|
+
"map/agents/list" // List agents with filters (server-filtered)
|
|
371
|
+
"map/agents/get" // Get single agent details
|
|
372
|
+
|
|
373
|
+
// MESSAGING
|
|
374
|
+
"map/send" // Send message to address
|
|
375
|
+
|
|
376
|
+
// STREAMING
|
|
377
|
+
"map/subscribe" // Subscribe to event streams
|
|
378
|
+
"map/unsubscribe" // Unsubscribe from streams
|
|
379
|
+
|
|
380
|
+
// AUTH
|
|
381
|
+
"map/auth/refresh" // In-band token refresh
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### Tier 2: Structure (Recommended)
|
|
385
|
+
|
|
386
|
+
```typescript
|
|
387
|
+
// AGENTS (write)
|
|
388
|
+
"map/agents/register" // Add agent to system
|
|
389
|
+
"map/agents/spawn" // Register + initial task (atomic)
|
|
390
|
+
"map/agents/unregister" // Remove agent
|
|
391
|
+
"map/agents/update" // Update agent state/metadata
|
|
392
|
+
|
|
393
|
+
// LIFECYCLE CONTROL
|
|
394
|
+
"map/agents/stop" // Request graceful stop
|
|
395
|
+
"map/agents/suspend" // Pause agent
|
|
396
|
+
"map/agents/resume" // Resume suspended agent
|
|
397
|
+
|
|
398
|
+
// STRUCTURE
|
|
399
|
+
"map/structure/graph" // Get relationship graph
|
|
400
|
+
|
|
401
|
+
// SCOPES
|
|
402
|
+
"map/scopes/list" // List scopes
|
|
403
|
+
"map/scopes/create" // Create scope
|
|
404
|
+
"map/scopes/delete" // Delete scope
|
|
405
|
+
"map/scopes/join" // Agent joins scope
|
|
406
|
+
"map/scopes/leave" // Agent leaves scope
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### Tier 3: Extensions (Optional)
|
|
410
|
+
|
|
411
|
+
```typescript
|
|
412
|
+
// TASKS
|
|
413
|
+
"map/tasks/create" // Create task
|
|
414
|
+
"map/tasks/assign" // Assign to agent
|
|
415
|
+
"map/tasks/update" // Update status
|
|
416
|
+
"map/tasks/list" // List tasks
|
|
417
|
+
|
|
418
|
+
// STEERING
|
|
419
|
+
"map/inject" // Context injection with delivery semantics
|
|
420
|
+
|
|
421
|
+
// FEDERATION
|
|
422
|
+
"map/federation/connect" // Connect to peer MAP system
|
|
423
|
+
"map/federation/route" // Route message to peer system
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
---
|
|
427
|
+
|
|
428
|
+
## Design Decisions Summary
|
|
429
|
+
|
|
430
|
+
| Decision | Choice | Rationale |
|
|
431
|
+
|----------|--------|-----------|
|
|
432
|
+
| Primary abstraction | Agent + relationships, then messages | Matches mental model of multi-agent systems |
|
|
433
|
+
| Topology | Configuration, not protocol | Same protocol supports orchestration (tree) and collaboration (mesh) |
|
|
434
|
+
| Participant model | Unified - agents and clients same protocol | Consistent semantics, transport optimization, natural federation |
|
|
435
|
+
| Transport | Pluggable (WebSocket, stdio, in-process, HTTP) | Same protocol, optimized for different deployment contexts |
|
|
436
|
+
| Messaging | Unified with metadata specialization | One message type; metadata determines behavior |
|
|
437
|
+
| Lifecycle | Descriptive, not prescriptive | Protocol records metadata; implementation decides enforcement |
|
|
438
|
+
| Visibility | First-class on agents and scopes | Configurable per-agent and per-scope |
|
|
439
|
+
| Wire format | JSON-RPC 2.0 | Consistent with ACP, A2A, MCP |
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
## Related Specs
|
|
444
|
+
|
|
445
|
+
- [01-open-questions.md](01-open-questions.md): Open Questions & Design Decisions
|
|
446
|
+
- [02-wire-protocol.md](02-wire-protocol.md): Wire Protocol & ACP Compatibility Layer
|
|
447
|
+
- [03-streaming-semantics.md](03-streaming-semantics.md): Streaming Semantics
|
|
448
|
+
- [04-error-handling.md](04-error-handling.md): Error Handling & Failure Modes
|
|
449
|
+
- [05-connection-model.md](05-connection-model.md): Connection Model & Client Patterns
|
|
450
|
+
- [06-visibility-permissions.md](06-visibility-permissions.md): Visibility & Permission Model
|
|
451
|
+
- [07-federation.md](07-federation.md): Federation & System-to-System Communication
|
|
452
|
+
- [08-macro-agent-migration.md](08-macro-agent-migration.md): macro-agent Migration Example
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
## References
|
|
457
|
+
|
|
458
|
+
- ACP: [Agent Client Protocol](https://agentclientprotocol.com)
|
|
459
|
+
- A2A: [Agent-to-Agent Protocol](https://a2a-protocol.org/latest/)
|
|
460
|
+
- MCP: [Model Context Protocol](https://modelcontextprotocol.io)
|