@multi-agent-protocol/sdk 0.1.4 → 0.1.5

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, hG 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, g9 as TaskId, dH as MAPTask, c as Message, r as Event, k as ParticipantId, N as SubscriptionId, cG as ClientConnectionOptions, cF as ClientConnection, c3 as AgentsListRequestParams, fy as ScopesListRequestParams, q as SubscriptionFilter, fY as Subscription, e as EventType, bM as AgentConnectionOptions, X as AgentConnection } from './index-B5adJHGI.cjs';
1
+ import { P as ParticipantCapabilities, hG 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, g9 as TaskId, dH as MAPTask, c as Message, r as Event, k as ParticipantId, N as SubscriptionId, cG as ClientConnectionOptions, cF as ClientConnection, c3 as AgentsListRequestParams, fy as ScopesListRequestParams, q as SubscriptionFilter, fY as Subscription, e as EventType, bM as AgentConnectionOptions, X as AgentConnection } from './index-BVrYVfaf.cjs';
2
2
  import 'events';
3
3
 
4
4
  /**
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { P as ParticipantCapabilities, hG 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, g9 as TaskId, dH as MAPTask, c as Message, r as Event, k as ParticipantId, N as SubscriptionId, cG as ClientConnectionOptions, cF as ClientConnection, c3 as AgentsListRequestParams, fy as ScopesListRequestParams, q as SubscriptionFilter, fY as Subscription, e as EventType, bM as AgentConnectionOptions, X as AgentConnection } from './index-B5adJHGI.js';
1
+ import { P as ParticipantCapabilities, hG 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, g9 as TaskId, dH as MAPTask, c as Message, r as Event, k as ParticipantId, N as SubscriptionId, cG as ClientConnectionOptions, cF as ClientConnection, c3 as AgentsListRequestParams, fy as ScopesListRequestParams, q as SubscriptionFilter, fY as Subscription, e as EventType, bM as AgentConnectionOptions, X as AgentConnection } from './index-BVrYVfaf.js';
2
2
  import 'events';
3
3
 
4
4
  /**
package/dist/testing.js CHANGED
@@ -229,6 +229,7 @@ var TASK_METHODS = {
229
229
  var NOTIFICATION_METHODS = {
230
230
  EVENT: "map/event",
231
231
  MESSAGE: "map/message",
232
+ SEND: "map/send",
232
233
  /** Client acknowledges received events (for backpressure) */
233
234
  SUBSCRIBE_ACK: "map/subscribe.ack"};
234
235
  var PROTOCOL_ERROR_CODES = {
@@ -4480,7 +4481,8 @@ var ClientConnection = class _ClientConnection {
4480
4481
  }
4481
4482
  break;
4482
4483
  }
4483
- case NOTIFICATION_METHODS.MESSAGE: {
4484
+ case NOTIFICATION_METHODS.MESSAGE:
4485
+ case "map/send": {
4484
4486
  break;
4485
4487
  }
4486
4488
  default:
@@ -4824,7 +4826,9 @@ var AgentConnection = class _AgentConnection {
4824
4826
  constructor(stream, options = {}) {
4825
4827
  this.#connection = new BaseConnection(stream, options);
4826
4828
  this.#options = options;
4827
- this.#connection.setNotificationHandler(this.#handleNotification.bind(this));
4829
+ this.#connection.setNotificationHandler(
4830
+ this.#handleNotification.bind(this)
4831
+ );
4828
4832
  if (options.reconnection?.enabled && options.createStream) {
4829
4833
  this.#connection.onStateChange((newState) => {
4830
4834
  if (newState === "closed" && this.#connected && !this.#isReconnecting) {
@@ -5060,10 +5064,7 @@ var AgentConnection = class _AgentConnection {
5060
5064
  reason
5061
5065
  });
5062
5066
  }
5063
- const result = await this.#connection.sendRequest(
5064
- CORE_METHODS.DISCONNECT,
5065
- reason ? { reason } : void 0
5066
- );
5067
+ const result = await this.#connection.sendRequest(CORE_METHODS.DISCONNECT, reason ? { reason } : void 0);
5067
5068
  resumeToken = result.resumeToken;
5068
5069
  } finally {
5069
5070
  for (const subscription of this.#subscriptions.values()) {
@@ -5379,10 +5380,7 @@ var AgentConnection = class _AgentConnection {
5379
5380
  * @returns Created conversation and participant info
5380
5381
  */
5381
5382
  async createConversation(params) {
5382
- return this.#connection.sendRequest(
5383
- MAIL_METHODS.MAIL_CREATE,
5384
- params ?? {}
5385
- );
5383
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_CREATE, params ?? {});
5386
5384
  }
5387
5385
  /**
5388
5386
  * Get a conversation by ID with optional includes.
@@ -5392,10 +5390,7 @@ var AgentConnection = class _AgentConnection {
5392
5390
  * @returns Conversation details with requested includes
5393
5391
  */
5394
5392
  async getConversation(conversationId, include) {
5395
- return this.#connection.sendRequest(
5396
- MAIL_METHODS.MAIL_GET,
5397
- { conversationId, include }
5398
- );
5393
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_GET, { conversationId, include });
5399
5394
  }
