@multi-agent-protocol/sdk 0.0.7 → 0.0.9

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.
@@ -1,4 +1,4 @@
1
- import { P as ParticipantCapabilities, fE as SystemExposure, d as FederationRoutingConfig, S as Stream, cw as BaseConnection, f as SessionId, A as AgentId, m as Agent, l as ScopeId, n as Scope, c as Message, q as Event, j as ParticipantId, L as SubscriptionId, cD as ClientConnectionOptions, cC as ClientConnection, c1 as AgentsListRequestParams, eq as ScopesListRequestParams, p as SubscriptionFilter, eQ as Subscription, e as EventType, bL as AgentConnectionOptions, W as AgentConnection } from './index-BQXp4_rd.cjs';
1
+ import { P as ParticipantCapabilities, gY as SystemExposure, d as FederationRoutingConfig, S as Stream, cy as BaseConnection, f as SessionId, A as AgentId, n as Agent, m as ScopeId, o as Scope, c as Message, r as Event, k as ParticipantId, N as SubscriptionId, cF as ClientConnectionOptions, cE as ClientConnection, c3 as AgentsListRequestParams, fv as ScopesListRequestParams, q as SubscriptionFilter, fV as Subscription, e as EventType, bM as AgentConnectionOptions, X as AgentConnection } from './index-J32EeqzO.cjs';
2
2
  import 'events';
3
3
 
4
4
  /**
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { P as ParticipantCapabilities, fE as SystemExposure, d as FederationRoutingConfig, S as Stream, cw as BaseConnection, f as SessionId, A as AgentId, m as Agent, l as ScopeId, n as Scope, c as Message, q as Event, j as ParticipantId, L as SubscriptionId, cD as ClientConnectionOptions, cC as ClientConnection, c1 as AgentsListRequestParams, eq as ScopesListRequestParams, p as SubscriptionFilter, eQ as Subscription, e as EventType, bL as AgentConnectionOptions, W as AgentConnection } from './index-BQXp4_rd.js';
1
+ import { P as ParticipantCapabilities, gY as SystemExposure, d as FederationRoutingConfig, S as Stream, cy as BaseConnection, f as SessionId, A as AgentId, n as Agent, m as ScopeId, o as Scope, c as Message, r as Event, k as ParticipantId, N as SubscriptionId, cF as ClientConnectionOptions, cE as ClientConnection, c3 as AgentsListRequestParams, fv as ScopesListRequestParams, q as SubscriptionFilter, fV as Subscription, e as EventType, bM as AgentConnectionOptions, X as AgentConnection } from './index-J32EeqzO.js';
2
2
  import 'events';
3
3
 
4
4
  /**
package/dist/testing.js CHANGED
@@ -200,6 +200,21 @@ var PERMISSION_METHODS = {
200
200
  var FEDERATION_METHODS = {
201
201
  FEDERATION_ROUTE: "map/federation/route"
202
202
  };
203
+ var MAIL_METHODS = {
204
+ MAIL_CREATE: "mail/create",
205
+ MAIL_GET: "mail/get",
206
+ MAIL_LIST: "mail/list",
207
+ MAIL_CLOSE: "mail/close",
208
+ MAIL_JOIN: "mail/join",
209
+ MAIL_LEAVE: "mail/leave",
210
+ MAIL_INVITE: "mail/invite",
211
+ MAIL_TURN: "mail/turn",
212
+ MAIL_TURNS_LIST: "mail/turns/list",
213
+ MAIL_THREAD_CREATE: "mail/thread/create",
214
+ MAIL_THREAD_LIST: "mail/thread/list",
215
+ MAIL_SUMMARY: "mail/summary",
216
+ MAIL_REPLAY: "mail/replay"
217
+ };
203
218
  var NOTIFICATION_METHODS = {
204
219
  EVENT: "map/event",
205
220
  MESSAGE: "map/message",
@@ -248,7 +263,24 @@ var FEDERATION_ERROR_CODES = {
248
263
  /** Message has already visited this system (loop detected) */
