@multi-agent-protocol/sdk 0.0.7 → 0.0.8

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