5400
5395
  /**
5401
5396
  * List conversations with optional filters.
@@ -5404,10 +5399,7 @@ var AgentConnection = class _AgentConnection {
5404
5399
  * @returns Paginated list of conversations
5405
5400
  */
5406
5401
  async listConversations(params) {
5407
- return this.#connection.sendRequest(
5408
- MAIL_METHODS.MAIL_LIST,
5409
- params ?? {}
5410
- );
5402
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_LIST, params ?? {});
5411
5403
  }
5412
5404
  /**
5413
5405
  * Close a conversation.
@@ -5417,10 +5409,7 @@ var AgentConnection = class _AgentConnection {
5417
5409
  * @returns The closed conversation
5418
5410
  */
5419
5411
  async closeConversation(conversationId, reason) {
5420
- return this.#connection.sendRequest(
5421
- MAIL_METHODS.MAIL_CLOSE,
5422
- { conversationId, reason }
5423
- );
5412
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_CLOSE, { conversationId, reason });
5424
5413
  }
5425
5414
  /**
5426
5415
  * Join an existing conversation.
@@ -5429,10 +5418,7 @@ var AgentConnection = class _AgentConnection {
5429
5418
  * @returns Conversation, participant, and optional history
5430
5419
  */
5431
5420
  async joinConversation(params) {
5432
- return this.#connection.sendRequest(
5433
- MAIL_METHODS.MAIL_JOIN,
5434
- params
5435
- );
5421
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_JOIN, params);
5436
5422
  }
5437
5423
  /**
5438
5424
  * Leave a conversation.
@@ -5442,10 +5428,7 @@ var AgentConnection = class _AgentConnection {
5442
5428
  * @returns Leave confirmation with timestamp
5443
5429
  */
5444
5430
  async leaveConversation(conversationId, reason) {
5445
- return this.#connection.sendRequest(
5446
- MAIL_METHODS.MAIL_LEAVE,
5447
- { conversationId, reason }
5448
- );
5431
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_LEAVE, { conversationId, reason });
5449
5432
  }
5450
5433
  /**
5451
5434
  * Invite a participant to a conversation.
@@ -5454,10 +5437,7 @@ var AgentConnection = class _AgentConnection {
5454
5437
  * @returns Invite result
5455
5438
  */
5456
5439
  async inviteToConversation(params) {
5457
- return this.#connection.sendRequest(
5458
- MAIL_METHODS.MAIL_INVITE,
5459
- params
5460
- );
5440
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_INVITE, params);
5461
5441
  }
5462
5442
  /**
5463
5443
  * Record a turn (message) in a conversation.
@@ -5466,10 +5446,7 @@ var AgentConnection = class _AgentConnection {
5466
5446
  * @returns The created turn
5467
5447
  */
5468
5448
  async recordTurn(params) {
5469
- return this.#connection.sendRequest(
5470
- MAIL_METHODS.MAIL_TURN,
5471
- params
5472
- );
5449
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_TURN, params);
5473
5450
  }
5474
5451
  /**
5475
5452
  * List turns in a conversation with optional filters.
@@ -5478,10 +5455,7 @@ var AgentConnection = class _AgentConnection {
5478
5455
  * @returns Paginated list of turns
5479
5456
  */
5480
5457
  async listTurns(params) {
5481
- return this.#connection.sendRequest(
5482
- MAIL_METHODS.MAIL_TURNS_LIST,
5483
- params
5484
- );
5458
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_TURNS_LIST, params);
5485
5459
  }
5486
5460
  /**
5487
5461
  * Create a thread in a conversation.
@@ -5490,10 +5464,7 @@ var AgentConnection = class _AgentConnection {
5490
5464
  * @returns The created thread
5491
5465
  */
5492
5466
  async createThread(params) {
5493
- return this.#connection.sendRequest(
5494
- MAIL_METHODS.MAIL_THREAD_CREATE,
5495
- params
5496
- );
5467
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_THREAD_CREATE, params);
5497
5468
  }
5498
5469
  /**
5499
5470
  * List threads in a conversation.
@@ -5502,10 +5473,7 @@ var AgentConnection = class _AgentConnection {
5502
5473
  * @returns Paginated list of threads
5503
5474
  */
5504
5475
  async listThreads(params) {
5505
- return this.#connection.sendRequest(
5506
- MAIL_METHODS.MAIL_THREAD_LIST,
5507
- params
5508
- );
5476
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_THREAD_LIST, params);
5509
5477
  }
