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.
Files changed (143) hide show
  1. package/.claude/settings.local.json +59 -0
  2. package/dist/agent/agent-manager.d.ts.map +1 -1
  3. package/dist/agent/agent-manager.js +10 -4
  4. package/dist/agent/agent-manager.js.map +1 -1
  5. package/dist/cli/acp.d.ts +6 -0
  6. package/dist/cli/acp.d.ts.map +1 -1
  7. package/dist/cli/acp.js +16 -2
  8. package/dist/cli/acp.js.map +1 -1
  9. package/dist/map/adapter/index.d.ts +1 -1
  10. package/dist/map/adapter/index.d.ts.map +1 -1
  11. package/dist/map/adapter/index.js +1 -1
  12. package/dist/map/adapter/index.js.map +1 -1
  13. package/dist/map/utils/address-translation.d.ts +99 -0
  14. package/dist/map/utils/address-translation.d.ts.map +1 -0
  15. package/dist/map/utils/address-translation.js +285 -0
  16. package/dist/map/utils/address-translation.js.map +1 -0
  17. package/dist/map/utils/index.d.ts +7 -0
  18. package/dist/map/utils/index.d.ts.map +1 -0
  19. package/dist/map/utils/index.js +7 -0
  20. package/dist/map/utils/index.js.map +1 -0
  21. package/dist/server/combined-server.d.ts.map +1 -1
  22. package/dist/server/combined-server.js +8 -1
  23. package/dist/server/combined-server.js.map +1 -1
  24. package/dist/store/event-store.js +9 -2
  25. package/dist/store/event-store.js.map +1 -1
  26. package/dist/store/types/agents.d.ts +2 -0
  27. package/dist/store/types/agents.d.ts.map +1 -1
  28. package/package.json +4 -4
  29. package/references/acp-factory-ref/CHANGELOG.md +33 -0
  30. package/references/acp-factory-ref/LICENSE +21 -0
  31. package/references/acp-factory-ref/README.md +341 -0
  32. package/references/acp-factory-ref/package-lock.json +3102 -0
  33. package/references/acp-factory-ref/package.json +96 -0
  34. package/references/acp-factory-ref/python/CHANGELOG.md +33 -0
  35. package/references/acp-factory-ref/python/LICENSE +21 -0
  36. package/references/acp-factory-ref/python/Makefile +57 -0
  37. package/references/acp-factory-ref/python/README.md +253 -0
  38. package/references/acp-factory-ref/python/pyproject.toml +73 -0
  39. package/references/acp-factory-ref/python/tests/__init__.py +0 -0
  40. package/references/acp-factory-ref/python/tests/e2e/__init__.py +1 -0
  41. package/references/acp-factory-ref/python/tests/e2e/test_codex_e2e.py +349 -0
  42. package/references/acp-factory-ref/python/tests/e2e/test_gemini_e2e.py +165 -0
  43. package/references/acp-factory-ref/python/tests/e2e/test_opencode_e2e.py +296 -0
  44. package/references/acp-factory-ref/python/tests/test_client_handler.py +543 -0
  45. package/references/acp-factory-ref/python/tests/test_pushable.py +199 -0
  46. package/references/claude-code-acp/.github/workflows/ci.yml +45 -0
  47. package/references/claude-code-acp/.github/workflows/publish.yml +34 -0
  48. package/references/claude-code-acp/.prettierrc.json +4 -0
  49. package/references/claude-code-acp/CHANGELOG.md +249 -0
  50. package/references/claude-code-acp/LICENSE +222 -0
  51. package/references/claude-code-acp/README.md +53 -0
  52. package/references/claude-code-acp/docs/RELEASES.md +24 -0
  53. package/references/claude-code-acp/eslint.config.js +48 -0
  54. package/references/claude-code-acp/package-lock.json +4570 -0
  55. package/references/claude-code-acp/package.json +88 -0
  56. package/references/claude-code-acp/scripts/release.sh +119 -0
  57. package/references/claude-code-acp/src/acp-agent.ts +2079 -0
  58. package/references/claude-code-acp/src/index.ts +26 -0
  59. package/references/claude-code-acp/src/lib.ts +38 -0
  60. package/references/claude-code-acp/src/mcp-server.ts +911 -0
  61. package/references/claude-code-acp/src/settings.ts +522 -0
  62. package/references/claude-code-acp/src/tests/.claude/commands/quick-math.md +5 -0
  63. package/references/claude-code-acp/src/tests/.claude/commands/say-hello.md +6 -0
  64. package/references/claude-code-acp/src/tests/acp-agent-fork.test.ts +479 -0
  65. package/references/claude-code-acp/src/tests/acp-agent.test.ts +1502 -0
  66. package/references/claude-code-acp/src/tests/extract-lines.test.ts +103 -0
  67. package/references/claude-code-acp/src/tests/fork-session.test.ts +335 -0
  68. package/references/claude-code-acp/src/tests/replace-and-calculate-location.test.ts +334 -0
  69. package/references/claude-code-acp/src/tests/settings.test.ts +617 -0
  70. package/references/claude-code-acp/src/tests/skills-options.test.ts +187 -0
  71. package/references/claude-code-acp/src/tests/tools.test.ts +318 -0
  72. package/references/claude-code-acp/src/tests/typescript-declarations.test.ts +558 -0
  73. package/references/claude-code-acp/src/tools.ts +819 -0
  74. package/references/claude-code-acp/src/utils.ts +171 -0
  75. package/references/claude-code-acp/tsconfig.json +18 -0
  76. package/references/claude-code-acp/vitest.config.ts +19 -0
  77. package/references/multi-agent-protocol/.sudocode/issues.jsonl +111 -0
  78. package/references/multi-agent-protocol/.sudocode/specs.jsonl +13 -0
  79. package/references/multi-agent-protocol/LICENSE +21 -0
  80. package/references/multi-agent-protocol/README.md +113 -0
  81. package/references/multi-agent-protocol/docs/00-design-specification.md +496 -0
  82. package/references/multi-agent-protocol/docs/01-open-questions.md +1050 -0
  83. package/references/multi-agent-protocol/docs/02-wire-protocol.md +296 -0
  84. package/references/multi-agent-protocol/docs/03-streaming-semantics.md +252 -0
  85. package/references/multi-agent-protocol/docs/04-error-handling.md +231 -0
  86. package/references/multi-agent-protocol/docs/05-connection-model.md +244 -0
  87. package/references/multi-agent-protocol/docs/06-visibility-permissions.md +243 -0
  88. package/references/multi-agent-protocol/docs/07-federation.md +259 -0
  89. package/references/multi-agent-protocol/docs/08-macro-agent-migration.md +253 -0
  90. package/references/multi-agent-protocol/docs/09-authentication.md +680 -0
  91. package/references/multi-agent-protocol/docs/10-mail-protocol.md +553 -0
  92. package/references/multi-agent-protocol/docs/agent-iam-integration.md +877 -0
  93. package/references/multi-agent-protocol/docs/agentic-mesh-integration-draft.md +459 -0
  94. package/references/multi-agent-protocol/docs/git-transport-draft.md +251 -0
  95. package/references/multi-agent-protocol/docs-site/Gemfile +22 -0
  96. package/references/multi-agent-protocol/docs-site/README.md +82 -0
  97. package/references/multi-agent-protocol/docs-site/_config.yml +91 -0
  98. package/references/multi-agent-protocol/docs-site/_includes/head_custom.html +20 -0
  99. package/references/multi-agent-protocol/docs-site/_sass/color_schemes/map.scss +42 -0
  100. package/references/multi-agent-protocol/docs-site/_sass/custom/custom.scss +34 -0
  101. package/references/multi-agent-protocol/docs-site/examples/full-integration.md +510 -0
  102. package/references/multi-agent-protocol/docs-site/examples/index.md +138 -0
  103. package/references/multi-agent-protocol/docs-site/examples/simple-chat.md +282 -0
  104. package/references/multi-agent-protocol/docs-site/examples/task-queue.md +399 -0
  105. package/references/multi-agent-protocol/docs-site/getting-started/index.md +98 -0
  106. package/references/multi-agent-protocol/docs-site/getting-started/installation.md +219 -0
  107. package/references/multi-agent-protocol/docs-site/getting-started/overview.md +172 -0
  108. package/references/multi-agent-protocol/docs-site/getting-started/quickstart.md +237 -0
  109. package/references/multi-agent-protocol/docs-site/index.md +136 -0
  110. package/references/multi-agent-protocol/docs-site/protocol/authentication.md +391 -0
  111. package/references/multi-agent-protocol/docs-site/protocol/connection-model.md +376 -0
  112. package/references/multi-agent-protocol/docs-site/protocol/design.md +284 -0
  113. package/references/multi-agent-protocol/docs-site/protocol/error-handling.md +312 -0
  114. package/references/multi-agent-protocol/docs-site/protocol/federation.md +449 -0
  115. package/references/multi-agent-protocol/docs-site/protocol/index.md +129 -0
  116. package/references/multi-agent-protocol/docs-site/protocol/permissions.md +398 -0
  117. package/references/multi-agent-protocol/docs-site/protocol/streaming.md +353 -0
  118. package/references/multi-agent-protocol/docs-site/protocol/wire-protocol.md +369 -0
  119. package/references/multi-agent-protocol/docs-site/sdk/api/agent.md +357 -0
  120. package/references/multi-agent-protocol/docs-site/sdk/api/client.md +380 -0
  121. package/references/multi-agent-protocol/docs-site/sdk/api/index.md +62 -0
  122. package/references/multi-agent-protocol/docs-site/sdk/api/server.md +453 -0
  123. package/references/multi-agent-protocol/docs-site/sdk/api/types.md +468 -0
  124. package/references/multi-agent-protocol/docs-site/sdk/guides/agent.md +375 -0
  125. package/references/multi-agent-protocol/docs-site/sdk/guides/authentication.md +405 -0
  126. package/references/multi-agent-protocol/docs-site/sdk/guides/client.md +352 -0
  127. package/references/multi-agent-protocol/docs-site/sdk/guides/index.md +89 -0
  128. package/references/multi-agent-protocol/docs-site/sdk/guides/server.md +360 -0
  129. package/references/multi-agent-protocol/docs-site/sdk/guides/testing.md +446 -0
  130. package/references/multi-agent-protocol/docs-site/sdk/guides/transports.md +363 -0
  131. package/references/multi-agent-protocol/docs-site/sdk/index.md +206 -0
  132. package/references/multi-agent-protocol/package-lock.json +3886 -0
  133. package/references/multi-agent-protocol/package.json +56 -0
  134. package/references/multi-agent-protocol/schema/meta.json +467 -0
  135. package/references/multi-agent-protocol/schema/schema.json +2558 -0
  136. package/src/agent/__tests__/agent-manager.test.ts +67 -1
  137. package/src/agent/agent-manager.ts +10 -4
  138. package/src/cli/__tests__/stable-instance-id.test.ts +57 -0
  139. package/src/cli/acp.ts +17 -2
  140. package/src/map/adapter/index.ts +3 -0
  141. package/src/server/combined-server.ts +10 -0
  142. package/src/store/event-store.ts +10 -3
  143. package/src/store/types/agents.ts +2 -0
