@multi-agent-protocol/sdk 0.1.7 → 0.1.9
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-iu0EgJzG.d.cts → index-CY89vJGH.d.cts} +26 -0
- package/dist/{index-iu0EgJzG.d.ts → index-CY89vJGH.d.ts} +26 -0
- package/dist/index.cjs +55 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +55 -2
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +24 -0
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +24 -0
- package/dist/server.js.map +1 -1
- package/dist/testing.cjs +55 -2
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +55 -2
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -9102,6 +9102,7 @@ var RouterConnectionImpl = class {
|
|
|
9102
9102
|
_started = false;
|
|
9103
9103
|
_running = false;
|
|
9104
9104
|
_isClosed = false;
|
|
9105
|
+
_notificationHandler = null;
|
|
9105
9106
|
constructor(options) {
|
|
9106
9107
|
this.stream = options.stream;
|
|
9107
9108
|
this.handlers = options.handlers;
|
|
@@ -9186,6 +9187,15 @@ var RouterConnectionImpl = class {
|
|
|
9186
9187
|
}
|
|
9187
9188
|
this._closedResolve();
|
|
9188
9189
|
}
|
|
9190
|
+
/**
|
|
9191
|
+
* Register a handler for incoming notifications from the client.
|
|
9192
|
+
* By default, notifications are silently ignored. Setting a handler
|
|
9193
|
+
* allows the server to process custom notifications (e.g., opentasks
|
|
9194
|
+
* responses, trajectory content responses).
|
|
9195
|
+
*/
|
|
9196
|
+
onNotification(handler) {
|
|
9197
|
+
this._notificationHandler = handler;
|
|
9198
|
+
}
|
|
9189
9199
|
/**
|
|
9190
9200
|
* Send a notification to the connected peer.
|
|
9191
9201
|
*/
|
|
@@ -9228,8 +9238,22 @@ var RouterConnectionImpl = class {
|
|
|
9228
9238
|
async handleMessage(message2) {
|
|
9229
9239
|
if (this.isRequest(message2)) {
|
|
9230
9240
|
await this.handleRequest(message2);
|
|
9241
|
+
} else if (this.isNotification(message2)) {
|
|
9242
|
+
if (this._notificationHandler) {
|
|
9243
|
+
try {
|
|
9244
|
+
const msg = message2;
|
|
9245
|
+
this._notificationHandler(msg.method, msg.params);
|
|
9246
|
+
} catch {
|
|
9247
|
+
}
|
|
9248
|
+
}
|
|
9231
9249
|
}
|
|
9232
9250
|
}
|
|
9251
|
+
/**
|
|
9252
|
+
* Check if a message is a notification (method but no id).
|
|
9253
|
+
*/
|
|
9254
|
+
isNotification(message2) {
|
|
9255
|
+
return typeof message2 === "object" && message2 !== null && "jsonrpc" in message2 && message2.jsonrpc === "2.0" && "method" in message2 && !("id" in message2);
|
|
9256
|
+
}
|
|
9233
9257
|
/**
|
|
9234
9258
|
* Check if a message is a request.
|
|
9235
9259
|
*/
|