@multi-agent-protocol/sdk 0.1.3 → 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 = {
@@ -1785,6 +1786,7 @@ var TestServer = class {
1785
1786
  throw MAPRequestError.agentNotFound(params.parent);
1786
1787
  }
1787
1788
  return this.#handleAgentsRegister(connection, {
1789
+ agentId: params.agentId,
1788
1790
  name: params.name,
1789
1791
  role: params.role,
1790
1792
  parent: params.parent
@@ -4479,7 +4481,8 @@ var ClientConnection = class _ClientConnection {
4479
4481
  }
4480
4482
  break;
4481
4483
  }
4482
- case NOTIFICATION_METHODS.MESSAGE: {
4484
+ case NOTIFICATION_METHODS.MESSAGE:
4485
+ case "map/send": {
4483
4486
  break;
4484
4487
  }
4485
4488
  default:
@@ -4823,7 +4826,9 @@ var AgentConnection = class _AgentConnection {
4823
4826
  constructor(stream, options = {}) {
4824
4827
  this.#connection = new BaseConnection(stream, options);
4825
4828
  this.#options = options;
4826
- this.#connection.setNotificationHandler(this.#handleNotification.bind(this));
4829
+ this.#connection.setNotificationHandler(
4830
+ this.#handleNotification.bind(this)
4831
+ );
4827
4832
  if (options.reconnection?.enabled && options.createStream) {
4828
4833
  this.#connection.onStateChange((newState) => {
4829
4834
  if (newState === "closed" && this.#connected && !this.#isReconnecting) {
@@ -5059,10 +5064,7 @@ var AgentConnection = class _AgentConnection {
5059
5064
  reason
5060
5065
  });
5061
5066
  }
5062
- const result = await this.#connection.sendRequest(
5063
- CORE_METHODS.DISCONNECT,
5064
- reason ? { reason } : void 0
5065
- );
5067
+ const result = await this.#connection.sendRequest(CORE_METHODS.DISCONNECT, reason ? { reason } : void 0);
5066
5068
  resumeToken = result.resumeToken;
5067
5069
  } finally {
5068
5070
  for (const subscription of this.#subscriptions.values()) {
@@ -5378,10 +5380,7 @@ var AgentConnection = class _AgentConnection {
5378
5380
  * @returns Created conversation and participant info
5379
5381
  */
5380
5382
  async createConversation(params) {
5381
- return this.#connection.sendRequest(
5382
- MAIL_METHODS.MAIL_CREATE,
5383
- params ?? {}
5384
- );
5383
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_CREATE, params ?? {});
5385
5384
  }
5386
5385
  /**
5387
5386
  * Get a conversation by ID with optional includes.
@@ -5391,10 +5390,7 @@ var AgentConnection = class _AgentConnection {
5391
5390
  * @returns Conversation details with requested includes
5392
5391
  */
5393
5392
  async getConversation(conversationId, include) {
5394
- return this.#connection.sendRequest(
5395
- MAIL_METHODS.MAIL_GET,
5396
- { conversationId, include }
5397
- );
5393
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_GET, { conversationId, include });
5398
5394
  }
5399
5395
  /**
5400
5396
  * List conversations with optional filters.
@@ -5403,10 +5399,7 @@ var AgentConnection = class _AgentConnection {
5403
5399
  * @returns Paginated list of conversations
5404
5400
  */
5405
5401
  async listConversations(params) {
5406
- return this.#connection.sendRequest(
5407
- MAIL_METHODS.MAIL_LIST,
5408
- params ?? {}
5409
- );
5402
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_LIST, params ?? {});
5410
5403
  }
5411
5404
  /**
5412
5405
  * Close a conversation.
@@ -5416,10 +5409,7 @@ var AgentConnection = class _AgentConnection {
5416
5409
  * @returns The closed conversation
5417
5410
  */
5418
5411
  async closeConversation(conversationId, reason) {
5419
- return this.#connection.sendRequest(
5420
- MAIL_METHODS.MAIL_CLOSE,
5421
- { conversationId, reason }
5422
- );
5412
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_CLOSE, { conversationId, reason });
5423
5413
  }
