macro-agent 0.0.13 → 0.0.15
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.local.json +59 -0
- package/dist/agent/agent-manager.d.ts.map +1 -1
- package/dist/agent/agent-manager.js +10 -4
- package/dist/agent/agent-manager.js.map +1 -1
- package/dist/cli/acp.d.ts +6 -0
- package/dist/cli/acp.d.ts.map +1 -1
- package/dist/cli/acp.js +16 -2
- package/dist/cli/acp.js.map +1 -1
- package/dist/map/adapter/index.d.ts +1 -1
- package/dist/map/adapter/index.d.ts.map +1 -1
- package/dist/map/adapter/index.js +1 -1
- package/dist/map/adapter/index.js.map +1 -1
- package/dist/map/utils/address-translation.d.ts +99 -0
- package/dist/map/utils/address-translation.d.ts.map +1 -0
- package/dist/map/utils/address-translation.js +285 -0
- package/dist/map/utils/address-translation.js.map +1 -0
- package/dist/map/utils/index.d.ts +7 -0
- package/dist/map/utils/index.d.ts.map +1 -0
- package/dist/map/utils/index.js +7 -0
- package/dist/map/utils/index.js.map +1 -0
- package/dist/server/combined-server.d.ts.map +1 -1
- package/dist/server/combined-server.js +8 -1
- package/dist/server/combined-server.js.map +1 -1
- package/dist/store/event-store.js +9 -2
- package/dist/store/event-store.js.map +1 -1
- package/dist/store/types/agents.d.ts +2 -0
- package/dist/store/types/agents.d.ts.map +1 -1
- package/package.json +4 -4
- package/references/acp-factory-ref/CHANGELOG.md +33 -0
- package/references/acp-factory-ref/LICENSE +21 -0
- package/references/acp-factory-ref/README.md +341 -0
- package/references/acp-factory-ref/package-lock.json +3102 -0
- package/references/acp-factory-ref/package.json +96 -0
- package/references/acp-factory-ref/python/CHANGELOG.md +33 -0
- package/references/acp-factory-ref/python/LICENSE +21 -0
- package/references/acp-factory-ref/python/Makefile +57 -0
- package/references/acp-factory-ref/python/README.md +253 -0
- package/references/acp-factory-ref/python/pyproject.toml +73 -0
- package/references/acp-factory-ref/python/tests/__init__.py +0 -0
- package/references/acp-factory-ref/python/tests/e2e/__init__.py +1 -0
- package/references/acp-factory-ref/python/tests/e2e/test_codex_e2e.py +349 -0
- package/references/acp-factory-ref/python/tests/e2e/test_gemini_e2e.py +165 -0
- package/references/acp-factory-ref/python/tests/e2e/test_opencode_e2e.py +296 -0
- package/references/acp-factory-ref/python/tests/test_client_handler.py +543 -0
- package/references/acp-factory-ref/python/tests/test_pushable.py +199 -0
- package/references/claude-code-acp/.github/workflows/ci.yml +45 -0
- package/references/claude-code-acp/.github/workflows/publish.yml +34 -0
- package/references/claude-code-acp/.prettierrc.json +4 -0
- package/references/claude-code-acp/CHANGELOG.md +249 -0
- package/references/claude-code-acp/LICENSE +222 -0
- package/references/claude-code-acp/README.md +53 -0
- package/references/claude-code-acp/docs/RELEASES.md +24 -0
- package/references/claude-code-acp/eslint.config.js +48 -0
- package/references/claude-code-acp/package-lock.json +4570 -0
- package/references/claude-code-acp/package.json +88 -0
- package/references/claude-code-acp/scripts/release.sh +119 -0
- package/references/claude-code-acp/src/acp-agent.ts +2079 -0
- package/references/claude-code-acp/src/index.ts +26 -0
- package/references/claude-code-acp/src/lib.ts +38 -0
- package/references/claude-code-acp/src/mcp-server.ts +911 -0
- package/references/claude-code-acp/src/settings.ts +522 -0
- package/references/claude-code-acp/src/tests/.claude/commands/quick-math.md +5 -0
- package/references/claude-code-acp/src/tests/.claude/commands/say-hello.md +6 -0
- package/references/claude-code-acp/src/tests/acp-agent-fork.test.ts +479 -0
- package/references/claude-code-acp/src/tests/acp-agent.test.ts +1502 -0
- package/references/claude-code-acp/src/tests/extract-lines.test.ts +103 -0
- package/references/claude-code-acp/src/tests/fork-session.test.ts +335 -0
- package/references/claude-code-acp/src/tests/replace-and-calculate-location.test.ts +334 -0
- package/references/claude-code-acp/src/tests/settings.test.ts +617 -0
- package/references/claude-code-acp/src/tests/skills-options.test.ts +187 -0
- package/references/claude-code-acp/src/tests/tools.test.ts +318 -0
- package/references/claude-code-acp/src/tests/typescript-declarations.test.ts +558 -0
- package/references/claude-code-acp/src/tools.ts +819 -0
- package/references/claude-code-acp/src/utils.ts +171 -0
- package/references/claude-code-acp/tsconfig.json +18 -0
- package/references/claude-code-acp/vitest.config.ts +19 -0
- package/references/multi-agent-protocol/.sudocode/issues.jsonl +111 -0
- package/references/multi-agent-protocol/.sudocode/specs.jsonl +13 -0
- package/references/multi-agent-protocol/LICENSE +21 -0
- package/references/multi-agent-protocol/README.md +113 -0
- package/references/multi-agent-protocol/docs/00-design-specification.md +496 -0
- package/references/multi-agent-protocol/docs/01-open-questions.md +1050 -0
- package/references/multi-agent-protocol/docs/02-wire-protocol.md +296 -0
- package/references/multi-agent-protocol/docs/03-streaming-semantics.md +252 -0
- package/references/multi-agent-protocol/docs/04-error-handling.md +231 -0
- package/references/multi-agent-protocol/docs/05-connection-model.md +244 -0
- package/references/multi-agent-protocol/docs/06-visibility-permissions.md +243 -0
- package/references/multi-agent-protocol/docs/07-federation.md +259 -0
- package/references/multi-agent-protocol/docs/08-macro-agent-migration.md +253 -0
- package/references/multi-agent-protocol/docs/09-authentication.md +680 -0
- package/references/multi-agent-protocol/docs/10-mail-protocol.md +553 -0
- package/references/multi-agent-protocol/docs/agent-iam-integration.md +877 -0
- package/references/multi-agent-protocol/docs/agentic-mesh-integration-draft.md +459 -0
- package/references/multi-agent-protocol/docs/git-transport-draft.md +251 -0
- package/references/multi-agent-protocol/docs-site/Gemfile +22 -0
- package/references/multi-agent-protocol/docs-site/README.md +82 -0
- package/references/multi-agent-protocol/docs-site/_config.yml +91 -0
- package/references/multi-agent-protocol/docs-site/_includes/head_custom.html +20 -0
- package/references/multi-agent-protocol/docs-site/_sass/color_schemes/map.scss +42 -0
- package/references/multi-agent-protocol/docs-site/_sass/custom/custom.scss +34 -0
- package/references/multi-agent-protocol/docs-site/examples/full-integration.md +510 -0
- package/references/multi-agent-protocol/docs-site/examples/index.md +138 -0
- package/references/multi-agent-protocol/docs-site/examples/simple-chat.md +282 -0
- package/references/multi-agent-protocol/docs-site/examples/task-queue.md +399 -0
- package/references/multi-agent-protocol/docs-site/getting-started/index.md +98 -0
- package/references/multi-agent-protocol/docs-site/getting-started/installation.md +219 -0
- package/references/multi-agent-protocol/docs-site/getting-started/overview.md +172 -0
- package/references/multi-agent-protocol/docs-site/getting-started/quickstart.md +237 -0
- package/references/multi-agent-protocol/docs-site/index.md +136 -0
- package/references/multi-agent-protocol/docs-site/protocol/authentication.md +391 -0
- package/references/multi-agent-protocol/docs-site/protocol/connection-model.md +376 -0
- package/references/multi-agent-protocol/docs-site/protocol/design.md +284 -0
- package/references/multi-agent-protocol/docs-site/protocol/error-handling.md +312 -0
- package/references/multi-agent-protocol/docs-site/protocol/federation.md +449 -0
- package/references/multi-agent-protocol/docs-site/protocol/index.md +129 -0
- package/references/multi-agent-protocol/docs-site/protocol/permissions.md +398 -0
- package/references/multi-agent-protocol/docs-site/protocol/streaming.md +353 -0
- package/references/multi-agent-protocol/docs-site/protocol/wire-protocol.md +369 -0
- package/references/multi-agent-protocol/docs-site/sdk/api/agent.md +357 -0
- package/references/multi-agent-protocol/docs-site/sdk/api/client.md +380 -0
- package/references/multi-agent-protocol/docs-site/sdk/api/index.md +62 -0
- package/references/multi-agent-protocol/docs-site/sdk/api/server.md +453 -0
- package/references/multi-agent-protocol/docs-site/sdk/api/types.md +468 -0
- package/references/multi-agent-protocol/docs-site/sdk/guides/agent.md +375 -0
- package/references/multi-agent-protocol/docs-site/sdk/guides/authentication.md +405 -0
- package/references/multi-agent-protocol/docs-site/sdk/guides/client.md +352 -0
- package/references/multi-agent-protocol/docs-site/sdk/guides/index.md +89 -0
- package/references/multi-agent-protocol/docs-site/sdk/guides/server.md +360 -0
- package/references/multi-agent-protocol/docs-site/sdk/guides/testing.md +446 -0
- package/references/multi-agent-protocol/docs-site/sdk/guides/transports.md +363 -0
- package/references/multi-agent-protocol/docs-site/sdk/index.md +206 -0
- package/references/multi-agent-protocol/package-lock.json +3886 -0
- package/references/multi-agent-protocol/package.json +56 -0
- package/references/multi-agent-protocol/schema/meta.json +467 -0
- package/references/multi-agent-protocol/schema/schema.json +2558 -0
- package/src/agent/__tests__/agent-manager.test.ts +67 -1
- package/src/agent/agent-manager.ts +10 -4
- package/src/cli/__tests__/stable-instance-id.test.ts +57 -0
- package/src/cli/acp.ts +17 -2
- package/src/map/adapter/index.ts +3 -0
- package/src/server/combined-server.ts +10 -0
- package/src/store/event-store.ts +10 -3
- package/src/store/types/agents.ts +2 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Getting Started
|
|
3
|
+
nav_order: 2
|
|
4
|
+
has_children: true
|
|
5
|
+
description: "Get started with the Multi-Agent Protocol SDK"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Getting Started
|
|
9
|
+
|
|
10
|
+
Get a MAP server and connected agents running in minutes.
|
|
11
|
+
{: .fs-6 .fw-300 }
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## What You'll Learn
|
|
16
|
+
|
|
17
|
+
1. **[Overview](./overview.html)** - Understand what MAP is and when to use it
|
|
18
|
+
2. **[Quickstart](./quickstart.html)** - Run a server, agent, and client in 5 minutes
|
|
19
|
+
3. **[Installation](./installation.html)** - Install and configure the SDK
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Prerequisites
|
|
24
|
+
|
|
25
|
+
- **Node.js 18+** - MAP SDK requires Node.js 18 or later
|
|
26
|
+
- **npm or yarn** - For package management
|
|
27
|
+
- **TypeScript** (recommended) - The SDK is written in TypeScript with full type support
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Quick Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install @multi-agent-protocol/sdk
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Minimal Example
|
|
40
|
+
|
|
41
|
+
Here's the simplest possible MAP setup:
|
|
42
|
+
|
|
43
|
+
**Server:**
|
|
44
|
+
```typescript
|
|
45
|
+
import { MAPServer } from "@multi-agent-protocol/sdk/server";
|
|
46
|
+
import { WebSocketServer } from "ws";
|
|
47
|
+
|
|
48
|
+
const server = new MAPServer({ name: "MyServer" });
|
|
49
|
+
const wss = new WebSocketServer({ port: 8080 });
|
|
50
|
+
|
|
51
|
+
wss.on("connection", (ws) => {
|
|
52
|
+
const stream = websocketToStream(ws);
|
|
53
|
+
server.accept(stream).start();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
console.log("MAP Server running on ws://localhost:8080");
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Agent:**
|
|
60
|
+
```typescript
|
|
61
|
+
import { AgentConnection } from "@multi-agent-protocol/sdk";
|
|
62
|
+
|
|
63
|
+
const agent = new AgentConnection(stream, {
|
|
64
|
+
name: "Worker",
|
|
65
|
+
role: "processor"
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const { agent: registered } = await agent.connect();
|
|
69
|
+
console.log(`Agent registered: ${registered.id}`);
|
|
70
|
+
|
|
71
|
+
agent.onMessage((message) => {
|
|
72
|
+
console.log("Received:", message.payload);
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Client:**
|
|
77
|
+
```typescript
|
|
78
|
+
import { ClientConnection } from "@multi-agent-protocol/sdk";
|
|
79
|
+
|
|
80
|
+
const client = new ClientConnection(stream, { name: "Dashboard" });
|
|
81
|
+
await client.connect();
|
|
82
|
+
|
|
83
|
+
// List all agents
|
|
84
|
+
const { agents } = await client.listAgents();
|
|
85
|
+
console.log(`Found ${agents.length} agents`);
|
|
86
|
+
|
|
87
|
+
// Subscribe to events
|
|
88
|
+
const subscription = await client.subscribe({ eventTypes: ["agent.*"] });
|
|
89
|
+
for await (const event of subscription) {
|
|
90
|
+
console.log("Event:", event.type);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Next Steps
|
|
97
|
+
|
|
98
|
+
Ready to dive deeper? Start with the [Quickstart Guide](./quickstart.html) to build a complete working example.
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Installation
|
|
3
|
+
parent: Getting Started
|
|
4
|
+
nav_order: 3
|
|
5
|
+
description: "Install and configure the MAP SDK"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Installation
|
|
9
|
+
|
|
10
|
+
Install the Multi-Agent Protocol SDK in your project.
|
|
11
|
+
{: .fs-6 .fw-300 }
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
- **Node.js 18+** - The SDK uses modern JavaScript features
|
|
18
|
+
- **TypeScript 5.0+** (recommended) - Full type support included
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Package Installation
|
|
23
|
+
|
|
24
|
+
### npm
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install @multi-agent-protocol/sdk
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### yarn
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
yarn add @multi-agent-protocol/sdk
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### pnpm
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pnpm add @multi-agent-protocol/sdk
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Package Exports
|
|
45
|
+
|
|
46
|
+
The SDK provides multiple entry points:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
// Main exports (connections, types)
|
|
50
|
+
import {
|
|
51
|
+
ClientConnection,
|
|
52
|
+
AgentConnection,
|
|
53
|
+
GatewayConnection
|
|
54
|
+
} from "@multi-agent-protocol/sdk";
|
|
55
|
+
|
|
56
|
+
// Server components
|
|
57
|
+
import { MAPServer } from "@multi-agent-protocol/sdk/server";
|
|
58
|
+
|
|
59
|
+
// Building blocks for custom servers
|
|
60
|
+
import {
|
|
61
|
+
EventBusImpl,
|
|
62
|
+
AgentRegistryImpl,
|
|
63
|
+
ScopeManagerImpl,
|
|
64
|
+
SubscriptionManagerImpl,
|
|
65
|
+
} from "@multi-agent-protocol/sdk/server";
|
|
66
|
+
|
|
67
|
+
// Type definitions
|
|
68
|
+
import type {
|
|
69
|
+
Agent,
|
|
70
|
+
Message,
|
|
71
|
+
Event,
|
|
72
|
+
Subscription,
|
|
73
|
+
} from "@multi-agent-protocol/sdk";
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## TypeScript Configuration
|
|
79
|
+
|
|
80
|
+
For the best experience, use these TypeScript settings:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"compilerOptions": {
|
|
85
|
+
"target": "ES2022",
|
|
86
|
+
"module": "NodeNext",
|
|
87
|
+
"moduleResolution": "NodeNext",
|
|
88
|
+
"strict": true,
|
|
89
|
+
"esModuleInterop": true,
|
|
90
|
+
"skipLibCheck": true
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Transport Dependencies
|
|
98
|
+
|
|
99
|
+
The SDK is transport-agnostic. Install additional packages based on your needs:
|
|
100
|
+
|
|
101
|
+
### WebSocket (Browser & Node.js)
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npm install ws
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import WebSocket from "ws";
|
|
109
|
+
|
|
110
|
+
const ws = new WebSocket("ws://localhost:8080");
|
|
111
|
+
const stream = websocketToStream(ws);
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### HTTP + Server-Sent Events
|
|
115
|
+
|
|
116
|
+
For HTTP-based transports, no additional dependencies are needed:
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
// Use fetch + EventSource for HTTP transport
|
|
120
|
+
const stream = httpToStream("http://localhost:8080/map");
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Node.js Streams (stdio)
|
|
124
|
+
|
|
125
|
+
For stdio-based communication (CLI tools, child processes):
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import { stdioToStream } from "@multi-agent-protocol/sdk";
|
|
129
|
+
|
|
130
|
+
const stream = stdioToStream(process.stdin, process.stdout);
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Peer Dependencies
|
|
136
|
+
|
|
137
|
+
### Optional: agentic-mesh
|
|
138
|
+
|
|
139
|
+
For mesh networking and peer-to-peer connectivity:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
npm install agentic-mesh
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
import { MeshTransport } from "@multi-agent-protocol/sdk/mesh";
|
|
147
|
+
|
|
148
|
+
const transport = new MeshTransport({
|
|
149
|
+
networkId: "my-mesh-network"
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Environment Configuration
|
|
156
|
+
|
|
157
|
+
### Server Configuration
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
const server = new MAPServer({
|
|
161
|
+
// Server identity
|
|
162
|
+
name: "MyMAPServer",
|
|
163
|
+
version: "1.0.0",
|
|
164
|
+
|
|
165
|
+
// Optional: custom configuration
|
|
166
|
+
maxConnections: 1000,
|
|
167
|
+
heartbeatInterval: 30000,
|
|
168
|
+
});
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Connection Configuration
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
const client = new ClientConnection(stream, {
|
|
175
|
+
// Client identity
|
|
176
|
+
name: "Dashboard",
|
|
177
|
+
|
|
178
|
+
// Optional: reconnection settings
|
|
179
|
+
reconnect: true,
|
|
180
|
+
reconnectMaxAttempts: 5,
|
|
181
|
+
reconnectBaseDelay: 1000,
|
|
182
|
+
});
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Verifying Installation
|
|
188
|
+
|
|
189
|
+
Create a simple test file to verify everything works:
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
// test-install.ts
|
|
193
|
+
import { MAPServer } from "@multi-agent-protocol/sdk/server";
|
|
194
|
+
import { ClientConnection, AgentConnection } from "@multi-agent-protocol/sdk";
|
|
195
|
+
|
|
196
|
+
console.log("MAP SDK imported successfully!");
|
|
197
|
+
|
|
198
|
+
// Create a server instance
|
|
199
|
+
const server = new MAPServer({ name: "TestServer" });
|
|
200
|
+
console.log("Server created:", server);
|
|
201
|
+
|
|
202
|
+
console.log("Installation verified!");
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Run it:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
npx ts-node test-install.ts
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Next Steps
|
|
214
|
+
|
|
215
|
+
Now that you have the SDK installed:
|
|
216
|
+
|
|
217
|
+
1. **[Quickstart](./quickstart.html)** - Build your first MAP application
|
|
218
|
+
2. **[Server Guide](/multi-agent-protocol/sdk/guides/server.html)** - Configure your server
|
|
219
|
+
3. **[Examples](/multi-agent-protocol/examples/)** - See complete working examples
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Overview
|
|
3
|
+
parent: Getting Started
|
|
4
|
+
nav_order: 1
|
|
5
|
+
description: "Understand the Multi-Agent Protocol and when to use it"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Overview
|
|
9
|
+
|
|
10
|
+
The Multi-Agent Protocol (MAP) provides a standardized way to observe, coordinate, and route messages within multi-agent AI systems.
|
|
11
|
+
{: .fs-6 .fw-300 }
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## What is MAP?
|
|
16
|
+
|
|
17
|
+
MAP is a **JSON-RPC based protocol** designed for multi-agent systems. Unlike protocols designed for single-agent interaction or peer-to-peer agent delegation, MAP provides a **window into** a multi-agent system with visibility into its internal structure, agent relationships, and message flows.
|
|
18
|
+
|
|
19
|
+
### MAP Provides
|
|
20
|
+
|
|
21
|
+
- **Observation** - Clients can subscribe to events and watch agent activity
|
|
22
|
+
- **Coordination** - Agents can form hierarchies, join scopes, and collaborate
|
|
23
|
+
- **Routing** - Messages flow through scopes and across federated systems
|
|
24
|
+
- **Transparency** - Full visibility into the system's internal state
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Protocol Landscape
|
|
29
|
+
|
|
30
|
+
Understanding where MAP fits in the AI protocol ecosystem:
|
|
31
|
+
|
|
32
|
+
| Protocol | Relationship | Visibility | Primary Use |
|
|
33
|
+
|:---------|:-------------|:-----------|:------------|
|
|
34
|
+
| **MCP** | Agent → Tool | N/A | Tool invocation |
|
|
35
|
+
| **ACP** | Client → Agent | Opaque | Single-agent sessions |
|
|
36
|
+
| **A2A** | Agent → Agent (peer) | Opaque | Cross-org delegation |
|
|
37
|
+
| **MAP** | Client → System | **Transparent** | Internal orchestration |
|
|
38
|
+
|
|
39
|
+
### When to Use MAP
|
|
40
|
+
|
|
41
|
+
{: .highlight }
|
|
42
|
+
Use MAP when you need **visibility and coordination** across multiple agents working together.
|
|
43
|
+
|
|
44
|
+
**Good fits for MAP:**
|
|
45
|
+
- Multi-agent orchestration systems
|
|
46
|
+
- Agent dashboards and monitoring
|
|
47
|
+
- Systems requiring audit trails
|
|
48
|
+
- Collaborative AI workflows
|
|
49
|
+
- Agent marketplaces and registries
|
|
50
|
+
|
|
51
|
+
**Not ideal for MAP:**
|
|
52
|
+
- Simple single-agent chat applications (use ACP)
|
|
53
|
+
- Pure tool invocation (use MCP)
|
|
54
|
+
- Cross-organization agent handoffs (use A2A)
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Core Concepts
|
|
59
|
+
|
|
60
|
+
### Three Participant Types
|
|
61
|
+
|
|
62
|
+
MAP defines three types of participants:
|
|
63
|
+
|
|
64
|
+
| Type | Role | Capabilities |
|
|
65
|
+
|:-----|:-----|:-------------|
|
|
66
|
+
| **Agent** | Worker that processes tasks | Register, join scopes, send/receive messages |
|
|
67
|
+
| **Client** | Observer and requester | Subscribe to events, query state, send messages |
|
|
68
|
+
| **Gateway** | Federation bridge | Route between MAP systems |
|
|
69
|
+
|
|
70
|
+
### Key Components
|
|
71
|
+
|
|
72
|
+
A MAP server manages these internal components:
|
|
73
|
+
|
|
74
|
+
- **EventBus** - Central event dispatcher for all system events
|
|
75
|
+
- **AgentRegistry** - Tracks registered agents and their state
|
|
76
|
+
- **ScopeManager** - Manages logical groupings (rooms, topics, projects)
|
|
77
|
+
- **SessionManager** - Handles connections and reconnection
|
|
78
|
+
- **SubscriptionManager** - Event filtering and delivery
|
|
79
|
+
- **MessageRouter** - Routes messages to agents and scopes
|
|
80
|
+
|
|
81
|
+
### Protocol Methods
|
|
82
|
+
|
|
83
|
+
The protocol defines **27 methods** across three tiers:
|
|
84
|
+
|
|
85
|
+
**Core (Required):**
|
|
86
|
+
- `map/connect` - Establish connection
|
|
87
|
+
- `map/disconnect` - Clean shutdown
|
|
88
|
+
- `map/send` - Send messages
|
|
89
|
+
- `map/subscribe` - Subscribe to events
|
|
90
|
+
- `map/unsubscribe` - Cancel subscriptions
|
|
91
|
+
- `map/agents/list` - List registered agents
|
|
92
|
+
- `map/agents/get` - Get agent details
|
|
93
|
+
|
|
94
|
+
**Structure (Recommended):**
|
|
95
|
+
- Agent lifecycle: `register`, `spawn`, `unregister`, `update`, `stop`, `suspend`, `resume`
|
|
96
|
+
- Scope management: `scopes/create`, `scopes/join`, `scopes/leave`
|
|
97
|
+
- Structure queries: `scopes/list`, `agents/children`
|
|
98
|
+
|
|
99
|
+
**Extensions (Optional):**
|
|
100
|
+
- Federation: `federation/connect`, `federation/route`
|
|
101
|
+
- Session management: `sessions/list`, `sessions/get`
|
|
102
|
+
- Steering: `map/inject`
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Architecture
|
|
107
|
+
|
|
108
|
+
```mermaid
|
|
109
|
+
flowchart TB
|
|
110
|
+
subgraph Server["MAP Server"]
|
|
111
|
+
EventBus["EventBus"]
|
|
112
|
+
Agents["Agents"]
|
|
113
|
+
Scopes["Scopes"]
|
|
114
|
+
Sessions["Sessions"]
|
|
115
|
+
Subs["Subscriptions"]
|
|
116
|
+
Messages["Messages"]
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
Agent1["Agent"] --> Server
|
|
120
|
+
Client["Client"] --> Server
|
|
121
|
+
Agent2["Agent"] --> Server
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Key Features
|
|
127
|
+
|
|
128
|
+
### Real-time Streaming
|
|
129
|
+
|
|
130
|
+
Subscribe to events with backpressure support:
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
const subscription = await client.subscribe({
|
|
134
|
+
eventTypes: ["agent.*", "message.*"],
|
|
135
|
+
agents: ["agent-123"]
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
for await (const event of subscription) {
|
|
139
|
+
console.log(event.type, event.data);
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### 4-Layer Permission System
|
|
144
|
+
|
|
145
|
+
Control visibility and actions at multiple levels:
|
|
146
|
+
|
|
147
|
+
1. **System** - Global server configuration
|
|
148
|
+
2. **Participant** - Per-connection permissions
|
|
149
|
+
3. **Scope** - Namespace-level access
|
|
150
|
+
4. **Agent** - Individual agent preferences
|
|
151
|
+
|
|
152
|
+
### Federation
|
|
153
|
+
|
|
154
|
+
Connect multiple MAP systems:
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
// Gateway connects two MAP systems
|
|
158
|
+
const gateway = await GatewayConnection.connect(localServer, {
|
|
159
|
+
name: "federation-gateway",
|
|
160
|
+
remoteSystem: "https://remote-map.example.com"
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Causal Ordering
|
|
165
|
+
|
|
166
|
+
Events are delivered in dependency order, ensuring consistent state across clients.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Next Steps
|
|
171
|
+
|
|
172
|
+
Ready to start building? Continue to the [Quickstart Guide](./quickstart.html).
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Quickstart
|
|
3
|
+
parent: Getting Started
|
|
4
|
+
nav_order: 2
|
|
5
|
+
description: "Run a MAP server, agent, and client in 5 minutes"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Quickstart
|
|
9
|
+
|
|
10
|
+
Get a MAP server and connected agent running in 5 minutes.
|
|
11
|
+
{: .fs-6 .fw-300 }
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Prerequisites
|
|
16
|
+
|
|
17
|
+
- Node.js 18+
|
|
18
|
+
- npm or yarn
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install @multi-agent-protocol/sdk ws
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Step 1: Create a Server
|
|
31
|
+
|
|
32
|
+
The `MAPServer` class provides a complete MAP-compliant server with sensible defaults.
|
|
33
|
+
|
|
34
|
+
Create `server.ts`:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { MAPServer } from "@multi-agent-protocol/sdk/server";
|
|
38
|
+
import { WebSocketServer } from "ws";
|
|
39
|
+
|
|
40
|
+
// Create the MAP server
|
|
41
|
+
const server = new MAPServer({
|
|
42
|
+
name: "MyMAPServer",
|
|
43
|
+
version: "1.0.0",
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Create WebSocket server
|
|
47
|
+
const wss = new WebSocketServer({ port: 8080 });
|
|
48
|
+
|
|
49
|
+
// Accept connections
|
|
50
|
+
wss.on("connection", (ws) => {
|
|
51
|
+
console.log("New connection");
|
|
52
|
+
|
|
53
|
+
// Convert WebSocket to a bidirectional stream
|
|
54
|
+
const stream = websocketToStream(ws);
|
|
55
|
+
|
|
56
|
+
// Accept and start processing
|
|
57
|
+
const router = server.accept(stream);
|
|
58
|
+
router.start();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
console.log("MAP Server listening on ws://localhost:8080");
|
|
62
|
+
|
|
63
|
+
// Helper to convert WebSocket to stream
|
|
64
|
+
function websocketToStream(ws: WebSocket) {
|
|
65
|
+
return {
|
|
66
|
+
readable: new ReadableStream({
|
|
67
|
+
start(controller) {
|
|
68
|
+
ws.on("message", (data) => {
|
|
69
|
+
controller.enqueue(JSON.parse(data.toString()));
|
|
70
|
+
});
|
|
71
|
+
ws.on("close", () => controller.close());
|
|
72
|
+
ws.on("error", (err) => controller.error(err));
|
|
73
|
+
},
|
|
74
|
+
}),
|
|
75
|
+
writable: new WritableStream({
|
|
76
|
+
write(message) {
|
|
77
|
+
ws.send(JSON.stringify(message));
|
|
78
|
+
},
|
|
79
|
+
close() {
|
|
80
|
+
ws.close();
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Step 2: Create an Agent
|
|
90
|
+
|
|
91
|
+
Agents are workers that register with the server and process messages.
|
|
92
|
+
|
|
93
|
+
Create `agent.ts`:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { AgentConnection } from "@multi-agent-protocol/sdk";
|
|
97
|
+
import WebSocket from "ws";
|
|
98
|
+
|
|
99
|
+
async function main() {
|
|
100
|
+
// Connect to server
|
|
101
|
+
const ws = new WebSocket("ws://localhost:8080");
|
|
102
|
+
await new Promise((resolve) => ws.on("open", resolve));
|
|
103
|
+
|
|
104
|
+
const stream = websocketToStream(ws);
|
|
105
|
+
|
|
106
|
+
// Create agent connection
|
|
107
|
+
const agent = new AgentConnection(stream, {
|
|
108
|
+
name: "WorkerAgent",
|
|
109
|
+
role: "processor",
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Connect and register
|
|
113
|
+
const { agent: registered } = await agent.connect();
|
|
114
|
+
console.log(`Agent registered: ${registered.id}`);
|
|
115
|
+
|
|
116
|
+
// Handle incoming messages
|
|
117
|
+
agent.onMessage((message) => {
|
|
118
|
+
console.log(`Received message from ${message.from}:`);
|
|
119
|
+
console.log(message.payload);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Keep running
|
|
123
|
+
console.log("Agent running. Press Ctrl+C to exit.");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
main().catch(console.error);
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Step 3: Create a Client
|
|
132
|
+
|
|
133
|
+
Clients observe the system and can send messages to agents.
|
|
134
|
+
|
|
135
|
+
Create `client.ts`:
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
import { ClientConnection } from "@multi-agent-protocol/sdk";
|
|
139
|
+
import WebSocket from "ws";
|
|
140
|
+
|
|
141
|
+
async function main() {
|
|
142
|
+
// Connect to server
|
|
143
|
+
const ws = new WebSocket("ws://localhost:8080");
|
|
144
|
+
await new Promise((resolve) => ws.on("open", resolve));
|
|
145
|
+
|
|
146
|
+
const stream = websocketToStream(ws);
|
|
147
|
+
|
|
148
|
+
// Create client connection
|
|
149
|
+
const client = new ClientConnection(stream, {
|
|
150
|
+
name: "Dashboard",
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Connect
|
|
154
|
+
const result = await client.connect();
|
|
155
|
+
console.log(`Connected to ${result.systemInfo?.name}`);
|
|
156
|
+
|
|
157
|
+
// List all agents
|
|
158
|
+
const { agents } = await client.listAgents();
|
|
159
|
+
console.log(`Found ${agents.length} agents:`);
|
|
160
|
+
agents.forEach((a) => console.log(` - ${a.name} (${a.id})`));
|
|
161
|
+
|
|
162
|
+
// Subscribe to agent events
|
|
163
|
+
const subscription = await client.subscribe({
|
|
164
|
+
eventTypes: ["agent.registered", "agent.unregistered"],
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
console.log("Watching for agent events...");
|
|
168
|
+
|
|
169
|
+
for await (const event of subscription) {
|
|
170
|
+
console.log(`Event: ${event.type}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
main().catch(console.error);
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Step 4: Run It
|
|
180
|
+
|
|
181
|
+
Start each component in a separate terminal:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# Terminal 1: Start server
|
|
185
|
+
npx ts-node server.ts
|
|
186
|
+
|
|
187
|
+
# Terminal 2: Start agent
|
|
188
|
+
npx ts-node agent.ts
|
|
189
|
+
|
|
190
|
+
# Terminal 3: Start client
|
|
191
|
+
npx ts-node client.ts
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
You should see:
|
|
195
|
+
|
|
196
|
+
1. Server starts and listens on port 8080
|
|
197
|
+
2. Agent connects and registers
|
|
198
|
+
3. Client connects, lists the agent, and receives the registration event
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## What Just Happened?
|
|
203
|
+
|
|
204
|
+
1. **Server** created building blocks (EventBus, AgentRegistry, etc.) and wired them together
|
|
205
|
+
2. **Agent** connected, sent `map/connect`, then `map/agents/register`
|
|
206
|
+
3. **Server** registered the agent and emitted `agent.registered` event
|
|
207
|
+
4. **Client** connected, queried agents with `map/agents/list`, subscribed to events
|
|
208
|
+
5. **EventBus** delivered the registration event to the client's subscription
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Common Issues
|
|
213
|
+
|
|
214
|
+
### "Connection refused"
|
|
215
|
+
|
|
216
|
+
Make sure the server is running before starting agents or clients.
|
|
217
|
+
|
|
218
|
+
### "Method not found"
|
|
219
|
+
|
|
220
|
+
Check that you're using the correct SDK version on both server and client.
|
|
221
|
+
|
|
222
|
+
### Events not received
|
|
223
|
+
|
|
224
|
+
Verify your subscription filter matches the event types being emitted. Use `eventTypes: ["*"]` to receive all events during debugging.
|
|
225
|
+
|
|
226
|
+
### Agent not appearing in list
|
|
227
|
+
|
|
228
|
+
The agent must call `connect()` which automatically registers it. Check for connection errors.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Next Steps
|
|
233
|
+
|
|
234
|
+
- **[Server Quickstart](/multi-agent-protocol/sdk/guides/server.html)** - Learn MAPServer configuration options
|
|
235
|
+
- **[Agent Integration](/multi-agent-protocol/sdk/guides/agent.html)** - Build more sophisticated agents
|
|
236
|
+
- **[Client Integration](/multi-agent-protocol/sdk/guides/client.html)** - Build observability dashboards
|
|
237
|
+
- **[Transports](/multi-agent-protocol/sdk/guides/transports.html)** - Use different transports (stdio, HTTP, custom)
|