@multi-agent-protocol/sdk 0.1.7 → 0.1.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, 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-iu0EgJzG.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-CY89vJGH.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-iu0EgJzG.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-CY89vJGH.js';
2
2
  import 'events';
3
3
 
4
4
  /**
package/dist/testing.js CHANGED
@@ -4815,6 +4815,7 @@ var AgentConnection = class _AgentConnection {
4815
4815
  #options;
4816
4816
  #messageHandlers = /* @__PURE__ */ new Set();
4817
4817
  #reconnectionHandlers = /* @__PURE__ */ new Set();
4818
+ #notificationHandlers = /* @__PURE__ */ new Map();
4818
4819
  #scopeMemberships = /* @__PURE__ */ new Set();
4819
4820
  #agentId = null;
4820
4821
  #sessionId = null;
@@ -5235,6 +5236,47 @@ var AgentConnection = class _AgentConnection {
5235
5236
  this.#messageHandlers.delete(handler);
5236
5237
  return this;
5237
5238
  }
5239
+ /**
5240
+ * Register a handler for a specific notification method.
5241
+ *
5242
+ * Handles server-to-agent notifications that aren't standard MAP methods
5243
+ * (e.g., `trajectory/content.request`). When the server sends a JSON-RPC
5244
+ * notification with the specified method, the handler fires with the params.
5245
+ *
5246
+ * @param method - The JSON-RPC notification method name to handle
5247
+ * @param handler - Async function called with the notification params
5248
+ */
5249
+ onNotification(method, handler) {
5250
+ if (!this.#notificationHandlers.has(method)) {
5251
+ this.#notificationHandlers.set(method, /* @__PURE__ */ new Set());
5252
+ }
5253
+ this.#notificationHandlers.get(method).add(handler);
5254
+ return this;
5255
+ }
5256
+ /**
5257
+ * Remove a notification handler for a specific method.
5258
+ */
5259
+ offNotification(method, handler) {
5260
+ const handlers = this.#notificationHandlers.get(method);
5261
+ if (handlers) {
5262
+ handlers.delete(handler);
5263
+ if (handlers.size === 0) this.#notificationHandlers.delete(method);
5264
+ }
5265
+ return this;
5266
+ }
5267
+ /**
5268
+ * Send a raw JSON-RPC notification to the server.
5269
+ *
5270
+ * Used for custom protocol notifications (e.g., `trajectory/content.response`)
5271
+ * that aren't standard MAP methods. The notification is sent directly on the
5272
+ * underlying connection without any MAP-level wrapping.
5273
+ *
5274
+ * @param method - The JSON-RPC notification method name
5275
+ * @param params - The notification parameters
5276
+ */
5277
+ async sendNotification(method, params) {
5278
+ return this.#connection.sendNotification(method, params);
5279
+ }
5238
5280
  // ===========================================================================
5239
5281
  // State Management
5240
5282
  // ===========================================================================
@@ -5699,8 +5741,19 @@ var AgentConnection = class _AgentConnection {
5699
5741
  }
5700
5742
  break;
5701
5743
  }
5702
- default:
5703
- console.warn("MAP: Unknown notification:", method);
5744
+ default: {
5745
+ const handlers = this.#notificationHandlers.get(method);
5746
+ if (handlers?.size) {
5747
+ for (const handler of handlers) {
5748
+ try {
5749
+ await handler(params);
5750
+ } catch (error) {
5751
+ console.error("MAP: Notification handler error:", error);
5752
+ }
5753
+ }
5754
+ }
5755
+ break;
5756
+ }
5704
5757
  }
5705
5758
  }
5706
5759
  /**