5424
5414
  /**
5425
5415
  * Join an existing conversation.
@@ -5428,10 +5418,7 @@ var AgentConnection = class _AgentConnection {
5428
5418
  * @returns Conversation, participant, and optional history
5429
5419
  */
5430
5420
  async joinConversation(params) {
5431
- return this.#connection.sendRequest(
5432
- MAIL_METHODS.MAIL_JOIN,
5433
- params
5434
- );
5421
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_JOIN, params);
5435
5422
  }
5436
5423
  /**
5437
5424
  * Leave a conversation.
@@ -5441,10 +5428,7 @@ var AgentConnection = class _AgentConnection {
5441
5428
  * @returns Leave confirmation with timestamp
5442
5429
  */
5443
5430
  async leaveConversation(conversationId, reason) {
5444
- return this.#connection.sendRequest(
5445
- MAIL_METHODS.MAIL_LEAVE,
5446
- { conversationId, reason }
5447
- );
5431
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_LEAVE, { conversationId, reason });
5448
5432
  }
5449
5433
  /**
5450
5434
  * Invite a participant to a conversation.
@@ -5453,10 +5437,7 @@ var AgentConnection = class _AgentConnection {
5453
5437
  * @returns Invite result
5454
5438
  */
5455
5439
  async inviteToConversation(params) {
5456
- return this.#connection.sendRequest(
5457
- MAIL_METHODS.MAIL_INVITE,
5458
- params
5459
- );
5440
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_INVITE, params);
5460
5441
  }
5461
5442
  /**
5462
5443
  * Record a turn (message) in a conversation.
@@ -5465,10 +5446,7 @@ var AgentConnection = class _AgentConnection {
5465
5446
  * @returns The created turn
5466
5447
  */
5467
5448
  async recordTurn(params) {
5468
- return this.#connection.sendRequest(
5469
- MAIL_METHODS.MAIL_TURN,
5470
- params
5471
- );
5449
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_TURN, params);
5472
5450
  }
5473
5451
  /**
5474
5452
  * List turns in a conversation with optional filters.
@@ -5477,10 +5455,7 @@ var AgentConnection = class _AgentConnection {
5477
5455
  * @returns Paginated list of turns
5478
5456
  */
5479
5457
  async listTurns(params) {
5480
- return this.#connection.sendRequest(
5481
- MAIL_METHODS.MAIL_TURNS_LIST,
5482
- params
5483
- );
5458
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_TURNS_LIST, params);
5484
5459
  }
5485
5460
  /**
5486
5461
  * Create a thread in a conversation.
@@ -5489,10 +5464,7 @@ var AgentConnection = class _AgentConnection {
5489
5464
  * @returns The created thread
5490
5465
  */
5491
5466
  async createThread(params) {
5492
- return this.#connection.sendRequest(
5493
- MAIL_METHODS.MAIL_THREAD_CREATE,
5494
- params
5495
- );
5467
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_THREAD_CREATE, params);
5496
5468
  }
5497
5469
  /**
5498
5470
  * List threads in a conversation.
@@ -5501,10 +5473,7 @@ var AgentConnection = class _AgentConnection {
5501
5473
  * @returns Paginated list of threads
5502
5474
  */
5503
5475
  async listThreads(params) {
5504
- return this.#connection.sendRequest(
5505
- MAIL_METHODS.MAIL_THREAD_LIST,
5506
- params
5507
- );
5476
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_THREAD_LIST, params);
5508
5477
  }
5509
5478
  /**
5510
5479
  * Get a summary of a conversation.
@@ -5513,10 +5482,7 @@ var AgentConnection = class _AgentConnection {
5513
5482
  * @returns Generated summary with optional key points, decisions, and questions
5514
5483
  */
5515
5484
  async getConversationSummary(params) {
5516
- return this.#connection.sendRequest(
5517
- MAIL_METHODS.MAIL_SUMMARY,
5518
- params
5519
- );
5485
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_SUMMARY, params);
5520
5486
  }
5521
5487
  /**
5522
5488
  * Replay turns from a conversation, optionally from a specific point.
@@ -5525,10 +5491,7 @@ var AgentConnection = class _AgentConnection {
5525
5491
  * @returns Replayed turns with pagination info
5526
5492
  */