@@ -0,0 +1,352 @@
1
+ ---
2
+ title: Client Integration
3
+ parent: Guides
4
+ grand_parent: SDK
5
+ nav_order: 2
6
+ description: "Build clients that observe and interact with MAP systems"
7
+ ---
8
+
9
+ # Client Integration
10
+ {: .no_toc }
11
+
12
+ Build clients that observe agent activity and send messages.
13
+ {: .fs-6 .fw-300 }
14
+
15
+ ## Table of contents
16
+ {: .no_toc .text-delta }
17
+
18
+ 1. TOC
19
+ {:toc}
20
+
21
+ ---
22
+
23
+ ## When to Use ClientConnection
24
+
25
+ Use `ClientConnection` when building:
26
+ - Dashboards that monitor agent activity
27
+ - Control panels that manage agents
28
+ - Applications that send work to agents
29
+ - Tools that aggregate events from agents
30
+
31
+ ---
32
+
33
+ ## Basic Usage
34
+
35
+ ```typescript
36
+ import { ClientConnection } from "@multi-agent-protocol/sdk";
37
+
38
+ // Create connection
39
+ const client = new ClientConnection(stream, {
40
+ name: "Dashboard",
41
+ });
42
+
43
+ // Connect to server
44
+ const result = await client.connect();
45
+ console.log(`Connected to ${result.systemInfo?.name}`);
46
+ console.log(`Session ID: ${result.sessionId}`);
47
+
48
+ // Disconnect when done
49
+ await client.disconnect();
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Connection Options
55
+
56
+ ```typescript
57
+ const client = new ClientConnection(stream, {
58
+ name: "MyClient", // Client name shown in server
59
+ reconnect: {
60
+ enabled: true, // Auto-reconnect on disconnect
61
+ maxAttempts: 10, // Maximum reconnection attempts
62
+ baseDelayMs: 1000, // Initial delay between attempts
63
+ maxDelayMs: 30000, // Maximum delay (exponential backoff)
64
+ },
65
+ });
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Querying Agents
71
+
72
+ ### List All Agents
73
+
74
+ ```typescript
75
+ const { agents } = await client.listAgents();
76
+
77
+ agents.forEach((agent) => {
78
+ console.log(`${agent.name} (${agent.id})`);
79
+ console.log(` Role: ${agent.role}`);
80
+ console.log(` State: ${agent.state}`);
81
+ });
82
+ ```
83
+
84
+ ### Filter Agents
85
+
86
+ ```typescript
87
+ // By role
88
+ const { agents: workers } = await client.listAgents({
89
+ role: "worker",
90
+ });
91
+
92
+ // By state
93
+ const { agents: active } = await client.listAgents({
94
+ state: "running",
95
+ });
96
+
97
+ // By scope membership
98
+ const { agents: inScope } = await client.listAgents({
99
+ scopeId: "scope-123",
100
+ });
101
+ ```
102
+
103
+ ### Get Single Agent
104
+
105
+ ```typescript
106
+ const { agent } = await client.getAgent("agent-id");
107
+ if (agent) {
108
+ console.log(`Agent ${agent.name} is ${agent.state}`);
109
+ }
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Event Subscriptions
115
+
116
+ ### Subscribe to Events
117
+
118
+ ```typescript
119
+ // Subscribe to specific event types
120
+ const subscription = await client.subscribe({
121
+ eventTypes: ["agent.registered", "agent.unregistered"],
122
+ });
123
+
124
+ // Process events
125
+ for await (const event of subscription) {
126
+ console.log(`Event: ${event.type}`);
127
+ console.log(`Data:`, event.data);
128
+ }
129
+ ```
130
+
131
+ ### Event Type Patterns
132
+
133
+ ```typescript
134
+ // All agent events
135
+ const subscription = await client.subscribe({
136
+ eventTypes: ["agent.*"],
137
+ });
138
+
139
+ // All events
140
+ const subscription = await client.subscribe({
141
+ eventTypes: ["*"],
142
+ });
143
+
144
+ // Multiple specific types
145
+ const subscription = await client.subscribe({
146
+ eventTypes: [
147
+ "agent.registered",
148
+ "agent.unregistered",
149
+ "scope.created",
150
+ "message.sent",
151
+ ],
152
+ });
153
+ ```
154
+
155
+ ### Scope-Filtered Events
156
+
157
+ ```typescript
158
+ // Only events from specific scopes
159
+ const subscription = await client.subscribe({
160
+ eventTypes: ["message.*"],
161
+ scopeIds: ["scope-123", "scope-456"],
162
+ });
163
+ ```
164
+
165
+ ### Managing Subscriptions
166
+
167
+ ```typescript
168
+ const subscription = await client.subscribe({ eventTypes: ["*"] });
169
+
170
+ // Pause event delivery
171
+ await subscription.pause();
172
+
173
+ // Resume
174
+ await subscription.resume();
175
+
176
+ // Unsubscribe
177
+ await subscription.unsubscribe();
178
+ ```
179
+
180
+ ---
181
+
182
+ ## Sending Messages
183
+
184
+ ### Send to Agent
185
+
186
+ ```typescript
187
+ await client.send({
188
+ to: { agentId: "agent-123" },
189
+ payload: {
190
+ type: "task",
191
+ data: { action: "process", item: "item-456" },
192
+ },
193
+ });
194
+ ```
195
+
196
+ ### Send to Scope
197
+
198
+ ```typescript
199
+ // Message all agents in scope
200
+ await client.send({
201
+ to: { scopeId: "scope-123" },
202
+ payload: {
203
+ type: "announcement",
204
+ message: "System maintenance in 5 minutes",
205
+ },
206
+ });
207
+ ```
208
+
209
+ ---
210
+
211
+ ## Event Replay
212
+
213
+ Replay events you may have missed:
214
+
215
+ ```typescript
216
+ // Replay from specific event
217
+ const events = await client.replay({
218
+ afterEventId: "event-123",
219
+ limit: 100,
220
+ });
221
+
222
+ events.forEach((event) => {
223
+ console.log(`Missed event: ${event.type}`);
224
+ });
225
+
226
+ // Replay with filter
227
+ const agentEvents = await client.replay({
228
+ afterEventId: "event-123",
229
+ eventTypes: ["agent.*"],
230
+ limit: 50,
231
+ });
232
+ ```
233
+
234
+ ---
235
+
236
+ ## Session Resume
237
+
238
+ Resume a disconnected session:
239
+
240
+ ```typescript
241
+ // First connection
242
+ const client = new ClientConnection(stream, { name: "Dashboard" });
243
+ const { resumeToken } = await client.connect();
244
+
245
+ // Store resumeToken somewhere safe
246
+ saveToken(resumeToken);
247
+
248
+ // Later, resume the session
249
+ const client2 = new ClientConnection(newStream, { name: "Dashboard" });
250
+ const result = await client2.connect({
251
+ resumeToken: loadToken(),
252
+ });
253
+
254
+ if (result.resumed) {
255
+ console.log("Session resumed successfully");
256
+ // Subscriptions are automatically restored
257
+ }
258
+ ```
259
+
260
+ ---
261
+
262
+ ## Connection State
263
+
264
+ Monitor connection state:
265
+
266
+ ```typescript
267
+ client.onStateChange((state) => {
268
+ console.log(`Connection state: ${state}`);
269
+ // States: "initial", "connecting", "connected", "reconnecting", "closed"
270
+ });
271
+
272
+ // Check current state
273
+ if (client.state === "connected") {
274
+ // Safe to make requests
275
+ }
276
+ ```
277
+
278
+ ---
279
+
280
+ ## Complete Example: Dashboard
281
+
282
+ ```typescript
283
+ import { ClientConnection } from "@multi-agent-protocol/sdk";
284
+
285
+ async function createDashboard(stream: Stream) {
286
+ const client = new ClientConnection(stream, {
287
+ name: "Dashboard",
288
+ reconnect: { enabled: true },
289
+ });
290
+
291
+ // Connect
292
+ const { sessionId, systemInfo } = await client.connect();
293
+ console.log(`Connected to ${systemInfo?.name} (session: ${sessionId})`);
294
+
295
+ // Load initial state
296
+ const { agents } = await client.listAgents();
297
+ const { scopes } = await client.listScopes();
298
+
299
+ console.log(`Found ${agents.length} agents and ${scopes.length} scopes`);
300
+
301
+ // Subscribe to changes
302
+ const subscription = await client.subscribe({
303
+ eventTypes: [
304
+ "agent.registered",
305
+ "agent.unregistered",
306
+ "agent.updated",
307
+ "scope.created",
308
+ "scope.deleted",
309
+ ],
310
+ });
311
+
312
+ // Process events
313
+ console.log("Watching for changes...");
314
+ for await (const event of subscription) {
315
+ switch (event.type) {
316
+ case "agent.registered":
317
+ console.log(`+ Agent joined: ${event.data.agent.name}`);
318
+ break;
319
+ case "agent.unregistered":
320
+ console.log(`- Agent left: ${event.data.agentId}`);
321
+ break;
322
+ case "agent.updated":
323
+ console.log(`~ Agent updated: ${event.data.agent.name}`);
324
+ break;
325
+ case "scope.created":
326
+ console.log(`+ Scope created: ${event.data.scope.name}`);
327
+ break;
328
+ case "scope.deleted":
329
+ console.log(`- Scope deleted: ${event.data.scopeId}`);
330
+ break;
331
+ }
332
+ }
333
+ }
334
+ ```
335
+
336
+ ---
337
+
338
+ ## Best Practices
339
+
340
+ 1. **Handle reconnection** - Enable auto-reconnect for production clients
341
+ 2. **Use event replay** - After reconnection, replay missed events
342
+ 3. **Filter subscriptions** - Subscribe only to needed event types
343
+ 4. **Store resume tokens** - Persist tokens for session continuity
344
+ 5. **Handle state changes** - React to connection state transitions
345
+
346
+ ---
347
+
348
+ ## Next Steps
349
+
350
+ - [Agent Integration](./agent.html) - Build agents that process work
351
+ - [Transports](./transports.html) - Connect via different transports
352
+ - [Testing](./testing.html) - Test client integrations
@@ -0,0 +1,89 @@
1
+ ---
2
+ title: Guides
3
+ parent: SDK
4
+ nav_order: 1
5
+ has_children: true
6
+ description: "SDK integration guides"
7
+ ---
8
+
9
+ # SDK Guides
10
+
11
+ Step-by-step guides for integrating with the MAP SDK.
12
+ {: .fs-6 .fw-300 }
13
+
14
+ ---
15
+
16
+ ## Available Guides
17
+
18
+ | Guide | Description |
19
+ |:------|:------------|
20
+ | [Server Setup](./server.html) | Create and configure a MAP server |
21
+ | [Client Integration](./client.html) | Build clients that observe and interact |
22
+ | [Agent Integration](./agent.html) | Build agents that process work |
23
+ | [Transports](./transports.html) | WebSocket, stdio, and custom transports |
24
+ | [Authentication](./authentication.html) | Configure authentication methods |
25
+ | [Testing](./testing.html) | Test your MAP integrations |
26
+
27
+ ---
28
+
29
+ ## Quick Start
30
+
31
+ ### 1. Install the SDK
32
+
33
+ ```bash
34
+ npm install @multi-agent-protocol/sdk
35
+ ```
36
+
37
+ ### 2. Create a Server
38
+
39
+ ```typescript
40
+ import { MAPServer } from "@multi-agent-protocol/sdk/server";
41
+
42
+ const server = new MAPServer({ name: "MyServer" });
43
+ ```
44
+
45
+ ### 3. Accept Connections
46
+
47
+ ```typescript
48
+ import { WebSocketServer } from "ws";
49
+
50
+ const wss = new WebSocketServer({ port: 8080 });
51
+ wss.on("connection", (ws) => {
52
+ const stream = websocketToStream(ws);
53
+ server.accept(stream).start();
54
+ });
55
+ ```
56
+
57
+ ### 4. Connect an Agent
58
+
59
+ ```typescript
60
+ import { AgentConnection } from "@multi-agent-protocol/sdk";
61
+
62
+ const agent = new AgentConnection(stream, {
63
+ name: "Worker",
64
+ role: "processor"
65
+ });
66
+ await agent.connect();
67
+ ```
68
+
69
+ ### 5. Connect a Client
70
+
71
+ ```typescript
72
+ import { ClientConnection } from "@multi-agent-protocol/sdk";
73
+
74
+ const client = new ClientConnection(stream, { name: "Dashboard" });
75
+ await client.connect();
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Choosing the Right Guide
81
+
82
+ | I want to... | Start with... |
83
+ |:-------------|:--------------|
84
+ | Build a MAP server | [Server Setup](./server.html) |
85
+ | Monitor agent activity | [Client Integration](./client.html) |
86
+ | Create an AI agent | [Agent Integration](./agent.html) |
87
+ | Use stdio or HTTP | [Transports](./transports.html) |
88
+ | Add authentication | [Authentication](./authentication.html) |
89
+ | Write tests | [Testing](./testing.html) |