@mastra/deployer 0.3.3-alpha.1 → 0.3.4-alpha.0

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.
@@ -269,6 +269,40 @@ provider: string;
269
269
  modelId: string;
270
270
  }, ContentfulStatusCode, "json">>;
271
271
 
272
+ export declare function getAgentCardByIdHandler(c: Context): Promise<Response & TypedResponse< {
273
+ name: string;
274
+ description?: string | null | undefined;
275
+ url: string;
276
+ provider?: {
277
+ organization: string;
278
+ url?: string | null | undefined;
279
+ } | null | undefined;
280
+ version: string;
281
+ documentationUrl?: string | null | undefined;
282
+ capabilities: {
283
+ streaming?: boolean | undefined;
284
+ pushNotifications?: boolean | undefined;
285
+ stateTransitionHistory?: boolean | undefined;
286
+ };
287
+ authentication?: {
288
+ schemes: string[];
289
+ credentials?: string | null | undefined;
290
+ } | null | undefined;
291
+ defaultInputModes?: string[] | undefined;
292
+ defaultOutputModes?: string[] | undefined;
293
+ skills: {
294
+ id: string;
295
+ name: string;
296
+ description?: string | null | undefined;
297
+ tags?: string[] | null | undefined;
298
+ examples?: string[] | null | undefined;
299
+ inputModes?: string[] | null | undefined;
300
+ outputModes?: string[] | null | undefined;
301
+ }[];
302
+ }, ContentfulStatusCode, "json">>;
303
+
304
+ export declare function getAgentExecutionHandler(c: Context): Promise<Response>;
305
+
272
306
  export declare function getAgentsHandler(c: Context): Promise<Response & TypedResponse<any, ContentfulStatusCode, "json">>;
273
307
 
274
308
  declare function getDeployer(entryFile: string, outputDir: string): Promise<MastraDeployer | undefined>;
@@ -269,6 +269,40 @@ provider: string;
269
269
  modelId: string;
270
270
  }, ContentfulStatusCode, "json">>;
271
271
 
272
+ export declare function getAgentCardByIdHandler(c: Context): Promise<Response & TypedResponse< {
273
+ name: string;
274
+ description?: string | null | undefined;
275
+ url: string;
276
+ provider?: {
277
+ organization: string;
278
+ url?: string | null | undefined;
279
+ } | null | undefined;
280
+ version: string;
281
+ documentationUrl?: string | null | undefined;
282
+ capabilities: {
283
+ streaming?: boolean | undefined;
284
+ pushNotifications?: boolean | undefined;
285
+ stateTransitionHistory?: boolean | undefined;
286
+ };
287
+ authentication?: {
288
+ schemes: string[];
289
+ credentials?: string | null | undefined;
290
+ } | null | undefined;
291
+ defaultInputModes?: string[] | undefined;
292
+ defaultOutputModes?: string[] | undefined;
293
+ skills: {
294
+ id: string;
295
+ name: string;
296
+ description?: string | null | undefined;
297
+ tags?: string[] | null | undefined;
298
+ examples?: string[] | null | undefined;
299
+ inputModes?: string[] | null | undefined;
300
+ outputModes?: string[] | null | undefined;
301
+ }[];
302
+ }, ContentfulStatusCode, "json">>;
303
+
304
+ export declare function getAgentExecutionHandler(c: Context): Promise<Response>;
305
+
272
306
  export declare function getAgentsHandler(c: Context): Promise<Response & TypedResponse<any, ContentfulStatusCode, "json">>;
273
307
 
274
308
  declare function getDeployer(entryFile: string, outputDir: string): Promise<MastraDeployer | undefined>;
@@ -18,6 +18,8 @@ var cors = require('hono/cors');
18
18
  var logger = require('hono/logger');
19
19
  var timeout = require('hono/timeout');
20
20
  var httpException = require('hono/http-exception');
21
+ var a2a = require('@mastra/server/handlers/a2a');
22
+ var streaming = require('hono/streaming');
21
23
  var agents = require('@mastra/server/handlers/agents');
22
24
  var logs = require('@mastra/server/handlers/logs');
23
25
  var memory = require('@mastra/server/handlers/memory');
@@ -28,7 +30,6 @@ var telemetry = require('@mastra/server/handlers/telemetry');
28
30
  var tools = require('@mastra/server/handlers/tools');
29
31
  var vector = require('@mastra/server/handlers/vector');
30
32
  var vNextWorkflows = require('@mastra/server/handlers/vNextWorkflows');
31
- var streaming = require('hono/streaming');
32
33
  var voice = require('@mastra/server/handlers/voice');
33
34
  var workflows = require('@mastra/server/handlers/workflows');
34
35
 
@@ -159,27 +160,48 @@ Object.setPrototypeOf(requestPrototype, Request.prototype);
159
160
  var newRequest = (incoming, defaultHostname) => {
160
161
  const req = Object.create(requestPrototype);
161
162
  req[incomingKey] = incoming;
163
+ const incomingUrl = incoming.url || "";
164
+ if (incomingUrl[0] !== "/" && // short-circuit for performance. most requests are relative URL.
165
+ (incomingUrl.startsWith("http://") || incomingUrl.startsWith("https://"))) {
166
+ if (incoming instanceof http2.Http2ServerRequest) {
167
+ throw new RequestError("Absolute URL for :path is not allowed in HTTP/2");
168
+ }
169
+ try {
170
+ const url2 = new URL(incomingUrl);
171
+ req[urlKey] = url2.href;
172
+ } catch (e2) {
173
+ throw new RequestError("Invalid absolute URL", { cause: e2 });
174
+ }
175
+ return req;
176
+ }
162
177
  const host = (incoming instanceof http2.Http2ServerRequest ? incoming.authority : incoming.headers.host) || defaultHostname;
163
178
  if (!host) {
164
179
  throw new RequestError("Missing host header");
165
180
  }
166
- const url = new URL(
167
- `${incoming instanceof http2.Http2ServerRequest || incoming.socket && incoming.socket.encrypted ? "https" : "http"}://${host}${incoming.url}`
168
- );
181
+ let scheme;
182
+ if (incoming instanceof http2.Http2ServerRequest) {
183
+ scheme = incoming.scheme;
184
+ if (!(scheme === "http" || scheme === "https")) {
185
+ throw new RequestError("Unsupported scheme");
186
+ }
187
+ } else {
188
+ scheme = incoming.socket && incoming.socket.encrypted ? "https" : "http";
189
+ }
190
+ const url = new URL(`${scheme}://${host}${incomingUrl}`);
169
191
  if (url.hostname.length !== host.length && url.hostname !== host.replace(/:\d+$/, "")) {
170
192
  throw new RequestError("Invalid host header");
171
193
  }
172
194
  req[urlKey] = url.href;
173
195
  return req;
174
196
  };
