macro-agent 0.0.14 → 0.0.16

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 (154) hide show
  1. package/.claude/settings.local.json +59 -0
  2. package/dist/acp/index.d.ts +1 -1
  3. package/dist/acp/index.d.ts.map +1 -1
  4. package/dist/acp/index.js.map +1 -1
  5. package/dist/acp/macro-agent.d.ts +21 -0
  6. package/dist/acp/macro-agent.d.ts.map +1 -1
  7. package/dist/acp/macro-agent.js +182 -0
  8. package/dist/acp/macro-agent.js.map +1 -1
  9. package/dist/acp/types.d.ts +31 -2
  10. package/dist/acp/types.d.ts.map +1 -1
  11. package/dist/acp/types.js.map +1 -1
  12. package/dist/agent/agent-manager.d.ts.map +1 -1
  13. package/dist/agent/agent-manager.js +10 -4
  14. package/dist/agent/agent-manager.js.map +1 -1
  15. package/dist/cli/acp.d.ts +6 -0
  16. package/dist/cli/acp.d.ts.map +1 -1
  17. package/dist/cli/acp.js +16 -2
  18. package/dist/cli/acp.js.map +1 -1
  19. package/dist/map/adapter/acp-over-map.d.ts +5 -0
  20. package/dist/map/adapter/acp-over-map.d.ts.map +1 -1
  21. package/dist/map/adapter/acp-over-map.js +47 -4
  22. package/dist/map/adapter/acp-over-map.js.map +1 -1
  23. package/dist/map/utils/address-translation.d.ts +99 -0
  24. package/dist/map/utils/address-translation.d.ts.map +1 -0
  25. package/dist/map/utils/address-translation.js +285 -0
  26. package/dist/map/utils/address-translation.js.map +1 -0
  27. package/dist/map/utils/index.d.ts +7 -0
  28. package/dist/map/utils/index.d.ts.map +1 -0
  29. package/dist/map/utils/index.js +7 -0
  30. package/dist/map/utils/index.js.map +1 -0
  31. package/dist/store/event-store.js +9 -2
  32. package/dist/store/event-store.js.map +1 -1
  33. package/dist/store/types/agents.d.ts +2 -0
  34. package/dist/store/types/agents.d.ts.map +1 -1
  35. package/package.json +4 -4
  36. package/references/acp-factory-ref/CHANGELOG.md +33 -0
  37. package/references/acp-factory-ref/LICENSE +21 -0
  38. package/references/acp-factory-ref/README.md +341 -0
  39. package/references/acp-factory-ref/package-lock.json +3102 -0
  40. package/references/acp-factory-ref/package.json +96 -0
  41. package/references/acp-factory-ref/python/CHANGELOG.md +33 -0
  42. package/references/acp-factory-ref/python/LICENSE +21 -0
  43. package/references/acp-factory-ref/python/Makefile +57 -0
  44. package/references/acp-factory-ref/python/README.md +253 -0
  45. package/references/acp-factory-ref/python/pyproject.toml +73 -0
  46. package/references/acp-factory-ref/python/tests/__init__.py +0 -0
  47. package/references/acp-factory-ref/python/tests/e2e/__init__.py +1 -0
  48. package/references/acp-factory-ref/python/tests/e2e/test_codex_e2e.py +349 -0
  49. package/references/acp-factory-ref/python/tests/e2e/test_gemini_e2e.py +165 -0
  50. package/references/acp-factory-ref/python/tests/e2e/test_opencode_e2e.py +296 -0
  51. package/references/acp-factory-ref/python/tests/test_client_handler.py +543 -0
  52. package/references/acp-factory-ref/python/tests/test_pushable.py +199 -0
  53. package/references/claude-code-acp/.github/workflows/ci.yml +45 -0
  54. package/references/claude-code-acp/.github/workflows/publish.yml +34 -0
  55. package/references/claude-code-acp/.prettierrc.json +4 -0
  56. package/references/claude-code-acp/CHANGELOG.md +249 -0
  57. package/references/claude-code-acp/LICENSE +222 -0
  58. package/references/claude-code-acp/README.md +53 -0
  59. package/references/claude-code-acp/docs/RELEASES.md +24 -0
  60. package/references/claude-code-acp/eslint.config.js +48 -0
  61. package/references/claude-code-acp/package-lock.json +4570 -0
  62. package/references/claude-code-acp/package.json +88 -0
  63. package/references/claude-code-acp/scripts/release.sh +119 -0
  64. package/references/claude-code-acp/src/acp-agent.ts +2079 -0
  65. package/references/claude-code-acp/src/index.ts +26 -0
  66. package/references/claude-code-acp/src/lib.ts +38 -0
  67. package/references/claude-code-acp/src/mcp-server.ts +911 -0
  68. package/references/claude-code-acp/src/settings.ts +522 -0
  69. package/references/claude-code-acp/src/tests/.claude/commands/quick-math.md +5 -0
  70. package/references/claude-code-acp/src/tests/.claude/commands/say-hello.md +6 -0
  71. package/references/claude-code-acp/src/tests/acp-agent-fork.test.ts +479 -0
  72. package/references/claude-code-acp/src/tests/acp-agent.test.ts +1502 -0
  73. package/references/claude-code-acp/src/tests/extract-lines.test.ts +103 -0
  74. package/references/claude-code-acp/src/tests/fork-session.test.ts +335 -0
  75. package/references/claude-code-acp/src/tests/replace-and-calculate-location.test.ts +334 -0
  76. package/references/claude-code-acp/src/tests/settings.test.ts +617 -0
  77. package/references/claude-code-acp/src/tests/skills-options.test.ts +187 -0
  78. package/references/claude-code-acp/src/tests/tools.test.ts +318 -0
  79. package/references/claude-code-acp/src/tests/typescript-declarations.test.ts +558 -0
  80. package/references/claude-code-acp/src/tools.ts +819 -0
  81. package/references/claude-code-acp/src/utils.ts +171 -0
  82. package/references/claude-code-acp/tsconfig.json +18 -0
  83. package/references/claude-code-acp/vitest.config.ts +19 -0
  84. package/references/multi-agent-protocol/.sudocode/issues.jsonl +111 -0
  85. package/references/multi-agent-protocol/.sudocode/specs.jsonl +13 -0
  86. package/references/multi-agent-protocol/LICENSE +21 -0
  87. package/references/multi-agent-protocol/README.md +113 -0
  88. package/references/multi-agent-protocol/docs/00-design-specification.md +496 -0
  89. package/references/multi-agent-protocol/docs/01-open-questions.md +1050 -0
  90. package/references/multi-agent-protocol/docs/02-wire-protocol.md +296 -0
  91. package/references/multi-agent-protocol/docs/03-streaming-semantics.md +252 -0
  92. package/references/multi-agent-protocol/docs/04-error-handling.md +231 -0
  93. package/references/multi-agent-protocol/docs/05-connection-model.md +244 -0
  94. package/references/multi-agent-protocol/docs/06-visibility-permissions.md +243 -0
  95. package/references/multi-agent-protocol/docs/07-federation.md +259 -0
  96. package/references/multi-agent-protocol/docs/08-macro-agent-migration.md +253 -0
  97. package/references/multi-agent-protocol/docs/09-authentication.md +680 -0
  98. package/references/multi-agent-protocol/docs/10-mail-protocol.md +553 -0
  99. package/references/multi-agent-protocol/docs/agent-iam-integration.md +877 -0
  100. package/references/multi-agent-protocol/docs/agentic-mesh-integration-draft.md +459 -0
  101. package/references/multi-agent-protocol/docs/git-transport-draft.md +251 -0
  102. package/references/multi-agent-protocol/docs-site/Gemfile +22 -0
  103. package/references/multi-agent-protocol/docs-site/README.md +82 -0
  104. package/references/multi-agent-protocol/docs-site/_config.yml +91 -0
  105. package/references/multi-agent-protocol/docs-site/_includes/head_custom.html +20 -0
  106. package/references/multi-agent-protocol/docs-site/_sass/color_schemes/map.scss +42 -0
  107. package/references/multi-agent-protocol/docs-site/_sass/custom/custom.scss +34 -0
  108. package/references/multi-agent-protocol/docs-site/examples/full-integration.md +510 -0
  109. package/references/multi-agent-protocol/docs-site/examples/index.md +138 -0
  110. package/references/multi-agent-protocol/docs-site/examples/simple-chat.md +282 -0
  111. package/references/multi-agent-protocol/docs-site/examples/task-queue.md +399 -0
  112. package/references/multi-agent-protocol/docs-site/getting-started/index.md +98 -0
  113. package/references/multi-agent-protocol/docs-site/getting-started/installation.md +219 -0
  114. package/references/multi-agent-protocol/docs-site/getting-started/overview.md +172 -0
  115. package/references/multi-agent-protocol/docs-site/getting-started/quickstart.md +237 -0
  116. package/references/multi-agent-protocol/docs-site/index.md +136 -0
  117. package/references/multi-agent-protocol/docs-site/protocol/authentication.md +391 -0
  118. package/references/multi-agent-protocol/docs-site/protocol/connection-model.md +376 -0
  119. package/references/multi-agent-protocol/docs-site/protocol/design.md +284 -0
  120. package/references/multi-agent-protocol/docs-site/protocol/error-handling.md +312 -0
  121. package/references/multi-agent-protocol/docs-site/protocol/federation.md +449 -0
  122. package/references/multi-agent-protocol/docs-site/protocol/index.md +129 -0
  123. package/references/multi-agent-protocol/docs-site/protocol/permissions.md +398 -0
  124. package/references/multi-agent-protocol/docs-site/protocol/streaming.md +353 -0
  125. package/references/multi-agent-protocol/docs-site/protocol/wire-protocol.md +369 -0
  126. package/references/multi-agent-protocol/docs-site/sdk/api/agent.md +357 -0
  127. package/references/multi-agent-protocol/docs-site/sdk/api/client.md +380 -0
  128. package/references/multi-agent-protocol/docs-site/sdk/api/index.md +62 -0
  129. package/references/multi-agent-protocol/docs-site/sdk/api/server.md +453 -0
  130. package/references/multi-agent-protocol/docs-site/sdk/api/types.md +468 -0
  131. package/references/multi-agent-protocol/docs-site/sdk/guides/agent.md +375 -0
  132. package/references/multi-agent-protocol/docs-site/sdk/guides/authentication.md +405 -0
  133. package/references/multi-agent-protocol/docs-site/sdk/guides/client.md +352 -0
  134. package/references/multi-agent-protocol/docs-site/sdk/guides/index.md +89 -0
  135. package/references/multi-agent-protocol/docs-site/sdk/guides/server.md +360 -0
  136. package/references/multi-agent-protocol/docs-site/sdk/guides/testing.md +446 -0
  137. package/references/multi-agent-protocol/docs-site/sdk/guides/transports.md +363 -0
  138. package/references/multi-agent-protocol/docs-site/sdk/index.md +206 -0
  139. package/references/multi-agent-protocol/package-lock.json +3886 -0
  140. package/references/multi-agent-protocol/package.json +56 -0
  141. package/references/multi-agent-protocol/schema/meta.json +467 -0
  142. package/references/multi-agent-protocol/schema/schema.json +2558 -0
  143. package/src/acp/__tests__/history.test.ts +526 -0
  144. package/src/acp/__tests__/integration.test.ts +2 -1
  145. package/src/acp/index.ts +4 -0
  146. package/src/acp/macro-agent.ts +329 -85
  147. package/src/acp/types.ts +39 -2
  148. package/src/agent/__tests__/agent-manager.test.ts +67 -1
  149. package/src/agent/agent-manager.ts +10 -4
  150. package/src/cli/__tests__/stable-instance-id.test.ts +57 -0
  151. package/src/cli/acp.ts +17 -2
  152. package/src/map/adapter/acp-over-map.ts +57 -2
  153. package/src/store/event-store.ts +10 -3
  154. package/src/store/types/agents.ts +2 -0
