@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/index.js
CHANGED
|
@@ -1449,7 +1449,7 @@ var BaseConnection = class {
|
|
|
1449
1449
|
this.#pendingResponses.set(id, pending);
|
|
1450
1450
|
});
|
|
1451
1451
|
await this.#sendMessage(request);
|
|
1452
|
-
return responsePromise;
|
|
1452
|
+
return await responsePromise;
|
|
1453
1453
|
}
|
|
1454
1454
|
/**
|
|
1455
1455
|
* Send a notification (no response expected)
|
|
@@ -2241,16 +2241,34 @@ var ACPStreamConnection = class extends EventEmitter {
|
|
|
2241
2241
|
if (event.type === "message_delivered" && event.data) {
|
|
2242
2242
|
const message = event.data.message;
|
|
2243
2243
|
if (message?.payload) {
|
|
2244
|
-
|
|
2244
|
+
try {
|
|
2245
|
+
await this.#handleIncomingMessage(message);
|
|
2246
|
+
} catch (msgError) {
|
|
2247
|
+
this.#safeEmitError(
|
|
2248
|
+
msgError instanceof Error ? msgError : new Error(String(msgError))
|
|
2249
|
+
);
|
|
2250
|
+
}
|
|
2245
2251
|
}
|
|
2246
2252
|
}
|
|
2247
2253
|
}
|
|
2248
2254
|
} catch (error) {
|
|
2249
2255
|
if (!this.#closed) {
|
|
2250
|
-
this
|
|
2256
|
+
this.#safeEmitError(error instanceof Error ? error : new Error(String(error)));
|
|
2251
2257
|
}
|
|
2252
2258
|
}
|
|
2253
2259
|
}
|
|
2260
|
+
/**
|
|
2261
|
+
* Emit an "error" event safely. If no listeners are attached,
|
|
2262
|
+
* EventEmitter.emit("error") throws the error as an uncaught
|
|
2263
|
+
* exception — this method logs instead when no listeners exist.
|
|
2264
|
+
*/
|
|
2265
|
+
#safeEmitError(error) {
|
|
2266
|
+
if (this.listenerCount("error") > 0) {
|
|
2267
|
+
this.emit("error", error);
|
|
2268
|
+
} else {
|
|
2269
|
+
console.error("ACPStreamConnection error (no listener):", error.message);
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2254
2272
|
/**
|
|
2255
2273
|
* Handle an incoming message from the target agent.
|
|
2256
2274
|
*/
|
|
@@ -2444,7 +2462,7 @@ var ACPStreamConnection = class extends EventEmitter {
|
|
|
2444
2462
|
if (this.#closed && !this.#pendingRequests.has(correlationId)) {
|
|
2445
2463
|
throw new Error("ACP stream closed");
|
|
2446
2464
|
}
|
|
2447
|
-
return resultPromise;
|
|
2465
|
+
return await resultPromise;
|
|
2448
2466
|
}
|
|
2449
2467
|
/**
|
|
2450
2468
|
* Send an ACP notification (no response expected).
|
|
@@ -2495,7 +2513,7 @@ var ACPStreamConnection = class extends EventEmitter {
|
|
|
2495
2513
|
if (!this.#initialized) {
|
|
2496
2514
|
throw new Error("Must call initialize() before authenticate()");
|
|
2497
2515
|
}
|
|
2498
|
-
return this.#sendRequest(
|
|
2516
|
+
return await this.#sendRequest(
|
|
2499
2517
|
ACP_METHODS.AUTHENTICATE,
|
|
2500
2518
|
params
|
|
2501
2519
|
);
|
|
@@ -2535,7 +2553,7 @@ var ACPStreamConnection = class extends EventEmitter {
|
|
|
2535
2553
|
* Set the session mode.
|
|
2536
2554
|
*/
|
|
2537
2555
|
async setSessionMode(params) {
|
|
2538
|
-
return this.#sendRequest(
|
|
2556
|
+
return await this.#sendRequest(
|
|
2539
2557
|
ACP_METHODS.SESSION_SET_MODE,
|
|
2540
2558
|
params
|
|
2541
2559
|
);
|
|
@@ -2551,7 +2569,7 @@ var ACPStreamConnection = class extends EventEmitter {
|
|
|
2551
2569
|
if (!this.#sessionId) {
|
|
2552
2570
|
throw new Error("Must call newSession() or loadSession() before prompt()");
|
|
2553
2571
|
}
|
|
2554
|
-
return this.#sendRequest(
|
|
2572
|
+
return await this.#sendRequest(
|
|
2555
2573
|
ACP_METHODS.SESSION_PROMPT,
|
|
2556
2574
|
params
|
|
2557
2575
|
);
|
|
@@ -2593,7 +2611,7 @@ var ACPStreamConnection = class extends EventEmitter {
|
|
|
2593
2611
|
if (!this.#initialized) {
|
|
2594
2612
|
throw new Error("Must call initialize() before callExtension()");
|
|
2595
2613
|
}
|
|
2596
|
-
return this.#sendRequest(method, params);
|
|
2614
|
+
return await this.#sendRequest(method, params);
|
|
2597
2615
|
}
|
|
2598
2616
|
// ===========================================================================
|
|
2599
2617
|
// Lifecycle
|
|
@@ -3351,7 +3369,7 @@ var ClientConnection = class _ClientConnection {
|
|
|
3351
3369
|
* ```
|
|
3352
3370
|
*/
|
|
3353
3371
|
async callExtension(method, params) {
|
|
3354
|
-
return this.#connection.sendRequest(method, params);
|
|
3372
|
+
return await this.#connection.sendRequest(method, params);
|
|
3355
3373
|
}
|
|
3356
3374
|
// ===========================================================================
|
|
3357
3375
|
// Mail
|