@multi-agent-protocol/sdk 0.1.1 → 0.1.2
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-DHxPjZ_2.d.cts → index-B1Lpo3ll.d.cts} +168 -1
- package/dist/{index-DHxPjZ_2.d.ts → index-B1Lpo3ll.d.ts} +168 -1
- package/dist/index.cjs +97 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +97 -3
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +171 -1
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +5 -1
- package/dist/testing.d.ts +5 -1
- package/dist/testing.js +171 -1
- 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,
|
|
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-B1Lpo3ll.cjs';
|
|
2
2
|
import 'events';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -56,6 +56,10 @@ declare class TestServer {
|
|
|
56
56
|
* Get all scopes
|
|
57
57
|
*/
|
|
58
58
|
get scopes(): ReadonlyMap<ScopeId, Scope>;
|
|
59
|
+
/**
|
|
60
|
+
* Get all tasks
|
|
61
|
+
*/
|
|
62
|
+
get tasks(): ReadonlyMap<TaskId, MAPTask>;
|
|
59
63
|
/**
|
|
60
64
|
* Get all messages sent through the server
|
|
61
65
|
*/
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as ParticipantCapabilities,
|
|
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-B1Lpo3ll.js';
|
|
2
2
|
import 'events';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -56,6 +56,10 @@ declare class TestServer {
|
|
|
56
56
|
* Get all scopes
|
|
57
57
|
*/
|
|
58
58
|
get scopes(): ReadonlyMap<ScopeId, Scope>;
|
|
59
|
+
/**
|
|
60
|
+
* Get all tasks
|
|
61
|
+
*/
|
|
62
|
+
get tasks(): ReadonlyMap<TaskId, MAPTask>;
|
|
59
63
|
/**
|
|
60
64
|
* Get all messages sent through the server
|
|
61
65
|
*/
|
package/dist/testing.js
CHANGED
|
@@ -149,7 +149,12 @@ var EVENT_TYPES = {
|
|
|
149
149
|
SCOPE_MEMBER_LEFT: "scope_member_left",
|
|
150
150
|
// Permission events
|
|
151
151
|
PERMISSIONS_CLIENT_UPDATED: "permissions_client_updated",
|
|
152
|
-
PERMISSIONS_AGENT_UPDATED: "permissions_agent_updated"
|
|
152
|
+
PERMISSIONS_AGENT_UPDATED: "permissions_agent_updated",
|
|
153
|
+
// Task events
|
|
154
|
+
TASK_CREATED: "task.created",
|
|
155
|
+
TASK_ASSIGNED: "task.assigned",
|
|
156
|
+
TASK_STATUS: "task.status",
|
|
157
|
+
TASK_COMPLETED: "task.completed"};
|
|
153
158
|
var CORE_METHODS = {
|
|
154
159
|
CONNECT: "map/connect",
|
|
155
160
|
DISCONNECT: "map/disconnect",
|
|
@@ -215,6 +220,12 @@ var MAIL_METHODS = {
|
|
|
215
220
|
MAIL_SUMMARY: "mail/summary",
|
|
216
221
|
MAIL_REPLAY: "mail/replay"
|
|
217
222
|
};
|
|
223
|
+
var TASK_METHODS = {
|
|
224
|
+
TASKS_CREATE: "map/tasks/create",
|
|
225
|
+
TASKS_ASSIGN: "map/tasks/assign",
|
|
226
|
+
TASKS_UPDATE: "map/tasks/update",
|
|
227
|
+
TASKS_LIST: "map/tasks/list"
|
|
228
|
+
};
|
|
218
229
|
var NOTIFICATION_METHODS = {
|
|
219
230
|
EVENT: "map/event",
|
|
220
231
|
MESSAGE: "map/message",
|
|
@@ -1163,6 +1174,7 @@ var TestServer = class {
|
|
|
1163
1174
|
#agents = /* @__PURE__ */ new Map();
|
|
1164
1175
|
#scopes = /* @__PURE__ */ new Map();
|
|
1165
1176
|
#subscriptions = /* @__PURE__ */ new Map();
|
|
1177
|
+
#tasks = /* @__PURE__ */ new Map();
|
|
1166
1178
|
#messages = [];
|
|
1167
1179
|
#eventHistory = [];
|
|
1168
1180
|
#maxEventHistory;
|
|
@@ -1177,6 +1189,7 @@ var TestServer = class {
|
|
|
1177
1189
|
#nextScopeId = 1;
|
|
1178
1190
|
#nextSubscriptionId = 1;
|
|
1179
1191
|
#nextMessageId = 1;
|
|
1192
|
+
#nextTaskId = 1;
|
|
1180
1193
|
constructor(options = {}) {
|
|
1181
1194
|
this.#options = options;
|
|
1182
1195
|
this.#sessionId = `session-${Date.now()}`;
|
|
@@ -1208,6 +1221,12 @@ var TestServer = class {
|
|
|
1208
1221
|
get scopes() {
|
|
1209
1222
|
return this.#scopes;
|
|
1210
1223
|
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Get all tasks
|
|
1226
|
+
*/
|
|
1227
|
+
get tasks() {
|
|
1228
|
+
return this.#tasks;
|
|
1229
|
+
}
|
|
1211
1230
|
/**
|
|
1212
1231
|
* Get all messages sent through the server
|
|
1213
1232
|
*/
|
|
@@ -1365,6 +1384,17 @@ var TestServer = class {
|
|
|
1365
1384
|
connection,
|
|
1366
1385
|
params
|
|
1367
1386
|
);
|
|
1387
|
+
// =======================================================================
|
|
1388
|
+
// Task Methods
|
|
1389
|
+
// =======================================================================
|
|
1390
|
+
case TASK_METHODS.TASKS_CREATE:
|
|
1391
|
+
return this.#handleTasksCreate(params);
|
|
1392
|
+
case TASK_METHODS.TASKS_ASSIGN:
|
|
1393
|
+
return this.#handleTasksAssign(params);
|
|
1394
|
+
case TASK_METHODS.TASKS_UPDATE:
|
|
1395
|
+
return this.#handleTasksUpdate(params);
|
|
1396
|
+
case TASK_METHODS.TASKS_LIST:
|
|
1397
|
+
return this.#handleTasksList(params);
|
|
1368
1398
|
default:
|
|
1369
1399
|
throw MAPRequestError.methodNotFound(method);
|
|
1370
1400
|
}
|
|
@@ -2183,6 +2213,94 @@ var TestServer = class {
|
|
|
2183
2213
|
effectivePermissions
|
|
2184
2214
|
};
|
|
2185
2215
|
}
|
|
2216
|
+
// ===========================================================================
|
|
2217
|
+
// Task Handlers
|
|
2218
|
+
// ===========================================================================
|
|
2219
|
+
#handleTasksCreate(params) {
|
|
2220
|
+
const { task: taskInput } = params;
|
|
2221
|
+
const id = taskInput.id ?? `task-${this.#nextTaskId++}`;
|
|
2222
|
+
const task = {
|
|
2223
|
+
id,
|
|
2224
|
+
...taskInput.assignee !== void 0 && { assignee: taskInput.assignee },
|
|
2225
|
+
...taskInput.title !== void 0 && { title: taskInput.title },
|
|
2226
|
+
...taskInput.status !== void 0 && { status: taskInput.status },
|
|
2227
|
+
...taskInput.description !== void 0 && { description: taskInput.description },
|
|
2228
|
+
...taskInput.meta !== void 0 && { meta: taskInput.meta }
|
|
2229
|
+
};
|
|
2230
|
+
this.#tasks.set(id, task);
|
|
2231
|
+
this.emitEvent({
|
|
2232
|
+
type: EVENT_TYPES.TASK_CREATED,
|
|
2233
|
+
data: { task }
|
|
2234
|
+
});
|
|
2235
|
+
return { task };
|
|
2236
|
+
}
|
|
2237
|
+
#handleTasksAssign(params) {
|
|
2238
|
+
const { taskId, agentId } = params;
|
|
2239
|
+
const task = this.#tasks.get(taskId);
|
|
2240
|
+
if (!task) {
|
|
2241
|
+
throw MAPRequestError.invalidParams(`Task ${taskId} not found`);
|
|
2242
|
+
}
|
|
2243
|
+
task.assignee = agentId;
|
|
2244
|
+
this.#tasks.set(taskId, task);
|
|
2245
|
+
this.emitEvent({
|
|
2246
|
+
type: EVENT_TYPES.TASK_ASSIGNED,
|
|
2247
|
+
data: { taskId, agentId }
|
|
2248
|
+
});
|
|
2249
|
+
return { task };
|
|
2250
|
+
}
|
|
2251
|
+
#handleTasksUpdate(params) {
|
|
2252
|
+
const { taskId, ...updates } = params;
|
|
2253
|
+
const task = this.#tasks.get(taskId);
|
|
2254
|
+
if (!task) {
|
|
2255
|
+
throw MAPRequestError.invalidParams(`Task ${taskId} not found`);
|
|
2256
|
+
}
|
|
2257
|
+
const previousStatus = task.status;
|
|
2258
|
+
if (updates.status !== void 0) task.status = updates.status;
|
|
2259
|
+
if (updates.title !== void 0) task.title = updates.title;
|
|
2260
|
+
if (updates.description !== void 0) task.description = updates.description;
|
|
2261
|
+
if (updates.assignee !== void 0) task.assignee = updates.assignee;
|
|
2262
|
+
if (updates.meta !== void 0) task.meta = { ...task.meta, ...updates.meta };
|
|
2263
|
+
this.#tasks.set(taskId, task);
|
|
2264
|
+
if (updates.status !== void 0 && updates.status !== previousStatus) {
|
|
2265
|
+
this.emitEvent({
|
|
2266
|
+
type: EVENT_TYPES.TASK_STATUS,
|
|
2267
|
+
data: {
|
|
2268
|
+
taskId,
|
|
2269
|
+
previous: previousStatus ?? "open",
|
|
2270
|
+
current: updates.status
|
|
2271
|
+
}
|
|
2272
|
+
});
|
|
2273
|
+
}
|
|
2274
|
+
if (updates.status === "completed") {
|
|
2275
|
+
this.emitEvent({
|
|
2276
|
+
type: EVENT_TYPES.TASK_COMPLETED,
|
|
2277
|
+
data: { taskId }
|
|
2278
|
+
});
|
|
2279
|
+
}
|
|
2280
|
+
return { task };
|
|
2281
|
+
}
|
|
2282
|
+
#handleTasksList(params) {
|
|
2283
|
+
let tasks = Array.from(this.#tasks.values());
|
|
2284
|
+
if (params?.filter) {
|
|
2285
|
+
const { assignee, status } = params.filter;
|
|
2286
|
+
if (assignee) {
|
|
2287
|
+
tasks = tasks.filter((t) => t.assignee === assignee);
|
|
2288
|
+
}
|
|
2289
|
+
if (status) {
|
|
2290
|
+
const statuses = Array.isArray(status) ? status : [status];
|
|
2291
|
+
tasks = tasks.filter((t) => t.status !== void 0 && statuses.includes(t.status));
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
const limit = params?.limit ?? 100;
|
|
2295
|
+
const startIndex = params?.cursor ? parseInt(params.cursor, 10) : 0;
|
|
2296
|
+
const slice = tasks.slice(startIndex, startIndex + limit);
|
|
2297
|
+
const hasMore = startIndex + limit < tasks.length;
|
|
2298
|
+
return {
|
|
2299
|
+
tasks: slice,
|
|
2300
|
+
hasMore,
|
|
2301
|
+
nextCursor: hasMore ? String(startIndex + limit) : void 0
|
|
2302
|
+
};
|
|
2303
|
+
}
|
|
2186
2304
|
};
|
|
2187
2305
|
|
|
2188
2306
|
// src/stream/index.ts
|
|
@@ -4238,6 +4356,58 @@ var ClientConnection = class _ClientConnection {
|
|
|
4238
4356
|
});
|
|
4239
4357
|
}
|
|
4240
4358
|
// ===========================================================================
|
|
4359
|
+
// Tasks
|
|
4360
|
+
// ===========================================================================
|
|
4361
|
+
/**
|
|
4362
|
+
* Create a new task.
|
|
4363
|
+
*
|
|
4364
|
+
* @param params - Task creation parameters
|
|
4365
|
+
* @returns The created task
|
|
4366
|
+
*/
|
|
4367
|
+
async createTask(params) {
|
|
4368
|
+
return this.#connection.sendRequest(
|
|
4369
|
+
TASK_METHODS.TASKS_CREATE,
|
|
4370
|
+
params
|
|
4371
|
+
);
|
|
4372
|
+
}
|
|
4373
|
+
/**
|
|
4374
|
+
* Assign a task to an agent.
|
|
4375
|
+
*
|
|
4376
|
+
* @param taskId - ID of the task to assign
|
|
4377
|
+
* @param agentId - ID of the agent to assign to
|
|
4378
|
+
* @returns The updated task
|
|
4379
|
+
*/
|
|
4380
|
+
async assignTask(taskId, agentId) {
|
|
4381
|
+
return this.#connection.sendRequest(
|
|
4382
|
+
TASK_METHODS.TASKS_ASSIGN,
|
|
4383
|
+
{ taskId, agentId }
|
|
4384
|
+
);
|
|
4385
|
+
}
|
|
4386
|
+
/**
|
|
4387
|
+
* Update a task's status or fields.
|
|
4388
|
+
*
|
|
4389
|
+
* @param params - Update parameters including taskId and fields to change
|
|
4390
|
+
* @returns The updated task
|
|
4391
|
+
*/
|
|
4392
|
+
async updateTask(params) {
|
|
4393
|
+
return this.#connection.sendRequest(
|
|
4394
|
+
TASK_METHODS.TASKS_UPDATE,
|
|
4395
|
+
params
|
|
4396
|
+
);
|
|
4397
|
+
}
|
|
4398
|
+
/**
|
|
4399
|
+
* List tasks with optional filters.
|
|
4400
|
+
*
|
|
4401
|
+
* @param params - Optional filter, limit, and cursor parameters
|
|
4402
|
+
* @returns Paginated list of tasks
|
|
4403
|
+
*/
|
|
4404
|
+
async listTasks(params) {
|
|
4405
|
+
return this.#connection.sendRequest(
|
|
4406
|
+
TASK_METHODS.TASKS_LIST,
|
|
4407
|
+
params ?? {}
|
|
4408
|
+
);
|
|
4409
|
+
}
|
|
4410
|
+
// ===========================================================================
|
|
4241
4411
|
// Reconnection
|
|
4242
4412
|
// ===========================================================================
|
|
4243
4413
|
/**
|