175
- function writeFromReadableStream(stream3, writable) {
176
- if (stream3.locked) {
197
+ function writeFromReadableStream(stream4, writable) {
198
+ if (stream4.locked) {
177
199
  throw new TypeError("ReadableStream is locked.");
178
200
  } else if (writable.destroyed) {
179
- stream3.cancel();
201
+ stream4.cancel();
180
202
  return;
181
203
  }
182
- const reader = stream3.getReader();
204
+ const reader = stream4.getReader();
183
205
  writable.on("close", cancel);
184
206
  writable.on("error", cancel);
185
207
  reader.read().then(flow, cancel);
@@ -377,7 +399,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
377
399
  const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
378
400
  const internalBody = getInternalBody(res);
379
401
  if (internalBody) {
380
- const { length, source, stream: stream3 } = internalBody;
402
+ const { length, source, stream: stream4 } = internalBody;
381
403
  if (source instanceof Uint8Array && source.byteLength !== length) ; else {
382
404
  if (length) {
383
405
  resHeaderRecord["content-length"] = length;
@@ -388,7 +410,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
388
410
  } else if (source instanceof Blob) {
389
411
  outgoing.end(new Uint8Array(await source.arrayBuffer()));
390
412
  } else {
391
- await writeFromReadableStream(stream3, outgoing);
413
+ await writeFromReadableStream(stream4, outgoing);
392
414
  }
393
415
  return;
394
416
  }
@@ -461,7 +483,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
461
483
  }
462
484
  }
463
485
  try {
464
- return responseViaResponseObject(res, outgoing, options);
486
+ return await responseViaResponseObject(res, outgoing, options);
465
487
  } catch (e2) {
466
488
  return handleResponseError(e2, outgoing);
467
489
  }
@@ -492,18 +514,18 @@ var ENCODINGS = {
492
514
  gzip: ".gz"
493
515
  };
494
516
  var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
495
- var createStreamBody = (stream3) => {
517
+ var createStreamBody = (stream4) => {
496
518
  const body = new ReadableStream({
497
519
  start(controller) {
498
- stream3.on("data", (chunk) => {
520
+ stream4.on("data", (chunk) => {
499
521
  controller.enqueue(chunk);
500
522
  });
501
- stream3.on("end", () => {
523
+ stream4.on("end", () => {
502
524
  controller.close();
503
525
  });
504
526
  },
505
527
  cancel() {
506
- stream3.destroy();
528
+ stream4.destroy();
507
529
  }
508
530
  });
509
531
  return body;
@@ -599,10 +621,10 @@ var serveStatic = (options = { root: "" }) => {
599
621
  end = size - 1;
600
622
  }
601
623
  const chunksize = end - start + 1;
602
- const stream3 = fs.createReadStream(path, { start, end });
624
+ const stream4 = fs.createReadStream(path, { start, end });
603
625
  c2.header("Content-Length", chunksize.toString());
604
626
  c2.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
605
- return c2.body(createStreamBody(stream3), 206);
627
+ return c2.body(createStreamBody(stream4), 206);
606
628
  };
607
629
  };
608
630
  var RENDER_TYPE = {
@@ -723,7 +745,7 @@ var middleware = (options) => async (c2) => {
723
745
  );
724
746
  };
725
747
 
726
- // ../../node_modules/.pnpm/hono-openapi@0.4.6_hono@4.7.4_openapi-types@12.1.3_zod@3.24.3/node_modules/hono-openapi/utils.js
748
+ // ../../node_modules/.pnpm/hono-openapi@0.4.6_hono@4.7.7_openapi-types@12.1.3_zod@3.24.4/node_modules/hono-openapi/utils.js
727
749
  var e = Symbol("openapi");
728
750
  var s2 = ["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"];
729
751
  var n = (e2) => e2.charAt(0).toUpperCase() + e2.slice(1);
@@ -849,6 +871,59 @@ async function x(e2, t2, s3 = {}) {
849
871
  }
850
872
  return { docs: o2, components: n2 };
851
873
  }
874
+ async function getAgentCardByIdHandler(c2) {
875
+ const mastra = c2.get("mastra");
876
+ const agentId = c2.req.param("agentId");
877
+ const runtimeContext = c2.get("runtimeContext");
878
+ const result = await a2a.getAgentCardByIdHandler({
879
+ mastra,
880
+ agentId,
881
+ runtimeContext
882
+ });
883
+ return c2.json(result);
884
+ }
885
+ async function getAgentExecutionHandler(c2) {
886
+ const mastra = c2.get("mastra");
887
+ const agentId = c2.req.param("agentId");
888
+ const runtimeContext = c2.get("runtimeContext");
889
+ const logger2 = mastra.getLogger();
890
+ const body = await c2.req.json();
891
+ if (!["tasks/send", "tasks/sendSubscribe", "tasks/get", "tasks/cancel"].includes(body.method)) {
892
+ return c2.json({ error: { message: `Unsupported method: ${body.method}`, code: "invalid_method" } }, 400);
893
+ }
894
+ const result = await a2a.getAgentExecutionHandler({
895
+ mastra,
896
+ agentId,
897
+ runtimeContext,
898
+ requestId: crypto.randomUUID(),
899
+ method: body.method,
900
+ params: body.params,
901
+ logger: logger2
902
+ });
903
+ if (body.method === "tasks/sendSubscribe") {
904
+ return streaming.stream(
905
+ c2,
906
+ async (stream4) => {
907
+ try {
908
+ stream4.onAbort(() => {
909
+ if (!result.locked) {
910
+ return result.cancel();
911
+ }
912
+ });
913
+ for await (const chunk of result) {
914
+ await stream4.write(JSON.stringify(chunk) + "");
915
+ }
916
+ } catch (err) {
917
+ logger2.error("Error in tasks/sendSubscribe stream: " + err?.message);
918
+ }
919
+ },
920
+ async (err) => {
921
+ logger2.error("Error in tasks/sendSubscribe stream: " + err?.message);
922
+ }
923
+ );
924
+ }
925
+ return c2.json(result);
926
+ }
852
927
  function handleError(error, defaultMessage) {
853
928
  const apiError = error;
854
929
  throw new httpException.HTTPException(apiError.status || 500, {
@@ -969,7 +1044,7 @@ async function setAgentInstructionsHandler(c2) {
969
1044
  // src/server/handlers/client.ts
970
1045
  var clients = /* @__PURE__ */ new Set();
971
1046
  function handleClientsRefresh(c2) {
972
- const stream3 = new ReadableStream({
1047
+ const stream4 = new ReadableStream({
973
1048
  start(controller) {
974
1049
  clients.add(controller);
975
1050
  controller.enqueue("data: connected\n\n");
@@ -978,7 +1053,7 @@ function handleClientsRefresh(c2) {
978
1053
  });
979
1054
  }
980
1055
  });
981
- return new Response(stream3, {
1056
+ return new Response(stream4, {
982
1057
  headers: {
983
1058
  "Content-Type": "text/event-stream",
984
1059
  "Cache-Control": "no-cache",
@@ -1398,13 +1473,14 @@ function executeToolHandler(tools$1) {
1398
1473
  const runtimeContext = c2.get("runtimeContext");
1399
1474
  const toolId = decodeURIComponent(c2.req.param("toolId"));
1400
1475
  const runId = c2.req.query("runId");
1401
- const { data } = await c2.req.json();
1476
+ const { data, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
1402
1477
  const result = await tools.executeToolHandler(tools$1)({
1403
1478
  mastra,
1404
1479
  toolId,
1405
1480
  data,
1406
1481
  runtimeContext,
1407
- runId
1482
+ runId,
1483
+ runtimeContextFromRequest
1408
1484
  });
1409
1485
  return c2.json(result);
1410
1486
  } catch (error) {
@@ -1418,13 +1494,14 @@ async function executeAgentToolHandler(c2) {
1418
1494
  const runtimeContext = c2.get("runtimeContext");
1419
1495
  const agentId = c2.req.param("agentId");
1420
1496
  const toolId = c2.req.param("toolId");
1421
- const { data } = await c2.req.json();
1497
+ const { data, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
1422
1498
  const result = await tools.executeAgentToolHandler({
1423
1499
  mastra,
1424
1500
  agentId,
1425
1501
  toolId,
1426
1502
  data,
1427
- runtimeContext
1503
+ runtimeContext,
1504
+ runtimeContextFromRequest
1428
1505
  });
1429
1506
  return c2.json(result);
1430
1507
  } catch (error) {
@@ -1572,11 +1649,13 @@ async function startAsyncVNextWorkflowHandler(c2) {
1572
1649
  try {
1573
1650
  const mastra = c2.get("mastra");
1574
1651
  const workflowId = c2.req.param("workflowId");
1575
- const { inputData, runtimeContext } = await c2.req.json();
1652
+ const runtimeContext = c2.get("runtimeContext");
1653
+ const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
1576
1654
  const runId = c2.req.query("runId");
1577
1655
  const result = await vNextWorkflows.startAsyncVNextWorkflowHandler({
1578
1656
  mastra,
1579
1657
  runtimeContext,
1658
+ runtimeContextFromRequest,
1580
1659
  workflowId,
1581
1660
  runId,
1582
1661
  inputData
@@ -1590,11 +1669,13 @@ async function startVNextWorkflowRunHandler(c2) {
1590
1669
  try {
1591
1670
  const mastra = c2.get("mastra");
1592
1671
  const workflowId = c2.req.param("workflowId");
1593
- const { inputData, runtimeContext } = await c2.req.json();
1672
+ const runtimeContext = c2.get("runtimeContext");
1673
+ const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
1594
1674
  const runId = c2.req.query("runId");
1595
1675
  await vNextWorkflows.startVNextWorkflowRunHandler({
1596
1676
  mastra,
1597
1677
  runtimeContext,
1678
+ runtimeContextFromRequest,
1598
1679
  workflowId,
1599
1680
  runId,
1600
1681
  inputData
@@ -1615,20 +1696,20 @@ function watchVNextWorkflowHandler(c2) {
1615
1696
  }
1616
1697
  return streaming.stream(
1617
1698
  c2,
1618
- async (stream3) => {
1699
+ async (stream4) => {
1619
1700
  try {
1620
1701
  const result = await vNextWorkflows.watchVNextWorkflowHandler({
1621
1702
  mastra,
1622
1703
  workflowId,
1623
1704
  runId
1624
1705
  });
1625
- stream3.onAbort(() => {
1706
+ stream4.onAbort(() => {
1626
1707
  if (!result.locked) {
1627
1708
  return result.cancel();
1628
1709
  }
1629
1710
  });
1630
1711
  for await (const chunk of result) {
1631
- await stream3.write(chunk.toString() + "");
1712
+ await stream4.write(chunk.toString() + "");
1632
1713
  }
1633
1714
  } catch (err) {
1634
1715
  console.log(err);
@@ -1647,13 +1728,15 @@ async function resumeAsyncVNextWorkflowHandler(c2) {
1647
1728
  const mastra = c2.get("mastra");
1648
1729
  const workflowId = c2.req.param("workflowId");
1649
1730
  const runId = c2.req.query("runId");
1650
- const { step, resumeData, runtimeContext } = await c2.req.json();
1731
+ const runtimeContext = c2.get("runtimeContext");
1732
+ const { step, resumeData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
1651
1733
  if (!runId) {
1652
1734
  throw new httpException.HTTPException(400, { message: "runId required to resume workflow" });
1653
1735
  }
1654
1736
  const result = await vNextWorkflows.resumeAsyncVNextWorkflowHandler({
1655
1737
  mastra,
1656
1738
  runtimeContext,
1739
+ runtimeContextFromRequest,
1657
1740
  workflowId,
1658
1741
  runId,
1659
1742
  body: { step, resumeData }
@@ -1850,20 +1933,20 @@ function watchWorkflowHandler(c2) {
1850
1933
  }
1851
1934
  return streaming.stream(
1852
1935
  c2,
1853
- async (stream3) => {
1936
+ async (stream4) => {
1854
1937
  try {
1855
1938
  const result = await workflows.watchWorkflowHandler({
1856
1939
  mastra,
1857
1940
  workflowId,
1858
1941
  runId
1859
1942
  });
1860
- stream3.onAbort(() => {
1943
+ stream4.onAbort(() => {
1861
1944
  if (!result.locked) {
1862
1945
  return result.cancel();
1863
1946
  }
1864
1947
  });
1865
1948
  for await (const chunk of result) {
1866
- await stream3.write(chunk.toString() + "");
1949
+ await stream4.write(chunk.toString() + "");
1867
1950
  }
1868
1951
  } catch (err) {
1869
1952
  console.log(err);
@@ -2093,7 +2176,18 @@ async function createHonoServer(mastra, options = {}) {
2093
2176
  app.onError(errorHandler);
2094
2177
  app.use("*", function setContext(c2, next) {
2095
2178
  const runtimeContext$1 = new runtimeContext.RuntimeContext();
2096
- c2.set("runtimeContext", runtimeContext$1);
2179
+ const proxyRuntimeContext = new Proxy(runtimeContext$1, {
2180
+ get(target, prop) {
2181
+ if (prop === "get") {
2182
+ return function(key) {
2183
+ const value = target.get(key);
2184
+ return value ?? `<${key}>`;
2185
+ };
2186
+ }
2187
+ return Reflect.get(target, prop);
2188
+ }
2189
+ });
2190
+ c2.set("runtimeContext", proxyRuntimeContext);
2097
2191
  c2.set("mastra", mastra);
2098
2192
  c2.set("tools", tools);
2099
2193
  c2.set("playground", options.playground === true);
@@ -2167,6 +2261,142 @@ async function createHonoServer(mastra, options = {}) {
2167
2261
  if (server?.build?.apiReqLogs) {
2168
2262
  app.use(logger.logger());
2169
2263
  }
2264
+ app.get(
2265
+ "/.well-known/:agentId/agent.json",
2266
+ h({
2267
+ description: "Get agent configuration",
2268
+ tags: ["agents"],
2269
+ parameters: [
2270
+ {
2271
+ name: "agentId",
2272
+ in: "path",
2273
+ required: true,
2274
+ schema: { type: "string" }
2275
+ }
2276
+ ],
2277
+ responses: {
2278
+ 200: {
2279
+ description: "Agent configuration"
2280
+ }
2281
+ }
2282
+ }),
2283
+ getAgentCardByIdHandler
2284
+ );
2285
+ app.post(
2286
+ "/a2a/:agentId",
2287
+ h({
2288
+ description: "Execute agent via A2A protocol",
2289
+ tags: ["agents"],
2290
+ parameters: [
2291
+ {
2292
+ name: "agentId",
2293
+ in: "path",
2294
+ required: true,
2295
+ schema: { type: "string" }
2296
+ }
2297
+ ],
2298
+ requestBody: {
2299
+ required: true,
2300
+ content: {
2301
+ "application/json": {
2302
+ schema: {
2303
+ type: "object",
2304
+ properties: {
2305
+ method: {
2306
+ type: "string",
2307
+ enum: ["tasks/send", "tasks/sendSubscribe", "tasks/get", "tasks/cancel"],
2308
+ description: "The A2A protocol method to execute"
2309
+ },
2310
+ params: {
2311
+ type: "object",
2312
+ oneOf: [
2313
+ {
2314
+ // TaskSendParams
2315
+ type: "object",
2316
+ properties: {
2317
+ id: {
2318
+ type: "string",
2319
+ description: "Unique identifier for the task being initiated or continued"
2320
+ },
2321
+ sessionId: {
2322
+ type: "string",
2323
+ description: "Optional identifier for the session this task belongs to"
2324
+ },
2325
+ message: {
2326
+ type: "object",
2327
+ description: "The message content to send to the agent for processing"
2328
+ },
2329
+ pushNotification: {
2330
+ type: "object",
2331
+ nullable: true,
2332
+ description: "Optional pushNotification information for receiving notifications about this task"
2333
+ },
2334
+ historyLength: {
2335
+ type: "integer",
2336
+ nullable: true,
2337
+ description: "Optional parameter to specify how much message history to include in the response"
2338
+ },
2339
+ metadata: {
2340
+ type: "object",
2341
+ nullable: true,
2342
+ description: "Optional metadata associated with sending this message"
2343
+ }
2344
+ },
2345
+ required: ["id", "message"]
2346
+ },
2347
+ {
2348
+ // TaskQueryParams
2349
+ type: "object",
2350
+ properties: {
2351
+ id: { type: "string", description: "The unique identifier of the task" },
2352
+ historyLength: {
2353
+ type: "integer",
2354
+ nullable: true,
2355
+ description: "Optional history length to retrieve for the task"
2356
+ },
2357
+ metadata: {
2358
+ type: "object",
2359
+ nullable: true,
2360
+ description: "Optional metadata to include with the operation"
2361
+ }
2362
+ },
2363
+ required: ["id"]
2364
+ },
2365
+ {
2366
+ // TaskIdParams
2367
+ type: "object",
2368
+ properties: {
2369
+ id: { type: "string", description: "The unique identifier of the task" },
2370
+ metadata: {
2371
+ type: "object",
2372
+ nullable: true,
2373
+ description: "Optional metadata to include with the operation"
2374
+ }
2375
+ },
2376
+ required: ["id"]
2377
+ }
2378
+ ]
2379
+ }
2380
+ },
2381
+ required: ["method", "params"]
2382
+ }
2383
+ }
2384
+ }
2385
+ },
2386
+ responses: {
2387
+ 200: {
2388
+ description: "A2A response"
2389
+ },
2390
+ 400: {
2391
+ description: "Missing or invalid request parameters"
2392
+ },
2393
+ 404: {
2394
+ description: "Agent not found"
2395
+ }
2396
+ }
2397
+ }),
2398
+ getAgentExecutionHandler
2399
+ );
2170
2400
  app.get(
2171
2401
  "/api",
2172
2402
  h({
@@ -3007,7 +3237,8 @@ async function createHonoServer(mastra, options = {}) {
3007
3237
  schema: {
3008
3238
  type: "object",
3009
3239
  properties: {
3010
- data: { type: "object" }
3240
+ data: { type: "object" },
3241
+ runtimeContext: { type: "object" }
3011
3242
  },
3012
3243
  required: ["data"]
3013
3244
  }
@@ -3394,7 +3625,10 @@ async function createHonoServer(mastra, options = {}) {
3394
3625
  oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
3395
3626
  },
3396
3627
  resumeData: { type: "object" },
3397
- runtimeContext: { type: "object" }
3628
+ runtimeContext: {
3629
+ type: "object",
3630
+ description: "Runtime context for the workflow execution"
3631
+ }
3398
3632
  },
3399
3633
  required: ["step"]
3400
3634
  }
@@ -3435,7 +3669,10 @@ async function createHonoServer(mastra, options = {}) {
3435
3669
  oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
3436
3670
  },
3437
3671
  resumeData: { type: "object" },
3438
- runtimeContext: { type: "object" }
3672
+ runtimeContext: {
3673
+ type: "object",
3674
+ description: "Runtime context for the workflow execution"
3675
+ }
3439
3676
  },
3440
3677
  required: ["step"]
3441
3678
  }
@@ -3501,7 +3738,10 @@ async function createHonoServer(mastra, options = {}) {
3501
3738
  type: "object",
3502
3739
  properties: {
3503
3740
  inputData: { type: "object" },
3504
- runtimeContext: { type: "object" }
3741
+ runtimeContext: {
3742
+ type: "object",
3743
+ description: "Runtime context for the workflow execution"
3744
+ }
3505
3745
  }
3506
3746
  }
3507
3747
  }
@@ -3545,7 +3785,10 @@ async function createHonoServer(mastra, options = {}) {
3545
3785
  type: "object",
3546
3786
  properties: {
3547
3787
  inputData: { type: "object" },
3548
- runtimeContext: { type: "object" }
3788
+ runtimeContext: {
3789
+ type: "object",
3790
+ description: "Runtime context for the workflow execution"
3791
+ }
3549
3792
  }
3550
3793
  }
3551
3794
  }
@@ -4072,7 +4315,8 @@ async function createHonoServer(mastra, options = {}) {
4072
4315
  schema: {
4073
4316
  type: "object",
4074
4317
  properties: {
4075
- data: { type: "object" }
4318
+ data: { type: "object" },
4319
+ runtimeContext: { type: "object" }
4076
4320
  },
4077
4321
  required: ["data"]
4078
4322
  }
@@ -4365,7 +4609,7 @@ async function createNodeServer(mastra, options = {}) {
4365
4609
  const host = serverOptions?.host ?? "localhost";
4366
4610
  logger2.info(` Mastra API running on port http://${host}:${port}/api`);
4367
4611
  if (options?.isDev) {
4368
- logger2.info(`\uFFFD Open API documentation available at http://${host}:${port}/openapi.json`);
4612
+ logger2.info(`\u{1F517} Open API documentation available at http://${host}:${port}/openapi.json`);
4369
4613
  }
4370
4614
  if (options?.isDev) {
4371
4615
  logger2.info(`\u{1F9EA} Swagger UI available at http://${host}:${port}/swagger-ui`);
@@ -16,6 +16,8 @@ import { cors } from 'hono/cors';
16
16
  import { logger } from 'hono/logger';
17
17
  import { timeout } from 'hono/timeout';
18
18
  import { HTTPException } from 'hono/http-exception';
19
+ import { getAgentCardByIdHandler as getAgentCardByIdHandler$1, getAgentExecutionHandler as getAgentExecutionHandler$1 } from '@mastra/server/handlers/a2a';
20
+ import { stream } from 'hono/streaming';
19
21
  import { getAgentsHandler as getAgentsHandler$1, getAgentByIdHandler as getAgentByIdHandler$1, getEvalsByAgentIdHandler as getEvalsByAgentIdHandler$1, getLiveEvalsByAgentIdHandler as getLiveEvalsByAgentIdHandler$1, generateHandler as generateHandler$2, streamGenerateHandler as streamGenerateHandler$2 } from '@mastra/server/handlers/agents';
20
22
  import { getLogsHandler as getLogsHandler$1, getLogTransports as getLogTransports$1, getLogsByRunIdHandler as getLogsByRunIdHandler$1 } from '@mastra/server/handlers/logs';
21
23
  import { getMemoryStatusHandler as getMemoryStatusHandler$1, getThreadsHandler as getThreadsHandler$1, getThreadByIdHandler as getThreadByIdHandler$1, getMessagesHandler as getMessagesHandler$1, createThreadHandler as createThreadHandler$1, updateThreadHandler as updateThreadHandler$1, deleteThreadHandler as deleteThreadHandler$1, saveMessagesHandler as saveMessagesHandler$1 } from '@mastra/server/handlers/memory';
@@ -26,7 +28,6 @@ import { getTelemetryHandler as getTelemetryHandler$1, storeTelemetryHandler as
26
28
  import { executeAgentToolHandler as executeAgentToolHandler$1, getToolsHandler as getToolsHandler$1, getToolByIdHandler as getToolByIdHandler$1, executeToolHandler as executeToolHandler$1 } from '@mastra/server/handlers/tools';
27
29
  import { upsertVectors as upsertVectors$1, createIndex as createIndex$1, queryVectors as queryVectors$1, listIndexes as listIndexes$1, describeIndex as describeIndex$1, deleteIndex as deleteIndex$1 } from '@mastra/server/handlers/vector';
28
30
  import { getVNextWorkflowsHandler as getVNextWorkflowsHandler$1, getVNextWorkflowByIdHandler as getVNextWorkflowByIdHandler$1, getVNextWorkflowRunsHandler as getVNextWorkflowRunsHandler$1, resumeVNextWorkflowHandler as resumeVNextWorkflowHandler$1, resumeAsyncVNextWorkflowHandler as resumeAsyncVNextWorkflowHandler$1, createVNextWorkflowRunHandler as createVNextWorkflowRunHandler$1, startAsyncVNextWorkflowHandler as startAsyncVNextWorkflowHandler$1, startVNextWorkflowRunHandler as startVNextWorkflowRunHandler$1, watchVNextWorkflowHandler as watchVNextWorkflowHandler$1 } from '@mastra/server/handlers/vNextWorkflows';
29
- import { stream } from 'hono/streaming';
30
31
  import { getSpeakersHandler as getSpeakersHandler$1, generateSpeechHandler, transcribeSpeechHandler } from '@mastra/server/handlers/voice';
31
32
  import { getWorkflowsHandler as getWorkflowsHandler$1, getWorkflowByIdHandler as getWorkflowByIdHandler$1, getWorkflowRunsHandler as getWorkflowRunsHandler$1, resumeWorkflowHandler as resumeWorkflowHandler$1, resumeAsyncWorkflowHandler as resumeAsyncWorkflowHandler$1, createRunHandler as createRunHandler$1, startAsyncWorkflowHandler as startAsyncWorkflowHandler$1, startWorkflowRunHandler as startWorkflowRunHandler$1, watchWorkflowHandler as watchWorkflowHandler$1 } from '@mastra/server/handlers/workflows';
32
33
 
@@ -153,27 +154,48 @@ Object.setPrototypeOf(requestPrototype, Request.prototype);
153
154
  var newRequest = (incoming, defaultHostname) => {
154
155
  const req = Object.create(requestPrototype);
155
156
  req[incomingKey] = incoming;
157
+ const incomingUrl = incoming.url || "";
158
+ if (incomingUrl[0] !== "/" && // short-circuit for performance. most requests are relative URL.
159
+ (incomingUrl.startsWith("http://") || incomingUrl.startsWith("https://"))) {
160
+ if (incoming instanceof Http2ServerRequest) {
161
+ throw new RequestError("Absolute URL for :path is not allowed in HTTP/2");
162
+ }
163
+ try {
164
+ const url2 = new URL(incomingUrl);
165
+ req[urlKey] = url2.href;
166
+ } catch (e2) {
167
+ throw new RequestError("Invalid absolute URL", { cause: e2 });
168
+ }
169
+ return req;
170
+ }
156
171
  const host = (incoming instanceof Http2ServerRequest ? incoming.authority : incoming.headers.host) || defaultHostname;
157
172
  if (!host) {
158
173
  throw new RequestError("Missing host header");
159
174
  }
160
- const url = new URL(
161
- `${incoming instanceof Http2ServerRequest || incoming.socket && incoming.socket.encrypted ? "https" : "http"}://${host}${incoming.url}`
162
- );
175
+ let scheme;
176
+ if (incoming instanceof Http2ServerRequest) {
177
+ scheme = incoming.scheme;
178
+ if (!(scheme === "http" || scheme === "https")) {
179
+ throw new RequestError("Unsupported scheme");
180
+ }
181
+ } else {
182
+ scheme = incoming.socket && incoming.socket.encrypted ? "https" : "http";
183
+ }
184
+ const url = new URL(`${scheme}://${host}${incomingUrl}`);
163
185
  if (url.hostname.length !== host.length && url.hostname !== host.replace(/:\d+$/, "")) {
164
186
  throw new RequestError("Invalid host header");
165
187
  }
166
188
  req[urlKey] = url.href;
167
189
  return req;
168
190
  };
169
- function writeFromReadableStream(stream3, writable) {
170
- if (stream3.locked) {
191
+ function writeFromReadableStream(stream4, writable) {
192
+ if (stream4.locked) {
171
193
  throw new TypeError("ReadableStream is locked.");
172
194
  } else if (writable.destroyed) {
173
- stream3.cancel();
195
+ stream4.cancel();
174
196
  return;
175
197
  }
176
- const reader = stream3.getReader();
198
+ const reader = stream4.getReader();
177
199
  writable.on("close", cancel);
178
200
  writable.on("error", cancel);
179
201
  reader.read().then(flow, cancel);
@@ -371,7 +393,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
371
393
  const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
372
394
  const internalBody = getInternalBody(res);
373
395
  if (internalBody) {
374
- const { length, source, stream: stream3 } = internalBody;
396
+ const { length, source, stream: stream4 } = internalBody;
375
397
  if (source instanceof Uint8Array && source.byteLength !== length) ; else {
376
398
  if (length) {
377
399
  resHeaderRecord["content-length"] = length;
@@ -382,7 +404,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
382
404
  } else if (source instanceof Blob) {
383
405
  outgoing.end(new Uint8Array(await source.arrayBuffer()));
384
406
  } else {
385
- await writeFromReadableStream(stream3, outgoing);
407
+ await writeFromReadableStream(stream4, outgoing);
386
408
  }
387
409
  return;
388
410
  }
@@ -455,7 +477,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
455
477
  }
456
478
  }
457
479
  try {
458
- return responseViaResponseObject(res, outgoing, options);
480
+ return await responseViaResponseObject(res, outgoing, options);
459
481
  } catch (e2) {
460
482
  return handleResponseError(e2, outgoing);
461
483
  }
@@ -486,18 +508,18 @@ var ENCODINGS = {
486
508
  gzip: ".gz"
487
509
  };
488
510
  var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
489
- var createStreamBody = (stream3) => {
511
+ var createStreamBody = (stream4) => {
490
512
  const body = new ReadableStream({
491
513
  start(controller) {
492
- stream3.on("data", (chunk) => {
514
+ stream4.on("data", (chunk) => {
493
515
  controller.enqueue(chunk);
494
516
  });
495
- stream3.on("end", () => {
517
+ stream4.on("end", () => {
496
518
  controller.close();
497
519
  });
498
520
  },
499
521
  cancel() {
500
- stream3.destroy();
522
+ stream4.destroy();
501
523
  }
502
524
  });
503
525
  return body;
@@ -593,10 +615,10 @@ var serveStatic = (options = { root: "" }) => {
593
615
  end = size - 1;
594
616
  }
595
617
  const chunksize = end - start + 1;
596
- const stream3 = createReadStream(path, { start, end });
618
+ const stream4 = createReadStream(path, { start, end });
597
619
  c2.header("Content-Length", chunksize.toString());
598
620
  c2.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
599
- return c2.body(createStreamBody(stream3), 206);
621
+ return c2.body(createStreamBody(stream4), 206);
600
622
  };
601
623
  };
602
624
  var RENDER_TYPE = {
@@ -717,7 +739,7 @@ var middleware = (options) => async (c2) => {
717
739
  );
718
740
  };
719
741
 
720
- // ../../node_modules/.pnpm/hono-openapi@0.4.6_hono@4.7.4_openapi-types@12.1.3_zod@3.24.3/node_modules/hono-openapi/utils.js
742
+ // ../../node_modules/.pnpm/hono-openapi@0.4.6_hono@4.7.7_openapi-types@12.1.3_zod@3.24.4/node_modules/hono-openapi/utils.js
721
743
  var e = Symbol("openapi");
722
744
  var s2 = ["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"];
723
745
  var n = (e2) => e2.charAt(0).toUpperCase() + e2.slice(1);
@@ -843,6 +865,59 @@ async function x(e2, t2, s3 = {}) {
843
865
  }
844
866
  return { docs: o2, components: n2 };
845
867
  }
868
+ async function getAgentCardByIdHandler(c2) {
869
+ const mastra = c2.get("mastra");
870
+ const agentId = c2.req.param("agentId");
871
+ const runtimeContext = c2.get("runtimeContext");
872
+ const result = await getAgentCardByIdHandler$1({
873
+ mastra,
874
+ agentId,
875
+ runtimeContext
876
+ });
877
+ return c2.json(result);
878
+ }
879
+ async function getAgentExecutionHandler(c2) {
880
+ const mastra = c2.get("mastra");
881
+ const agentId = c2.req.param("agentId");
882
+ const runtimeContext = c2.get("runtimeContext");
883
+ const logger2 = mastra.getLogger();
884
+ const body = await c2.req.json();
885
+ if (!["tasks/send", "tasks/sendSubscribe", "tasks/get", "tasks/cancel"].includes(body.method)) {
886
+ return c2.json({ error: { message: `Unsupported method: ${body.method}`, code: "invalid_method" } }, 400);
887
+ }
888
+ const result = await getAgentExecutionHandler$1({
889
+ mastra,
890
+ agentId,
891
+ runtimeContext,
892
+ requestId: randomUUID(),
893
+ method: body.method,
894
+ params: body.params,
895
+ logger: logger2
896
+ });
897
+ if (body.method === "tasks/sendSubscribe") {
898
+ return stream(
899
+ c2,
900
+ async (stream4) => {
901
+ try {
902
+ stream4.onAbort(() => {
903
+ if (!result.locked) {
904
+ return result.cancel();
905
+ }
906
+ });
907
+ for await (const chunk of result) {
908
+ await stream4.write(JSON.stringify(chunk) + "");
909
+ }
910
+ } catch (err) {
911
+ logger2.error("Error in tasks/sendSubscribe stream: " + err?.message);
912
+ }
913
+ },
914
+ async (err) => {
915
+ logger2.error("Error in tasks/sendSubscribe stream: " + err?.message);
916
+ }
917
+ );
918
+ }
919
+ return c2.json(result);
920
+ }
846
921
  function handleError(error, defaultMessage) {
847
922
  const apiError = error;
848
923
  throw new HTTPException(apiError.status || 500, {
@@ -963,7 +1038,7 @@ async function setAgentInstructionsHandler(c2) {
963
1038
  // src/server/handlers/client.ts
964
1039
  var clients = /* @__PURE__ */ new Set();
965
1040
  function handleClientsRefresh(c2) {
966
- const stream3 = new ReadableStream({
1041
+ const stream4 = new ReadableStream({
967
1042
  start(controller) {
968
1043
  clients.add(controller);
969
1044
  controller.enqueue("data: connected\n\n");
@@ -972,7 +1047,7 @@ function handleClientsRefresh(c2) {
972
1047
  });
973
1048
  }
974
1049
  });
975
- return new Response(stream3, {
1050
+ return new Response(stream4, {
976
1051
  headers: {
977
1052
  "Content-Type": "text/event-stream",
978
1053
  "Cache-Control": "no-cache",
@@ -1392,13 +1467,14 @@ function executeToolHandler(tools) {
1392
1467
  const runtimeContext = c2.get("runtimeContext");
1393
1468
  const toolId = decodeURIComponent(c2.req.param("toolId"));
1394
1469
  const runId = c2.req.query("runId");
1395
- const { data } = await c2.req.json();
1470
+ const { data, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
1396
1471
  const result = await executeToolHandler$1(tools)({
1397
1472
  mastra,
1398
1473
  toolId,
1399
1474
  data,
1400
1475
  runtimeContext,
1401
- runId
1476
+ runId,
1477
+ runtimeContextFromRequest
1402
1478
  });
1403
1479
  return c2.json(result);
1404
1480
  } catch (error) {
@@ -1412,13 +1488,14 @@ async function executeAgentToolHandler(c2) {
1412
1488
  const runtimeContext = c2.get("runtimeContext");
1413
1489
  const agentId = c2.req.param("agentId");
1414
1490
  const toolId = c2.req.param("toolId");
1415
- const { data } = await c2.req.json();
1491
+ const { data, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
1416
1492
  const result = await executeAgentToolHandler$1({
1417
1493
  mastra,
1418
1494
  agentId,
1419
1495
  toolId,
1420
1496
  data,
1421
- runtimeContext
1497
+ runtimeContext,
1498
+ runtimeContextFromRequest
1422
1499
  });
1423
1500
  return c2.json(result);
1424
1501
  } catch (error) {
@@ -1566,11 +1643,13 @@ async function startAsyncVNextWorkflowHandler(c2) {
1566
1643
  try {
1567
1644
  const mastra = c2.get("mastra");
1568
1645
  const workflowId = c2.req.param("workflowId");
1569
- const { inputData, runtimeContext } = await c2.req.json();
1646
+ const runtimeContext = c2.get("runtimeContext");
1647
+ const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
1570
1648
  const runId = c2.req.query("runId");
1571
1649
  const result = await startAsyncVNextWorkflowHandler$1({
1572
1650
  mastra,
1573
1651
  runtimeContext,
1652
+ runtimeContextFromRequest,
1574
1653
  workflowId,
1575
1654
  runId,
1576
1655
  inputData
@@ -1584,11 +1663,13 @@ async function startVNextWorkflowRunHandler(c2) {
1584
1663
  try {
1585
1664
  const mastra = c2.get("mastra");
1586
1665
  const workflowId = c2.req.param("workflowId");
1587
- const { inputData, runtimeContext } = await c2.req.json();
1666
+ const runtimeContext = c2.get("runtimeContext");
1667
+ const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
1588
1668
  const runId = c2.req.query("runId");
1589
1669
  await startVNextWorkflowRunHandler$1({
1590
1670
  mastra,
1591
1671
  runtimeContext,
1672
+ runtimeContextFromRequest,
1592
1673
  workflowId,
1593
1674
  runId,
1594
1675
  inputData
@@ -1609,20 +1690,20 @@ function watchVNextWorkflowHandler(c2) {
1609
1690
  }
1610
1691
  return stream(
1611
1692
  c2,
1612
- async (stream3) => {
1693
+ async (stream4) => {
1613
1694
  try {
1614
1695
  const result = await watchVNextWorkflowHandler$1({
1615
1696
  mastra,
1616
1697
  workflowId,
1617
1698
  runId
1618
1699
  });
1619
- stream3.onAbort(() => {
1700
+ stream4.onAbort(() => {
1620
1701
  if (!result.locked) {
1621
1702
  return result.cancel();
1622
1703
  }
1623
1704
  });
1624
1705
  for await (const chunk of result) {
1625
- await stream3.write(chunk.toString() + "");
1706
+ await stream4.write(chunk.toString() + "");
1626
1707
  }
1627
1708
  } catch (err) {
1628
1709
  console.log(err);
@@ -1641,13 +1722,15 @@ async function resumeAsyncVNextWorkflowHandler(c2) {
1641
1722
  const mastra = c2.get("mastra");
1642
1723
  const workflowId = c2.req.param("workflowId");
1643
1724
  const runId = c2.req.query("runId");
1644
- const { step, resumeData, runtimeContext } = await c2.req.json();
1725
+ const runtimeContext = c2.get("runtimeContext");
1726
+ const { step, resumeData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
1645
1727
  if (!runId) {
1646
1728
  throw new HTTPException(400, { message: "runId required to resume workflow" });
1647
1729
  }
1648
1730
  const result = await resumeAsyncVNextWorkflowHandler$1({
1649
1731
  mastra,
1650
1732
  runtimeContext,
1733
+ runtimeContextFromRequest,
1651
1734
  workflowId,
1652
1735
  runId,
1653
1736
  body: { step, resumeData }
@@ -1844,20 +1927,20 @@ function watchWorkflowHandler(c2) {
1844
1927
  }
1845
1928
  return stream(
1846
1929
  c2,
1847
- async (stream3) => {
1930
+ async (stream4) => {
1848
1931
  try {
1849
1932
  const result = await watchWorkflowHandler$1({
1850
1933
  mastra,
1851
1934
  workflowId,
1852
1935
  runId
1853
1936
  });
1854
- stream3.onAbort(() => {
1937
+ stream4.onAbort(() => {
1855
1938
  if (!result.locked) {
1856
1939
  return result.cancel();
1857
1940
  }
1858
1941
  });
1859
1942
  for await (const chunk of result) {
1860
- await stream3.write(chunk.toString() + "");
1943
+ await stream4.write(chunk.toString() + "");
1861
1944
  }
1862
1945
  } catch (err) {
1863
1946
  console.log(err);
@@ -2087,7 +2170,18 @@ async function createHonoServer(mastra, options = {}) {
2087
2170
  app.onError(errorHandler);
2088
2171
  app.use("*", function setContext(c2, next) {
2089
2172
  const runtimeContext = new RuntimeContext();
2090
- c2.set("runtimeContext", runtimeContext);
2173
+ const proxyRuntimeContext = new Proxy(runtimeContext, {
2174
+ get(target, prop) {
2175
+ if (prop === "get") {
2176
+ return function(key) {
2177
+ const value = target.get(key);
2178
+ return value ?? `<${key}>`;
2179
+ };
2180
+ }
2181
+ return Reflect.get(target, prop);
2182
+ }
2183
+ });
2184
+ c2.set("runtimeContext", proxyRuntimeContext);
2091
2185
  c2.set("mastra", mastra);
2092
2186
  c2.set("tools", tools);
2093
2187
  c2.set("playground", options.playground === true);
@@ -2161,6 +2255,142 @@ async function createHonoServer(mastra, options = {}) {
2161
2255
  if (server?.build?.apiReqLogs) {
2162
2256
  app.use(logger());
2163
2257
  }
2258
+ app.get(
2259
+ "/.well-known/:agentId/agent.json",
2260
+ h({
2261
+ description: "Get agent configuration",
2262
+ tags: ["agents"],
2263
+ parameters: [
2264
+ {
2265
+ name: "agentId",
2266
+ in: "path",
2267
+ required: true,
2268
+ schema: { type: "string" }
2269
+ }
2270
+ ],
2271
+ responses: {
2272
+ 200: {
2273
+ description: "Agent configuration"
2274
+ }
2275
+ }
2276
+ }),
2277
+ getAgentCardByIdHandler
2278
+ );
2279
+ app.post(
2280
+ "/a2a/:agentId",
2281
+ h({
2282
+ description: "Execute agent via A2A protocol",
2283
+ tags: ["agents"],
2284
+ parameters: [
2285
+ {
2286
+ name: "agentId",
2287
+ in: "path",
2288
+ required: true,
2289
+ schema: { type: "string" }
2290
+ }
2291
+ ],
2292
+ requestBody: {
2293
+ required: true,
2294
+ content: {
2295
+ "application/json": {
2296
+ schema: {
2297
+ type: "object",
2298
+ properties: {
2299
+ method: {
2300
+ type: "string",
2301
+ enum: ["tasks/send", "tasks/sendSubscribe", "tasks/get", "tasks/cancel"],
2302
+ description: "The A2A protocol method to execute"
2303
+ },
2304
+ params: {
2305
+ type: "object",
2306
+ oneOf: [
2307
+ {
2308
+ // TaskSendParams
2309
+ type: "object",
2310
+ properties: {
2311
+ id: {
2312
+ type: "string",
2313
+ description: "Unique identifier for the task being initiated or continued"
2314
+ },
2315
+ sessionId: {
2316
+ type: "string",
2317
+ description: "Optional identifier for the session this task belongs to"
2318
+ },
2319
+ message: {
2320
+ type: "object",
2321
+ description: "The message content to send to the agent for processing"
2322
+ },
2323
+ pushNotification: {
2324
+ type: "object",
2325
+ nullable: true,
2326
+ description: "Optional pushNotification information for receiving notifications about this task"
2327
+ },
2328
+ historyLength: {
2329
+ type: "integer",
2330
+ nullable: true,
2331
+ description: "Optional parameter to specify how much message history to include in the response"
2332
+ },
2333
+ metadata: {
2334
+ type: "object",
2335
+ nullable: true,
2336
+ description: "Optional metadata associated with sending this message"
2337
+ }
2338
+ },
2339
+ required: ["id", "message"]
2340
+ },
2341
+ {
2342
+ // TaskQueryParams
2343
+ type: "object",
2344
+ properties: {
2345
+ id: { type: "string", description: "The unique identifier of the task" },
2346
+ historyLength: {
2347
+ type: "integer",
2348
+ nullable: true,
2349
+ description: "Optional history length to retrieve for the task"
2350
+ },
2351
+ metadata: {
2352
+ type: "object",
2353
+ nullable: true,
2354
+ description: "Optional metadata to include with the operation"
2355
+ }
2356
+ },
2357
+ required: ["id"]
2358
+ },
2359
+ {
2360
+ // TaskIdParams
2361
+ type: "object",
2362
+ properties: {
2363
+ id: { type: "string", description: "The unique identifier of the task" },
2364
+ metadata: {
2365
+ type: "object",
2366
+ nullable: true,
2367
+ description: "Optional metadata to include with the operation"
2368
+ }
2369
+ },
2370
+ required: ["id"]
2371
+ }
2372
+ ]
2373
+ }
2374
+ },
2375
+ required: ["method", "params"]
2376
+ }
2377
+ }
2378
+ }
2379
+ },
2380
+ responses: {
2381
+ 200: {
2382
+ description: "A2A response"
2383
+ },
2384
+ 400: {
2385
+ description: "Missing or invalid request parameters"
2386
+ },
2387
+ 404: {
2388
+ description: "Agent not found"
2389
+ }
2390
+ }
2391
+ }),
2392
+ getAgentExecutionHandler
2393
+ );
2164
2394
  app.get(
2165
2395
  "/api",
2166
2396
  h({
@@ -3001,7 +3231,8 @@ async function createHonoServer(mastra, options = {}) {
3001
3231
  schema: {
3002
3232
  type: "object",
3003
3233
  properties: {
3004
- data: { type: "object" }
3234
+ data: { type: "object" },
3235
+ runtimeContext: { type: "object" }
3005
3236
  },
3006
3237
  required: ["data"]
3007
3238
  }
@@ -3388,7 +3619,10 @@ async function createHonoServer(mastra, options = {}) {
3388
3619
  oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
3389
3620
  },
3390
3621
  resumeData: { type: "object" },
3391
- runtimeContext: { type: "object" }
3622
+ runtimeContext: {
3623
+ type: "object",
3624
+ description: "Runtime context for the workflow execution"
3625
+ }
3392
3626
  },
3393
3627
  required: ["step"]
3394
3628
  }
@@ -3429,7 +3663,10 @@ async function createHonoServer(mastra, options = {}) {
3429
3663
  oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
3430
3664
  },
3431
3665
  resumeData: { type: "object" },
3432
- runtimeContext: { type: "object" }
3666
+ runtimeContext: {
3667
+ type: "object",
3668
+ description: "Runtime context for the workflow execution"
3669
+ }
3433
3670
  },
3434
3671
  required: ["step"]
3435
3672
  }
@@ -3495,7 +3732,10 @@ async function createHonoServer(mastra, options = {}) {
3495
3732
  type: "object",
3496
3733
  properties: {
3497
3734
  inputData: { type: "object" },
3498
- runtimeContext: { type: "object" }
3735
+ runtimeContext: {
3736
+ type: "object",
3737
+ description: "Runtime context for the workflow execution"
3738
+ }
3499
3739
  }
3500
3740
  }
3501
3741
  }
@@ -3539,7 +3779,10 @@ async function createHonoServer(mastra, options = {}) {
3539
3779
  type: "object",
3540
3780
  properties: {
3541
3781
  inputData: { type: "object" },
3542
- runtimeContext: { type: "object" }
3782
+ runtimeContext: {
3783
+ type: "object",
3784
+ description: "Runtime context for the workflow execution"
3785
+ }
3543
3786
  }
3544
3787
  }
3545
3788
  }
@@ -4066,7 +4309,8 @@ async function createHonoServer(mastra, options = {}) {
4066
4309
  schema: {
4067
4310
  type: "object",
4068
4311
  properties: {
4069
- data: { type: "object" }
4312
+ data: { type: "object" },
4313
+ runtimeContext: { type: "object" }
4070
4314
  },
4071
4315
  required: ["data"]
4072
4316
  }
@@ -4359,7 +4603,7 @@ async function createNodeServer(mastra, options = {}) {
4359
4603
  const host = serverOptions?.host ?? "localhost";
4360
4604
  logger2.info(` Mastra API running on port http://${host}:${port}/api`);
4361
4605
  if (options?.isDev) {
4362
- logger2.info(`\uFFFD Open API documentation available at http://${host}:${port}/openapi.json`);
4606
+ logger2.info(`\u{1F517} Open API documentation available at http://${host}:${port}/openapi.json`);
4363
4607
  }
4364
4608
  if (options?.isDev) {
4365
4609
  logger2.info(`\u{1F9EA} Swagger UI available at http://${host}:${port}/swagger-ui`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/deployer",
3
- "version": "0.3.3-alpha.1",
3
+ "version": "0.3.4-alpha.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -107,8 +107,8 @@
107
107
  "rollup-plugin-node-externals": "^8.0.0",
108
108
  "typescript-paths": "^1.5.1",
109
109
  "zod": "^3.24.3",
110
- "@mastra/core": "^0.9.3-alpha.1",
111
- "@mastra/server": "^2.0.3-alpha.1"
110
+ "@mastra/core": "^0.9.4-alpha.0",
111
+ "@mastra/server": "^2.0.4-alpha.0"
112
112
  },
113
113
  "devDependencies": {
114
114
  "@hono/node-server": "^1.13.8",
@@ -128,7 +128,7 @@
128
128
  "typescript": "^5.8.2",
129
129
  "vitest": "^2.1.9",
130
130
  "zod-to-json-schema": "^3.24.5",
131
- "@internal/lint": "0.0.3"
131
+ "@internal/lint": "0.0.4"
132
132
  },
133
133
  "scripts": {
134
134
  "build": "tsup src/index.ts src/build/index.ts src/server/index.ts src/build/bundler.ts src/build/analyze.ts src/bundler/index.ts src/services/index.ts src/validator/loader.ts src/validator/custom-resolver.ts --format esm,cjs --clean --experimental-dts --treeshake=smallest --splitting --publicDir",