5510
5478
  /**
5511
5479
  * Get a summary of a conversation.
@@ -5514,10 +5482,7 @@ var AgentConnection = class _AgentConnection {
5514
5482
  * @returns Generated summary with optional key points, decisions, and questions
5515
5483
  */
5516
5484
  async getConversationSummary(params) {
5517
- return this.#connection.sendRequest(
5518
- MAIL_METHODS.MAIL_SUMMARY,
5519
- params
5520
- );
5485
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_SUMMARY, params);
5521
5486
  }
5522
5487
  /**
5523
5488
  * Replay turns from a conversation, optionally from a specific point.
@@ -5526,10 +5491,7 @@ var AgentConnection = class _AgentConnection {
5526
5491
  * @returns Replayed turns with pagination info
5527
5492
  */
5528
5493
  async replayConversation(params) {
5529
- return this.#connection.sendRequest(
5530
- MAIL_METHODS.MAIL_REPLAY,
5531
- params
5532
- );
5494
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_REPLAY, params);
5533
5495
  }
5534
5496
  /**
5535
5497
  * Send a message to an agent with mail context attached.
@@ -5576,10 +5538,7 @@ var AgentConnection = class _AgentConnection {
5576
5538
  * @returns The created task
5577
5539
  */
5578
5540
  async createTask(params) {
5579
- return this.#connection.sendRequest(
5580
- TASK_METHODS.TASKS_CREATE,
5581
- params
5582
- );
5541
+ return this.#connection.sendRequest(TASK_METHODS.TASKS_CREATE, params);
5583
5542
  }
5584
5543
  /**
5585
5544
  * Assign a task to an agent.
@@ -5589,10 +5548,7 @@ var AgentConnection = class _AgentConnection {
5589
5548
  * @returns The updated task
5590
5549
  */
5591
5550
  async assignTask(taskId, agentId) {
5592
- return this.#connection.sendRequest(
5593
- TASK_METHODS.TASKS_ASSIGN,
5594
- { taskId, agentId }
5595
- );
5551
+ return this.#connection.sendRequest(TASK_METHODS.TASKS_ASSIGN, { taskId, agentId });
5596
5552
  }
5597
5553
  /**
5598
5554
  * Update a task's status or fields.
@@ -5601,10 +5557,7 @@ var AgentConnection = class _AgentConnection {
5601
5557
  * @returns The updated task
5602
5558
  */
5603
5559
  async updateTask(params) {
5604
- return this.#connection.sendRequest(
5605
- TASK_METHODS.TASKS_UPDATE,
5606
- params
5607
- );
5560
+ return this.#connection.sendRequest(TASK_METHODS.TASKS_UPDATE, params);
5608
5561
  }
5609
5562
  /**
5610
5563
  * List tasks with optional filters.
@@ -5613,10 +5566,7 @@ var AgentConnection = class _AgentConnection {
5613
5566
  * @returns Paginated list of tasks
5614
5567
  */
5615
5568
  async listTasks(params) {
5616
- return this.#connection.sendRequest(
5617
- TASK_METHODS.TASKS_LIST,
5618
- params ?? {}
5619
- );
5569
+ return this.#connection.sendRequest(TASK_METHODS.TASKS_LIST, params ?? {});
5620
5570
  }
5621
5571
  // ===========================================================================
5622
5572
  // Internal
@@ -5628,17 +5578,21 @@ var AgentConnection = class _AgentConnection {
5628
5578
  switch (method) {
5629
5579
  case NOTIFICATION_METHODS.EVENT: {
5630
5580
  const eventParams = params;
5631
- const subscription = this.#subscriptions.get(eventParams.subscriptionId);
5581
+ const subscription = this.#subscriptions.get(
5582
+ eventParams.subscriptionId
5583
+ );
5632
5584
  if (subscription) {
5633
5585
  subscription._pushEvent(eventParams);
5634
5586
  }
5635
5587
  break;
5636
5588
  }
5637
- case NOTIFICATION_METHODS.MESSAGE: {
5589
+ case NOTIFICATION_METHODS.MESSAGE:
5590
+ case NOTIFICATION_METHODS.SEND: {
5638
5591
  const messageParams = params;
5592
+ const message = messageParams.message ?? messageParams;
5639
5593
  for (const handler of this.#messageHandlers) {
5640
5594
  try {
5641
- await handler(messageParams.message);
5595
+ await handler(message);
5642
5596
  } catch (error) {
5643
5597
  console.error("MAP: Message handler error:", error);
5644
5598
  }
@@ -5731,7 +5685,11 @@ var AgentConnection = class _AgentConnection {
5731
5685
  try {
5732
5686
  await this.joinScope(scopeId);
5733
5687
  } catch (error) {
5734
- console.warn("MAP: Failed to restore scope membership:", scopeId, error);
5688
+ console.warn(
5689
+ "MAP: Failed to restore scope membership:",
5690
+ scopeId,
5691
+ error
5692
+ );
5735
5693
  }
5736
5694
  }
5737
5695
  }