@multi-agent-protocol/sdk 0.0.2
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/README.md +248 -0
- package/dist/index-C7XPWnxS.d.cts +3052 -0
- package/dist/index-C7XPWnxS.d.ts +3052 -0
- package/dist/index.cjs +4528 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2288 -0
- package/dist/index.d.ts +2288 -0
- package/dist/index.js +4353 -0
- package/dist/index.js.map +1 -0
- package/dist/testing.cjs +4004 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +367 -0
- package/dist/testing.d.ts +367 -0
- package/dist/testing.js +4000 -0
- package/dist/testing.js.map +1 -0
- package/package.json +79 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,2288 @@
|
|
|
1
|
+
import { R as RequestId, M as MAPError, a as MAPErrorData, E as ErrorCategory, F as FederationBufferConfig, b as FederationEnvelope, c as Message, S as Stream, B as BaseConnectionOptions, P as ParticipantCapabilities, d as FederationRoutingConfig, e as EventType, C as ConnectResponseResult, f as SessionId, g as FederationConnectResponseResult, h as FederationRouteResponseResult, i as ConnectionState, j as ParticipantId, k as ParticipantType, A as AgentId, l as ScopeId, m as Agent, n as Scope, o as Address, p as SubscriptionFilter, q as Event, r as AgentsGetResponseResult, s as AgentsListResponseResult, t as AgentsRegisterResponseResult, u as AgentsSpawnResponseResult, v as AgentsUnregisterResponseResult, w as AgentsUpdateResponseResult, x as ProtocolVersion, y as SessionInfo, D as DisconnectResponseResult, z as ScopesCreateResponseResult, G as ScopesJoinResponseResult, H as ScopesLeaveResponseResult, I as ScopesListResponseResult, J as MessageId, K as SendResponseResult, L as SubscriptionId, N as SubscribeResponseResult, U as UnsubscribeResponseResult } from './index-C7XPWnxS.cjs';
|
|
2
|
+
export { O as AGENT_ERROR_CODES, Q as AUTH_ERROR_CODES, T as AUTH_METHODS, V as AcceptanceContext, W as AgentAcceptanceRule, X as AgentConnection, Y as AgentConnectionOptions, Z as AgentIncludeOptions, _ as AgentLifecycle, $ as AgentMessagingRule, a0 as AgentPermissionConfig, a1 as AgentPermissions, a2 as AgentReconnectionEventHandler, a3 as AgentReconnectionEventType, a4 as AgentReconnectionOptions, a5 as AgentRelationship, a6 as AgentRelationshipType, a7 as AgentState, a8 as AgentVisibility, a9 as AgentVisibilityRule, aa as AgentsGetRequest, ab as AgentsGetRequestParams, ac as AgentsListFilter, ad as AgentsListRequest, ae as AgentsListRequestParams, af as AgentsRegisterRequest, ag as AgentsRegisterRequestParams, ah as AgentsResumeRequest, ai as AgentsResumeRequestParams, aj as AgentsResumeResponseResult, ak as AgentsSpawnRequest, al as AgentsSpawnRequestParams, am as AgentsStopRequest, an as AgentsStopRequestParams, ao as AgentsStopResponseResult, ap as AgentsSuspendRequest, aq as AgentsSuspendRequestParams, ar as AgentsSuspendResponseResult, as as AgentsUnregisterRequest, at as AgentsUnregisterRequestParams, au as AgentsUpdateRequest, av as AgentsUpdateRequestParams, aw as AnyMessage, ax as AuthMethod, ay as AuthParams, az as AuthRefreshRequest, aA as AuthRefreshRequestParams, aB as AuthRefreshResponseResult, aC as BaseConnection, aD as BroadcastAddress, aE as CAPABILITY_REQUIREMENTS, aF as CORE_METHODS, aG as ClientAcceptanceRule, aH as ClientConnection, aI as ClientConnectionOptions, aJ as ConnectRequest, aK as ConnectRequestParams, aL as CorrelationId, aM as DEFAULT_AGENT_PERMISSION_CONFIG, aN as DeliverySemantics, aO as DirectAddress, aP as DisconnectPolicy, aQ as DisconnectRequest, aR as DisconnectRequestParams, aS as ERROR_CODES, aT as EVENT_TYPES, aU as EXTENSION_METHODS, aV as EventInput, aW as EventNotification, aX as EventNotificationParams, aY as FEDERATION_ERROR_CODES, aZ as FEDERATION_METHODS, a_ as FederatedAddress, a$ as FederationAuth, b0 as FederationConnectRequest, b1 as FederationConnectRequestParams, b2 as FederationMetadata, b3 as FederationReplayConfig, b4 as FederationRouteRequest, b5 as FederationRouteRequestParams, b6 as GatewayReconnectionEvent, b7 as GatewayReconnectionEventHandler, b8 as GatewayReconnectionEventType, b9 as GatewayReconnectionOptions, ba as GraphEdge, bb as HierarchicalAddress, bc as InjectDelivery, bd as InjectDeliveryResult, be as InjectRequest, bf as InjectRequestParams, bg as InjectResponseResult, bh as JSONRPC_VERSION, bi as JoinPolicy, bj as LIFECYCLE_METHODS, bk as MAPNotification, bl as MAPNotificationBase, bm as MAPRequest, bn as MAPRequestBase, bo as MAPResponse, bp as MAPResponseError, bq as MAPResponseSuccess, br as MAP_METHODS, bs as MessageDeliveredEventData, bt as MessageFailedEventData, bu as MessageHandler, bv as MessageMeta, bw as MessageNotification, bx as MessageNotificationParams, by as MessagePriority, bz as MessageRelationship, bA as MessageSentEventData, bB as MessageVisibility, bC as Meta, bD as MultiAddress, bE as NOTIFICATION_METHODS, bF as NotificationHandler, bG as OBSERVATION_METHODS, bH as OverflowHandler, bI as OverflowInfo, bJ as PERMISSION_METHODS, bK as PROTOCOL_ERROR_CODES, bL as PROTOCOL_VERSION, bM as Participant, bN as ParticipantAddress, bO as PermissionAction, bP as PermissionContext, bQ as PermissionParticipant, bR as PermissionResult, bS as PermissionSystemConfig, bT as PermissionsAgentUpdatedEventData, bU as PermissionsClientUpdatedEventData, bV as PermissionsUpdateRequest, bW as PermissionsUpdateRequestParams, bX as PermissionsUpdateResponseResult, bY as RESOURCE_ERROR_CODES, bZ as ROUTING_ERROR_CODES, b_ as ReconnectionEventHandler, b$ as ReconnectionEventType, c0 as ReconnectionOptions, c1 as ReplayRequest, c2 as ReplayRequestParams, c3 as ReplayResponseResult, c4 as ReplayedEvent, c5 as RequestHandler, c6 as RoleAddress, c7 as SCOPE_METHODS, c8 as SESSION_METHODS, c9 as STATE_METHODS, ca as STEERING_METHODS, cb as STRUCTURE_METHODS, cc as ScopeAddress, cd as ScopeMessagingRule, ce as ScopeVisibility, cf as ScopeVisibilityRule, cg as ScopesCreateRequest, ch as ScopesCreateRequestParams, ci as ScopesDeleteRequest, cj as ScopesDeleteRequestParams, ck as ScopesDeleteResponseResult, cl as ScopesGetRequest, cm as ScopesGetRequestParams, cn as ScopesGetResponseResult, co as ScopesJoinRequest, cp as ScopesJoinRequestParams, cq as ScopesLeaveRequest, cr as ScopesLeaveRequestParams, cs as ScopesListRequest, ct as ScopesListRequestParams, cu as ScopesMembersRequest, cv as ScopesMembersRequestParams, cw as ScopesMembersResponseResult, cx as SendPolicy, cy as SendRequest, cz as SendRequestParams, cA as SessionCloseRequest, cB as SessionCloseRequestParams, cC as SessionCloseResponseResult, cD as SessionListRequest, cE as SessionListRequestParams, cF as SessionListResponseResult, cG as SessionLoadRequest, cH as SessionLoadRequestParams, cI as SessionLoadResponseResult, cJ as StateChangeHandler, cK as StreamingCapabilities, cL as StructureGraphRequest, cM as StructureGraphRequestParams, cN as StructureGraphResponseResult, cO as StructureVisibilityRule, cP as SubscribeRequest, cQ as SubscribeRequestParams, cR as Subscription, cS as SubscriptionAckNotification, cT as SubscriptionAckParams, cU as SubscriptionOptions, cV as SubscriptionState, cW as SystemAcceptanceRule, cX as SystemAddress, cY as Timestamp, cZ as TransportType, c_ as UnsubscribeRequest, c$ as UnsubscribeRequestParams, d0 as canAgentAcceptMessage, d1 as canAgentMessageAgent, d2 as canAgentSeeAgent, d3 as canControlAgent, d4 as canJoinScope, d5 as canMessageAgent, d6 as canPerformAction, d7 as canPerformMethod, d8 as canSeeAgent, d9 as canSeeScope, da as canSendToScope, db as createEvent, dc as createStreamPair, dd as createSubscription, de as deepMergePermissions, df as filterVisibleAgents, dg as filterVisibleEvents, dh as filterVisibleScopes, di as hasCapability, dj as isAgentExposed, dk as isBroadcastAddress, dl as isDirectAddress, dm as isEventTypeExposed, dn as isFederatedAddress, dp as isHierarchicalAddress, dq as isOrphanedAgent, dr as isScopeAddress, ds as isScopeExposed, dt as isSuccessResponse, du as mapVisibilityToRule, dv as ndJsonStream, dw as resolveAgentPermissions, dx as websocketStream } from './index-C7XPWnxS.cjs';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export { monotonicFactory, ulid } from 'ulid';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* JSON-RPC 2.0 utilities for MAP protocol
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generic JSON-RPC request structure
|
|
12
|
+
*/
|
|
13
|
+
interface JsonRpcRequest<TParams = unknown> {
|
|
14
|
+
jsonrpc: '2.0';
|
|
15
|
+
id: RequestId;
|
|
16
|
+
method: string;
|
|
17
|
+
params?: TParams;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Generic JSON-RPC notification structure (no id)
|
|
21
|
+
*/
|
|
22
|
+
interface JsonRpcNotification<TParams = unknown> {
|
|
23
|
+
jsonrpc: '2.0';
|
|
24
|
+
method: string;
|
|
25
|
+
params?: TParams;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Generic JSON-RPC success response
|
|
29
|
+
*/
|
|
30
|
+
interface JsonRpcSuccessResponse<TResult = unknown> {
|
|
31
|
+
jsonrpc: '2.0';
|
|
32
|
+
id: RequestId;
|
|
33
|
+
result: TResult;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Generic JSON-RPC error response
|
|
37
|
+
*/
|
|
38
|
+
interface JsonRpcErrorResponse {
|
|
39
|
+
jsonrpc: '2.0';
|
|
40
|
+
id: RequestId;
|
|
41
|
+
error: MAPError;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Any JSON-RPC response
|
|
45
|
+
*/
|
|
46
|
+
type JsonRpcResponse<TResult = unknown> = JsonRpcSuccessResponse<TResult> | JsonRpcErrorResponse;
|
|
47
|
+
/**
|
|
48
|
+
* Check if a message is a request (has id and method)
|
|
49
|
+
*/
|
|
50
|
+
declare function isRequest(message: unknown): message is JsonRpcRequest;
|
|
51
|
+
/**
|
|
52
|
+
* Check if a message is a notification (has method but no id)
|
|
53
|
+
*/
|
|
54
|
+
declare function isNotification(message: unknown): message is JsonRpcNotification;
|
|
55
|
+
/**
|
|
56
|
+
* Check if a message is a response (has id but no method)
|
|
57
|
+
*/
|
|
58
|
+
declare function isResponse(message: unknown): message is JsonRpcResponse;
|
|
59
|
+
/**
|
|
60
|
+
* Check if a response is an error response
|
|
61
|
+
*/
|
|
62
|
+
declare function isErrorResponse(response: JsonRpcResponse): response is JsonRpcErrorResponse;
|
|
63
|
+
/**
|
|
64
|
+
* Create a JSON-RPC request
|
|
65
|
+
*/
|
|
66
|
+
declare function createRequest<TParams>(id: RequestId, method: string, params?: TParams): JsonRpcRequest<TParams>;
|
|
67
|
+
/**
|
|
68
|
+
* Create a JSON-RPC notification
|
|
69
|
+
*/
|
|
70
|
+
declare function createNotification<TParams>(method: string, params?: TParams): JsonRpcNotification<TParams>;
|
|
71
|
+
/**
|
|
72
|
+
* Create a JSON-RPC success response
|
|
73
|
+
*/
|
|
74
|
+
declare function createSuccessResponse<TResult>(id: RequestId, result: TResult): JsonRpcSuccessResponse<TResult>;
|
|
75
|
+
/**
|
|
76
|
+
* Create a JSON-RPC error response
|
|
77
|
+
*/
|
|
78
|
+
declare function createErrorResponse(id: RequestId, error: MAPError): JsonRpcErrorResponse;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Error classes for MAP protocol
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Error thrown when a MAP request fails.
|
|
86
|
+
*
|
|
87
|
+
* Extends Error with JSON-RPC error properties and provides
|
|
88
|
+
* factory methods for common error types.
|
|
89
|
+
*/
|
|
90
|
+
declare class MAPRequestError extends Error {
|
|
91
|
+
readonly code: number;
|
|
92
|
+
readonly data?: MAPErrorData;
|
|
93
|
+
constructor(code: number, message: string, data?: MAPErrorData);
|
|
94
|
+
/**
|
|
95
|
+
* Convert to MAP error object
|
|
96
|
+
*/
|
|
97
|
+
toError(): MAPError;
|
|
98
|
+
/**
|
|
99
|
+
* Convert to JSON-RPC error response
|
|
100
|
+
*/
|
|
101
|
+
toResponse(id: RequestId): JsonRpcErrorResponse;
|
|
102
|
+
static parseError(details?: string): MAPRequestError;
|
|
103
|
+
static invalidRequest(details?: string): MAPRequestError;
|
|
104
|
+
static methodNotFound(method: string): MAPRequestError;
|
|
105
|
+
static invalidParams(details?: unknown): MAPRequestError;
|
|
106
|
+
static internalError(details?: string): MAPRequestError;
|
|
107
|
+
static authRequired(): MAPRequestError;
|
|
108
|
+
static authFailed(details?: string): MAPRequestError;
|
|
109
|
+
static tokenExpired(): MAPRequestError;
|
|
110
|
+
static permissionDenied(required?: string): MAPRequestError;
|
|
111
|
+
static addressNotFound(address: string): MAPRequestError;
|
|
112
|
+
static agentNotFound(agentId: string): MAPRequestError;
|
|
113
|
+
static scopeNotFound(scopeId: string): MAPRequestError;
|
|
114
|
+
static deliveryFailed(details?: string): MAPRequestError;
|
|
115
|
+
static addressAmbiguous(address: string): MAPRequestError;
|
|
116
|
+
static agentExists(agentId: string): MAPRequestError;
|
|
117
|
+
static stateInvalid(currentState: string, requestedAction: string): MAPRequestError;
|
|
118
|
+
static agentNotResponding(agentId: string): MAPRequestError;
|
|
119
|
+
static agentTerminated(agentId: string): MAPRequestError;
|
|
120
|
+
static spawnFailed(details?: string): MAPRequestError;
|
|
121
|
+
static resourceExhausted(resource?: string): MAPRequestError;
|
|
122
|
+
static rateLimited(retryAfterMs?: number): MAPRequestError;
|
|
123
|
+
static quotaExceeded(quota?: string): MAPRequestError;
|
|
124
|
+
static federationUnavailable(systemId?: string): MAPRequestError;
|
|
125
|
+
static federationSystemNotFound(systemId: string): MAPRequestError;
|
|
126
|
+
static federationAuthFailed(systemId: string): MAPRequestError;
|
|
127
|
+
static federationRouteRejected(systemId: string, reason?: string): MAPRequestError;
|
|
128
|
+
/**
|
|
129
|
+
* Create from a MAP error object
|
|
130
|
+
*/
|
|
131
|
+
static fromError(error: MAPError): MAPRequestError;
|
|
132
|
+
/**
|
|
133
|
+
* Check if this error is retryable
|
|
134
|
+
*/
|
|
135
|
+
get retryable(): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Get retry delay in milliseconds, if specified
|
|
138
|
+
*/
|
|
139
|
+
get retryAfterMs(): number | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* Get error category
|
|
142
|
+
*/
|
|
143
|
+
get category(): ErrorCategory | undefined;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Error thrown when a connection is closed unexpectedly
|
|
147
|
+
*/
|
|
148
|
+
declare class MAPConnectionError extends Error {
|
|
149
|
+
constructor(message: string);
|
|
150
|
+
static closed(): MAPConnectionError;
|
|
151
|
+
static timeout(): MAPConnectionError;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Error thrown when an operation times out
|
|
155
|
+
*/
|
|
156
|
+
declare class MAPTimeoutError extends Error {
|
|
157
|
+
readonly timeoutMs: number;
|
|
158
|
+
constructor(operation: string, timeoutMs: number);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Federation Outage Buffer
|
|
163
|
+
*
|
|
164
|
+
* Buffers outbound messages during federation outages for later delivery
|
|
165
|
+
* when the peer reconnects.
|
|
166
|
+
*/
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Buffer statistics for a peer.
|
|
170
|
+
*/
|
|
171
|
+
interface PeerBufferStats {
|
|
172
|
+
/** Number of messages currently buffered */
|
|
173
|
+
count: number;
|
|
174
|
+
/** Age of oldest message in milliseconds */
|
|
175
|
+
oldestAge: number;
|
|
176
|
+
/** Total messages ever enqueued */
|
|
177
|
+
totalEnqueued: number;
|
|
178
|
+
/** Total messages dropped due to overflow/expiry */
|
|
179
|
+
totalDropped: number;
|
|
180
|
+
/** Current buffer size in bytes */
|
|
181
|
+
totalBytes: number;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Buffer for storing outbound messages during federation outages.
|
|
185
|
+
*
|
|
186
|
+
* Messages are stored per-peer and drained on reconnection.
|
|
187
|
+
* Supports configurable size limits, retention, and overflow strategies.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```typescript
|
|
191
|
+
* const buffer = new FederationOutageBuffer({
|
|
192
|
+
* maxMessages: 500,
|
|
193
|
+
* retentionMs: 30000,
|
|
194
|
+
* overflowStrategy: 'drop-oldest',
|
|
195
|
+
* });
|
|
196
|
+
*
|
|
197
|
+
* // Buffer messages during outage
|
|
198
|
+
* buffer.enqueue('peer-1', envelope);
|
|
199
|
+
*
|
|
200
|
+
* // On reconnect, drain and send
|
|
201
|
+
* const messages = buffer.drain('peer-1');
|
|
202
|
+
* for (const msg of messages) {
|
|
203
|
+
* await send(msg);
|
|
204
|
+
* }
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
declare class FederationOutageBuffer {
|
|
208
|
+
#private;
|
|
209
|
+
constructor(config?: FederationBufferConfig);
|
|
210
|
+
/**
|
|
211
|
+
* Whether buffering is enabled.
|
|
212
|
+
*/
|
|
213
|
+
get enabled(): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Get the configuration.
|
|
216
|
+
*/
|
|
217
|
+
get config(): Readonly<Required<FederationBufferConfig>>;
|
|
218
|
+
/**
|
|
219
|
+
* Enqueue a message for a peer.
|
|
220
|
+
*
|
|
221
|
+
* @param peerId - Target peer system ID
|
|
222
|
+
* @param envelope - Message envelope to buffer
|
|
223
|
+
* @returns true if message was buffered, false if rejected
|
|
224
|
+
*/
|
|
225
|
+
enqueue(peerId: string, envelope: FederationEnvelope<Message>): boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Drain all buffered messages for a peer.
|
|
228
|
+
*
|
|
229
|
+
* Returns messages in FIFO order and clears the buffer.
|
|
230
|
+
*
|
|
231
|
+
* @param peerId - Target peer system ID
|
|
232
|
+
* @returns Array of buffered envelopes
|
|
233
|
+
*/
|
|
234
|
+
drain(peerId: string): FederationEnvelope<Message>[];
|
|
235
|
+
/**
|
|
236
|
+
* Peek at buffered messages without removing them.
|
|
237
|
+
*
|
|
238
|
+
* @param peerId - Target peer system ID
|
|
239
|
+
* @returns Array of buffered envelopes (still in buffer)
|
|
240
|
+
*/
|
|
241
|
+
peek(peerId: string): FederationEnvelope<Message>[];
|
|
242
|
+
/**
|
|
243
|
+
* Get statistics for all peer buffers.
|
|
244
|
+
*
|
|
245
|
+
* @returns Map of peer ID to buffer stats
|
|
246
|
+
*/
|
|
247
|
+
stats(): Map<string, PeerBufferStats>;
|
|
248
|
+
/**
|
|
249
|
+
* Get count for a specific peer.
|
|
250
|
+
*
|
|
251
|
+
* @param peerId - Target peer system ID
|
|
252
|
+
* @returns Number of buffered messages
|
|
253
|
+
*/
|
|
254
|
+
count(peerId: string): number;
|
|
255
|
+
/**
|
|
256
|
+
* Check if buffer has messages for a peer.
|
|
257
|
+
*
|
|
258
|
+
* @param peerId - Target peer system ID
|
|
259
|
+
* @returns true if there are buffered messages
|
|
260
|
+
*/
|
|
261
|
+
has(peerId: string): boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Clear buffer for a specific peer.
|
|
264
|
+
*
|
|
265
|
+
* @param peerId - Target peer system ID
|
|
266
|
+
*/
|
|
267
|
+
clear(peerId: string): void;
|
|
268
|
+
/**
|
|
269
|
+
* Clear all buffers.
|
|
270
|
+
*/
|
|
271
|
+
clearAll(): void;
|
|
272
|
+
/**
|
|
273
|
+
* Get list of peers with buffered messages.
|
|
274
|
+
*
|
|
275
|
+
* @returns Array of peer IDs
|
|
276
|
+
*/
|
|
277
|
+
peers(): string[];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Gateway connection for MAP protocol federation
|
|
282
|
+
*
|
|
283
|
+
* Used by gateways to connect two MAP systems together,
|
|
284
|
+
* routing messages between them.
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Options for automatic gateway reconnection
|
|
289
|
+
*/
|
|
290
|
+
interface GatewayReconnectionOptions {
|
|
291
|
+
/** Enable automatic reconnection (default: false) */
|
|
292
|
+
enabled: boolean;
|
|
293
|
+
/** Maximum number of retry attempts (default: 10) */
|
|
294
|
+
maxRetries?: number;
|
|
295
|
+
/** Initial delay in milliseconds (default: 1000) */
|
|
296
|
+
baseDelayMs?: number;
|
|
297
|
+
/** Maximum delay in milliseconds (default: 30000) */
|
|
298
|
+
maxDelayMs?: number;
|
|
299
|
+
/** Add jitter to delays (default: true) */
|
|
300
|
+
jitter?: boolean;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Options for event replay on gateway reconnection
|
|
304
|
+
*/
|
|
305
|
+
interface GatewayReplayOptions {
|
|
306
|
+
/** Enable replay on reconnection (default: false) */
|
|
307
|
+
enabled: boolean;
|
|
308
|
+
/** Event types to replay (default: all) */
|
|
309
|
+
eventTypes?: EventType[];
|
|
310
|
+
/** Maximum events to replay per peer (default: 1000) */
|
|
311
|
+
maxEvents?: number;
|
|
312
|
+
/** Maximum age of events to replay in ms (default: 1 hour) */
|
|
313
|
+
maxAgeMs?: number;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Reconnection event types for gateway
|
|
317
|
+
*/
|
|
318
|
+
type GatewayReconnectionEventType = 'disconnected' | 'reconnecting' | 'reconnected' | 'reconnectFailed' | 'bufferOverflow' | 'bufferDrained' | 'replayStarted' | 'replayCompleted';
|
|
319
|
+
/**
|
|
320
|
+
* Handler for gateway reconnection events
|
|
321
|
+
*/
|
|
322
|
+
type GatewayReconnectionEventHandler = (event: {
|
|
323
|
+
type: GatewayReconnectionEventType;
|
|
324
|
+
attempt?: number;
|
|
325
|
+
delay?: number;
|
|
326
|
+
error?: Error;
|
|
327
|
+
peerId?: string;
|
|
328
|
+
messagesBuffered?: number;
|
|
329
|
+
messagesDrained?: number;
|
|
330
|
+
eventsReplayed?: number;
|
|
331
|
+
}) => void;
|
|
332
|
+
/**
|
|
333
|
+
* Options for gateway connection
|
|
334
|
+
*/
|
|
335
|
+
interface GatewayConnectionOptions extends BaseConnectionOptions {
|
|
336
|
+
/** Gateway name */
|
|
337
|
+
name?: string;
|
|
338
|
+
/** Gateway capabilities */
|
|
339
|
+
capabilities?: ParticipantCapabilities;
|
|
340
|
+
/** Federation routing configuration */
|
|
341
|
+
routing?: FederationRoutingConfig;
|
|
342
|
+
/** Factory to create new stream for reconnection */
|
|
343
|
+
createStream?: () => Promise<Stream>;
|
|
344
|
+
/** Reconnection options */
|
|
345
|
+
reconnection?: GatewayReconnectionOptions;
|
|
346
|
+
/** Outage buffer configuration */
|
|
347
|
+
buffer?: FederationBufferConfig;
|
|
348
|
+
/** Replay options for reconnection */
|
|
349
|
+
replay?: GatewayReplayOptions;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Gateway connection for MAP federation.
|
|
353
|
+
*
|
|
354
|
+
* Provides methods for:
|
|
355
|
+
* - Connecting to peer MAP systems
|
|
356
|
+
* - Routing messages between systems
|
|
357
|
+
* - Automatic reconnection with message buffering
|
|
358
|
+
*/
|
|
359
|
+
declare class GatewayConnection {
|
|
360
|
+
#private;
|
|
361
|
+
constructor(stream: Stream, options?: GatewayConnectionOptions);
|
|
362
|
+
/**
|
|
363
|
+
* Connect to the local MAP system
|
|
364
|
+
*/
|
|
365
|
+
connect(options?: {
|
|
366
|
+
auth?: {
|
|
367
|
+
method: 'bearer' | 'api-key' | 'mtls' | 'none';
|
|
368
|
+
token?: string;
|
|
369
|
+
};
|
|
370
|
+
}): Promise<ConnectResponseResult>;
|
|
371
|
+
/**
|
|
372
|
+
* Disconnect from the local MAP system
|
|
373
|
+
*/
|
|
374
|
+
disconnect(reason?: string): Promise<void>;
|
|
375
|
+
/**
|
|
376
|
+
* Whether the gateway is connected to the local system
|
|
377
|
+
*/
|
|
378
|
+
get isConnected(): boolean;
|
|
379
|
+
/**
|
|
380
|
+
* Current session ID
|
|
381
|
+
*/
|
|
382
|
+
get sessionId(): SessionId | null;
|
|
383
|
+
/**
|
|
384
|
+
* Server capabilities
|
|
385
|
+
*/
|
|
386
|
+
get serverCapabilities(): ParticipantCapabilities | null;
|
|
387
|
+
/**
|
|
388
|
+
* List of connected remote systems
|
|
389
|
+
*/
|
|
390
|
+
get connectedSystems(): Map<string, {
|
|
391
|
+
name?: string;
|
|
392
|
+
version?: string;
|
|
393
|
+
}>;
|
|
394
|
+
/**
|
|
395
|
+
* AbortSignal that triggers when the connection closes
|
|
396
|
+
*/
|
|
397
|
+
get signal(): AbortSignal;
|
|
398
|
+
/**
|
|
399
|
+
* Promise that resolves when the connection closes
|
|
400
|
+
*/
|
|
401
|
+
get closed(): Promise<void>;
|
|
402
|
+
/**
|
|
403
|
+
* Connect to a remote MAP system
|
|
404
|
+
*/
|
|
405
|
+
connectToSystem(systemId: string, endpoint: string, auth?: {
|
|
406
|
+
method: 'bearer' | 'api-key' | 'mtls';
|
|
407
|
+
credentials?: string;
|
|
408
|
+
}): Promise<FederationConnectResponseResult>;
|
|
409
|
+
/**
|
|
410
|
+
* Route a message to a remote system.
|
|
411
|
+
*
|
|
412
|
+
* If routing config is provided, wraps the message in a federation envelope
|
|
413
|
+
* with proper metadata for multi-hop routing. Otherwise, sends raw message
|
|
414
|
+
* for backwards compatibility.
|
|
415
|
+
*
|
|
416
|
+
* During reconnection, messages are buffered if buffer is configured.
|
|
417
|
+
*/
|
|
418
|
+
routeToSystem(systemId: string, message: Message): Promise<FederationRouteResponseResult>;
|
|
419
|
+
/**
|
|
420
|
+
* Check if a remote system is connected
|
|
421
|
+
*/
|
|
422
|
+
isSystemConnected(systemId: string): boolean;
|
|
423
|
+
/**
|
|
424
|
+
* Current connection state
|
|
425
|
+
*/
|
|
426
|
+
get state(): ConnectionState;
|
|
427
|
+
/**
|
|
428
|
+
* Whether the connection is currently reconnecting
|
|
429
|
+
*/
|
|
430
|
+
get isReconnecting(): boolean;
|
|
431
|
+
/**
|
|
432
|
+
* Get the outage buffer (for advanced use)
|
|
433
|
+
*/
|
|
434
|
+
get outageBuffer(): FederationOutageBuffer | null;
|
|
435
|
+
/**
|
|
436
|
+
* Get last sync timestamp for a peer
|
|
437
|
+
*/
|
|
438
|
+
getLastSyncTimestamp(peerId: string): number | undefined;
|
|
439
|
+
/**
|
|
440
|
+
* Register a handler for reconnection events.
|
|
441
|
+
*
|
|
442
|
+
* @param handler - Function called when reconnection events occur
|
|
443
|
+
* @returns Unsubscribe function to remove the handler
|
|
444
|
+
*/
|
|
445
|
+
onReconnection(handler: GatewayReconnectionEventHandler): () => void;
|
|
446
|
+
/**
|
|
447
|
+
* Register a handler for connection state changes.
|
|
448
|
+
*
|
|
449
|
+
* @param handler - Function called when state changes
|
|
450
|
+
* @returns Unsubscribe function to remove the handler
|
|
451
|
+
*/
|
|
452
|
+
onStateChange(handler: (newState: ConnectionState, oldState: ConnectionState) => void): () => void;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* MAP Router Interface
|
|
457
|
+
*
|
|
458
|
+
* Defines the interface for implementing a MAP system router/server.
|
|
459
|
+
* The actual router implementation is not included in the SDK.
|
|
460
|
+
*/
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Information about a connected participant
|
|
464
|
+
*/
|
|
465
|
+
interface ConnectedParticipant {
|
|
466
|
+
id: ParticipantId;
|
|
467
|
+
type: ParticipantType;
|
|
468
|
+
name?: string;
|
|
469
|
+
capabilities: ParticipantCapabilities;
|
|
470
|
+
sessionId: SessionId;
|
|
471
|
+
connectedAt: number;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Agent exposure configuration.
|
|
475
|
+
* Controls which agents are visible to external participants.
|
|
476
|
+
*/
|
|
477
|
+
interface AgentExposure {
|
|
478
|
+
/** Whether agents are public by default (default: true) */
|
|
479
|
+
publicByDefault?: boolean;
|
|
480
|
+
/** Glob patterns for agents that are always public */
|
|
481
|
+
publicAgents?: string[];
|
|
482
|
+
/** Glob patterns for agents that are always hidden (takes precedence over publicAgents) */
|
|
483
|
+
hiddenAgents?: string[];
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Event exposure configuration.
|
|
487
|
+
* Controls which event types are visible to external participants.
|
|
488
|
+
*/
|
|
489
|
+
interface EventExposure {
|
|
490
|
+
/** Event types that are exposed (whitelist - if provided, only these types are visible) */
|
|
491
|
+
exposedTypes?: EventType[];
|
|
492
|
+
/** Event types that are always hidden (blacklist - takes precedence) */
|
|
493
|
+
hiddenTypes?: EventType[];
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Scope exposure configuration.
|
|
497
|
+
* Controls which scopes are visible to external participants.
|
|
498
|
+
*/
|
|
499
|
+
interface ScopeExposure {
|
|
500
|
+
/** Whether scopes are public by default (default: true) */
|
|
501
|
+
publicByDefault?: boolean;
|
|
502
|
+
/** Glob patterns for scopes that are always public */
|
|
503
|
+
publicScopes?: string[];
|
|
504
|
+
/** Glob patterns for scopes that are always hidden (takes precedence over publicScopes) */
|
|
505
|
+
hiddenScopes?: string[];
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* System-level exposure configuration.
|
|
509
|
+
* Controls what entities are visible to participants at the system level (Layer 1).
|
|
510
|
+
*/
|
|
511
|
+
interface SystemExposure {
|
|
512
|
+
/** Agent visibility configuration */
|
|
513
|
+
agents?: AgentExposure;
|
|
514
|
+
/** Event visibility configuration */
|
|
515
|
+
events?: EventExposure;
|
|
516
|
+
/** Scope visibility configuration */
|
|
517
|
+
scopes?: ScopeExposure;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Resource limits for the router.
|
|
521
|
+
* Enforces capacity constraints to prevent resource exhaustion.
|
|
522
|
+
*/
|
|
523
|
+
interface RouterLimits {
|
|
524
|
+
/** Maximum total concurrent connections */
|
|
525
|
+
maxConnections?: number;
|
|
526
|
+
/** Maximum connections per unique client identity */
|
|
527
|
+
maxConnectionsPerClient?: number;
|
|
528
|
+
/** Maximum subscriptions per connection */
|
|
529
|
+
maxSubscriptionsPerConnection?: number;
|
|
530
|
+
/** Maximum agents a single client can register */
|
|
531
|
+
maxAgentsPerClient?: number;
|
|
532
|
+
/** Maximum scopes a single agent can join */
|
|
533
|
+
maxScopesPerAgent?: number;
|
|
534
|
+
/** Maximum events to retain for replay */
|
|
535
|
+
maxEventHistory?: number;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Router configuration
|
|
539
|
+
*/
|
|
540
|
+
interface MAPRouterConfig {
|
|
541
|
+
/** System name */
|
|
542
|
+
name?: string;
|
|
543
|
+
/** System version */
|
|
544
|
+
version?: string;
|
|
545
|
+
/** Default capabilities granted to clients */
|
|
546
|
+
defaultClientCapabilities?: ParticipantCapabilities;
|
|
547
|
+
/** Default capabilities granted to agents */
|
|
548
|
+
defaultAgentCapabilities?: ParticipantCapabilities;
|
|
549
|
+
/**
|
|
550
|
+
* System-level exposure configuration.
|
|
551
|
+
* Controls what entities are visible at Layer 1 of the permission model.
|
|
552
|
+
*/
|
|
553
|
+
exposure?: SystemExposure;
|
|
554
|
+
/**
|
|
555
|
+
* Resource limits for the router.
|
|
556
|
+
*/
|
|
557
|
+
limits?: RouterLimits;
|
|
558
|
+
/**
|
|
559
|
+
* Capabilities granted to anonymous/unauthenticated participants.
|
|
560
|
+
* If not set, anonymous connections may be rejected or granted minimal permissions.
|
|
561
|
+
*/
|
|
562
|
+
anonymousCapabilities?: ParticipantCapabilities;
|
|
563
|
+
/** Authentication handler */
|
|
564
|
+
authenticate?: (participantType: ParticipantType, auth: {
|
|
565
|
+
method: string;
|
|
566
|
+
token?: string;
|
|
567
|
+
}) => Promise<{
|
|
568
|
+
allowed: boolean;
|
|
569
|
+
capabilities?: ParticipantCapabilities;
|
|
570
|
+
}>;
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Interface for MAP router implementations.
|
|
574
|
+
*
|
|
575
|
+
* A router is the central component that:
|
|
576
|
+
* - Accepts connections from participants (clients, agents, gateways)
|
|
577
|
+
* - Routes messages between participants
|
|
578
|
+
* - Manages agent lifecycle
|
|
579
|
+
* - Handles subscriptions and event delivery
|
|
580
|
+
* - Enforces permissions and visibility
|
|
581
|
+
*/
|
|
582
|
+
interface MAPRouter {
|
|
583
|
+
/**
|
|
584
|
+
* Router configuration
|
|
585
|
+
*/
|
|
586
|
+
readonly config: MAPRouterConfig;
|
|
587
|
+
/**
|
|
588
|
+
* Accept a new connection
|
|
589
|
+
*/
|
|
590
|
+
acceptConnection(stream: Stream): Promise<ConnectedParticipant>;
|
|
591
|
+
/**
|
|
592
|
+
* Get all connected participants
|
|
593
|
+
*/
|
|
594
|
+
getParticipants(): ConnectedParticipant[];
|
|
595
|
+
/**
|
|
596
|
+
* Get a specific participant
|
|
597
|
+
*/
|
|
598
|
+
getParticipant(id: ParticipantId): ConnectedParticipant | undefined;
|
|
599
|
+
/**
|
|
600
|
+
* Disconnect a participant
|
|
601
|
+
*/
|
|
602
|
+
disconnectParticipant(id: ParticipantId, reason?: string): Promise<void>;
|
|
603
|
+
/**
|
|
604
|
+
* Register a new agent
|
|
605
|
+
*/
|
|
606
|
+
registerAgent(options: {
|
|
607
|
+
agentId?: AgentId;
|
|
608
|
+
name?: string;
|
|
609
|
+
role?: string;
|
|
610
|
+
parent?: AgentId;
|
|
611
|
+
scopes?: ScopeId[];
|
|
612
|
+
visibility?: string;
|
|
613
|
+
capabilities?: ParticipantCapabilities;
|
|
614
|
+
metadata?: Record<string, unknown>;
|
|
615
|
+
}): Promise<Agent>;
|
|
616
|
+
/**
|
|
617
|
+
* Get an agent by ID
|
|
618
|
+
*/
|
|
619
|
+
getAgent(agentId: AgentId): Agent | undefined;
|
|
620
|
+
/**
|
|
621
|
+
* List agents with filters
|
|
622
|
+
*/
|
|
623
|
+
listAgents(filter?: {
|
|
624
|
+
states?: string[];
|
|
625
|
+
roles?: string[];
|
|
626
|
+
scopes?: ScopeId[];
|
|
627
|
+
parent?: AgentId;
|
|
628
|
+
}): Agent[];
|
|
629
|
+
/**
|
|
630
|
+
* Update an agent
|
|
631
|
+
*/
|
|
632
|
+
updateAgent(agentId: AgentId, updates: {
|
|
633
|
+
state?: string;
|
|
634
|
+
metadata?: Record<string, unknown>;
|
|
635
|
+
}): Promise<Agent>;
|
|
636
|
+
/**
|
|
637
|
+
* Unregister an agent
|
|
638
|
+
*/
|
|
639
|
+
unregisterAgent(agentId: AgentId): Promise<void>;
|
|
640
|
+
/**
|
|
641
|
+
* Create a scope
|
|
642
|
+
*/
|
|
643
|
+
createScope(options: {
|
|
644
|
+
scopeId?: ScopeId;
|
|
645
|
+
name?: string;
|
|
646
|
+
parent?: ScopeId;
|
|
647
|
+
joinPolicy?: string;
|
|
648
|
+
visibility?: string;
|
|
649
|
+
messageVisibility?: string;
|
|
650
|
+
sendPolicy?: string;
|
|
651
|
+
}): Promise<Scope>;
|
|
652
|
+
/**
|
|
653
|
+
* Get a scope by ID
|
|
654
|
+
*/
|
|
655
|
+
getScope(scopeId: ScopeId): Scope | undefined;
|
|
656
|
+
/**
|
|
657
|
+
* List scopes
|
|
658
|
+
*/
|
|
659
|
+
listScopes(filter?: {
|
|
660
|
+
parent?: ScopeId;
|
|
661
|
+
}): Scope[];
|
|
662
|
+
/**
|
|
663
|
+
* Delete a scope
|
|
664
|
+
*/
|
|
665
|
+
deleteScope(scopeId: ScopeId): Promise<void>;
|
|
666
|
+
/**
|
|
667
|
+
* Add an agent to a scope
|
|
668
|
+
*/
|
|
669
|
+
joinScope(scopeId: ScopeId, agentId: AgentId): Promise<void>;
|
|
670
|
+
/**
|
|
671
|
+
* Remove an agent from a scope
|
|
672
|
+
*/
|
|
673
|
+
leaveScope(scopeId: ScopeId, agentId: AgentId): Promise<void>;
|
|
674
|
+
/**
|
|
675
|
+
* Get scope members
|
|
676
|
+
*/
|
|
677
|
+
getScopeMembers(scopeId: ScopeId): AgentId[];
|
|
678
|
+
/**
|
|
679
|
+
* Route a message to its destination(s)
|
|
680
|
+
*/
|
|
681
|
+
routeMessage(from: ParticipantId, to: Address, message: Message): Promise<{
|
|
682
|
+
delivered: ParticipantId[];
|
|
683
|
+
}>;
|
|
684
|
+
/**
|
|
685
|
+
* Create a subscription for a participant
|
|
686
|
+
*/
|
|
687
|
+
createSubscription(participantId: ParticipantId, filter?: SubscriptionFilter): Promise<string>;
|
|
688
|
+
/**
|
|
689
|
+
* Remove a subscription
|
|
690
|
+
*/
|
|
691
|
+
removeSubscription(subscriptionId: string): Promise<void>;
|
|
692
|
+
/**
|
|
693
|
+
* Emit an event to subscribers
|
|
694
|
+
*/
|
|
695
|
+
emitEvent(event: Event): void;
|
|
696
|
+
/**
|
|
697
|
+
* Start the router
|
|
698
|
+
*/
|
|
699
|
+
start(): Promise<void>;
|
|
700
|
+
/**
|
|
701
|
+
* Stop the router
|
|
702
|
+
*/
|
|
703
|
+
stop(): Promise<void>;
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Factory type for creating MAP routers
|
|
707
|
+
*/
|
|
708
|
+
type MAPRouterFactory = (config?: MAPRouterConfig) => MAPRouter;
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Zod validators for MAP protocol types
|
|
712
|
+
*
|
|
713
|
+
* These validators provide runtime validation for protocol messages.
|
|
714
|
+
* They are generated based on the JSON schema but hand-tuned for proper Zod compatibility.
|
|
715
|
+
*/
|
|
716
|
+
|
|
717
|
+
declare const JsonRpcVersionSchema: z.ZodLiteral<"2.0">;
|
|
718
|
+
declare const RequestIdSchema: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
719
|
+
declare const ProtocolVersionSchema: z.ZodLiteral<1>;
|
|
720
|
+
declare const TimestampSchema: z.ZodNumber;
|
|
721
|
+
declare const MetaSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
722
|
+
declare const ParticipantIdSchema: z.ZodString;
|
|
723
|
+
declare const AgentIdSchema: z.ZodString;
|
|
724
|
+
declare const ScopeIdSchema: z.ZodString;
|
|
725
|
+
declare const SessionIdSchema: z.ZodString;
|
|
726
|
+
declare const MessageIdSchema: z.ZodString;
|
|
727
|
+
declare const SubscriptionIdSchema: z.ZodString;
|
|
728
|
+
declare const CorrelationIdSchema: z.ZodString;
|
|
729
|
+
declare const ParticipantTypeSchema: z.ZodEnum<["agent", "client", "system", "gateway"]>;
|
|
730
|
+
declare const TransportTypeSchema: z.ZodEnum<["websocket", "stdio", "inprocess", "http-sse"]>;
|
|
731
|
+
declare const ErrorCategorySchema: z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>;
|
|
732
|
+
declare const AgentVisibilitySchema: z.ZodEnum<["public", "parent-only", "scope", "system"]>;
|
|
733
|
+
declare const AgentStateSchema: z.ZodUnion<[z.ZodEnum<["registered", "idle", "busy", "waiting", "stopping", "stopped", "error"]>, z.ZodString]>;
|
|
734
|
+
declare const MessagePrioritySchema: z.ZodEnum<["low", "normal", "high", "urgent"]>;
|
|
735
|
+
declare const DeliverySemanticsSchema: z.ZodEnum<["at-most-once", "at-least-once", "exactly-once"]>;
|
|
736
|
+
declare const MessageRelationshipSchema: z.ZodEnum<["peer", "parent-to-child", "child-to-parent", "supervisor-to-supervised", "broadcast"]>;
|
|
737
|
+
declare const EventTypeSchema: z.ZodEnum<["agent.registered", "agent.unregistered", "agent.state-changed", "agent.spawned", "scope.created", "scope.deleted", "scope.joined", "scope.left", "message.sent", "message.delivered", "session.started", "session.ended", "system.error", "system.shutdown"]>;
|
|
738
|
+
declare const ScopeJoinPolicySchema: z.ZodEnum<["open", "approval", "invite"]>;
|
|
739
|
+
declare const ScopeVisibilitySchema: z.ZodEnum<["public", "private", "unlisted"]>;
|
|
740
|
+
declare const MessageVisibilitySchema: z.ZodEnum<["members", "public"]>;
|
|
741
|
+
declare const ScopeSendPolicySchema: z.ZodEnum<["anyone", "members"]>;
|
|
742
|
+
declare const ParticipantCapabilitiesSchema: z.ZodObject<{
|
|
743
|
+
observation: z.ZodOptional<z.ZodObject<{
|
|
744
|
+
canObserve: z.ZodOptional<z.ZodBoolean>;
|
|
745
|
+
canQuery: z.ZodOptional<z.ZodBoolean>;
|
|
746
|
+
}, "strict", z.ZodTypeAny, {
|
|
747
|
+
canObserve?: boolean | undefined;
|
|
748
|
+
canQuery?: boolean | undefined;
|
|
749
|
+
}, {
|
|
750
|
+
canObserve?: boolean | undefined;
|
|
751
|
+
canQuery?: boolean | undefined;
|
|
752
|
+
}>>;
|
|
753
|
+
messaging: z.ZodOptional<z.ZodObject<{
|
|
754
|
+
canSend: z.ZodOptional<z.ZodBoolean>;
|
|
755
|
+
canReceive: z.ZodOptional<z.ZodBoolean>;
|
|
756
|
+
canBroadcast: z.ZodOptional<z.ZodBoolean>;
|
|
757
|
+
}, "strict", z.ZodTypeAny, {
|
|
758
|
+
canSend?: boolean | undefined;
|
|
759
|
+
canReceive?: boolean | undefined;
|
|
760
|
+
canBroadcast?: boolean | undefined;
|
|
761
|
+
}, {
|
|
762
|
+
canSend?: boolean | undefined;
|
|
763
|
+
canReceive?: boolean | undefined;
|
|
764
|
+
canBroadcast?: boolean | undefined;
|
|
765
|
+
}>>;
|
|
766
|
+
lifecycle: z.ZodOptional<z.ZodObject<{
|
|
767
|
+
canSpawn: z.ZodOptional<z.ZodBoolean>;
|
|
768
|
+
canRegister: z.ZodOptional<z.ZodBoolean>;
|
|
769
|
+
canUnregister: z.ZodOptional<z.ZodBoolean>;
|
|
770
|
+
canSteer: z.ZodOptional<z.ZodBoolean>;
|
|
771
|
+
canStop: z.ZodOptional<z.ZodBoolean>;
|
|
772
|
+
}, "strict", z.ZodTypeAny, {
|
|
773
|
+
canSpawn?: boolean | undefined;
|
|
774
|
+
canRegister?: boolean | undefined;
|
|
775
|
+
canUnregister?: boolean | undefined;
|
|
776
|
+
canSteer?: boolean | undefined;
|
|
777
|
+
canStop?: boolean | undefined;
|
|
778
|
+
}, {
|
|
779
|
+
canSpawn?: boolean | undefined;
|
|
780
|
+
canRegister?: boolean | undefined;
|
|
781
|
+
canUnregister?: boolean | undefined;
|
|
782
|
+
canSteer?: boolean | undefined;
|
|
783
|
+
canStop?: boolean | undefined;
|
|
784
|
+
}>>;
|
|
785
|
+
scopes: z.ZodOptional<z.ZodObject<{
|
|
786
|
+
canCreateScopes: z.ZodOptional<z.ZodBoolean>;
|
|
787
|
+
canManageScopes: z.ZodOptional<z.ZodBoolean>;
|
|
788
|
+
}, "strict", z.ZodTypeAny, {
|
|
789
|
+
canCreateScopes?: boolean | undefined;
|
|
790
|
+
canManageScopes?: boolean | undefined;
|
|
791
|
+
}, {
|
|
792
|
+
canCreateScopes?: boolean | undefined;
|
|
793
|
+
canManageScopes?: boolean | undefined;
|
|
794
|
+
}>>;
|
|
795
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
796
|
+
}, "strict", z.ZodTypeAny, {
|
|
797
|
+
_meta?: Record<string, unknown> | undefined;
|
|
798
|
+
scopes?: {
|
|
799
|
+
canCreateScopes?: boolean | undefined;
|
|
800
|
+
canManageScopes?: boolean | undefined;
|
|
801
|
+
} | undefined;
|
|
802
|
+
observation?: {
|
|
803
|
+
canObserve?: boolean | undefined;
|
|
804
|
+
canQuery?: boolean | undefined;
|
|
805
|
+
} | undefined;
|
|
806
|
+
messaging?: {
|
|
807
|
+
canSend?: boolean | undefined;
|
|
808
|
+
canReceive?: boolean | undefined;
|
|
809
|
+
canBroadcast?: boolean | undefined;
|
|
810
|
+
} | undefined;
|
|
811
|
+
lifecycle?: {
|
|
812
|
+
canSpawn?: boolean | undefined;
|
|
813
|
+
canRegister?: boolean | undefined;
|
|
814
|
+
canUnregister?: boolean | undefined;
|
|
815
|
+
canSteer?: boolean | undefined;
|
|
816
|
+
canStop?: boolean | undefined;
|
|
817
|
+
} | undefined;
|
|
818
|
+
}, {
|
|
819
|
+
_meta?: Record<string, unknown> | undefined;
|
|
820
|
+
scopes?: {
|
|
821
|
+
canCreateScopes?: boolean | undefined;
|
|
822
|
+
canManageScopes?: boolean | undefined;
|
|
823
|
+
} | undefined;
|
|
824
|
+
observation?: {
|
|
825
|
+
canObserve?: boolean | undefined;
|
|
826
|
+
canQuery?: boolean | undefined;
|
|
827
|
+
} | undefined;
|
|
828
|
+
messaging?: {
|
|
829
|
+
canSend?: boolean | undefined;
|
|
830
|
+
canReceive?: boolean | undefined;
|
|
831
|
+
canBroadcast?: boolean | undefined;
|
|
832
|
+
} | undefined;
|
|
833
|
+
lifecycle?: {
|
|
834
|
+
canSpawn?: boolean | undefined;
|
|
835
|
+
canRegister?: boolean | undefined;
|
|
836
|
+
canUnregister?: boolean | undefined;
|
|
837
|
+
canSteer?: boolean | undefined;
|
|
838
|
+
canStop?: boolean | undefined;
|
|
839
|
+
} | undefined;
|
|
840
|
+
}>;
|
|
841
|
+
declare const DirectAddressSchema: z.ZodObject<{
|
|
842
|
+
agent: z.ZodString;
|
|
843
|
+
}, "strict", z.ZodTypeAny, {
|
|
844
|
+
agent: string;
|
|
845
|
+
}, {
|
|
846
|
+
agent: string;
|
|
847
|
+
}>;
|
|
848
|
+
declare const MultiAddressSchema: z.ZodObject<{
|
|
849
|
+
agents: z.ZodArray<z.ZodString, "many">;
|
|
850
|
+
}, "strict", z.ZodTypeAny, {
|
|
851
|
+
agents: string[];
|
|
852
|
+
}, {
|
|
853
|
+
agents: string[];
|
|
854
|
+
}>;
|
|
855
|
+
declare const ScopeAddressSchema: z.ZodObject<{
|
|
856
|
+
scope: z.ZodString;
|
|
857
|
+
}, "strict", z.ZodTypeAny, {
|
|
858
|
+
scope: string;
|
|
859
|
+
}, {
|
|
860
|
+
scope: string;
|
|
861
|
+
}>;
|
|
862
|
+
declare const RoleAddressSchema: z.ZodObject<{
|
|
863
|
+
role: z.ZodString;
|
|
864
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
865
|
+
}, "strict", z.ZodTypeAny, {
|
|
866
|
+
role: string;
|
|
867
|
+
scope?: string | undefined;
|
|
868
|
+
}, {
|
|
869
|
+
role: string;
|
|
870
|
+
scope?: string | undefined;
|
|
871
|
+
}>;
|
|
872
|
+
declare const HierarchicalAddressSchema: z.ZodObject<{
|
|
873
|
+
parent: z.ZodOptional<z.ZodLiteral<true>>;
|
|
874
|
+
children: z.ZodOptional<z.ZodLiteral<true>>;
|
|
875
|
+
siblings: z.ZodOptional<z.ZodLiteral<true>>;
|
|
876
|
+
ancestors: z.ZodOptional<z.ZodLiteral<true>>;
|
|
877
|
+
descendants: z.ZodOptional<z.ZodLiteral<true>>;
|
|
878
|
+
}, "strict", z.ZodTypeAny, {
|
|
879
|
+
parent?: true | undefined;
|
|
880
|
+
children?: true | undefined;
|
|
881
|
+
ancestors?: true | undefined;
|
|
882
|
+
descendants?: true | undefined;
|
|
883
|
+
siblings?: true | undefined;
|
|
884
|
+
}, {
|
|
885
|
+
parent?: true | undefined;
|
|
886
|
+
children?: true | undefined;
|
|
887
|
+
ancestors?: true | undefined;
|
|
888
|
+
descendants?: true | undefined;
|
|
889
|
+
siblings?: true | undefined;
|
|
890
|
+
}>;
|
|
891
|
+
declare const BroadcastAddressSchema: z.ZodObject<{
|
|
892
|
+
broadcast: z.ZodLiteral<true>;
|
|
893
|
+
}, "strict", z.ZodTypeAny, {
|
|
894
|
+
broadcast: true;
|
|
895
|
+
}, {
|
|
896
|
+
broadcast: true;
|
|
897
|
+
}>;
|
|
898
|
+
declare const SystemAddressSchema: z.ZodObject<{
|
|
899
|
+
system: z.ZodLiteral<true>;
|
|
900
|
+
}, "strict", z.ZodTypeAny, {
|
|
901
|
+
system: true;
|
|
902
|
+
}, {
|
|
903
|
+
system: true;
|
|
904
|
+
}>;
|
|
905
|
+
declare const ParticipantAddressSchema: z.ZodObject<{
|
|
906
|
+
participant: z.ZodString;
|
|
907
|
+
}, "strict", z.ZodTypeAny, {
|
|
908
|
+
participant: string;
|
|
909
|
+
}, {
|
|
910
|
+
participant: string;
|
|
911
|
+
}>;
|
|
912
|
+
declare const FederatedAddressSchema: z.ZodObject<{
|
|
913
|
+
system: z.ZodString;
|
|
914
|
+
address: z.ZodLazy<z.ZodType<unknown, z.ZodTypeDef, unknown>>;
|
|
915
|
+
}, "strict", z.ZodTypeAny, {
|
|
916
|
+
system: string;
|
|
917
|
+
address?: unknown;
|
|
918
|
+
}, {
|
|
919
|
+
system: string;
|
|
920
|
+
address?: unknown;
|
|
921
|
+
}>;
|
|
922
|
+
declare const AddressSchema: z.ZodType<unknown>;
|
|
923
|
+
declare const AgentRelationshipSchema: z.ZodObject<{
|
|
924
|
+
type: z.ZodEnum<["peer", "supervisor", "supervised", "collaborator"]>;
|
|
925
|
+
agentId: z.ZodString;
|
|
926
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
927
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
928
|
+
}, "strict", z.ZodTypeAny, {
|
|
929
|
+
agentId: string;
|
|
930
|
+
type: "peer" | "supervisor" | "supervised" | "collaborator";
|
|
931
|
+
_meta?: Record<string, unknown> | undefined;
|
|
932
|
+
metadata?: Record<string, unknown> | undefined;
|
|
933
|
+
}, {
|
|
934
|
+
agentId: string;
|
|
935
|
+
type: "peer" | "supervisor" | "supervised" | "collaborator";
|
|
936
|
+
_meta?: Record<string, unknown> | undefined;
|
|
937
|
+
metadata?: Record<string, unknown> | undefined;
|
|
938
|
+
}>;
|
|
939
|
+
declare const AgentLifecycleSchema: z.ZodObject<{
|
|
940
|
+
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
941
|
+
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
942
|
+
stoppedAt: z.ZodOptional<z.ZodNumber>;
|
|
943
|
+
lastActiveAt: z.ZodOptional<z.ZodNumber>;
|
|
944
|
+
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
945
|
+
exitReason: z.ZodOptional<z.ZodString>;
|
|
946
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
947
|
+
}, "strict", z.ZodTypeAny, {
|
|
948
|
+
_meta?: Record<string, unknown> | undefined;
|
|
949
|
+
exitCode?: number | undefined;
|
|
950
|
+
exitReason?: string | undefined;
|
|
951
|
+
createdAt?: number | undefined;
|
|
952
|
+
startedAt?: number | undefined;
|
|
953
|
+
stoppedAt?: number | undefined;
|
|
954
|
+
lastActiveAt?: number | undefined;
|
|
955
|
+
}, {
|
|
956
|
+
_meta?: Record<string, unknown> | undefined;
|
|
957
|
+
exitCode?: number | undefined;
|
|
958
|
+
exitReason?: string | undefined;
|
|
959
|
+
createdAt?: number | undefined;
|
|
960
|
+
startedAt?: number | undefined;
|
|
961
|
+
stoppedAt?: number | undefined;
|
|
962
|
+
lastActiveAt?: number | undefined;
|
|
963
|
+
}>;
|
|
964
|
+
declare const AgentSchema: z.ZodObject<{
|
|
965
|
+
id: z.ZodString;
|
|
966
|
+
name: z.ZodOptional<z.ZodString>;
|
|
967
|
+
description: z.ZodOptional<z.ZodString>;
|
|
968
|
+
parent: z.ZodOptional<z.ZodString>;
|
|
969
|
+
relationships: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
970
|
+
type: z.ZodEnum<["peer", "supervisor", "supervised", "collaborator"]>;
|
|
971
|
+
agentId: z.ZodString;
|
|
972
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
973
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
974
|
+
}, "strict", z.ZodTypeAny, {
|
|
975
|
+
agentId: string;
|
|
976
|
+
type: "peer" | "supervisor" | "supervised" | "collaborator";
|
|
977
|
+
_meta?: Record<string, unknown> | undefined;
|
|
978
|
+
metadata?: Record<string, unknown> | undefined;
|
|
979
|
+
}, {
|
|
980
|
+
agentId: string;
|
|
981
|
+
type: "peer" | "supervisor" | "supervised" | "collaborator";
|
|
982
|
+
_meta?: Record<string, unknown> | undefined;
|
|
983
|
+
metadata?: Record<string, unknown> | undefined;
|
|
984
|
+
}>, "many">>;
|
|
985
|
+
state: z.ZodUnion<[z.ZodEnum<["registered", "idle", "busy", "waiting", "stopping", "stopped", "error"]>, z.ZodString]>;
|
|
986
|
+
role: z.ZodOptional<z.ZodString>;
|
|
987
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
988
|
+
visibility: z.ZodOptional<z.ZodEnum<["public", "parent-only", "scope", "system"]>>;
|
|
989
|
+
lifecycle: z.ZodOptional<z.ZodObject<{
|
|
990
|
+
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
991
|
+
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
992
|
+
stoppedAt: z.ZodOptional<z.ZodNumber>;
|
|
993
|
+
lastActiveAt: z.ZodOptional<z.ZodNumber>;
|
|
994
|
+
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
995
|
+
exitReason: z.ZodOptional<z.ZodString>;
|
|
996
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
997
|
+
}, "strict", z.ZodTypeAny, {
|
|
998
|
+
_meta?: Record<string, unknown> | undefined;
|
|
999
|
+
exitCode?: number | undefined;
|
|
1000
|
+
exitReason?: string | undefined;
|
|
1001
|
+
createdAt?: number | undefined;
|
|
1002
|
+
startedAt?: number | undefined;
|
|
1003
|
+
stoppedAt?: number | undefined;
|
|
1004
|
+
lastActiveAt?: number | undefined;
|
|
1005
|
+
}, {
|
|
1006
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1007
|
+
exitCode?: number | undefined;
|
|
1008
|
+
exitReason?: string | undefined;
|
|
1009
|
+
createdAt?: number | undefined;
|
|
1010
|
+
startedAt?: number | undefined;
|
|
1011
|
+
stoppedAt?: number | undefined;
|
|
1012
|
+
lastActiveAt?: number | undefined;
|
|
1013
|
+
}>>;
|
|
1014
|
+
capabilities: z.ZodOptional<z.ZodObject<{
|
|
1015
|
+
observation: z.ZodOptional<z.ZodObject<{
|
|
1016
|
+
canObserve: z.ZodOptional<z.ZodBoolean>;
|
|
1017
|
+
canQuery: z.ZodOptional<z.ZodBoolean>;
|
|
1018
|
+
}, "strict", z.ZodTypeAny, {
|
|
1019
|
+
canObserve?: boolean | undefined;
|
|
1020
|
+
canQuery?: boolean | undefined;
|
|
1021
|
+
}, {
|
|
1022
|
+
canObserve?: boolean | undefined;
|
|
1023
|
+
canQuery?: boolean | undefined;
|
|
1024
|
+
}>>;
|
|
1025
|
+
messaging: z.ZodOptional<z.ZodObject<{
|
|
1026
|
+
canSend: z.ZodOptional<z.ZodBoolean>;
|
|
1027
|
+
canReceive: z.ZodOptional<z.ZodBoolean>;
|
|
1028
|
+
canBroadcast: z.ZodOptional<z.ZodBoolean>;
|
|
1029
|
+
}, "strict", z.ZodTypeAny, {
|
|
1030
|
+
canSend?: boolean | undefined;
|
|
1031
|
+
canReceive?: boolean | undefined;
|
|
1032
|
+
canBroadcast?: boolean | undefined;
|
|
1033
|
+
}, {
|
|
1034
|
+
canSend?: boolean | undefined;
|
|
1035
|
+
canReceive?: boolean | undefined;
|
|
1036
|
+
canBroadcast?: boolean | undefined;
|
|
1037
|
+
}>>;
|
|
1038
|
+
lifecycle: z.ZodOptional<z.ZodObject<{
|
|
1039
|
+
canSpawn: z.ZodOptional<z.ZodBoolean>;
|
|
1040
|
+
canRegister: z.ZodOptional<z.ZodBoolean>;
|
|
1041
|
+
canUnregister: z.ZodOptional<z.ZodBoolean>;
|
|
1042
|
+
canSteer: z.ZodOptional<z.ZodBoolean>;
|
|
1043
|
+
canStop: z.ZodOptional<z.ZodBoolean>;
|
|
1044
|
+
}, "strict", z.ZodTypeAny, {
|
|
1045
|
+
canSpawn?: boolean | undefined;
|
|
1046
|
+
canRegister?: boolean | undefined;
|
|
1047
|
+
canUnregister?: boolean | undefined;
|
|
1048
|
+
canSteer?: boolean | undefined;
|
|
1049
|
+
canStop?: boolean | undefined;
|
|
1050
|
+
}, {
|
|
1051
|
+
canSpawn?: boolean | undefined;
|
|
1052
|
+
canRegister?: boolean | undefined;
|
|
1053
|
+
canUnregister?: boolean | undefined;
|
|
1054
|
+
canSteer?: boolean | undefined;
|
|
1055
|
+
canStop?: boolean | undefined;
|
|
1056
|
+
}>>;
|
|
1057
|
+
scopes: z.ZodOptional<z.ZodObject<{
|
|
1058
|
+
canCreateScopes: z.ZodOptional<z.ZodBoolean>;
|
|
1059
|
+
canManageScopes: z.ZodOptional<z.ZodBoolean>;
|
|
1060
|
+
}, "strict", z.ZodTypeAny, {
|
|
1061
|
+
canCreateScopes?: boolean | undefined;
|
|
1062
|
+
canManageScopes?: boolean | undefined;
|
|
1063
|
+
}, {
|
|
1064
|
+
canCreateScopes?: boolean | undefined;
|
|
1065
|
+
canManageScopes?: boolean | undefined;
|
|
1066
|
+
}>>;
|
|
1067
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1068
|
+
}, "strict", z.ZodTypeAny, {
|
|
1069
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1070
|
+
scopes?: {
|
|
1071
|
+
canCreateScopes?: boolean | undefined;
|
|
1072
|
+
canManageScopes?: boolean | undefined;
|
|
1073
|
+
} | undefined;
|
|
1074
|
+
observation?: {
|
|
1075
|
+
canObserve?: boolean | undefined;
|
|
1076
|
+
canQuery?: boolean | undefined;
|
|
1077
|
+
} | undefined;
|
|
1078
|
+
messaging?: {
|
|
1079
|
+
canSend?: boolean | undefined;
|
|
1080
|
+
canReceive?: boolean | undefined;
|
|
1081
|
+
canBroadcast?: boolean | undefined;
|
|
1082
|
+
} | undefined;
|
|
1083
|
+
lifecycle?: {
|
|
1084
|
+
canSpawn?: boolean | undefined;
|
|
1085
|
+
canRegister?: boolean | undefined;
|
|
1086
|
+
canUnregister?: boolean | undefined;
|
|
1087
|
+
canSteer?: boolean | undefined;
|
|
1088
|
+
canStop?: boolean | undefined;
|
|
1089
|
+
} | undefined;
|
|
1090
|
+
}, {
|
|
1091
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1092
|
+
scopes?: {
|
|
1093
|
+
canCreateScopes?: boolean | undefined;
|
|
1094
|
+
canManageScopes?: boolean | undefined;
|
|
1095
|
+
} | undefined;
|
|
1096
|
+
observation?: {
|
|
1097
|
+
canObserve?: boolean | undefined;
|
|
1098
|
+
canQuery?: boolean | undefined;
|
|
1099
|
+
} | undefined;
|
|
1100
|
+
messaging?: {
|
|
1101
|
+
canSend?: boolean | undefined;
|
|
1102
|
+
canReceive?: boolean | undefined;
|
|
1103
|
+
canBroadcast?: boolean | undefined;
|
|
1104
|
+
} | undefined;
|
|
1105
|
+
lifecycle?: {
|
|
1106
|
+
canSpawn?: boolean | undefined;
|
|
1107
|
+
canRegister?: boolean | undefined;
|
|
1108
|
+
canUnregister?: boolean | undefined;
|
|
1109
|
+
canSteer?: boolean | undefined;
|
|
1110
|
+
canStop?: boolean | undefined;
|
|
1111
|
+
} | undefined;
|
|
1112
|
+
}>>;
|
|
1113
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1114
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1115
|
+
}, "strict", z.ZodTypeAny, {
|
|
1116
|
+
id: string;
|
|
1117
|
+
state: string;
|
|
1118
|
+
role?: string | undefined;
|
|
1119
|
+
parent?: string | undefined;
|
|
1120
|
+
name?: string | undefined;
|
|
1121
|
+
capabilities?: {
|
|
1122
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1123
|
+
scopes?: {
|
|
1124
|
+
canCreateScopes?: boolean | undefined;
|
|
1125
|
+
canManageScopes?: boolean | undefined;
|
|
1126
|
+
} | undefined;
|
|
1127
|
+
observation?: {
|
|
1128
|
+
canObserve?: boolean | undefined;
|
|
1129
|
+
canQuery?: boolean | undefined;
|
|
1130
|
+
} | undefined;
|
|
1131
|
+
messaging?: {
|
|
1132
|
+
canSend?: boolean | undefined;
|
|
1133
|
+
canReceive?: boolean | undefined;
|
|
1134
|
+
canBroadcast?: boolean | undefined;
|
|
1135
|
+
} | undefined;
|
|
1136
|
+
lifecycle?: {
|
|
1137
|
+
canSpawn?: boolean | undefined;
|
|
1138
|
+
canRegister?: boolean | undefined;
|
|
1139
|
+
canUnregister?: boolean | undefined;
|
|
1140
|
+
canSteer?: boolean | undefined;
|
|
1141
|
+
canStop?: boolean | undefined;
|
|
1142
|
+
} | undefined;
|
|
1143
|
+
} | undefined;
|
|
1144
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1145
|
+
visibility?: "system" | "public" | "parent-only" | "scope" | undefined;
|
|
1146
|
+
scopes?: string[] | undefined;
|
|
1147
|
+
metadata?: Record<string, unknown> | undefined;
|
|
1148
|
+
lifecycle?: {
|
|
1149
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1150
|
+
exitCode?: number | undefined;
|
|
1151
|
+
exitReason?: string | undefined;
|
|
1152
|
+
createdAt?: number | undefined;
|
|
1153
|
+
startedAt?: number | undefined;
|
|
1154
|
+
stoppedAt?: number | undefined;
|
|
1155
|
+
lastActiveAt?: number | undefined;
|
|
1156
|
+
} | undefined;
|
|
1157
|
+
description?: string | undefined;
|
|
1158
|
+
relationships?: {
|
|
1159
|
+
agentId: string;
|
|
1160
|
+
type: "peer" | "supervisor" | "supervised" | "collaborator";
|
|
1161
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1162
|
+
metadata?: Record<string, unknown> | undefined;
|
|
1163
|
+
}[] | undefined;
|
|
1164
|
+
}, {
|
|
1165
|
+
id: string;
|
|
1166
|
+
state: string;
|
|
1167
|
+
role?: string | undefined;
|
|
1168
|
+
parent?: string | undefined;
|
|
1169
|
+
name?: string | undefined;
|
|
1170
|
+
capabilities?: {
|
|
1171
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1172
|
+
scopes?: {
|
|
1173
|
+
canCreateScopes?: boolean | undefined;
|
|
1174
|
+
canManageScopes?: boolean | undefined;
|
|
1175
|
+
} | undefined;
|
|
1176
|
+
observation?: {
|
|
1177
|
+
canObserve?: boolean | undefined;
|
|
1178
|
+
canQuery?: boolean | undefined;
|
|
1179
|
+
} | undefined;
|
|
1180
|
+
messaging?: {
|
|
1181
|
+
canSend?: boolean | undefined;
|
|
1182
|
+
canReceive?: boolean | undefined;
|
|
1183
|
+
canBroadcast?: boolean | undefined;
|
|
1184
|
+
} | undefined;
|
|
1185
|
+
lifecycle?: {
|
|
1186
|
+
canSpawn?: boolean | undefined;
|
|
1187
|
+
canRegister?: boolean | undefined;
|
|
1188
|
+
canUnregister?: boolean | undefined;
|
|
1189
|
+
canSteer?: boolean | undefined;
|
|
1190
|
+
canStop?: boolean | undefined;
|
|
1191
|
+
} | undefined;
|
|
1192
|
+
} | undefined;
|
|
1193
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1194
|
+
visibility?: "system" | "public" | "parent-only" | "scope" | undefined;
|
|
1195
|
+
scopes?: string[] | undefined;
|
|
1196
|
+
metadata?: Record<string, unknown> | undefined;
|
|
1197
|
+
lifecycle?: {
|
|
1198
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1199
|
+
exitCode?: number | undefined;
|
|
1200
|
+
exitReason?: string | undefined;
|
|
1201
|
+
createdAt?: number | undefined;
|
|
1202
|
+
startedAt?: number | undefined;
|
|
1203
|
+
stoppedAt?: number | undefined;
|
|
1204
|
+
lastActiveAt?: number | undefined;
|
|
1205
|
+
} | undefined;
|
|
1206
|
+
description?: string | undefined;
|
|
1207
|
+
relationships?: {
|
|
1208
|
+
agentId: string;
|
|
1209
|
+
type: "peer" | "supervisor" | "supervised" | "collaborator";
|
|
1210
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1211
|
+
metadata?: Record<string, unknown> | undefined;
|
|
1212
|
+
}[] | undefined;
|
|
1213
|
+
}>;
|
|
1214
|
+
declare const ScopeSchema: z.ZodObject<{
|
|
1215
|
+
id: z.ZodString;
|
|
1216
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1217
|
+
parent: z.ZodOptional<z.ZodString>;
|
|
1218
|
+
children: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1219
|
+
joinPolicy: z.ZodOptional<z.ZodEnum<["open", "approval", "invite"]>>;
|
|
1220
|
+
visibility: z.ZodOptional<z.ZodEnum<["public", "private", "unlisted"]>>;
|
|
1221
|
+
messageVisibility: z.ZodOptional<z.ZodEnum<["members", "public"]>>;
|
|
1222
|
+
sendPolicy: z.ZodOptional<z.ZodEnum<["anyone", "members"]>>;
|
|
1223
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1224
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1225
|
+
}, "strict", z.ZodTypeAny, {
|
|
1226
|
+
id: string;
|
|
1227
|
+
parent?: string | undefined;
|
|
1228
|
+
children?: string[] | undefined;
|
|
1229
|
+
name?: string | undefined;
|
|
1230
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1231
|
+
visibility?: "public" | "private" | "unlisted" | undefined;
|
|
1232
|
+
metadata?: Record<string, unknown> | undefined;
|
|
1233
|
+
joinPolicy?: "open" | "invite" | "approval" | undefined;
|
|
1234
|
+
messageVisibility?: "public" | "members" | undefined;
|
|
1235
|
+
sendPolicy?: "members" | "anyone" | undefined;
|
|
1236
|
+
}, {
|
|
1237
|
+
id: string;
|
|
1238
|
+
parent?: string | undefined;
|
|
1239
|
+
children?: string[] | undefined;
|
|
1240
|
+
name?: string | undefined;
|
|
1241
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1242
|
+
visibility?: "public" | "private" | "unlisted" | undefined;
|
|
1243
|
+
metadata?: Record<string, unknown> | undefined;
|
|
1244
|
+
joinPolicy?: "open" | "invite" | "approval" | undefined;
|
|
1245
|
+
messageVisibility?: "public" | "members" | undefined;
|
|
1246
|
+
sendPolicy?: "members" | "anyone" | undefined;
|
|
1247
|
+
}>;
|
|
1248
|
+
declare const MessageMetaSchema: z.ZodObject<{
|
|
1249
|
+
correlationId: z.ZodOptional<z.ZodString>;
|
|
1250
|
+
causationId: z.ZodOptional<z.ZodString>;
|
|
1251
|
+
traceId: z.ZodOptional<z.ZodString>;
|
|
1252
|
+
spanId: z.ZodOptional<z.ZodString>;
|
|
1253
|
+
priority: z.ZodOptional<z.ZodEnum<["low", "normal", "high", "urgent"]>>;
|
|
1254
|
+
delivery: z.ZodOptional<z.ZodEnum<["at-most-once", "at-least-once", "exactly-once"]>>;
|
|
1255
|
+
relationship: z.ZodOptional<z.ZodEnum<["peer", "parent-to-child", "child-to-parent", "supervisor-to-supervised", "broadcast"]>>;
|
|
1256
|
+
expiresAt: z.ZodOptional<z.ZodNumber>;
|
|
1257
|
+
isResult: z.ZodOptional<z.ZodBoolean>;
|
|
1258
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1259
|
+
}, "strict", z.ZodTypeAny, {
|
|
1260
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1261
|
+
correlationId?: string | undefined;
|
|
1262
|
+
relationship?: "peer" | "parent-to-child" | "child-to-parent" | "broadcast" | "supervisor-to-supervised" | undefined;
|
|
1263
|
+
isResult?: boolean | undefined;
|
|
1264
|
+
causationId?: string | undefined;
|
|
1265
|
+
traceId?: string | undefined;
|
|
1266
|
+
spanId?: string | undefined;
|
|
1267
|
+
priority?: "urgent" | "high" | "normal" | "low" | undefined;
|
|
1268
|
+
delivery?: "at-most-once" | "at-least-once" | "exactly-once" | undefined;
|
|
1269
|
+
expiresAt?: number | undefined;
|
|
1270
|
+
}, {
|
|
1271
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1272
|
+
correlationId?: string | undefined;
|
|
1273
|
+
relationship?: "peer" | "parent-to-child" | "child-to-parent" | "broadcast" | "supervisor-to-supervised" | undefined;
|
|
1274
|
+
isResult?: boolean | undefined;
|
|
1275
|
+
causationId?: string | undefined;
|
|
1276
|
+
traceId?: string | undefined;
|
|
1277
|
+
spanId?: string | undefined;
|
|
1278
|
+
priority?: "urgent" | "high" | "normal" | "low" | undefined;
|
|
1279
|
+
delivery?: "at-most-once" | "at-least-once" | "exactly-once" | undefined;
|
|
1280
|
+
expiresAt?: number | undefined;
|
|
1281
|
+
}>;
|
|
1282
|
+
declare const MessageSchema: z.ZodObject<{
|
|
1283
|
+
id: z.ZodString;
|
|
1284
|
+
from: z.ZodString;
|
|
1285
|
+
to: z.ZodType<unknown, z.ZodTypeDef, unknown>;
|
|
1286
|
+
timestamp: z.ZodNumber;
|
|
1287
|
+
payload: z.ZodOptional<z.ZodUnknown>;
|
|
1288
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
1289
|
+
correlationId: z.ZodOptional<z.ZodString>;
|
|
1290
|
+
causationId: z.ZodOptional<z.ZodString>;
|
|
1291
|
+
traceId: z.ZodOptional<z.ZodString>;
|
|
1292
|
+
spanId: z.ZodOptional<z.ZodString>;
|
|
1293
|
+
priority: z.ZodOptional<z.ZodEnum<["low", "normal", "high", "urgent"]>>;
|
|
1294
|
+
delivery: z.ZodOptional<z.ZodEnum<["at-most-once", "at-least-once", "exactly-once"]>>;
|
|
1295
|
+
relationship: z.ZodOptional<z.ZodEnum<["peer", "parent-to-child", "child-to-parent", "supervisor-to-supervised", "broadcast"]>>;
|
|
1296
|
+
expiresAt: z.ZodOptional<z.ZodNumber>;
|
|
1297
|
+
isResult: z.ZodOptional<z.ZodBoolean>;
|
|
1298
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1299
|
+
}, "strict", z.ZodTypeAny, {
|
|
1300
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1301
|
+
correlationId?: string | undefined;
|
|
1302
|
+
relationship?: "peer" | "parent-to-child" | "child-to-parent" | "broadcast" | "supervisor-to-supervised" | undefined;
|
|
1303
|
+
isResult?: boolean | undefined;
|
|
1304
|
+
causationId?: string | undefined;
|
|
1305
|
+
traceId?: string | undefined;
|
|
1306
|
+
spanId?: string | undefined;
|
|
1307
|
+
priority?: "urgent" | "high" | "normal" | "low" | undefined;
|
|
1308
|
+
delivery?: "at-most-once" | "at-least-once" | "exactly-once" | undefined;
|
|
1309
|
+
expiresAt?: number | undefined;
|
|
1310
|
+
}, {
|
|
1311
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1312
|
+
correlationId?: string | undefined;
|
|
1313
|
+
relationship?: "peer" | "parent-to-child" | "child-to-parent" | "broadcast" | "supervisor-to-supervised" | undefined;
|
|
1314
|
+
isResult?: boolean | undefined;
|
|
1315
|
+
causationId?: string | undefined;
|
|
1316
|
+
traceId?: string | undefined;
|
|
1317
|
+
spanId?: string | undefined;
|
|
1318
|
+
priority?: "urgent" | "high" | "normal" | "low" | undefined;
|
|
1319
|
+
delivery?: "at-most-once" | "at-least-once" | "exactly-once" | undefined;
|
|
1320
|
+
expiresAt?: number | undefined;
|
|
1321
|
+
}>>;
|
|
1322
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1323
|
+
}, "strict", z.ZodTypeAny, {
|
|
1324
|
+
id: string;
|
|
1325
|
+
timestamp: number;
|
|
1326
|
+
from: string;
|
|
1327
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1328
|
+
meta?: {
|
|
1329
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1330
|
+
correlationId?: string | undefined;
|
|
1331
|
+
relationship?: "peer" | "parent-to-child" | "child-to-parent" | "broadcast" | "supervisor-to-supervised" | undefined;
|
|
1332
|
+
isResult?: boolean | undefined;
|
|
1333
|
+
causationId?: string | undefined;
|
|
1334
|
+
traceId?: string | undefined;
|
|
1335
|
+
spanId?: string | undefined;
|
|
1336
|
+
priority?: "urgent" | "high" | "normal" | "low" | undefined;
|
|
1337
|
+
delivery?: "at-most-once" | "at-least-once" | "exactly-once" | undefined;
|
|
1338
|
+
expiresAt?: number | undefined;
|
|
1339
|
+
} | undefined;
|
|
1340
|
+
payload?: unknown;
|
|
1341
|
+
to?: unknown;
|
|
1342
|
+
}, {
|
|
1343
|
+
id: string;
|
|
1344
|
+
timestamp: number;
|
|
1345
|
+
from: string;
|
|
1346
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1347
|
+
meta?: {
|
|
1348
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1349
|
+
correlationId?: string | undefined;
|
|
1350
|
+
relationship?: "peer" | "parent-to-child" | "child-to-parent" | "broadcast" | "supervisor-to-supervised" | undefined;
|
|
1351
|
+
isResult?: boolean | undefined;
|
|
1352
|
+
causationId?: string | undefined;
|
|
1353
|
+
traceId?: string | undefined;
|
|
1354
|
+
spanId?: string | undefined;
|
|
1355
|
+
priority?: "urgent" | "high" | "normal" | "low" | undefined;
|
|
1356
|
+
delivery?: "at-most-once" | "at-least-once" | "exactly-once" | undefined;
|
|
1357
|
+
expiresAt?: number | undefined;
|
|
1358
|
+
} | undefined;
|
|
1359
|
+
payload?: unknown;
|
|
1360
|
+
to?: unknown;
|
|
1361
|
+
}>;
|
|
1362
|
+
declare const EventSchema: z.ZodObject<{
|
|
1363
|
+
type: z.ZodEnum<["agent.registered", "agent.unregistered", "agent.state-changed", "agent.spawned", "scope.created", "scope.deleted", "scope.joined", "scope.left", "message.sent", "message.delivered", "session.started", "session.ended", "system.error", "system.shutdown"]>;
|
|
1364
|
+
timestamp: z.ZodNumber;
|
|
1365
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1366
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1367
|
+
}, "strict", z.ZodTypeAny, {
|
|
1368
|
+
timestamp: number;
|
|
1369
|
+
type: "agent.registered" | "agent.unregistered" | "agent.state-changed" | "agent.spawned" | "scope.created" | "scope.deleted" | "scope.joined" | "scope.left" | "message.sent" | "message.delivered" | "session.started" | "session.ended" | "system.error" | "system.shutdown";
|
|
1370
|
+
data?: Record<string, unknown> | undefined;
|
|
1371
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1372
|
+
}, {
|
|
1373
|
+
timestamp: number;
|
|
1374
|
+
type: "agent.registered" | "agent.unregistered" | "agent.state-changed" | "agent.spawned" | "scope.created" | "scope.deleted" | "scope.joined" | "scope.left" | "message.sent" | "message.delivered" | "session.started" | "session.ended" | "system.error" | "system.shutdown";
|
|
1375
|
+
data?: Record<string, unknown> | undefined;
|
|
1376
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1377
|
+
}>;
|
|
1378
|
+
declare const SubscriptionFilterSchema: z.ZodObject<{
|
|
1379
|
+
eventTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["agent.registered", "agent.unregistered", "agent.state-changed", "agent.spawned", "scope.created", "scope.deleted", "scope.joined", "scope.left", "message.sent", "message.delivered", "session.started", "session.ended", "system.error", "system.shutdown"]>, "many">>;
|
|
1380
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1381
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1382
|
+
includeChildren: z.ZodOptional<z.ZodBoolean>;
|
|
1383
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1384
|
+
}, "strict", z.ZodTypeAny, {
|
|
1385
|
+
agents?: string[] | undefined;
|
|
1386
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1387
|
+
scopes?: string[] | undefined;
|
|
1388
|
+
eventTypes?: ("agent.registered" | "agent.unregistered" | "agent.state-changed" | "agent.spawned" | "scope.created" | "scope.deleted" | "scope.joined" | "scope.left" | "message.sent" | "message.delivered" | "session.started" | "session.ended" | "system.error" | "system.shutdown")[] | undefined;
|
|
1389
|
+
includeChildren?: boolean | undefined;
|
|
1390
|
+
}, {
|
|
1391
|
+
agents?: string[] | undefined;
|
|
1392
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1393
|
+
scopes?: string[] | undefined;
|
|
1394
|
+
eventTypes?: ("agent.registered" | "agent.unregistered" | "agent.state-changed" | "agent.spawned" | "scope.created" | "scope.deleted" | "scope.joined" | "scope.left" | "message.sent" | "message.delivered" | "session.started" | "session.ended" | "system.error" | "system.shutdown")[] | undefined;
|
|
1395
|
+
includeChildren?: boolean | undefined;
|
|
1396
|
+
}>;
|
|
1397
|
+
declare const MAPErrorDataSchema: z.ZodObject<{
|
|
1398
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1399
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1400
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1401
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1402
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1403
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1404
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1405
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1406
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1407
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1408
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1409
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1410
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1411
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1412
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1413
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1414
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1415
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
1416
|
+
declare const MAPErrorSchema: z.ZodObject<{
|
|
1417
|
+
code: z.ZodNumber;
|
|
1418
|
+
message: z.ZodString;
|
|
1419
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
1420
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1421
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1422
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1423
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1424
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1425
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1426
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1427
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1428
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1429
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1430
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1431
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1432
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1433
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1434
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1435
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1436
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1437
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
1438
|
+
}, "strict", z.ZodTypeAny, {
|
|
1439
|
+
message: string;
|
|
1440
|
+
code: number;
|
|
1441
|
+
data?: z.objectOutputType<{
|
|
1442
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1443
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1444
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1445
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1446
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1447
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
1448
|
+
}, {
|
|
1449
|
+
message: string;
|
|
1450
|
+
code: number;
|
|
1451
|
+
data?: z.objectInputType<{
|
|
1452
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1453
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1454
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1455
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1456
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1457
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
1458
|
+
}>;
|
|
1459
|
+
declare const MAPRequestSchema: z.ZodObject<{
|
|
1460
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
1461
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
1462
|
+
method: z.ZodString;
|
|
1463
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1464
|
+
}, "strict", z.ZodTypeAny, {
|
|
1465
|
+
jsonrpc: "2.0";
|
|
1466
|
+
id: string | number;
|
|
1467
|
+
method: string;
|
|
1468
|
+
params?: Record<string, unknown> | undefined;
|
|
1469
|
+
}, {
|
|
1470
|
+
jsonrpc: "2.0";
|
|
1471
|
+
id: string | number;
|
|
1472
|
+
method: string;
|
|
1473
|
+
params?: Record<string, unknown> | undefined;
|
|
1474
|
+
}>;
|
|
1475
|
+
declare const MAPResponseSuccessSchema: z.ZodObject<{
|
|
1476
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
1477
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
1478
|
+
result: z.ZodUnknown;
|
|
1479
|
+
}, "strict", z.ZodTypeAny, {
|
|
1480
|
+
jsonrpc: "2.0";
|
|
1481
|
+
id: string | number;
|
|
1482
|
+
result?: unknown;
|
|
1483
|
+
}, {
|
|
1484
|
+
jsonrpc: "2.0";
|
|
1485
|
+
id: string | number;
|
|
1486
|
+
result?: unknown;
|
|
1487
|
+
}>;
|
|
1488
|
+
declare const MAPResponseErrorSchema: z.ZodObject<{
|
|
1489
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
1490
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
1491
|
+
error: z.ZodObject<{
|
|
1492
|
+
code: z.ZodNumber;
|
|
1493
|
+
message: z.ZodString;
|
|
1494
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
1495
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1496
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1497
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1498
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1499
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1500
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1501
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1502
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1503
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1504
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1505
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1506
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1507
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1508
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1509
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1510
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1511
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1512
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
1513
|
+
}, "strict", z.ZodTypeAny, {
|
|
1514
|
+
message: string;
|
|
1515
|
+
code: number;
|
|
1516
|
+
data?: z.objectOutputType<{
|
|
1517
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1518
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1519
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1520
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1521
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1522
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
1523
|
+
}, {
|
|
1524
|
+
message: string;
|
|
1525
|
+
code: number;
|
|
1526
|
+
data?: z.objectInputType<{
|
|
1527
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1528
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1529
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1530
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1531
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1532
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
1533
|
+
}>;
|
|
1534
|
+
}, "strict", z.ZodTypeAny, {
|
|
1535
|
+
error: {
|
|
1536
|
+
message: string;
|
|
1537
|
+
code: number;
|
|
1538
|
+
data?: z.objectOutputType<{
|
|
1539
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1540
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1541
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1542
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1543
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1544
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
1545
|
+
};
|
|
1546
|
+
jsonrpc: "2.0";
|
|
1547
|
+
id: string | number;
|
|
1548
|
+
}, {
|
|
1549
|
+
error: {
|
|
1550
|
+
message: string;
|
|
1551
|
+
code: number;
|
|
1552
|
+
data?: z.objectInputType<{
|
|
1553
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1554
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1555
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1556
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1557
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1558
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
1559
|
+
};
|
|
1560
|
+
jsonrpc: "2.0";
|
|
1561
|
+
id: string | number;
|
|
1562
|
+
}>;
|
|
1563
|
+
declare const MAPResponseSchema: z.ZodUnion<[z.ZodObject<{
|
|
1564
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
1565
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
1566
|
+
result: z.ZodUnknown;
|
|
1567
|
+
}, "strict", z.ZodTypeAny, {
|
|
1568
|
+
jsonrpc: "2.0";
|
|
1569
|
+
id: string | number;
|
|
1570
|
+
result?: unknown;
|
|
1571
|
+
}, {
|
|
1572
|
+
jsonrpc: "2.0";
|
|
1573
|
+
id: string | number;
|
|
1574
|
+
result?: unknown;
|
|
1575
|
+
}>, z.ZodObject<{
|
|
1576
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
1577
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
1578
|
+
error: z.ZodObject<{
|
|
1579
|
+
code: z.ZodNumber;
|
|
1580
|
+
message: z.ZodString;
|
|
1581
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
1582
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1583
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1584
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1585
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1586
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1587
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1588
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1589
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1590
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1591
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1592
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1593
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1594
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1595
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1596
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1597
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1598
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1599
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
1600
|
+
}, "strict", z.ZodTypeAny, {
|
|
1601
|
+
message: string;
|
|
1602
|
+
code: number;
|
|
1603
|
+
data?: z.objectOutputType<{
|
|
1604
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1605
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1606
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1607
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1608
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1609
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
1610
|
+
}, {
|
|
1611
|
+
message: string;
|
|
1612
|
+
code: number;
|
|
1613
|
+
data?: z.objectInputType<{
|
|
1614
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1615
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1616
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1617
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1618
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1619
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
1620
|
+
}>;
|
|
1621
|
+
}, "strict", z.ZodTypeAny, {
|
|
1622
|
+
error: {
|
|
1623
|
+
message: string;
|
|
1624
|
+
code: number;
|
|
1625
|
+
data?: z.objectOutputType<{
|
|
1626
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1627
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1628
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1629
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1630
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1631
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
1632
|
+
};
|
|
1633
|
+
jsonrpc: "2.0";
|
|
1634
|
+
id: string | number;
|
|
1635
|
+
}, {
|
|
1636
|
+
error: {
|
|
1637
|
+
message: string;
|
|
1638
|
+
code: number;
|
|
1639
|
+
data?: z.objectInputType<{
|
|
1640
|
+
category: z.ZodOptional<z.ZodEnum<["protocol", "auth", "routing", "agent", "resource", "federation", "internal"]>>;
|
|
1641
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
1642
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
1643
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1644
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1645
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
1646
|
+
};
|
|
1647
|
+
jsonrpc: "2.0";
|
|
1648
|
+
id: string | number;
|
|
1649
|
+
}>]>;
|
|
1650
|
+
declare const MAPNotificationSchema: z.ZodObject<{
|
|
1651
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
1652
|
+
method: z.ZodString;
|
|
1653
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1654
|
+
}, "strict", z.ZodTypeAny, {
|
|
1655
|
+
jsonrpc: "2.0";
|
|
1656
|
+
method: string;
|
|
1657
|
+
params?: Record<string, unknown> | undefined;
|
|
1658
|
+
}, {
|
|
1659
|
+
jsonrpc: "2.0";
|
|
1660
|
+
method: string;
|
|
1661
|
+
params?: Record<string, unknown> | undefined;
|
|
1662
|
+
}>;
|
|
1663
|
+
type ParticipantIdValidated = z.infer<typeof ParticipantIdSchema>;
|
|
1664
|
+
type AgentIdValidated = z.infer<typeof AgentIdSchema>;
|
|
1665
|
+
type ScopeIdValidated = z.infer<typeof ScopeIdSchema>;
|
|
1666
|
+
type SessionIdValidated = z.infer<typeof SessionIdSchema>;
|
|
1667
|
+
type MessageIdValidated = z.infer<typeof MessageIdSchema>;
|
|
1668
|
+
type ParticipantTypeValidated = z.infer<typeof ParticipantTypeSchema>;
|
|
1669
|
+
type AgentStateValidated = z.infer<typeof AgentStateSchema>;
|
|
1670
|
+
type AgentValidated = z.infer<typeof AgentSchema>;
|
|
1671
|
+
type ScopeValidated = z.infer<typeof ScopeSchema>;
|
|
1672
|
+
type MessageValidated = z.infer<typeof MessageSchema>;
|
|
1673
|
+
type EventValidated = z.infer<typeof EventSchema>;
|
|
1674
|
+
type AddressValidated = z.infer<typeof AddressSchema>;
|
|
1675
|
+
type MAPRequestValidated = z.infer<typeof MAPRequestSchema>;
|
|
1676
|
+
type MAPResponseValidated = z.infer<typeof MAPResponseSchema>;
|
|
1677
|
+
type MAPNotificationValidated = z.infer<typeof MAPNotificationSchema>;
|
|
1678
|
+
type MAPErrorValidated = z.infer<typeof MAPErrorSchema>;
|
|
1679
|
+
type ParticipantCapabilitiesValidated = z.infer<typeof ParticipantCapabilitiesSchema>;
|
|
1680
|
+
type SubscriptionFilterValidated = z.infer<typeof SubscriptionFilterSchema>;
|
|
1681
|
+
|
|
1682
|
+
/**
|
|
1683
|
+
* Protocol utilities for MAP SDK
|
|
1684
|
+
*
|
|
1685
|
+
* Provides:
|
|
1686
|
+
* - METHOD_REGISTRY: Single source of truth for all methods with metadata
|
|
1687
|
+
* - Response builders: Type-safe response construction
|
|
1688
|
+
* - Helper functions for method capability checking
|
|
1689
|
+
*/
|
|
1690
|
+
|
|
1691
|
+
/** Method category for organization */
|
|
1692
|
+
type MethodCategory = 'core' | 'observation' | 'lifecycle' | 'state' | 'steering' | 'scope' | 'session' | 'auth' | 'federation' | 'notification';
|
|
1693
|
+
/** Capability path like 'observation.canQuery' */
|
|
1694
|
+
type CapabilityPath = string;
|
|
1695
|
+
/** Method metadata */
|
|
1696
|
+
interface MethodInfo {
|
|
1697
|
+
/** The wire method name */
|
|
1698
|
+
method: string;
|
|
1699
|
+
/** Category for organization */
|
|
1700
|
+
category: MethodCategory;
|
|
1701
|
+
/** Required capabilities (empty = no special capabilities needed) */
|
|
1702
|
+
capabilities: CapabilityPath[];
|
|
1703
|
+
/** Human-readable description */
|
|
1704
|
+
description: string;
|
|
1705
|
+
}
|
|
1706
|
+
/**
|
|
1707
|
+
* Method Registry - Single source of truth for all MAP methods
|
|
1708
|
+
*
|
|
1709
|
+
* Use this instead of individual method constants for:
|
|
1710
|
+
* - Capability checking
|
|
1711
|
+
* - Method validation
|
|
1712
|
+
* - Documentation generation
|
|
1713
|
+
*/
|
|
1714
|
+
declare const METHOD_REGISTRY: Record<string, MethodInfo>;
|
|
1715
|
+
/**
|
|
1716
|
+
* Get methods by category
|
|
1717
|
+
*/
|
|
1718
|
+
declare function getMethodsByCategory(category: MethodCategory): MethodInfo[];
|
|
1719
|
+
/**
|
|
1720
|
+
* Get required capabilities for a method
|
|
1721
|
+
*/
|
|
1722
|
+
declare function getRequiredCapabilities(methodName: string): CapabilityPath[];
|
|
1723
|
+
/**
|
|
1724
|
+
* Check if capabilities satisfy method requirements
|
|
1725
|
+
*/
|
|
1726
|
+
declare function hasRequiredCapabilities(methodName: string, capabilities: ParticipantCapabilities): boolean;
|
|
1727
|
+
/**
|
|
1728
|
+
* Get method info by wire method name (e.g., 'map/agents/list')
|
|
1729
|
+
*/
|
|
1730
|
+
declare function getMethodInfo(wireMethod: string): MethodInfo | undefined;
|
|
1731
|
+
/**
|
|
1732
|
+
* Build connect response
|
|
1733
|
+
*/
|
|
1734
|
+
declare function buildConnectResponse(params: {
|
|
1735
|
+
protocolVersion: ProtocolVersion;
|
|
1736
|
+
sessionId: SessionId;
|
|
1737
|
+
participantId: ParticipantId;
|
|
1738
|
+
capabilities: ParticipantCapabilities;
|
|
1739
|
+
systemInfo?: {
|
|
1740
|
+
name?: string;
|
|
1741
|
+
version?: string;
|
|
1742
|
+
};
|
|
1743
|
+
reconnected?: boolean;
|
|
1744
|
+
reclaimedAgents?: Agent[];
|
|
1745
|
+
ownedAgents?: string[];
|
|
1746
|
+
}): ConnectResponseResult;
|
|
1747
|
+
/**
|
|
1748
|
+
* Build disconnect response
|
|
1749
|
+
*/
|
|
1750
|
+
declare function buildDisconnectResponse(session: SessionInfo): DisconnectResponseResult;
|
|
1751
|
+
/**
|
|
1752
|
+
* Build send response
|
|
1753
|
+
*/
|
|
1754
|
+
declare function buildSendResponse(messageId: MessageId, delivered: ParticipantId[]): SendResponseResult;
|
|
1755
|
+
/**
|
|
1756
|
+
* Build agents/register response
|
|
1757
|
+
*/
|
|
1758
|
+
declare function buildAgentsRegisterResponse(agent: Agent): AgentsRegisterResponseResult;
|
|
1759
|
+
/**
|
|
1760
|
+
* Build agents/unregister response
|
|
1761
|
+
*/
|
|
1762
|
+
declare function buildAgentsUnregisterResponse(agent: Agent): AgentsUnregisterResponseResult;
|
|
1763
|
+
/**
|
|
1764
|
+
* Build agents/list response
|
|
1765
|
+
*/
|
|
1766
|
+
declare function buildAgentsListResponse(agents: Agent[]): AgentsListResponseResult;
|
|
1767
|
+
/**
|
|
1768
|
+
* Build agents/get response
|
|
1769
|
+
*/
|
|
1770
|
+
declare function buildAgentsGetResponse(agent: Agent, children?: Agent[], descendants?: Agent[]): AgentsGetResponseResult;
|
|
1771
|
+
/**
|
|
1772
|
+
* Build agents/update response
|
|
1773
|
+
*/
|
|
1774
|
+
declare function buildAgentsUpdateResponse(agent: Agent): AgentsUpdateResponseResult;
|
|
1775
|
+
/**
|
|
1776
|
+
* Build agents/spawn response
|
|
1777
|
+
*/
|
|
1778
|
+
declare function buildAgentsSpawnResponse(agent: Agent): AgentsSpawnResponseResult;
|
|
1779
|
+
/**
|
|
1780
|
+
* Build scopes/create response
|
|
1781
|
+
*/
|
|
1782
|
+
declare function buildScopesCreateResponse(scope: Scope): ScopesCreateResponseResult;
|
|
1783
|
+
/**
|
|
1784
|
+
* Build scopes/list response
|
|
1785
|
+
*/
|
|
1786
|
+
declare function buildScopesListResponse(scopes: Scope[]): ScopesListResponseResult;
|
|
1787
|
+
/**
|
|
1788
|
+
* Build scopes/join response
|
|
1789
|
+
*/
|
|
1790
|
+
declare function buildScopesJoinResponse(scope: Scope, agent: Agent): ScopesJoinResponseResult;
|
|
1791
|
+
/**
|
|
1792
|
+
* Build scopes/leave response
|
|
1793
|
+
*/
|
|
1794
|
+
declare function buildScopesLeaveResponse(scope: Scope, agent: Agent): ScopesLeaveResponseResult;
|
|
1795
|
+
/**
|
|
1796
|
+
* Build subscribe response
|
|
1797
|
+
*/
|
|
1798
|
+
declare function buildSubscribeResponse(subscriptionId: SubscriptionId): SubscribeResponseResult;
|
|
1799
|
+
/**
|
|
1800
|
+
* Build unsubscribe response
|
|
1801
|
+
*/
|
|
1802
|
+
declare function buildUnsubscribeResponse(subscriptionId: SubscriptionId, closedAt?: number): UnsubscribeResponseResult;
|
|
1803
|
+
|
|
1804
|
+
/**
|
|
1805
|
+
* ULID utilities for MAP event IDs
|
|
1806
|
+
*
|
|
1807
|
+
* ULIDs (Universally Unique Lexicographically Sortable Identifiers) are:
|
|
1808
|
+
* - 26 characters, Crockford Base32 encoded
|
|
1809
|
+
* - Time-sortable (first 48 bits = millisecond timestamp)
|
|
1810
|
+
* - Lexicographically sortable (string comparison = chronological order)
|
|
1811
|
+
*
|
|
1812
|
+
* Format: TTTTTTTTTTRRRRRRRRRRRRRRR
|
|
1813
|
+
* |---------|-------------|
|
|
1814
|
+
* Timestamp Randomness
|
|
1815
|
+
* (10 chars) (16 chars)
|
|
1816
|
+
*
|
|
1817
|
+
* @example
|
|
1818
|
+
* ```typescript
|
|
1819
|
+
* import { ulid, ulidTimestamp, compareUlid } from './utils/ulid';
|
|
1820
|
+
*
|
|
1821
|
+
* const id = ulid(); // "01HQJY3KCNP5VXWZ8M4R6T2G9B"
|
|
1822
|
+
* const ts = ulidTimestamp(id); // 1706123456789
|
|
1823
|
+
* ```
|
|
1824
|
+
*/
|
|
1825
|
+
|
|
1826
|
+
/**
|
|
1827
|
+
* Extract the timestamp from a ULID.
|
|
1828
|
+
*
|
|
1829
|
+
* @param id - The ULID string
|
|
1830
|
+
* @returns Unix timestamp in milliseconds
|
|
1831
|
+
*
|
|
1832
|
+
* @example
|
|
1833
|
+
* ```typescript
|
|
1834
|
+
* const id = ulid();
|
|
1835
|
+
* const timestamp = ulidTimestamp(id);
|
|
1836
|
+
* console.log(new Date(timestamp));
|
|
1837
|
+
* ```
|
|
1838
|
+
*/
|
|
1839
|
+
declare function ulidTimestamp(id: string): number;
|
|
1840
|
+
/**
|
|
1841
|
+
* Compare two ULIDs lexicographically.
|
|
1842
|
+
*
|
|
1843
|
+
* Since ULIDs are designed to be lexicographically sortable,
|
|
1844
|
+
* this comparison also gives chronological ordering.
|
|
1845
|
+
*
|
|
1846
|
+
* @param a - First ULID
|
|
1847
|
+
* @param b - Second ULID
|
|
1848
|
+
* @returns Negative if a < b, positive if a > b, zero if equal
|
|
1849
|
+
*
|
|
1850
|
+
* @example
|
|
1851
|
+
* ```typescript
|
|
1852
|
+
* const ids = [ulid(), ulid(), ulid()];
|
|
1853
|
+
* ids.sort(compareUlid); // Chronological order
|
|
1854
|
+
* ```
|
|
1855
|
+
*/
|
|
1856
|
+
declare function compareUlid(a: string, b: string): number;
|
|
1857
|
+
/**
|
|
1858
|
+
* Check if a string is a valid ULID format.
|
|
1859
|
+
*
|
|
1860
|
+
* @param id - String to check
|
|
1861
|
+
* @returns True if valid ULID format
|
|
1862
|
+
*/
|
|
1863
|
+
declare function isValidUlid(id: string): boolean;
|
|
1864
|
+
|
|
1865
|
+
/**
|
|
1866
|
+
* Retry utilities with exponential backoff
|
|
1867
|
+
*
|
|
1868
|
+
* Provides configurable retry logic for handling transient failures
|
|
1869
|
+
* in network operations like reconnection.
|
|
1870
|
+
*/
|
|
1871
|
+
/**
|
|
1872
|
+
* Configuration for retry behavior
|
|
1873
|
+
*/
|
|
1874
|
+
interface RetryPolicy {
|
|
1875
|
+
/** Maximum number of retry attempts (default: 10) */
|
|
1876
|
+
maxRetries: number;
|
|
1877
|
+
/** Initial delay in milliseconds (default: 1000) */
|
|
1878
|
+
baseDelayMs: number;
|
|
1879
|
+
/** Maximum delay in milliseconds (default: 30000) */
|
|
1880
|
+
maxDelayMs: number;
|
|
1881
|
+
/** Add randomness to delay to prevent thundering herd (default: true) */
|
|
1882
|
+
jitter: boolean;
|
|
1883
|
+
/** Custom function to determine if an error is retryable */
|
|
1884
|
+
isRetryable?: (error: Error) => boolean;
|
|
1885
|
+
}
|
|
1886
|
+
/**
|
|
1887
|
+
* Default retry policy with sensible defaults for network operations
|
|
1888
|
+
*/
|
|
1889
|
+
declare const DEFAULT_RETRY_POLICY: RetryPolicy;
|
|
1890
|
+
/**
|
|
1891
|
+
* State passed to retry callbacks
|
|
1892
|
+
*/
|
|
1893
|
+
interface RetryState {
|
|
1894
|
+
/** Current attempt number (1-indexed) */
|
|
1895
|
+
attempt: number;
|
|
1896
|
+
/** Delay before next retry in milliseconds */
|
|
1897
|
+
nextDelayMs: number;
|
|
1898
|
+
/** The error that caused this retry */
|
|
1899
|
+
lastError?: Error;
|
|
1900
|
+
}
|
|
1901
|
+
/**
|
|
1902
|
+
* Callbacks for monitoring retry progress
|
|
1903
|
+
*/
|
|
1904
|
+
interface RetryCallbacks<T> {
|
|
1905
|
+
/** Called before each retry attempt */
|
|
1906
|
+
onRetry?: (state: RetryState) => void;
|
|
1907
|
+
/** Called on successful completion */
|
|
1908
|
+
onSuccess?: (result: T, attempts: number) => void;
|
|
1909
|
+
/** Called when all retries are exhausted */
|
|
1910
|
+
onFailure?: (error: Error, attempts: number) => void;
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* Calculate delay for a retry attempt using exponential backoff.
|
|
1914
|
+
*
|
|
1915
|
+
* Formula: min(baseDelay * 2^(attempt-1), maxDelay) * jitter
|
|
1916
|
+
*
|
|
1917
|
+
* @param attempt - Current attempt number (1-indexed)
|
|
1918
|
+
* @param policy - Retry policy configuration
|
|
1919
|
+
* @returns Delay in milliseconds
|
|
1920
|
+
*
|
|
1921
|
+
* @example
|
|
1922
|
+
* ```typescript
|
|
1923
|
+
* // With baseDelay=1000, maxDelay=30000:
|
|
1924
|
+
* // Attempt 1: 1000ms
|
|
1925
|
+
* // Attempt 2: 2000ms
|
|
1926
|
+
* // Attempt 3: 4000ms
|
|
1927
|
+
* // Attempt 4: 8000ms
|
|
1928
|
+
* // Attempt 5: 16000ms
|
|
1929
|
+
* // Attempt 6+: 30000ms (capped)
|
|
1930
|
+
* ```
|
|
1931
|
+
*/
|
|
1932
|
+
declare function calculateDelay(attempt: number, policy: RetryPolicy): number;
|
|
1933
|
+
/**
|
|
1934
|
+
* Execute an async operation with retry logic.
|
|
1935
|
+
*
|
|
1936
|
+
* Retries the operation on failure using exponential backoff until
|
|
1937
|
+
* either it succeeds or the maximum retries are exhausted.
|
|
1938
|
+
*
|
|
1939
|
+
* @param operation - Async function to execute
|
|
1940
|
+
* @param policy - Retry policy (defaults to DEFAULT_RETRY_POLICY)
|
|
1941
|
+
* @param callbacks - Optional callbacks for monitoring progress
|
|
1942
|
+
* @returns The result of the successful operation
|
|
1943
|
+
* @throws The last error if all retries are exhausted
|
|
1944
|
+
*
|
|
1945
|
+
* @example
|
|
1946
|
+
* ```typescript
|
|
1947
|
+
* const result = await withRetry(
|
|
1948
|
+
* () => fetch('https://api.example.com/data'),
|
|
1949
|
+
* { maxRetries: 3, baseDelayMs: 1000, maxDelayMs: 5000, jitter: true },
|
|
1950
|
+
* {
|
|
1951
|
+
* onRetry: ({ attempt, nextDelayMs }) => {
|
|
1952
|
+
* console.log(`Retry ${attempt}, waiting ${nextDelayMs}ms`);
|
|
1953
|
+
* },
|
|
1954
|
+
* }
|
|
1955
|
+
* );
|
|
1956
|
+
* ```
|
|
1957
|
+
*/
|
|
1958
|
+
declare function withRetry<T>(operation: () => Promise<T>, policy?: RetryPolicy, callbacks?: RetryCallbacks<T>): Promise<T>;
|
|
1959
|
+
/**
|
|
1960
|
+
* Create a retryable wrapper around an async function.
|
|
1961
|
+
*
|
|
1962
|
+
* Returns a new function with the same signature that automatically
|
|
1963
|
+
* retries on failure according to the policy.
|
|
1964
|
+
*
|
|
1965
|
+
* @param fn - Async function to wrap
|
|
1966
|
+
* @param policy - Retry policy
|
|
1967
|
+
* @returns Wrapped function with retry behavior
|
|
1968
|
+
*
|
|
1969
|
+
* @example
|
|
1970
|
+
* ```typescript
|
|
1971
|
+
* const fetchWithRetry = retryable(
|
|
1972
|
+
* async (url: string) => fetch(url),
|
|
1973
|
+
* { maxRetries: 3, baseDelayMs: 1000, maxDelayMs: 5000, jitter: true }
|
|
1974
|
+
* );
|
|
1975
|
+
*
|
|
1976
|
+
* const response = await fetchWithRetry('https://api.example.com');
|
|
1977
|
+
* ```
|
|
1978
|
+
*/
|
|
1979
|
+
declare function retryable<TArgs extends unknown[], TResult>(fn: (...args: TArgs) => Promise<TResult>, policy?: RetryPolicy): (...args: TArgs) => Promise<TResult>;
|
|
1980
|
+
/**
|
|
1981
|
+
* Create a partial retry policy merged with defaults.
|
|
1982
|
+
*
|
|
1983
|
+
* @param options - Partial policy options to override defaults
|
|
1984
|
+
* @returns Complete retry policy
|
|
1985
|
+
*/
|
|
1986
|
+
declare function createRetryPolicy(options?: Partial<RetryPolicy>): RetryPolicy;
|
|
1987
|
+
/**
|
|
1988
|
+
* Sleep for a specified duration.
|
|
1989
|
+
*
|
|
1990
|
+
* @param ms - Duration in milliseconds
|
|
1991
|
+
* @returns Promise that resolves after the duration
|
|
1992
|
+
*/
|
|
1993
|
+
declare function sleep(ms: number): Promise<void>;
|
|
1994
|
+
|
|
1995
|
+
/**
|
|
1996
|
+
* Causal Event Buffer
|
|
1997
|
+
*
|
|
1998
|
+
* Buffers events and releases them in causal order. Events with `causedBy`
|
|
1999
|
+
* dependencies are held until all their predecessor events have been seen.
|
|
2000
|
+
*
|
|
2001
|
+
* This is useful for:
|
|
2002
|
+
* - Ensuring events are processed in correct causal order
|
|
2003
|
+
* - Handling out-of-order event delivery
|
|
2004
|
+
* - Building consistent views from event streams
|
|
2005
|
+
*/
|
|
2006
|
+
|
|
2007
|
+
/**
|
|
2008
|
+
* Event with envelope metadata for causal tracking
|
|
2009
|
+
*/
|
|
2010
|
+
interface CausalEvent {
|
|
2011
|
+
/** Unique event identifier */
|
|
2012
|
+
eventId: string;
|
|
2013
|
+
/** Event IDs that must be processed before this event */
|
|
2014
|
+
causedBy?: string[];
|
|
2015
|
+
/** The event payload */
|
|
2016
|
+
event: Event;
|
|
2017
|
+
/** Timestamp when the event was received */
|
|
2018
|
+
receivedAt?: number;
|
|
2019
|
+
}
|
|
2020
|
+
/**
|
|
2021
|
+
* Options for CausalEventBuffer
|
|
2022
|
+
*/
|
|
2023
|
+
interface CausalEventBufferOptions {
|
|
2024
|
+
/**
|
|
2025
|
+
* Maximum time (ms) to wait for causal predecessors before releasing anyway.
|
|
2026
|
+
* Default: 5000ms. Set to 0 or Infinity to wait indefinitely.
|
|
2027
|
+
*/
|
|
2028
|
+
maxWaitTime?: number;
|
|
2029
|
+
/**
|
|
2030
|
+
* Maximum number of events to buffer before force-releasing oldest.
|
|
2031
|
+
* Default: 1000. Prevents unbounded memory growth.
|
|
2032
|
+
*/
|
|
2033
|
+
maxBufferSize?: number;
|
|
2034
|
+
/**
|
|
2035
|
+
* Callback when an event is released despite missing predecessors (timeout or buffer overflow).
|
|
2036
|
+
*/
|
|
2037
|
+
onForcedRelease?: (event: CausalEvent, missingPredecessors: string[]) => void;
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* Result from pushing an event to the buffer
|
|
2041
|
+
*/
|
|
2042
|
+
interface CausalBufferPushResult {
|
|
2043
|
+
/** Events that are now ready to be processed in causal order */
|
|
2044
|
+
ready: CausalEvent[];
|
|
2045
|
+
/** Number of events still waiting for predecessors */
|
|
2046
|
+
pending: number;
|
|
2047
|
+
}
|
|
2048
|
+
/**
|
|
2049
|
+
* Buffers events and releases them in causal order.
|
|
2050
|
+
*
|
|
2051
|
+
* Events with `causedBy` dependencies are held until all predecessor events
|
|
2052
|
+
* have been seen (pushed to the buffer). Events without dependencies are
|
|
2053
|
+
* released immediately.
|
|
2054
|
+
*
|
|
2055
|
+
* @example
|
|
2056
|
+
* ```typescript
|
|
2057
|
+
* const buffer = new CausalEventBuffer();
|
|
2058
|
+
*
|
|
2059
|
+
* // Event B depends on A, but arrives first
|
|
2060
|
+
* let result = buffer.push({
|
|
2061
|
+
* eventId: 'B',
|
|
2062
|
+
* causedBy: ['A'],
|
|
2063
|
+
* event: { id: 'B', type: 'effect', timestamp: 2 }
|
|
2064
|
+
* });
|
|
2065
|
+
* console.log(result.ready); // [] - B is waiting for A
|
|
2066
|
+
* console.log(result.pending); // 1
|
|
2067
|
+
*
|
|
2068
|
+
* // Event A arrives
|
|
2069
|
+
* result = buffer.push({
|
|
2070
|
+
* eventId: 'A',
|
|
2071
|
+
* event: { id: 'A', type: 'cause', timestamp: 1 }
|
|
2072
|
+
* });
|
|
2073
|
+
* console.log(result.ready); // [A, B] - Both released in order
|
|
2074
|
+
* console.log(result.pending); // 0
|
|
2075
|
+
* ```
|
|
2076
|
+
*/
|
|
2077
|
+
declare class CausalEventBuffer {
|
|
2078
|
+
#private;
|
|
2079
|
+
constructor(options?: CausalEventBufferOptions);
|
|
2080
|
+
/**
|
|
2081
|
+
* Push an event into the buffer.
|
|
2082
|
+
*
|
|
2083
|
+
* @param event - The event to buffer
|
|
2084
|
+
* @returns Events that are ready to be processed (in causal order)
|
|
2085
|
+
*/
|
|
2086
|
+
push(event: CausalEvent): CausalBufferPushResult;
|
|
2087
|
+
/**
|
|
2088
|
+
* Get the number of events waiting for predecessors
|
|
2089
|
+
*/
|
|
2090
|
+
get pendingCount(): number;
|
|
2091
|
+
/**
|
|
2092
|
+
* Get the number of unique events seen
|
|
2093
|
+
*/
|
|
2094
|
+
get seenCount(): number;
|
|
2095
|
+
/**
|
|
2096
|
+
* Check if a specific event has been seen
|
|
2097
|
+
*/
|
|
2098
|
+
hasSeen(eventId: string): boolean;
|
|
2099
|
+
/**
|
|
2100
|
+
* Force release all pending events, regardless of missing predecessors.
|
|
2101
|
+
* Useful for cleanup or when you know no more events are coming.
|
|
2102
|
+
*
|
|
2103
|
+
* @returns All pending events in the order they would be released
|
|
2104
|
+
*/
|
|
2105
|
+
flush(): CausalEvent[];
|
|
2106
|
+
/**
|
|
2107
|
+
* Clear all state (seen events, pending events)
|
|
2108
|
+
*/
|
|
2109
|
+
clear(): void;
|
|
2110
|
+
}
|
|
2111
|
+
/**
|
|
2112
|
+
* Validate that events are in causal order.
|
|
2113
|
+
*
|
|
2114
|
+
* An event sequence is in causal order if no event appears before
|
|
2115
|
+
* any of its predecessors (events in its causedBy array).
|
|
2116
|
+
*
|
|
2117
|
+
* @param events - Events to validate
|
|
2118
|
+
* @returns True if events are in valid causal order
|
|
2119
|
+
*
|
|
2120
|
+
* @example
|
|
2121
|
+
* ```typescript
|
|
2122
|
+
* const events = [
|
|
2123
|
+
* { eventId: 'A', event: {...} },
|
|
2124
|
+
* { eventId: 'B', causedBy: ['A'], event: {...} },
|
|
2125
|
+
* { eventId: 'C', causedBy: ['B'], event: {...} },
|
|
2126
|
+
* ];
|
|
2127
|
+
* console.log(validateCausalOrder(events)); // true
|
|
2128
|
+
*
|
|
2129
|
+
* const badOrder = [
|
|
2130
|
+
* { eventId: 'B', causedBy: ['A'], event: {...} },
|
|
2131
|
+
* { eventId: 'A', event: {...} }, // A should come before B
|
|
2132
|
+
* ];
|
|
2133
|
+
* console.log(validateCausalOrder(badOrder)); // false
|
|
2134
|
+
* ```
|
|
2135
|
+
*/
|
|
2136
|
+
declare function validateCausalOrder(events: CausalEvent[]): boolean;
|
|
2137
|
+
/**
|
|
2138
|
+
* Sort events into causal order using topological sort.
|
|
2139
|
+
*
|
|
2140
|
+
* If the events form a valid DAG (no cycles), returns them in an order
|
|
2141
|
+
* where no event appears before its predecessors. If there are cycles
|
|
2142
|
+
* or missing predecessors, throws an error.
|
|
2143
|
+
*
|
|
2144
|
+
* @param events - Events to sort
|
|
2145
|
+
* @returns Events in causal order
|
|
2146
|
+
* @throws If events contain cycles or reference missing predecessors
|
|
2147
|
+
*
|
|
2148
|
+
* @example
|
|
2149
|
+
* ```typescript
|
|
2150
|
+
* const unordered = [
|
|
2151
|
+
* { eventId: 'C', causedBy: ['B'], event: {...} },
|
|
2152
|
+
* { eventId: 'A', event: {...} },
|
|
2153
|
+
* { eventId: 'B', causedBy: ['A'], event: {...} },
|
|
2154
|
+
* ];
|
|
2155
|
+
* const ordered = sortCausalOrder(unordered);
|
|
2156
|
+
* // ordered = [A, B, C]
|
|
2157
|
+
* ```
|
|
2158
|
+
*/
|
|
2159
|
+
declare function sortCausalOrder(events: CausalEvent[]): CausalEvent[];
|
|
2160
|
+
|
|
2161
|
+
/**
|
|
2162
|
+
* Federation Envelope Utilities
|
|
2163
|
+
*
|
|
2164
|
+
* Provides functions for creating and processing federation envelopes
|
|
2165
|
+
* for routing messages between federated MAP systems.
|
|
2166
|
+
*/
|
|
2167
|
+
|
|
2168
|
+
/**
|
|
2169
|
+
* Options for creating a federation envelope.
|
|
2170
|
+
*/
|
|
2171
|
+
interface CreateEnvelopeOptions {
|
|
2172
|
+
/** Correlation ID for cross-system tracing */
|
|
2173
|
+
correlationId?: string;
|
|
2174
|
+
/** Maximum number of hops before rejection */
|
|
2175
|
+
maxHops?: number;
|
|
2176
|
+
/** Whether to track the full routing path */
|
|
2177
|
+
trackPath?: boolean;
|
|
2178
|
+
}
|
|
2179
|
+
/**
|
|
2180
|
+
* Result of processing a federation envelope.
|
|
2181
|
+
*/
|
|
2182
|
+
type ProcessEnvelopeResult<T> = {
|
|
2183
|
+
success: true;
|
|
2184
|
+
envelope: FederationEnvelope<T>;
|
|
2185
|
+
} | {
|
|
2186
|
+
success: false;
|
|
2187
|
+
errorCode: number;
|
|
2188
|
+
errorMessage: string;
|
|
2189
|
+
};
|
|
2190
|
+
/**
|
|
2191
|
+
* Create a new federation envelope for outbound messages.
|
|
2192
|
+
*
|
|
2193
|
+
* @param payload - The payload to wrap (typically a Message)
|
|
2194
|
+
* @param sourceSystem - ID of the originating system
|
|
2195
|
+
* @param targetSystem - ID of the destination system
|
|
2196
|
+
* @param options - Optional envelope options
|
|
2197
|
+
* @returns A new federation envelope
|
|
2198
|
+
*
|
|
2199
|
+
* @example
|
|
2200
|
+
* ```typescript
|
|
2201
|
+
* const envelope = createFederationEnvelope(
|
|
2202
|
+
* message,
|
|
2203
|
+
* 'system-alpha',
|
|
2204
|
+
* 'system-beta',
|
|
2205
|
+
* { trackPath: true, correlationId: 'req-123' }
|
|
2206
|
+
* );
|
|
2207
|
+
* ```
|
|
2208
|
+
*/
|
|
2209
|
+
declare function createFederationEnvelope<T>(payload: T, sourceSystem: string, targetSystem: string, options?: CreateEnvelopeOptions): FederationEnvelope<T>;
|
|
2210
|
+
/**
|
|
2211
|
+
* Process an incoming federation envelope for forwarding.
|
|
2212
|
+
*
|
|
2213
|
+
* Validates the envelope against routing configuration and returns
|
|
2214
|
+
* an updated envelope ready for forwarding, or an error if routing
|
|
2215
|
+
* should be rejected.
|
|
2216
|
+
*
|
|
2217
|
+
* Checks performed:
|
|
2218
|
+
* 1. Hop count hasn't exceeded maximum
|
|
2219
|
+
* 2. No routing loops (if path tracking enabled)
|
|
2220
|
+
* 3. Source system is in allowed sources (if configured)
|
|
2221
|
+
* 4. Target system is in allowed targets (if configured)
|
|
2222
|
+
*
|
|
2223
|
+
* @param envelope - The incoming envelope
|
|
2224
|
+
* @param config - Routing configuration for this system
|
|
2225
|
+
* @returns Updated envelope or error result
|
|
2226
|
+
*
|
|
2227
|
+
* @example
|
|
2228
|
+
* ```typescript
|
|
2229
|
+
* const result = processFederationEnvelope(envelope, {
|
|
2230
|
+
* systemId: 'system-gamma',
|
|
2231
|
+
* maxHops: 5,
|
|
2232
|
+
* trackPath: true,
|
|
2233
|
+
* });
|
|
2234
|
+
*
|
|
2235
|
+
* if (result.success) {
|
|
2236
|
+
* forwardToNext(result.envelope);
|
|
2237
|
+
* } else {
|
|
2238
|
+
* rejectWithError(result.errorCode, result.errorMessage);
|
|
2239
|
+
* }
|
|
2240
|
+
* ```
|
|
2241
|
+
*/
|
|
2242
|
+
declare function processFederationEnvelope<T>(envelope: FederationEnvelope<T>, config: FederationRoutingConfig): ProcessEnvelopeResult<T>;
|
|
2243
|
+
/**
|
|
2244
|
+
* Check if an envelope has reached its final destination.
|
|
2245
|
+
*
|
|
2246
|
+
* @param envelope - The envelope to check
|
|
2247
|
+
* @param currentSystemId - ID of the current system
|
|
2248
|
+
* @returns true if this is the target system
|
|
2249
|
+
*/
|
|
2250
|
+
declare function isEnvelopeAtDestination(envelope: FederationEnvelope<unknown>, currentSystemId: string): boolean;
|
|
2251
|
+
/**
|
|
2252
|
+
* Extract the payload from a federation envelope.
|
|
2253
|
+
*
|
|
2254
|
+
* @param envelope - The envelope to unwrap
|
|
2255
|
+
* @returns The payload
|
|
2256
|
+
*/
|
|
2257
|
+
declare function unwrapEnvelope<T>(envelope: FederationEnvelope<T>): T;
|
|
2258
|
+
/**
|
|
2259
|
+
* Get routing metadata for logging/debugging.
|
|
2260
|
+
*
|
|
2261
|
+
* @param envelope - The envelope to inspect
|
|
2262
|
+
* @returns Routing information
|
|
2263
|
+
*/
|
|
2264
|
+
declare function getEnvelopeRoutingInfo(envelope: FederationEnvelope<unknown>): {
|
|
2265
|
+
source: string;
|
|
2266
|
+
target: string;
|
|
2267
|
+
hops: number;
|
|
2268
|
+
path?: string[];
|
|
2269
|
+
age: number;
|
|
2270
|
+
correlationId?: string;
|
|
2271
|
+
};
|
|
2272
|
+
/**
|
|
2273
|
+
* Validate that an object is a valid federation envelope.
|
|
2274
|
+
*
|
|
2275
|
+
* @param obj - Object to validate
|
|
2276
|
+
* @returns true if valid envelope structure
|
|
2277
|
+
*/
|
|
2278
|
+
declare function isValidEnvelope(obj: unknown): obj is FederationEnvelope<unknown>;
|
|
2279
|
+
/**
|
|
2280
|
+
* Create an updated envelope with a new payload (for transformations).
|
|
2281
|
+
*
|
|
2282
|
+
* @param envelope - Original envelope
|
|
2283
|
+
* @param newPayload - New payload
|
|
2284
|
+
* @returns New envelope with same metadata but new payload
|
|
2285
|
+
*/
|
|
2286
|
+
declare function withPayload<T, U>(envelope: FederationEnvelope<T>, newPayload: U): FederationEnvelope<U>;
|
|
2287
|
+
|
|
2288
|
+
export { Address, AddressSchema, type AddressValidated, Agent, type AgentExposure, AgentId, AgentIdSchema, type AgentIdValidated, AgentLifecycleSchema, AgentRelationshipSchema, AgentSchema, AgentStateSchema, type AgentStateValidated, type AgentValidated, AgentVisibilitySchema, AgentsGetResponseResult, AgentsListResponseResult, AgentsRegisterResponseResult, AgentsSpawnResponseResult, AgentsUnregisterResponseResult, AgentsUpdateResponseResult, BaseConnectionOptions, BroadcastAddressSchema, type CapabilityPath, type CausalBufferPushResult, type CausalEvent, CausalEventBuffer, type CausalEventBufferOptions, ConnectResponseResult, type ConnectedParticipant, ConnectionState, CorrelationIdSchema, type CreateEnvelopeOptions, DEFAULT_RETRY_POLICY, DeliverySemanticsSchema, DirectAddressSchema, DisconnectResponseResult, ErrorCategory, ErrorCategorySchema, Event, type EventExposure, EventSchema, EventType, EventTypeSchema, type EventValidated, FederatedAddressSchema, FederationBufferConfig, FederationConnectResponseResult, FederationEnvelope, FederationOutageBuffer, FederationRouteResponseResult, FederationRoutingConfig, GatewayConnection, type GatewayConnectionOptions, HierarchicalAddressSchema, JsonRpcVersionSchema, MAPConnectionError, MAPError, MAPErrorData, MAPErrorDataSchema, MAPErrorSchema, type MAPErrorValidated, MAPNotificationSchema, type MAPNotificationValidated, MAPRequestError, MAPRequestSchema, type MAPRequestValidated, MAPResponseErrorSchema, MAPResponseSchema, MAPResponseSuccessSchema, type MAPResponseValidated, type MAPRouter, type MAPRouterConfig, type MAPRouterFactory, MAPTimeoutError, METHOD_REGISTRY, Message, MessageId, MessageIdSchema, type MessageIdValidated, MessageMetaSchema, MessagePrioritySchema, MessageRelationshipSchema, MessageSchema, type MessageValidated, MessageVisibilitySchema, MetaSchema, type MethodCategory, type MethodInfo, MultiAddressSchema, ParticipantAddressSchema, ParticipantCapabilities, ParticipantCapabilitiesSchema, type ParticipantCapabilitiesValidated, ParticipantId, ParticipantIdSchema, type ParticipantIdValidated, ParticipantType, ParticipantTypeSchema, type ParticipantTypeValidated, type PeerBufferStats, type ProcessEnvelopeResult, ProtocolVersion, ProtocolVersionSchema, RequestId, RequestIdSchema, type RetryCallbacks, type RetryPolicy, type RetryState, RoleAddressSchema, type RouterLimits, Scope, ScopeAddressSchema, type ScopeExposure, ScopeId, ScopeIdSchema, type ScopeIdValidated, ScopeJoinPolicySchema, ScopeSchema, ScopeSendPolicySchema, type ScopeValidated, ScopeVisibilitySchema, ScopesCreateResponseResult, ScopesJoinResponseResult, ScopesLeaveResponseResult, ScopesListResponseResult, SendResponseResult, SessionId, SessionIdSchema, type SessionIdValidated, SessionInfo, Stream, SubscribeResponseResult, SubscriptionFilter, SubscriptionFilterSchema, type SubscriptionFilterValidated, SubscriptionId, SubscriptionIdSchema, SystemAddressSchema, type SystemExposure, TimestampSchema, TransportTypeSchema, UnsubscribeResponseResult, buildAgentsGetResponse, buildAgentsListResponse, buildAgentsRegisterResponse, buildAgentsSpawnResponse, buildAgentsUnregisterResponse, buildAgentsUpdateResponse, buildConnectResponse, buildDisconnectResponse, buildScopesCreateResponse, buildScopesJoinResponse, buildScopesLeaveResponse, buildScopesListResponse, buildSendResponse, buildSubscribeResponse, buildUnsubscribeResponse, calculateDelay, compareUlid, createErrorResponse, createFederationEnvelope, createNotification, createRequest, createRetryPolicy, createSuccessResponse, getEnvelopeRoutingInfo, getMethodInfo, getMethodsByCategory, getRequiredCapabilities, hasRequiredCapabilities, isEnvelopeAtDestination, isErrorResponse, isNotification, isRequest, isResponse, isValidEnvelope, isValidUlid, processFederationEnvelope, retryable, sleep, sortCausalOrder, ulidTimestamp, unwrapEnvelope, validateCausalOrder, withPayload, withRetry };
|