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.
- package/.claude/settings.local.json +59 -0
- package/dist/acp/index.d.ts +1 -1
- package/dist/acp/index.d.ts.map +1 -1
- package/dist/acp/index.js.map +1 -1
- package/dist/acp/macro-agent.d.ts +21 -0
- package/dist/acp/macro-agent.d.ts.map +1 -1
- package/dist/acp/macro-agent.js +182 -0
- package/dist/acp/macro-agent.js.map +1 -1
- package/dist/acp/types.d.ts +31 -2
- package/dist/acp/types.d.ts.map +1 -1
- package/dist/acp/types.js.map +1 -1
- 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/acp-over-map.d.ts +5 -0
- package/dist/map/adapter/acp-over-map.d.ts.map +1 -1
- package/dist/map/adapter/acp-over-map.js +47 -4
- package/dist/map/adapter/acp-over-map.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/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/acp/__tests__/history.test.ts +526 -0
- package/src/acp/__tests__/integration.test.ts +2 -1
- package/src/acp/index.ts +4 -0
- package/src/acp/macro-agent.ts +329 -85
- package/src/acp/types.ts +39 -2
- 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/acp-over-map.ts +57 -2
- package/src/store/event-store.ts +10 -3
- package/src/store/types/agents.ts +2 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: API Reference
|
|
3
|
+
parent: SDK
|
|
4
|
+
nav_order: 2
|
|
5
|
+
has_children: true
|
|
6
|
+
description: "SDK API reference documentation"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# API Reference
|
|
10
|
+
|
|
11
|
+
Complete API reference for the MAP TypeScript SDK.
|
|
12
|
+
{: .fs-6 .fw-300 }
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Available References
|
|
17
|
+
|
|
18
|
+
| Reference | Description |
|
|
19
|
+
|:----------|:------------|
|
|
20
|
+
| [Server API](./server.html) | MAPServer class and building blocks |
|
|
21
|
+
| [Client API](./client.html) | ClientConnection methods and properties |
|
|
22
|
+
| [Agent API](./agent.html) | AgentConnection methods and properties |
|
|
23
|
+
| [Types](./types.html) | TypeScript type definitions |
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Quick Import Reference
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
// Main exports
|
|
31
|
+
import {
|
|
32
|
+
ClientConnection,
|
|
33
|
+
AgentConnection,
|
|
34
|
+
GatewayConnection,
|
|
35
|
+
} from "@multi-agent-protocol/sdk";
|
|
36
|
+
|
|
37
|
+
// Server components
|
|
38
|
+
import {
|
|
39
|
+
MAPServer,
|
|
40
|
+
EventBusImpl,
|
|
41
|
+
AgentRegistryImpl,
|
|
42
|
+
ScopeManagerImpl,
|
|
43
|
+
SessionManagerImpl,
|
|
44
|
+
SubscriptionManagerImpl,
|
|
45
|
+
MessageRouterImpl,
|
|
46
|
+
} from "@multi-agent-protocol/sdk/server";
|
|
47
|
+
|
|
48
|
+
// Stream utilities
|
|
49
|
+
import { createStreamPair } from "@multi-agent-protocol/sdk/stream";
|
|
50
|
+
|
|
51
|
+
// Types
|
|
52
|
+
import type {
|
|
53
|
+
Agent,
|
|
54
|
+
RegisteredAgent,
|
|
55
|
+
Message,
|
|
56
|
+
Event,
|
|
57
|
+
Subscription,
|
|
58
|
+
Scope,
|
|
59
|
+
Session,
|
|
60
|
+
Stream,
|
|
61
|
+
} from "@multi-agent-protocol/sdk";
|
|
62
|
+
```
|
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Server API
|
|
3
|
+
parent: API Reference
|
|
4
|
+
grand_parent: SDK
|
|
5
|
+
nav_order: 1
|
|
6
|
+
description: "MAPServer class and building blocks API"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Server API
|
|
10
|
+
{: .no_toc }
|
|
11
|
+
|
|
12
|
+
MAPServer class and building block APIs.
|
|
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
|
+
## MAPServer
|
|
24
|
+
|
|
25
|
+
The main server class that wires together all building blocks.
|
|
26
|
+
|
|
27
|
+
### Constructor
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
const server = new MAPServer(options?: MAPServerOptions);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Options
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
interface MAPServerOptions {
|
|
37
|
+
// Server identity
|
|
38
|
+
name?: string;
|
|
39
|
+
version?: string;
|
|
40
|
+
|
|
41
|
+
// Capabilities advertised to clients
|
|
42
|
+
capabilities?: ServerCapabilities;
|
|
43
|
+
|
|
44
|
+
// Custom protocol handlers
|
|
45
|
+
additionalHandlers?: Record<string, Handler>;
|
|
46
|
+
|
|
47
|
+
// Request middleware
|
|
48
|
+
middleware?: Middleware[];
|
|
49
|
+
|
|
50
|
+
// Event delivery configuration
|
|
51
|
+
eventDelivery?: {
|
|
52
|
+
enabled?: boolean;
|
|
53
|
+
filter?: (event: Event, subscription: Subscription) => boolean;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Session configuration
|
|
57
|
+
resumeWindowMs?: number;
|
|
58
|
+
|
|
59
|
+
// Custom stores
|
|
60
|
+
stores?: {
|
|
61
|
+
events?: EventStore;
|
|
62
|
+
agents?: AgentStore;
|
|
63
|
+
sessions?: SessionStore;
|
|
64
|
+
scopes?: ScopeStore;
|
|
65
|
+
subscriptions?: SubscriptionStore;
|
|
66
|
+
messages?: MessageStore;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// Custom building blocks
|
|
70
|
+
eventBus?: EventBus;
|
|
71
|
+
agents?: AgentRegistry;
|
|
72
|
+
sessions?: SessionManager;
|
|
73
|
+
scopes?: ScopeManager;
|
|
74
|
+
subscriptions?: SubscriptionManager;
|
|
75
|
+
messages?: MessageRouter;
|
|
76
|
+
|
|
77
|
+
// Authentication
|
|
78
|
+
auth?: AuthConfig;
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Properties
|
|
83
|
+
|
|
84
|
+
| Property | Type | Description |
|
|
85
|
+
|:---------|:-----|:------------|
|
|
86
|
+
| `agents` | `AgentRegistry` | Agent registry instance |
|
|
87
|
+
| `sessions` | `SessionManager` | Session manager instance |
|
|
88
|
+
| `scopes` | `ScopeManager` | Scope manager instance |
|
|
89
|
+
| `subscriptions` | `SubscriptionManager` | Subscription manager instance |
|
|
90
|
+
| `messages` | `MessageRouter` | Message router instance |
|
|
91
|
+
| `connections` | `Map<string, Router>` | Active connections |
|
|
92
|
+
|
|
93
|
+
### Methods
|
|
94
|
+
|
|
95
|
+
#### accept()
|
|
96
|
+
|
|
97
|
+
Accept an incoming connection:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
const router = server.accept(stream: Stream, options?: AcceptOptions): Router;
|
|
101
|
+
|
|
102
|
+
interface AcceptOptions {
|
|
103
|
+
role?: "client" | "agent" | "gateway";
|
|
104
|
+
name?: string;
|
|
105
|
+
resumeToken?: string;
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### emit()
|
|
110
|
+
|
|
111
|
+
Emit an event to the event bus:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
server.emit(event: { type: string; data: unknown }): void;
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### on()
|
|
118
|
+
|
|
119
|
+
Listen for events:
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
server.on(eventType: string, handler: (event: Event) => void): void;
|
|
123
|
+
server.on("agent.registered", (event) => { ... });
|
|
124
|
+
server.on("*", (event) => { ... }); // All events
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### close()
|
|
128
|
+
|
|
129
|
+
Gracefully shut down the server:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
await server.close(options?: CloseOptions): Promise<void>;
|
|
133
|
+
|
|
134
|
+
interface CloseOptions {
|
|
135
|
+
timeout?: number; // Default: 5000ms
|
|
136
|
+
force?: boolean; // Skip graceful shutdown
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## AgentRegistry
|
|
143
|
+
|
|
144
|
+
Manages registered agents.
|
|
145
|
+
|
|
146
|
+
### Methods
|
|
147
|
+
|
|
148
|
+
#### register()
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
const agent = agents.register(params: RegisterParams): RegisteredAgent;
|
|
152
|
+
|
|
153
|
+
interface RegisterParams {
|
|
154
|
+
name: string;
|
|
155
|
+
sessionId: string;
|
|
156
|
+
role?: string;
|
|
157
|
+
parentId?: string;
|
|
158
|
+
metadata?: Record<string, unknown>;
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### unregister()
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
const success = agents.unregister(agentId: string): boolean;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
#### get()
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
const agent = agents.get(agentId: string): RegisteredAgent | undefined;
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### list()
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
const agentList = agents.list(filter?: AgentFilter): RegisteredAgent[];
|
|
178
|
+
|
|
179
|
+
interface AgentFilter {
|
|
180
|
+
role?: string;
|
|
181
|
+
state?: string;
|
|
182
|
+
scopeId?: string;
|
|
183
|
+
parentId?: string;
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### update()
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
const agent = agents.update(agentId: string, updates: AgentUpdates): RegisteredAgent;
|
|
191
|
+
|
|
192
|
+
interface AgentUpdates {
|
|
193
|
+
state?: string;
|
|
194
|
+
metadata?: Record<string, unknown>;
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## ScopeManager
|
|
201
|
+
|
|
202
|
+
Manages scopes (logical groupings).
|
|
203
|
+
|
|
204
|
+
### Methods
|
|
205
|
+
|
|
206
|
+
#### create()
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
const scope = scopes.create(params: CreateScopeParams): Scope;
|
|
210
|
+
|
|
211
|
+
interface CreateScopeParams {
|
|
212
|
+
name: string;
|
|
213
|
+
parentId?: string;
|
|
214
|
+
metadata?: Record<string, unknown>;
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
#### delete()
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
const success = scopes.delete(scopeId: string): boolean;
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
#### get()
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
const scope = scopes.get(scopeId: string): Scope | undefined;
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
#### list()
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
const scopeList = scopes.list(filter?: ScopeFilter): Scope[];
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
#### join()
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
scopes.join(scopeId: string, agentId: string): void;
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
#### leave()
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
scopes.leave(scopeId: string, agentId: string): void;
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
#### getMembers()
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
const memberIds = scopes.getMembers(scopeId: string): string[];
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## SessionManager
|
|
257
|
+
|
|
258
|
+
Manages connection sessions.
|
|
259
|
+
|
|
260
|
+
### Methods
|
|
261
|
+
|
|
262
|
+
#### create()
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
const session = sessions.create(params: CreateSessionParams): Session;
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
#### get()
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
const session = sessions.get(sessionId: string): Session | undefined;
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
#### list()
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
const sessionList = sessions.list(filter?: SessionFilter): Session[];
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
#### close()
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
sessions.close(sessionId: string): void;
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
#### canResume()
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
const resumable = sessions.canResume(resumeToken: string): boolean;
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
#### resume()
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
const session = sessions.resume(resumeToken: string): Session | undefined;
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## EventBus
|
|
301
|
+
|
|
302
|
+
Central event dispatcher.
|
|
303
|
+
|
|
304
|
+
### Methods
|
|
305
|
+
|
|
306
|
+
#### emit()
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
eventBus.emit(event: Event): void;
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
#### on()
|
|
313
|
+
|
|
314
|
+
```typescript
|
|
315
|
+
eventBus.on(eventType: string, handler: EventHandler): void;
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
#### off()
|
|
319
|
+
|
|
320
|
+
```typescript
|
|
321
|
+
eventBus.off(eventType: string, handler: EventHandler): void;
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
#### getHistory()
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
const events = eventBus.getHistory(afterId?: string, limit?: number): Event[];
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## SubscriptionManager
|
|
333
|
+
|
|
334
|
+
Manages event subscriptions.
|
|
335
|
+
|
|
336
|
+
### Methods
|
|
337
|
+
|
|
338
|
+
#### create()
|
|
339
|
+
|
|
340
|
+
```typescript
|
|
341
|
+
const subscription = subscriptions.create(params: CreateSubscriptionParams): Subscription;
|
|
342
|
+
|
|
343
|
+
interface CreateSubscriptionParams {
|
|
344
|
+
sessionId: string;
|
|
345
|
+
eventTypes: string[];
|
|
346
|
+
scopeIds?: string[];
|
|
347
|
+
options?: SubscriptionOptions;
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
#### get()
|
|
352
|
+
|
|
353
|
+
```typescript
|
|
354
|
+
const subscription = subscriptions.get(subscriptionId: string): Subscription | undefined;
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
#### delete()
|
|
358
|
+
|
|
359
|
+
```typescript
|
|
360
|
+
subscriptions.delete(subscriptionId: string): void;
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
#### getForSession()
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
const subs = subscriptions.getForSession(sessionId: string): Subscription[];
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## MessageRouter
|
|
372
|
+
|
|
373
|
+
Routes messages between participants.
|
|
374
|
+
|
|
375
|
+
### Methods
|
|
376
|
+
|
|
377
|
+
#### send()
|
|
378
|
+
|
|
379
|
+
```typescript
|
|
380
|
+
const result = await messages.send(params: SendParams): SendResult;
|
|
381
|
+
|
|
382
|
+
interface SendParams {
|
|
383
|
+
from?: string;
|
|
384
|
+
to: Address;
|
|
385
|
+
payload: unknown;
|
|
386
|
+
meta?: MessageMeta;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
interface SendResult {
|
|
390
|
+
messageId: string;
|
|
391
|
+
delivered: number;
|
|
392
|
+
receipts: DeliveryReceipt[];
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
#### getQueue()
|
|
397
|
+
|
|
398
|
+
```typescript
|
|
399
|
+
const queue = messages.getQueue(agentId: string): Message[];
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
## Types
|
|
405
|
+
|
|
406
|
+
### RegisteredAgent
|
|
407
|
+
|
|
408
|
+
```typescript
|
|
409
|
+
interface RegisteredAgent {
|
|
410
|
+
id: string;
|
|
411
|
+
name: string;
|
|
412
|
+
sessionId: string;
|
|
413
|
+
role?: string;
|
|
414
|
+
state: AgentState;
|
|
415
|
+
parentId?: string;
|
|
416
|
+
scopeIds: string[];
|
|
417
|
+
metadata?: Record<string, unknown>;
|
|
418
|
+
registeredAt: number;
|
|
419
|
+
updatedAt: number;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
type AgentState = "registered" | "running" | "busy" | "suspended" | "stopped";
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
### Scope
|
|
426
|
+
|
|
427
|
+
```typescript
|
|
428
|
+
interface Scope {
|
|
429
|
+
id: string;
|
|
430
|
+
name: string;
|
|
431
|
+
parentId?: string;
|
|
432
|
+
metadata?: Record<string, unknown>;
|
|
433
|
+
createdAt: number;
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### Session
|
|
438
|
+
|
|
439
|
+
```typescript
|
|
440
|
+
interface Session {
|
|
441
|
+
id: string;
|
|
442
|
+
participantType: "client" | "agent" | "gateway";
|
|
443
|
+
name?: string;
|
|
444
|
+
state: SessionState;
|
|
445
|
+
agentId?: string;
|
|
446
|
+
resumeToken?: string;
|
|
447
|
+
principal?: Principal;
|
|
448
|
+
connectedAt: number;
|
|
449
|
+
lastActivityAt: number;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
type SessionState = "connecting" | "connected" | "disconnected" | "closed";
|
|
453
|
+
```
|