@multi-agent-protocol/sdk 0.0.11 → 0.1.0

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, 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-BojLgS6o.cjs';
1
+ import { P as ParticipantCapabilities, hm 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, cG as ClientConnectionOptions, cF as ClientConnection, c3 as AgentsListRequestParams, fw as ScopesListRequestParams, q as SubscriptionFilter, fW as Subscription, e as EventType, bM as AgentConnectionOptions, X as AgentConnection } from './index-OkNSW4wR.cjs';
2
2
  import 'events';
3
3
 
4
4
  /**
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
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-BojLgS6o.js';
1
+ import { P as ParticipantCapabilities, hm 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, cG as ClientConnectionOptions, cF as ClientConnection, c3 as AgentsListRequestParams, fw as ScopesListRequestParams, q as SubscriptionFilter, fW as Subscription, e as EventType, bM as AgentConnectionOptions, X as AgentConnection } from './index-OkNSW4wR.js';
2
2
  import 'events';
3
3
 
4
4
  /**
package/dist/testing.js CHANGED
@@ -282,6 +282,13 @@ var MAIL_ERROR_CODES = {
282
282
  MAIL_HISTORY_ACCESS_DENIED: 10009,
283
283
  MAIL_PARENT_CONVERSATION_NOT_FOUND: 10010
284
284
  };
285
+ var TRAJECTORY_ERROR_CODES = {
286
+ TRAJECTORY_NOT_ENABLED: 13e3,
287
+ TRAJECTORY_CHECKPOINT_NOT_FOUND: 13001,
288
+ TRAJECTORY_CONTENT_UNAVAILABLE: 13002,
289
+ TRAJECTORY_STREAM_FAILED: 13003,
290
+ TRAJECTORY_PERMISSION_DENIED: 13004
291
+ };
285
292
  var ERROR_CODES = {
286
293
  ...PROTOCOL_ERROR_CODES,
287
294
  ...AUTH_ERROR_CODES,
@@ -289,7 +296,8 @@ var ERROR_CODES = {
289
296
  ...AGENT_ERROR_CODES,
290
297
  ...RESOURCE_ERROR_CODES,
291
298
  ...FEDERATION_ERROR_CODES,
292
- ...MAIL_ERROR_CODES
299
+ ...MAIL_ERROR_CODES,
300
+ ...TRAJECTORY_ERROR_CODES
293
301
  };
294
302
  var PROTOCOL_VERSION = 1;
295
303
 
@@ -718,7 +726,7 @@ var BaseConnection = class {
718
726
  this.#pendingResponses.set(id, pending);
719
727
  });
720
728
  await this.#sendMessage(request);
721
- return responsePromise;
729
+ return await responsePromise;
722
730
  }
723
731
  /**
724
732
  * Send a notification (no response expected)
@@ -2921,16 +2929,34 @@ var ACPStreamConnection = class extends EventEmitter {
2921
2929
  if (event.type === "message_delivered" && event.data) {
2922
2930
  const message = event.data.message;
2923
2931
  if (message?.payload) {
2924
- await this.#handleIncomingMessage(message);
2932
+ try {
2933
+ await this.#handleIncomingMessage(message);
2934
+ } catch (msgError) {
2935
+ this.#safeEmitError(
2936
+ msgError instanceof Error ? msgError : new Error(String(msgError))
2937
+ );
2938
+ }
2925
2939
  }
2926
2940
  }
2927
2941
  }
2928
2942
  } catch (error) {
2929
2943
  if (!this.#closed) {
2930
- this.emit("error", error);
2944
+ this.#safeEmitError(error instanceof Error ? error : new Error(String(error)));
2931
2945
  }
2932
2946
  }
2933
2947
  }
2948
+ /**
2949
+ * Emit an "error" event safely. If no listeners are attached,
2950
+ * EventEmitter.emit("error") throws the error as an uncaught
2951
+ * exception — this method logs instead when no listeners exist.
2952
+ */
2953
+ #safeEmitError(error) {
2954
+ if (this.listenerCount("error") > 0) {
2955
+ this.emit("error", error);
2956
+ } else {
2957
+ console.error("ACPStreamConnection error (no listener):", error.message);
2958
+ }
2959
+ }
2934
2960
  /**
2935
2961
  * Handle an incoming message from the target agent.
2936
2962
  */
@@ -3124,7 +3150,7 @@ var ACPStreamConnection = class extends EventEmitter {
3124
3150
  if (this.#closed && !this.#pendingRequests.has(correlationId)) {
3125
3151
  throw new Error("ACP stream closed");
3126
3152
  }
3127
- return resultPromise;
3153
+ return await resultPromise;
3128
3154
  }
3129
3155
  /**
3130
3156
  * Send an ACP notification (no response expected).
@@ -3175,7 +3201,7 @@ var ACPStreamConnection = class extends EventEmitter {
3175
3201
  if (!this.#initialized) {
3176
3202
  throw new Error("Must call initialize() before authenticate()");
3177
3203
  }
3178
- return this.#sendRequest(
3204
+ return await this.#sendRequest(
3179
3205
  ACP_METHODS.AUTHENTICATE,
3180
3206
  params
3181
3207
  );
@@ -3215,7 +3241,7 @@ var ACPStreamConnection = class extends EventEmitter {
3215
3241
  * Set the session mode.
3216
3242
  */
3217
3243
  async setSessionMode(params) {
3218
- return this.#sendRequest(
3244
+ return await this.#sendRequest(
3219
3245
  ACP_METHODS.SESSION_SET_MODE,
3220
3246
  params
3221
3247
  );
@@ -3231,7 +3257,7 @@ var ACPStreamConnection = class extends EventEmitter {
3231
3257
  if (!this.#sessionId) {
3232
3258
  throw new Error("Must call newSession() or loadSession() before prompt()");
3233
3259
  }
3234
- return this.#sendRequest(
3260
+ return await this.#sendRequest(
3235
3261
  ACP_METHODS.SESSION_PROMPT,
3236
3262
  params
3237
3263
  );
@@ -3273,7 +3299,7 @@ var ACPStreamConnection = class extends EventEmitter {
3273
3299
  if (!this.#initialized) {
3274
3300
  throw new Error("Must call initialize() before callExtension()");
3275
3301
  }
3276
- return this.#sendRequest(method, params);
3302
+ return await this.#sendRequest(method, params);
3277
3303
  }
3278
3304
  // ===========================================================================
3279
3305
  // Lifecycle
@@ -4028,7 +4054,7 @@ var ClientConnection = class _ClientConnection {
4028
4054
  * ```
4029
4055
  */
4030
4056
  async callExtension(method, params) {
4031
- return this.#connection.sendRequest(method, params);
4057
+ return await this.#connection.sendRequest(method, params);
4032
4058
  }
4033
4059
  // ===========================================================================
4034
4060
  // Mail