@mastra/server 1.58.0-alpha.1 → 1.58.0-alpha.3
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/CHANGELOG.md +63 -0
- package/dist/_types/@mastra_schema-compat/dist/provider-compats/anthropic.d.ts +1 -1
- package/dist/{a2a-CnU9zaGR.js → a2a-8C4O2dVJ.js} +41 -5
- package/dist/a2a-8C4O2dVJ.js.map +1 -0
- package/dist/{a2a-D3ZYeXIx.cjs → a2a-B6YkZ2i9.cjs} +277 -52
- package/dist/a2a-B6YkZ2i9.cjs.map +1 -0
- package/dist/{a2a-oM7aqLz4.cjs → a2a-MPoM5lzS.cjs} +41 -5
- package/dist/a2a-MPoM5lzS.cjs.map +1 -0
- package/dist/{a2a-CHi9AJ0n.js → a2a-_D2EA4oa.js} +266 -53
- package/dist/a2a-_D2EA4oa.js.map +1 -0
- package/dist/{agent-builder-BDYN3r89.cjs → agent-builder-DAiJH1u2.cjs} +2 -2
- package/dist/{agent-builder-BDYN3r89.cjs.map → agent-builder-DAiJH1u2.cjs.map} +1 -1
- package/dist/{agent-builder-Dqy_qumV.js → agent-builder-gGFywDVq.js} +2 -2
- package/dist/{agent-builder-Dqy_qumV.js.map → agent-builder-gGFywDVq.js.map} +1 -1
- package/dist/{api-schema-manifest-J5hfk5ZZ.cjs → api-schema-manifest-B3bC-D98.cjs} +2 -2
- package/dist/{api-schema-manifest-J5hfk5ZZ.cjs.map → api-schema-manifest-B3bC-D98.cjs.map} +1 -1
- package/dist/{api-schema-manifest-R8CsF6RX.js → api-schema-manifest-B4J_QYOr.js} +2 -2
- package/dist/{api-schema-manifest-R8CsF6RX.js.map → api-schema-manifest-B4J_QYOr.js.map} +1 -1
- package/dist/{dist-IUXZtNBY.js → dist-BKRMiJcn.js} +102 -49
- package/dist/dist-BKRMiJcn.js.map +1 -0
- package/dist/{dist-DgY0llRv.cjs → dist-C2-SedDQ.cjs} +102 -49
- package/dist/dist-C2-SedDQ.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-agents-a2a.md +39 -0
- package/dist/docs/references/reference-server-routes.md +25 -11
- package/dist/route-builder-CIk5k35M.js.map +1 -1
- package/dist/route-builder-CgLVYL1c.cjs.map +1 -1
- package/dist/{routes-BzR8iVj4.cjs → routes-CZwPlO3-.cjs} +3 -2
- package/dist/routes-CZwPlO3-.cjs.map +1 -0
- package/dist/{routes-C7iRCN_l.js → routes-HUaCyUb7.js} +4 -3
- package/dist/{routes-C7iRCN_l.js.map → routes-HUaCyUb7.js.map} +1 -1
- package/dist/server/a2a/store.cjs +4 -0
- package/dist/server/a2a/store.cjs.map +1 -1
- package/dist/server/a2a/store.d.ts +3 -0
- package/dist/server/a2a/store.d.ts.map +1 -1
- package/dist/server/a2a/store.js +4 -0
- package/dist/server/a2a/store.js.map +1 -1
- package/dist/server/handlers/a2a.cjs +3 -1
- package/dist/server/handlers/a2a.d.ts +152 -10
- package/dist/server/handlers/a2a.d.ts.map +1 -1
- package/dist/server/handlers/a2a.js +2 -2
- package/dist/server/handlers/agent-builder.cjs +3 -3
- package/dist/server/handlers/agent-builder.js +3 -3
- package/dist/server/handlers/agent-controller.cjs +25 -6
- package/dist/server/handlers/agent-controller.cjs.map +1 -1
- package/dist/server/handlers/agent-controller.d.ts +4 -3
- package/dist/server/handlers/agent-controller.d.ts.map +1 -1
- package/dist/server/handlers/agent-controller.js +25 -6
- package/dist/server/handlers/agent-controller.js.map +1 -1
- package/dist/server/handlers/mcp-client-versions.cjs +1 -1
- package/dist/server/handlers/mcp-client-versions.js +1 -1
- package/dist/server/handlers/prompt-block-versions.cjs +1 -1
- package/dist/server/handlers/prompt-block-versions.js +1 -1
- package/dist/server/handlers/scorer-versions.cjs +1 -1
- package/dist/server/handlers/scorer-versions.js +1 -1
- package/dist/server/handlers/stored-mcp-clients.cjs +1 -1
- package/dist/server/handlers/stored-mcp-clients.js +1 -1
- package/dist/server/handlers/stored-prompt-blocks.cjs +1 -1
- package/dist/server/handlers/stored-prompt-blocks.js +1 -1
- package/dist/server/handlers/stored-scorers.cjs +1 -1
- package/dist/server/handlers/stored-scorers.js +1 -1
- package/dist/server/handlers/stored-skill-favorites.cjs +1 -1
- package/dist/server/handlers/stored-skill-favorites.js +1 -1
- package/dist/server/handlers/stored-skills.cjs +1 -1
- package/dist/server/handlers/stored-skills.js +1 -1
- package/dist/server/handlers/system.cjs +1 -1
- package/dist/server/handlers/system.js +1 -1
- package/dist/server/handlers/workflows.cjs +93 -2
- package/dist/server/handlers/workflows.cjs.map +1 -1
- package/dist/server/handlers/workflows.d.ts +9 -0
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +92 -3
- package/dist/server/handlers/workflows.js.map +1 -1
- package/dist/server/handlers.cjs +1 -1
- package/dist/server/handlers.js +1 -1
- package/dist/server/schemas/a2a.d.ts +70 -6
- package/dist/server/schemas/a2a.d.ts.map +1 -1
- package/dist/server/schemas/index.cjs +4 -4
- package/dist/server/schemas/index.js +4 -4
- package/dist/server/schemas/workflows.d.ts +8 -0
- package/dist/server/schemas/workflows.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +1 -1
- package/dist/server/server-adapter/index.js +1 -1
- package/dist/server/server-adapter/routes/a2a.d.ts +116 -8
- package/dist/server/server-adapter/routes/a2a.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/workflows.d.ts +7 -1
- package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -1
- package/dist/{workflows-DPW6FrY0.js → workflows-CMU5dz_4.js} +7 -2
- package/dist/workflows-CMU5dz_4.js.map +1 -0
- package/dist/{workflows-XfiENvkF.cjs → workflows-Dzxr6cmf.cjs} +12 -1
- package/dist/workflows-Dzxr6cmf.cjs.map +1 -0
- package/package.json +7 -7
- package/dist/a2a-CHi9AJ0n.js.map +0 -1
- package/dist/a2a-CnU9zaGR.js.map +0 -1
- package/dist/a2a-D3ZYeXIx.cjs.map +0 -1
- package/dist/a2a-oM7aqLz4.cjs.map +0 -1
- package/dist/dist-DgY0llRv.cjs.map +0 -1
- package/dist/dist-IUXZtNBY.js.map +0 -1
- package/dist/routes-BzR8iVj4.cjs.map +0 -1
- package/dist/workflows-DPW6FrY0.js.map +0 -1
- package/dist/workflows-XfiENvkF.cjs.map +0 -1
|
@@ -3,7 +3,7 @@ import { n as createRoute } from "./route-builder-CIk5k35M.js";
|
|
|
3
3
|
import { r as convertInstructionsToString } from "./utils-BUK03Frl.js";
|
|
4
4
|
import { getAgentFromSystem } from "./server/handlers/agents.js";
|
|
5
5
|
import { TaskStoreVersionConflictError } from "./server/a2a/store.js";
|
|
6
|
-
import { a as agentExecutionResponseSchema, i as agentExecutionBodySchema, r as agentCardResponseSchema, t as a2aAgentIdPathParams } from "./a2a-
|
|
6
|
+
import { a as agentExecutionResponseSchema, i as agentExecutionBodySchema, r as agentCardResponseSchema, t as a2aAgentIdPathParams } from "./a2a-8C4O2dVJ.js";
|
|
7
7
|
import { getPublicOrigin } from "./server/handlers/auth.js";
|
|
8
8
|
import { z } from "zod/v4";
|
|
9
9
|
import { isDeepStrictEqual } from "util";
|
|
@@ -420,7 +420,9 @@ var a2a_exports = /* @__PURE__ */ __exportAll({
|
|
|
420
420
|
handleSetTaskPushNotificationConfig: () => handleSetTaskPushNotificationConfig,
|
|
421
421
|
handleTaskCancel: () => handleTaskCancel,
|
|
422
422
|
handleTaskGet: () => handleTaskGet,
|
|
423
|
-
|
|
423
|
+
handleTaskList: () => handleTaskList,
|
|
424
|
+
handleTaskResubscribe: () => handleTaskResubscribe,
|
|
425
|
+
resolveA2AProtocolVersion: () => resolveA2AProtocolVersion
|
|
424
426
|
});
|
|
425
427
|
const messagePartSchema = z.discriminatedUnion("kind", [
|
|
426
428
|
z.object({
|
|
@@ -462,6 +464,7 @@ const messageSendParamsSchema = z.object({
|
|
|
462
464
|
configuration: z.object({
|
|
463
465
|
acceptedOutputModes: z.array(z.string()).optional(),
|
|
464
466
|
blocking: z.boolean().optional(),
|
|
467
|
+
returnImmediately: z.boolean().optional(),
|
|
465
468
|
historyLength: z.number().optional(),
|
|
466
469
|
pushNotificationConfig: z.object({
|
|
467
470
|
url: z.string(),
|
|
@@ -476,6 +479,159 @@ const messageSendParamsSchema = z.object({
|
|
|
476
479
|
});
|
|
477
480
|
const defaultPushNotificationStore = new InMemoryPushNotificationStore();
|
|
478
481
|
const defaultPushNotificationSender = new DefaultPushNotificationSender(defaultPushNotificationStore);
|
|
482
|
+
const V1_TASK_STATES = {
|
|
483
|
+
submitted: "TASK_STATE_SUBMITTED",
|
|
484
|
+
working: "TASK_STATE_WORKING",
|
|
485
|
+
completed: "TASK_STATE_COMPLETED",
|
|
486
|
+
failed: "TASK_STATE_FAILED",
|
|
487
|
+
canceled: "TASK_STATE_CANCELED",
|
|
488
|
+
"input-required": "TASK_STATE_INPUT_REQUIRED",
|
|
489
|
+
rejected: "TASK_STATE_REJECTED",
|
|
490
|
+
"auth-required": "TASK_STATE_AUTH_REQUIRED"
|
|
491
|
+
};
|
|
492
|
+
function normalizeV1Part(part) {
|
|
493
|
+
if ("text" in part) return {
|
|
494
|
+
kind: "text",
|
|
495
|
+
text: part.text,
|
|
496
|
+
metadata: part.metadata
|
|
497
|
+
};
|
|
498
|
+
if ("raw" in part) return {
|
|
499
|
+
kind: "file",
|
|
500
|
+
file: {
|
|
501
|
+
bytes: part.raw,
|
|
502
|
+
mimeType: part.mediaType,
|
|
503
|
+
name: part.filename
|
|
504
|
+
},
|
|
505
|
+
metadata: part.metadata
|
|
506
|
+
};
|
|
507
|
+
if ("url" in part) return {
|
|
508
|
+
kind: "file",
|
|
509
|
+
file: {
|
|
510
|
+
uri: part.url,
|
|
511
|
+
mimeType: part.mediaType,
|
|
512
|
+
name: part.filename
|
|
513
|
+
},
|
|
514
|
+
metadata: part.metadata
|
|
515
|
+
};
|
|
516
|
+
return {
|
|
517
|
+
kind: "data",
|
|
518
|
+
data: part.data,
|
|
519
|
+
metadata: part.metadata
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
function normalizeV1Params(params) {
|
|
523
|
+
if (!params?.message) return params;
|
|
524
|
+
const configuration = params.configuration;
|
|
525
|
+
return {
|
|
526
|
+
...params,
|
|
527
|
+
message: {
|
|
528
|
+
...params.message,
|
|
529
|
+
kind: "message",
|
|
530
|
+
role: params.message.role === "ROLE_AGENT" ? "agent" : "user",
|
|
531
|
+
parts: params.message.parts.map((part) => normalizeV1Part(part))
|
|
532
|
+
},
|
|
533
|
+
configuration: configuration ? {
|
|
534
|
+
...configuration,
|
|
535
|
+
blocking: configuration.returnImmediately === void 0 ? void 0 : !configuration.returnImmediately,
|
|
536
|
+
pushNotificationConfig: configuration.taskPushNotificationConfig
|
|
537
|
+
} : void 0
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
function toV1Part(part) {
|
|
541
|
+
if (part.kind === "text") return {
|
|
542
|
+
text: part.text,
|
|
543
|
+
metadata: part.metadata
|
|
544
|
+
};
|
|
545
|
+
if (part.kind === "file") return "uri" in part.file ? {
|
|
546
|
+
url: part.file.uri,
|
|
547
|
+
filename: part.file.name,
|
|
548
|
+
mediaType: part.file.mimeType,
|
|
549
|
+
metadata: part.metadata
|
|
550
|
+
} : {
|
|
551
|
+
raw: part.file.bytes,
|
|
552
|
+
filename: part.file.name,
|
|
553
|
+
mediaType: part.file.mimeType,
|
|
554
|
+
metadata: part.metadata
|
|
555
|
+
};
|
|
556
|
+
return {
|
|
557
|
+
data: part.data,
|
|
558
|
+
metadata: part.metadata
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
function toV1Message(message) {
|
|
562
|
+
if (!message) return void 0;
|
|
563
|
+
return {
|
|
564
|
+
messageId: message.messageId,
|
|
565
|
+
contextId: message.contextId,
|
|
566
|
+
taskId: message.taskId,
|
|
567
|
+
role: message.role === "agent" ? "ROLE_AGENT" : "ROLE_USER",
|
|
568
|
+
parts: message.parts?.map(toV1Part),
|
|
569
|
+
metadata: message.metadata,
|
|
570
|
+
extensions: message.extensions,
|
|
571
|
+
referenceTaskIds: message.referenceTaskIds
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
function toV1Task(task, { includeArtifacts = true, historyLength } = {}) {
|
|
575
|
+
return {
|
|
576
|
+
id: task.id,
|
|
577
|
+
contextId: task.contextId,
|
|
578
|
+
status: {
|
|
579
|
+
state: V1_TASK_STATES[task.status.state] ?? "TASK_STATE_UNSPECIFIED",
|
|
580
|
+
message: toV1Message(task.status.message),
|
|
581
|
+
timestamp: task.status.timestamp
|
|
582
|
+
},
|
|
583
|
+
artifacts: includeArtifacts ? task.artifacts?.map((artifact) => ({
|
|
584
|
+
artifactId: artifact.artifactId,
|
|
585
|
+
name: artifact.name,
|
|
586
|
+
description: artifact.description,
|
|
587
|
+
parts: artifact.parts?.map(toV1Part),
|
|
588
|
+
metadata: artifact.metadata,
|
|
589
|
+
extensions: artifact.extensions
|
|
590
|
+
})) : void 0,
|
|
591
|
+
history: task.history?.slice(historyLength === void 0 ? 0 : -historyLength).map(toV1Message),
|
|
592
|
+
metadata: task.metadata
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
function toV1Result(result, method) {
|
|
596
|
+
if (method === "message/send") return result?.kind === "message" ? { message: toV1Message(result) } : { task: toV1Task(result) };
|
|
597
|
+
if (method === "message/stream" || method === "tasks/resubscribe") {
|
|
598
|
+
if (result?.kind === "status-update") return { statusUpdate: {
|
|
599
|
+
taskId: result.taskId,
|
|
600
|
+
contextId: result.contextId,
|
|
601
|
+
status: {
|
|
602
|
+
state: V1_TASK_STATES[result.status.state] ?? "TASK_STATE_UNSPECIFIED",
|
|
603
|
+
message: toV1Message(result.status.message),
|
|
604
|
+
timestamp: result.status.timestamp
|
|
605
|
+
},
|
|
606
|
+
final: result.final,
|
|
607
|
+
metadata: result.metadata
|
|
608
|
+
} };
|
|
609
|
+
if (result?.kind === "artifact-update") return { artifactUpdate: {
|
|
610
|
+
taskId: result.taskId,
|
|
611
|
+
contextId: result.contextId,
|
|
612
|
+
artifact: {
|
|
613
|
+
...result.artifact,
|
|
614
|
+
parts: result.artifact.parts?.map(toV1Part)
|
|
615
|
+
},
|
|
616
|
+
append: result.append,
|
|
617
|
+
lastChunk: result.lastChunk,
|
|
618
|
+
metadata: result.metadata
|
|
619
|
+
} };
|
|
620
|
+
return result?.kind === "message" ? { message: toV1Message(result) } : { task: toV1Task(result) };
|
|
621
|
+
}
|
|
622
|
+
if (method === "tasks/get" || method === "tasks/cancel") return toV1Task(result);
|
|
623
|
+
return result;
|
|
624
|
+
}
|
|
625
|
+
function convertV1Response(response, method) {
|
|
626
|
+
if (!response || !("result" in response)) return response;
|
|
627
|
+
return {
|
|
628
|
+
...response,
|
|
629
|
+
result: toV1Result(response.result, method)
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
async function* convertV1Stream(stream, method) {
|
|
633
|
+
for await (const response of stream) yield convertV1Response(response, method);
|
|
634
|
+
}
|
|
479
635
|
function createAgentCardDefaults({ pushNotifications = false } = {}) {
|
|
480
636
|
return {
|
|
481
637
|
protocolVersion: "0.3.0",
|
|
@@ -1095,6 +1251,25 @@ async function handleTaskGet({ requestId, taskStore, agentId, taskId }) {
|
|
|
1095
1251
|
if (!task) throw MastraA2AError.taskNotFound(taskId);
|
|
1096
1252
|
return createSuccessResponse(requestId, task);
|
|
1097
1253
|
}
|
|
1254
|
+
function handleTaskList({ requestId, taskStore, agentId, params }) {
|
|
1255
|
+
const requestedPageSize = params.pageSize ?? 50;
|
|
1256
|
+
const offset = params.pageToken ? Number.parseInt(params.pageToken, 10) : 0;
|
|
1257
|
+
const start = Number.isFinite(offset) && offset >= 0 ? offset : 0;
|
|
1258
|
+
const status = typeof params.status === "string" ? params.status.replace(/^TASK_STATE_/, "").toLowerCase().replaceAll("_", "-") : void 0;
|
|
1259
|
+
const timestampAfter = params.statusTimestampAfter ? Date.parse(params.statusTimestampAfter) : void 0;
|
|
1260
|
+
const matchingTasks = taskStore.list({ agentId }).filter((task) => !params.contextId || task.contextId === params.contextId).filter((task) => !status || task.status.state === status).filter((task) => !timestampAfter || task.status.timestamp !== void 0 && Date.parse(task.status.timestamp) >= timestampAfter);
|
|
1261
|
+
const tasks = matchingTasks.slice(start, start + requestedPageSize).map((task) => toV1Task(task, {
|
|
1262
|
+
includeArtifacts: params.includeArtifacts ?? false,
|
|
1263
|
+
historyLength: params.historyLength
|
|
1264
|
+
}));
|
|
1265
|
+
const nextOffset = start + tasks.length;
|
|
1266
|
+
return createSuccessResponse(requestId, {
|
|
1267
|
+
tasks,
|
|
1268
|
+
nextPageToken: nextOffset < matchingTasks.length ? String(nextOffset) : "",
|
|
1269
|
+
pageSize: requestedPageSize,
|
|
1270
|
+
totalSize: matchingTasks.length
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1098
1273
|
async function loadTaskOrThrow({ taskStore, agentId, taskId }) {
|
|
1099
1274
|
const task = await taskStore.load({
|
|
1100
1275
|
agentId,
|
|
@@ -1612,63 +1787,87 @@ async function handleTaskCancel({ requestId, taskStore, pushNotificationSender,
|
|
|
1612
1787
|
}
|
|
1613
1788
|
throw MastraA2AError.invalidRequest(`Task ${taskId} was updated concurrently. Retry the request.`);
|
|
1614
1789
|
}
|
|
1615
|
-
async function getAgentExecutionHandler({ requestId, mastra, agentId, requestContext, method, params, taskStore, pushNotificationStore, pushNotificationSender, logger, abortSignal }) {
|
|
1790
|
+
async function getAgentExecutionHandler({ requestId, mastra, agentId, requestContext, method, params, taskStore, pushNotificationStore, pushNotificationSender, logger, abortSignal, protocolVersion = "0.3" }) {
|
|
1616
1791
|
const agent = await getAgentFromSystem({
|
|
1617
1792
|
mastra,
|
|
1618
1793
|
agentId
|
|
1619
1794
|
});
|
|
1795
|
+
const protocolParams = protocolVersion === "1.0" ? normalizeV1Params(params) : params;
|
|
1620
1796
|
const { pushNotificationStore: resolvedPushNotificationStore, pushNotificationSender: resolvedPushNotificationSender } = resolvePushNotificationPair({
|
|
1621
1797
|
pushNotificationStore,
|
|
1622
1798
|
pushNotificationSender
|
|
1623
1799
|
});
|
|
1624
1800
|
let taskId;
|
|
1625
1801
|
try {
|
|
1626
|
-
taskId = getTaskIdFromParams(
|
|
1802
|
+
taskId = getTaskIdFromParams(protocolParams);
|
|
1627
1803
|
switch (method) {
|
|
1628
|
-
case "message/send":
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
}
|
|
1657
|
-
case "tasks/
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1804
|
+
case "message/send": {
|
|
1805
|
+
const result = await handleMessageSend({
|
|
1806
|
+
requestId,
|
|
1807
|
+
params: protocolParams,
|
|
1808
|
+
taskStore,
|
|
1809
|
+
pushNotificationStore: resolvedPushNotificationStore,
|
|
1810
|
+
pushNotificationSender: resolvedPushNotificationSender,
|
|
1811
|
+
agent,
|
|
1812
|
+
agentId,
|
|
1813
|
+
logger,
|
|
1814
|
+
requestContext
|
|
1815
|
+
});
|
|
1816
|
+
return protocolVersion === "1.0" ? convertV1Response(result, method) : result;
|
|
1817
|
+
}
|
|
1818
|
+
case "message/stream": {
|
|
1819
|
+
const result = await handleMessageStream({
|
|
1820
|
+
requestId,
|
|
1821
|
+
taskStore,
|
|
1822
|
+
params: protocolParams,
|
|
1823
|
+
pushNotificationStore: resolvedPushNotificationStore,
|
|
1824
|
+
pushNotificationSender: resolvedPushNotificationSender,
|
|
1825
|
+
agent,
|
|
1826
|
+
agentId,
|
|
1827
|
+
logger,
|
|
1828
|
+
requestContext,
|
|
1829
|
+
abortSignal
|
|
1830
|
+
});
|
|
1831
|
+
return protocolVersion === "1.0" ? convertV1Stream(result, method) : result;
|
|
1832
|
+
}
|
|
1833
|
+
case "tasks/get": {
|
|
1834
|
+
const result = await handleTaskGet({
|
|
1835
|
+
requestId,
|
|
1836
|
+
taskStore,
|
|
1837
|
+
agentId,
|
|
1838
|
+
taskId: taskId || "No task ID provided"
|
|
1839
|
+
});
|
|
1840
|
+
return protocolVersion === "1.0" ? convertV1Response(result, method) : result;
|
|
1841
|
+
}
|
|
1842
|
+
case "tasks/list":
|
|
1843
|
+
if (protocolVersion !== "1.0") throw MastraA2AError.methodNotFound(method);
|
|
1844
|
+
return handleTaskList({
|
|
1845
|
+
requestId,
|
|
1846
|
+
taskStore,
|
|
1847
|
+
agentId,
|
|
1848
|
+
params: protocolParams ?? {}
|
|
1849
|
+
});
|
|
1850
|
+
case "tasks/cancel": {
|
|
1851
|
+
const result = await handleTaskCancel({
|
|
1852
|
+
requestId,
|
|
1853
|
+
taskStore,
|
|
1854
|
+
pushNotificationSender: resolvedPushNotificationSender,
|
|
1855
|
+
agentId,
|
|
1856
|
+
taskId: taskId || "No task ID provided",
|
|
1857
|
+
logger
|
|
1858
|
+
});
|
|
1859
|
+
return protocolVersion === "1.0" ? convertV1Response(result, method) : result;
|
|
1860
|
+
}
|
|
1861
|
+
case "tasks/resubscribe": {
|
|
1862
|
+
const result = handleTaskResubscribe({
|
|
1863
|
+
requestId,
|
|
1864
|
+
taskStore,
|
|
1865
|
+
agentId,
|
|
1866
|
+
taskId: taskId || "No task ID provided",
|
|
1867
|
+
abortSignal
|
|
1868
|
+
});
|
|
1869
|
+
return protocolVersion === "1.0" ? convertV1Stream(result, method) : result;
|
|
1870
|
+
}
|
|
1672
1871
|
case "tasks/pushNotificationConfig/set": return await handleSetTaskPushNotificationConfig({
|
|
1673
1872
|
requestId,
|
|
1674
1873
|
taskStore,
|
|
@@ -1705,6 +1904,12 @@ async function getAgentExecutionHandler({ requestId, mastra, agentId, requestCon
|
|
|
1705
1904
|
return normalizeError(error, requestId, taskId, logger);
|
|
1706
1905
|
}
|
|
1707
1906
|
}
|
|
1907
|
+
function resolveA2AProtocolVersion(request) {
|
|
1908
|
+
const version = request?.headers.get("A2A-Version")?.trim();
|
|
1909
|
+
if (!version || version === "0.3") return "0.3";
|
|
1910
|
+
if (version === "1.0") return "1.0";
|
|
1911
|
+
throw MastraA2AError.versionNotSupported(version);
|
|
1912
|
+
}
|
|
1708
1913
|
const GET_AGENT_CARD_ROUTE = createRoute({
|
|
1709
1914
|
method: "GET",
|
|
1710
1915
|
path: "/.well-known/:agentId/agent-card.json",
|
|
@@ -1741,23 +1946,31 @@ const AGENT_EXECUTION_ROUTE = createRoute({
|
|
|
1741
1946
|
description: "Executes an agent action via JSON-RPC 2.0 over A2A protocol",
|
|
1742
1947
|
tags: ["Agent-to-Agent"],
|
|
1743
1948
|
requiresAuth: true,
|
|
1744
|
-
handler: async ({ mastra, agentId, requestContext, taskStore, abortSignal, ...bodyParams }) => {
|
|
1949
|
+
handler: async ({ mastra, agentId, requestContext, taskStore, abortSignal, request, ...bodyParams }) => {
|
|
1745
1950
|
const { id: requestId, method } = bodyParams;
|
|
1951
|
+
const params = "params" in bodyParams ? bodyParams.params : void 0;
|
|
1952
|
+
let protocolVersion;
|
|
1953
|
+
try {
|
|
1954
|
+
protocolVersion = resolveA2AProtocolVersion(request);
|
|
1955
|
+
} catch (error) {
|
|
1956
|
+
return createA2AJsonResponse(normalizeError(error, requestId));
|
|
1957
|
+
}
|
|
1746
1958
|
const result = await getAgentExecutionHandler({
|
|
1747
1959
|
requestId,
|
|
1748
1960
|
mastra,
|
|
1749
1961
|
agentId,
|
|
1750
1962
|
requestContext,
|
|
1751
1963
|
method,
|
|
1752
|
-
params
|
|
1964
|
+
params,
|
|
1753
1965
|
taskStore,
|
|
1754
|
-
abortSignal
|
|
1966
|
+
abortSignal,
|
|
1967
|
+
protocolVersion
|
|
1755
1968
|
});
|
|
1756
1969
|
if (method === "message/stream" || method === "tasks/resubscribe") return createA2ASSEResponse(result);
|
|
1757
1970
|
return createA2AJsonResponse(result);
|
|
1758
1971
|
}
|
|
1759
1972
|
});
|
|
1760
1973
|
//#endregion
|
|
1761
|
-
export { getAgentExecutionHandler as a, handleListTaskPushNotificationConfig as c, handleSetTaskPushNotificationConfig as d, handleTaskCancel as f, getAgentCardByIdHandler as i, handleMessageSend as l,
|
|
1974
|
+
export { getAgentExecutionHandler as a, handleListTaskPushNotificationConfig as c, handleSetTaskPushNotificationConfig as d, handleTaskCancel as f, resolveA2AProtocolVersion as g, handleTaskResubscribe as h, getAgentCardByIdHandler as i, handleMessageSend as l, handleTaskList as m, GET_AGENT_CARD_ROUTE as n, handleDeleteTaskPushNotificationConfig as o, handleTaskGet as p, a2a_exports as r, handleGetTaskPushNotificationConfig as s, AGENT_EXECUTION_ROUTE as t, handleMessageStream as u };
|
|
1762
1975
|
|
|
1763
|
-
//# sourceMappingURL=a2a-
|
|
1976
|
+
//# sourceMappingURL=a2a-_D2EA4oa.js.map
|