@multi-agent-protocol/sdk 0.1.4 → 0.1.6
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-B5adJHGI.d.cts → index-iu0EgJzG.d.cts} +88 -32
- package/dist/{index-B5adJHGI.d.ts → index-iu0EgJzG.d.ts} +88 -32
- package/dist/index.cjs +146 -88
- 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 +146 -88
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +146 -88
- 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 +146 -88
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/testing.d.cts
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-
|
|
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';
|
|
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-
|
|
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';
|
|
2
2
|
import 'events';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/testing.js
CHANGED
|
@@ -229,6 +229,7 @@ var TASK_METHODS = {
|
|
|
229
229
|
var NOTIFICATION_METHODS = {
|
|
230
230
|
EVENT: "map/event",
|
|
231
231
|
MESSAGE: "map/message",
|
|
232
|
+
SEND: "map/send",
|
|
232
233
|
/** Client acknowledges received events (for backpressure) */
|
|
233
234
|
SUBSCRIBE_ACK: "map/subscribe.ack"};
|
|
234
235
|
var PROTOCOL_ERROR_CODES = {
|
|
@@ -4480,7 +4481,8 @@ var ClientConnection = class _ClientConnection {
|
|
|
4480
4481
|
}
|
|
4481
4482
|
break;
|
|
4482
4483
|
}
|
|
4483
|
-
case NOTIFICATION_METHODS.MESSAGE:
|
|
4484
|
+
case NOTIFICATION_METHODS.MESSAGE:
|
|
4485
|
+
case "map/send": {
|
|
4484
4486
|
break;
|
|
4485
4487
|
}
|
|
4486
4488
|
default:
|
|
@@ -4824,7 +4826,9 @@ var AgentConnection = class _AgentConnection {
|
|
|
4824
4826
|
constructor(stream, options = {}) {
|
|
4825
4827
|
this.#connection = new BaseConnection(stream, options);
|
|
4826
4828
|
this.#options = options;
|
|
4827
|
-
this.#connection.setNotificationHandler(
|
|
4829
|
+
this.#connection.setNotificationHandler(
|
|
4830
|
+
this.#handleNotification.bind(this)
|
|
4831
|
+
);
|
|
4828
4832
|
if (options.reconnection?.enabled && options.createStream) {
|
|
4829
4833
|
this.#connection.onStateChange((newState) => {
|
|
4830
4834
|
if (newState === "closed" && this.#connected && !this.#isReconnecting) {
|
|
@@ -4893,6 +4897,52 @@ var AgentConnection = class _AgentConnection {
|
|
|
4893
4897
|
await agent.connect({ auth: options?.auth });
|
|
4894
4898
|
return agent;
|
|
4895
4899
|
}
|
|
4900
|
+
/**
|
|
4901
|
+
* Create an AgentConnection over WebSocket without performing the MAP handshake.
|
|
4902
|
+
*
|
|
4903
|
+
* Use this when you need to control the connection flow — e.g., to handle
|
|
4904
|
+
* server-driven auth negotiation before registration.
|
|
4905
|
+
*
|
|
4906
|
+
* @example
|
|
4907
|
+
* ```typescript
|
|
4908
|
+
* const agent = await AgentConnection.createConnection('ws://localhost:8080', {
|
|
4909
|
+
* name: 'Worker',
|
|
4910
|
+
* role: 'processor',
|
|
4911
|
+
* });
|
|
4912
|
+
*
|
|
4913
|
+
* const result = await agent.connectOnly();
|
|
4914
|
+
* if (result.authRequired) {
|
|
4915
|
+
* await agent.authenticate({ method: result.authRequired.methods[0], token: cred });
|
|
4916
|
+
* }
|
|
4917
|
+
* await agent.register();
|
|
4918
|
+
* ```
|
|
4919
|
+
*/
|
|
4920
|
+
static async createConnection(url, options) {
|
|
4921
|
+
const parsedUrl = new URL(url);
|
|
4922
|
+
if (!["ws:", "wss:"].includes(parsedUrl.protocol)) {
|
|
4923
|
+
throw new Error(`Unsupported protocol: ${parsedUrl.protocol}. Use ws: or wss:`);
|
|
4924
|
+
}
|
|
4925
|
+
const timeout = options?.connectTimeout ?? 1e4;
|
|
4926
|
+
const ws = new WebSocket(url);
|
|
4927
|
+
await waitForOpen(ws, timeout);
|
|
4928
|
+
const stream = websocketStream(ws);
|
|
4929
|
+
const createStream = async () => {
|
|
4930
|
+
const newWs = new WebSocket(url);
|
|
4931
|
+
await waitForOpen(newWs, timeout);
|
|
4932
|
+
return websocketStream(newWs);
|
|
4933
|
+
};
|
|
4934
|
+
const reconnection = options?.reconnection === true ? { enabled: true } : typeof options?.reconnection === "object" ? options.reconnection : void 0;
|
|
4935
|
+
return new _AgentConnection(stream, {
|
|
4936
|
+
name: options?.name,
|
|
4937
|
+
role: options?.role,
|
|
4938
|
+
capabilities: options?.capabilities,
|
|
4939
|
+
visibility: options?.visibility,
|
|
4940
|
+
parent: options?.parent,
|
|
4941
|
+
scopes: options?.scopes,
|
|
4942
|
+
createStream,
|
|
4943
|
+
reconnection
|
|
4944
|
+
});
|
|
4945
|
+
}
|
|
4896
4946
|
/**
|
|
4897
4947
|
* Connect and register an agent via agentic-mesh transport.
|
|
4898
4948
|
*
|
|
@@ -4989,6 +5039,65 @@ var AgentConnection = class _AgentConnection {
|
|
|
4989
5039
|
this.#connection._transitionTo("connected");
|
|
4990
5040
|
return { connection: connectResult, agent: registerResult.agent };
|
|
4991
5041
|
}
|
|
5042
|
+
/**
|
|
5043
|
+
* Connect to the MAP system without registering an agent.
|
|
5044
|
+
*
|
|
5045
|
+
* Use this when the server may require authentication before registration.
|
|
5046
|
+
* After connecting, check `authRequired` in the response and call
|
|
5047
|
+
* `authenticate()` if needed, then `register()` to complete the handshake.
|
|
5048
|
+
*
|
|
5049
|
+
* @example
|
|
5050
|
+
* ```typescript
|
|
5051
|
+
* const result = await agent.connectOnly();
|
|
5052
|
+
*
|
|
5053
|
+
* if (result.authRequired) {
|
|
5054
|
+
* const method = result.authRequired.methods[0];
|
|
5055
|
+
* await agent.authenticate({ method, token: myCredential });
|
|
5056
|
+
* }
|
|
5057
|
+
*
|
|
5058
|
+
* await agent.register();
|
|
5059
|
+
* ```
|
|
5060
|
+
*/
|
|
5061
|
+
async connectOnly(options) {
|
|
5062
|
+
const connectParams = {
|
|
5063
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
5064
|
+
participantType: "agent",
|
|
5065
|
+
participantId: options?.agentId,
|
|
5066
|
+
name: this.#options.name,
|
|
5067
|
+
capabilities: this.#options.capabilities,
|
|
5068
|
+
resumeToken: options?.resumeToken,
|
|
5069
|
+
auth: options?.auth
|
|
5070
|
+
};
|
|
5071
|
+
const connectResult = await this.#connection.sendRequest(CORE_METHODS.CONNECT, connectParams);
|
|
5072
|
+
this.#sessionId = connectResult.sessionId;
|
|
5073
|
+
this.#serverCapabilities = connectResult.capabilities;
|
|
5074
|
+
this.#connected = true;
|
|
5075
|
+
this.#lastConnectOptions = options;
|
|
5076
|
+
return connectResult;
|
|
5077
|
+
}
|
|
5078
|
+
/**
|
|
5079
|
+
* Register as an agent after connecting.
|
|
5080
|
+
*
|
|
5081
|
+
* Call this after `connectOnly()` and optional `authenticate()` to complete
|
|
5082
|
+
* the connection handshake. Uses the options provided during construction
|
|
5083
|
+
* (name, role, scopes, etc.) unless overridden.
|
|
5084
|
+
*/
|
|
5085
|
+
async register(overrides) {
|
|
5086
|
+
const registerParams = {
|
|
5087
|
+
agentId: overrides?.agentId ?? this.#lastConnectOptions?.agentId,
|
|
5088
|
+
name: overrides?.name ?? this.#options.name,
|
|
5089
|
+
role: overrides?.role ?? this.#options.role,
|
|
5090
|
+
parent: this.#options.parent,
|
|
5091
|
+
scopes: this.#options.scopes,
|
|
5092
|
+
visibility: this.#options.visibility,
|
|
5093
|
+
capabilities: this.#options.capabilities
|
|
5094
|
+
};
|
|
5095
|
+
const registerResult = await this.#connection.sendRequest(LIFECYCLE_METHODS.AGENTS_REGISTER, registerParams);
|
|
5096
|
+
this.#agentId = registerResult.agent.id;
|
|
5097
|
+
this.#currentState = registerResult.agent.state;
|
|
5098
|
+
this.#connection._transitionTo("connected");
|
|
5099
|
+
return registerResult.agent;
|
|
5100
|
+
}
|
|
4992
5101
|
/**
|
|
4993
5102
|
* Authenticate with the server after connection.
|
|
4994
5103
|
*
|
|
@@ -5001,20 +5110,15 @@ var AgentConnection = class _AgentConnection {
|
|
|
5001
5110
|
*
|
|
5002
5111
|
* @example
|
|
5003
5112
|
* ```typescript
|
|
5004
|
-
* const
|
|
5005
|
-
*
|
|
5006
|
-
* // First connect to get auth requirements
|
|
5007
|
-
* const connectResult = await agent.connectOnly();
|
|
5113
|
+
* const result = await agent.connectOnly();
|
|
5008
5114
|
*
|
|
5009
|
-
* if (
|
|
5115
|
+
* if (result.authRequired) {
|
|
5010
5116
|
* const authResult = await agent.authenticate({
|
|
5011
|
-
* method:
|
|
5012
|
-
* token:
|
|
5117
|
+
* method: result.authRequired.methods[0],
|
|
5118
|
+
* token: myCredential,
|
|
5013
5119
|
* });
|
|
5014
|
-
*
|
|
5015
5120
|
* if (authResult.success) {
|
|
5016
|
-
*
|
|
5017
|
-
* await agent.register({ name: 'MyAgent', role: 'worker' });
|
|
5121
|
+
* await agent.register();
|
|
5018
5122
|
* }
|
|
5019
5123
|
* }
|
|
5020
5124
|
* ```
|
|
@@ -5060,10 +5164,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5060
5164
|
reason
|
|
5061
5165
|
});
|
|
5062
5166
|
}
|
|
5063
|
-
const result = await this.#connection.sendRequest(
|
|
5064
|
-
CORE_METHODS.DISCONNECT,
|
|
5065
|
-
reason ? { reason } : void 0
|
|
5066
|
-
);
|
|
5167
|
+
const result = await this.#connection.sendRequest(CORE_METHODS.DISCONNECT, reason ? { reason } : void 0);
|
|
5067
5168
|
resumeToken = result.resumeToken;
|
|
5068
5169
|
} finally {
|
|
5069
5170
|
for (const subscription of this.#subscriptions.values()) {
|
|
@@ -5379,10 +5480,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5379
5480
|
* @returns Created conversation and participant info
|
|
5380
5481
|
*/
|
|
5381
5482
|
async createConversation(params) {
|
|
5382
|
-
return this.#connection.sendRequest(
|
|
5383
|
-
MAIL_METHODS.MAIL_CREATE,
|
|
5384
|
-
params ?? {}
|
|
5385
|
-
);
|
|
5483
|
+
return this.#connection.sendRequest(MAIL_METHODS.MAIL_CREATE, params ?? {});
|
|
5386
5484
|
}
|
|
5387
5485
|
/**
|
|
5388
5486
|
* Get a conversation by ID with optional includes.
|
|
@@ -5392,10 +5490,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5392
5490
|
* @returns Conversation details with requested includes
|
|
5393
5491
|
*/
|
|
5394
5492
|
async getConversation(conversationId, include) {
|
|
5395
|
-
return this.#connection.sendRequest(
|
|
5396
|
-
MAIL_METHODS.MAIL_GET,
|
|
5397
|
-
{ conversationId, include }
|
|
5398
|
-
);
|
|
5493
|
+
return this.#connection.sendRequest(MAIL_METHODS.MAIL_GET, { conversationId, include });
|
|
5399
5494
|
}
|
|
5400
5495
|
/**
|
|
5401
5496
|
* List conversations with optional filters.
|
|
@@ -5404,10 +5499,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5404
5499
|
* @returns Paginated list of conversations
|
|
5405
5500
|
*/
|
|
5406
5501
|
async listConversations(params) {
|
|
5407
|
-
return this.#connection.sendRequest(
|
|
5408
|
-
MAIL_METHODS.MAIL_LIST,
|
|
5409
|
-
params ?? {}
|
|
5410
|
-
);
|
|
5502
|
+
return this.#connection.sendRequest(MAIL_METHODS.MAIL_LIST, params ?? {});
|
|
5411
5503
|
}
|
|
5412
5504
|
/**
|
|
5413
5505
|
* Close a conversation.
|
|
@@ -5417,10 +5509,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5417
5509
|
* @returns The closed conversation
|
|
5418
5510
|
*/
|
|
5419
5511
|
async closeConversation(conversationId, reason) {
|
|
5420
|
-
return this.#connection.sendRequest(
|
|
5421
|
-
MAIL_METHODS.MAIL_CLOSE,
|
|
5422
|
-
{ conversationId, reason }
|
|
5423
|
-
);
|
|
5512
|
+
return this.#connection.sendRequest(MAIL_METHODS.MAIL_CLOSE, { conversationId, reason });
|
|
5424
5513
|
}
|
|
5425
5514
|
/**
|
|
5426
5515
|
* Join an existing conversation.
|
|
@@ -5429,10 +5518,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5429
5518
|
* @returns Conversation, participant, and optional history
|
|
5430
5519
|
*/
|
|
5431
5520
|
async joinConversation(params) {
|
|
5432
|
-
return this.#connection.sendRequest(
|
|
5433
|
-
MAIL_METHODS.MAIL_JOIN,
|
|
5434
|
-
params
|
|
5435
|
-
);
|
|
5521
|
+
return this.#connection.sendRequest(MAIL_METHODS.MAIL_JOIN, params);
|
|
5436
5522
|
}
|
|
5437
5523
|
/**
|
|
5438
5524
|
* Leave a conversation.
|
|
@@ -5442,10 +5528,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5442
5528
|
* @returns Leave confirmation with timestamp
|
|
5443
5529
|
*/
|
|
5444
5530
|
async leaveConversation(conversationId, reason) {
|
|
5445
|
-
return this.#connection.sendRequest(
|
|
5446
|
-
MAIL_METHODS.MAIL_LEAVE,
|
|
5447
|
-
{ conversationId, reason }
|
|
5448
|
-
);
|
|
5531
|
+
return this.#connection.sendRequest(MAIL_METHODS.MAIL_LEAVE, { conversationId, reason });
|
|
5449
5532
|
}
|
|
5450
5533
|
/**
|
|
5451
5534
|
* Invite a participant to a conversation.
|
|
@@ -5454,10 +5537,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5454
5537
|
* @returns Invite result
|
|
5455
5538
|
*/
|
|
5456
5539
|
async inviteToConversation(params) {
|
|
5457
|
-
return this.#connection.sendRequest(
|
|
5458
|
-
MAIL_METHODS.MAIL_INVITE,
|
|
5459
|
-
params
|
|
5460
|
-
);
|
|
5540
|
+
return this.#connection.sendRequest(MAIL_METHODS.MAIL_INVITE, params);
|
|
5461
5541
|
}
|
|
5462
5542
|
/**
|
|
5463
5543
|
* Record a turn (message) in a conversation.
|
|
@@ -5466,10 +5546,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5466
5546
|
* @returns The created turn
|
|
5467
5547
|
*/
|
|
5468
5548
|
async recordTurn(params) {
|
|
5469
|
-
return this.#connection.sendRequest(
|
|
5470
|
-
MAIL_METHODS.MAIL_TURN,
|
|
5471
|
-
params
|
|
5472
|
-
);
|
|
5549
|
+
return this.#connection.sendRequest(MAIL_METHODS.MAIL_TURN, params);
|
|
5473
5550
|
}
|
|
5474
5551
|
/**
|
|
5475
5552
|
* List turns in a conversation with optional filters.
|
|
@@ -5478,10 +5555,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5478
5555
|
* @returns Paginated list of turns
|
|
5479
5556
|
*/
|
|
5480
5557
|
async listTurns(params) {
|
|
5481
|
-
return this.#connection.sendRequest(
|
|
5482
|
-
MAIL_METHODS.MAIL_TURNS_LIST,
|
|
5483
|
-
params
|
|
5484
|
-
);
|
|
5558
|
+
return this.#connection.sendRequest(MAIL_METHODS.MAIL_TURNS_LIST, params);
|
|
5485
5559
|
}
|
|
5486
5560
|
/**
|
|
5487
5561
|
* Create a thread in a conversation.
|
|
@@ -5490,10 +5564,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5490
5564
|
* @returns The created thread
|
|
5491
5565
|
*/
|
|
5492
5566
|
async createThread(params) {
|
|
5493
|
-
return this.#connection.sendRequest(
|
|
5494
|
-
MAIL_METHODS.MAIL_THREAD_CREATE,
|
|
5495
|
-
params
|
|
5496
|
-
);
|
|
5567
|
+
return this.#connection.sendRequest(MAIL_METHODS.MAIL_THREAD_CREATE, params);
|
|
5497
5568
|
}
|
|
5498
5569
|
/**
|
|
5499
5570
|
* List threads in a conversation.
|
|
@@ -5502,10 +5573,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5502
5573
|
* @returns Paginated list of threads
|
|
5503
5574
|
*/
|
|
5504
5575
|
async listThreads(params) {
|
|
5505
|
-
return this.#connection.sendRequest(
|
|
5506
|
-
MAIL_METHODS.MAIL_THREAD_LIST,
|
|
5507
|
-
params
|
|
5508
|
-
);
|
|
5576
|
+
return this.#connection.sendRequest(MAIL_METHODS.MAIL_THREAD_LIST, params);
|
|
5509
5577
|
}
|
|
5510
5578
|
/**
|
|
5511
5579
|
* Get a summary of a conversation.
|
|
@@ -5514,10 +5582,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5514
5582
|
* @returns Generated summary with optional key points, decisions, and questions
|
|
5515
5583
|
*/
|
|
5516
5584
|
async getConversationSummary(params) {
|
|
5517
|
-
return this.#connection.sendRequest(
|
|
5518
|
-
MAIL_METHODS.MAIL_SUMMARY,
|
|
5519
|
-
params
|
|
5520
|
-
);
|
|
5585
|
+
return this.#connection.sendRequest(MAIL_METHODS.MAIL_SUMMARY, params);
|
|
5521
5586
|
}
|
|
5522
5587
|
/**
|
|
5523
5588
|
* Replay turns from a conversation, optionally from a specific point.
|
|
@@ -5526,10 +5591,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5526
5591
|
* @returns Replayed turns with pagination info
|
|
5527
5592
|
*/
|
|
5528
5593
|
async replayConversation(params) {
|
|
5529
|
-
return this.#connection.sendRequest(
|
|
5530
|
-
MAIL_METHODS.MAIL_REPLAY,
|
|
5531
|
-
params
|
|
5532
|
-
);
|
|
5594
|
+
return this.#connection.sendRequest(MAIL_METHODS.MAIL_REPLAY, params);
|
|
5533
5595
|
}
|
|
5534
5596
|
/**
|
|
5535
5597
|
* Send a message to an agent with mail context attached.
|
|
@@ -5576,10 +5638,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5576
5638
|
* @returns The created task
|
|
5577
5639
|
*/
|
|
5578
5640
|
async createTask(params) {
|
|
5579
|
-
return this.#connection.sendRequest(
|
|
5580
|
-
TASK_METHODS.TASKS_CREATE,
|
|
5581
|
-
params
|
|
5582
|
-
);
|
|
5641
|
+
return this.#connection.sendRequest(TASK_METHODS.TASKS_CREATE, params);
|
|
5583
5642
|
}
|
|
5584
5643
|
/**
|
|
5585
5644
|
* Assign a task to an agent.
|
|
@@ -5589,10 +5648,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5589
5648
|
* @returns The updated task
|
|
5590
5649
|
*/
|
|
5591
5650
|
async assignTask(taskId, agentId) {
|
|
5592
|
-
return this.#connection.sendRequest(
|
|
5593
|
-
TASK_METHODS.TASKS_ASSIGN,
|
|
5594
|
-
{ taskId, agentId }
|
|
5595
|
-
);
|
|
5651
|
+
return this.#connection.sendRequest(TASK_METHODS.TASKS_ASSIGN, { taskId, agentId });
|
|
5596
5652
|
}
|
|
5597
5653
|
/**
|
|
5598
5654
|
* Update a task's status or fields.
|
|
@@ -5601,10 +5657,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5601
5657
|
* @returns The updated task
|
|
5602
5658
|
*/
|
|
5603
5659
|
async updateTask(params) {
|
|
5604
|
-
return this.#connection.sendRequest(
|
|
5605
|
-
TASK_METHODS.TASKS_UPDATE,
|
|
5606
|
-
params
|
|
5607
|
-
);
|
|
5660
|
+
return this.#connection.sendRequest(TASK_METHODS.TASKS_UPDATE, params);
|
|
5608
5661
|
}
|
|
5609
5662
|
/**
|
|
5610
5663
|
* List tasks with optional filters.
|
|
@@ -5613,10 +5666,7 @@ var AgentConnection = class _AgentConnection {
|
|
|
5613
5666
|
* @returns Paginated list of tasks
|
|
5614
5667
|
*/
|
|
5615
5668
|
async listTasks(params) {
|
|
5616
|
-
return this.#connection.sendRequest(
|
|
5617
|
-
TASK_METHODS.TASKS_LIST,
|
|
5618
|
-
params ?? {}
|
|
5619
|
-
);
|
|
5669
|
+
return this.#connection.sendRequest(TASK_METHODS.TASKS_LIST, params ?? {});
|
|
5620
5670
|
}
|
|
5621
5671
|
// ===========================================================================
|
|
5622
5672
|
// Internal
|
|
@@ -5628,17 +5678,21 @@ var AgentConnection = class _AgentConnection {
|
|
|
5628
5678
|
switch (method) {
|
|
5629
5679
|
case NOTIFICATION_METHODS.EVENT: {
|
|
5630
5680
|
const eventParams = params;
|
|
5631
|
-
const subscription = this.#subscriptions.get(
|
|
5681
|
+
const subscription = this.#subscriptions.get(
|
|
5682
|
+
eventParams.subscriptionId
|
|
5683
|
+
);
|
|
5632
5684
|
if (subscription) {
|
|
5633
5685
|
subscription._pushEvent(eventParams);
|
|
5634
5686
|
}
|
|
5635
5687
|
break;
|
|
5636
5688
|
}
|
|
5637
|
-
case NOTIFICATION_METHODS.MESSAGE:
|
|
5689
|
+
case NOTIFICATION_METHODS.MESSAGE:
|
|
5690
|
+
case NOTIFICATION_METHODS.SEND: {
|
|
5638
5691
|
const messageParams = params;
|
|
5692
|
+
const message = messageParams.message ?? messageParams;
|
|
5639
5693
|
for (const handler of this.#messageHandlers) {
|
|
5640
5694
|
try {
|
|
5641
|
-
await handler(
|
|
5695
|
+
await handler(message);
|
|
5642
5696
|
} catch (error) {
|
|
5643
5697
|
console.error("MAP: Message handler error:", error);
|
|
5644
5698
|
}
|
|
@@ -5731,7 +5785,11 @@ var AgentConnection = class _AgentConnection {
|
|
|
5731
5785
|
try {
|
|
5732
5786
|
await this.joinScope(scopeId);
|
|
5733
5787
|
} catch (error) {
|
|
5734
|
-
console.warn(
|
|
5788
|
+
console.warn(
|
|
5789
|
+
"MAP: Failed to restore scope membership:",
|
|
5790
|
+
scopeId,
|
|
5791
|
+
error
|
|
5792
|
+
);
|
|
5735
5793
|
}
|
|
5736
5794
|
}
|
|
5737
5795
|
}
|