5527
5493
  async replayConversation(params) {
5528
- return this.#connection.sendRequest(
5529
- MAIL_METHODS.MAIL_REPLAY,
5530
- params
5531
- );
5494
+ return this.#connection.sendRequest(MAIL_METHODS.MAIL_REPLAY, params);
5532
5495
  }
5533
5496
  /**
5534
5497
  * Send a message to an agent with mail context attached.
@@ -5575,10 +5538,7 @@ var AgentConnection = class _AgentConnection {
5575
5538
  * @returns The created task
5576
5539
  */
5577
5540
  async createTask(params) {
5578
- return this.#connection.sendRequest(
5579
- TASK_METHODS.TASKS_CREATE,
5580
- params
5581
- );
5541
+ return this.#connection.sendRequest(TASK_METHODS.TASKS_CREATE, params);
5582
5542
  }
5583
5543
  /**
5584
5544
  * Assign a task to an agent.
@@ -5588,10 +5548,7 @@ var AgentConnection = class _AgentConnection {
5588
5548
  * @returns The updated task
5589
5549
  */
5590
5550
  async assignTask(taskId, agentId) {
5591
- return this.#connection.sendRequest(
5592
- TASK_METHODS.TASKS_ASSIGN,
5593
- { taskId, agentId }
5594
- );
5551
+ return this.#connection.sendRequest(TASK_METHODS.TASKS_ASSIGN, { taskId, agentId });
5595
5552
  }
5596
5553
  /**
5597
5554
  * Update a task's status or fields.
@@ -5600,10 +5557,7 @@ var AgentConnection = class _AgentConnection {
5600
5557
  * @returns The updated task
5601
5558
  */
5602
5559
  async updateTask(params) {
5603
- return this.#connection.sendRequest(
5604
- TASK_METHODS.TASKS_UPDATE,
5605
- params
5606
- );
5560
+ return this.#connection.sendRequest(TASK_METHODS.TASKS_UPDATE, params);
5607
5561
  }
5608
5562
  /**
5609
5563
  * List tasks with optional filters.
@@ -5612,10 +5566,7 @@ var AgentConnection = class _AgentConnection {
5612
5566
  * @returns Paginated list of tasks
5613
5567
  */
5614
5568
  async listTasks(params) {
5615
- return this.#connection.sendRequest(
5616
- TASK_METHODS.TASKS_LIST,
5617
- params ?? {}
5618
- );
5569
+ return this.#connection.sendRequest(TASK_METHODS.TASKS_LIST, params ?? {});
5619
5570
  }
5620
5571
  // ===========================================================================
5621
5572
  // Internal
@@ -5627,17 +5578,21 @@ var AgentConnection = class _AgentConnection {
5627
5578
  switch (method) {
5628
5579
  case NOTIFICATION_METHODS.EVENT: {
5629
5580
  const eventParams = params;
5630
- const subscription = this.#subscriptions.get(eventParams.subscriptionId);
5581
+ const subscription = this.#subscriptions.get(
5582
+ eventParams.subscriptionId
5583
+ );
5631
5584
  if (subscription) {
5632
5585
  subscription._pushEvent(eventParams);
5633
5586
  }
5634
5587
  break;
5635
5588
  }
5636
- case NOTIFICATION_METHODS.MESSAGE: {
5589
+ case NOTIFICATION_METHODS.MESSAGE:
5590
+ case NOTIFICATION_METHODS.SEND: {
5637
5591
  const messageParams = params;
5592
+ const message = messageParams.message ?? messageParams;
5638
5593
  for (const handler of this.#messageHandlers) {
5639
5594
  try {
5640
- await handler(messageParams.message);
5595
+ await handler(message);
5641
5596
  } catch (error) {
5642
5597
  console.error("MAP: Message handler error:", error);
5643
5598
  }
@@ -5730,7 +5685,11 @@ var AgentConnection = class _AgentConnection {
5730
5685
  try {
5731
5686
  await this.joinScope(scopeId);
5732
5687
  } catch (error) {
5733
- 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
+ );
5734
5693
  }
5735
5694
  }
5736
5695
  }