@multi-agent-protocol/sdk 0.0.4 → 0.0.6
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 +164 -5
- package/dist/{index-Z76qC_Us.d.cts → index-BQXp4_rd.d.cts} +1898 -142
- package/dist/{index-Z76qC_Us.d.ts → index-BQXp4_rd.d.ts} +1898 -142
- package/dist/index.cjs +2906 -1104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +641 -24
- package/dist/index.d.ts +641 -24
- package/dist/index.js +2889 -1102
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +1092 -8
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +2 -1
- package/dist/testing.d.ts +2 -1
- package/dist/testing.js +1092 -8
- package/dist/testing.js.map +1 -1
- package/package.json +8 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
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-
|
|
2
|
-
export {
|
|
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, O as AgentVisibility, Q as ScopeVisibility, T as AgentState, V as MessageMeta, W as AgentConnection, X as ACPAgentHandler, Y as ACPSessionNotification, Z as ACPRequestPermissionRequest, _ as ACPRequestPermissionResponse, $ as ACPReadTextFileRequest, a0 as ACPReadTextFileResponse, a1 as ACPWriteTextFileRequest, a2 as ACPWriteTextFileResponse, a3 as ACPCreateTerminalRequest, a4 as ACPCreateTerminalResponse, a5 as ACPTerminalOutputRequest, a6 as ACPTerminalOutputResponse, a7 as ACPReleaseTerminalRequest, a8 as ACPReleaseTerminalResponse, a9 as ACPWaitForTerminalExitRequest, aa as ACPWaitForTerminalExitResponse, ab as ACPKillTerminalCommandRequest, ac as ACPKillTerminalCommandResponse, ad as ACPSessionId } from './index-BQXp4_rd.js';
|
|
2
|
+
export { ae as ACPAgentCapabilities, af as ACPAgentContext, ag as ACPAnnotations, ah as ACPAudioContent, ai as ACPAuthMethod, aj as ACPAuthenticateRequest, ak as ACPAuthenticateResponse, al as ACPAvailableCommand, am as ACPAvailableCommandsUpdate, an as ACPBlobResourceContents, ao as ACPCancelNotification, ap as ACPCancelledPermissionOutcome, aq as ACPCapability, ar as ACPClientCapabilities, as as ACPClientHandlers, at as ACPContent, au as ACPContentBlock, av as ACPContentChunk, aw as ACPContext, ax as ACPCurrentModeUpdate, ay as ACPDiff, az as ACPEmbeddedResource, aA as ACPEnvVariable, aB as ACPEnvelope, aC as ACPError, aD as ACPErrorCode, aE as ACPErrorObject, aF as ACPErrorResponse, aG as ACPFileSystemCapability, aH as ACPHttpHeader, aI as ACPImageContent, aJ as ACPImplementation, aK as ACPInitializeRequest, aL as ACPInitializeResponse, aM as ACPLoadSessionRequest, aN as ACPLoadSessionResponse, aO as ACPMcpCapabilities, aP as ACPMcpServer, aQ as ACPMcpServerHttp, aR as ACPMcpServerSse, aS as ACPMcpServerStdio, aT as ACPMessage, aU as ACPMeta, aV as ACPNewSessionRequest, aW as ACPNewSessionResponse, aX as ACPNotification, aY as ACPPermissionOption, aZ as ACPPermissionOptionId, a_ as ACPPermissionOptionKind, a$ as ACPPlan, b0 as ACPPlanEntry, b1 as ACPPlanEntryPriority, b2 as ACPPlanEntryStatus, b3 as ACPPromptCapabilities, b4 as ACPPromptRequest, b5 as ACPPromptResponse, b6 as ACPProtocolVersion, b7 as ACPRequest, b8 as ACPRequestId, b9 as ACPRequestPermissionOutcome, ba as ACPResourceLink, bb as ACPResponse, bc as ACPRole, bd as ACPSelectedPermissionOutcome, be as ACPSessionCapabilities, bf as ACPSessionInfoUpdate, bg as ACPSessionMode, bh as ACPSessionModeId, bi as ACPSessionModeState, bj as ACPSessionUpdate, bk as ACPSetSessionModeRequest, bl as ACPSetSessionModeResponse, bm as ACPStopReason, bn as ACPStreamConnection, bo as ACPStreamEvents, bp as ACPStreamOptions, bq as ACPSuccessResponse, br as ACPTerminal, bs as ACPTerminalExitStatus, bt as ACPTextContent, bu as ACPTextResourceContents, bv as ACPToolCall, bw as ACPToolCallContent, bx as ACPToolCallId, by as ACPToolCallLocation, bz as ACPToolCallStatus, bA as ACPToolCallUpdate, bB as ACPToolKind, bC as ACP_ERROR_CODES, bD as ACP_METHODS, bE as ACP_PROTOCOL_VERSION, bF as AGENT_ERROR_CODES, bG as AUTH_ERROR_CODES, bH as AUTH_METHODS, bI as AcceptanceContext, bJ as AgentAcceptanceRule, bK as AgentConnectOptions, bL as AgentConnectionOptions, bM as AgentIncludeOptions, bN as AgentLifecycle, bO as AgentMeshConnectOptions, bP as AgentMessagingRule, bQ as AgentPermissionConfig, bR as AgentPermissions, bS as AgentReconnectionEventHandler, bT as AgentReconnectionEventType, bU as AgentReconnectionOptions, bV as AgentRelationship, bW as AgentRelationshipType, bX as AgentVisibilityRule, bY as AgenticMeshStreamConfig, bZ as AgentsGetRequest, b_ as AgentsGetRequestParams, b$ as AgentsListFilter, c0 as AgentsListRequest, c1 as AgentsListRequestParams, c2 as AgentsRegisterRequest, c3 as AgentsRegisterRequestParams, c4 as AgentsResumeRequest, c5 as AgentsResumeRequestParams, c6 as AgentsResumeResponseResult, c7 as AgentsSpawnRequest, c8 as AgentsSpawnRequestParams, c9 as AgentsStopRequest, ca as AgentsStopRequestParams, cb as AgentsStopResponseResult, cc as AgentsSuspendRequest, cd as AgentsSuspendRequestParams, ce as AgentsSuspendResponseResult, cf as AgentsUnregisterRequest, cg as AgentsUnregisterRequestParams, ch as AgentsUpdateRequest, ci as AgentsUpdateRequestParams, cj as AnyMessage, ck as AuthCredentials, cl as AuthError, cm as AuthErrorCode, cn as AuthMethod, co as AuthPrincipal, cp as AuthRefreshRequest, cq as AuthRefreshRequestParams, cr as AuthRefreshResponseResult, cs as AuthResult, ct as AuthenticateRequest, cu as AuthenticateRequestParams, cv as AuthenticateResponseResult, cw as BaseConnection, cx as BroadcastAddress, cy as CAPABILITY_REQUIREMENTS, cz as CORE_METHODS, cA as ClientAcceptanceRule, cB as ClientConnectOptions, cC as ClientConnection, cD as ClientConnectionOptions, cE as ConnectRequest, cF as ConnectRequestParams, cG as CorrelationId, cH as DEFAULT_AGENT_PERMISSION_CONFIG, cI as DeliverySemantics, cJ as DirectAddress, cK as DisconnectPolicy, cL as DisconnectRequest, cM as DisconnectRequestParams, cN as ERROR_CODES, cO as EVENT_TYPES, cP as EXTENSION_METHODS, cQ as EventInput, cR as EventNotification, cS as EventNotificationParams, cT as FEDERATION_ERROR_CODES, cU as FEDERATION_METHODS, cV as FederatedAddress, cW as FederationAuth, cX as FederationConnectRequest, cY as FederationConnectRequestParams, cZ as FederationMetadata, c_ as FederationReplayConfig, c$ as FederationRouteRequest, d0 as FederationRouteRequestParams, d1 as GatewayReconnectionEvent, d2 as GatewayReconnectionEventHandler, d3 as GatewayReconnectionEventType, d4 as GatewayReconnectionOptions, d5 as GraphEdge, d6 as HierarchicalAddress, d7 as InjectDelivery, d8 as InjectDeliveryResult, d9 as InjectRequest, da as InjectRequestParams, db as InjectResponseResult, dc as JSONRPC_VERSION, dd as JoinPolicy, de as LIFECYCLE_METHODS, df as MAPNotification, dg as MAPNotificationBase, dh as MAPRequest, di as MAPRequestBase, dj as MAPResponse, dk as MAPResponseError, dl as MAPResponseSuccess, dm as MAP_METHODS, dn as MeshConnectOptions, dp as MeshPeerEndpoint, dq as MeshTransportAdapter, dr as MessageDeliveredEventData, ds as MessageFailedEventData, dt as MessageHandler, du as MessageNotification, dv as MessageNotificationParams, dw as MessagePriority, dx as MessageRelationship, dy as MessageSentEventData, dz as MessageVisibility, dA as Meta, dB as MultiAddress, dC as NOTIFICATION_METHODS, dD as NotificationHandler, dE as OBSERVATION_METHODS, dF as OverflowHandler, dG as OverflowInfo, dH as PERMISSION_METHODS, dI as PROTOCOL_ERROR_CODES, dJ as PROTOCOL_VERSION, dK as Participant, dL as ParticipantAddress, dM as PermissionAction, dN as PermissionContext, dO as PermissionParticipant, dP as PermissionResult, dQ as PermissionSystemConfig, dR as PermissionsAgentUpdatedEventData, dS as PermissionsClientUpdatedEventData, dT as PermissionsUpdateRequest, dU as PermissionsUpdateRequestParams, dV as PermissionsUpdateResponseResult, dW as RESOURCE_ERROR_CODES, dX as ROUTING_ERROR_CODES, dY as ReconnectionEventHandler, dZ as ReconnectionEventType, d_ as ReconnectionOptions, d$ as ReplayRequest, e0 as ReplayRequestParams, e1 as ReplayResponseResult, e2 as ReplayedEvent, e3 as RequestHandler, e4 as RoleAddress, e5 as SCOPE_METHODS, e6 as SESSION_METHODS, e7 as STATE_METHODS, e8 as STEERING_METHODS, e9 as STRUCTURE_METHODS, ea as ScopeAddress, eb as ScopeMessagingRule, ec as ScopeVisibilityRule, ed as ScopesCreateRequest, ee as ScopesCreateRequestParams, ef as ScopesDeleteRequest, eg as ScopesDeleteRequestParams, eh as ScopesDeleteResponseResult, ei as ScopesGetRequest, ej as ScopesGetRequestParams, ek as ScopesGetResponseResult, el as ScopesJoinRequest, em as ScopesJoinRequestParams, en as ScopesLeaveRequest, eo as ScopesLeaveRequestParams, ep as ScopesListRequest, eq as ScopesListRequestParams, er as ScopesMembersRequest, es as ScopesMembersRequestParams, et as ScopesMembersResponseResult, eu as SendPolicy, ev as SendRequest, ew as SendRequestParams, ex as ServerAuthCapabilities, ey as SessionCloseRequest, ez as SessionCloseRequestParams, eA as SessionCloseResponseResult, eB as SessionListRequest, eC as SessionListRequestParams, eD as SessionListResponseResult, eE as SessionLoadRequest, eF as SessionLoadRequestParams, eG as SessionLoadResponseResult, eH as StandardAuthMethod, eI as StateChangeHandler, eJ as StreamingCapabilities, eK as StructureGraphRequest, eL as StructureGraphRequestParams, eM as StructureGraphResponseResult, eN as StructureVisibilityRule, eO as SubscribeRequest, eP as SubscribeRequestParams, eQ as Subscription, eR as SubscriptionAckNotification, eS as SubscriptionAckParams, eT as SubscriptionOptions, eU as SubscriptionState, eV as SystemAcceptanceRule, eW as SystemAddress, eX as Timestamp, eY as TransportType, eZ as UnsubscribeRequest, e_ as UnsubscribeRequestParams, e$ as agenticMeshStream, f0 as canAgentAcceptMessage, f1 as canAgentMessageAgent, f2 as canAgentSeeAgent, f3 as canControlAgent, f4 as canJoinScope, f5 as canMessageAgent, f6 as canPerformAction, f7 as canPerformMethod, f8 as canSeeAgent, f9 as canSeeScope, fa as canSendToScope, fb as createACPStream, fc as createEvent, fd as createStreamPair, fe as createSubscription, ff as deepMergePermissions, fg as filterVisibleAgents, fh as filterVisibleEvents, fi as filterVisibleScopes, fj as hasCapability, fk as isACPEnvelope, fl as isACPErrorResponse, fm as isACPNotification, fn as isACPRequest, fo as isACPResponse, fp as isACPSuccessResponse, fq as isAgentExposed, fr as isBroadcastAddress, fs as isDirectAddress, ft as isEventTypeExposed, fu as isFederatedAddress, fv as isHierarchicalAddress, fw as isOrphanedAgent, fx as isScopeExposed, fy as isSuccessResponse, fz as mapVisibilityToRule, fA as ndJsonStream, fB as resolveAgentPermissions, fC as waitForOpen, fD as websocketStream } from './index-BQXp4_rd.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
export { monotonicFactory, ulid } from 'ulid';
|
|
5
|
+
import 'events';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* JSON-RPC 2.0 utilities for MAP protocol
|
|
@@ -108,6 +109,9 @@ declare class MAPRequestError extends Error {
|
|
|
108
109
|
static authFailed(details?: string): MAPRequestError;
|
|
109
110
|
static tokenExpired(): MAPRequestError;
|
|
110
111
|
static permissionDenied(required?: string): MAPRequestError;
|
|
112
|
+
static insufficientScope(required?: string): MAPRequestError;
|
|
113
|
+
static methodNotSupported(method: string): MAPRequestError;
|
|
114
|
+
static invalidCredentials(details?: string): MAPRequestError;
|
|
111
115
|
static addressNotFound(address: string): MAPRequestError;
|
|
112
116
|
static agentNotFound(agentId: string): MAPRequestError;
|
|
113
117
|
static scopeNotFound(scopeId: string): MAPRequestError;
|
|
@@ -1117,6 +1121,7 @@ declare const AgentSchema: z.ZodObject<{
|
|
|
1117
1121
|
state: string;
|
|
1118
1122
|
role?: string | undefined;
|
|
1119
1123
|
parent?: string | undefined;
|
|
1124
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1120
1125
|
name?: string | undefined;
|
|
1121
1126
|
capabilities?: {
|
|
1122
1127
|
_meta?: Record<string, unknown> | undefined;
|
|
@@ -1141,7 +1146,6 @@ declare const AgentSchema: z.ZodObject<{
|
|
|
1141
1146
|
canStop?: boolean | undefined;
|
|
1142
1147
|
} | undefined;
|
|
1143
1148
|
} | undefined;
|
|
1144
|
-
_meta?: Record<string, unknown> | undefined;
|
|
1145
1149
|
visibility?: "system" | "public" | "parent-only" | "scope" | undefined;
|
|
1146
1150
|
scopes?: string[] | undefined;
|
|
1147
1151
|
metadata?: Record<string, unknown> | undefined;
|
|
@@ -1166,6 +1170,7 @@ declare const AgentSchema: z.ZodObject<{
|
|
|
1166
1170
|
state: string;
|
|
1167
1171
|
role?: string | undefined;
|
|
1168
1172
|
parent?: string | undefined;
|
|
1173
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1169
1174
|
name?: string | undefined;
|
|
1170
1175
|
capabilities?: {
|
|
1171
1176
|
_meta?: Record<string, unknown> | undefined;
|
|
@@ -1190,7 +1195,6 @@ declare const AgentSchema: z.ZodObject<{
|
|
|
1190
1195
|
canStop?: boolean | undefined;
|
|
1191
1196
|
} | undefined;
|
|
1192
1197
|
} | undefined;
|
|
1193
|
-
_meta?: Record<string, unknown> | undefined;
|
|
1194
1198
|
visibility?: "system" | "public" | "parent-only" | "scope" | undefined;
|
|
1195
1199
|
scopes?: string[] | undefined;
|
|
1196
1200
|
metadata?: Record<string, unknown> | undefined;
|
|
@@ -1226,8 +1230,8 @@ declare const ScopeSchema: z.ZodObject<{
|
|
|
1226
1230
|
id: string;
|
|
1227
1231
|
parent?: string | undefined;
|
|
1228
1232
|
children?: string[] | undefined;
|
|
1229
|
-
name?: string | undefined;
|
|
1230
1233
|
_meta?: Record<string, unknown> | undefined;
|
|
1234
|
+
name?: string | undefined;
|
|
1231
1235
|
visibility?: "public" | "private" | "unlisted" | undefined;
|
|
1232
1236
|
metadata?: Record<string, unknown> | undefined;
|
|
1233
1237
|
joinPolicy?: "open" | "invite" | "approval" | undefined;
|
|
@@ -1237,8 +1241,8 @@ declare const ScopeSchema: z.ZodObject<{
|
|
|
1237
1241
|
id: string;
|
|
1238
1242
|
parent?: string | undefined;
|
|
1239
1243
|
children?: string[] | undefined;
|
|
1240
|
-
name?: string | undefined;
|
|
1241
1244
|
_meta?: Record<string, unknown> | undefined;
|
|
1245
|
+
name?: string | undefined;
|
|
1242
1246
|
visibility?: "public" | "private" | "unlisted" | undefined;
|
|
1243
1247
|
metadata?: Record<string, unknown> | undefined;
|
|
1244
1248
|
joinPolicy?: "open" | "invite" | "approval" | undefined;
|
|
@@ -1257,8 +1261,9 @@ declare const MessageMetaSchema: z.ZodObject<{
|
|
|
1257
1261
|
isResult: z.ZodOptional<z.ZodBoolean>;
|
|
1258
1262
|
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1259
1263
|
}, "strict", z.ZodTypeAny, {
|
|
1260
|
-
_meta?: Record<string, unknown> | undefined;
|
|
1261
1264
|
correlationId?: string | undefined;
|
|
1265
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1266
|
+
expiresAt?: number | undefined;
|
|
1262
1267
|
relationship?: "peer" | "parent-to-child" | "child-to-parent" | "broadcast" | "supervisor-to-supervised" | undefined;
|
|
1263
1268
|
isResult?: boolean | undefined;
|
|
1264
1269
|
causationId?: string | undefined;
|
|
@@ -1266,10 +1271,10 @@ declare const MessageMetaSchema: z.ZodObject<{
|
|
|
1266
1271
|
spanId?: string | undefined;
|
|
1267
1272
|
priority?: "urgent" | "high" | "normal" | "low" | undefined;
|
|
1268
1273
|
delivery?: "at-most-once" | "at-least-once" | "exactly-once" | undefined;
|
|
1269
|
-
expiresAt?: number | undefined;
|
|
1270
1274
|
}, {
|
|
1271
|
-
_meta?: Record<string, unknown> | undefined;
|
|
1272
1275
|
correlationId?: string | undefined;
|
|
1276
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1277
|
+
expiresAt?: number | undefined;
|
|
1273
1278
|
relationship?: "peer" | "parent-to-child" | "child-to-parent" | "broadcast" | "supervisor-to-supervised" | undefined;
|
|
1274
1279
|
isResult?: boolean | undefined;
|
|
1275
1280
|
causationId?: string | undefined;
|
|
@@ -1277,7 +1282,6 @@ declare const MessageMetaSchema: z.ZodObject<{
|
|
|
1277
1282
|
spanId?: string | undefined;
|
|
1278
1283
|
priority?: "urgent" | "high" | "normal" | "low" | undefined;
|
|
1279
1284
|
delivery?: "at-most-once" | "at-least-once" | "exactly-once" | undefined;
|
|
1280
|
-
expiresAt?: number | undefined;
|
|
1281
1285
|
}>;
|
|
1282
1286
|
declare const MessageSchema: z.ZodObject<{
|
|
1283
1287
|
id: z.ZodString;
|
|
@@ -1297,8 +1301,9 @@ declare const MessageSchema: z.ZodObject<{
|
|
|
1297
1301
|
isResult: z.ZodOptional<z.ZodBoolean>;
|
|
1298
1302
|
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1299
1303
|
}, "strict", z.ZodTypeAny, {
|
|
1300
|
-
_meta?: Record<string, unknown> | undefined;
|
|
1301
1304
|
correlationId?: string | undefined;
|
|
1305
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1306
|
+
expiresAt?: number | undefined;
|
|
1302
1307
|
relationship?: "peer" | "parent-to-child" | "child-to-parent" | "broadcast" | "supervisor-to-supervised" | undefined;
|
|
1303
1308
|
isResult?: boolean | undefined;
|
|
1304
1309
|
causationId?: string | undefined;
|
|
@@ -1306,10 +1311,10 @@ declare const MessageSchema: z.ZodObject<{
|
|
|
1306
1311
|
spanId?: string | undefined;
|
|
1307
1312
|
priority?: "urgent" | "high" | "normal" | "low" | undefined;
|
|
1308
1313
|
delivery?: "at-most-once" | "at-least-once" | "exactly-once" | undefined;
|
|
1309
|
-
expiresAt?: number | undefined;
|
|
1310
1314
|
}, {
|
|
1311
|
-
_meta?: Record<string, unknown> | undefined;
|
|
1312
1315
|
correlationId?: string | undefined;
|
|
1316
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1317
|
+
expiresAt?: number | undefined;
|
|
1313
1318
|
relationship?: "peer" | "parent-to-child" | "child-to-parent" | "broadcast" | "supervisor-to-supervised" | undefined;
|
|
1314
1319
|
isResult?: boolean | undefined;
|
|
1315
1320
|
causationId?: string | undefined;
|
|
@@ -1317,17 +1322,18 @@ declare const MessageSchema: z.ZodObject<{
|
|
|
1317
1322
|
spanId?: string | undefined;
|
|
1318
1323
|
priority?: "urgent" | "high" | "normal" | "low" | undefined;
|
|
1319
1324
|
delivery?: "at-most-once" | "at-least-once" | "exactly-once" | undefined;
|
|
1320
|
-
expiresAt?: number | undefined;
|
|
1321
1325
|
}>>;
|
|
1322
1326
|
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1323
1327
|
}, "strict", z.ZodTypeAny, {
|
|
1324
1328
|
id: string;
|
|
1325
1329
|
timestamp: number;
|
|
1326
1330
|
from: string;
|
|
1331
|
+
payload?: unknown;
|
|
1327
1332
|
_meta?: Record<string, unknown> | undefined;
|
|
1328
1333
|
meta?: {
|
|
1329
|
-
_meta?: Record<string, unknown> | undefined;
|
|
1330
1334
|
correlationId?: string | undefined;
|
|
1335
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1336
|
+
expiresAt?: number | undefined;
|
|
1331
1337
|
relationship?: "peer" | "parent-to-child" | "child-to-parent" | "broadcast" | "supervisor-to-supervised" | undefined;
|
|
1332
1338
|
isResult?: boolean | undefined;
|
|
1333
1339
|
causationId?: string | undefined;
|
|
@@ -1335,18 +1341,18 @@ declare const MessageSchema: z.ZodObject<{
|
|
|
1335
1341
|
spanId?: string | undefined;
|
|
1336
1342
|
priority?: "urgent" | "high" | "normal" | "low" | undefined;
|
|
1337
1343
|
delivery?: "at-most-once" | "at-least-once" | "exactly-once" | undefined;
|
|
1338
|
-
expiresAt?: number | undefined;
|
|
1339
1344
|
} | undefined;
|
|
1340
|
-
payload?: unknown;
|
|
1341
1345
|
to?: unknown;
|
|
1342
1346
|
}, {
|
|
1343
1347
|
id: string;
|
|
1344
1348
|
timestamp: number;
|
|
1345
1349
|
from: string;
|
|
1350
|
+
payload?: unknown;
|
|
1346
1351
|
_meta?: Record<string, unknown> | undefined;
|
|
1347
1352
|
meta?: {
|
|
1348
|
-
_meta?: Record<string, unknown> | undefined;
|
|
1349
1353
|
correlationId?: string | undefined;
|
|
1354
|
+
_meta?: Record<string, unknown> | undefined;
|
|
1355
|
+
expiresAt?: number | undefined;
|
|
1350
1356
|
relationship?: "peer" | "parent-to-child" | "child-to-parent" | "broadcast" | "supervisor-to-supervised" | undefined;
|
|
1351
1357
|
isResult?: boolean | undefined;
|
|
1352
1358
|
causationId?: string | undefined;
|
|
@@ -1354,9 +1360,7 @@ declare const MessageSchema: z.ZodObject<{
|
|
|
1354
1360
|
spanId?: string | undefined;
|
|
1355
1361
|
priority?: "urgent" | "high" | "normal" | "low" | undefined;
|
|
1356
1362
|
delivery?: "at-most-once" | "at-least-once" | "exactly-once" | undefined;
|
|
1357
|
-
expiresAt?: number | undefined;
|
|
1358
1363
|
} | undefined;
|
|
1359
|
-
payload?: unknown;
|
|
1360
1364
|
to?: unknown;
|
|
1361
1365
|
}>;
|
|
1362
1366
|
declare const EventSchema: z.ZodObject<{
|
|
@@ -1378,20 +1382,20 @@ declare const EventSchema: z.ZodObject<{
|
|
|
1378
1382
|
declare const SubscriptionFilterSchema: z.ZodObject<{
|
|
1379
1383
|
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
1384
|
scopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1381
|
-
|
|
1385
|
+
fromAgents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1382
1386
|
includeChildren: z.ZodOptional<z.ZodBoolean>;
|
|
1383
1387
|
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1384
1388
|
}, "strict", z.ZodTypeAny, {
|
|
1385
|
-
agents?: string[] | undefined;
|
|
1386
1389
|
_meta?: Record<string, unknown> | undefined;
|
|
1387
1390
|
scopes?: string[] | undefined;
|
|
1388
1391
|
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;
|
|
1392
|
+
fromAgents?: string[] | undefined;
|
|
1389
1393
|
includeChildren?: boolean | undefined;
|
|
1390
1394
|
}, {
|
|
1391
|
-
agents?: string[] | undefined;
|
|
1392
1395
|
_meta?: Record<string, unknown> | undefined;
|
|
1393
1396
|
scopes?: string[] | undefined;
|
|
1394
1397
|
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;
|
|
1398
|
+
fromAgents?: string[] | undefined;
|
|
1395
1399
|
includeChildren?: boolean | undefined;
|
|
1396
1400
|
}>;
|
|
1397
1401
|
declare const MAPErrorDataSchema: z.ZodObject<{
|
|
@@ -2407,4 +2411,617 @@ declare function toAgent(agentId: string): string;
|
|
|
2407
2411
|
*/
|
|
2408
2412
|
declare function toScope(scopeId: string): string;
|
|
2409
2413
|
|
|
2410
|
-
|
|
2414
|
+
/**
|
|
2415
|
+
* Type definitions for MAPMeshPeer
|
|
2416
|
+
*
|
|
2417
|
+
* These types define the configuration and interfaces for decentralized
|
|
2418
|
+
* P2P mesh peers that run their own MAP server.
|
|
2419
|
+
*/
|
|
2420
|
+
|
|
2421
|
+
/**
|
|
2422
|
+
* Peer endpoint for mesh connections.
|
|
2423
|
+
*/
|
|
2424
|
+
interface PeerEndpoint {
|
|
2425
|
+
/** Unique peer identifier */
|
|
2426
|
+
peerId: string;
|
|
2427
|
+
/** Transport-specific address (IP, hostname, etc.) */
|
|
2428
|
+
address: string;
|
|
2429
|
+
/** Optional port number */
|
|
2430
|
+
port?: number;
|
|
2431
|
+
/** Additional transport-specific metadata */
|
|
2432
|
+
metadata?: Record<string, unknown>;
|
|
2433
|
+
}
|
|
2434
|
+
/**
|
|
2435
|
+
* Transport adapter interface (subset used by MAPMeshPeer).
|
|
2436
|
+
* Full interface is defined in agentic-mesh.
|
|
2437
|
+
*/
|
|
2438
|
+
interface TransportAdapter {
|
|
2439
|
+
/** Whether the transport is currently active */
|
|
2440
|
+
readonly active: boolean;
|
|
2441
|
+
/** Start the transport */
|
|
2442
|
+
start(): Promise<void>;
|
|
2443
|
+
/** Stop the transport */
|
|
2444
|
+
stop(): Promise<void>;
|
|
2445
|
+
/** Connect to a peer endpoint */
|
|
2446
|
+
connect(endpoint: PeerEndpoint): Promise<boolean>;
|
|
2447
|
+
/** Check if connected to a peer */
|
|
2448
|
+
isConnected(peerId: string): boolean;
|
|
2449
|
+
/** Event emitter methods */
|
|
2450
|
+
on(event: string, handler: (...args: unknown[]) => void): void;
|
|
2451
|
+
off(event: string, handler: (...args: unknown[]) => void): void;
|
|
2452
|
+
}
|
|
2453
|
+
/**
|
|
2454
|
+
* Git sync configuration for MAPMeshPeer.
|
|
2455
|
+
*/
|
|
2456
|
+
interface MeshGitConfig {
|
|
2457
|
+
/** Enable git sync service */
|
|
2458
|
+
enabled: boolean;
|
|
2459
|
+
/** Local repository path */
|
|
2460
|
+
repoPath: string;
|
|
2461
|
+
/** HTTP port for git-remote-mesh helper (default: 3456) */
|
|
2462
|
+
httpPort?: number;
|
|
2463
|
+
/** HTTP host to bind (default: 127.0.0.1) */
|
|
2464
|
+
httpHost?: string;
|
|
2465
|
+
/** Additional git transport options */
|
|
2466
|
+
options?: Record<string, unknown>;
|
|
2467
|
+
}
|
|
2468
|
+
/**
|
|
2469
|
+
* MAP server configuration options.
|
|
2470
|
+
*/
|
|
2471
|
+
interface MeshMapServerConfig {
|
|
2472
|
+
/** System name for the MAP server */
|
|
2473
|
+
systemName?: string;
|
|
2474
|
+
/** Additional server options */
|
|
2475
|
+
[key: string]: unknown;
|
|
2476
|
+
}
|
|
2477
|
+
/**
|
|
2478
|
+
* Configuration for creating a MAPMeshPeer.
|
|
2479
|
+
*/
|
|
2480
|
+
interface MAPMeshPeerConfig {
|
|
2481
|
+
/** Unique peer identifier */
|
|
2482
|
+
peerId: string;
|
|
2483
|
+
/** Display name for this peer */
|
|
2484
|
+
peerName?: string;
|
|
2485
|
+
/** Transport adapter (from agentic-mesh) */
|
|
2486
|
+
transport: TransportAdapter;
|
|
2487
|
+
/** Git sync configuration (optional) */
|
|
2488
|
+
git?: MeshGitConfig;
|
|
2489
|
+
/** Initial peers to connect to on start */
|
|
2490
|
+
peers?: PeerEndpoint[];
|
|
2491
|
+
/** MAP server configuration */
|
|
2492
|
+
map?: MeshMapServerConfig;
|
|
2493
|
+
}
|
|
2494
|
+
/**
|
|
2495
|
+
* Configuration for creating a local agent.
|
|
2496
|
+
*/
|
|
2497
|
+
interface CreateAgentConfig {
|
|
2498
|
+
/** Agent ID (auto-generated if not provided) */
|
|
2499
|
+
agentId?: AgentId;
|
|
2500
|
+
/** Agent name */
|
|
2501
|
+
name?: string;
|
|
2502
|
+
/** Agent role */
|
|
2503
|
+
role?: string;
|
|
2504
|
+
/** Initial scopes to join */
|
|
2505
|
+
scopes?: ScopeId[];
|
|
2506
|
+
/** Agent visibility settings */
|
|
2507
|
+
visibility?: AgentVisibility;
|
|
2508
|
+
/** Initial metadata */
|
|
2509
|
+
metadata?: Record<string, unknown>;
|
|
2510
|
+
}
|
|
2511
|
+
/**
|
|
2512
|
+
* Result of a send operation.
|
|
2513
|
+
*/
|
|
2514
|
+
interface SendResult {
|
|
2515
|
+
/** IDs of participants who received the message */
|
|
2516
|
+
delivered: string[];
|
|
2517
|
+
/** Failed deliveries with reasons */
|
|
2518
|
+
failed?: Array<{
|
|
2519
|
+
participantId: string;
|
|
2520
|
+
reason: string;
|
|
2521
|
+
}>;
|
|
2522
|
+
}
|
|
2523
|
+
/**
|
|
2524
|
+
* Local agent on this peer's MapServer.
|
|
2525
|
+
*/
|
|
2526
|
+
interface LocalAgent {
|
|
2527
|
+
/** Agent ID */
|
|
2528
|
+
readonly agentId: AgentId;
|
|
2529
|
+
/** Agent name */
|
|
2530
|
+
readonly name: string;
|
|
2531
|
+
/** Agent role */
|
|
2532
|
+
readonly role?: string;
|
|
2533
|
+
/** Current agent state */
|
|
2534
|
+
readonly state: AgentState;
|
|
2535
|
+
/** Mark agent as busy */
|
|
2536
|
+
busy(): Promise<void>;
|
|
2537
|
+
/** Mark agent as idle */
|
|
2538
|
+
idle(): Promise<void>;
|
|
2539
|
+
/** Update agent state */
|
|
2540
|
+
updateState(state: AgentState): Promise<void>;
|
|
2541
|
+
/** Update agent metadata */
|
|
2542
|
+
updateMetadata(metadata: Record<string, unknown>): Promise<void>;
|
|
2543
|
+
/** Send a message */
|
|
2544
|
+
send(to: Address, payload: unknown, meta?: MessageMeta): Promise<SendResult>;
|
|
2545
|
+
/** Register message handler */
|
|
2546
|
+
onMessage(handler: (message: Message) => void | Promise<void>): () => void;
|
|
2547
|
+
/** Unregister this agent */
|
|
2548
|
+
unregister(reason?: string): Promise<void>;
|
|
2549
|
+
}
|
|
2550
|
+
/**
|
|
2551
|
+
* Configuration for creating a scope.
|
|
2552
|
+
*/
|
|
2553
|
+
interface CreateScopeConfig {
|
|
2554
|
+
/** Scope ID (auto-generated if not provided) */
|
|
2555
|
+
scopeId?: ScopeId;
|
|
2556
|
+
/** Scope name */
|
|
2557
|
+
name?: string;
|
|
2558
|
+
/** Scope description */
|
|
2559
|
+
description?: string;
|
|
2560
|
+
/** Scope visibility */
|
|
2561
|
+
visibility?: ScopeVisibility;
|
|
2562
|
+
/** Scope metadata */
|
|
2563
|
+
metadata?: Record<string, unknown>;
|
|
2564
|
+
}
|
|
2565
|
+
/**
|
|
2566
|
+
* Options for sync operations.
|
|
2567
|
+
*/
|
|
2568
|
+
interface SyncOptions {
|
|
2569
|
+
/** Branch to sync (default: current branch) */
|
|
2570
|
+
branch?: string;
|
|
2571
|
+
/** Remote name to use */
|
|
2572
|
+
remoteName?: string;
|
|
2573
|
+
/** Bidirectional sync (pull then push) */
|
|
2574
|
+
bidirectional?: boolean;
|
|
2575
|
+
/** Force sync (overwrite conflicts) */
|
|
2576
|
+
force?: boolean;
|
|
2577
|
+
/** Use rebase instead of merge */
|
|
2578
|
+
rebase?: boolean;
|
|
2579
|
+
}
|
|
2580
|
+
/**
|
|
2581
|
+
* Options for pull operations.
|
|
2582
|
+
*/
|
|
2583
|
+
interface PullOptions {
|
|
2584
|
+
/** Use rebase instead of merge */
|
|
2585
|
+
rebase?: boolean;
|
|
2586
|
+
/** Fast-forward only (fail if not possible) */
|
|
2587
|
+
ffOnly?: boolean;
|
|
2588
|
+
}
|
|
2589
|
+
/**
|
|
2590
|
+
* Options for push operations.
|
|
2591
|
+
*/
|
|
2592
|
+
interface PushOptions {
|
|
2593
|
+
/** Force push */
|
|
2594
|
+
force?: boolean;
|
|
2595
|
+
/** Set upstream tracking */
|
|
2596
|
+
setUpstream?: boolean;
|
|
2597
|
+
/** Push all branches */
|
|
2598
|
+
all?: boolean;
|
|
2599
|
+
/** Push tags */
|
|
2600
|
+
tags?: boolean;
|
|
2601
|
+
}
|
|
2602
|
+
/**
|
|
2603
|
+
* Options for clone operations.
|
|
2604
|
+
*/
|
|
2605
|
+
interface CloneOptions {
|
|
2606
|
+
/** Branch to clone */
|
|
2607
|
+
branch?: string;
|
|
2608
|
+
/** Shallow clone depth */
|
|
2609
|
+
depth?: number;
|
|
2610
|
+
/** Clone as bare repository */
|
|
2611
|
+
bare?: boolean;
|
|
2612
|
+
}
|
|
2613
|
+
/**
|
|
2614
|
+
* Result of a git sync operation.
|
|
2615
|
+
*/
|
|
2616
|
+
interface SyncResult {
|
|
2617
|
+
/** Whether operation succeeded */
|
|
2618
|
+
success: boolean;
|
|
2619
|
+
/** Type of operation performed */
|
|
2620
|
+
operation: 'fetch' | 'pull' | 'push' | 'clone' | 'sync';
|
|
2621
|
+
/** Peer ID involved */
|
|
2622
|
+
peerId: string;
|
|
2623
|
+
/** Branch involved */
|
|
2624
|
+
branch?: string;
|
|
2625
|
+
/** Commits transferred */
|
|
2626
|
+
commits?: string[];
|
|
2627
|
+
/** Error message if failed */
|
|
2628
|
+
error?: string;
|
|
2629
|
+
/** Command output */
|
|
2630
|
+
output?: string;
|
|
2631
|
+
}
|
|
2632
|
+
/**
|
|
2633
|
+
* Git sync client for a specific repository.
|
|
2634
|
+
*/
|
|
2635
|
+
interface GitSyncClient {
|
|
2636
|
+
/** Bidirectional sync with a peer */
|
|
2637
|
+
sync(peerId: string, options?: SyncOptions): Promise<SyncResult>;
|
|
2638
|
+
/** Fetch from a peer */
|
|
2639
|
+
fetch(peerId: string, branch?: string): Promise<SyncResult>;
|
|
2640
|
+
/** Pull from a peer */
|
|
2641
|
+
pull(peerId: string, branch?: string, options?: PullOptions): Promise<SyncResult>;
|
|
2642
|
+
/** Push to a peer */
|
|
2643
|
+
push(peerId: string, branch?: string, options?: PushOptions): Promise<SyncResult>;
|
|
2644
|
+
/** Clone from a peer */
|
|
2645
|
+
clone(peerId: string, destPath: string, options?: CloneOptions): Promise<SyncResult>;
|
|
2646
|
+
/** List refs on remote peer */
|
|
2647
|
+
listRemoteRefs(peerId: string): Promise<Array<{
|
|
2648
|
+
ref: string;
|
|
2649
|
+
sha: string;
|
|
2650
|
+
}>>;
|
|
2651
|
+
}
|
|
2652
|
+
/**
|
|
2653
|
+
* Git sync service exposed by MAPMeshPeer.
|
|
2654
|
+
*/
|
|
2655
|
+
interface GitSyncService {
|
|
2656
|
+
/** Whether the git service is running */
|
|
2657
|
+
readonly isRunning: boolean;
|
|
2658
|
+
/** HTTP port for git-remote-mesh helper */
|
|
2659
|
+
readonly httpPort: number;
|
|
2660
|
+
/** Create a sync client for a specific repository */
|
|
2661
|
+
createSyncClient(repoPath: string): GitSyncClient;
|
|
2662
|
+
/** Sync with a peer */
|
|
2663
|
+
sync(peerId: string, options?: SyncOptions): Promise<SyncResult>;
|
|
2664
|
+
/** Pull from a peer */
|
|
2665
|
+
pull(peerId: string, branch?: string, options?: PullOptions): Promise<SyncResult>;
|
|
2666
|
+
/** Push to a peer */
|
|
2667
|
+
push(peerId: string, branch?: string, options?: PushOptions): Promise<SyncResult>;
|
|
2668
|
+
/** Clone from a peer */
|
|
2669
|
+
clone(peerId: string, destPath: string, options?: CloneOptions): Promise<SyncResult>;
|
|
2670
|
+
}
|
|
2671
|
+
/**
|
|
2672
|
+
* Event subscription for MAPMeshPeer.
|
|
2673
|
+
*/
|
|
2674
|
+
interface MeshEventSubscription {
|
|
2675
|
+
/** Subscription ID */
|
|
2676
|
+
readonly id: SubscriptionId;
|
|
2677
|
+
/** Async iterator for events */
|
|
2678
|
+
[Symbol.asyncIterator](): AsyncIterator<Event>;
|
|
2679
|
+
/** Unsubscribe */
|
|
2680
|
+
unsubscribe(): Promise<void>;
|
|
2681
|
+
}
|
|
2682
|
+
/**
|
|
2683
|
+
* Events emitted by MAPMeshPeer.
|
|
2684
|
+
*/
|
|
2685
|
+
interface MAPMeshPeerEvents {
|
|
2686
|
+
/** Peer started */
|
|
2687
|
+
started: () => void;
|
|
2688
|
+
/** Peer stopped */
|
|
2689
|
+
stopped: () => void;
|
|
2690
|
+
/** Connected to a peer */
|
|
2691
|
+
'peer:connected': (peerId: string, endpoint: PeerEndpoint) => void;
|
|
2692
|
+
/** Disconnected from a peer */
|
|
2693
|
+
'peer:disconnected': (peerId: string, reason?: string) => void;
|
|
2694
|
+
/** Agent registered on this peer */
|
|
2695
|
+
'agent:registered': (agent: Agent) => void;
|
|
2696
|
+
/** Agent unregistered from this peer */
|
|
2697
|
+
'agent:unregistered': (agent: Agent) => void;
|
|
2698
|
+
/** Scope created */
|
|
2699
|
+
'scope:created': (scope: Scope) => void;
|
|
2700
|
+
/** Scope deleted */
|
|
2701
|
+
'scope:deleted': (scope: Scope) => void;
|
|
2702
|
+
/** Error occurred */
|
|
2703
|
+
error: (error: Error) => void;
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
/**
|
|
2707
|
+
* MAPMeshPeer - Decentralized P2P mesh peer
|
|
2708
|
+
*
|
|
2709
|
+
* Wraps agentic-mesh's MeshPeer to provide a unified interface for
|
|
2710
|
+
* decentralized MAP networks where each peer runs its own MapServer.
|
|
2711
|
+
*
|
|
2712
|
+
* @module
|
|
2713
|
+
*/
|
|
2714
|
+
|
|
2715
|
+
/**
|
|
2716
|
+
* Decentralized P2P mesh peer with MAP protocol support.
|
|
2717
|
+
*
|
|
2718
|
+
* Each MAPMeshPeer runs its own MapServer and can connect to other peers
|
|
2719
|
+
* for agent discovery, messaging, and git synchronization.
|
|
2720
|
+
*
|
|
2721
|
+
* @example
|
|
2722
|
+
* ```typescript
|
|
2723
|
+
* import { createNebulaTransport } from 'agentic-mesh';
|
|
2724
|
+
* import { MAPMeshPeer } from '@multi-agent-protocol/sdk';
|
|
2725
|
+
*
|
|
2726
|
+
* // Create transport
|
|
2727
|
+
* const transport = createNebulaTransport({
|
|
2728
|
+
* configPath: '/etc/nebula/config.yml',
|
|
2729
|
+
* });
|
|
2730
|
+
*
|
|
2731
|
+
* // Create mesh peer
|
|
2732
|
+
* const peer = await MAPMeshPeer.create({
|
|
2733
|
+
* peerId: 'worker-1',
|
|
2734
|
+
* peerName: 'Worker Node 1',
|
|
2735
|
+
* transport,
|
|
2736
|
+
* git: {
|
|
2737
|
+
* enabled: true,
|
|
2738
|
+
* repoPath: '/workspace/project',
|
|
2739
|
+
* },
|
|
2740
|
+
* peers: [
|
|
2741
|
+
* { peerId: 'coordinator', address: '10.0.0.1', port: 4242 },
|
|
2742
|
+
* ],
|
|
2743
|
+
* });
|
|
2744
|
+
*
|
|
2745
|
+
* // Start the peer
|
|
2746
|
+
* await peer.start();
|
|
2747
|
+
*
|
|
2748
|
+
* // Create a local agent
|
|
2749
|
+
* const agent = await peer.createAgent({
|
|
2750
|
+
* name: 'DataProcessor',
|
|
2751
|
+
* role: 'processor',
|
|
2752
|
+
* });
|
|
2753
|
+
*
|
|
2754
|
+
* // Connect to another peer
|
|
2755
|
+
* await peer.connectToPeer({ peerId: 'worker-2', address: '10.0.0.3' });
|
|
2756
|
+
*
|
|
2757
|
+
* // Sync code with connected peer
|
|
2758
|
+
* await peer.git?.sync('worker-2', { branch: 'main' });
|
|
2759
|
+
*
|
|
2760
|
+
* // Clean shutdown
|
|
2761
|
+
* await peer.stop();
|
|
2762
|
+
* ```
|
|
2763
|
+
*/
|
|
2764
|
+
declare class MAPMeshPeer {
|
|
2765
|
+
#private;
|
|
2766
|
+
private constructor();
|
|
2767
|
+
/**
|
|
2768
|
+
* Create a new MAPMeshPeer.
|
|
2769
|
+
*
|
|
2770
|
+
* Requires `agentic-mesh` to be installed as a peer dependency.
|
|
2771
|
+
*
|
|
2772
|
+
* @param config - Peer configuration
|
|
2773
|
+
* @returns Promise resolving to the created peer (not yet started)
|
|
2774
|
+
*/
|
|
2775
|
+
static create(config: MAPMeshPeerConfig): Promise<MAPMeshPeer>;
|
|
2776
|
+
/** Unique peer identifier */
|
|
2777
|
+
get peerId(): string;
|
|
2778
|
+
/** Display name for this peer */
|
|
2779
|
+
get peerName(): string;
|
|
2780
|
+
/** Whether the peer is currently running */
|
|
2781
|
+
get isRunning(): boolean;
|
|
2782
|
+
/** List of connected peer IDs */
|
|
2783
|
+
get connectedPeers(): string[];
|
|
2784
|
+
/** Git sync service (null if git not enabled) */
|
|
2785
|
+
get git(): GitSyncService | null;
|
|
2786
|
+
/**
|
|
2787
|
+
* Start the mesh peer.
|
|
2788
|
+
*
|
|
2789
|
+
* This starts the transport, MAP server, and git service (if enabled),
|
|
2790
|
+
* then connects to any initial peers specified in the config.
|
|
2791
|
+
*/
|
|
2792
|
+
start(): Promise<void>;
|
|
2793
|
+
/**
|
|
2794
|
+
* Stop the mesh peer.
|
|
2795
|
+
*
|
|
2796
|
+
* This disconnects from all peers, unregisters all agents,
|
|
2797
|
+
* stops the git service, MAP server, and transport.
|
|
2798
|
+
*/
|
|
2799
|
+
stop(): Promise<void>;
|
|
2800
|
+
/**
|
|
2801
|
+
* Connect to a remote peer.
|
|
2802
|
+
*
|
|
2803
|
+
* After connecting, agents on both peers will be discoverable
|
|
2804
|
+
* and messages can be routed between them.
|
|
2805
|
+
*
|
|
2806
|
+
* @param endpoint - Peer endpoint to connect to
|
|
2807
|
+
*/
|
|
2808
|
+
connectToPeer(endpoint: PeerEndpoint): Promise<void>;
|
|
2809
|
+
/**
|
|
2810
|
+
* Disconnect from a peer.
|
|
2811
|
+
*
|
|
2812
|
+
* @param peerId - ID of peer to disconnect from
|
|
2813
|
+
* @param reason - Optional reason for disconnecting
|
|
2814
|
+
*/
|
|
2815
|
+
disconnectFromPeer(peerId: string, reason?: string): Promise<void>;
|
|
2816
|
+
/**
|
|
2817
|
+
* Check if connected to a specific peer.
|
|
2818
|
+
*
|
|
2819
|
+
* @param peerId - Peer ID to check
|
|
2820
|
+
* @returns true if connected
|
|
2821
|
+
*/
|
|
2822
|
+
isConnectedTo(peerId: string): boolean;
|
|
2823
|
+
/**
|
|
2824
|
+
* Create and register a local agent on this peer's MapServer.
|
|
2825
|
+
*
|
|
2826
|
+
* @param config - Agent configuration
|
|
2827
|
+
* @returns The created agent
|
|
2828
|
+
*/
|
|
2829
|
+
createAgent(config: CreateAgentConfig): Promise<LocalAgent>;
|
|
2830
|
+
/**
|
|
2831
|
+
* Get a local agent by ID.
|
|
2832
|
+
*
|
|
2833
|
+
* @param agentId - Agent ID to look up
|
|
2834
|
+
* @returns The agent, or undefined if not found
|
|
2835
|
+
*/
|
|
2836
|
+
getAgent(agentId: AgentId): LocalAgent | undefined;
|
|
2837
|
+
/**
|
|
2838
|
+
* Get all local agents on this peer.
|
|
2839
|
+
*/
|
|
2840
|
+
getLocalAgents(): Agent[];
|
|
2841
|
+
/**
|
|
2842
|
+
* Get all known agents (local and discovered from connected peers).
|
|
2843
|
+
*/
|
|
2844
|
+
getAllAgents(): Agent[];
|
|
2845
|
+
/**
|
|
2846
|
+
* Create a scope on this peer's MapServer.
|
|
2847
|
+
*
|
|
2848
|
+
* @param config - Scope configuration
|
|
2849
|
+
* @returns The created scope
|
|
2850
|
+
*/
|
|
2851
|
+
createScope(config: CreateScopeConfig): Scope;
|
|
2852
|
+
/**
|
|
2853
|
+
* Get a scope by ID.
|
|
2854
|
+
*
|
|
2855
|
+
* @param scopeId - Scope ID to look up
|
|
2856
|
+
* @returns The scope, or undefined if not found
|
|
2857
|
+
*/
|
|
2858
|
+
getScope(scopeId: ScopeId): Scope | undefined;
|
|
2859
|
+
/**
|
|
2860
|
+
* List all scopes on this peer.
|
|
2861
|
+
*/
|
|
2862
|
+
listScopes(): Scope[];
|
|
2863
|
+
/**
|
|
2864
|
+
* Send a message from an agent to an address.
|
|
2865
|
+
*
|
|
2866
|
+
* Messages are routed to local agents or forwarded to connected peers.
|
|
2867
|
+
*
|
|
2868
|
+
* @param from - Sending agent ID
|
|
2869
|
+
* @param to - Destination address
|
|
2870
|
+
* @param payload - Message payload
|
|
2871
|
+
* @param meta - Optional message metadata
|
|
2872
|
+
* @returns Send result with delivery status
|
|
2873
|
+
*/
|
|
2874
|
+
send(from: AgentId, to: Address, payload: unknown, meta?: MessageMeta): Promise<SendResult>;
|
|
2875
|
+
/**
|
|
2876
|
+
* Subscribe to events from this peer's MapServer.
|
|
2877
|
+
*
|
|
2878
|
+
* @param filter - Optional filter for event types
|
|
2879
|
+
* @returns Event subscription
|
|
2880
|
+
*/
|
|
2881
|
+
subscribe(filter?: SubscriptionFilter): MeshEventSubscription;
|
|
2882
|
+
/**
|
|
2883
|
+
* Register a handler for peer connection events.
|
|
2884
|
+
*
|
|
2885
|
+
* @param handler - Function called when a peer connects
|
|
2886
|
+
* @returns Unsubscribe function
|
|
2887
|
+
*/
|
|
2888
|
+
onPeerConnected(handler: (peerId: string, endpoint: PeerEndpoint) => void): () => void;
|
|
2889
|
+
/**
|
|
2890
|
+
* Register a handler for peer disconnection events.
|
|
2891
|
+
*
|
|
2892
|
+
* @param handler - Function called when a peer disconnects
|
|
2893
|
+
* @returns Unsubscribe function
|
|
2894
|
+
*/
|
|
2895
|
+
onPeerDisconnected(handler: (peerId: string, reason?: string) => void): () => void;
|
|
2896
|
+
/**
|
|
2897
|
+
* Register a handler for agent registration events.
|
|
2898
|
+
*
|
|
2899
|
+
* @param handler - Function called when an agent registers
|
|
2900
|
+
* @returns Unsubscribe function
|
|
2901
|
+
*/
|
|
2902
|
+
onAgentRegistered(handler: (agent: Agent) => void): () => void;
|
|
2903
|
+
/**
|
|
2904
|
+
* Register a handler for agent unregistration events.
|
|
2905
|
+
*
|
|
2906
|
+
* @param handler - Function called when an agent unregisters
|
|
2907
|
+
* @returns Unsubscribe function
|
|
2908
|
+
*/
|
|
2909
|
+
onAgentUnregistered(handler: (agent: Agent) => void): () => void;
|
|
2910
|
+
/**
|
|
2911
|
+
* Register a handler for error events.
|
|
2912
|
+
*
|
|
2913
|
+
* @param handler - Function called when an error occurs
|
|
2914
|
+
* @returns Unsubscribe function
|
|
2915
|
+
*/
|
|
2916
|
+
onError(handler: (error: Error) => void): () => void;
|
|
2917
|
+
}
|
|
2918
|
+
|
|
2919
|
+
/**
|
|
2920
|
+
* ACPAgentAdapter - Agent-side helper for ACP-over-MAP.
|
|
2921
|
+
*
|
|
2922
|
+
* Simplifies implementing ACP-compatible agents by handling the
|
|
2923
|
+
* MAP↔ACP translation layer automatically.
|
|
2924
|
+
*
|
|
2925
|
+
* @module
|
|
2926
|
+
*/
|
|
2927
|
+
|
|
2928
|
+
/**
|
|
2929
|
+
* Adapter for implementing ACP-compatible agents.
|
|
2930
|
+
*
|
|
2931
|
+
* Handles the ACP envelope protocol, request routing, and provides
|
|
2932
|
+
* helper methods for agent→client communication.
|
|
2933
|
+
*
|
|
2934
|
+
* @example
|
|
2935
|
+
* ```typescript
|
|
2936
|
+
* const mapAgent = await AgentConnection.connect('ws://localhost:8080', {
|
|
2937
|
+
* name: 'CodingAgent',
|
|
2938
|
+
* capabilities: { protocols: ['acp'], acp: { version: '2024-10-07' } }
|
|
2939
|
+
* });
|
|
2940
|
+
*
|
|
2941
|
+
* const adapter = new ACPAgentAdapter(mapAgent, {
|
|
2942
|
+
* initialize: async (params, ctx) => ({
|
|
2943
|
+
* protocolVersion: 20241007,
|
|
2944
|
+
* agentInfo: { name: 'CodingAgent', version: '1.0.0' },
|
|
2945
|
+
* agentCapabilities: { loadSession: true }
|
|
2946
|
+
* }),
|
|
2947
|
+
* newSession: async (params, ctx) => ({
|
|
2948
|
+
* sessionId: generateId()
|
|
2949
|
+
* }),
|
|
2950
|
+
* prompt: async (params, ctx) => {
|
|
2951
|
+
* await adapter.sendSessionUpdate(ctx.streamId, {
|
|
2952
|
+
* sessionId: params.sessionId,
|
|
2953
|
+
* update: { sessionUpdate: 'agent_message_chunk', content: { type: 'text', text: 'Hello!' } }
|
|
2954
|
+
* });
|
|
2955
|
+
* return { stopReason: 'end_turn' };
|
|
2956
|
+
* },
|
|
2957
|
+
* cancel: async (params, ctx) => {}
|
|
2958
|
+
* });
|
|
2959
|
+
* ```
|
|
2960
|
+
*/
|
|
2961
|
+
declare class ACPAgentAdapter {
|
|
2962
|
+
#private;
|
|
2963
|
+
/**
|
|
2964
|
+
* Create a new ACP agent adapter.
|
|
2965
|
+
*
|
|
2966
|
+
* @param mapAgent - The underlying MAP agent connection
|
|
2967
|
+
* @param handler - Handler implementing ACP agent methods
|
|
2968
|
+
* @param options - Optional configuration
|
|
2969
|
+
*/
|
|
2970
|
+
constructor(mapAgent: AgentConnection, handler: ACPAgentHandler, options?: {
|
|
2971
|
+
clientRequestTimeout?: number;
|
|
2972
|
+
});
|
|
2973
|
+
/**
|
|
2974
|
+
* Send a session update notification to the client.
|
|
2975
|
+
*/
|
|
2976
|
+
sendSessionUpdate(streamId: string, notification: ACPSessionNotification): Promise<void>;
|
|
2977
|
+
/**
|
|
2978
|
+
* Request permission from the client.
|
|
2979
|
+
*/
|
|
2980
|
+
requestPermission(streamId: string, request: ACPRequestPermissionRequest): Promise<ACPRequestPermissionResponse>;
|
|
2981
|
+
/**
|
|
2982
|
+
* Read a text file from the client.
|
|
2983
|
+
*/
|
|
2984
|
+
readTextFile(streamId: string, request: ACPReadTextFileRequest): Promise<ACPReadTextFileResponse>;
|
|
2985
|
+
/**
|
|
2986
|
+
* Write a text file on the client.
|
|
2987
|
+
*/
|
|
2988
|
+
writeTextFile(streamId: string, request: ACPWriteTextFileRequest): Promise<ACPWriteTextFileResponse>;
|
|
2989
|
+
/**
|
|
2990
|
+
* Create a terminal on the client.
|
|
2991
|
+
*/
|
|
2992
|
+
createTerminal(streamId: string, request: ACPCreateTerminalRequest): Promise<ACPCreateTerminalResponse>;
|
|
2993
|
+
/**
|
|
2994
|
+
* Get terminal output from the client.
|
|
2995
|
+
*/
|
|
2996
|
+
terminalOutput(streamId: string, request: ACPTerminalOutputRequest): Promise<ACPTerminalOutputResponse>;
|
|
2997
|
+
/**
|
|
2998
|
+
* Release a terminal on the client.
|
|
2999
|
+
*/
|
|
3000
|
+
releaseTerminal(streamId: string, request: ACPReleaseTerminalRequest): Promise<ACPReleaseTerminalResponse>;
|
|
3001
|
+
/**
|
|
3002
|
+
* Wait for a terminal to exit on the client.
|
|
3003
|
+
*/
|
|
3004
|
+
waitForTerminalExit(streamId: string, request: ACPWaitForTerminalExitRequest): Promise<ACPWaitForTerminalExitResponse>;
|
|
3005
|
+
/**
|
|
3006
|
+
* Kill a terminal command on the client.
|
|
3007
|
+
*/
|
|
3008
|
+
killTerminal(streamId: string, request: ACPKillTerminalCommandRequest): Promise<ACPKillTerminalCommandResponse>;
|
|
3009
|
+
/**
|
|
3010
|
+
* Get the current session ID for a stream.
|
|
3011
|
+
*/
|
|
3012
|
+
getSessionId(streamId: string): ACPSessionId | null;
|
|
3013
|
+
/**
|
|
3014
|
+
* Get the client participant ID for a stream.
|
|
3015
|
+
*/
|
|
3016
|
+
getClientParticipantId(streamId: string): ParticipantId | undefined;
|
|
3017
|
+
/**
|
|
3018
|
+
* Check if a stream is active.
|
|
3019
|
+
*/
|
|
3020
|
+
hasStream(streamId: string): boolean;
|
|
3021
|
+
/**
|
|
3022
|
+
* Remove a stream context (e.g., on disconnect).
|
|
3023
|
+
*/
|
|
3024
|
+
removeStream(streamId: string): boolean;
|
|
3025
|
+
}
|
|
3026
|
+
|
|
3027
|
+
export { ACPAgentAdapter, ACPAgentHandler, ACPCreateTerminalRequest, ACPCreateTerminalResponse, ACPKillTerminalCommandRequest, ACPKillTerminalCommandResponse, ACPReadTextFileRequest, ACPReadTextFileResponse, ACPReleaseTerminalRequest, ACPReleaseTerminalResponse, ACPRequestPermissionRequest, ACPRequestPermissionResponse, ACPSessionId, ACPSessionNotification, ACPTerminalOutputRequest, ACPTerminalOutputResponse, ACPWaitForTerminalExitRequest, ACPWaitForTerminalExitResponse, ACPWriteTextFileRequest, ACPWriteTextFileResponse, Address, type AddressComponents, AddressSchema, type AddressType, type AddressValidated, Agent, AgentConnection, type AgentExposure, AgentId, AgentIdSchema, type AgentIdValidated, AgentLifecycleSchema, AgentRelationshipSchema, AgentSchema, AgentState, AgentStateSchema, type AgentStateValidated, type AgentValidated, AgentVisibility, AgentVisibilitySchema, AgentsGetResponseResult, AgentsListResponseResult, AgentsRegisterResponseResult, AgentsSpawnResponseResult, AgentsUnregisterResponseResult, AgentsUpdateResponseResult, BaseConnectionOptions, BroadcastAddressSchema, type CapabilityPath, type CausalBufferPushResult, type CausalEvent, CausalEventBuffer, type CausalEventBufferOptions, type CloneOptions, ConnectResponseResult, type ConnectedParticipant, ConnectionState, CorrelationIdSchema, type CreateAgentConfig, type CreateEnvelopeOptions, type CreateScopeConfig, 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, type GitSyncClient, type GitSyncService, HierarchicalAddressSchema, InvalidAddressError, JsonRpcVersionSchema, type LocalAgent, MAPConnectionError, MAPError, MAPErrorData, MAPErrorDataSchema, MAPErrorSchema, type MAPErrorValidated, MAPMeshPeer, type MAPMeshPeerConfig, type MAPMeshPeerEvents, MAPNotificationSchema, type MAPNotificationValidated, MAPRequestError, MAPRequestSchema, type MAPRequestValidated, MAPResponseErrorSchema, MAPResponseSchema, MAPResponseSuccessSchema, type MAPResponseValidated, type MAPRouter, type MAPRouterConfig, type MAPRouterFactory, MAPTimeoutError, METHOD_REGISTRY, type MeshEventSubscription, type MeshGitConfig, type MeshMapServerConfig, Message, MessageId, MessageIdSchema, type MessageIdValidated, MessageMeta, 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 PeerEndpoint, type ProcessEnvelopeResult, ProtocolVersion, ProtocolVersionSchema, type PullOptions, type PushOptions, RequestId, RequestIdSchema, type RetryCallbacks, type RetryPolicy, type RetryState, RoleAddressSchema, type RouterLimits, Scope, ScopeAddressSchema, type ScopeExposure, ScopeId, ScopeIdSchema, type ScopeIdValidated, ScopeJoinPolicySchema, ScopeSchema, ScopeSendPolicySchema, type ScopeValidated, ScopeVisibility, ScopeVisibilitySchema, ScopesCreateResponseResult, ScopesJoinResponseResult, ScopesLeaveResponseResult, ScopesListResponseResult, SendResponseResult, type SendResult, SessionId, SessionIdSchema, type SessionIdValidated, SessionInfo, Stream, SubscribeResponseResult, SubscriptionFilter, SubscriptionFilterSchema, type SubscriptionFilterValidated, SubscriptionId, SubscriptionIdSchema, type SyncOptions, type SyncResult, SystemAddressSchema, type SystemExposure, TimestampSchema, type TransportAdapter, 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, extractId, extractType, formatAddress, getEnvelopeRoutingInfo, getMethodInfo, getMethodsByCategory, getRequiredCapabilities, hasRequiredCapabilities, isAddress, isAgentAddress, isEnvelopeAtDestination, isErrorResponse, isNotification, isRequest, isResponse, isScopeAddress, isValidEnvelope, isValidUlid, parseAddress, processFederationEnvelope, retryable, sleep, sortCausalOrder, toAgent, toScope, ulidTimestamp, unwrapEnvelope, validateCausalOrder, withPayload, withRetry };
|