@multi-agent-protocol/sdk 0.0.11 → 0.0.12
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.
- package/dist/index.cjs +27 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -9
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +27 -9
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +27 -9
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/testing.js
CHANGED
|
@@ -718,7 +718,7 @@ var BaseConnection = class {
|
|
|
718
718
|
this.#pendingResponses.set(id, pending);
|
|
719
719
|
});
|
|
720
720
|
await this.#sendMessage(request);
|
|
721
|
-
return responsePromise;
|
|
721
|
+
return await responsePromise;
|
|
722
722
|
}
|
|
723
723
|
/**
|
|
724
724
|
* Send a notification (no response expected)
|
|
@@ -2921,16 +2921,34 @@ var ACPStreamConnection = class extends EventEmitter {
|
|
|
2921
2921
|
if (event.type === "message_delivered" && event.data) {
|
|
2922
2922
|
const message = event.data.message;
|
|
2923
2923
|
if (message?.payload) {
|
|
2924
|
-
|
|
2924
|
+
try {
|
|
2925
|
+
await this.#handleIncomingMessage(message);
|
|
2926
|
+
} catch (msgError) {
|
|
2927
|
+
this.#safeEmitError(
|
|
2928
|
+
msgError instanceof Error ? msgError : new Error(String(msgError))
|
|
2929
|
+
);
|
|
2930
|
+
}
|
|
2925
2931
|
}
|
|
2926
2932
|
}
|
|
2927
2933
|
}
|
|
2928
2934
|
} catch (error) {
|
|
2929
2935
|
if (!this.#closed) {
|
|
2930
|
-
this
|
|
2936
|
+
this.#safeEmitError(error instanceof Error ? error : new Error(String(error)));
|
|
2931
2937
|
}
|
|
2932
2938
|
}
|
|
2933
2939
|
}
|
|
2940
|
+
/**
|
|
2941
|
+
* Emit an "error" event safely. If no listeners are attached,
|
|
2942
|
+
* EventEmitter.emit("error") throws the error as an uncaught
|
|
2943
|
+
* exception — this method logs instead when no listeners exist.
|
|
2944
|
+
*/
|
|
2945
|
+
#safeEmitError(error) {
|
|
2946
|
+
if (this.listenerCount("error") > 0) {
|
|
2947
|
+
this.emit("error", error);
|
|
2948
|
+
} else {
|
|
2949
|
+
console.error("ACPStreamConnection error (no listener):", error.message);
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2934
2952
|
/**
|
|
2935
2953
|
* Handle an incoming message from the target agent.
|
|
2936
2954
|
*/
|
|
@@ -3124,7 +3142,7 @@ var ACPStreamConnection = class extends EventEmitter {
|
|
|
3124
3142
|
if (this.#closed && !this.#pendingRequests.has(correlationId)) {
|
|
3125
3143
|
throw new Error("ACP stream closed");
|
|
3126
3144
|
}
|
|
3127
|
-
return resultPromise;
|
|
3145
|
+
return await resultPromise;
|
|
3128
3146
|
}
|
|
3129
3147
|
/**
|
|
3130
3148
|
* Send an ACP notification (no response expected).
|
|
@@ -3175,7 +3193,7 @@ var ACPStreamConnection = class extends EventEmitter {
|
|
|
3175
3193
|
if (!this.#initialized) {
|
|
3176
3194
|
throw new Error("Must call initialize() before authenticate()");
|
|
3177
3195
|
}
|
|
3178
|
-
return this.#sendRequest(
|
|
3196
|
+
return await this.#sendRequest(
|
|
3179
3197
|
ACP_METHODS.AUTHENTICATE,
|
|
3180
3198
|
params
|
|
3181
3199
|
);
|
|
@@ -3215,7 +3233,7 @@ var ACPStreamConnection = class extends EventEmitter {
|
|
|
3215
3233
|
* Set the session mode.
|
|
3216
3234
|
*/
|
|
3217
3235
|
async setSessionMode(params) {
|
|
3218
|
-
return this.#sendRequest(
|
|
3236
|
+
return await this.#sendRequest(
|
|
3219
3237
|
ACP_METHODS.SESSION_SET_MODE,
|
|
3220
3238
|
params
|
|
3221
3239
|
);
|
|
@@ -3231,7 +3249,7 @@ var ACPStreamConnection = class extends EventEmitter {
|
|
|
3231
3249
|
if (!this.#sessionId) {
|
|
3232
3250
|
throw new Error("Must call newSession() or loadSession() before prompt()");
|
|
3233
3251
|
}
|
|
3234
|
-
return this.#sendRequest(
|
|
3252
|
+
return await this.#sendRequest(
|
|
3235
3253
|
ACP_METHODS.SESSION_PROMPT,
|
|
3236
3254
|
params
|
|
3237
3255
|
);
|
|
@@ -3273,7 +3291,7 @@ var ACPStreamConnection = class extends EventEmitter {
|
|
|
3273
3291
|
if (!this.#initialized) {
|
|
3274
3292
|
throw new Error("Must call initialize() before callExtension()");
|
|
3275
3293
|
}
|
|
3276
|
-
return this.#sendRequest(method, params);
|
|
3294
|
+
return await this.#sendRequest(method, params);
|
|
3277
3295
|
}
|
|
3278
3296
|
// ===========================================================================
|
|
3279
3297
|
// Lifecycle
|
|
@@ -4028,7 +4046,7 @@ var ClientConnection = class _ClientConnection {
|
|
|
4028
4046
|
* ```
|
|
4029
4047
|
*/
|
|
4030
4048
|
async callExtension(method, params) {
|
|
4031
|
-
return this.#connection.sendRequest(method, params);
|
|
4049
|
+
return await this.#connection.sendRequest(method, params);
|
|
4032
4050
|
}
|
|
4033
4051
|
// ===========================================================================
|
|
4034
4052
|
// Mail
|