@@ -0,0 +1,375 @@
1
+ ---
2
+ title: Agent Integration
3
+ parent: Guides
4
+ grand_parent: SDK
5
+ nav_order: 3
6
+ description: "Build agents that register and process work"
7
+ ---
8
+
9
+ # Agent Integration
10
+ {: .no_toc }
11
+
12
+ Build agents that register with MAP servers and collaborate with other agents.
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 AgentConnection
24
+
25
+ Use `AgentConnection` when building:
26
+ - AI agents that process tasks
27
+ - Workers that handle background jobs
28
+ - Services that collaborate with other agents
29
+ - Bots that respond to events
30
+
31
+ ---
32
+
33
+ ## Basic Usage
34
+
35
+ ```typescript
36
+ import { AgentConnection } from "@multi-agent-protocol/sdk";
37
+
38
+ // Create connection
39
+ const agent = new AgentConnection(stream, {
40
+ name: "WorkerAgent",
41
+ role: "processor",
42
+ });
43
+
44
+ // Connect (automatically registers the agent)
45
+ const { agent: registered, connection } = await agent.connect();
46
+ console.log(`Registered as ${registered.id}`);
47
+
48
+ // Handle messages
49
+ agent.onMessage((message) => {
50
+ console.log(`Received from ${message.from}:`, message.payload);
51
+ });
52
+
53
+ // Disconnect when done
54
+ await agent.disconnect();
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Connection Options
60
+
61
+ ```typescript
62
+ const agent = new AgentConnection(stream, {
63
+ name: "WorkerAgent", // Agent name (required)
64
+ role: "processor", // Agent role
65
+ metadata: { // Custom metadata
66
+ version: "1.0.0",
67
+ capabilities: ["text", "image"],
68
+ },
69
+ reconnect: {
70
+ enabled: true, // Auto-reconnect
71
+ maxAttempts: 10,
72
+ baseDelayMs: 1000,
73
+ maxDelayMs: 30000,
74
+ },
75
+ });
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Message Handling
81
+
82
+ ### Basic Handler
83
+
84
+ ```typescript
85
+ agent.onMessage((message) => {
86
+ const { type, data } = message.payload;
87
+
88
+ switch (type) {
89
+ case "task":
90
+ processTask(data);
91
+ break;
92
+ case "query":
93
+ handleQuery(data);
94
+ break;
95
+ default:
96
+ console.log(`Unknown message type: ${type}`);
97
+ }
98
+ });
99
+ ```
100
+
101
+ ### Async Handler
102
+
103
+ ```typescript
104
+ agent.onMessage(async (message) => {
105
+ const result = await processAsync(message.payload);
106
+
107
+ // Reply to sender
108
+ await agent.send({
109
+ to: { agentId: message.from },
110
+ payload: { type: "result", data: result },
111
+ });
112
+ });
113
+ ```
114
+
115
+ ---
116
+
117
+ ## Sending Messages
118
+
119
+ ### Send to Another Agent
120
+
121
+ ```typescript
122
+ await agent.send({
123
+ to: { agentId: "other-agent-id" },
124
+ payload: {
125
+ type: "request",
126
+ data: { action: "help", context: {} },
127
+ },
128
+ });
129
+ ```
130
+
131
+ ### Send to Scope
132
+
133
+ ```typescript
134
+ // Message all agents in the scope
135
+ await agent.send({
136
+ to: { scopeId: "team-scope" },
137
+ payload: {
138
+ type: "broadcast",
139
+ message: "Task completed",
140
+ },
141
+ });
142
+ ```
143
+
144
+ ---
145
+
146
+ ## Working with Scopes
147
+
148
+ Scopes are logical groupings for collaboration.
149
+
150
+ ### Create a Scope
151
+
152
+ ```typescript
153
+ const scope = await agent.createScope({
154
+ name: "project-alpha",
155
+ metadata: {
156
+ description: "Agents working on project alpha",
157
+ },
158
+ });
159
+ console.log(`Created scope: ${scope.id}`);
160
+ ```
161
+
162
+ ### Join a Scope
163
+
164
+ ```typescript
165
+ await agent.joinScope("scope-id");
166
+ console.log("Joined scope");
167
+
168
+ // Now receives messages sent to that scope
169
+ ```
170
+
171
+ ### Leave a Scope
172
+
173
+ ```typescript
174
+ await agent.leaveScope("scope-id");
175
+ ```
176
+
177
+ ---
178
+
179
+ ## Updating Agent State
180
+
181
+ ### Update Metadata
182
+
183
+ ```typescript
184
+ await agent.update({
185
+ metadata: {
186
+ currentTask: "task-123",
187
+ progress: 0.5,
188
+ },
189
+ });
190
+ ```
191
+
192
+ ### Update State
193
+
194
+ ```typescript
195
+ // Set busy state
196
+ await agent.update({ state: "busy" });
197
+
198
+ // Set running state
199
+ await agent.update({ state: "running" });
200
+ ```
201
+
202
+ ---
203
+
204
+ ## Querying Other Agents
205
+
206
+ ### List Agents
207
+
208
+ ```typescript
209
+ const { agents } = await agent.listAgents();
210
+ agents.forEach((a) => {
211
+ console.log(`${a.name} (${a.role}): ${a.state}`);
212
+ });
213
+ ```
214
+
215
+ ### Find Specific Agents
216
+
217
+ ```typescript
218
+ // Find by role
219
+ const { agents: processors } = await agent.listAgents({
220
+ role: "processor",
221
+ });
222
+
223
+ // Find by state
224
+ const { agents: available } = await agent.listAgents({
225
+ state: "running",
226
+ });
227
+
228
+ // Find in scope
229
+ const { agents: teammates } = await agent.listAgents({
230
+ scopeId: "team-scope",
231
+ });
232
+ ```
233
+
234
+ ---
235
+
236
+ ## Event Subscriptions
237
+
238
+ Agents can subscribe to system events:
239
+
240
+ ```typescript
241
+ const subscription = await agent.subscribe({
242
+ eventTypes: [
243
+ "agent.registered", // New agents
244
+ "scope.joined", // Agents joining scopes
245
+ "message.sent", // Messages in scopes we're in
246
+ ],
247
+ });
248
+
249
+ for await (const event of subscription) {
250
+ switch (event.type) {
251
+ case "agent.registered":
252
+ console.log(`New agent: ${event.data.agent.name}`);
253
+ break;
254
+ case "scope.joined":
255
+ if (event.data.scopeId === myScope.id) {
256
+ console.log(`${event.data.agentId} joined our scope`);
257
+ }
258
+ break;
259
+ }
260
+ }
261
+ ```
262
+
263
+ ---
264
+
265
+ ## Complete Example: Task Processor
266
+
267
+ ```typescript
268
+ import { AgentConnection } from "@multi-agent-protocol/sdk";
269
+
270
+ async function createTaskProcessor(stream: Stream) {
271
+ const agent = new AgentConnection(stream, {
272
+ name: "TaskProcessor",
273
+ role: "worker",
274
+ metadata: {
275
+ capabilities: ["text-analysis", "summarization"],
276
+ },
277
+ reconnect: { enabled: true },
278
+ });
279
+
280
+ // Connect
281
+ const { agent: registered } = await agent.connect();
282
+ console.log(`Registered as ${registered.id}`);
283
+
284
+ // Join task queue scope
285
+ await agent.joinScope("task-queue");
286
+ console.log("Joined task queue");
287
+
288
+ // Set up message handler
289
+ agent.onMessage(async (message) => {
290
+ const { taskId, type, data } = message.payload;
291
+ console.log(`Processing task ${taskId} (${type})`);
292
+
293
+ // Update state
294
+ await agent.update({
295
+ state: "busy",
296
+ metadata: { currentTask: taskId },
297
+ });
298
+
299
+ try {
300
+ // Process the task
301
+ let result;
302
+ switch (type) {
303
+ case "analyze":
304
+ result = await analyzeText(data);
305
+ break;
306
+ case "summarize":
307
+ result = await summarizeText(data);
308
+ break;
309
+ default:
310
+ throw new Error(`Unknown task type: ${type}`);
311
+ }
312
+
313
+ // Send result back
314
+ await agent.send({
315
+ to: { agentId: message.from },
316
+ payload: {
317
+ type: "task-result",
318
+ taskId,
319
+ success: true,
320
+ result,
321
+ },
322
+ });
323
+
324
+ console.log(`Completed task ${taskId}`);
325
+ } catch (error) {
326
+ // Send error back
327
+ await agent.send({
328
+ to: { agentId: message.from },
329
+ payload: {
330
+ type: "task-result",
331
+ taskId,
332
+ success: false,
333
+ error: error.message,
334
+ },
335
+ });
336
+
337
+ console.error(`Failed task ${taskId}:`, error);
338
+ } finally {
339
+ // Update state back to running
340
+ await agent.update({
341
+ state: "running",
342
+ metadata: { currentTask: null },
343
+ });
344
+ }
345
+ });
346
+
347
+ console.log("Ready to process tasks");
348
+
349
+ // Handle shutdown
350
+ process.on("SIGTERM", async () => {
351
+ console.log("Shutting down...");
352
+ await agent.leaveScope("task-queue");
353
+ await agent.disconnect();
354
+ });
355
+ }
356
+ ```
357
+
358
+ ---
359
+
360
+ ## Best Practices
361
+
362
+ 1. **Handle reconnection** - Store resume token for session continuity
363
+ 2. **Update state** - Keep agent state current (running/busy/etc.)
364
+ 3. **Use scopes** - Group related agents for easier messaging
365
+ 4. **Handle errors** - Send error responses for failed tasks
366
+ 5. **Clean up** - Leave scopes and disconnect gracefully
367
+ 6. **Use metadata** - Store agent capabilities and current work
368
+
369
+ ---
370
+
371
+ ## Next Steps
372
+
373
+ - [Client Integration](./client.html) - Build monitoring dashboards
374
+ - [Transports](./transports.html) - Connect via different transports
375
+ - [Testing](./testing.html) - Test agent integrations