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,468 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Types
|
|
3
|
+
parent: API Reference
|
|
4
|
+
grand_parent: SDK
|
|
5
|
+
nav_order: 4
|
|
6
|
+
description: "TypeScript type definitions"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Types
|
|
10
|
+
{: .no_toc }
|
|
11
|
+
|
|
12
|
+
TypeScript type definitions for the MAP SDK.
|
|
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
|
+
## Core Types
|
|
24
|
+
|
|
25
|
+
### Stream
|
|
26
|
+
|
|
27
|
+
Bidirectional communication stream:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
interface Stream {
|
|
31
|
+
readable: ReadableStream<JSONRPCMessage>;
|
|
32
|
+
writable: WritableStream<JSONRPCMessage>;
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### JSONRPCMessage
|
|
37
|
+
|
|
38
|
+
JSON-RPC 2.0 message types:
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
type JSONRPCMessage = JSONRPCRequest | JSONRPCResponse | JSONRPCNotification;
|
|
42
|
+
|
|
43
|
+
interface JSONRPCRequest {
|
|
44
|
+
jsonrpc: "2.0";
|
|
45
|
+
id: string | number;
|
|
46
|
+
method: string;
|
|
47
|
+
params?: unknown;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface JSONRPCResponse {
|
|
51
|
+
jsonrpc: "2.0";
|
|
52
|
+
id: string | number;
|
|
53
|
+
result?: unknown;
|
|
54
|
+
error?: JSONRPCError;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface JSONRPCNotification {
|
|
58
|
+
jsonrpc: "2.0";
|
|
59
|
+
method: string;
|
|
60
|
+
params?: unknown;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface JSONRPCError {
|
|
64
|
+
code: number;
|
|
65
|
+
message: string;
|
|
66
|
+
data?: unknown;
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Entity Types
|
|
73
|
+
|
|
74
|
+
### Agent
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
interface Agent {
|
|
78
|
+
id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
role?: string;
|
|
81
|
+
state: AgentState;
|
|
82
|
+
parentId?: string;
|
|
83
|
+
scopeIds: string[];
|
|
84
|
+
metadata?: Record<string, unknown>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type AgentState =
|
|
88
|
+
| "registered"
|
|
89
|
+
| "running"
|
|
90
|
+
| "busy"
|
|
91
|
+
| "idle"
|
|
92
|
+
| "suspended"
|
|
93
|
+
| "stopping"
|
|
94
|
+
| "stopped"
|
|
95
|
+
| "failed";
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### RegisteredAgent
|
|
99
|
+
|
|
100
|
+
Extended agent with registration details:
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
interface RegisteredAgent extends Agent {
|
|
104
|
+
sessionId: string;
|
|
105
|
+
registeredAt: number;
|
|
106
|
+
updatedAt: number;
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Scope
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
interface Scope {
|
|
114
|
+
id: string;
|
|
115
|
+
name: string;
|
|
116
|
+
parentId?: string;
|
|
117
|
+
metadata?: Record<string, unknown>;
|
|
118
|
+
createdAt: number;
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Session
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
interface Session {
|
|
126
|
+
id: string;
|
|
127
|
+
participantType: ParticipantType;
|
|
128
|
+
name?: string;
|
|
129
|
+
state: SessionState;
|
|
130
|
+
agentId?: string;
|
|
131
|
+
resumeToken?: string;
|
|
132
|
+
principal?: Principal;
|
|
133
|
+
connectedAt: number;
|
|
134
|
+
lastActivityAt: number;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
type ParticipantType = "client" | "agent" | "gateway";
|
|
138
|
+
|
|
139
|
+
type SessionState = "connecting" | "connected" | "disconnected" | "closed";
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Message Types
|
|
145
|
+
|
|
146
|
+
### Message
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
interface Message {
|
|
150
|
+
id: string;
|
|
151
|
+
from: string;
|
|
152
|
+
to: Address;
|
|
153
|
+
payload: unknown;
|
|
154
|
+
meta?: MessageMeta;
|
|
155
|
+
timestamp: number;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface MessageMeta {
|
|
159
|
+
priority?: Priority;
|
|
160
|
+
delivery?: DeliveryMode;
|
|
161
|
+
ttl?: number;
|
|
162
|
+
requireAck?: boolean;
|
|
163
|
+
correlationId?: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
type Priority = "low" | "normal" | "high" | "urgent";
|
|
167
|
+
type DeliveryMode = "inject" | "interrupt" | "queue" | "best-effort";
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Address
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
type Address =
|
|
174
|
+
| { agentId: string }
|
|
175
|
+
| { scopeId: string }
|
|
176
|
+
| { role: string }
|
|
177
|
+
| { agentIds: string[] }
|
|
178
|
+
| { parent: true }
|
|
179
|
+
| { children: true };
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### IncomingMessage
|
|
183
|
+
|
|
184
|
+
Message received by an agent:
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
interface IncomingMessage {
|
|
188
|
+
id: string;
|
|
189
|
+
from: string;
|
|
190
|
+
payload: unknown;
|
|
191
|
+
meta?: MessageMeta;
|
|
192
|
+
timestamp: number;
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Event Types
|
|
199
|
+
|
|
200
|
+
### Event
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
interface Event {
|
|
204
|
+
id: string;
|
|
205
|
+
type: string;
|
|
206
|
+
data: unknown;
|
|
207
|
+
timestamp: number;
|
|
208
|
+
agentId?: string;
|
|
209
|
+
scopeId?: string;
|
|
210
|
+
causedBy?: string[];
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Event Type Strings
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
// Agent events
|
|
218
|
+
type AgentEventType =
|
|
219
|
+
| "agent.registered"
|
|
220
|
+
| "agent.unregistered"
|
|
221
|
+
| "agent.updated"
|
|
222
|
+
| "agent.state";
|
|
223
|
+
|
|
224
|
+
// Scope events
|
|
225
|
+
type ScopeEventType =
|
|
226
|
+
| "scope.created"
|
|
227
|
+
| "scope.deleted"
|
|
228
|
+
| "scope.joined"
|
|
229
|
+
| "scope.left";
|
|
230
|
+
|
|
231
|
+
// Message events
|
|
232
|
+
type MessageEventType =
|
|
233
|
+
| "message.sent"
|
|
234
|
+
| "message.delivered"
|
|
235
|
+
| "message.failed";
|
|
236
|
+
|
|
237
|
+
// System events
|
|
238
|
+
type SystemEventType =
|
|
239
|
+
| "system.heartbeat"
|
|
240
|
+
| "system.capacity";
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Subscription Types
|
|
246
|
+
|
|
247
|
+
### Subscription
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
interface Subscription {
|
|
251
|
+
id: string;
|
|
252
|
+
sessionId: string;
|
|
253
|
+
eventTypes: string[];
|
|
254
|
+
scopeIds?: string[];
|
|
255
|
+
state: SubscriptionState;
|
|
256
|
+
createdAt: number;
|
|
257
|
+
|
|
258
|
+
// Async iterator
|
|
259
|
+
[Symbol.asyncIterator](): AsyncIterator<Event>;
|
|
260
|
+
|
|
261
|
+
// Methods
|
|
262
|
+
pause(): Promise<void>;
|
|
263
|
+
resume(): Promise<void>;
|
|
264
|
+
unsubscribe(): Promise<void>;
|
|
265
|
+
ack(eventId: string): Promise<void>;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
type SubscriptionState = "active" | "paused" | "closed";
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### SubscribeParams
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
interface SubscribeParams {
|
|
275
|
+
eventTypes: string[];
|
|
276
|
+
scopeIds?: string[];
|
|
277
|
+
options?: SubscriptionOptions;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
interface SubscriptionOptions {
|
|
281
|
+
bufferSize?: number;
|
|
282
|
+
overflowStrategy?: "drop" | "error" | "block";
|
|
283
|
+
ordering?: "none" | "per-agent" | "causal" | "total";
|
|
284
|
+
includeHistory?: boolean;
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Authentication Types
|
|
291
|
+
|
|
292
|
+
### AuthCredentials
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
interface AuthCredentials {
|
|
296
|
+
method: AuthMethod;
|
|
297
|
+
credential?: string;
|
|
298
|
+
metadata?: Record<string, unknown>;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
type AuthMethod = "none" | "bearer" | "api-key" | "mtls" | string;
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Principal
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
interface Principal {
|
|
308
|
+
id: string;
|
|
309
|
+
issuer?: string;
|
|
310
|
+
claims?: Record<string, unknown>;
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### AuthResult
|
|
315
|
+
|
|
316
|
+
```typescript
|
|
317
|
+
interface AuthResult {
|
|
318
|
+
success: boolean;
|
|
319
|
+
principal?: Principal;
|
|
320
|
+
expiresAt?: number;
|
|
321
|
+
error?: {
|
|
322
|
+
code: AuthErrorCode;
|
|
323
|
+
message: string;
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
type AuthErrorCode =
|
|
328
|
+
| "invalid_credentials"
|
|
329
|
+
| "expired"
|
|
330
|
+
| "insufficient_scope"
|
|
331
|
+
| "method_not_supported"
|
|
332
|
+
| "auth_required";
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## Connection Types
|
|
338
|
+
|
|
339
|
+
### ConnectionState
|
|
340
|
+
|
|
341
|
+
```typescript
|
|
342
|
+
type ConnectionState =
|
|
343
|
+
| "initial"
|
|
344
|
+
| "connecting"
|
|
345
|
+
| "connected"
|
|
346
|
+
| "reconnecting"
|
|
347
|
+
| "closed";
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### ReconnectOptions
|
|
351
|
+
|
|
352
|
+
```typescript
|
|
353
|
+
interface ReconnectOptions {
|
|
354
|
+
enabled: boolean;
|
|
355
|
+
maxAttempts?: number;
|
|
356
|
+
baseDelayMs?: number;
|
|
357
|
+
maxDelayMs?: number;
|
|
358
|
+
backoffMultiplier?: number;
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## Server Types
|
|
365
|
+
|
|
366
|
+
### ServerCapabilities
|
|
367
|
+
|
|
368
|
+
```typescript
|
|
369
|
+
interface ServerCapabilities {
|
|
370
|
+
streaming?: {
|
|
371
|
+
backpressure?: boolean;
|
|
372
|
+
maxSubscriptions?: number;
|
|
373
|
+
};
|
|
374
|
+
federation?: boolean;
|
|
375
|
+
replay?: boolean;
|
|
376
|
+
scopes?: boolean;
|
|
377
|
+
maxMessageSize?: number;
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Handler
|
|
382
|
+
|
|
383
|
+
```typescript
|
|
384
|
+
type Handler = (
|
|
385
|
+
params: unknown,
|
|
386
|
+
context: HandlerContext
|
|
387
|
+
) => Promise<unknown>;
|
|
388
|
+
|
|
389
|
+
interface HandlerContext {
|
|
390
|
+
session: Session;
|
|
391
|
+
requestId: string;
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Middleware
|
|
396
|
+
|
|
397
|
+
```typescript
|
|
398
|
+
type Middleware = (
|
|
399
|
+
method: string,
|
|
400
|
+
params: unknown,
|
|
401
|
+
context: HandlerContext,
|
|
402
|
+
next: () => Promise<unknown>
|
|
403
|
+
) => Promise<unknown>;
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
---
|
|
407
|
+
|
|
408
|
+
## Error Types
|
|
409
|
+
|
|
410
|
+
### MAPError
|
|
411
|
+
|
|
412
|
+
```typescript
|
|
413
|
+
interface MAPError extends Error {
|
|
414
|
+
code: number;
|
|
415
|
+
category: ErrorCategory;
|
|
416
|
+
data?: {
|
|
417
|
+
retryable?: boolean;
|
|
418
|
+
retryAfter?: number;
|
|
419
|
+
details?: unknown;
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
type ErrorCategory =
|
|
424
|
+
| "protocol"
|
|
425
|
+
| "auth"
|
|
426
|
+
| "routing"
|
|
427
|
+
| "agent"
|
|
428
|
+
| "resource"
|
|
429
|
+
| "federation"
|
|
430
|
+
| "internal";
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### Error Codes
|
|
434
|
+
|
|
435
|
+
```typescript
|
|
436
|
+
// Protocol errors (JSON-RPC)
|
|
437
|
+
const PARSE_ERROR = -32700;
|
|
438
|
+
const INVALID_REQUEST = -32600;
|
|
439
|
+
const METHOD_NOT_FOUND = -32601;
|
|
440
|
+
const INVALID_PARAMS = -32602;
|
|
441
|
+
const INTERNAL_ERROR = -32603;
|
|
442
|
+
|
|
443
|
+
// Auth errors
|
|
444
|
+
const AUTH_REQUIRED = 1000;
|
|
445
|
+
const AUTH_FAILED = 1001;
|
|
446
|
+
const AUTH_EXPIRED = 1002;
|
|
447
|
+
const PERMISSION_DENIED = 1003;
|
|
448
|
+
|
|
449
|
+
// Routing errors
|
|
450
|
+
const AGENT_NOT_FOUND = 2000;
|
|
451
|
+
const AGENT_STOPPED = 2001;
|
|
452
|
+
const DELIVERY_FAILED = 2006;
|
|
453
|
+
const DELIVERY_TIMEOUT = 2007;
|
|
454
|
+
|
|
455
|
+
// Agent errors
|
|
456
|
+
const AGENT_EXISTS = 3000;
|
|
457
|
+
const INVALID_PARENT = 3001;
|
|
458
|
+
const MAX_AGENTS_EXCEEDED = 3003;
|
|
459
|
+
|
|
460
|
+
// Resource errors
|
|
461
|
+
const RATE_LIMITED = 4000;
|
|
462
|
+
const QUOTA_EXCEEDED = 4001;
|
|
463
|
+
const BUFFER_OVERFLOW = 4002;
|
|
464
|
+
|
|
465
|
+
// Federation errors
|
|
466
|
+
const PEER_UNREACHABLE = 5000;
|
|
467
|
+
const PEER_TIMEOUT = 5001;
|
|
468
|
+
```
|