249
264
  FEDERATION_LOOP_DETECTED: 5010,
250
265
  /** Message exceeded maximum hop count */
251
- FEDERATION_MAX_HOPS_EXCEEDED: 5011
266
+ FEDERATION_MAX_HOPS_EXCEEDED: 5011,
267
+ /** DID document resolution failed (network error, invalid document, etc.) */
268
+ FEDERATION_DID_RESOLUTION_FAILED: 5004,
269
+ /** DID proof verification failed (bad signature, expired, wrong challenge, etc.) */
270
+ FEDERATION_DID_PROOF_INVALID: 5005
271
+ };
272
+ var MAIL_ERROR_CODES = {
273
+ MAIL_CONVERSATION_NOT_FOUND: 1e4,
274
+ MAIL_CONVERSATION_CLOSED: 10001,
275
+ MAIL_NOT_A_PARTICIPANT: 10002,
276
+ MAIL_PERMISSION_DENIED: 10003,
277
+ MAIL_TURN_NOT_FOUND: 10004,
278
+ MAIL_THREAD_NOT_FOUND: 10005,
279
+ MAIL_INVALID_TURN_CONTENT: 10006,
280
+ MAIL_PARTICIPANT_ALREADY_JOINED: 10007,
281
+ MAIL_INVITATION_REQUIRED: 10008,
282
+ MAIL_HISTORY_ACCESS_DENIED: 10009,
283
+ MAIL_PARENT_CONVERSATION_NOT_FOUND: 10010
252
284
  };
253
285
  var ERROR_CODES = {
254
286
  ...PROTOCOL_ERROR_CODES,
@@ -256,7 +288,8 @@ var ERROR_CODES = {
256
288
  ...ROUTING_ERROR_CODES,
257
289
  ...AGENT_ERROR_CODES,
258
290
  ...RESOURCE_ERROR_CODES,
259
- ...FEDERATION_ERROR_CODES
291
+ ...FEDERATION_ERROR_CODES,
292
+ ...MAIL_ERROR_CODES
260
293
  };
261
294
  var PROTOCOL_VERSION = 1;
262
295
 
@@ -3972,6 +4005,187 @@ var ClientConnection = class _ClientConnection {
3972
4005
  return this.#connection.sendRequest(STATE_METHODS.AGENTS_RESUME, { agentId });
3973
4006
  }
3974
4007
  // ===========================================================================
4008
+ // Mail
4009
+ // ===========================================================================
4010
+ /**
4011
+ * Create a new mail conversation.
4012
+ *
4013
+ * @param params - Conversation creation parameters
4014
+ * @returns Created conversation and participant info
4015
+ */
4016
+ async createConversation(params) {
4017
+ return this.#connection.sendRequest(
4018
+ MAIL_METHODS.MAIL_CREATE,
4019
+ params ?? {}
4020
+ );
4021
+ }
4022
+ /**
4023
+ * Get a conversation by ID with optional includes.
4024
+ *
4025
+ * @param conversationId - ID of the conversation to retrieve
4026
+ * @param include - Optional fields to include (participants, threads, recentTurns, stats)
4027
+ * @returns Conversation details with requested includes
4028
+ */
4029
+ async getConversation(conversationId, include) {
4030
+ return this.#connection.sendRequest(
4031
+ MAIL_METHODS.MAIL_GET,
4032
+ { conversationId, include }
4033
+ );
4034
+ }
4035
+ /**
4036
+ * List conversations with optional filters.
4037
+ *
4038
+ * @param params - Optional filter, limit, and cursor parameters
4039
+ * @returns Paginated list of conversations
4040
+ */
4041
+ async listConversations(params) {
4042
+ return this.#connection.sendRequest(
4043
+ MAIL_METHODS.MAIL_LIST,
4044
+ params ?? {}
4045
+ );
4046
+ }
4047
+ /**
4048
+ * Close a conversation.
4049
+ *
4050
+ * @param conversationId - ID of the conversation to close
4051
+ * @param reason - Optional reason for closing
4052
+ * @returns The closed conversation
4053
+ */
4054
+ async closeConversation(conversationId, reason) {
4055
+ return this.#connection.sendRequest(
4056
+ MAIL_METHODS.MAIL_CLOSE,
4057
+ { conversationId, reason }
4058
+ );
4059
+ }
4060
+ /**
4061
+ * Join an existing conversation.
4062
+ *
4063
+ * @param params - Join parameters including conversationId and optional catch-up config
4064
+ * @returns Conversation, participant, and optional history
4065
+ */
4066
+ async joinConversation(params) {
4067
+ return this.#connection.sendRequest(
4068
+ MAIL_METHODS.MAIL_JOIN,
4069
+ params
4070
+ );
4071
+ }
4072
+ /**
4073
+ * Leave a conversation.
4074
+ *
4075
+ * @param conversationId - ID of the conversation to leave
4076
+ * @param reason - Optional reason for leaving
4077
+ * @returns Leave confirmation with timestamp
4078
+ */
4079
+ async leaveConversation(conversationId, reason) {
4080
+ return this.#connection.sendRequest(
4081
+ MAIL_METHODS.MAIL_LEAVE,
4082
+ { conversationId, reason }
4083
+ );
4084
+ }
4085
+ /**
4086
+ * Invite a participant to a conversation.
4087
+ *
4088
+ * @param params - Invite parameters including conversationId and participant info
4089
+ * @returns Invite result
4090
+ */
4091
+ async inviteToConversation(params) {
4092
+ return this.#connection.sendRequest(
4093
+ MAIL_METHODS.MAIL_INVITE,
4094
+ params
4095
+ );
4096
+ }
4097
+ /**
4098
+ * Record a turn (message) in a conversation.
4099
+ *
4100
+ * @param params - Turn parameters including conversationId, contentType, and content
4101
+ * @returns The created turn
4102
+ */
4103
+ async recordTurn(params) {
4104
+ return this.#connection.sendRequest(
4105
+ MAIL_METHODS.MAIL_TURN,
4106
+ params
4107
+ );
4108
+ }
4109
+ /**
4110
+ * List turns in a conversation with optional filters.
4111
+ *
4112
+ * @param params - List parameters including conversationId and optional filters
4113
+ * @returns Paginated list of turns
4114
+ */
4115
+ async listTurns(params) {
4116
+ return this.#connection.sendRequest(
4117
+ MAIL_METHODS.MAIL_TURNS_LIST,
4118
+ params
4119
+ );
4120
+ }
4121
+ /**
4122
+ * Create a thread in a conversation.
4123
+ *
4124
+ * @param params - Thread creation parameters including conversationId and rootTurnId
4125
+ * @returns The created thread
4126
+ */
4127
+ async createThread(params) {
4128
+ return this.#connection.sendRequest(
4129
+ MAIL_METHODS.MAIL_THREAD_CREATE,
4130
+ params
4131
+ );
4132
+ }
4133
+ /**
4134
+ * List threads in a conversation.
4135
+ *
4136
+ * @param params - List parameters including conversationId
4137
+ * @returns Paginated list of threads
4138
+ */
4139
+ async listThreads(params) {
4140
+ return this.#connection.sendRequest(
4141
+ MAIL_METHODS.MAIL_THREAD_LIST,
4142
+ params
4143
+ );
4144
+ }
4145
+ /**
4146
+ * Get a summary of a conversation.
4147
+ *
4148
+ * @param params - Summary parameters including conversationId and optional scope/includes
4149
+ * @returns Generated summary with optional key points, decisions, and questions
4150
+ */
4151
+ async getConversationSummary(params) {
4152
+ return this.#connection.sendRequest(
4153
+ MAIL_METHODS.MAIL_SUMMARY,
4154
+ params
4155
+ );
4156
+ }
4157
+ /**
4158
+ * Replay turns from a conversation, optionally from a specific point.
4159
+ *
4160
+ * @param params - Replay parameters including conversationId and optional starting point
4161
+ * @returns Replayed turns with pagination info
4162
+ */
4163
+ async replayConversation(params) {
4164
+ return this.#connection.sendRequest(
4165
+ MAIL_METHODS.MAIL_REPLAY,
4166
+ params
4167
+ );
4168
+ }
4169
+ /**
4170
+ * Send a message to an address with mail context attached.
4171
+ *
4172
+ * Wraps the standard `send()` method, automatically attaching `meta.mail`
4173
+ * with the specified conversationId so the message is recorded as a turn
4174
+ * in the conversation.
4175
+ *
4176
+ * @param to - Target address
4177
+ * @param payload - Message payload
4178
+ * @param conversationId - Conversation to associate with
4179
+ * @param options - Optional threadId and additional message meta
4180
+ * @returns Send result
4181
+ */
4182
+ async sendWithMail(to, payload, conversationId, options) {
4183
+ return this.send(to, payload, {
4184
+ ...options?.meta,
4185
+ mail: { conversationId, threadId: options?.threadId }
4186
+ });
4187
+ }
4188
+ // ===========================================================================
3975
4189
  // Reconnection
3976
4190
  // ===========================================================================
3977
4191
  /**
@@ -4933,6 +5147,187 @@ var AgentConnection = class _AgentConnection {
4933
5147
  return this.#connection.onStateChange(handler);
4934
5148
  }
4935
5149
  // ===========================================================================
5150
+ // Mail
5151
+ // ===========================================================================
5152
+ /**
5153
+ * Create a new mail conversation.
5154
+ *
5155
+ * @param params - Conversation creation parameters
5156
+ * @returns Created conversation and participant info
5157
+ */
5158
+ async createConversation(params) {
5159
+ return this.#connection.sendRequest(
5160
+ MAIL_METHODS.MAIL_CREATE,
5161
+ params ?? {}
5162
+ );
5163
+ }
5164
+ /**
5165
+ * Get a conversation by ID with optional includes.
5166
+ *
5167
+ * @param conversationId - ID of the conversation to retrieve
5168
+ * @param include - Optional fields to include (participants, threads, recentTurns, stats)
5169
+ * @returns Conversation details with requested includes
5170
+ */
5171
+ async getConversation(conversationId, include) {
5172
+ return this.#connection.sendRequest(
5173
+ MAIL_METHODS.MAIL_GET,
5174
+ { conversationId, include }
5175
+ );
5176
+ }
5177
+ /**
5178
+ * List conversations with optional filters.
5179
+ *
5180
+ * @param params - Optional filter, limit, and cursor parameters
5181
+ * @returns Paginated list of conversations
5182
+ */
5183
+ async listConversations(params) {
5184
+ return this.#connection.sendRequest(
5185
+ MAIL_METHODS.MAIL_LIST,
5186
+ params ?? {}
5187
+ );
5188
+ }
5189
+ /**
5190
+ * Close a conversation.
5191
+ *
5192
+ * @param conversationId - ID of the conversation to close
5193
+ * @param reason - Optional reason for closing
5194
+ * @returns The closed conversation
5195
+ */
5196
+ async closeConversation(conversationId, reason) {
5197
+ return this.#connection.sendRequest(
5198
+ MAIL_METHODS.MAIL_CLOSE,
5199
+ { conversationId, reason }
5200
+ );
5201
+ }
5202
+ /**
5203
+ * Join an existing conversation.
5204
+ *
5205
+ * @param params - Join parameters including conversationId and optional catch-up config
5206
+ * @returns Conversation, participant, and optional history
5207
+ */
5208
+ async joinConversation(params) {
5209
+ return this.#connection.sendRequest(
5210
+ MAIL_METHODS.MAIL_JOIN,
5211
+ params
5212
+ );
5213
+ }
5214
+ /**
5215
+ * Leave a conversation.
5216
+ *
5217
+ * @param conversationId - ID of the conversation to leave
5218
+ * @param reason - Optional reason for leaving
5219
+ * @returns Leave confirmation with timestamp
5220
+ */
5221
+ async leaveConversation(conversationId, reason) {
5222
+ return this.#connection.sendRequest(
5223
+ MAIL_METHODS.MAIL_LEAVE,
5224
+ { conversationId, reason }
5225
+ );
5226
+ }
5227
+ /**
5228
+ * Invite a participant to a conversation.
5229
+ *
5230
+ * @param params - Invite parameters including conversationId and participant info
5231
+ * @returns Invite result
5232
+ */
5233
+ async inviteToConversation(params) {
5234
+ return this.#connection.sendRequest(
5235
+ MAIL_METHODS.MAIL_INVITE,
5236
+ params
5237
+ );
5238
+ }
5239
+ /**
5240
+ * Record a turn (message) in a conversation.
5241
+ *
5242
+ * @param params - Turn parameters including conversationId, contentType, and content
5243
+ * @returns The created turn
5244
+ */
5245
+ async recordTurn(params) {
5246
+ return this.#connection.sendRequest(
5247
+ MAIL_METHODS.MAIL_TURN,
5248
+ params
5249
+ );
5250
+ }
5251
+ /**
5252
+ * List turns in a conversation with optional filters.
5253
+ *
5254
+ * @param params - List parameters including conversationId and optional filters
5255
+ * @returns Paginated list of turns
5256
+ */
5257
+ async listTurns(params) {
5258
+ return this.#connection.sendRequest(
5259
+ MAIL_METHODS.MAIL_TURNS_LIST,
5260
+ params
5261
+ );
5262
+ }
5263
+ /**
5264
+ * Create a thread in a conversation.
5265
+ *
5266
+ * @param params - Thread creation parameters including conversationId and rootTurnId
5267
+ * @returns The created thread
5268
+ */
5269
+ async createThread(params) {
5270
+ return this.#connection.sendRequest(
5271
+ MAIL_METHODS.MAIL_THREAD_CREATE,
5272
+ params
5273
+ );
5274
+ }
5275
+ /**
5276
+ * List threads in a conversation.
5277
+ *
5278
+ * @param params - List parameters including conversationId
5279
+ * @returns Paginated list of threads
5280
+ */
5281
+ async listThreads(params) {
5282
+ return this.#connection.sendRequest(
5283
+ MAIL_METHODS.MAIL_THREAD_LIST,
5284
+ params
5285
+ );
5286
+ }
5287
+ /**
5288
+ * Get a summary of a conversation.
5289
+ *
5290
+ * @param params - Summary parameters including conversationId and optional scope/includes
5291
+ * @returns Generated summary with optional key points, decisions, and questions
5292
+ */
5293
+ async getConversationSummary(params) {
5294
+ return this.#connection.sendRequest(
5295
+ MAIL_METHODS.MAIL_SUMMARY,
5296
+ params
5297
+ );
5298
+ }
5299
+ /**
5300
+ * Replay turns from a conversation, optionally from a specific point.
5301
+ *
5302
+ * @param params - Replay parameters including conversationId and optional starting point
5303
+ * @returns Replayed turns with pagination info
5304
+ */
5305
+ async replayConversation(params) {
5306
+ return this.#connection.sendRequest(
5307
+ MAIL_METHODS.MAIL_REPLAY,
5308
+ params
5309
+ );
5310
+ }
5311
+ /**
5312
+ * Send a message to an agent with mail context attached.
5313
+ *
5314
+ * Wraps the standard `send()` method, automatically attaching `meta.mail`
5315
+ * with the specified conversationId so the message is recorded as a turn
5316
+ * in the conversation.
5317
+ *
5318
+ * @param to - Target address
5319
+ * @param payload - Message payload
5320
+ * @param conversationId - Conversation to associate with
5321
+ * @param options - Optional threadId and additional message meta
5322
+ * @returns Send result
5323
+ */
5324
+ async sendWithMail(to, payload, conversationId, options) {
5325
+ return this.send(to, payload, {
5326
+ ...options?.meta,
5327
+ mail: { conversationId, threadId: options?.threadId }
5328
+ });
5329
+ }
5330
+ // ===========================================================================
4936
5331
  // Internal
4937
5332
  // ===========================================================================
4938
5333
  /**